mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Consolidate groupbox drawing code
This commit is contained in:
@@ -447,26 +447,6 @@ namespace OpenRCT2::Ui
|
||||
WidgetText(dpi, w, widgetIndex);
|
||||
}
|
||||
|
||||
static std::pair<StringId, void*> WidgetGetStringidAndArgs(const Widget& widget)
|
||||
{
|
||||
auto stringId = widget.text;
|
||||
void* formatArgs = gCommonFormatArgs;
|
||||
if (widget.flags & WIDGET_FLAGS::TEXT_IS_STRING)
|
||||
{
|
||||
if (widget.string == nullptr || widget.string[0] == '\0')
|
||||
{
|
||||
stringId = kStringIdNone;
|
||||
formatArgs = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
stringId = STR_STRING;
|
||||
formatArgs = const_cast<void*>(reinterpret_cast<const void*>(&widget.string));
|
||||
}
|
||||
}
|
||||
return std::make_pair(stringId, formatArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EB535
|
||||
@@ -482,7 +462,21 @@ namespace OpenRCT2::Ui
|
||||
auto textRight = l;
|
||||
|
||||
// Text
|
||||
auto [stringId, formatArgs] = WidgetGetStringidAndArgs(widget);
|
||||
auto stringId = widget.text;
|
||||
auto rawFt = Formatter::Common();
|
||||
if (widget.flags & WIDGET_FLAGS::TEXT_IS_STRING)
|
||||
{
|
||||
if (widget.string != nullptr && widget.string[0] != '\0')
|
||||
{
|
||||
stringId = STR_STRING;
|
||||
rawFt.Add<utf8*>(widget.string);
|
||||
}
|
||||
else
|
||||
{
|
||||
stringId = kStringIdNone;
|
||||
}
|
||||
}
|
||||
|
||||
if (stringId != kStringIdNone)
|
||||
{
|
||||
auto colour = w.colours[widget.colour].withFlag(ColourFlag::translucent, false);
|
||||
@@ -490,7 +484,8 @@ namespace OpenRCT2::Ui
|
||||
colour.setFlag(ColourFlag::inset, true);
|
||||
|
||||
utf8 buffer[512] = { 0 };
|
||||
OpenRCT2::FormatStringLegacy(buffer, sizeof(buffer), stringId, formatArgs);
|
||||
OpenRCT2::FormatStringLegacy(buffer, sizeof(buffer), stringId, rawFt.Data());
|
||||
|
||||
auto ft = Formatter();
|
||||
ft.Add<utf8*>(buffer);
|
||||
DrawTextBasic(dpi, { l, t }, STR_STRING, ft, { colour });
|
||||
|
||||
Reference in New Issue
Block a user