finish city improvment
This commit is contained in:
1 parent
92d75cac5d
commit
daa1d9056e
5 files changed
+91
-11
No files matched your search
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
#include "ClientTools.h"
|
||||
#include "Global.h"
|
||||
#include "Inp.h"
|
||||
#include "KeyBindings.h"
|
||||
@@ -214,6 +215,8 @@ void HelpDlg::prepare(int sbPos)
|
||||
mainText.appendList(searchResult);
|
||||
} else if (kind == LinkCategory::Adv && no >= 0 && no < nAdv) {
|
||||
prepareAdvance(no);
|
||||
} else if (kind == LinkCategory::Imp && no >= 0 && no < nImp) {
|
||||
prepareImprovement(no);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
const int idx = scrollBar->position() + i;
|
||||
|
||||
Reference in new issue
Block a user