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

+25 -70
View File
@@ -37,7 +37,6 @@
#include "Term.h"
#include "Tribes.h"
#include <QHash>
#include <QKeyEvent>
#include <QMenu>
@@ -62,60 +61,14 @@ constexpr int yReport = 165;
constexpr int wReport = 352;
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)
{
return QStringLiteral("government #%1 ").arg(government);
return phrases.lookup(QStringLiteral("GOVERNMENT"), government);
}
QString phraseCredibility(int roughCredibility)
{
static const QHash<int, QString> table = {
{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();
return phrases.lookup(QStringLiteral("CREDIBILITY"), roughCredibility);
}
} // namespace
@@ -127,8 +80,8 @@ NatStatDlg::NatStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::Na
ui->contactBtn->setTemplate(Templates ? &Templates->data : nullptr);
ui->contactBtn->setButtonIndex(3);
helpContext = QStringLiteral("DIPLOMACY");
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT")));
ui->contactBtn->setToolTip(phrase(QStringLiteral("BTN_DIALOG")));
ui->toggleBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_SELECT")));
ui->contactBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_DIALOG")));
back.setSize(width(), height());
back.canvas().begin();
@@ -237,11 +190,12 @@ void NatStatDlg::generateReportText()
ClientTools::server(sGetChart + (no << 4), ClientTools::me, pView, list.data()) >= rExecuted) {
const int i = list[static_cast<std::size_t>(currentReport->TurnOfCivilReport)];
switch (no) {
case stPop: return phrase(QStringLiteral("FRSTATPOP")).arg(i);
case stTerritory: return phrase(QStringLiteral("FRSTATTER")).arg(i);
case stScience: return phrase(QStringLiteral("FRSTATTECH")).arg(i / nAdv);
case stPop: return formatPhrase(QStringLiteral("FRSTATPOP"), { QString::number(i) });
case stTerritory: return formatPhrase(QStringLiteral("FRSTATTER"), { QString::number(i) });
case stScience: return formatPhrase(QStringLiteral("FRSTATTECH"), { QString::number(i / nAdv) });
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();
}
}
@@ -252,12 +206,12 @@ void NatStatDlg::generateReportText()
reportText.append(QString());
if (ClientTools::myRO->Turn - currentReport->TurnOfCivilReport > 1 &&
(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());
}
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(stTerritory));
}
@@ -272,13 +226,14 @@ void NatStatDlg::generateReportText()
}
if (hasContact) {
reportText.append(QString());
reportText.append(phrase(QStringLiteral("FRRELATIONS")));
reportText.append(phrases.lookup(QStringLiteral("FRRELATIONS")));
for (int extinctPart = 0; extinctPart <= 1; ++extinctPart) {
for (int treaty = trAlliance; treaty >= trNone; --treaty) {
for (int p1 = 0; p1 < nPl; ++p1) {
if (p1 != ClientTools::me && currentReport->Treaty[p1] == treaty &&
((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)
s = QLatin1Char('(') + s + QLatin1Char(')');
reportText.append(s);
@@ -315,38 +270,38 @@ void NatStatDlg::offscreenPaint()
if (pView == ClientTools::me || !extinct)
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib,
phraseGovernment(currentReport->Government) + QStringLiteral("and"));
phraseGovernment(currentReport->Government) + phrases.lookup(QStringLiteral("FRAND")));
if (pView == ClientTools::me) {
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
phraseCredibility(Term::roughCredibility(ClientTools::myRO->Credibility)));
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38,
phrase(QStringLiteral("FRCREDIBILITY")).arg(ClientTools::myRO->Credibility));
formatPhrase(QStringLiteral("FRCREDIBILITY"), { QString::number(ClientTools::myRO->Credibility) }));
} else {
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,
Term::turnToString(currentReport->TurnOfCivilReport));
} else {
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
phraseCredibility(Term::roughCredibility(currentReport->Credibility)));
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) {
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);
} 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,
phraseTreaty(ClientTools::myRO->Treaty[pView]));
phrases.lookup(QStringLiteral("TREATY"), ClientTools::myRO->Treaty[pView]));
if (currentReport->TurnOfContact < 0) {
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
phrase(QStringLiteral("FRNOVISIT")));
phrases.lookup(QStringLiteral("FRNOVISIT")));
} else {
loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation + 19,
phrase(QStringLiteral("FRLASTCONTACT")));
phrases.lookup(QStringLiteral("FRLASTCONTACT")));
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
Term::turnToString(currentReport->TurnOfContact));
}
@@ -374,7 +329,7 @@ void NatStatDlg::offscreenPaint()
}
}
} 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);
}
@@ -382,7 +337,7 @@ void NatStatDlg::offscreenPaint()
// Server(sGetAIInfo,...) returning a live AI-credits string isn't wired here yet.
loweredTextOut(canvas, -1, *MainTexture, 42, 445, QString());
} 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());