improved help

This commit is contained in:
Geoffray Levasseur committed 2026-11-07 01:05:05 +01:00
1 parent 7d123a9542
commit d577a1efa3
10 files changed
+1576 -15

No files matched your search

+90 -14
View File
@@ -28,14 +28,15 @@
// PORT STATUS (see /memories/repo/cevo-evo-game.md): Help.pas is 2297
// lines; this is a deliberately SIMPLIFIED port. The navigation/history/
// search-plumbing/scrolling/link-click machinery is faithful, but
// prepare()/offscreenPaint()/line() render a plain single-paragraph
// placeholder per page instead of the original's full icon-rich,
// per-TextFormat layout engine (pkAdvIcon/pkBigIcon/pkTer/pkModel/...),
// because that engine's actual CONTENT comes from Help/Help.txt (loaded
// through the real StringTable, but the file isn't shipped in resources/
// yet). waterSign()/paintTerrIcon() (cosmetic pixel effects) are no-ops.
// Extend this file (not a new one) to port the real layout engine.
// search-plumbing/scrolling/link-click machinery is faithful. The real
// Help/Help.txt content is loaded (resources/Help/Help.txt is shipped) and
// used via the StringTable `helpText`/the global `phrases`. prepareAdvance()
// renders a reasonably faithful LinkCategory::Adv page (prereqs/governments/
// improvements/features/follow-on research it unlocks). Other categories
// (Imp/Ter/Feature/Model/Text) still render a plain placeholder paragraph
// instead of the original's full icon-rich, per-TextFormat layout engine
// (pkAdvIcon/pkBigIcon/pkTer/pkModel/...); extend prepare() similarly if
// needed. waterSign()/paintTerrIcon() (cosmetic pixel effects) are no-ops.
#include "Help.h"
#include "ui_Help.h"
@@ -186,10 +187,10 @@ void HelpDlg::prepare(int sbPos)
mainText.clear();
QString title;
switch (kind) {
case LinkCategory::Adv: title = QStringLiteral("Advance #%1").arg(no); break;
case LinkCategory::Imp: title = QStringLiteral("Improvement #%1").arg(no); break;
case LinkCategory::Ter: title = QStringLiteral("Terrain #%1").arg(no); break;
case LinkCategory::Feature: title = QStringLiteral("Feature #%1").arg(no); break;
case LinkCategory::Adv: title = phrases.lookup(QStringLiteral("ADVANCES"), no); break;
case LinkCategory::Imp: title = phrases.lookup(QStringLiteral("IMPROVEMENTS"), no); break;
case LinkCategory::Ter: title = phrases.lookup(QStringLiteral("TERRAIN"), no); break;
case LinkCategory::Feature: title = phrases.lookup(QStringLiteral("FEATURES"), no); break;
case LinkCategory::Model: title = QStringLiteral("Unit design #%1").arg(no); break;
case LinkCategory::Text: title = helpText.lookupByHandle(no); break;
case LinkCategory::Misc:
@@ -208,10 +209,13 @@ void HelpDlg::prepare(int sbPos)
mainText.addLine(title, TextFormat::Caption);
mainText.lineFeed();
if (kind == LinkCategory::Misc && static_cast<MiscLinkIndex>(no) == MiscLinkIndex::SearchResult)
if (kind == LinkCategory::Misc && static_cast<MiscLinkIndex>(no) == MiscLinkIndex::SearchResult) {
mainText.appendList(searchResult);
else
} else if (kind == LinkCategory::Adv && no >= 0 && no < nAdv) {
prepareAdvance(no);
} else {
mainText.addLine(QStringLiteral("Detailed help content isn't available in this build."));
}
mainText.lineFeed();
scrollBar->init(mainText.count() - 1, innerHeight / 24);
@@ -222,6 +226,78 @@ void HelpDlg::prepare(int sbPos)
sel = -1;
}
void HelpDlg::prepareAdvance(int advance)
{
// Section helper (NextSection in the original): only emits the section
// header + a blank line separator if the section actually has entries.
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 (IsFutureTech(advance)) {
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_FUTURE")));
mainText.lineFeed();
mainText.addLine(helpText.lookup(advance == futResearchTechnology ? QStringLiteral("FUTURETECHHELP100")
: QStringLiteral("FUTURETECHHELP25")));
} else {
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_ADV")));
}
HyperText preqs;
for (int i = 0; i < 3; ++i) {
if (AdvPreq[advance][i] != preNone)
preqs.addLine(phrases.lookup(QStringLiteral("ADVANCES"), AdvPreq[advance][i]), TextFormat::AdvIconAsPreq,
0, LinkCategory::Adv, AdvPreq[advance][i], true);
}
addSection(AdvPreq[advance][2] != preNone ? QStringLiteral("PREREQALT") : QStringLiteral("PREREQ"), preqs);
HyperText govs;
for (int i = 2; i < nGov; ++i) {
if (GovPreq[i] == advance)
govs.addLine(phrases.lookup(QStringLiteral("GOVERNMENT"), i), TextFormat::Gov, 0, LinkCategory::Misc,
static_cast<int>(MiscLinkIndex::GovList), true);
}
addSection(QStringLiteral("GOVALLOW"), govs);
HyperText imps;
for (int i = 0; i < nWonder; ++i) {
if (Imp[i].Preq == advance)
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
LinkCategory::Imp, i, true);
}
for (int i = nWonder; i < nImp; ++i) {
if (Imp[i].Preq == advance && Imp[i].Kind != ikCommon)
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
LinkCategory::Imp, i, true);
}
for (int i = nWonder; i < nImp; ++i) {
if (Imp[i].Preq == advance && Imp[i].Kind == ikCommon)
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
LinkCategory::Imp, i, true);
}
addSection(QStringLiteral("BUILDALLOW"), imps);
HyperText feats;
for (int i = 0; i < nFeature; ++i) {
if (Feature[i].Preq == advance)
feats.addLine(phrases.lookup(QStringLiteral("FEATURES"), i), TextFormat::Feature, 0,
LinkCategory::Feature, i, true);
}
addSection(QStringLiteral("FEATALLOW"), feats);
HyperText follow;
for (int i = 0; i < nAdv; ++i) {
if (AdvPreq[i][0] == advance || AdvPreq[i][1] == advance || AdvPreq[i][2] == advance)
follow.addLine(phrases.lookup(QStringLiteral("ADVANCES"), i), TextFormat::AdvIcon, 0, LinkCategory::Adv,
i, true);
}
addSection(QStringLiteral("FOLLOWADV"), follow);
}
void HelpDlg::line(Dpi::Canvas &canvas, int i, bool lit)
{
const int idx = scrollBar->position() + i;
+4
View File
@@ -133,6 +133,10 @@ protected:
private:
void prepare(int sbPos = 0);
// Builds mainText's body for a single LinkCategory::Adv page (Help.pas's
// THelpDlg.Prepare's hkAdv branch): prerequisites, and what the advance
// newly allows (governments/improvements/features/further research).
void prepareAdvance(int advance);
void search(const QString &searchString);
void line(Dpi::Canvas &canvas, int i, bool lit);
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
+1 -1
View File
@@ -33,7 +33,7 @@
# load it from CMAKE_INSTALL_RESOURCEDIR (see CEVO_RESOURCE_DIR, defined for
# the c-evo-evo target in the top-level CMakeLists.txt).
install(DIRECTORY Graphics Music Sounds Localization Tribes Maps Saved
install(DIRECTORY Graphics Music Sounds Localization Tribes Maps Saved Help
DESTINATION ${CMAKE_INSTALL_RESOURCEDIR}
)
# English (default) texts; localized ones live in Localization/<locale>/.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB