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.
This commit is contained in:
Peter Nelson 2023-10-28 16:08:44 +01:00 committed by GitHub
parent 062c19830b
commit 129e98fbab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -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 uint DropDownListStringItem::Width() const
{ {
return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal();

View File

@ -37,10 +37,10 @@ public:
*/ */
class DropDownListStringItem : public DropDownListItem { class DropDownListStringItem : public DropDownListItem {
public: public:
const std::string string; ///< String of item std::string string; ///< String of item
DropDownListStringItem(StringID string, int result, bool masked); 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; } bool Selectable() const override { return true; }
uint Width() const override; uint Width() const override;