Codechange: Use EncodedStrings for News messages. (#13654)

This commit is contained in:
Peter Nelson
2025-02-23 20:24:02 +00:00
committed by GitHub
parent 0afae7c546
commit 6e10584b91
30 changed files with 304 additions and 293 deletions

View File

@@ -174,18 +174,24 @@ struct SubsidyListWindow : Window {
if (!s->IsAwarded()) {
if (IsInsideMM(pos, 0, cap)) {
/* Displays the two offered towns */
SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
std::string text;
/* If using wallclock units, show minutes remaining. Otherwise show the date when the subsidy ends. */
if (TimerGameEconomy::UsingWallclockUnits()) {
SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_TIME);
SetDParam(8, s->remaining + 1); // We get the rest of the current economy month for free, since the expiration is checked on each new month.
text = GetString(STR_SUBSIDIES_OFFERED_FROM_TO,
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
STR_SUBSIDIES_OFFERED_EXPIRY_TIME,
s->remaining + 1); // We get the rest of the current economy month for free, since the expiration is checked on each new month.
} else {
SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_DATE);
SetDParam(8, TimerGameEconomy::date - ymd.day + s->remaining * 32);
text = GetString(STR_SUBSIDIES_OFFERED_FROM_TO,
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
STR_SUBSIDIES_OFFERED_EXPIRY_DATE,
TimerGameEconomy::date.base() - ymd.day + s->remaining * 32);
}
DrawCargoIcon(tr, pos * GetCharacterHeight(FS_NORMAL), s->cargo_type);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), text);
}
pos++;
num++;
@@ -206,21 +212,27 @@ struct SubsidyListWindow : Window {
for (const Subsidy *s : Subsidy::Iterate()) {
if (s->IsAwarded()) {
if (IsInsideMM(pos, 0, cap)) {
SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
SetDParam(7, s->awarded);
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
std::string text;
/* If using wallclock units, show minutes remaining. Otherwise show the date when the subsidy ends. */
if (TimerGameEconomy::UsingWallclockUnits()) {
SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME);
SetDParam(9, s->remaining);
}
else {
SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE);
SetDParam(9, TimerGameEconomy::date - ymd.day + s->remaining * 32);
text = GetString(STR_SUBSIDIES_SUBSIDISED_FROM_TO,
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
GetString(STR_COMPANY_NAME, s->awarded),
STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME,
s->remaining + 1); // We get the rest of the current economy month for free, since the expiration is checked on each new month.
} else {
text = GetString(STR_SUBSIDIES_SUBSIDISED_FROM_TO,
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
GetString(STR_COMPANY_NAME, s->awarded),
STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE,
TimerGameEconomy::date.base() - ymd.day + s->remaining * 32);
}
/* Displays the two connected stations */
DrawCargoIcon(tr, pos * GetCharacterHeight(FS_NORMAL), s->cargo_type);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), text);
}
pos++;
num++;