removed old temporary phrase and formatPrase implementations

This commit is contained in:
Geoffray Levasseur committed 2026-11-17 11:42:28 +01:00
1 parent 6e634e13d2
commit e96b871779
14 files changed
+231 -598

No files matched your search

+58 -105
View File
@@ -97,55 +97,6 @@ constexpr std::array<int, nImp - 28> ImpPosition = {
-1, 9, -1, -1, -1, -1,
};
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own flat-key text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_OK"), QStringLiteral("OK")},
{QStringLiteral("BTN_BUY"), QStringLiteral("Buy")},
{QStringLiteral("SUPUNITS"), QStringLiteral("Supported units")},
{QStringLiteral("LUX"), QStringLiteral("Luxury")},
{QStringLiteral("UNREST"), QStringLiteral("Unrest")},
{QStringLiteral("HAPPINESSDEMAND"), QStringLiteral("Demand")},
{QStringLiteral("HAPPINESSPLUS"), QStringLiteral("Content")},
{QStringLiteral("HAPPINESS"), QStringLiteral("Happiness")},
{QStringLiteral("CONTROL"), QStringLiteral("Martial law")},
{QStringLiteral("FAITH"), QStringLiteral("Faith")},
{QStringLiteral("LACK"), QStringLiteral("Lack")},
{QStringLiteral("FOOD"), QStringLiteral("Food")},
{QStringLiteral("DEMAND"), QStringLiteral("Demand")},
{QStringLiteral("SUPPORT"), QStringLiteral("Support")},
{QStringLiteral("PROFIT"), QStringLiteral("Profit")},
{QStringLiteral("SURPLUS"), QStringLiteral("Surplus")},
{QStringLiteral("STORAGE"), QStringLiteral("Storage")},
{QStringLiteral("MATERIAL"), QStringLiteral("Material")},
{QStringLiteral("PROD"), QStringLiteral("Production")},
{QStringLiteral("POLL"), QStringLiteral("Pollution")},
{QStringLiteral("TRADE"), QStringLiteral("Trade")},
{QStringLiteral("CORR"), QStringLiteral("Corruption")},
{QStringLiteral("TAX"), QStringLiteral("Tax")},
{QStringLiteral("SCIENCE"), QStringLiteral("Science")},
{QStringLiteral("READY"), QStringLiteral("Already completed.")},
{QStringLiteral("NOMONEY"), QStringLiteral("Not enough money (%1 needed, %2 available).")},
{QStringLiteral("BUY"), QStringLiteral("Buy for %1 gold?")},
{QStringLiteral("NOCHANGEINANARCHY"), QStringLiteral("Cannot change city management in anarchy.")},
{QStringLiteral("NOSELLAGAIN"), QStringLiteral("Cannot sell %1 again this turn.")},
{QStringLiteral("OUTOFCONTROL"), QStringLiteral("%1 is out of our control.")},
{QStringLiteral("SELL"), QStringLiteral("Sell %1?")},
{QStringLiteral("DISPOSE"), QStringLiteral("Dispose of %1?")},
{QStringLiteral("SPDESTRUCTQUERY"), QStringLiteral("This will destroy the space ship parts built so far.")},
{QStringLiteral("CITYMANAGEOFF"), QStringLiteral("Turn off city management?")},
{QStringLiteral("DOUBLESTATEIMP"),
QStringLiteral("%1 is already being built in %2.")},
{QStringLiteral("LOSEMAT"), QStringLiteral("This will lose %1/%2 production material.")},
{QStringLiteral("LOSEMAT3"), QStringLiteral("This will lose production material.")},
{QStringLiteral("EMIGRATE"), QStringLiteral("City is too small; found a new city instead?")},
};
const auto it = table.find(key);
return it != table.end() ? *it : key;
}
QString impName(int iix)
{
return phrases.lookup(QStringLiteral("IMPROVEMENTS"), iix);
@@ -185,9 +136,9 @@ CityDlg::CityDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::CityDlg)
agePrepared = -2;
optimizeCixTileChange = -1;
ui->closeBtn->setCaption(phrase(QStringLiteral("BTN_OK")));
ui->buyBtn->setToolTip(phrase(QStringLiteral("BTN_BUY")));
ui->supportArea->setToolTip(phrase(QStringLiteral("SUPUNITS")));
ui->closeBtn->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->buyBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_BUY")));
ui->supportArea->setToolTip(phrases.lookup(QStringLiteral("SUPUNITS")));
back.setTransparent(false);
back.setSize(width(), height());
@@ -582,7 +533,7 @@ void CityDlg::offscreenPaint()
if (!isCityAlive) {
makeRed(offscreen, 18, 280, 298, 40);
s = cGov == gAnarchy ? governmentName(gAnarchy) : phrase(QStringLiteral("CITYEVENT_CAPTURED"));
s = cGov == gAnarchy ? governmentName(gAnarchy) : phrases.lookup(QStringLiteral("CITYEVENTS"), 14);
risedTextOut(canvas, 167 - biColorTextWidth(canvas, s) / 2, ymOpt - 9, s);
} else if (allowChange) {
const int optiType = c.Status >> 4 & 0x0F;
@@ -688,47 +639,47 @@ void CityDlg::offscreenPaint()
// happiness section
if (isCityAlive) {
if (cGov == gFundamentalism) {
countBar(offscreen, xHapp, yHapp + dyBar, wBar, 17, phrase(QStringLiteral("FAITH")),
countBar(offscreen, xHapp, yHapp + dyBar, wBar, 17, phrases.lookup(QStringLiteral("FAITH")),
report.CollectedControl, *MainTexture);
} else {
countBar(offscreen, xHapp, yHapp + dyBar, wBar, 17, phrase(QStringLiteral("HAPPINESS")), report.Morale,
countBar(offscreen, xHapp, yHapp + dyBar, wBar, 17, phrases.lookup(QStringLiteral("HAPPINESS")), report.Morale,
*MainTexture);
countBar(offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16, phrase(QStringLiteral("CONTROL")),
countBar(offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16, phrases.lookup(QStringLiteral("CONTROL")),
report.CollectedControl, *MainTexture);
}
countBar(offscreen, xHapp, yHapp, wBar, 8, phrase(QStringLiteral("LUX")), report.Luxury, *MainTexture);
countBar(offscreen, xHapp + dxBar, yHapp, wBar, 19, phrase(QStringLiteral("UNREST")), 2 * report.Deployed,
countBar(offscreen, xHapp, yHapp, wBar, 8, phrases.lookup(QStringLiteral("LUX")), report.Luxury, *MainTexture);
countBar(offscreen, xHapp + dxBar, yHapp, wBar, 19, phrases.lookup(QStringLiteral("UNREST")), 2 * report.Deployed,
*MainTexture);
countBar(offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17, phrase(QStringLiteral("HAPPINESSDEMAND")),
countBar(offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17, phrases.lookup(QStringLiteral("HAPPINESSDEMAND")),
c.Size, *MainTexture);
if (report.HappinessBalance >= 0) {
countBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17, phrase(QStringLiteral("HAPPINESSPLUS")),
countBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17, phrases.lookup(QStringLiteral("HAPPINESSPLUS")),
report.HappinessBalance, *MainTexture);
} else {
makeRed(offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38);
countBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18, phrase(QStringLiteral("LACK")),
countBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18, phrases.lookup(QStringLiteral("LACK")),
-report.HappinessBalance, redTex);
}
}
// food section
if (isCityAlive) {
countBar(offscreen, xFood, yFood + dyBar / 2, wBar, 0, phrase(QStringLiteral("FOOD")), report.CollectedFood,
countBar(offscreen, xFood, yFood + dyBar / 2, wBar, 0, phrases.lookup(QStringLiteral("FOOD")), report.CollectedFood,
*MainTexture);
countBar(offscreen, xFood + dxBar, yFood + dyBar, wBar, 0, phrase(QStringLiteral("DEMAND")), 2 * c.Size,
countBar(offscreen, xFood + dxBar, yFood + dyBar, wBar, 0, phrases.lookup(QStringLiteral("DEMAND")), 2 * c.Size,
*MainTexture);
countBar(offscreen, xFood + dxBar, yFood, wBar, 0, phrase(QStringLiteral("SUPPORT")), report.FoodSupport,
countBar(offscreen, xFood + dxBar, yFood, wBar, 0, phrases.lookup(QStringLiteral("SUPPORT")), report.FoodSupport,
*MainTexture);
if (report.FoodSurplus >= 0) {
if (cGov == gFuture || (c.Size >= NeedAqueductSize && report.FoodSurplus < 2))
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6, phrase(QStringLiteral("PROFIT")),
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6, phrases.lookup(QStringLiteral("PROFIT")),
report.FoodSurplus, *MainTexture);
else
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0, phrase(QStringLiteral("SURPLUS")),
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0, phrases.lookup(QStringLiteral("SURPLUS")),
report.FoodSurplus, *MainTexture);
} else {
makeRed(offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38);
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1, phrase(QStringLiteral("LACK")),
countBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1, phrases.lookup(QStringLiteral("LACK")),
-report.FoodSurplus, redTex);
}
}
@@ -739,24 +690,24 @@ void CityDlg::offscreenPaint()
report.Storage, 1, canGrow);
loweredTextOut(canvas, -1, *MainTexture, xFood + 3 - 5, yFood + 102 - 20,
QStringLiteral("%1/%2").arg(trueFood).arg(report.Storage));
loweredTextOut(canvas, -1, *MainTexture, xFood - 2, yFood + 66, phrase(QStringLiteral("STORAGE")));
loweredTextOut(canvas, -1, *MainTexture, xFood - 2, yFood + 66, phrases.lookup(QStringLiteral("STORAGE")));
// production section
if (isCityAlive) {
countBar(offscreen, xProd, yProd, wBar, 2, phrase(QStringLiteral("MATERIAL")), report.CollectedMaterial,
countBar(offscreen, xProd, yProd, wBar, 2, phrases.lookup(QStringLiteral("MATERIAL")), report.CollectedMaterial,
*MainTexture);
countBar(offscreen, xProd + dxBar, yProd, wBar, 2, phrase(QStringLiteral("SUPPORT")), report.MaterialSupport,
countBar(offscreen, xProd + dxBar, yProd, wBar, 2, phrases.lookup(QStringLiteral("SUPPORT")), report.MaterialSupport,
*MainTexture);
if (report.Production >= 0) {
if ((c.Project & (cpImp + cpIndex)) == cpImp + imTrGoods)
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6, phrase(QStringLiteral("PROFIT")),
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6, phrases.lookup(QStringLiteral("PROFIT")),
report.Production, *MainTexture);
else
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2, phrase(QStringLiteral("PROD")),
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2, phrases.lookup(QStringLiteral("PROD")),
report.Production, *MainTexture);
} else {
makeRed(offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38);
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3, phrase(QStringLiteral("LACK")),
countBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3, phrases.lookup(QStringLiteral("LACK")),
-report.Production, redTex);
}
}
@@ -779,17 +730,17 @@ void CityDlg::offscreenPaint()
// pollution section
if (isCityAlive && report.AddPollution > 0) {
fillBar(xPoll + 3, yPoll + 20, truePoll, report.AddPollution, MaxPollution, 3, true);
risedTextOut(canvas, xPoll + 3 - 5, yPoll + 20 - 20, phrase(QStringLiteral("POLL")));
risedTextOut(canvas, xPoll + 3 - 5, yPoll + 20 - 20, phrases.lookup(QStringLiteral("POLL")));
}
// trade section
if (isCityAlive && report.CollectedTrade > 0) {
countBar(offscreen, xTrade, yTrade + dyBar / 2, wBar, 4, phrase(QStringLiteral("TRADE")),
countBar(offscreen, xTrade, yTrade + dyBar / 2, wBar, 4, phrases.lookup(QStringLiteral("TRADE")),
report.CollectedTrade, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5, phrase(QStringLiteral("CORR")),
countBar(offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5, phrases.lookup(QStringLiteral("CORR")),
report.Corruption, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade, wBar, 6, phrase(QStringLiteral("TAX")), report.Tax, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, phrase(QStringLiteral("SCIENCE")),
countBar(offscreen, xTrade + dxBar, yTrade, wBar, 6, phrases.lookup(QStringLiteral("TAX")), report.Tax, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, phrases.lookup(QStringLiteral("SCIENCE")),
report.Science, *MainTexture);
}
@@ -883,7 +834,7 @@ void CityDlg::offscreenPaint()
ui->imp4Area->setToolTip(imix[4] >= 0 ? impName(imix[4]) : QString());
ui->imp5Area->setToolTip(imix[5] >= 0 ? impName(imix[5]) : QString());
} else { // smSupportedUnits
loweredTextOut(canvas, -1, *MainTexture, xZoomMap + 6, yZoomMap + 2, phrase(QStringLiteral("SUPUNITS")));
loweredTextOut(canvas, -1, *MainTexture, xZoomMap + 6, yZoomMap + 2, phrases.lookup(QStringLiteral("SUPUNITS")));
int freeSupp = c.Size * SupportFree[cGov] >> 1;
int cnt = 0;
for (int i = 0; i < ClientTools::myRO->nUn; ++i)
@@ -1107,14 +1058,15 @@ void CityDlg::buyClick()
else
cost *= 4;
if (cost <= 0 && report.HappinessBalance >= 0) {
dlg->messageText = phrase(QStringLiteral("READY"));
dlg->messageText = phrases.lookup(QStringLiteral("READY"));
dlg->kind = MessageKind::Ok;
} else if (cost > ClientTools::myRO->Money) {
dlg->openSound = QStringLiteral("MSG_DEFAULT");
dlg->messageText = phrase(QStringLiteral("NOMONEY")).arg(cost).arg(ClientTools::myRO->Money);
dlg->messageText = formatPhrase(QStringLiteral("NOMONEY"),
{ QString::number(cost), QString::number(ClientTools::myRO->Money) });
dlg->kind = MessageKind::Ok;
} else {
dlg->messageText = phrase(QStringLiteral("BUY")).arg(cost);
dlg->messageText = formatPhrase(QStringLiteral("BUY"), { QString::number(cost) });
dlg->kind = MessageKind::YesNo;
}
const MessageKind queriedKind = dlg->kind;
@@ -1165,9 +1117,9 @@ void CityDlg::chooseProject()
int cix1 = ClientTools::myRO->nCity - 1;
while (cix1 >= 0 && ClientTools::myCity[cix1].Built[newProject & cpIndex] == 0)
--cix1;
dlg->messageText = phrase(QStringLiteral("DOUBLESTATEIMP"))
.arg(impName(newProject & cpIndex))
.arg(Tribes::cityName(ClientTools::myCity[cix1].ID));
dlg->messageText = formatPhrase(QStringLiteral("DOUBLESTATEIMP"),
{ impName(newProject & cpIndex),
Tribes::cityName(ClientTools::myCity[cix1].ID) });
dlg->openSound = QStringLiteral("MSG_DEFAULT");
dlg->kind = MessageKind::OkCancel;
dlg->iconKind = MessgEx::MessageIconKind::Imp;
@@ -1185,14 +1137,15 @@ void CityDlg::chooseProject()
if ((newProject & (cpImp | cpIndex)) != (ClientTools::myCity[cix].Project0 & (cpImp | cpIndex))) {
if (pt1 == ProjectKind::TrGoods || pt1 == ProjectKind::Ship ||
(pt1 != pt0 && pt0 != ProjectKind::Caravan)) {
queryOk = MessgEx::simpleQuery(MessageKind::OkCancel,
phrase(QStringLiteral("LOSEMAT"))
.arg(ClientTools::myCity[cix].Prod0)
.arg(ClientTools::myCity[cix].Prod0),
QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok;
queryOk = MessgEx::simpleQuery(
MessageKind::OkCancel,
formatPhrase(QStringLiteral("LOSEMAT"),
{ QString::number(ClientTools::myCity[cix].Prod0),
QString::number(ClientTools::myCity[cix].Prod0) }),
QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok;
} else if ((ClientTools::myCity[cix].Project & (cpImp | cpIndex)) ==
(ClientTools::myCity[cix].Project0 & (cpImp | cpIndex))) {
queryOk = MessgEx::simpleQuery(MessageKind::OkCancel, phrase(QStringLiteral("LOSEMAT3")),
queryOk = MessgEx::simpleQuery(MessageKind::OkCancel, phrases.lookup(QStringLiteral("LOSEMAT3")),
QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok;
}
}
@@ -1208,7 +1161,7 @@ void CityDlg::chooseProject()
(ClientTools::myCity[cix].Size < 3 &&
(ClientTools::myModel[newProject & cpIndex].Kind == mkSlaves ||
(newProject & cpConscripts) != 0)))) {
if (MessgEx::simpleQuery(MessageKind::YesNo, phrase(QStringLiteral("EMIGRATE")),
if (MessgEx::simpleQuery(MessageKind::YesNo, phrases.lookup(QStringLiteral("EMIGRATE")),
QStringLiteral("MSG_DEFAULT")) != Dpi::ModalResult::Ok)
newProject |= cpDisbandCity;
}
@@ -1266,7 +1219,7 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
if (IsoEngine::clientMode < scContact && x >= xView && y >= yView && x < xView + 73 && y < yView + 50) {
if (cGov == gAnarchy) {
if (auto *dlg = Term::mainScreenMessgExDlg()) {
dlg->messageText = phrase(QStringLiteral("NOCHANGEINANARCHY"));
dlg->messageText = phrases.lookup(QStringLiteral("NOCHANGEINANARCHY"));
dlg->kind = MessageKind::Ok;
dlg->showModal();
}
@@ -1296,19 +1249,19 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
if (iix == imPalace || Imp[iix].Kind == ikWonder) {
dlg->messageText = impName(iix);
if (iix == woOracle)
dlg->messageText += QStringLiteral("\n") +
phrase(QStringLiteral("ORACLEINCOME"))
.arg(ClientTools::myRO->OracleIncome);
dlg->messageText +=
QStringLiteral("\n") +
formatPhrase(QStringLiteral("ORACLEINCOME"),
{ QString::number(ClientTools::myRO->OracleIncome) });
dlg->kind = MessageKind::Ok;
dlg->showModal();
} else {
const int sellResult =
ClientTools::server(sSellCityImprovement - sExecute, ClientTools::me, cix, &iix);
if (sellResult < rExecuted) {
dlg->messageText =
phrase(sellResult == eOnlyOnce ? QStringLiteral("NOSELLAGAIN")
: QStringLiteral("OUTOFCONTROL"))
.arg(impName(iix));
dlg->messageText = formatPhrase(sellResult == eOnlyOnce ? QStringLiteral("NOSELLAGAIN")
: QStringLiteral("OUTOFCONTROL"),
{ impName(iix) });
dlg->kind = MessageKind::Ok;
dlg->showModal();
} else {
@@ -1317,24 +1270,24 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
if (ClientTools::server(sRebuildCityImprovement - sExecute, ClientTools::me, cix,
&iix) < rExecuted) {
rebuild = false;
dlg->messageText = phrase(QStringLiteral("SELL")).arg(impName(iix));
dlg->messageText = formatPhrase(QStringLiteral("SELL"), { impName(iix) });
if (iix == imSpacePort) {
const auto &ship = ClientTools::myRO->Ship[ClientTools::me];
if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0)
dlg->messageText +=
QStringLiteral(" ") + phrase(QStringLiteral("SPDESTRUCTQUERY"));
QStringLiteral(" ") + phrases.lookup(QStringLiteral("SPDESTRUCTQUERY"));
}
dlg->kind = MessageKind::YesNo;
if (dlg->showModal() != Dpi::ModalResult::Ok)
newIix = -1;
} else {
rebuild = true;
dlg->messageText = phrase(QStringLiteral("DISPOSE")).arg(impName(iix));
dlg->messageText = formatPhrase(QStringLiteral("DISPOSE"), { impName(iix) });
if (iix == imSpacePort) {
const auto &ship = ClientTools::myRO->Ship[ClientTools::me];
if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0)
dlg->messageText +=
QStringLiteral(" ") + phrase(QStringLiteral("SPDESTRUCTQUERY"));
QStringLiteral(" ") + phrases.lookup(QStringLiteral("SPDESTRUCTQUERY"));
}
dlg->kind = MessageKind::YesNo;
if (dlg->showModal() != Dpi::ModalResult::Ok)
@@ -1397,7 +1350,7 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
Q_ASSERT(!Term::supervising);
if ((c.Status & Term::csResourceWeightsMask) != 0) {
if (auto *dlg = Term::mainScreenMessgExDlg()) {
dlg->messageText = phrase(QStringLiteral("CITYMANAGEOFF"));
dlg->messageText = phrases.lookup(QStringLiteral("CITYMANAGEOFF"));
dlg->openSound = QStringLiteral("MSG_DEFAULT");
dlg->kind = MessageKind::OkCancel;
dlg->iconKind = MessgEx::MessageIconKind::FullControl;