From 9c2a33f9c437f24163da63e70f3778fec6ef538f Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Fri, 31 Mar 2023 11:46:11 -0400 Subject: [PATCH] Add: Wallclock mode for subsidies --- src/lang/english.txt | 22 +++++++++++++--------- src/subsidy_gui.cpp | 20 ++++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 21a9f540b9..8248c489b0 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -923,12 +923,12 @@ STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST :{WHITE}{STATION STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}Offer of subsidy expired:{}{}{STRING} from {STRING2} to {STRING2} will now not attract a subsidy STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}Subsidy withdrawn:{}{}{STRING} service from {STRING2} to {STRING2} is no longer subsidised -STR_NEWS_SERVICE_SUBSIDY_OFFERED :{BIG_FONT}{BLACK}Service subsidy offered:{}{}First {STRING} from {STRING2} to {STRING2} will attract a {NUM} year subsidy from the local authority! +STR_NEWS_SERVICE_SUBSIDY_OFFERED :{BIG_FONT}{BLACK}Service subsidy offered:{}{}First {STRING} from {STRING2} to {STRING2} will attract a {UNITS_YEARS_OR_MINUTES} subsidy from the local authority! ###length 4 -STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay 50% extra for the next {NUM} year{P "" s}! -STR_NEWS_SERVICE_SUBSIDY_AWARDED_DOUBLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay double rates for the next {NUM} year{P "" s}! -STR_NEWS_SERVICE_SUBSIDY_AWARDED_TRIPLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay triple rates for the next {NUM} year{P "" s}! -STR_NEWS_SERVICE_SUBSIDY_AWARDED_QUADRUPLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay quadruple rates for the next {NUM} year{P "" s}! +STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay 50% extra for the next {UNITS_YEARS_OR_MINUTES}! +STR_NEWS_SERVICE_SUBSIDY_AWARDED_DOUBLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay double rates for the next {UNITS_YEARS_OR_MINUTES}! +STR_NEWS_SERVICE_SUBSIDY_AWARDED_TRIPLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay triple rates for the next {UNITS_YEARS_OR_MINUTES}! +STR_NEWS_SERVICE_SUBSIDY_AWARDED_QUADRUPLE :{BIG_FONT}{BLACK}Service subsidy awarded to {RAW_STRING}!{}{}{STRING} from {STRING2} to {STRING2} will pay quadruple rates for the next {UNITS_YEARS_OR_MINUTES}! STR_NEWS_ROAD_REBUILDING :{BIG_FONT}{BLACK}Traffic chaos in {TOWN}!{}{}Road rebuilding programme funded by {RAW_STRING} brings 6 {TKM months minutes} of misery to motorists! STR_NEWS_EXCLUSIVE_RIGHTS_TITLE :{BIG_FONT}{BLACK}Transport monopoly! @@ -1277,9 +1277,9 @@ STR_CONFIG_SETTING_SUBSIDY_MULTIPLIER :Subsidy multipl STR_CONFIG_SETTING_SUBSIDY_MULTIPLIER_HELPTEXT :Set how much is paid for subsidised connections STR_CONFIG_SETTING_SUBSIDY_DURATION :Subsidy duration: {STRING2} -STR_CONFIG_SETTING_SUBSIDY_DURATION_HELPTEXT :Set the number of years for which a subsidy is awarded +STR_CONFIG_SETTING_SUBSIDY_DURATION_HELPTEXT :Set the number of {TKM years periods} for which a subsidy is awarded -STR_CONFIG_SETTING_SUBSIDY_DURATION_VALUE :{NUM} year{P "" s} +STR_CONFIG_SETTING_SUBSIDY_DURATION_VALUE :{UNITS_YEARS_OR_PERIODS} ###setting-zero-is-special STR_CONFIG_SETTING_SUBSIDY_DURATION_DISABLED :No subsidies @@ -3666,11 +3666,15 @@ STR_GOAL_QUESTION_BUTTON_CLOSE :Close # Subsidies window STR_SUBSIDIES_CAPTION :{WHITE}Subsidies STR_SUBSIDIES_OFFERED_TITLE :{BLACK}Subsidies on offer for services taking: -STR_SUBSIDIES_OFFERED_FROM_TO :{ORANGE}{STRING} from {STRING2} to {STRING2}{YELLOW} (by {DATE_SHORT}) +STR_SUBSIDIES_OFFERED_FROM_TO :{ORANGE}{STRING} from {STRING2} to {STRING2}{YELLOW} ({STRING1}) STR_SUBSIDIES_NONE :{ORANGE}- None - STR_SUBSIDIES_SUBSIDISED_TITLE :{BLACK}Services already subsidised: -STR_SUBSIDIES_SUBSIDISED_FROM_TO :{ORANGE}{STRING} from {STRING2} to {STRING2}{YELLOW} ({COMPANY}{YELLOW}, until {DATE_SHORT}) +STR_SUBSIDIES_SUBSIDISED_FROM_TO :{ORANGE}{STRING} from {STRING2} to {STRING2}{YELLOW} ({COMPANY}{YELLOW}, {STRING1}) STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on service to centre main view on industry/town. Ctrl+Click to open a new viewport on industry/town location +STR_SUBSIDIES_OFFERED_EXPIRY_DATE :by {DATE_SHORT} +STR_SUBSIDIES_OFFERED_EXPIRY_TIME :within {UNITS_MONTHS_OR_MINUTES} +STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE :until {DATE_SHORT} +STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME :{UNITS_MONTHS_OR_MINUTES} remaining # Story book window STR_STORY_BOOK_CAPTION :{WHITE}{COMPANY} Story Book diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index c0d5c0eeff..9e72fe203e 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -159,7 +159,15 @@ struct SubsidyListWindow : Window { if (IsInsideMM(pos, 0, cap)) { /* Displays the two offered towns */ SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui); - SetDParam(7, TimerGameEconomy::date - ymd.day + s->remaining * 32); + /* 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. + } else { + SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_DATE); + SetDParam(8, TimerGameEconomy::date - ymd.day + s->remaining * 32); + } + DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO); } pos++; @@ -183,7 +191,15 @@ struct SubsidyListWindow : Window { if (IsInsideMM(pos, 0, cap)) { SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui); SetDParam(7, s->awarded); - SetDParam(8, TimerGameEconomy::date - ymd.day + s->remaining * 32); + /* 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); + } /* Displays the two connected stations */ DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);