From 2f75f3d147c7bd9ef749bb6d5694900bee7418b0 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 2 Mar 2025 18:33:11 +0000 Subject: [PATCH] Codechange: Use GetWidgetString for goal, league and story windows. (#13700) --- src/goal_gui.cpp | 24 +++++++++++------------- src/league_gui.cpp | 7 ++++--- src/story_gui.cpp | 16 ++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 6484419e8a..c9184f67ca 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -51,16 +51,14 @@ struct GoalListWindow : public Window { this->OnInvalidateData(0); } - void SetStringParameters(WidgetID widget) const override + std::string GetWidgetString(WidgetID widget, StringID stringid) const override { - if (widget != WID_GOAL_CAPTION) return; + if (widget != WID_GOAL_CAPTION) return this->Window::GetWidgetString(widget, stringid); if (this->window_number == CompanyID::Invalid()) { - SetDParam(0, STR_GOALS_SPECTATOR_CAPTION); - } else { - SetDParam(0, STR_GOALS_CAPTION); - SetDParam(1, this->window_number); + return GetString(stringid, STR_GOALS_SPECTATOR_CAPTION); } + return GetString(stringid, STR_GOALS_CAPTION, this->window_number); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override @@ -348,20 +346,20 @@ struct GoalQuestionWindow : public Window { } - void SetStringParameters(WidgetID widget) const override + std::string GetWidgetString(WidgetID widget, StringID stringid) const override { switch (widget) { case WID_GQ_BUTTON_1: - SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]); - break; + return GetString(stringid, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]); case WID_GQ_BUTTON_2: - SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]); - break; + return GetString(stringid, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]); case WID_GQ_BUTTON_3: - SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]); - break; + return GetString(stringid, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]); + + default: + return this->Window::GetWidgetString(widget, stringid); } } diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 442cf51751..b411298a68 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -296,10 +296,11 @@ public: this->InitNested(table); } - void SetStringParameters(WidgetID widget) const override + std::string GetWidgetString(WidgetID widget, StringID stringid) const override { - if (widget != WID_SLT_CAPTION) return; - SetDParamStr(0, this->title); + if (widget != WID_SLT_CAPTION) return this->Window::GetWidgetString(widget, stringid); + + return GetString(stringid, this->title); } void OnPaint() override diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 015b4067ed..9195035308 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -637,22 +637,22 @@ public: } } - void SetStringParameters(WidgetID widget) const override + std::string GetWidgetString(WidgetID widget, StringID stringid) const override { switch (widget) { case WID_SB_SEL_PAGE: { StoryPage *page = this->GetSelPage(); - SetDParamStr(0, page != nullptr && !page->title.empty() ? page->title : this->selected_generic_title); - break; + return GetString(stringid, page != nullptr && !page->title.empty() ? page->title : this->selected_generic_title); } + case WID_SB_CAPTION: if (this->window_number == CompanyID::Invalid()) { - SetDParam(0, STR_STORY_BOOK_SPECTATOR_CAPTION); - } else { - SetDParam(0, STR_STORY_BOOK_CAPTION); - SetDParam(1, this->window_number); + return GetString(stringid, STR_STORY_BOOK_SPECTATOR_CAPTION); } - break; + return GetString(stringid, STR_STORY_BOOK_CAPTION, this->window_number); + + default: + return this->Window::GetWidgetString(widget, stringid); } }