mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #18324: Refactor TitleOptions to class
This commit is contained in:
parent
7e653fc201
commit
fdbceae17c
|
@ -19,40 +19,23 @@ enum WindowTitleOptionsWidgetIdx {
|
||||||
WIDX_OPTIONS,
|
WIDX_OPTIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
static rct_widget window_title_options_widgets[] = {
|
static rct_widget _windowTitleOptionsWidgets[] = {
|
||||||
MakeWidget({0, 0}, {80, 15}, WindowWidgetType::Button, WindowColour::Tertiary, STR_OPTIONS, STR_OPTIONS_TIP),
|
MakeWidget({0, 0}, {80, 15}, WindowWidgetType::Button, WindowColour::Tertiary, STR_OPTIONS, STR_OPTIONS_TIP),
|
||||||
WIDGETS_END,
|
WIDGETS_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void WindowTitleOptionsMouseup(rct_window *w, WidgetIndex widgetIndex);
|
|
||||||
static void WindowTitleOptionsPaint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
||||||
|
|
||||||
static WindowEventList window_title_options_events([](auto& events)
|
|
||||||
{
|
|
||||||
events.mouse_up = &WindowTitleOptionsMouseup;
|
|
||||||
events.paint = &WindowTitleOptionsPaint;
|
|
||||||
});
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
/**
|
class TitleOptionsWindow final : public Window
|
||||||
* Creates the window containing the options button on the title screen.
|
|
||||||
*/
|
|
||||||
rct_window* WindowTitleOptionsOpen()
|
|
||||||
{
|
{
|
||||||
rct_window* window = WindowCreate(
|
public:
|
||||||
ScreenCoordsXY(context_get_width() - 80, 0), 80, 15, &window_title_options_events, WindowClass::TitleOptions,
|
void OnOpen() override
|
||||||
WF_STICK_TO_BACK | WF_TRANSPARENT);
|
{
|
||||||
window->widgets = window_title_options_widgets;
|
widgets = _windowTitleOptionsWidgets;
|
||||||
WindowInitScrollWidgets(*window);
|
WindowInitScrollWidgets(*this);
|
||||||
|
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WindowTitleOptionsMouseup(rct_window* w, WidgetIndex widgetIndex)
|
void OnMouseUp(WidgetIndex widgetIndex) override
|
||||||
{
|
{
|
||||||
if (gIntroState != IntroState::None)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (widgetIndex)
|
switch (widgetIndex)
|
||||||
{
|
{
|
||||||
case WIDX_OPTIONS:
|
case WIDX_OPTIONS:
|
||||||
|
@ -61,7 +44,23 @@ static void WindowTitleOptionsMouseup(rct_window* w, WidgetIndex widgetIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WindowTitleOptionsPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
void OnDraw(rct_drawpixelinfo& dpi) override
|
||||||
{
|
{
|
||||||
WindowDrawWidgets(*w, dpi);
|
DrawWidgets(dpi);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the window containing the options button on the title screen.
|
||||||
|
*/
|
||||||
|
rct_window* WindowTitleOptionsOpen()
|
||||||
|
{
|
||||||
|
auto* window = window_bring_to_front_by_class(WindowClass::TitleOptions);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
window = WindowCreate<TitleOptionsWindow>(
|
||||||
|
WindowClass::TitleOptions, ScreenCoordsXY(context_get_width() - 80, 0), 80, 15, WF_STICK_TO_BACK | WF_TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue