improved hlep system
This commit is contained in:
1 parent
96d20979a6
commit
7a867d957e
1 file changed
+133
-1
+133
-1
@@ -459,7 +459,6 @@ void HelpDlg::prepareImprovement(int imp)
|
|||||||
|
|
||||||
mainText.lineFeed();
|
mainText.lineFeed();
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("COSTS")), TextFormat::Section);
|
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;
|
const int cost = difficulty == 0 ? Imp[imp].Cost : Imp[imp].Cost * BuildCostMod[difficulty] / 12;
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
||||||
if (Imp[imp].Maint > 0)
|
if (Imp[imp].Maint > 0)
|
||||||
@@ -618,6 +617,139 @@ void HelpDlg::prepareTerrain(int no)
|
|||||||
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HelpDlg::prepareFeature(int no)
|
||||||
|
{
|
||||||
|
if (no == 200) { // complete feature list, grouped by capacity/special/advance
|
||||||
|
for (int group = 0; group < 3; ++group) {
|
||||||
|
if (mainText.count() > 1) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.lineFeed();
|
||||||
|
}
|
||||||
|
switch (group) {
|
||||||
|
case 0: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE1LIST")), TextFormat::Section); break;
|
||||||
|
case 1: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE2LIST")), TextFormat::Section); break;
|
||||||
|
case 2: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE3LIST")), TextFormat::Section); break;
|
||||||
|
}
|
||||||
|
std::vector<QString> names;
|
||||||
|
std::vector<int> indices;
|
||||||
|
for (int i = 0; i < nFeature; ++i) {
|
||||||
|
if (Feature[i].Preq == preNA)
|
||||||
|
continue;
|
||||||
|
const int which = i < mcFirstNonCap ? 0 : (AutoFeature & (1u << i)) ? 2 : 1;
|
||||||
|
if (which == group) {
|
||||||
|
names.push_back(phrases.lookup(QStringLiteral("FEATURES"), i));
|
||||||
|
indices.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::vector<std::size_t> order(names.size());
|
||||||
|
for (std::size_t i = 0; i < order.size(); ++i)
|
||||||
|
order[i] = i;
|
||||||
|
std::sort(order.begin(), order.end(),
|
||||||
|
[&names](std::size_t a, std::size_t b) { return names[a] < names[b]; });
|
||||||
|
for (std::size_t i : order)
|
||||||
|
mainText.addLine(names[i], TextFormat::Feature, 0, LinkCategory::Feature, indices[i], true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (no < mcFirstNonCap)
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_CAP")));
|
||||||
|
else if (AutoFeature & (1u << no))
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_STANDARD")));
|
||||||
|
else
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_FEATURE")));
|
||||||
|
|
||||||
|
const QString effect = helpText.lookup(QStringLiteral("FEATUREHELP"), no);
|
||||||
|
if (!effect.isEmpty()) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("EFFECT")), TextFormat::Section);
|
||||||
|
mainText.addLine(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Feature[no].Weight != 0 || Feature[no].Cost != 0) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("COSTS")), TextFormat::Section);
|
||||||
|
QString cost = QString::number(Feature[no].Cost);
|
||||||
|
if (Feature[no].Cost >= 0)
|
||||||
|
cost = QLatin1Char('+') + cost;
|
||||||
|
mainText.addLine(formatS(helpText.lookup(QStringLiteral("COSTBASE")), cost));
|
||||||
|
if (Feature[no].Weight > 0) {
|
||||||
|
mainText.addLine(formatS(helpText.lookup(QStringLiteral("WEIGHT")),
|
||||||
|
QLatin1Char('+') + QString::number(Feature[no].Weight)));
|
||||||
|
if (no == mcDefense)
|
||||||
|
mainText.addLine(formatS(helpText.lookup(QStringLiteral("WEIGHT")), QStringLiteral("+2")),
|
||||||
|
TextFormat::Domain, dGround);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Feature[no].Preq != preNone) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
if (Feature[no].Preq == preSun)
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woSun), TextFormat::SmallIconAsPreq, 0,
|
||||||
|
LinkCategory::Imp, woSun, true);
|
||||||
|
else
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), Feature[no].Preq), TextFormat::AdvIconAsPreq,
|
||||||
|
0, LinkCategory::Adv, Feature[no].Preq, true);
|
||||||
|
mainText.text(mainText.count() - 1) =
|
||||||
|
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
HyperText seeAlso;
|
||||||
|
appendSeeAlsoEntries(seeAlso, LinkCategory::Feature, no);
|
||||||
|
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::prepareModel(int)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nSpecialModel; ++i) {
|
||||||
|
if (i == 2) // skip pixSlaves/pixNoSlaves-style gap, matches the original
|
||||||
|
continue;
|
||||||
|
if (mainText.count() > 1) {
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.lineFeed();
|
||||||
|
}
|
||||||
|
int pix = 0;
|
||||||
|
QString name;
|
||||||
|
Tribes::findStdModelPicture(Term::SpecialModelPictureCode[static_cast<std::size_t>(i)], pix, name);
|
||||||
|
mainText.addLine(name, TextFormat::Section);
|
||||||
|
mainText.addLine(formatArgs(helpText.lookup(QStringLiteral("STRENGTH")),
|
||||||
|
{ QString::number(SpecialModel[i].Attack), QString::number(SpecialModel[i].Defense) }));
|
||||||
|
mainText.addLine(formatS(helpText.lookup(QStringLiteral("SPEED")), movementToString(SpecialModel[i].Speed)),
|
||||||
|
TextFormat::Model, pix);
|
||||||
|
const int cost =
|
||||||
|
difficulty == 0 ? SpecialModel[i].Cost : SpecialModel[i].Cost * BuildCostMod[difficulty] / 12;
|
||||||
|
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
||||||
|
const QString special = helpText.lookup(QStringLiteral("SPECIALMODEL"), i);
|
||||||
|
if (!special.isEmpty() && special != QLatin1String("*"))
|
||||||
|
mainText.addLine(special);
|
||||||
|
if (SpecialModelPreq[i] >= 0)
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), SpecialModelPreq[i]),
|
||||||
|
TextFormat::AdvIconAsPreq, 0, LinkCategory::Adv, SpecialModelPreq[i], true);
|
||||||
|
else if (SpecialModelPreq[i] == preLighthouse)
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woLighthouse),
|
||||||
|
TextFormat::SmallIconAsPreq, 0, LinkCategory::Imp, woLighthouse, true);
|
||||||
|
else if (SpecialModelPreq[i] == preBuilder)
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woPyramids), TextFormat::SmallIconAsPreq,
|
||||||
|
0, LinkCategory::Imp, woPyramids, true);
|
||||||
|
else if (SpecialModelPreq[i] == preLeo)
|
||||||
|
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woLeo), TextFormat::SmallIconAsPreq, 0,
|
||||||
|
LinkCategory::Imp, woLeo, true);
|
||||||
|
if (SpecialModelPreq[i] != preNone)
|
||||||
|
mainText.text(mainText.count() - 1) =
|
||||||
|
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
||||||
|
}
|
||||||
|
mainText.lineFeed();
|
||||||
|
mainText.addLine(helpText.lookup(QStringLiteral("MODELNOTE")));
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in new issue
Block a user