removed old temporary phrase and formatPrase implementations
This commit is contained in:
1 parent
6e634e13d2
commit
e96b871779
14 files changed
+231
-598
No files matched your search
@@ -31,38 +31,11 @@
|
||||
#include "Global.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace Cevo {
|
||||
namespace Diplomacy {
|
||||
|
||||
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)
|
||||
{
|
||||
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)];
|
||||
switch (price & static_cast<std::uint32_t>(opMask)) {
|
||||
case opChoose:
|
||||
return phrase(QStringLiteral("PRICE_CHOOSE"));
|
||||
return phrases.lookup(QStringLiteral("PRICE_CHOOSE"));
|
||||
case opCivilReport:
|
||||
return tribe.tPhrase(QStringLiteral("PRICE_CIVIL"));
|
||||
case opMilReport:
|
||||
@@ -95,15 +68,15 @@ QString priceToString(int p, std::uint32_t price)
|
||||
return phraseTreaty(static_cast<int>(price - opTreaty));
|
||||
case opShipParts:
|
||||
switch ((price >> 16) & 0xFu) {
|
||||
case 0: return phrase(QStringLiteral("PRICE_SHIPCOMP")).arg(price & 0xFFFFu);
|
||||
case 1: return phrase(QStringLiteral("PRICE_SHIPPOW")).arg(price & 0xFFFFu);
|
||||
case 2: return phrase(QStringLiteral("PRICE_SHIPHAB")).arg(price & 0xFFFFu);
|
||||
case 0: return formatPhrase(QStringLiteral("PRICE_SHIPCOMP"), { QString::number(price & 0xFFFFu) });
|
||||
case 1: return formatPhrase(QStringLiteral("PRICE_SHIPPOW"), { QString::number(price & 0xFFFFu) });
|
||||
case 2: return formatPhrase(QStringLiteral("PRICE_SHIPHAB"), { QString::number(price & 0xFFFFu) });
|
||||
default: return QString();
|
||||
}
|
||||
case opMoney:
|
||||
return QStringLiteral("%1%c").arg(price - opMoney);
|
||||
case opTribute:
|
||||
return phrase(QStringLiteral("PRICE_TRIBUTE")).arg(price - opTribute);
|
||||
return formatPhrase(QStringLiteral("PRICE_TRIBUTE"), { QString::number(price - opTribute) });
|
||||
case opTech:
|
||||
return phraseAdvance(static_cast<int>(price - opTech));
|
||||
case opAllTech:
|
||||
@@ -131,16 +104,16 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
|
||||
switch (command) {
|
||||
case scDipCancelTreaty:
|
||||
switch (treaty) {
|
||||
case trPeace: result = phrase(QStringLiteral("FRCANCELTREATY_PEACE")); break;
|
||||
case trFriendlyContact: result = phrase(QStringLiteral("FRCANCELTREATY_FRIENDLY")); break;
|
||||
case trAlliance: result = phrase(QStringLiteral("FRCANCELTREATY_ALLIANCE")); break;
|
||||
case trPeace: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_PEACE")); break;
|
||||
case trFriendlyContact: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_FRIENDLY")); break;
|
||||
case trAlliance: result = phrases.lookup(QStringLiteral("FRCANCELTREATY_ALLIANCE")); break;
|
||||
default: break;
|
||||
}
|
||||
doIntro = false;
|
||||
break;
|
||||
|
||||
case scDipNotice:
|
||||
result = phrase(QStringLiteral("FRNOTICE"));
|
||||
result = phrases.lookup(QStringLiteral("FRNOTICE"));
|
||||
break;
|
||||
|
||||
case scDipAccept:
|
||||
@@ -177,12 +150,12 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
|
||||
QString sDeliver;
|
||||
for (int i = 0; i < offer.nDeliver; ++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;
|
||||
for (int i = 0; i < offer.nCost; ++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) {
|
||||
@@ -194,7 +167,7 @@ QString dipCommandToString(int pSender, int pTarget, int treaty, int oppCommand,
|
||||
// here, unreachable without a StringTables.pas port.
|
||||
result = sender.tPhrase(QStringLiteral("FRNOTACCEPTOFFER")) + QLatin1Char(' ');
|
||||
}
|
||||
result += phrase(QStringLiteral("FRDONE"));
|
||||
result += phrases.lookup(QStringLiteral("FRDONE"));
|
||||
doIntro = false;
|
||||
}
|
||||
} 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) {
|
||||
result += target.tPhrase(QStringLiteral("FRPRESENT")).arg(sDeliver);
|
||||
} 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) {
|
||||
result += phrase(QStringLiteral("FRCOSTCHOICE")).arg(sDeliver);
|
||||
result += formatPhrase(QStringLiteral("FRCOSTCHOICE"), { sDeliver });
|
||||
} else {
|
||||
result += phrase(QStringLiteral("FROFFER")).arg(sDeliver, sCost);
|
||||
result += formatPhrase(QStringLiteral("FROFFER"), { sDeliver, sCost });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user