finish city improvment
This commit is contained in:
1 parent
92d75cac5d
commit
daa1d9056e
5 files changed
+91
-11
No files matched your search
@@ -148,7 +148,7 @@ QString phrase(const QString &key)
|
|||||||
|
|
||||||
QString impName(int iix)
|
QString impName(int iix)
|
||||||
{
|
{
|
||||||
return QStringLiteral("Improvement #%1").arg(iix);
|
return phrases.lookup(QStringLiteral("IMPROVEMENTS"), iix);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString modelName(int cOwner, int mix)
|
QString modelName(int cOwner, int mix)
|
||||||
@@ -158,7 +158,7 @@ QString modelName(int cOwner, int mix)
|
|||||||
|
|
||||||
QString governmentName(int gov)
|
QString governmentName(int gov)
|
||||||
{
|
{
|
||||||
return QStringLiteral("Government #%1").arg(gov);
|
return phrases.lookup(QStringLiteral("GOVERNMENT"), gov);
|
||||||
}
|
}
|
||||||
|
|
||||||
void play(const QString &item)
|
void play(const QString &item)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "Cevo/CevoScreenTools.h"
|
#include "Cevo/CevoScreenTools.h"
|
||||||
#include "Cevo/CevoTexture.h"
|
#include "Cevo/CevoTexture.h"
|
||||||
#include "ClientTools.h"
|
#include "ClientTools.h"
|
||||||
|
#include "Global.h"
|
||||||
#include "Term.h"
|
#include "Term.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@@ -58,18 +59,12 @@ QString phrase(const QString &key)
|
|||||||
|
|
||||||
QString phraseCityType(int ctype)
|
QString phraseCityType(int ctype)
|
||||||
{
|
{
|
||||||
static const QHash<int, QString> table = {
|
return phrases.lookup(QStringLiteral("CITYTYPE"), ctype);
|
||||||
{0, QStringLiteral("Type A")}, {1, QStringLiteral("Type B")},
|
|
||||||
{2, QStringLiteral("Type C")}, {3, QStringLiteral("Type D")},
|
|
||||||
};
|
|
||||||
const auto it = table.constFind(ctype);
|
|
||||||
return it != table.constEnd() ? it.value() : QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString phraseImprovement(int iix)
|
QString phraseImprovement(int iix)
|
||||||
{
|
{
|
||||||
// Imp[]'s display names (StringTables.pas) aren't ported.
|
return phrases.lookup(QStringLiteral("IMPROVEMENTS"), iix);
|
||||||
return QStringLiteral("Improvement #%1").arg(iix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int xList = 7;
|
constexpr int xList = 7;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
#include "Cevo/CevoScreenTools.h"
|
#include "Cevo/CevoScreenTools.h"
|
||||||
#include "Cevo/Protocol.h"
|
#include "Cevo/Protocol.h"
|
||||||
|
#include "ClientTools.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Inp.h"
|
#include "Inp.h"
|
||||||
#include "KeyBindings.h"
|
#include "KeyBindings.h"
|
||||||
@@ -214,6 +215,8 @@ void HelpDlg::prepare(int sbPos)
|
|||||||
mainText.appendList(searchResult);
|
mainText.appendList(searchResult);
|
||||||
} else if (kind == LinkCategory::Adv && no >= 0 && no < nAdv) {
|
} else if (kind == LinkCategory::Adv && no >= 0 && no < nAdv) {
|
||||||
prepareAdvance(no);
|
prepareAdvance(no);
|
||||||
|
} else if (kind == LinkCategory::Imp && no >= 0 && no < nImp) {
|
||||||
|
prepareImprovement(no);
|
||||||
} else {
|
} else {
|
||||||
mainText.addLine(QStringLiteral("Detailed help content isn't available in this build."));
|
mainText.addLine(QStringLiteral("Detailed help content isn't available in this build."));
|
||||||
}
|
}
|
||||||
@@ -299,6 +302,86 @@ void HelpDlg::prepareAdvance(int advance)
|
|||||||
addSection(QStringLiteral("FOLLOWADV"), follow);
|
addSection(QStringLiteral("FOLLOWADV"), follow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HelpDlg::prepareImprovement(int imp)
|
||||||
|
{
|
||||||
|
const auto addSection = [this](const QString &headerKey, const HyperText &entries) {
|
||||||
|
if (entries.count() == 0)
|
||||||
|
return;
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(headerKey), TextFormat::Section);
|
||||||
|
mainText.appendList(entries);
|
||||||
|
};
|
||||||
|
const auto formatD = [](QString fmt, int value) {
|
||||||
|
fmt.replace(QStringLiteral("%d"), QString::number(value));
|
||||||
|
fmt.replace(QStringLiteral("%%"), QStringLiteral("%"));
|
||||||
|
return fmt;
|
||||||
|
};
|
||||||
|
const auto formatS = [](QString fmt, const QString &value) {
|
||||||
|
fmt.replace(QStringLiteral("%s"), value);
|
||||||
|
fmt.replace(QStringLiteral("%%"), QStringLiteral("%"));
|
||||||
|
return fmt;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (Imp[imp].Kind) {
|
||||||
|
case ikWonder: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_WONDER"))); break;
|
||||||
|
case ikCommon: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_IMP"))); break;
|
||||||
|
case ikShipPart: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_SHIPPART"))); break;
|
||||||
|
default: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_NAT"))); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Imp[imp].Kind != ikShipPart) {
|
||||||
|
const QString effect = helpText.lookup(QStringLiteral("IMPHELP"), imp);
|
||||||
|
if (!effect.isEmpty()) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("EFFECT")), TextFormat::Section);
|
||||||
|
mainText.addLine(effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HyperText preqs;
|
||||||
|
if (Imp[imp].Preq != preNone)
|
||||||
|
preqs.addLine(phrases.lookup(QStringLiteral("ADVANCES"), Imp[imp].Preq), TextFormat::AdvIconAsPreq, 0,
|
||||||
|
LinkCategory::Adv, Imp[imp].Preq, true);
|
||||||
|
addSection(QStringLiteral("PREREQ"), preqs);
|
||||||
|
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("COSTS")), TextFormat::Section);
|
||||||
|
const int difficulty = ClientTools::g.Difficulty[ClientTools::me];
|
||||||
|
const int cost = difficulty == 0 ? Imp[imp].Cost : Imp[imp].Cost * BuildCostMod[difficulty] / 12;
|
||||||
|
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
||||||
|
if (Imp[imp].Maint > 0)
|
||||||
|
mainText.addLine(formatD(helpText.lookup(QStringLiteral("MAINTCOST")), Imp[imp].Maint));
|
||||||
|
|
||||||
|
HyperText replaces;
|
||||||
|
for (int i = 0; i < nImpReplacement; ++i) {
|
||||||
|
if (ImpReplacement[i].NewImp == imp)
|
||||||
|
replaces.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), ImpReplacement[i].OldImp),
|
||||||
|
TextFormat::SmallIcon, 0, LinkCategory::Imp, ImpReplacement[i].OldImp, true);
|
||||||
|
}
|
||||||
|
addSection(QStringLiteral("REPLACE"), replaces);
|
||||||
|
|
||||||
|
if (imp < nWonder && Imp[imp].Expiration >= 0) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("EXPIRATION")), TextFormat::Section);
|
||||||
|
mainText.addLine(formatS(helpText.lookup(QStringLiteral("EXPWITH")),
|
||||||
|
phrases.lookup(QStringLiteral("ADVANCES"), Imp[imp].Expiration)));
|
||||||
|
}
|
||||||
|
|
||||||
|
HyperText seeAlso;
|
||||||
|
if (imp < nWonder && Imp[imp].Expiration >= 0)
|
||||||
|
seeAlso.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woEiffel), TextFormat::SmallIcon, 0,
|
||||||
|
LinkCategory::Imp, woEiffel, true);
|
||||||
|
for (int i = 0; i < nImpReplacement; ++i) {
|
||||||
|
if (ImpReplacement[i].OldImp == imp)
|
||||||
|
seeAlso.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), ImpReplacement[i].NewImp),
|
||||||
|
TextFormat::SmallIcon, 0, LinkCategory::Imp, ImpReplacement[i].NewImp, true);
|
||||||
|
}
|
||||||
|
if (imp == imSupermarket)
|
||||||
|
seeAlso.addLine(helpText.lookup(QStringLiteral("HELPTITLE_JOBLIST")), TextFormat::Normal, 0,
|
||||||
|
LinkCategory::Misc, static_cast<int>(MiscLinkIndex::JobList), true);
|
||||||
|
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
||||||
|
}
|
||||||
|
|
||||||
void HelpDlg::line(Dpi::Canvas &canvas, int i, bool lit)
|
void HelpDlg::line(Dpi::Canvas &canvas, int i, bool lit)
|
||||||
{
|
{
|
||||||
const int idx = scrollBar->position() + i;
|
const int idx = scrollBar->position() + i;
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ private:
|
|||||||
// THelpDlg.Prepare's hkAdv branch): prerequisites, and what the advance
|
// THelpDlg.Prepare's hkAdv branch): prerequisites, and what the advance
|
||||||
// newly allows (governments/improvements/features/further research).
|
// newly allows (governments/improvements/features/further research).
|
||||||
void prepareAdvance(int advance);
|
void prepareAdvance(int advance);
|
||||||
|
// Same idea as prepareAdvance(), for LinkCategory::Imp pages.
|
||||||
|
void prepareImprovement(int imp);
|
||||||
void search(const QString &searchString);
|
void search(const QString &searchString);
|
||||||
void line(Dpi::Canvas &canvas, int i, bool lit);
|
void line(Dpi::Canvas &canvas, int i, bool lit);
|
||||||
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
|
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
|
||||||
|
|||||||
@@ -987,7 +987,7 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
|
|||||||
break;
|
break;
|
||||||
case ListKind::Project: {
|
case ListKind::Project: {
|
||||||
if (lix & cpType) {
|
if (lix & cpType) {
|
||||||
s = impName(lix & cpIndex); // CITYTYPE phrase not ported; reuses imp placeholder naming
|
s = phrases.lookup(QStringLiteral("CITYTYPE"), lix & cpIndex);
|
||||||
} else if ((lix & cpImp) == 0) {
|
} else if ((lix & cpImp) == 0) {
|
||||||
s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix & cpIndex);
|
s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix & cpIndex);
|
||||||
if (lix & cpConscripts)
|
if (lix & cpConscripts)
|
||||||
|
|||||||
Reference in new issue
Block a user