mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Implement group boxes
This commit is contained in:
2
distribution/openrct2.d.ts
vendored
2
distribution/openrct2.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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<utf8*>(buffer);
|
||||
gfx_draw_string_left(dpi, STR_STRING, args, colour, l, t);
|
||||
textRight = l + gfx_get_string_width(buffer) + 1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user