removed old temporary phrase and formatPrase implementations

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

No files matched your search

+20 -49
View File
@@ -36,8 +36,6 @@
#include "Term.h"
#include "Tribes.h"
#include <QHash>
namespace Cevo {
namespace UnitStat {
@@ -59,38 +57,11 @@ constexpr int hEnemyCityDefense = 320;
constexpr int hEnemyCity = 166;
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 &)
{
darkGradient(canvas, x - 6, y + 1, 180, 1);
if (mi.Kind >= 0x10) {
const QString s = phrase(QStringLiteral("UNITSPECIAL"));
const QString s = phrases.lookup(QStringLiteral("UNITSPECIAL"));
canvas.font().setColor(Qt::black);
canvas.textOut(x - 1, y + 1, s);
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;
if (ClientTools::myModel[mixShow].Status & Term::msObsolete) {
ui->switchBtn->setButtonIndex(12);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_OBSOLETE")));
ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_OBSOLETE")));
} else {
ui->switchBtn->setButtonIndex(11);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_NONOBSOLETE")));
ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NONOBSOLETE")));
}
};
ui->conscriptsBtn->onClick = [this] {
ClientTools::myModel[mixShow].Status ^= Term::msAllowConscripts;
if ((ClientTools::myModel[mixShow].Status & Term::msAllowConscripts) == 0) {
ui->conscriptsBtn->setButtonIndex(30);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_NOCONSCRIPTS")));
ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NOCONSCRIPTS")));
} else {
ui->conscriptsBtn->setButtonIndex(29);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
}
};
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));
}
if (isSpecialUnit)
ui->helpBtn->setToolTip(phrase(QStringLiteral("CONTROLS6")));
ui->helpBtn->setToolTip(phrases.lookup(QStringLiteral("CONTROLS"), 6));
ui->helpBtn->setVisible(isSpecialUnit);
offscreenPaint();
};
@@ -540,13 +511,13 @@ void UnitStatDlg::offscreenPaint()
}
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);
risedTextOut(canvas, xTotal + 170 - biColorTextWidth(canvas, s), yTotal, s);
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);
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,
MainTexture->colorBevelLight);
s = ClientTools::g.Difficulty[ClientTools::me] == 0
@@ -559,7 +530,7 @@ void UnitStatDlg::offscreenPaint()
const TModel &m = ClientTools::myModel[mixShow];
if (m.IntroTurn > 0) {
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, yTotal + StatDown - 19,
phrase(m.Kind == mkEnemyDeveloped ? QStringLiteral("UNITADOPT")
phrases.lookup(m.Kind == mkEnemyDeveloped ? QStringLiteral("UNITADOPT")
: QStringLiteral("UNITINTRO")));
dLine(canvas, xTotal - 2, xTotal + 170, (yTotal + StatDown - 19) + 16, MainTexture->colorTextShade,
MainTexture->colorTextLight);
@@ -567,37 +538,37 @@ void UnitStatDlg::offscreenPaint()
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)
numberBar(canvas, xTotal, yTotal + StatDown + 19, phrase(QStringLiteral("UNITLOST")), m.Lost,
numberBar(canvas, xTotal, yTotal + StatDown + 19, phrases.lookup(QStringLiteral("UNITLOST")), m.Lost,
*MainTexture);
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);
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);
if (m.Status & Term::msObsolete) {
ui->switchBtn->setButtonIndex(12);
ui->switchBtn->setToolTip(phrase(QStringLiteral("BTN_OBSOLETE")));
ui->switchBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_OBSOLETE")));
} else {
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) {
ui->conscriptsBtn->setButtonIndex(30);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_NOCONSCRIPTS")));
ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_NOCONSCRIPTS")));
} else {
ui->conscriptsBtn->setButtonIndex(29);
ui->conscriptsBtn->setToolTip(phrase(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
ui->conscriptsBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_ALLOWCONSCRIPTS")));
}
} else if (kind == UnitStatDialogKind::EnemyModel) {
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);
if (available > 0)
numberBar(canvas, xTotal, yTotal + StatDown, phrase(QStringLiteral("UNITKNOWN")), available,
numberBar(canvas, xTotal, yTotal + StatDown, phrases.lookup(QStringLiteral("UNITKNOWN")), available,
*MainTexture);
}
}