many sparse changes

This commit is contained in:
Geoffray Levasseur committed 2026-11-03 18:33:45 +01:00
1 parent 2c26c6f795
commit 7aa4ea4425
23 files changed
+1317 -290

No files matched your search

+6 -8
View File
@@ -32,10 +32,10 @@
// 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 via
// StringTables.pas, which isn't ported (StringTable below is a disclosed
// stub). waterSign()/paintTerrIcon() (cosmetic pixel effects) are no-ops.
// Extend this file (not a new one) if StringTables.pas is ever ported.
// 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.
#include "Help.h"
#include "ui_Help.h"
@@ -401,13 +401,11 @@ void HelpDlg::searchBtnClicked()
void HelpDlg::search(const QString &searchString)
{
searchResult.clear();
// Real full-text search needs Help/Help.txt's content via
// StringTables.pas (not ported) - the StringTable stub's search()
// always returns false, so this never finds anything yet.
// The result list isn't built yet (needs the Help.txt layout engine):
// the matches are found but not recorded.
int handle = -1;
int index = -1;
while (helpText.search(searchString, handle, index)) {
// unreachable with the current StringTable stub
}
}
+1 -28
View File
@@ -30,6 +30,7 @@
#include "Cevo/CevoBaseWin.h"
#include "Cevo/CevoPVScrollBar.h"
#include "Cevo/CevoStringTables.h"
#include <QColor>
#include <QString>
@@ -103,34 +104,6 @@ struct HistItem {
QString searchContent;
};
// Minimal stand-in for StringTables.pas's TStringTable (not ported) - a
// key->text lookup with handle-based indirection and full-text search.
// Since Help/Help.txt's real content isn't available without a
// StringTables.pas port, every lookup returns a disclosed placeholder and
// search() never matches anything.
class StringTable {
public:
void loadFromFile(const QString &fileName) { Q_UNUSED(fileName); }
QString operator[](const QString &key) const { return key; }
int getHandle(const QString &key) const
{
Q_UNUSED(key);
return -1;
}
QString lookupByHandle(int handle) const
{
Q_UNUSED(handle);
return QString();
}
bool search(const QString &searchString, int &handle, int &index) const
{
Q_UNUSED(searchString);
Q_UNUSED(handle);
Q_UNUSED(index);
return false;
}
};
// THelpDlg equivalent: the in-game encyclopedia/hypertext browser. UI built
// from Help.ui (adapted from the original's Help.lfm). The real content
// (Help/Help.txt via StringTables.pas) isn't available, so prepare()/
+26 -7
View File
@@ -44,6 +44,7 @@ namespace Term {
MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
{
mainScreen = this;
IsoEngine::init([](int emix) { return initEnemyModel(emix); });
mainScreenZoomToCity = [this](int loc, bool nextUnitOnClose, int showEvent) {
@@ -73,7 +74,11 @@ MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
};
}
MainScreen::~MainScreen() = default;
MainScreen::~MainScreen()
{
if (mainScreen == this)
mainScreen = nullptr;
}
Wonders::WondersDlg &MainScreen::wondersDlg()
{
@@ -250,14 +255,15 @@ void MainScreen::arrangeDialogs()
}
namespace {
// Original: `if G.RO[DipMem[Me].pContact] <> nil then ApplyToVisibleForms
// (faClose) else begin if CityDlg.Visible ... end;` - the ApplyToVisibleForms
// branch is multiplayer/hotseat-only (closes every dialog so the next
// player's turn starts clean) and isn't reachable without the full
// GRO[]/hotseat machinery; simplified to always take the single-player
// "close CityDlg/UnitStatDlg if open" path, disclosed.
// Closes every dialog for the next (hot-seat) player when the contacted
// nation is also locally controlled, otherwise just the city/unit dialogs.
void closeDialogsForNextPlayer(MainScreen &mainScreen)
{
const int pContact = dipMem[static_cast<std::size_t>(ClientTools::me)].pContact;
if (pContact >= 0 && ClientTools::g.RO[pContact] != nullptr) {
applyToVisibleForms(FormAction::Close);
return;
}
if (mainScreen.cityDlg().isVisible())
mainScreen.cityDlg().close();
if (mainScreen.unitStatDlg().isVisible())
@@ -535,6 +541,19 @@ void MainScreen::showEnemyShipChange(const TShowShipChange &change)
dlg.showModal();
}
void MainScreen::initModule()
{
initAdvIcons();
unusedTribeFiles.clear();
Tribes::hGrStdUnits = loadGraphicSet(QStringLiteral("StdUnits") + QLatin1String(PngExt));
initSmallImp();
}
void MainScreen::doneModule()
{
unusedTribeFiles.clear();
}
void MainScreen::rememberPeaceViolation()
{
myData->peaceEvaHappened = 0;
+4
View File
@@ -113,6 +113,10 @@ public:
// Picks (at random among the best) the unused tribe whose colour differs most from the tribes in play.
int chooseUnusedTribe();
void showEnemyShipChange(const TShowShipChange &showShipChange);
// Term.pas's InitModule()/DoneModule(): one-time asset/table setup
// (advance icons, StdUnits graphics, smallImp).
void initModule();
void doneModule();
private:
std::unique_ptr<Wonders::WondersDlg> m_wondersDlg;
+58 -21
View File
@@ -68,9 +68,8 @@ QString turnToString(int turn)
if (!generateNames)
return QString::number(turn);
const int year = turnToYear(turn);
// Phrases['BC']/['AD'] (StringTables.pas) aren't ported; disclosed
// plain-English fallback format.
return year < 0 ? QStringLiteral("%1 BC").arg(-year) : QStringLiteral("AD %1").arg(year);
return phraseToQtFormat(phrases.lookup(year < 0 ? QStringLiteral("BC") : QStringLiteral("AD")))
.arg(std::abs(year));
}
void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government, bool isControl)
@@ -145,6 +144,57 @@ std::array<int, nAdv> advIcon = [] {
result.fill(-1);
return result;
}();
void initAdvIcons()
{
for (int i = 0; i < nAdv; ++i) {
int &icon = advIcon[static_cast<std::size_t>(i)];
if (IsFutureTech(i)) {
icon = 96 + i - futResearchTechnology;
continue;
}
icon = -1;
for (int domain = 0; domain < nDomains; ++domain) {
for (int j = 0; j < nUpgrade; ++j) {
if (Upgrade[domain][j].Preq == i)
icon = icon >= 0 ? 85 : 86 + domain;
}
}
for (int j = 0; j < nFeature; ++j) {
if (Feature[j].Preq != i)
continue;
for (int domain = 0; domain < nDomains; ++domain) {
if (Feature[j].Domains & (1 << domain))
icon = (icon >= 0 && icon != 86 + domain) ? 85 : 86 + domain;
}
}
for (int j = nWonder; j < nImp; ++j) {
if (Imp[j].Preq == i)
icon = j;
}
for (int j = nWonder; j < nImp; ++j) {
if (Imp[j].Preq == i && Imp[j].Kind != ikCommon)
icon = j;
}
for (int j = 0; j < nJob; ++j) {
if (i == JobPreq[j])
icon = 84;
}
for (int j = 0; j < nWonder; ++j) {
if (Imp[j].Preq == i)
icon = j;
}
if (icon < 0)
icon = ClientTools::advValue[static_cast<std::size_t>(i)] < 1000
? -7
: 24 + ClientTools::advValue[static_cast<std::size_t>(i)] / 1000;
for (int j = 2; j < nGov; ++j) {
if (GovPreq[j] == i)
icon = j - 8;
}
}
advIcon[adConscription] = 86 + dGround;
}
std::array<int, nPl * nMmax> lostArmy{};
int nLostArmy = 0;
@@ -330,8 +380,8 @@ void tellNewModels()
if (dlg) {
if (ClientTools::myModel[told].Kind == mkSelfDeveloped)
dlg->openSound = QStringLiteral("NEWMODEL_%1").arg(age);
// TODO: Phrases['MODELAVAILABLE'] (StringTables.pas not ported) - plain English fallback.
dlg->messageText = QStringLiteral("New units are ready for production.");
// Phrases['MODELAVAILABLE']
dlg->messageText = phrases.lookup(QStringLiteral("MODELAVAILABLE"));
if (gameMode == cMovie) {
dlg->kind = MessageKind::OkHelp; // doesn't matter
dlg->messageText += QLatin1Char('\\') + myTribe.modelNameAt(told);
@@ -384,23 +434,10 @@ const std::array<QString, 16> CityEventSoundItem = {
QString cityEventName(int i)
{
// TODO: needs Phrases/Phrases2 (StringTables.pas not ported) - plain
// English fallback descriptions per event index.
static const std::array<QString, 16> fallback = {
QStringLiteral("Civil disorder"), QStringLiteral("Population grows"),
QStringLiteral("Population declines"), QStringLiteral("Unit lost"),
QStringLiteral("Improvement lost"), QStringLiteral("Production sabotaged"),
QStringLiteral("No growth without aqueduct/sewer"), QStringLiteral("Pollution"),
QStringLiteral("City under siege"), QStringLiteral("Wonder obsolete"),
QStringLiteral("Settler production delayed"), QStringLiteral("City founded"),
QStringLiteral("City founded"), QStringLiteral(""),
QStringLiteral("All improvements built"), QStringLiteral(""),
};
if (i == 14) // chAllImpsMade
return fallback[14];
if (i >= 0 && i < static_cast<int>(fallback.size()))
return fallback[static_cast<std::size_t>(i)];
return QString();
return phrases2FallenBackToEnglish ? phrases.lookup(QStringLiteral("CITYEVENTS"), 1)
: phrases2.lookup(QStringLiteral("CITYEVENT_ALLIMPSMADE"));
return phrases.lookup(QStringLiteral("CITYEVENTS"), i);
}
void helpOnTerrain(int loc, WindowMode newMode)
+4 -2
View File
@@ -234,8 +234,7 @@ constexpr int chTypeDel = 0x8000;
constexpr int nCityEventPriority = 16;
extern const std::array<int, nCityEventPriority> CityEventPriority;
extern const std::array<QString, 16> CityEventSoundItem;
// TODO: needs Phrases/Phrases2 (StringTables.pas not ported) - falls back
// to a plain English description per event index.
// Term.pas's CityEventName(): the description of city event index i.
QString cityEventName(int i);
// Term.pas's HelpOnTerrain(): opens the help dialog on the terrain-info
@@ -316,6 +315,9 @@ bool createTribe(int p, QString fileName, bool original);
void tellNewContacts();
void tellNewModels();
// Term.pas's InitModule() `AdvIcon` table setup (the icon displayed with each advance).
void initAdvIcons();
// Term.pas's `UnusedTribeFiles` (name + colour of every tribe file not yet in play).
struct UnusedTribe {
QString fileName;
+1 -45
View File
@@ -33,7 +33,6 @@
#include <QFile>
#include <QFileInfo>
#include <QHash>
#include <QTextStream>
#include <limits>
@@ -358,50 +357,7 @@ QString Tribe::tString(QString templateText) const
QString Tribe::tPhrase(const QString &item) const
{
// Phrases/Phrases2 (StringTables.pas) aren't ported; these are
// disclosed plain-English placeholders for the keys looked up via
// Tribe::TPhrase() across this file and Diplomacy.pas, run through
// TString() for the tribe's own #x name-template substitution.
static const QHash<QString, QString> table = {
{QStringLiteral("GENCITY"), QStringLiteral("City %1")},
{QStringLiteral("SHORTNAME"), QStringLiteral("#A")},
{QStringLiteral("PRICE_CIVIL"), QStringLiteral("our civil report")},
{QStringLiteral("PRICE_MIL"), QStringLiteral("our military report")},
{QStringLiteral("PRICE_MAP"), QStringLiteral("our map")},
{QStringLiteral("PRICE_ALLTECH"), QStringLiteral("all our advances")},
{QStringLiteral("PRICE_ALLMODEL"), QStringLiteral("all our unit designs")},
{QStringLiteral("FRACCEPTTREATY"), QStringLiteral("We accept your treaty proposal.")},
{QStringLiteral("FRACCEPTDEMAND_STRONG"), QStringLiteral("As you wish.")},
{QStringLiteral("FRACCEPTPRESENT"), QStringLiteral("We gladly accept your gift.")},
{QStringLiteral("FRACCEPTOFFER"), QStringLiteral("We accept your offer.")},
{QStringLiteral("FRBREAK"), QStringLiteral("We break off negotiations.")},
{QStringLiteral("FRNOTACCEPTTREATY"), QStringLiteral("We do not accept this treaty.")},
{QStringLiteral("FRNOTACCEPTDEMAND_STRONG"), QStringLiteral("We refuse your demand.")},
{QStringLiteral("FRNOTACCEPTPRESENT"), QStringLiteral("We decline your gift.")},
{QStringLiteral("FRBYE"), QStringLiteral("Farewell.")},
{QStringLiteral("FRNOTACCEPTOFFER"), QStringLiteral("We do not accept this offer.")},
{QStringLiteral("FRNEWNATION"), QStringLiteral("We have contact to #n now.")},
{QStringLiteral("SHIPBUILT"), QStringLiteral("#N have completed a part of their transstellar colony ship.")},
{QStringLiteral("SHIPBITRADE1"), QStringLiteral("#S and")},
{QStringLiteral("SHIPBITRADE2"), QStringLiteral("#s are exchanging colony ship parts.")},
{QStringLiteral("SHIPUNITRADE1"), QStringLiteral("#N receive")},
{QStringLiteral("SHIPUNITRADE2"), QStringLiteral("colony ship parts from #s.")},
{QStringLiteral("SHIPCAPTURE1"), QStringLiteral("#N take control of the")},
{QStringLiteral("SHIPCAPTURE2"), QStringLiteral("#a colony ship!")},
{QStringLiteral("SHIPDESTROYED"), QStringLiteral("#N lost control of their colony ship.")},
{QStringLiteral("FRPEACE"), QStringLiteral("we propose a peace treaty")},
{QStringLiteral("FRFRIENDLY"), QStringLiteral("we propose friendly relations")},
{QStringLiteral("FRALLIANCE"), QStringLiteral("we propose an alliance")},
{QStringLiteral("FRDEMAND_STRONG"), QStringLiteral("we demand %1")},
{QStringLiteral("FRPRESENT"), QStringLiteral("we offer you %1 as a gift")},
{QStringLiteral("FRSTART_NOTREATY"), QStringLiteral("Greetings.")},
{QStringLiteral("FRSTART_PEACE"), QStringLiteral("Greetings, friend.")},
{QStringLiteral("WONDEROWNER"), QStringLiteral("built by the #A")},
{QStringLiteral("GENMODEL"), QStringLiteral("Model #%1")},
{QStringLiteral("OWNED"), QStringLiteral("%1 (owned)")},
};
const auto it = table.constFind(item);
return tString(it != table.constEnd() ? it.value() : item);
return tString(phraseToQtFormat(phrases.lookup(item)));
}
void Tribe::initAge(int age)
+2 -3
View File
@@ -104,9 +104,8 @@ public:
QString getCityName(int i) const;
void setCityName(int i, const QString &newName);
QString tString(QString templateText) const;
// Phrases/Phrases2 (StringTables.pas) aren't ported; falls back to a
// plain-English template for the one phrase this file needs (city-name
// generation past the end of a tribe's scripted name list).
// TString(Phrases[item]) with the %d/%s placeholders turned into
// QString::arg() style %1, %2, ...
QString tPhrase(const QString &item) const;
void setModelPicture(const ModelPictureInfo &info, bool isNew);
bool chooseModelPicture(ModelPictureInfo &picture, int code, int turn, bool forceNew);