1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Implement Widget API

This commit is contained in:
Ted John
2020-02-14 23:36:24 +00:00
parent 7274e45c93
commit b1cf6fcf63
5 changed files with 293 additions and 0 deletions

View File

@@ -234,6 +234,11 @@ namespace OpenRCT2::Ui::Windows
}
return nullptr;
}
CustomWidgetDesc* GetCustomWidgetDesc(size_t widgetIndex)
{
return const_cast<CustomWidgetDesc*>(std::as_const(*this).GetCustomWidgetDesc(widgetIndex));
}
};
static rct_windownumber _nextWindowNumber;
@@ -529,4 +534,19 @@ namespace OpenRCT2::Ui::Windows
}
}
}
void UpdateWidgetText(rct_window* w, rct_widgetindex widgetIndex, const std::string& value)
{
if (w->custom_info != nullptr)
{
auto &customInfo = GetInfo(w);
auto customWidgetInfo = customInfo.GetCustomWidgetDesc(widgetIndex);
if (customWidgetInfo != nullptr)
{
customWidgetInfo->Text = CustomWidgetDesc::ProcessString(value);
w->widgets[widgetIndex].string = customWidgetInfo->Text.data();
}
}
}
} // namespace OpenRCT2::Ui::Windows