From 129e98fbab17ac8af3e5f4224fa176da3a5cbdf5 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 28 Oct 2023 16:08:44 +0100 Subject: [PATCH] Fix d42a78f: Some raw drop down list strings may need token processing. (#11400) Storing the raw string without processing though GetString() caused token processing to be skipped. --- src/widgets/dropdown.cpp | 7 +++++++ src/widgets/dropdown_type.h | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 43be78dbec..bca67a504e 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -36,6 +36,13 @@ DropDownListStringItem::DropDownListStringItem(StringID string, int result, bool { } +DropDownListStringItem::DropDownListStringItem(const std::string &string, int result, bool masked) : DropDownListItem(result, masked) +{ + /* A raw string may contain parsable tokens, so it needs to be passed through GetString. */ + SetDParamStr(0, string); + this->string = GetString(STR_JUST_RAW_STRING); +} + uint DropDownListStringItem::Width() const { return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index 19da6acfcd..424b9906ae 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -37,10 +37,10 @@ public: */ class DropDownListStringItem : public DropDownListItem { public: - const std::string string; ///< String of item + std::string string; ///< String of item DropDownListStringItem(StringID string, int result, bool masked); - DropDownListStringItem(const std::string &string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} + DropDownListStringItem(const std::string &string, int result, bool masked); bool Selectable() const override { return true; } uint Width() const override;