diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 2093d931bd..bf3058ba13 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -326,7 +326,7 @@ export interface Park { * Represents the type of a widget, e.g. button or label. */ export type WidgetType = - "button" | "dropdown" | "label" | "tabview" | "viewport"; + "button" | "dropdown" | "groupbox" | "label" | "tabview" | "viewport"; export interface Widget { type: WidgetType; diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 7f4072b40f..78f2d7311e 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -455,7 +455,22 @@ static void widget_groupbox_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg int32_t textRight = l; // Text - if (widget->text != STR_NONE) + auto stringId = widget->text; + void* formatArgs = gCommonFormatArgs; + if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING) + { + if (widget->string == nullptr || widget->string[0] == '\0') + { + stringId = STR_NONE; + formatArgs = nullptr; + } + else + { + stringId = STR_STRING; + formatArgs = &widget->string; + } + } + if (stringId != STR_NONE) { uint8_t colour = w->colours[widget->colour] & 0x7F; if (widget_is_disabled(w, widgetIndex)) @@ -463,7 +478,7 @@ static void widget_groupbox_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg utf8 buffer[512] = { 0 }; uint8_t args[sizeof(uintptr_t)] = { 0 }; - format_string(buffer, sizeof(buffer), widget->text, gCommonFormatArgs); + format_string(buffer, sizeof(buffer), stringId, formatArgs); Formatter(args).Add(buffer); gfx_draw_string_left(dpi, STR_STRING, args, colour, l, t); textRight = l + gfx_get_string_width(buffer) + 1; diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index a5d02962a0..80834e61cb 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -137,7 +137,7 @@ namespace OpenRCT2::Ui::Windows result.SelectedIndex = desc["selectedIndex"].as_int(); result.OnChange = desc["onChange"]; } - else if (result.Type == "label") + else if (result.Type == "groupbox" || result.Type == "label") { result.Text = ProcessString(desc["text"].as_string()); } @@ -460,6 +460,13 @@ namespace OpenRCT2::Ui::Windows widget.flags |= WIDGET_FLAGS::IS_ENABLED; widgetList.push_back(widget); } + else if (desc.Type == "groupbox") + { + widget.type = WWT_GROUPBOX; + widget.string = (utf8*)desc.Text.c_str(); + widget.flags |= WIDGET_FLAGS::TEXT_IS_STRING; + widgetList.push_back(widget); + } else if (desc.Type == "label") { widget.type = WWT_LABEL;