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
+230 -597

No files matched your search

+5 -16
View File
@@ -32,6 +32,7 @@
#include "Cevo/CevoScreenTools.h" #include "Cevo/CevoScreenTools.h"
#include "Cevo/CevoTexture.h" #include "Cevo/CevoTexture.h"
#include "ClientTools.h" #include "ClientTools.h"
#include "Global.h"
#include "Term.h" #include "Term.h"
#include <QCloseEvent> #include <QCloseEvent>
@@ -51,26 +52,14 @@ constexpr QRgb DamageColor = 0x0000E0;
constexpr QRgb FanaticColor = 0x800080; constexpr QRgb FanaticColor = 0x800080;
constexpr QRgb FirstStrikeColor = 0xA0A0A0; constexpr QRgb FirstStrikeColor = 0xA0A0A0;
// TODO: needs Phrases[] (StringTables.pas not ported) - plain English literals.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_YES"), QStringLiteral("Yes")},
{QStringLiteral("BTN_NO"), QStringLiteral("No")},
{QStringLiteral("TITLE_SUICIDE"), QStringLiteral("Hopeless attack")},
{QStringLiteral("SUICIDE"), QStringLiteral("This attack has no chance of success.\\Attack anyway?")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? *it : key;
}
} // namespace } // namespace
BattleDlg::BattleDlg(QWidget *parent) : DrawDlg(parent), ui(new Ui::BattleDlg) BattleDlg::BattleDlg(QWidget *parent) : DrawDlg(parent), ui(new Ui::BattleDlg)
{ {
ui->setupUi(this); ui->setupUi(this);
isoMap = std::make_unique<IsoEngine::IsoMap>(); isoMap = std::make_unique<IsoEngine::IsoMap>();
ui->okBtn->setCaption(phrase(QStringLiteral("BTN_YES"))); ui->okBtn->setCaption(phrases.lookup(QStringLiteral("BTN_YES")));
ui->cancelBtn->setCaption(phrase(QStringLiteral("BTN_NO"))); ui->cancelBtn->setCaption(phrases.lookup(QStringLiteral("BTN_NO")));
initButtons(); initButtons();
ui->okBtn->onClick = [this] { ui->okBtn->onClick = [this] {
@@ -226,10 +215,10 @@ void BattleDlg::paintEvent(QPaintEvent *)
int ym; int ym;
if (isSuicideQuery) { if (isSuicideQuery) {
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
QString s = phrase(QStringLiteral("TITLE_SUICIDE")); QString s = phrases.lookup(QStringLiteral("TITLE_SUICIDE"));
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, 7 + Border, s); risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, 7 + Border, s);
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
s = phrase(QStringLiteral("SUICIDE")); s = phrases.lookup(QStringLiteral("SUICIDE"));
const int p = s.indexOf(QLatin1Char('\\')); const int p = s.indexOf(QLatin1Char('\\'));
if (p < 0) { if (p < 0) {
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, 205, s); risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, 205, s);
+57 -104
View File
@@ -97,55 +97,6 @@ constexpr std::array<int, nImp - 28> ImpPosition = {
-1, 9, -1, -1, -1, -1, -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) QString impName(int iix)
{ {
return phrases.lookup(QStringLiteral("IMPROVEMENTS"), iix); return phrases.lookup(QStringLiteral("IMPROVEMENTS"), iix);
@@ -185,9 +136,9 @@ CityDlg::CityDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::CityDlg)
agePrepared = -2; agePrepared = -2;
optimizeCixTileChange = -1; optimizeCixTileChange = -1;
ui->closeBtn->setCaption(phrase(QStringLiteral("BTN_OK"))); ui->closeBtn->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->buyBtn->setToolTip(phrase(QStringLiteral("BTN_BUY"))); ui->buyBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_BUY")));
ui->supportArea->setToolTip(phrase(QStringLiteral("SUPUNITS"))); ui->supportArea->setToolTip(phrases.lookup(QStringLiteral("SUPUNITS")));
back.setTransparent(false); back.setTransparent(false);
back.setSize(width(), height()); back.setSize(width(), height());
@@ -582,7 +533,7 @@ void CityDlg::offscreenPaint()
if (!isCityAlive) { if (!isCityAlive) {
makeRed(offscreen, 18, 280, 298, 40); 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); risedTextOut(canvas, 167 - biColorTextWidth(canvas, s) / 2, ymOpt - 9, s);
} else if (allowChange) { } else if (allowChange) {
const int optiType = c.Status >> 4 & 0x0F; const int optiType = c.Status >> 4 & 0x0F;
@@ -688,47 +639,47 @@ void CityDlg::offscreenPaint()
// happiness section // happiness section
if (isCityAlive) { if (isCityAlive) {
if (cGov == gFundamentalism) { 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); report.CollectedControl, *MainTexture);
} else { } 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); *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); report.CollectedControl, *MainTexture);
} }
countBar(offscreen, xHapp, yHapp, wBar, 8, phrase(QStringLiteral("LUX")), report.Luxury, *MainTexture); countBar(offscreen, xHapp, yHapp, wBar, 8, phrases.lookup(QStringLiteral("LUX")), report.Luxury, *MainTexture);
countBar(offscreen, xHapp + dxBar, yHapp, wBar, 19, phrase(QStringLiteral("UNREST")), 2 * report.Deployed, countBar(offscreen, xHapp + dxBar, yHapp, wBar, 19, phrases.lookup(QStringLiteral("UNREST")), 2 * report.Deployed,
*MainTexture); *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); c.Size, *MainTexture);
if (report.HappinessBalance >= 0) { 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); report.HappinessBalance, *MainTexture);
} else { } else {
makeRed(offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38); 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); -report.HappinessBalance, redTex);
} }
} }
// food section // food section
if (isCityAlive) { 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); *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); *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); *MainTexture);
if (report.FoodSurplus >= 0) { if (report.FoodSurplus >= 0) {
if (cGov == gFuture || (c.Size >= NeedAqueductSize && report.FoodSurplus < 2)) 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); report.FoodSurplus, *MainTexture);
else 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); report.FoodSurplus, *MainTexture);
} else { } else {
makeRed(offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38); 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); -report.FoodSurplus, redTex);
} }
} }
@@ -739,24 +690,24 @@ void CityDlg::offscreenPaint()
report.Storage, 1, canGrow); report.Storage, 1, canGrow);
loweredTextOut(canvas, -1, *MainTexture, xFood + 3 - 5, yFood + 102 - 20, loweredTextOut(canvas, -1, *MainTexture, xFood + 3 - 5, yFood + 102 - 20,
QStringLiteral("%1/%2").arg(trueFood).arg(report.Storage)); 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 // production section
if (isCityAlive) { 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); *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); *MainTexture);
if (report.Production >= 0) { if (report.Production >= 0) {
if ((c.Project & (cpImp + cpIndex)) == cpImp + imTrGoods) 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); report.Production, *MainTexture);
else 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); report.Production, *MainTexture);
} else { } else {
makeRed(offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38); 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); -report.Production, redTex);
} }
} }
@@ -779,17 +730,17 @@ void CityDlg::offscreenPaint()
// pollution section // pollution section
if (isCityAlive && report.AddPollution > 0) { if (isCityAlive && report.AddPollution > 0) {
fillBar(xPoll + 3, yPoll + 20, truePoll, report.AddPollution, MaxPollution, 3, true); 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 // trade section
if (isCityAlive && report.CollectedTrade > 0) { 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); 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); report.Corruption, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade, wBar, 6, phrase(QStringLiteral("TAX")), report.Tax, *MainTexture); countBar(offscreen, xTrade + dxBar, yTrade, wBar, 6, phrases.lookup(QStringLiteral("TAX")), report.Tax, *MainTexture);
countBar(offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, phrase(QStringLiteral("SCIENCE")), countBar(offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, phrases.lookup(QStringLiteral("SCIENCE")),
report.Science, *MainTexture); report.Science, *MainTexture);
} }
@@ -883,7 +834,7 @@ void CityDlg::offscreenPaint()
ui->imp4Area->setToolTip(imix[4] >= 0 ? impName(imix[4]) : QString()); ui->imp4Area->setToolTip(imix[4] >= 0 ? impName(imix[4]) : QString());
ui->imp5Area->setToolTip(imix[5] >= 0 ? impName(imix[5]) : QString()); ui->imp5Area->setToolTip(imix[5] >= 0 ? impName(imix[5]) : QString());
} else { // smSupportedUnits } 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 freeSupp = c.Size * SupportFree[cGov] >> 1;
int cnt = 0; int cnt = 0;
for (int i = 0; i < ClientTools::myRO->nUn; ++i) for (int i = 0; i < ClientTools::myRO->nUn; ++i)
@@ -1107,14 +1058,15 @@ void CityDlg::buyClick()
else else
cost *= 4; cost *= 4;
if (cost <= 0 && report.HappinessBalance >= 0) { if (cost <= 0 && report.HappinessBalance >= 0) {
dlg->messageText = phrase(QStringLiteral("READY")); dlg->messageText = phrases.lookup(QStringLiteral("READY"));
dlg->kind = MessageKind::Ok; dlg->kind = MessageKind::Ok;
} else if (cost > ClientTools::myRO->Money) { } else if (cost > ClientTools::myRO->Money) {
dlg->openSound = QStringLiteral("MSG_DEFAULT"); 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; dlg->kind = MessageKind::Ok;
} else { } else {
dlg->messageText = phrase(QStringLiteral("BUY")).arg(cost); dlg->messageText = formatPhrase(QStringLiteral("BUY"), { QString::number(cost) });
dlg->kind = MessageKind::YesNo; dlg->kind = MessageKind::YesNo;
} }
const MessageKind queriedKind = dlg->kind; const MessageKind queriedKind = dlg->kind;
@@ -1165,9 +1117,9 @@ void CityDlg::chooseProject()
int cix1 = ClientTools::myRO->nCity - 1; int cix1 = ClientTools::myRO->nCity - 1;
while (cix1 >= 0 && ClientTools::myCity[cix1].Built[newProject & cpIndex] == 0) while (cix1 >= 0 && ClientTools::myCity[cix1].Built[newProject & cpIndex] == 0)
--cix1; --cix1;
dlg->messageText = phrase(QStringLiteral("DOUBLESTATEIMP")) dlg->messageText = formatPhrase(QStringLiteral("DOUBLESTATEIMP"),
.arg(impName(newProject & cpIndex)) { impName(newProject & cpIndex),
.arg(Tribes::cityName(ClientTools::myCity[cix1].ID)); Tribes::cityName(ClientTools::myCity[cix1].ID) });
dlg->openSound = QStringLiteral("MSG_DEFAULT"); dlg->openSound = QStringLiteral("MSG_DEFAULT");
dlg->kind = MessageKind::OkCancel; dlg->kind = MessageKind::OkCancel;
dlg->iconKind = MessgEx::MessageIconKind::Imp; dlg->iconKind = MessgEx::MessageIconKind::Imp;
@@ -1185,14 +1137,15 @@ void CityDlg::chooseProject()
if ((newProject & (cpImp | cpIndex)) != (ClientTools::myCity[cix].Project0 & (cpImp | cpIndex))) { if ((newProject & (cpImp | cpIndex)) != (ClientTools::myCity[cix].Project0 & (cpImp | cpIndex))) {
if (pt1 == ProjectKind::TrGoods || pt1 == ProjectKind::Ship || if (pt1 == ProjectKind::TrGoods || pt1 == ProjectKind::Ship ||
(pt1 != pt0 && pt0 != ProjectKind::Caravan)) { (pt1 != pt0 && pt0 != ProjectKind::Caravan)) {
queryOk = MessgEx::simpleQuery(MessageKind::OkCancel, queryOk = MessgEx::simpleQuery(
phrase(QStringLiteral("LOSEMAT")) MessageKind::OkCancel,
.arg(ClientTools::myCity[cix].Prod0) formatPhrase(QStringLiteral("LOSEMAT"),
.arg(ClientTools::myCity[cix].Prod0), { QString::number(ClientTools::myCity[cix].Prod0),
QString::number(ClientTools::myCity[cix].Prod0) }),
QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok; QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok;
} else if ((ClientTools::myCity[cix].Project & (cpImp | cpIndex)) == } else if ((ClientTools::myCity[cix].Project & (cpImp | cpIndex)) ==
(ClientTools::myCity[cix].Project0 & (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; QStringLiteral("MSG_DEFAULT")) == Dpi::ModalResult::Ok;
} }
} }
@@ -1208,7 +1161,7 @@ void CityDlg::chooseProject()
(ClientTools::myCity[cix].Size < 3 && (ClientTools::myCity[cix].Size < 3 &&
(ClientTools::myModel[newProject & cpIndex].Kind == mkSlaves || (ClientTools::myModel[newProject & cpIndex].Kind == mkSlaves ||
(newProject & cpConscripts) != 0)))) { (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) QStringLiteral("MSG_DEFAULT")) != Dpi::ModalResult::Ok)
newProject |= cpDisbandCity; 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 (IsoEngine::clientMode < scContact && x >= xView && y >= yView && x < xView + 73 && y < yView + 50) {
if (cGov == gAnarchy) { if (cGov == gAnarchy) {
if (auto *dlg = Term::mainScreenMessgExDlg()) { if (auto *dlg = Term::mainScreenMessgExDlg()) {
dlg->messageText = phrase(QStringLiteral("NOCHANGEINANARCHY")); dlg->messageText = phrases.lookup(QStringLiteral("NOCHANGEINANARCHY"));
dlg->kind = MessageKind::Ok; dlg->kind = MessageKind::Ok;
dlg->showModal(); dlg->showModal();
} }
@@ -1296,19 +1249,19 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
if (iix == imPalace || Imp[iix].Kind == ikWonder) { if (iix == imPalace || Imp[iix].Kind == ikWonder) {
dlg->messageText = impName(iix); dlg->messageText = impName(iix);
if (iix == woOracle) if (iix == woOracle)
dlg->messageText += QStringLiteral("\n") + dlg->messageText +=
phrase(QStringLiteral("ORACLEINCOME")) QStringLiteral("\n") +
.arg(ClientTools::myRO->OracleIncome); formatPhrase(QStringLiteral("ORACLEINCOME"),
{ QString::number(ClientTools::myRO->OracleIncome) });
dlg->kind = MessageKind::Ok; dlg->kind = MessageKind::Ok;
dlg->showModal(); dlg->showModal();
} else { } else {
const int sellResult = const int sellResult =
ClientTools::server(sSellCityImprovement - sExecute, ClientTools::me, cix, &iix); ClientTools::server(sSellCityImprovement - sExecute, ClientTools::me, cix, &iix);
if (sellResult < rExecuted) { if (sellResult < rExecuted) {
dlg->messageText = dlg->messageText = formatPhrase(sellResult == eOnlyOnce ? QStringLiteral("NOSELLAGAIN")
phrase(sellResult == eOnlyOnce ? QStringLiteral("NOSELLAGAIN") : QStringLiteral("OUTOFCONTROL"),
: QStringLiteral("OUTOFCONTROL")) { impName(iix) });
.arg(impName(iix));
dlg->kind = MessageKind::Ok; dlg->kind = MessageKind::Ok;
dlg->showModal(); dlg->showModal();
} else { } else {
@@ -1317,24 +1270,24 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
if (ClientTools::server(sRebuildCityImprovement - sExecute, ClientTools::me, cix, if (ClientTools::server(sRebuildCityImprovement - sExecute, ClientTools::me, cix,
&iix) < rExecuted) { &iix) < rExecuted) {
rebuild = false; rebuild = false;
dlg->messageText = phrase(QStringLiteral("SELL")).arg(impName(iix)); dlg->messageText = formatPhrase(QStringLiteral("SELL"), { impName(iix) });
if (iix == imSpacePort) { if (iix == imSpacePort) {
const auto &ship = ClientTools::myRO->Ship[ClientTools::me]; const auto &ship = ClientTools::myRO->Ship[ClientTools::me];
if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0) if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0)
dlg->messageText += dlg->messageText +=
QStringLiteral(" ") + phrase(QStringLiteral("SPDESTRUCTQUERY")); QStringLiteral(" ") + phrases.lookup(QStringLiteral("SPDESTRUCTQUERY"));
} }
dlg->kind = MessageKind::YesNo; dlg->kind = MessageKind::YesNo;
if (dlg->showModal() != Dpi::ModalResult::Ok) if (dlg->showModal() != Dpi::ModalResult::Ok)
newIix = -1; newIix = -1;
} else { } else {
rebuild = true; rebuild = true;
dlg->messageText = phrase(QStringLiteral("DISPOSE")).arg(impName(iix)); dlg->messageText = formatPhrase(QStringLiteral("DISPOSE"), { impName(iix) });
if (iix == imSpacePort) { if (iix == imSpacePort) {
const auto &ship = ClientTools::myRO->Ship[ClientTools::me]; const auto &ship = ClientTools::myRO->Ship[ClientTools::me];
if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0) if (ship.Parts[0] + ship.Parts[1] + ship.Parts[2] > 0)
dlg->messageText += dlg->messageText +=
QStringLiteral(" ") + phrase(QStringLiteral("SPDESTRUCTQUERY")); QStringLiteral(" ") + phrases.lookup(QStringLiteral("SPDESTRUCTQUERY"));
} }
dlg->kind = MessageKind::YesNo; dlg->kind = MessageKind::YesNo;
if (dlg->showModal() != Dpi::ModalResult::Ok) if (dlg->showModal() != Dpi::ModalResult::Ok)
@@ -1397,7 +1350,7 @@ void CityDlg::mousePressEvent(QMouseEvent *event)
Q_ASSERT(!Term::supervising); Q_ASSERT(!Term::supervising);
if ((c.Status & Term::csResourceWeightsMask) != 0) { if ((c.Status & Term::csResourceWeightsMask) != 0) {
if (auto *dlg = Term::mainScreenMessgExDlg()) { if (auto *dlg = Term::mainScreenMessgExDlg()) {
dlg->messageText = phrase(QStringLiteral("CITYMANAGEOFF")); dlg->messageText = phrases.lookup(QStringLiteral("CITYMANAGEOFF"));
dlg->openSound = QStringLiteral("MSG_DEFAULT"); dlg->openSound = QStringLiteral("MSG_DEFAULT");
dlg->kind = MessageKind::OkCancel; dlg->kind = MessageKind::OkCancel;
dlg->iconKind = MessgEx::MessageIconKind::FullControl; dlg->iconKind = MessgEx::MessageIconKind::FullControl;
+4 -19
View File
@@ -35,7 +35,6 @@
#include "Global.h" #include "Global.h"
#include "Term.h" #include "Term.h"
#include <QHash>
#include <QMouseEvent> #include <QMouseEvent>
namespace Cevo { namespace Cevo {
@@ -43,20 +42,6 @@ namespace CityType {
namespace { namespace {
// Phrases (StringTables.pas) aren't ported; disclosed plain-English
// placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("TITLE_CITYTYPES"), QStringLiteral("City Types")},
{QStringLiteral("BTN_DELETE"), QStringLiteral("Delete")},
{QStringLiteral("BUILDORDER"), QStringLiteral("Build order")},
{QStringLiteral("BUILDREST"), QStringLiteral("Remaining improvements")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
QString phraseCityType(int ctype) QString phraseCityType(int ctype)
{ {
return phrases.lookup(QStringLiteral("CITYTYPE"), ctype); return phrases.lookup(QStringLiteral("CITYTYPE"), ctype);
@@ -91,8 +76,8 @@ CityTypeDlg::CityTypeDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::CityTy
captionRight = ui->closeBtn->x(); captionRight = ui->closeBtn->x();
initButtons(); initButtons();
helpContext = QStringLiteral("MACRO"); helpContext = QStringLiteral("MACRO");
setWindowTitle(phrase(QStringLiteral("TITLE_CITYTYPES"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_CITYTYPES")));
ui->deleteBtn->setToolTip(phrase(QStringLiteral("BTN_DELETE"))); ui->deleteBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_DELETE")));
ui->closeBtn->onClick = [this] { close(); }; ui->closeBtn->onClick = [this] { close(); };
ui->deleteBtn->onClick = [this] { ui->deleteBtn->onClick = [this] {
@@ -194,9 +179,9 @@ void CityTypeDlg::offscreenPaint()
bitBltBitmap(offscreen, xSwitch + 2 + i * 42, ySwitch + 2, Term::xSizeSmall, Term::ySizeSmall, bitBltBitmap(offscreen, xSwitch + 2 + i * 42, ySwitch + 2, Term::xSizeSmall, Term::ySizeSmall,
*Term::smallImp, (i + 3) * Term::xSizeSmall, 0); *Term::smallImp, (i + 3) * Term::xSizeSmall, 0);
} }
risedTextOut(canvas, 8, yList + 32 * nListRow + 2, phrase(QStringLiteral("BUILDORDER"))); risedTextOut(canvas, 8, yList + 32 * nListRow + 2, phrases.lookup(QStringLiteral("BUILDORDER")));
risedTextOut(canvas, 8, ySwitch + 26, phraseCityType(ctype)); risedTextOut(canvas, 8, ySwitch + 26, phraseCityType(ctype));
const QString buildRest = phrase(QStringLiteral("BUILDREST")); const QString buildRest = phrases.lookup(QStringLiteral("BUILDREST"));
risedTextOut(canvas, (innerWidth - biColorTextWidth(canvas, buildRest)) / 2, yList + 72 + 32 * nListRow, risedTextOut(canvas, (innerWidth - biColorTextWidth(canvas, buildRest)) / 2, yList + 72 + 32 * nListRow,
buildRest); buildRest);
+11 -34
View File
@@ -33,9 +33,9 @@
#include "Cevo/CevoTexture.h" #include "Cevo/CevoTexture.h"
#include "Cevo/Database.h" #include "Cevo/Database.h"
#include "ClientTools.h" #include "ClientTools.h"
#include "Global.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
@@ -46,33 +46,9 @@ namespace Diagram {
namespace { namespace {
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_PAGE"), QStringLiteral("Next chart")},
{QStringLiteral("BTN_SELECT"), QStringLiteral("Select nation")},
{QStringLiteral("TITLE_DIAGRAMS"), QStringLiteral("Charts")},
{QStringLiteral("TITLE_SHIPS"), QStringLiteral("Colonization Ships")},
{QStringLiteral("SHARE"), QStringLiteral("%1/%2")},
{QStringLiteral("SHIPHAB"), QStringLiteral("Habitation")},
{QStringLiteral("SHIPPOW"), QStringLiteral("Power")},
{QStringLiteral("SHIPCOMP"), QStringLiteral("Components")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
QString phraseDiagram(int mode) QString phraseDiagram(int mode)
{ {
static const QHash<int, QString> table = { return phrases.lookup(QStringLiteral("DIAGRAM"), mode);
{stPop, QStringLiteral("Population")}, {stTerritory, QStringLiteral("Territory")},
{stMil, QStringLiteral("Military")}, {stScience, QStringLiteral("Science")},
{stExplore, QStringLiteral("Explored")}, {stWork, QStringLiteral("Workers")},
};
const auto it = table.constFind(mode);
return it != table.constEnd() ? it.value() : QString();
} }
constexpr int Border = 24; constexpr int Border = 24;
@@ -90,7 +66,8 @@ void shareBar(Dpi::Canvas &canvas, int x, int y, const QString &cap, int val0, i
{ {
loweredTextOut(canvas, -1, *MainTexture, x - 2, y, cap); loweredTextOut(canvas, -1, *MainTexture, x - 2, y, cap);
dLine(canvas, x - 2, x + 169, y + 16, MainTexture->colorTextShade, MainTexture->colorTextLight); dLine(canvas, x - 2, x + 169, y + 16, MainTexture->colorTextShade, MainTexture->colorTextLight);
const QString s = val0 > 0 ? phrase(QStringLiteral("SHARE")).arg(val0).arg(val1) : QStringLiteral("0"); const QString s = val0 > 0 ? formatPhrase(QStringLiteral("SHARE"), { QString::number(val0), QString::number(val1) })
: QStringLiteral("0");
risedTextOut(canvas, x + 170 - biColorTextWidth(canvas, s), y, s); risedTextOut(canvas, x + 170 - biColorTextWidth(canvas, s), y, s);
} }
@@ -261,11 +238,11 @@ void DiaDlg::offscreenPaint()
paintColonyShip(canvas, player, 8, innerWidth - 16, yArea); paintColonyShip(canvas, player, 8, innerWidth - 16, yArea);
shareBar(canvas, innerWidth / 2 - 85, innerHeight - 62, phrase(QStringLiteral("SHIPHAB")), shareBar(canvas, innerWidth / 2 - 85, innerHeight - 62, phrases.lookup(QStringLiteral("SHIPHAB")),
ClientTools::myRO->Ship[player].Parts[spHab], 2); ClientTools::myRO->Ship[player].Parts[spHab], 2);
shareBar(canvas, innerWidth / 2 - 85, innerHeight - 43, phrase(QStringLiteral("SHIPPOW")), shareBar(canvas, innerWidth / 2 - 85, innerHeight - 43, phrases.lookup(QStringLiteral("SHIPPOW")),
ClientTools::myRO->Ship[player].Parts[spPow], 4); ClientTools::myRO->Ship[player].Parts[spPow], 4);
shareBar(canvas, innerWidth / 2 - 85, innerHeight - 24, phrase(QStringLiteral("SHIPCOMP")), shareBar(canvas, innerWidth / 2 - 85, innerHeight - 24, phrases.lookup(QStringLiteral("SHIPCOMP")),
ClientTools::myRO->Ship[player].Parts[spComp], 6); ClientTools::myRO->Ship[player].Parts[spComp], 6);
} }
@@ -308,8 +285,8 @@ void DiaDlg::showNewContentCharts(WindowMode newMode)
kind = DiagramKind::Chart; kind = DiagramKind::Chart;
mode = stPop; mode = stPop;
ui->toggleBtn->setButtonIndex(15); ui->toggleBtn->setButtonIndex(15);
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_PAGE"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_PAGE")));
setWindowTitle(phrase(QStringLiteral("TITLE_DIAGRAMS"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_DIAGRAMS")));
showNewContent(newMode); showNewContent(newMode);
} }
@@ -326,8 +303,8 @@ void DiaDlg::showNewContentShip(WindowMode newMode, int p)
player = p; player = p;
} }
ui->toggleBtn->setButtonIndex(28); ui->toggleBtn->setButtonIndex(28);
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SELECT")));
setWindowTitle(phrase(QStringLiteral("TITLE_SHIPS"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_SHIPS")));
showNewContent(newMode); showNewContent(newMode);
} }
+15 -42
View File
@@ -31,38 +31,11 @@
#include "Global.h" #include "Global.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
namespace Cevo { namespace Cevo {
namespace Diplomacy { namespace Diplomacy {
namespace { namespace {
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for the (non tribe-specific) keys this file
// looks up directly via Phrases[...].
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("FRCANCELTREATY_PEACE"), QStringLiteral("I hereby cancel our peace treaty.")},
{QStringLiteral("FRCANCELTREATY_FRIENDLY"), QStringLiteral("I hereby end our friendly relations.")},
{QStringLiteral("FRCANCELTREATY_ALLIANCE"), QStringLiteral("I hereby cancel our alliance.")},
{QStringLiteral("FRNOTICE"), QStringLiteral("I have a notice for you.")},
{QStringLiteral("FRDONE"), QStringLiteral("That is all.")},
{QStringLiteral("FRDELCHOICE"), QStringLiteral("in exchange for %1, you may choose what we deliver")},
{QStringLiteral("FRCOSTCHOICE"), QStringLiteral("we offer %1, you may choose the price")},
{QStringLiteral("FROFFER"), QStringLiteral("we offer %1 in exchange for %2")},
{QStringLiteral("PRICE_CHOOSE"), QStringLiteral("something of our choosing")},
{QStringLiteral("PRICE_SHIPCOMP"), QStringLiteral("%1 spaceship component(s)")},
{QStringLiteral("PRICE_SHIPPOW"), QStringLiteral("%1 spaceship power module(s)")},
{QStringLiteral("PRICE_SHIPHAB"), QStringLiteral("%1 spaceship habitation module(s)")},
{QStringLiteral("PRICE_TRIBUTE"), QStringLiteral("a tribute of %1")},
{QStringLiteral("PRICE_CONCAT"), QStringLiteral("%1, %2")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
QString phraseTreaty(int treatyType) QString phraseTreaty(int treatyType)
{ {
switch (treatyType) { switch (treatyType) {
@@ -84,7 +57,7 @@ QString priceToString(int p, std::uint32_t price)
Tribes::Tribe &tribe = *Tribes::tribe[static_cast<std::size_t>(p)]; Tribes::Tribe &tribe = *Tribes::tribe[static_cast<std::size_t>(p)];
switch (price & static_cast<std::uint32_t>(opMask)) { switch (price & static_cast<std::uint32_t>(opMask)) {
case opChoose: case opChoose:
return phrase(QStringLiteral("PRICE_CHOOSE")); return phrases.lookup(QStringLiteral("PRICE_CHOOSE"));
case opCivilReport: case opCivilReport:
return tribe.tPhrase(QStringLiteral("PRICE_CIVIL")); return tribe.tPhrase(QStringLiteral("PRICE_CIVIL"));
case opMilReport: case opMilReport:
@@ -95,15 +68,15 @@ QString priceToString(int p, std::uint32_t price)
return phraseTreaty(static_cast<int>(price - opTreaty)); return phraseTreaty(static_cast<int>(price - opTreaty));
case opShipParts: case opShipParts:
switch ((price >> 16) & 0xFu) { switch ((price >> 16) & 0xFu) {
case 0: return phrase(QStringLiteral("PRICE_SHIPCOMP")).arg(price & 0xFFFFu); case 0: return formatPhrase(QStringLiteral("PRICE_SHIPCOMP"), { QString::number(price & 0xFFFFu) });
case 1: return phrase(QStringLiteral("PRICE_SHIPPOW")).arg(price & 0xFFFFu); case 1: return formatPhrase(QStringLiteral("PRICE_SHIPPOW"), { QString::number(price & 0xFFFFu) });
case 2: return phrase(QStringLiteral("PRICE_SHIPHAB")).arg(price & 0xFFFFu); case 2: return formatPhrase(QStringLiteral("PRICE_SHIPHAB"), { QString::number(price & 0xFFFFu) });
default: return QString(); default: return QString();
} }
case opMoney: case opMoney:
return QStringLiteral("%1%c").arg(price - opMoney); return QStringLiteral("%1%c").arg(price - opMoney);
case opTribute: case opTribute:
return phrase(QStringLiteral("PRICE_TRIBUTE")).arg(price - opTribute); return formatPhrase(QStringLiteral("PRICE_TRIBUTE"), { QString::number(price - opTribute) });
case opTech: case opTech:
return phraseAdvance(static_cast<int>(price - opTech)); return phraseAdvance(static_cast<int>(price - opTech));
case opAllTech: case opAllTech:
@@ -131,16 +104,16 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
switch (command) { switch (command) {
case scDipCancelTreaty: case scDipCancelTreaty:
switch (treaty) { switch (treaty) {
case trPeace: result = phrase(QStringLiteral("FRCANCELTREATY_PEACE")); break; case trPeace: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_PEACE")); break;
case trFriendlyContact: result = phrase(QStringLiteral("FRCANCELTREATY_FRIENDLY")); break; case trFriendlyContact: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_FRIENDLY")); break;
case trAlliance: result = phrase(QStringLiteral("FRCANCELTREATY_ALLIANCE")); break; case trAlliance: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_ALLIANCE")); break;
default: break; default: break;
} }
doIntro = false; doIntro = false;
break; break;
case scDipNotice: case scDipNotice:
result = phrase(QStringLiteral("FRNOTICE")); result = phrases.lookup(QStringLiteral("FRNOTICE"));
break; break;
case scDipAccept: case scDipAccept:
@@ -177,12 +150,12 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
QString sDeliver; QString sDeliver;
for (int i = 0; i < offer.nDeliver; ++i) { for (int i = 0; i < offer.nDeliver; ++i) {
const QString sAdd = priceToString(pSender, offer.Price[i]); const QString sAdd = priceToString(pSender, offer.Price[i]);
sDeliver = i == 0 ? sAdd : phrase(QStringLiteral("PRICE_CONCAT")).arg(sDeliver, sAdd); sDeliver = i == 0 ? sAdd : formatPhrase(QStringLiteral("PRICE_CONCAT"), { sDeliver, sAdd });
} }
QString sCost; QString sCost;
for (int i = 0; i < offer.nCost; ++i) { for (int i = 0; i < offer.nCost; ++i) {
const QString sAdd = priceToString(pTarget, offer.Price[offer.nDeliver + i]); const QString sAdd = priceToString(pTarget, offer.Price[offer.nDeliver + i]);
sCost = i == 0 ? sAdd : phrase(QStringLiteral("PRICE_CONCAT")).arg(sCost, sAdd); sCost = i == 0 ? sAdd : formatPhrase(QStringLiteral("PRICE_CONCAT"), { sCost, sAdd });
} }
if (offer.nDeliver == 0 && offer.nCost == 0) { if (offer.nDeliver == 0 && offer.nCost == 0) {
@@ -194,7 +167,7 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
// here, unreachable without a StringTables.pas port. // here, unreachable without a StringTables.pas port.
result = sender.tPhrase(QStringLiteral("FRNOTACCEPTOFFER")) + QLatin1Char(' '); result = sender.tPhrase(QStringLiteral("FRNOTACCEPTOFFER")) + QLatin1Char(' ');
} }
result += phrase(QStringLiteral("FRDONE")); result += phrases.lookup(QStringLiteral("FRDONE"));
doIntro = false; doIntro = false;
} }
} else if (offer.nDeliver + offer.nCost == 1 && } else if (offer.nDeliver + offer.nCost == 1 &&
@@ -214,11 +187,11 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
} else if (offer.nCost == 0) { } else if (offer.nCost == 0) {
result += target.tPhrase(QStringLiteral("FRPRESENT")).arg(sDeliver); result += target.tPhrase(QStringLiteral("FRPRESENT")).arg(sDeliver);
} else if (offer.nDeliver == 1 && offer.Price[0] == opChoose) { } else if (offer.nDeliver == 1 && offer.Price[0] == opChoose) {
result += phrase(QStringLiteral("FRDELCHOICE")).arg(sCost); result += formatPhrase(QStringLiteral("FRDELCHOICE"), { sCost });
} else if (offer.nCost == 1 && offer.Price[offer.nDeliver] == opChoose) { } else if (offer.nCost == 1 && offer.Price[offer.nDeliver] == opChoose) {
result += phrase(QStringLiteral("FRCOSTCHOICE")).arg(sDeliver); result += formatPhrase(QStringLiteral("FRCOSTCHOICE"), { sDeliver });
} else { } else {
result += phrase(QStringLiteral("FROFFER")).arg(sDeliver, sCost); result += formatPhrase(QStringLiteral("FROFFER"), { sDeliver, sCost });
} }
break; break;
} }
+15 -29
View File
@@ -36,7 +36,6 @@
#include "Term.h" #include "Term.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
#include <QMouseEvent> #include <QMouseEvent>
namespace Cevo { namespace Cevo {
@@ -59,25 +58,6 @@ constexpr int yTotal0 = 354;
constexpr int xView = 17; constexpr int xView = 17;
constexpr int yView0 = 283; constexpr int yView0 = 283;
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("TITLE_DRAFT"), QStringLiteral("Unit Design")},
{QStringLiteral("BTN_OK"), QStringLiteral("OK")},
{QStringLiteral("DOMAIN0"), QStringLiteral("Ground units")},
{QStringLiteral("DOMAIN1"), QStringLiteral("Sea units")},
{QStringLiteral("DOMAIN2"), QStringLiteral("Air units")},
{QStringLiteral("UNITSTRENGTH"), QStringLiteral("Strength")},
{QStringLiteral("UNITTRANSPORT"), QStringLiteral("Transport")},
{QStringLiteral("UNITSPEED"), QStringLiteral("Speed")},
{QStringLiteral("UNITCOST"), QStringLiteral("Cost")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
QString phraseFeature(int code) QString phraseFeature(int code)
{ {
return phrases.lookup(QStringLiteral("FEATURES"), code); return phrases.lookup(QStringLiteral("FEATURES"), code);
@@ -107,12 +87,18 @@ DraftDlg::DraftDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::DraftD
ui->setupUi(this); ui->setupUi(this);
initButtons(); initButtons();
helpContext = QStringLiteral("CLASSES"); helpContext = QStringLiteral("CLASSES");
setWindowTitle(phrase(QStringLiteral("TITLE_DRAFT"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_DRAFT")));
ui->okBtn->setCaption(phrase(QStringLiteral("BTN_OK"))); ui->okBtn->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->groundArea->setToolTip(phrase(QStringLiteral("DOMAIN0"))); if (!phrases2FallenBackToEnglish) {
ui->seaArea->setToolTip(phrase(QStringLiteral("DOMAIN1"))); ui->groundArea->setToolTip(phrases2.lookup(QStringLiteral("DRAFTDOMAIN"), 0));
ui->airArea->setToolTip(phrase(QStringLiteral("DOMAIN2"))); ui->seaArea->setToolTip(phrases2.lookup(QStringLiteral("DRAFTDOMAIN"), 1));
ui->airArea->setToolTip(phrases2.lookup(QStringLiteral("DRAFTDOMAIN"), 2));
} else {
ui->groundArea->setToolTip(phrases.lookup(QStringLiteral("DOMAIN"), 0));
ui->seaArea->setToolTip(phrases.lookup(QStringLiteral("DOMAIN"), 1));
ui->airArea->setToolTip(phrases.lookup(QStringLiteral("DOMAIN"), 2));
}
back.setSize(width(), height()); back.setSize(width(), height());
back.canvas().begin(); back.canvas().begin();
@@ -282,7 +268,7 @@ void DraftDlg::offscreenPaint()
int y = yTotal; int y = yTotal;
darkGradient(canvas, xTotal - 6, y + 1, 184, 2); darkGradient(canvas, xTotal - 6, y + 1, 184, 2);
darkGradient(canvas, xTotal2 + 172, y + 1, 95, 2); darkGradient(canvas, xTotal2 + 172, y + 1, 95, 2);
risedTextOut(canvas, xTotal - 2, y, phrase(QStringLiteral("UNITSTRENGTH"))); risedTextOut(canvas, xTotal - 2, y, phrases.lookup(QStringLiteral("UNITSTRENGTH")));
risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MStrength)); risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MStrength));
risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("=")); risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("="));
const QString s = QStringLiteral("%1/%2").arg(devModel.Attack).arg(devModel.Defense); const QString s = QStringLiteral("%1/%2").arg(devModel.Attack).arg(devModel.Defense);
@@ -293,7 +279,7 @@ void DraftDlg::offscreenPaint()
y = yTotal + 19; y = yTotal + 19;
darkGradient(canvas, xTotal - 6, y + 1, 184, 1); darkGradient(canvas, xTotal - 6, y + 1, 184, 1);
darkGradient(canvas, xTotal2 + 172, y + 1, 95, 1); darkGradient(canvas, xTotal2 + 172, y + 1, 95, 1);
risedTextOut(canvas, xTotal - 2, y, phrase(QStringLiteral("UNITTRANSPORT"))); risedTextOut(canvas, xTotal - 2, y, phrases.lookup(QStringLiteral("UNITTRANSPORT")));
risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MTrans)); risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MTrans));
risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("=")); risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("="));
@@ -325,7 +311,7 @@ void DraftDlg::offscreenPaint()
// speed bar // speed bar
y = yTotal + 38; y = yTotal + 38;
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrase(QStringLiteral("UNITSPEED"))); loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrases.lookup(QStringLiteral("UNITSPEED")));
dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight); dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight);
dLine(canvas, xTotal2 + 176, xTotal2 + 263, y + 16, MainTexture->colorBevelShade, dLine(canvas, xTotal2 + 176, xTotal2 + 263, y + 16, MainTexture->colorBevelShade,
MainTexture->colorBevelLight); MainTexture->colorBevelLight);
@@ -334,7 +320,7 @@ void DraftDlg::offscreenPaint()
// cost bar // cost bar
y = yTotal + 57; y = yTotal + 57;
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrase(QStringLiteral("UNITCOST"))); loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrases.lookup(QStringLiteral("UNITCOST")));
loweredTextOut(canvas, -1, *MainTexture, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MCost)); loweredTextOut(canvas, -1, *MainTexture, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MCost));
loweredTextOut(canvas, -1, *MainTexture, xTotal2 + 148 + 30, y, QStringLiteral("=")); loweredTextOut(canvas, -1, *MainTexture, xTotal2 + 148 + 30, y, QStringLiteral("="));
dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight); dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight);
+4 -17
View File
@@ -49,19 +49,6 @@ namespace Enhance {
namespace { namespace {
// TODO: needs Phrases[] (StringTables.pas not ported) - plain English
// literals until localization is ported.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("TITLE_ENHANCE"), QStringLiteral("Enhance terrain")},
{QStringLiteral("BTN_SELECT"), QStringLiteral("Select terrain")},
{QStringLiteral("TWOTERRAINS"), QStringLiteral("%1/%2")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? *it : key;
}
QString terrainName(int terrType) QString terrainName(int terrType)
{ {
return phrases.lookup(QStringLiteral("TERRAIN"), terrType); return phrases.lookup(QStringLiteral("TERRAIN"), terrType);
@@ -81,8 +68,8 @@ EnhanceDlg::EnhanceDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::EnhanceD
captionRight = ui->closeBtn->x(); captionRight = ui->closeBtn->x();
captionLeft = ui->toggleBtn->x() + ui->toggleBtn->width(); captionLeft = ui->toggleBtn->x() + ui->toggleBtn->width();
initButtons(); initButtons();
setWindowTitle(phrase(QStringLiteral("TITLE_ENHANCE"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_ENHANCE")));
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SELECT")));
popup = new QMenu(this); popup = new QMenu(this);
for (int terrType = fGrass; terrType <= fMountains; ++terrType) { for (int terrType = fGrass; terrType <= fMountains; ++terrType) {
@@ -90,9 +77,9 @@ EnhanceDlg::EnhanceDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::EnhanceD
continue; continue;
QString caption; QString caption;
if (terrType == fGrass) if (terrType == fGrass)
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fGrass)).arg(terrainName(fGrass + 12)); caption = formatPhrase(QStringLiteral("TWOTERRAINS"), { terrainName(fGrass), terrainName(fGrass + 12) });
else if (terrType == fForest) else if (terrType == fForest)
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fForest)).arg(terrainName(Term::fJungle)); caption = formatPhrase(QStringLiteral("TWOTERRAINS"), { terrainName(fForest), terrainName(Term::fJungle) });
else else
caption = terrainName(terrType); caption = terrainName(terrType);
QAction *action = popup->addAction(caption); QAction *action = popup->addAction(caption);
+4 -19
View File
@@ -50,7 +50,6 @@
#include "Messg.h" #include "Messg.h"
#include "Term.h" #include "Term.h"
#include <QHash>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
@@ -69,20 +68,6 @@ namespace {
constexpr int MaxHist = 16; constexpr int MaxHist = 16;
constexpr int ScrollBarWidth = 16; // matches Dpi::ScrollBar's fixed width constexpr int ScrollBarWidth = 16; // matches Dpi::ScrollBar's fixed width
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own chrome text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_CONTENTS"), QStringLiteral("Contents")},
{QStringLiteral("BTN_BACK"), QStringLiteral("Back")},
{QStringLiteral("BTN_SEARCH"), QStringLiteral("Search")},
{QStringLiteral("SEARCH"), QStringLiteral("Search Help")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
// Help.txt phrases carry raw C printf-style specifiers (copied from the // Help.txt phrases carry raw C printf-style specifiers (copied from the
// original's Format() call sites) - NOT Qt's %1/%2 .arg() syntax. Scans // original's Format() call sites) - NOT Qt's %1/%2 .arg() syntax. Scans
// left to right, filling each %d/%s in order from args (supports formats // left to right, filling each %d/%s in order from args (supports formats
@@ -232,9 +217,9 @@ HelpDlg::HelpDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::HelpDlg)
helpText.loadFromFile(localizedFilePath(QStringLiteral("Help/Help.txt"))); helpText.loadFromFile(localizedFilePath(QStringLiteral("Help/Help.txt")));
helpContext = QStringLiteral("CONCEPTS"); helpContext = QStringLiteral("CONCEPTS");
ui->topBtn->setToolTip(phrase(QStringLiteral("BTN_CONTENTS"))); ui->topBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_CONTENTS")));
ui->backBtn->setToolTip(phrase(QStringLiteral("BTN_BACK"))); ui->backBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_BACK")));
ui->searchBtn->setToolTip(phrase(QStringLiteral("BTN_SEARCH"))); ui->searchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SEARCH")));
ui->closeBtn->onClick = [this] { close(); }; ui->closeBtn->onClick = [this] { close(); };
ui->backBtn->onClick = [this] { backBtnClicked(); }; ui->backBtn->onClick = [this] { backBtnClicked(); };
@@ -1157,7 +1142,7 @@ void HelpDlg::topBtnClicked()
void HelpDlg::searchBtnClicked() void HelpDlg::searchBtnClicked()
{ {
auto inputDlg = std::make_unique<InputDlg>(nullptr); auto inputDlg = std::make_unique<InputDlg>(nullptr);
inputDlg->setWindowTitle(phrase(QStringLiteral("SEARCH"))); inputDlg->setWindowTitle(phrases.lookup(QStringLiteral("SEARCH")));
inputDlg->editInput()->setText(searchContent); inputDlg->editInput()->setText(searchContent);
inputDlg->centerToRect(geometry()); inputDlg->centerToRect(geometry());
if (inputDlg->showModal() == Dpi::ModalResult::Ok && inputDlg->editInput()->text().length() >= 2) { if (inputDlg->showModal() == Dpi::ModalResult::Ok && inputDlg->editInput()->text().length() >= 2) {
+25 -70
View File
@@ -37,7 +37,6 @@
#include "Term.h" #include "Term.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
@@ -62,60 +61,14 @@ constexpr int yReport = 165;
constexpr int wReport = 352; constexpr int wReport = 352;
constexpr int hReport = ReportLines * LineSpacing; constexpr int hReport = ReportLines * LineSpacing;
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_SELECT"), QStringLiteral("Select nation")},
{QStringLiteral("BTN_DIALOG"), QStringLiteral("Negotiate")},
{QStringLiteral("FRSTATPOP"), QStringLiteral("Population: %1")},
{QStringLiteral("FRSTATTER"), QStringLiteral("Territory: %1")},
{QStringLiteral("FRSTATTECH"), QStringLiteral("Advances researched: %1")},
{QStringLiteral("FRSTATEXP"), QStringLiteral("Land explored: %1%")},
{QStringLiteral("FROLDCIVILREP"), QStringLiteral("Last report: %1")},
{QStringLiteral("FRTREASURY"), QStringLiteral("Treasury: %1")},
{QStringLiteral("FRRELATIONS"), QStringLiteral("Relations:")},
{QStringLiteral("FRCOLDWAR"), QStringLiteral("We are in a cold war.")},
{QStringLiteral("FRMYANARCHY"), QStringLiteral("We are in anarchy.")},
{QStringLiteral("FRANARCHY"), QStringLiteral("They are in anarchy.")},
{QStringLiteral("FREXTINCT"), QStringLiteral("Extinct since")},
{QStringLiteral("FRCREDIBILITY"), QStringLiteral("Credibility: %1")},
{QStringLiteral("FRNOCONTACT"), QStringLiteral("No contact")},
{QStringLiteral("FRTREATY"), QStringLiteral("Treaty:")},
{QStringLiteral("FRNOVISIT"), QStringLiteral("Never visited")},
{QStringLiteral("FRLASTCONTACT"), QStringLiteral("Last contact:")},
{QStringLiteral("FRNOCIVILREP"), QStringLiteral("No civil report available.")},
{QStringLiteral("MENU_TELLAI"), QStringLiteral("Tell AI")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
QString phraseGovernment(int government) QString phraseGovernment(int government)
{ {
return QStringLiteral("government #%1 ").arg(government); return phrases.lookup(QStringLiteral("GOVERNMENT"), government);
} }
QString phraseCredibility(int roughCredibility) QString phraseCredibility(int roughCredibility)
{ {
static const QHash<int, QString> table = { return phrases.lookup(QStringLiteral("CREDIBILITY"), roughCredibility);
{0, QStringLiteral("poor")}, {1, QStringLiteral("fair")}, {2, QStringLiteral("good")},
{3, QStringLiteral("perfect")},
};
const auto it = table.constFind(roughCredibility);
return it != table.constEnd() ? it.value() : QString();
}
QString phraseTreaty(int treaty)
{
static const QHash<int, QString> table = {
{trNoContact, QStringLiteral("no contact")}, {trNone, QStringLiteral("none")},
{trCeaseFire, QStringLiteral("cease-fire")}, {trPeace, QStringLiteral("peace")},
{trFriendlyContact, QStringLiteral("friendly")}, {trAlliance, QStringLiteral("alliance")},
};
const auto it = table.constFind(treaty);
return it != table.constEnd() ? it.value() : QString();
} }
} // namespace } // namespace
@@ -127,8 +80,8 @@ NatStatDlg::NatStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::Na
ui->contactBtn->setTemplate(Templates ? &Templates->data : nullptr); ui->contactBtn->setTemplate(Templates ? &Templates->data : nullptr);
ui->contactBtn->setButtonIndex(3); ui->contactBtn->setButtonIndex(3);
helpContext = QStringLiteral("DIPLOMACY"); helpContext = QStringLiteral("DIPLOMACY");
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SELECT")));
ui->contactBtn->setToolTip(phrase(QStringLiteral("BTN_DIALOG"))); ui->contactBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_DIALOG")));
back.setSize(width(), height()); back.setSize(width(), height());
back.canvas().begin(); back.canvas().begin();
@@ -237,11 +190,12 @@ void NatStatDlg::generateReportText()
ClientTools::server(sGetChart + (no << 4), ClientTools::me, pView, list.data()) >= rExecuted) { ClientTools::server(sGetChart + (no << 4), ClientTools::me, pView, list.data()) >= rExecuted) {
const int i = list[static_cast<std::size_t>(currentReport->TurnOfCivilReport)]; const int i = list[static_cast<std::size_t>(currentReport->TurnOfCivilReport)];
switch (no) { switch (no) {
case stPop: return phrase(QStringLiteral("FRSTATPOP")).arg(i); case stPop: return formatPhrase(QStringLiteral("FRSTATPOP"), { QString::number(i) });
case stTerritory: return phrase(QStringLiteral("FRSTATTER")).arg(i); case stTerritory: return formatPhrase(QStringLiteral("FRSTATTER"), { QString::number(i) });
case stScience: return phrase(QStringLiteral("FRSTATTECH")).arg(i / nAdv); case stScience: return formatPhrase(QStringLiteral("FRSTATTECH"), { QString::number(i / nAdv) });
case stExplore: case stExplore:
return phrase(QStringLiteral("FRSTATEXP")).arg(i * 100 / (ClientTools::g.lx * ClientTools::g.ly)); return formatPhrase(QStringLiteral("FRSTATEXP"),
{ QString::number(i * 100 / (ClientTools::g.lx * ClientTools::g.ly)) });
default: return QString(); default: return QString();
} }
} }
@@ -252,12 +206,12 @@ void NatStatDlg::generateReportText()
reportText.append(QString()); reportText.append(QString());
if (ClientTools::myRO->Turn - currentReport->TurnOfCivilReport > 1 && if (ClientTools::myRO->Turn - currentReport->TurnOfCivilReport > 1 &&
(1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) { (1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) {
reportText.append(phrase(QStringLiteral("FROLDCIVILREP")).arg(Term::turnToString(currentReport->TurnOfCivilReport))); reportText.append(formatPhrase(QStringLiteral("FROLDCIVILREP"), { Term::turnToString(currentReport->TurnOfCivilReport) }));
reportText.append(QString()); reportText.append(QString());
} }
if ((1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) { if ((1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) {
reportText.append(phrase(QStringLiteral("FRTREASURY")).arg(currentReport->Money)); reportText.append(formatPhrase(QStringLiteral("FRTREASURY"), { QString::number(currentReport->Money) }));
reportText.append(statText(stPop)); reportText.append(statText(stPop));
reportText.append(statText(stTerritory)); reportText.append(statText(stTerritory));
} }
@@ -272,13 +226,14 @@ void NatStatDlg::generateReportText()
} }
if (hasContact) { if (hasContact) {
reportText.append(QString()); reportText.append(QString());
reportText.append(phrase(QStringLiteral("FRRELATIONS"))); reportText.append(phrases.lookup(QStringLiteral("FRRELATIONS")));
for (int extinctPart = 0; extinctPart <= 1; ++extinctPart) { for (int extinctPart = 0; extinctPart <= 1; ++extinctPart) {
for (int treaty = trAlliance; treaty >= trNone; --treaty) { for (int treaty = trAlliance; treaty >= trNone; --treaty) {
for (int p1 = 0; p1 < nPl; ++p1) { for (int p1 = 0; p1 < nPl; ++p1) {
if (p1 != ClientTools::me && currentReport->Treaty[p1] == treaty && if (p1 != ClientTools::me && currentReport->Treaty[p1] == treaty &&
((1u << p1 & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0) == (extinctPart != 0)) { ((1u << p1 & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0) == (extinctPart != 0)) {
QString s = Tribes::tribe[static_cast<std::size_t>(p1)]->tString(phraseTreaty(treaty)); QString s = Tribes::tribe[static_cast<std::size_t>(p1)]->tString(
phrases.lookup(QStringLiteral("HAVETREATY"), treaty));
if (extinctPart) if (extinctPart)
s = QLatin1Char('(') + s + QLatin1Char(')'); s = QLatin1Char('(') + s + QLatin1Char(')');
reportText.append(s); reportText.append(s);
@@ -315,38 +270,38 @@ void NatStatDlg::offscreenPaint()
if (pView == ClientTools::me || !extinct) if (pView == ClientTools::me || !extinct)
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib,
phraseGovernment(currentReport->Government) + QStringLiteral("and")); phraseGovernment(currentReport->Government) + phrases.lookup(QStringLiteral("FRAND")));
if (pView == ClientTools::me) { if (pView == ClientTools::me) {
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
phraseCredibility(Term::roughCredibility(ClientTools::myRO->Credibility))); phraseCredibility(Term::roughCredibility(ClientTools::myRO->Credibility)));
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38,
phrase(QStringLiteral("FRCREDIBILITY")).arg(ClientTools::myRO->Credibility)); formatPhrase(QStringLiteral("FRCREDIBILITY"), { QString::number(ClientTools::myRO->Credibility) }));
} else { } else {
if (extinct) { if (extinct) {
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 9, phrase(QStringLiteral("FREXTINCT"))); loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 9, phrases.lookup(QStringLiteral("FREXTINCT")));
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 28, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 28,
Term::turnToString(currentReport->TurnOfCivilReport)); Term::turnToString(currentReport->TurnOfCivilReport));
} else { } else {
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
phraseCredibility(Term::roughCredibility(currentReport->Credibility))); phraseCredibility(Term::roughCredibility(currentReport->Credibility)));
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38, loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38,
phrase(QStringLiteral("FRCREDIBILITY")).arg(currentReport->Credibility)); formatPhrase(QStringLiteral("FRCREDIBILITY"), { QString::number(currentReport->Credibility) }));
} }
if (ClientTools::myRO->Treaty[pView] == trNoContact) { if (ClientTools::myRO->Treaty[pView] == trNoContact) {
const QString s = phrase(QStringLiteral("FRNOCONTACT")); const QString s = phrases.lookup(QStringLiteral("FRNOCONTACT"));
loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, yRelation + 9, s); loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, yRelation + 9, s);
} else if (showContact) { } else if (showContact) {
loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation, phrase(QStringLiteral("FRTREATY"))); loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation, phrases.lookup(QStringLiteral("FRTREATY")));
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation, loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation,
phraseTreaty(ClientTools::myRO->Treaty[pView])); phrases.lookup(QStringLiteral("TREATY"), ClientTools::myRO->Treaty[pView]));
if (currentReport->TurnOfContact < 0) { if (currentReport->TurnOfContact < 0) {
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19, loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
phrase(QStringLiteral("FRNOVISIT"))); phrases.lookup(QStringLiteral("FRNOVISIT")));
} else { } else {
loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation + 19, loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation + 19,
phrase(QStringLiteral("FRLASTCONTACT"))); phrases.lookup(QStringLiteral("FRLASTCONTACT")));
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19, loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
Term::turnToString(currentReport->TurnOfContact)); Term::turnToString(currentReport->TurnOfContact));
} }
@@ -374,7 +329,7 @@ void NatStatDlg::offscreenPaint()
} }
} }
} else { } else {
const QString s = phrase(QStringLiteral("FRNOCIVILREP")); const QString s = phrases.lookup(QStringLiteral("FRNOCIVILREP"));
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, yReport + hReport / 2 - 10, s); risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, yReport + hReport / 2 - 10, s);
} }
@@ -382,7 +337,7 @@ void NatStatDlg::offscreenPaint()
// Server(sGetAIInfo,...) returning a live AI-credits string isn't wired here yet. // Server(sGetAIInfo,...) returning a live AI-credits string isn't wired here yet.
loweredTextOut(canvas, -1, *MainTexture, 42, 445, QString()); loweredTextOut(canvas, -1, *MainTexture, 42, 445, QString());
} else { } else {
loweredTextOut(canvas, -2, *MainTexture, 42, 445, phrase(QStringLiteral("MENU_TELLAI"))); loweredTextOut(canvas, -2, *MainTexture, 42, 445, phrases.lookup(QStringLiteral("MENU_TELLAI")));
} }
ui->contactBtn->setBack(canvas, ui->contactBtn->x(), ui->contactBtn->y()); ui->contactBtn->setBack(canvas, ui->contactBtn->x(), ui->contactBtn->y());
+28 -84
View File
@@ -34,6 +34,7 @@
#include "Cevo/CevoTexture.h" #include "Cevo/CevoTexture.h"
#include "ClientTools.h" #include "ClientTools.h"
#include "Diplomacy.h" #include "Diplomacy.h"
#include "Global.h"
#include "Inp.h" #include "Inp.h"
#include "IsoEngine.h" #include "IsoEngine.h"
#include "MessgEx.h" #include "MessgEx.h"
@@ -92,54 +93,6 @@ const std::array<std::uint32_t, 12> ButtonPrice = {
static_cast<std::uint32_t>(opShipParts), static_cast<std::uint32_t>(opShipParts), static_cast<std::uint32_t>(opShipParts), static_cast<std::uint32_t>(opShipParts),
}; };
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_OK"), QStringLiteral("OK")},
{QStringLiteral("BTN_ACCEPT"), QStringLiteral("Accept")},
{QStringLiteral("BTN_BREAK"), QStringLiteral("Break off")},
{QStringLiteral("BTN_CNTREATY"), QStringLiteral("Cancel treaty")},
{QStringLiteral("BTN_NOTICE"), QStringLiteral("Notice")},
{QStringLiteral("BTN_PASS"), QStringLiteral("Pass")},
{QStringLiteral("BTN_WANTPEACE"), QStringLiteral("Want peace")},
{QStringLiteral("BTN_OFFERPEACE"), QStringLiteral("Offer peace")},
{QStringLiteral("BTN_WANTFRIENDLY"), QStringLiteral("Want friendly relations")},
{QStringLiteral("BTN_OFFERFRIENDLY"), QStringLiteral("Offer friendly relations")},
{QStringLiteral("BTN_WANTALLIANCE"), QStringLiteral("Want alliance")},
{QStringLiteral("BTN_OFFERALLIANCE"), QStringLiteral("Offer alliance")},
{QStringLiteral("MAX2WANTS"), QStringLiteral("You can only ask for 2 things at once.")},
{QStringLiteral("MAX2OFFERS"), QStringLiteral("You can only offer 2 things at once.")},
{QStringLiteral("CANCELTREATYRUSH"), QStringLiteral("You can't cancel the treaty again so soon.")},
{QStringLiteral("TITLE_AMOUNT"), QStringLiteral("Enter amount")},
{QStringLiteral("TITLE_NUMBER"), QStringLiteral("Enter number")},
{QStringLiteral("NOSPACEPORT"), QStringLiteral("We have no space port to ship parts from.")},
{QStringLiteral("WANT_ANYTHING"), QStringLiteral("Anything")},
{QStringLiteral("WANT_STATEREPORT"), QStringLiteral("State report")},
{QStringLiteral("WANT_MILREPORT"), QStringLiteral("Military report")},
{QStringLiteral("WANT_MAP"), QStringLiteral("Map")},
{QStringLiteral("WANT_TECH"), QStringLiteral("Advance")},
{QStringLiteral("WANT_MODEL"), QStringLiteral("Unit design")},
{QStringLiteral("WANT_MONEY"), QStringLiteral("Money")},
{QStringLiteral("WANT_HITREATY"), QStringLiteral("Improve treaty")},
{QStringLiteral("WANT_LOTREATY"), QStringLiteral("Worsen treaty")},
{QStringLiteral("WANT_SHIPPART"), QStringLiteral("Ship part")},
{QStringLiteral("OFFER_ANYTHING"), QStringLiteral("Anything")},
{QStringLiteral("OFFER_STATEREPORT"), QStringLiteral("State report")},
{QStringLiteral("OFFER_MILREPORT"), QStringLiteral("Military report")},
{QStringLiteral("OFFER_MAP"), QStringLiteral("Map")},
{QStringLiteral("OFFER_TECH"), QStringLiteral("Advance")},
{QStringLiteral("OFFER_MODEL"), QStringLiteral("Unit design")},
{QStringLiteral("OFFER_MONEY"), QStringLiteral("Money")},
{QStringLiteral("OFFER_HITREATY"), QStringLiteral("Improve treaty")},
{QStringLiteral("OFFER_LOTREATY"), QStringLiteral("Worsen treaty")},
{QStringLiteral("OFFER_SHIPPART"), QStringLiteral("Ship part")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? *it : key;
}
} // namespace } // namespace
NegoDlg::NegoDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::NegoDlg) NegoDlg::NegoDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::NegoDlg)
@@ -154,24 +107,15 @@ NegoDlg::NegoDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::NegoDlg)
ui->offerTech1Btn, ui->offerTech2Btn, ui->offerModelBtn, ui->offerMoneyBtn, ui->offerTech1Btn, ui->offerTech2Btn, ui->offerModelBtn, ui->offerMoneyBtn,
ui->offerHiTreatyBtn, ui->offerLoTreatyBtn, ui->offerShipPart1Btn, ui->offerShipPart2Btn}; ui->offerHiTreatyBtn, ui->offerLoTreatyBtn, ui->offerShipPart1Btn, ui->offerShipPart2Btn};
const std::array<QString, 12> wantHints = {
phrase(QStringLiteral("WANT_ANYTHING")), phrase(QStringLiteral("WANT_STATEREPORT")),
phrase(QStringLiteral("WANT_MILREPORT")), phrase(QStringLiteral("WANT_MAP")),
phrase(QStringLiteral("WANT_TECH")), phrase(QStringLiteral("WANT_TECH")),
phrase(QStringLiteral("WANT_MODEL")), phrase(QStringLiteral("WANT_MONEY")),
phrase(QStringLiteral("WANT_HITREATY")), phrase(QStringLiteral("WANT_LOTREATY")),
phrase(QStringLiteral("WANT_SHIPPART")), phrase(QStringLiteral("WANT_SHIPPART")),
};
const std::array<QString, 12> offerHints = {
phrase(QStringLiteral("OFFER_ANYTHING")), phrase(QStringLiteral("OFFER_STATEREPORT")),
phrase(QStringLiteral("OFFER_MILREPORT")), phrase(QStringLiteral("OFFER_MAP")),
phrase(QStringLiteral("OFFER_TECH")), phrase(QStringLiteral("OFFER_TECH")),
phrase(QStringLiteral("OFFER_MODEL")), phrase(QStringLiteral("OFFER_MONEY")),
phrase(QStringLiteral("OFFER_HITREATY")), phrase(QStringLiteral("OFFER_LOTREATY")),
phrase(QStringLiteral("OFFER_SHIPPART")), phrase(QStringLiteral("OFFER_SHIPPART")),
};
const std::array<int, 12> buttonIndex = {17, 6, 7, 8, 10, 10, 11, 12, 14, 15, 16, 16}; const std::array<int, 12> buttonIndex = {17, 6, 7, 8, 10, 10, 11, 12, 14, 15, 16, 16};
std::array<QString, 12> wantHints;
std::array<QString, 12> offerHints;
for (int i = 0; i < 12; ++i) {
wantHints[static_cast<std::size_t>(i)] = phrases.lookup(QStringLiteral("WANT"), buttonIndex[static_cast<std::size_t>(i)] - 6);
offerHints[static_cast<std::size_t>(i)] = phrases.lookup(QStringLiteral("OFFER"), buttonIndex[static_cast<std::size_t>(i)] - 6);
}
for (int i = 0; i < 12; ++i) { for (int i = 0; i < 12; ++i) {
ButtonN *w = wantButtons[static_cast<std::size_t>(i)]; ButtonN *w = wantButtons[static_cast<std::size_t>(i)];
ButtonN *o = offerButtons[static_cast<std::size_t>(i)]; ButtonN *o = offerButtons[static_cast<std::size_t>(i)];
@@ -210,10 +154,10 @@ NegoDlg::NegoDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::NegoDlg)
ui->cancelTreatyBtn->onClick = [this] { fastClicked(scDipCancelTreaty - scDipStart); }; ui->cancelTreatyBtn->onClick = [this] { fastClicked(scDipCancelTreaty - scDipStart); };
helpContext = QStringLiteral("DIPLOMACY"); helpContext = QStringLiteral("DIPLOMACY");
ui->okBtn->setCaption(phrase(QStringLiteral("BTN_OK"))); ui->okBtn->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->acceptBtn->setSmartHint(phrase(QStringLiteral("BTN_ACCEPT"))); ui->acceptBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_ACCEPT")));
ui->exitBtn->setSmartHint(phrase(QStringLiteral("BTN_BREAK"))); ui->exitBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_BREAK")));
ui->cancelTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_CNTREATY"))); ui->cancelTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_CNTREATY")));
romanFont.setName(QStringLiteral("Times New Roman")); romanFont.setName(QStringLiteral("Times New Roman"));
romanFont.setSize(20); romanFont.setSize(20);
@@ -275,20 +219,20 @@ void NegoDlg::showNewContent(WindowMode newMode)
setButtonStates(); setButtonStates();
const int pContact = Term::dipMem[static_cast<std::size_t>(ClientTools::me)].pContact; const int pContact = Term::dipMem[static_cast<std::size_t>(ClientTools::me)].pContact;
ui->passBtn->setSmartHint(IsoEngine::clientMode == scDipCancelTreaty || IsoEngine::clientMode == scDipBreak ui->passBtn->setSmartHint(IsoEngine::clientMode == scDipCancelTreaty || IsoEngine::clientMode == scDipBreak
? phrase(QStringLiteral("BTN_NOTICE")) ? phrases.lookup(QStringLiteral("BTN_NOTICE"))
: phrase(QStringLiteral("BTN_PASS"))); : phrases.lookup(QStringLiteral("BTN_PASS")));
switch (ClientTools::myRO->Treaty[pContact]) { switch (ClientTools::myRO->Treaty[pContact]) {
case trNone: case trNone:
ui->wantHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_WANTPEACE"))); ui->wantHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_WANTPEACE")));
ui->offerHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_OFFERPEACE"))); ui->offerHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_OFFERPEACE")));
break; break;
case trPeace: case trPeace:
ui->wantHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_WANTFRIENDLY"))); ui->wantHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_WANTFRIENDLY")));
ui->offerHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_OFFERFRIENDLY"))); ui->offerHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_OFFERFRIENDLY")));
break; break;
case trFriendlyContact: case trFriendlyContact:
ui->wantHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_WANTALLIANCE"))); ui->wantHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_WANTALLIANCE")));
ui->offerHiTreatyBtn->setSmartHint(phrase(QStringLiteral("BTN_OFFERALLIANCE"))); ui->offerHiTreatyBtn->setSmartHint(phrases.lookup(QStringLiteral("BTN_OFFERALLIANCE")));
break; break;
default: default:
break; break;
@@ -671,7 +615,7 @@ void NegoDlg::wantClicked(int priceIndex)
price = 0xFFFFFFFFu; // toggle off price = 0xFFFFFFFFu; // toggle off
} else { } else {
if (currentOffer.nCost >= 2) { if (currentOffer.nCost >= 2) {
MessgEx::soundMessageEx(phrase(QStringLiteral("MAX2WANTS")), QString()); MessgEx::soundMessageEx(phrases.lookup(QStringLiteral("MAX2WANTS")), QString());
return; return;
} }
price = ButtonPrice[static_cast<std::size_t>(priceIndex)]; price = ButtonPrice[static_cast<std::size_t>(priceIndex)];
@@ -684,7 +628,7 @@ void NegoDlg::wantClicked(int priceIndex)
break; break;
case static_cast<std::uint32_t>(opMoney): { case static_cast<std::uint32_t>(opMoney): {
InputDlg dlg; InputDlg dlg;
dlg.setWindowTitle(phrase(QStringLiteral("TITLE_AMOUNT"))); dlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_AMOUNT")));
dlg.editInput()->setText(QString()); dlg.editInput()->setText(QString());
dlg.centerToRect(geometry()); dlg.centerToRect(geometry());
if (dlg.showModal() != Dpi::ModalResult::Ok) if (dlg.showModal() != Dpi::ModalResult::Ok)
@@ -700,7 +644,7 @@ void NegoDlg::wantClicked(int priceIndex)
if (ClientTools::myRO->NatBuilt[imSpacePort] == 0) { if (ClientTools::myRO->NatBuilt[imSpacePort] == 0) {
if (auto *dlg = Term::mainScreenMessgExDlg()) { if (auto *dlg = Term::mainScreenMessgExDlg()) {
dlg->openSound = QStringLiteral("WARNING_LOWSUPPORT"); dlg->openSound = QStringLiteral("WARNING_LOWSUPPORT");
dlg->messageText = phrase(QStringLiteral("NOSPACEPORT")); dlg->messageText = phrases.lookup(QStringLiteral("NOSPACEPORT"));
dlg->kind = MessageKind::YesNo; dlg->kind = MessageKind::YesNo;
dlg->iconKind = MessgEx::MessageIconKind::Imp; dlg->iconKind = MessgEx::MessageIconKind::Imp;
dlg->iconIndex = imSpacePort; dlg->iconIndex = imSpacePort;
@@ -717,7 +661,7 @@ void NegoDlg::wantClicked(int priceIndex)
price += static_cast<std::uint32_t>(selectDlg->result << 16); price += static_cast<std::uint32_t>(selectDlg->result << 16);
int max = ClientTools::myRO->Ship[pContact].Parts[selectDlg->result]; int max = ClientTools::myRO->Ship[pContact].Parts[selectDlg->result];
InputDlg amountDlg; InputDlg amountDlg;
amountDlg.setWindowTitle(phrase(QStringLiteral("TITLE_NUMBER"))); amountDlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_NUMBER")));
amountDlg.editInput()->setText(QString()); amountDlg.editInput()->setText(QString());
amountDlg.centerToRect(geometry()); amountDlg.centerToRect(geometry());
if (amountDlg.showModal() != Dpi::ModalResult::Ok) if (amountDlg.showModal() != Dpi::ModalResult::Ok)
@@ -788,7 +732,7 @@ void NegoDlg::offerClicked(int priceIndex)
price = 0xFFFFFFFFu; // toggle off price = 0xFFFFFFFFu; // toggle off
} else { } else {
if (currentOffer.nDeliver >= 2) { if (currentOffer.nDeliver >= 2) {
MessgEx::soundMessageEx(phrase(QStringLiteral("MAX2OFFERS")), QString()); MessgEx::soundMessageEx(phrases.lookup(QStringLiteral("MAX2OFFERS")), QString());
return; return;
} }
price = ButtonPrice[static_cast<std::size_t>(priceIndex)]; price = ButtonPrice[static_cast<std::size_t>(priceIndex)];
@@ -801,7 +745,7 @@ void NegoDlg::offerClicked(int priceIndex)
break; break;
case static_cast<std::uint32_t>(opMoney): { case static_cast<std::uint32_t>(opMoney): {
InputDlg dlg; InputDlg dlg;
dlg.setWindowTitle(phrase(QStringLiteral("TITLE_AMOUNT"))); dlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_AMOUNT")));
dlg.editInput()->setText(QString()); dlg.editInput()->setText(QString());
dlg.centerToRect(geometry()); dlg.centerToRect(geometry());
if (dlg.showModal() != Dpi::ModalResult::Ok) if (dlg.showModal() != Dpi::ModalResult::Ok)
@@ -825,7 +769,7 @@ void NegoDlg::offerClicked(int priceIndex)
price += static_cast<std::uint32_t>(selectDlg->result << 16); price += static_cast<std::uint32_t>(selectDlg->result << 16);
int max = ClientTools::myRO->Ship[me].Parts[selectDlg->result]; int max = ClientTools::myRO->Ship[me].Parts[selectDlg->result];
InputDlg amountDlg; InputDlg amountDlg;
amountDlg.setWindowTitle(phrase(QStringLiteral("TITLE_NUMBER"))); amountDlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_NUMBER")));
amountDlg.editInput()->setText(QString()); amountDlg.editInput()->setText(QString());
amountDlg.centerToRect(geometry()); amountDlg.centerToRect(geometry());
if (amountDlg.showModal() != Dpi::ModalResult::Ok) if (amountDlg.showModal() != Dpi::ModalResult::Ok)
@@ -893,7 +837,7 @@ void NegoDlg::fastClicked(int commandOffset)
ClientTools::myRO->Turn < ClientTools::myRO->Turn <
ClientTools::myRO->LastCancelTreaty[Term::dipMem[static_cast<std::size_t>(ClientTools::me)].pContact] + ClientTools::myRO->LastCancelTreaty[Term::dipMem[static_cast<std::size_t>(ClientTools::me)].pContact] +
CancelTreatyTurns) { CancelTreatyTurns) {
MessgEx::soundMessageEx(phrase(QStringLiteral("CANCELTREATYRUSH")), QString()); MessgEx::soundMessageEx(phrases.lookup(QStringLiteral("CANCELTREATYRUSH")), QString());
return; return;
} }
if (newCommand == scDipOffer && (IsoEngine::clientMode == scDipCancelTreaty || IsoEngine::clientMode == scDipBreak)) if (newCommand == scDipOffer && (IsoEngine::clientMode == scDipCancelTreaty || IsoEngine::clientMode == scDipBreak))
+7 -24
View File
@@ -32,11 +32,10 @@
#include "Cevo/CevoScreenTools.h" #include "Cevo/CevoScreenTools.h"
#include "Cevo/CevoTexture.h" #include "Cevo/CevoTexture.h"
#include "ClientTools.h" #include "ClientTools.h"
#include "Global.h"
#include "Term.h" #include "Term.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
namespace Cevo { namespace Cevo {
namespace Rates { namespace Rates {
@@ -44,22 +43,6 @@ namespace {
constexpr int MessageLineSpacing = 20; constexpr int MessageLineSpacing = 20;
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("TITLE_RATES"), QStringLiteral("Rates")},
{QStringLiteral("NORATES"), QStringLiteral("The Statue of Liberty lets your people decide for themselves.")},
{QStringLiteral("RATES"), QStringLiteral("Set your tax, science and luxury rates.\\(click the arrows)")},
{QStringLiteral("SCIENCE"), QStringLiteral("Science")},
{QStringLiteral("LUX"), QStringLiteral("Luxury")},
{QStringLiteral("TAXRATE"), QStringLiteral("Tax")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
} // namespace } // namespace
RatesDlg::RatesDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::RatesDlg) RatesDlg::RatesDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::RatesDlg)
@@ -74,7 +57,7 @@ RatesDlg::RatesDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::RatesD
ui->scienceBtn->onClick = [this] { taxLuxBtnClick(2); }; ui->scienceBtn->onClick = [this] { taxLuxBtnClick(2); };
ui->luxBtn->onClick = [this] { taxLuxBtnClick(3); }; ui->luxBtn->onClick = [this] { taxLuxBtnClick(3); };
onShow = [this] { onShow = [this] {
setWindowTitle(phrase(QStringLiteral("TITLE_RATES"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_RATES")));
const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me; const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me;
ui->scienceBtn->setVisible(!hasLiberty); ui->scienceBtn->setVisible(!hasLiberty);
ui->luxBtn->setVisible(!hasLiberty); ui->luxBtn->setVisible(!hasLiberty);
@@ -101,11 +84,11 @@ void RatesDlg::offscreenPaint()
btnFrame(canvas, ui->closeBtn->geometry(), *MainTexture); btnFrame(canvas, ui->closeBtn->geometry(), *MainTexture);
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
QString s = phrase(QStringLiteral("TITLE_RATES")); QString s = phrases.lookup(QStringLiteral("TITLE_RATES"));
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2 - 1, 7, s); risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2 - 1, 7, s);
const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me; const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me;
s = phrase(hasLiberty ? QStringLiteral("NORATES") : QStringLiteral("RATES")); s = phrases.lookup(hasLiberty ? QStringLiteral("NORATES") : QStringLiteral("RATES"));
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
const int p = s.indexOf(QLatin1Char('\\')); const int p = s.indexOf(QLatin1Char('\\'));
if (p < 0) { if (p < 0) {
@@ -125,7 +108,7 @@ void RatesDlg::offscreenPaint()
bitBltBitmap(offscreen, width() / 2 - xSizeBig / 2, 52, xSizeBig, ySizeBig, *bigImp, (woLiberty % 7) * xSizeBig, bitBltBitmap(offscreen, width() / 2 - xSizeBig / 2, 52, xSizeBig, ySizeBig, *bigImp, (woLiberty % 7) * xSizeBig,
(woLiberty / 7 + Term::SystemIconLines) * ySizeBig); (woLiberty / 7 + Term::SystemIconLines) * ySizeBig);
} else { } else {
s = phrase(QStringLiteral("SCIENCE")); s = phrases.lookup(QStringLiteral("SCIENCE"));
risedTextOut(canvas, 16 + 120 - biColorTextWidth(canvas, s), 44, s); risedTextOut(canvas, 16 + 120 - biColorTextWidth(canvas, s), 44, s);
s = QStringLiteral("%1%").arg(100 - ClientTools::myRO->TaxRate - ClientTools::myRO->LuxRate); s = QStringLiteral("%1%").arg(100 - ClientTools::myRO->TaxRate - ClientTools::myRO->LuxRate);
risedTextOut(canvas, 16 + 120 - biColorTextWidth(canvas, s), 60, s); risedTextOut(canvas, 16 + 120 - biColorTextWidth(canvas, s), 60, s);
@@ -145,7 +128,7 @@ void RatesDlg::offscreenPaint()
canvas.fillRect(QRect(x, y, max - current, 7)); canvas.fillRect(QRect(x, y, max - current, 7));
canvas.brush().setStyle(Qt::NoBrush); canvas.brush().setStyle(Qt::NoBrush);
risedTextOut(canvas, 16 + 160, 44, phrase(QStringLiteral("LUX"))); risedTextOut(canvas, 16 + 160, 44, phrases.lookup(QStringLiteral("LUX")));
s = QStringLiteral("%1%").arg(ClientTools::myRO->LuxRate); s = QStringLiteral("%1%").arg(ClientTools::myRO->LuxRate);
risedTextOut(canvas, 16 + 160, 60, s); risedTextOut(canvas, 16 + 160, 60, s);
paintProgressBar(canvas, 5, 16 + 160, 81, ClientTools::myRO->LuxRate * 120 / 100, 0, 120, *MainTexture); paintProgressBar(canvas, 5, 16 + 160, 81, ClientTools::myRO->LuxRate * 120 / 100, 0, 120, *MainTexture);
@@ -154,7 +137,7 @@ void RatesDlg::offscreenPaint()
} }
dLine(canvas, 1, width() - 2, 154, MainTexture->colorBevelShade, MainTexture->colorBevelLight); dLine(canvas, 1, width() - 2, 154, MainTexture->colorBevelShade, MainTexture->colorBevelLight);
risedTextOut(canvas, 16 + 80, 164, phrase(QStringLiteral("TAXRATE"))); risedTextOut(canvas, 16 + 80, 164, phrases.lookup(QStringLiteral("TAXRATE")));
s = QStringLiteral("%1%").arg(ClientTools::myRO->TaxRate); s = QStringLiteral("%1%").arg(ClientTools::myRO->TaxRate);
risedTextOut(canvas, 16 + 80, 180, s); risedTextOut(canvas, 16 + 80, 180, s);
paintProgressBar(canvas, 0, 16 + 80, 201, ClientTools::myRO->TaxRate * 120 / 100, 0, 120, *MainTexture); paintProgressBar(canvas, 0, 16 + 80, 201, ClientTools::myRO->TaxRate * 120 / 100, 0, 120, *MainTexture);
+30 -70
View File
@@ -62,46 +62,6 @@ bool mustChoose(ListKind kind)
return kind == ListKind::Tribe || kind == ListKind::StealTech || kind == ListKind::Government; return kind == ListKind::Tribe || kind == ListKind::StealTech || kind == ListKind::Government;
} }
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("BTN_IMPRS"), QStringLiteral("Improvements")},
{QStringLiteral("BTN_WONDERS"), QStringLiteral("Wonders")},
{QStringLiteral("BTN_CLASSES"), QStringLiteral("Unit classes")},
{QStringLiteral("BTN_PAGE"), QStringLiteral("Show events")},
{QStringLiteral("BTN_SELECT"), QStringLiteral("Select player")},
{QStringLiteral("FARTECH"), QStringLiteral("Research focus")},
{QStringLiteral("TECHFOCUS"), QStringLiteral("Research focus: %1")},
{QStringLiteral("TITLE_CITIES"), QStringLiteral("Cities")},
{QStringLiteral("TITLE_EVENTS"), QStringLiteral("Events (%1)")},
{QStringLiteral("SHIFTCLICK"), QStringLiteral("Shift+click for more information")},
{QStringLiteral("CONSCRIPTS"), QStringLiteral("%1 (conscripts)")},
{QStringLiteral("NATEXISTS"), QStringLiteral("%1 (already built elsewhere)")},
{QStringLiteral("PRICECAT_ALLMODEL"), QStringLiteral("All unit designs")},
{QStringLiteral("PRICECAT_ALLTECH"), QStringLiteral("All advances")},
{QStringLiteral("NEXUS"), QStringLiteral("Galactic Nexus")},
{QStringLiteral("NOFARTECH"), QStringLiteral("No research focus")},
{QStringLiteral("INITUNIT"), QStringLiteral("New unit class")},
{QStringLiteral("SCIENCEREPORT_EXTINCT"), QStringLiteral("%1 (extinct)")},
{QStringLiteral("TITLE_PROJECT"), QStringLiteral("Choose project")},
{QStringLiteral("TITLE_TECHSELECT"), QStringLiteral("Choose advance")},
{QStringLiteral("TITLE_FARTECH"), QStringLiteral("Choose research focus")},
{QStringLiteral("FRMILREP"), QStringLiteral("Military report")},
{QStringLiteral("TITLE_EMODELS"), QStringLiteral("Enemy unit designs")},
{QStringLiteral("TITLE_TRIBE"), QStringLiteral("Choose nation")},
{QStringLiteral("TITLE_SCIENCE"), QStringLiteral("Science report")},
{QStringLiteral("TITLE_CHOOSESHIPPART"), QStringLiteral("Choose ship part")},
{QStringLiteral("TITLE_CHOOSETECH"), QStringLiteral("Choose advance")},
{QStringLiteral("TITLE_CHOOSEMODEL"), QStringLiteral("Choose unit design")},
{QStringLiteral("TITLE_GOV"), QStringLiteral("Choose government")},
{QStringLiteral("TITLE_SPYMISSION"), QStringLiteral("Choose mission")},
{QStringLiteral("TITLE_CITYNAME"), QStringLiteral("Rename city")},
{QStringLiteral("TITLE_MODELNAME"), QStringLiteral("Rename unit design")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? *it : key;
}
QString advanceName(int advance) QString advanceName(int advance)
{ {
return phrases.lookup(QStringLiteral("ADVANCES"), advance); return phrases.lookup(QStringLiteral("ADVANCES"), advance);
@@ -170,9 +130,9 @@ ListDlg::ListDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::ListDlg)
popup = new QMenu(this); popup = new QMenu(this);
ui->layerImprovementsButton->setToolTip(phrase(QStringLiteral("BTN_IMPRS"))); ui->layerImprovementsButton->setToolTip(phrases.lookup(QStringLiteral("BTN_IMPRS")));
ui->layerWondersButton->setToolTip(phrase(QStringLiteral("BTN_WONDERS"))); ui->layerWondersButton->setToolTip(phrases.lookup(QStringLiteral("BTN_WONDERS")));
ui->layerClassesButton->setToolTip(phrase(QStringLiteral("BTN_CLASSES"))); ui->layerClassesButton->setToolTip(phrases.lookup(QStringLiteral("BTN_CLASSES")));
ui->closeBtn->onClick = [this] { ui->closeBtn->onClick = [this] {
closable = true; closable = true;
@@ -317,7 +277,7 @@ bool ListDlg::renameCity(int cix)
{ {
const QString oldName = Tribes::cityName(ClientTools::myCity[cix].ID); const QString oldName = Tribes::cityName(ClientTools::myCity[cix].ID);
InputDlg dlg; InputDlg dlg;
dlg.setWindowTitle(phrase(QStringLiteral("TITLE_CITYNAME"))); dlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_CITYNAME")));
dlg.editInput()->setText(oldName); dlg.editInput()->setText(oldName);
dlg.centerToRect(geometry()); dlg.centerToRect(geometry());
const Dpi::ModalResult result = dlg.showModal(); const Dpi::ModalResult result = dlg.showModal();
@@ -338,7 +298,7 @@ bool ListDlg::renameModel(int mix)
{ {
const QString oldName = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(mix); const QString oldName = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(mix);
InputDlg dlg; InputDlg dlg;
dlg.setWindowTitle(phrase(QStringLiteral("TITLE_MODELNAME"))); dlg.setWindowTitle(phrases.lookup(QStringLiteral("TITLE_MODELNAME")));
dlg.editInput()->setText(oldName); dlg.editInput()->setText(oldName);
dlg.centerToRect(geometry()); dlg.centerToRect(geometry());
const Dpi::ModalResult result = dlg.showModal(); const Dpi::ModalResult result = dlg.showModal();
@@ -955,7 +915,7 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
case ListKind::AllEnemyModels: case ListKind::AllEnemyModels:
case ListKind::ChooseEnemyModel: case ListKind::ChooseEnemyModel:
if (lix == mixAll) { if (lix == mixAll) {
s = phrase(QStringLiteral("PRICECAT_ALLMODEL")); s = phrases.lookup(QStringLiteral("PRICECAT_ALLMODEL"));
} else { } else {
const TModelInfo &mox = (*ClientTools::myRO->EnemyModel)[lix]; const TModelInfo &mox = (*ClientTools::myRO->EnemyModel)[lix];
if (Term::mainScreenNamesChecked) { if (Term::mainScreenNamesChecked) {
@@ -978,7 +938,7 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
break; break;
case ListKind::ChooseModel: case ListKind::ChooseModel:
if (lix == mixAll) { if (lix == mixAll) {
s = phrase(QStringLiteral("PRICECAT_ALLMODEL")); s = phrases.lookup(QStringLiteral("PRICECAT_ALLMODEL"));
} else { } else {
s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix); s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix);
if (nonText) if (nonText)
@@ -991,7 +951,7 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
} else if ((lix & cpImp) == 0) { } else if ((lix & cpImp) == 0) {
s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix & cpIndex); s = Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->modelNameAt(lix & cpIndex);
if (lix & cpConscripts) if (lix & cpConscripts)
s = phrase(QStringLiteral("CONSCRIPTS")).arg(s); s = formatPhrase(QStringLiteral("CONSCRIPTS"), { s });
} else { } else {
s = impName(lix & cpIndex); s = impName(lix & cpIndex);
const int iix = lix & cpIndex; const int iix = lix & cpIndex;
@@ -1001,7 +961,7 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
ClientTools::myCity[cixProject].Built[imPower] + ClientTools::myCity[cixProject].Built[imHydro] + ClientTools::myCity[cixProject].Built[imPower] + ClientTools::myCity[cixProject].Built[imHydro] +
ClientTools::myCity[cixProject].Built[imNuclear] > ClientTools::myCity[cixProject].Built[imNuclear] >
0)) 0))
s = phrase(QStringLiteral("NATEXISTS")).arg(s); s = formatPhrase(QStringLiteral("NATEXISTS"), { s });
} }
if (nonText) if (nonText)
displayProject(8 + ofs, y0 - 15, lix); displayProject(8 + ofs, y0 - 15, lix);
@@ -1014,14 +974,14 @@ void ListDlg::paintLine(Dpi::Canvas &ca, int l, bool nonText, bool lit, bool toW
case ListKind::ChooseEnemyTech: case ListKind::ChooseEnemyTech:
case ListKind::StealTech: { case ListKind::StealTech: {
if (lix == adAll) { if (lix == adAll) {
s = phrase(QStringLiteral("PRICECAT_ALLTECH")); s = phrases.lookup(QStringLiteral("PRICECAT_ALLTECH"));
} else { } else {
if (lix == Term::adNexus) if (lix == Term::adNexus)
s = phrase(QStringLiteral("NEXUS")); s = phrases.lookup(QStringLiteral("NEXUS"));
else if (lix == Term::adNone) else if (lix == Term::adNone)
s = phrase(QStringLiteral("NOFARTECH")); s = phrases.lookup(QStringLiteral("NOFARTECH"));
else if (lix == adMilitary) else if (lix == adMilitary)
s = phrase(QStringLiteral("INITUNIT")); s = phrases.lookup(QStringLiteral("INITUNIT"));
else { else {
s = advanceName(lix); s = advanceName(lix);
if (kind == ListKind::Advance && IsFutureTech(lix)) { if (kind == ListKind::Advance && IsFutureTech(lix)) {
@@ -1208,7 +1168,7 @@ void ListDlg::offscreenPaint()
Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->tPhrase(QStringLiteral("TITLE_CITIES"))); Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->tPhrase(QStringLiteral("TITLE_CITIES")));
break; break;
case ListKind::CityEvents: case ListKind::CityEvents:
setWindowTitle(phrase(QStringLiteral("TITLE_EVENTS")).arg(Term::turnToString(ClientTools::myRO->Turn))); setWindowTitle(formatPhrase(QStringLiteral("TITLE_EVENTS"), { Term::turnToString(ClientTools::myRO->Turn) }));
break; break;
default: default:
break; break;
@@ -1268,45 +1228,45 @@ void ListDlg::showNewContent(WindowMode newMode, ListKind listKind)
modalIndication = !mustChoose(kind); modalIndication = !mustChoose(kind);
switch (kind) { switch (kind) {
case ListKind::Project: case ListKind::Project:
setWindowTitle(phrase(QStringLiteral("TITLE_PROJECT"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_PROJECT")));
break; break;
case ListKind::Advance: case ListKind::Advance:
setWindowTitle(phrase(QStringLiteral("TITLE_TECHSELECT"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_TECHSELECT")));
break; break;
case ListKind::FarAdvance: case ListKind::FarAdvance:
setWindowTitle(phrase(QStringLiteral("TITLE_FARTECH"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_FARTECH")));
break; break;
case ListKind::Models: case ListKind::Models:
case ListKind::EnemyModels: case ListKind::EnemyModels:
setWindowTitle(phrase(QStringLiteral("FRMILREP"))); setWindowTitle(phrases.lookup(QStringLiteral("FRMILREP")));
break; break;
case ListKind::AllEnemyModels: case ListKind::AllEnemyModels:
setWindowTitle(phrase(QStringLiteral("TITLE_EMODELS"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_EMODELS")));
break; break;
case ListKind::Tribe: case ListKind::Tribe:
setWindowTitle(phrase(QStringLiteral("TITLE_TRIBE"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_TRIBE")));
break; break;
case ListKind::Science: case ListKind::Science:
setWindowTitle(phrase(QStringLiteral("TITLE_SCIENCE"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_SCIENCE")));
break; break;
case ListKind::ShipPart: case ListKind::ShipPart:
case ListKind::EnemyShipPart: case ListKind::EnemyShipPart:
setWindowTitle(phrase(QStringLiteral("TITLE_CHOOSESHIPPART"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_CHOOSESHIPPART")));
break; break;
case ListKind::ChooseTech: case ListKind::ChooseTech:
case ListKind::ChooseEnemyTech: case ListKind::ChooseEnemyTech:
case ListKind::StealTech: case ListKind::StealTech:
setWindowTitle(phrase(QStringLiteral("TITLE_CHOOSETECH"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_CHOOSETECH")));
break; break;
case ListKind::ChooseModel: case ListKind::ChooseModel:
case ListKind::ChooseEnemyModel: case ListKind::ChooseEnemyModel:
setWindowTitle(phrase(QStringLiteral("TITLE_CHOOSEMODEL"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_CHOOSEMODEL")));
break; break;
case ListKind::Government: case ListKind::Government:
setWindowTitle(phrase(QStringLiteral("TITLE_GOV"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_GOV")));
break; break;
case ListKind::Mission: case ListKind::Mission:
setWindowTitle(phrase(QStringLiteral("TITLE_SPYMISSION"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_SPYMISSION")));
break; break;
default: default:
break; break;
@@ -1316,13 +1276,13 @@ void ListDlg::showNewContent(WindowMode newMode, ListKind listKind)
if (kind == ListKind::Advance) { if (kind == ListKind::Advance) {
ui->toggleBtn->setButtonIndex(13); ui->toggleBtn->setButtonIndex(13);
ui->toggleBtn->setToolTip(phrase(QStringLiteral("FARTECH"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("FARTECH")));
} else if (kind == ListKind::Cities) { } else if (kind == ListKind::Cities) {
ui->toggleBtn->setButtonIndex(15); ui->toggleBtn->setButtonIndex(15);
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_PAGE"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_PAGE")));
} else { } else {
ui->toggleBtn->setButtonIndex(28); ui->toggleBtn->setButtonIndex(28);
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT"))); ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SELECT")));
} }
bool showFocus = false; bool showFocus = false;
@@ -1616,7 +1576,7 @@ void ListDlg::mouseMoveEvent(QMouseEvent *event)
if (scienceNation >= 0) { if (scienceNation >= 0) {
QString s = Tribes::tribe[static_cast<std::size_t>(scienceNation)]->tPhrase(QStringLiteral("SHORTNAME")); QString s = Tribes::tribe[static_cast<std::size_t>(scienceNation)]->tPhrase(QStringLiteral("SHORTNAME"));
if ((ClientTools::myRO->Alive & (1 << scienceNation)) == 0) if ((ClientTools::myRO->Alive & (1 << scienceNation)) == 0)
s = phrase(QStringLiteral("SCIENCEREPORT_EXTINCT")).arg(s); s = formatPhrase(QStringLiteral("SCIENCEREPORT_EXTINCT"), { s });
else if (ClientTools::myRO->EnemyReport[scienceNation]->TurnOfCivilReport < ClientTools::myRO->Turn - 1) else if (ClientTools::myRO->EnemyReport[scienceNation]->TurnOfCivilReport < ClientTools::myRO->Turn - 1)
s += QStringLiteral(" (%1)").arg( s += QStringLiteral(" (%1)").arg(
Term::turnToString(ClientTools::myRO->EnemyReport[scienceNation]->TurnOfCivilReport)); Term::turnToString(ClientTools::myRO->EnemyReport[scienceNation]->TurnOfCivilReport));
+20 -49
View File
@@ -36,8 +36,6 @@
#include "Term.h" #include "Term.h"
#include "Tribes.h" #include "Tribes.h"
#include <QHash>
namespace Cevo { namespace Cevo {
namespace UnitStat { namespace UnitStat {
@@ -59,38 +57,11 @@ constexpr int hEnemyCityDefense = 320;
constexpr int hEnemyCity = 166; constexpr int hEnemyCity = 166;
constexpr int hMax = 320; constexpr int hMax = 320;
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("UNITSPECIAL"), QStringLiteral("Special unit")},
{QStringLiteral("CONTROLS6"), QStringLiteral("Special unit controls")},
{QStringLiteral("UNITSTRENGTH"), QStringLiteral("Attack/Defense")},
{QStringLiteral("UNITSPEED"), QStringLiteral("Speed")},
{QStringLiteral("UNITCOST"), QStringLiteral("Cost")},
{QStringLiteral("UNITADOPT"), QStringLiteral("Adopted")},
{QStringLiteral("UNITINTRO"), QStringLiteral("Introduced")},
{QStringLiteral("UNITBUILT"), QStringLiteral("Built")},
{QStringLiteral("UNITLOST"), QStringLiteral("Lost")},
{QStringLiteral("UNITINPROD"), QStringLiteral("In production")},
{QStringLiteral("UNITAVAILABLE"), QStringLiteral("Available")},
{QStringLiteral("UNITDESTROYED"), QStringLiteral("Destroyed")},
{QStringLiteral("UNITKNOWN"), QStringLiteral("Known")},
{QStringLiteral("BTN_OBSOLETE"), QStringLiteral("Mark as obsolete")},
{QStringLiteral("BTN_NONOBSOLETE"), QStringLiteral("Mark as not obsolete")},
{QStringLiteral("BTN_NOCONSCRIPTS"), QStringLiteral("Allow conscripts")},
{QStringLiteral("BTN_ALLOWCONSCRIPTS"), QStringLiteral("Disallow conscripts")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
void featureBar(Dpi::Canvas &canvas, int x, int y, const TModelInfo &mi, const Texture &) void featureBar(Dpi::Canvas &canvas, int x, int y, const TModelInfo &mi, const Texture &)
{ {
darkGradient(canvas, x - 6, y + 1, 180, 1); darkGradient(canvas, x - 6, y + 1, 180, 1);
if (mi.Kind >= 0x10) { if (mi.Kind >= 0x10) {
const QString s = phrase(QStringLiteral("UNITSPECIAL")); const QString s = phrases.lookup(QStringLiteral("UNITSPECIAL"));
canvas.font().setColor(Qt::black); canvas.font().setColor(Qt::black);
canvas.textOut(x - 1, y + 1, s); canvas.textOut(x - 1, y + 1, s);
canvas.font().setColor(QColor(0xB0, 0xB0, 0xB0)); canvas.font().setColor(QColor(0xB0, 0xB0, 0xB0));
@@ -159,20 +130,20 @@ UnitStatDlg::UnitStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::
ClientTools::myModel[mixShow].Status ^= Term::msObsolete; ClientTools::myModel[mixShow].Status ^= Term::msObsolete;
if (ClientTools::myModel[mixShow].Status & Term::msObsolete) { if (ClientTools::myModel[mixShow].Status & Term::msObsolete) {
ui->switchBtn->setButtonIndex(12); ui->switchBtn->setButtonIndex(12);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_OBSOLETE"))); ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_OBSOLETE")));
} else { } else {
ui->switchBtn->setButtonIndex(11); ui->switchBtn->setButtonIndex(11);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_NONOBSOLETE"))); ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NONOBSOLETE")));
} }
}; };
ui->conscriptsBtn->onClick = [this] { ui->conscriptsBtn->onClick = [this] {
ClientTools::myModel[mixShow].Status ^= Term::msAllowConscripts; ClientTools::myModel[mixShow].Status ^= Term::msAllowConscripts;
if ((ClientTools::myModel[mixShow].Status & Term::msAllowConscripts) == 0) { if ((ClientTools::myModel[mixShow].Status & Term::msAllowConscripts) == 0) {
ui->conscriptsBtn->setButtonIndex(30); ui->conscriptsBtn->setButtonIndex(30);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_NOCONSCRIPTS"))); ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NOCONSCRIPTS")));
} else { } else {
ui->conscriptsBtn->setButtonIndex(29); ui->conscriptsBtn->setButtonIndex(29);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_ALLOWCONSCRIPTS"))); ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
} }
}; };
ui->helpBtn->onClick = [this] { ui->helpBtn->onClick = [this] {
@@ -263,7 +234,7 @@ UnitStatDlg::UnitStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::
setWindowTitle(Tribes::tribe[owner]->tPhrase(QStringLiteral("GENMODEL")).arg(mix)); setWindowTitle(Tribes::tribe[owner]->tPhrase(QStringLiteral("GENMODEL")).arg(mix));
} }
if (isSpecialUnit) if (isSpecialUnit)
ui->helpBtn->setToolTip(phrase(QStringLiteral("CONTROLS6"))); ui->helpBtn->setToolTip(phrases.lookup(QStringLiteral("CONTROLS"), 6));
ui->helpBtn->setVisible(isSpecialUnit); ui->helpBtn->setVisible(isSpecialUnit);
offscreenPaint(); offscreenPaint();
}; };
@@ -540,13 +511,13 @@ void UnitStatDlg::offscreenPaint()
} }
darkGradient(canvas, xTotal - 6, yTotal + 1, 180, 2); darkGradient(canvas, xTotal - 6, yTotal + 1, 180, 2);
risedTextOut(canvas, xTotal - 2, yTotal, phrase(QStringLiteral("UNITSTRENGTH"))); risedTextOut(canvas, xTotal - 2, yTotal, phrases.lookup(QStringLiteral("UNITSTRENGTH")));
QString s = QString::number(mi.Attack) + QLatin1Char('/') + QString::number(mi.Defense); QString s = QString::number(mi.Attack) + QLatin1Char('/') + QString::number(mi.Defense);
risedTextOut(canvas, xTotal + 170 - biColorTextWidth(canvas, s), yTotal, s); risedTextOut(canvas, xTotal + 170 - biColorTextWidth(canvas, s), yTotal, s);
featureBar(canvas, xTotal, yTotal + 19, mi, *MainTexture); featureBar(canvas, xTotal, yTotal + 19, mi, *MainTexture);
numberBarS(canvas, xTotal, yTotal + 38, phrase(QStringLiteral("UNITSPEED")), movementToString(mi.Speed), numberBarS(canvas, xTotal, yTotal + 38, phrases.lookup(QStringLiteral("UNITSPEED")), movementToString(mi.Speed),
*MainTexture); *MainTexture);
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, yTotal + 57, phrase(QStringLiteral("UNITCOST"))); loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, yTotal + 57, phrases.lookup(QStringLiteral("UNITCOST")));
dLine(canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16, MainTexture->colorBevelShade, dLine(canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16, MainTexture->colorBevelShade,
MainTexture->colorBevelLight); MainTexture->colorBevelLight);
s = ClientTools::g.Difficulty[ClientTools::me] == 0 s = ClientTools::g.Difficulty[ClientTools::me] == 0
@@ -559,7 +530,7 @@ void UnitStatDlg::offscreenPaint()
const TModel &m = ClientTools::myModel[mixShow]; const TModel &m = ClientTools::myModel[mixShow];
if (m.IntroTurn > 0) { if (m.IntroTurn > 0) {
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, yTotal + StatDown - 19, loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, yTotal + StatDown - 19,
phrase(m.Kind == mkEnemyDeveloped ? QStringLiteral("UNITADOPT") phrases.lookup(m.Kind == mkEnemyDeveloped ? QStringLiteral("UNITADOPT")
: QStringLiteral("UNITINTRO"))); : QStringLiteral("UNITINTRO")));
dLine(canvas, xTotal - 2, xTotal + 170, (yTotal + StatDown - 19) + 16, MainTexture->colorTextShade, dLine(canvas, xTotal - 2, xTotal + 170, (yTotal + StatDown - 19) + 16, MainTexture->colorTextShade,
MainTexture->colorTextLight); MainTexture->colorTextLight);
@@ -567,37 +538,37 @@ void UnitStatDlg::offscreenPaint()
risedTextOut(canvas, xTotal + 170 - biColorTextWidth(canvas, introS), yTotal + StatDown - 19, introS); risedTextOut(canvas, xTotal + 170 - biColorTextWidth(canvas, introS), yTotal + StatDown - 19, introS);
} }
numberBar(canvas, xTotal, yTotal + StatDown, phrase(QStringLiteral("UNITBUILT")), m.Built, *MainTexture); numberBar(canvas, xTotal, yTotal + StatDown, phrases.lookup(QStringLiteral("UNITBUILT")), m.Built, *MainTexture);
if (m.Lost > 0) if (m.Lost > 0)
numberBar(canvas, xTotal, yTotal + StatDown + 19, phrase(QStringLiteral("UNITLOST")), m.Lost, numberBar(canvas, xTotal, yTotal + StatDown + 19, phrases.lookup(QStringLiteral("UNITLOST")), m.Lost,
*MainTexture); *MainTexture);
if (inProd > 0) if (inProd > 0)
numberBar(canvas, xTotal, yTotal + StatDown + 57, phrase(QStringLiteral("UNITINPROD")), inProd, numberBar(canvas, xTotal, yTotal + StatDown + 57, phrases.lookup(QStringLiteral("UNITINPROD")), inProd,
*MainTexture); *MainTexture);
if (available > 0) if (available > 0)
numberBar(canvas, xTotal, yTotal + StatDown + 38, phrase(QStringLiteral("UNITAVAILABLE")), available, numberBar(canvas, xTotal, yTotal + StatDown + 38, phrases.lookup(QStringLiteral("UNITAVAILABLE")), available,
*MainTexture); *MainTexture);
if (m.Status & Term::msObsolete) { if (m.Status & Term::msObsolete) {
ui->switchBtn->setButtonIndex(12); ui->switchBtn->setButtonIndex(12);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_OBSOLETE"))); ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_OBSOLETE")));
} else { } else {
ui->switchBtn->setButtonIndex(11); ui->switchBtn->setButtonIndex(11);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_NONOBSOLETE"))); ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NONOBSOLETE")));
} }
if ((m.Status & Term::msAllowConscripts) == 0) { if ((m.Status & Term::msAllowConscripts) == 0) {
ui->conscriptsBtn->setButtonIndex(30); ui->conscriptsBtn->setButtonIndex(30);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_NOCONSCRIPTS"))); ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NOCONSCRIPTS")));
} else { } else {
ui->conscriptsBtn->setButtonIndex(29); ui->conscriptsBtn->setButtonIndex(29);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_ALLOWCONSCRIPTS"))); ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
} }
} else if (kind == UnitStatDialogKind::EnemyModel) { } else if (kind == UnitStatDialogKind::EnemyModel) {
if (destroyed > 0) if (destroyed > 0)
numberBar(canvas, xTotal, yTotal + StatDown - 19, phrase(QStringLiteral("UNITDESTROYED")), destroyed, numberBar(canvas, xTotal, yTotal + StatDown - 19, phrases.lookup(QStringLiteral("UNITDESTROYED")), destroyed,
*MainTexture); *MainTexture);
if (available > 0) if (available > 0)
numberBar(canvas, xTotal, yTotal + StatDown, phrase(QStringLiteral("UNITKNOWN")), available, numberBar(canvas, xTotal, yTotal + StatDown, phrases.lookup(QStringLiteral("UNITKNOWN")), available,
*MainTexture); *MainTexture);
} }
} }
+5 -20
View File
@@ -39,7 +39,6 @@
#include "Dpi/DpiPixelPointer.h" #include "Dpi/DpiPixelPointer.h"
#include <QHash>
#include <QMouseEvent> #include <QMouseEvent>
namespace Cevo { namespace Cevo {
@@ -71,20 +70,6 @@ constexpr QPoint RingPosition[21] = {
QPoint(160, 64), // Mir QPoint(160, 64), // Mir
}; };
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
// plain-English placeholders for this dialog's own text.
QString phrase(const QString &key)
{
static const QHash<QString, QString> table = {
{QStringLiteral("TITLE_WONDERS"), QStringLiteral("World Wonders")},
{QStringLiteral("NOWONDER"), QStringLiteral("No wonder built yet")},
{QStringLiteral("DESTROYED"), QStringLiteral("Destroyed")},
{QStringLiteral("EXPIRED"), QStringLiteral("Expired")},
};
const auto it = table.constFind(key);
return it != table.constEnd() ? it.value() : key;
}
} // namespace } // namespace
WondersDlg::WondersDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::WondersDlg) WondersDlg::WondersDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::WondersDlg)
@@ -94,7 +79,7 @@ WondersDlg::WondersDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::Wo
ui->closeBtn->onClick = [this] { close(); }; ui->closeBtn->onClick = [this] { close(); };
initButtons(); initButtons();
onShow = [this] { onShow = [this] {
setWindowTitle(phrase(QStringLiteral("TITLE_WONDERS"))); setWindowTitle(phrases.lookup(QStringLiteral("TITLE_WONDERS")));
selection = -1; selection = -1;
offscreenPaint(); offscreenPaint();
}; };
@@ -206,7 +191,7 @@ void WondersDlg::offscreenPaint()
btnFrame(canvas, ui->closeBtn->geometry(), *MainTexture); btnFrame(canvas, ui->closeBtn->geometry(), *MainTexture);
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
QString s = phrase(QStringLiteral("TITLE_WONDERS")); QString s = phrases.lookup(QStringLiteral("TITLE_WONDERS"));
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2 - 1, 7, s); risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2 - 1, 7, s);
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]); canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
@@ -258,7 +243,7 @@ void WondersDlg::offscreenPaint()
} }
if (!haveWonder) { if (!haveWonder) {
s = phrase(QStringLiteral("NOWONDER")); s = phrases.lookup(QStringLiteral("NOWONDER"));
risedTextOut(canvas, center.x() - biColorTextWidth(canvas, s) / 2, center.y() - canvas.textHeight(s) / 2, s); risedTextOut(canvas, center.x() - biColorTextWidth(canvas, s) / 2, center.y() - canvas.textHeight(s) / 2, s);
} }
canvas.end(); canvas.end();
@@ -278,9 +263,9 @@ void WondersDlg::vpaint(Dpi::Canvas &canvas)
loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, height() - 3 - 36 - 10, s); loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, height() - 3 - 36 - 10, s);
if (ClientTools::myRO->Wonder[selection].CityID == WonderDestroyed) if (ClientTools::myRO->Wonder[selection].CityID == WonderDestroyed)
s = phrase(QStringLiteral("DESTROYED")); s = phrases.lookup(QStringLiteral("DESTROYED"));
else if (ClientTools::myRO->Wonder[selection].EffectiveOwner < 0) else if (ClientTools::myRO->Wonder[selection].EffectiveOwner < 0)
s = phrase(QStringLiteral("EXPIRED")); s = phrases.lookup(QStringLiteral("EXPIRED"));
else else
s = Tribes::tribe[static_cast<std::size_t>(ClientTools::myRO->Wonder[selection].EffectiveOwner)]->tPhrase( s = Tribes::tribe[static_cast<std::size_t>(ClientTools::myRO->Wonder[selection].EffectiveOwner)]->tPhrase(
QStringLiteral("WONDEROWNER")); QStringLiteral("WONDEROWNER"));