mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Remove event handlers (#20439)
This commit is contained in:
@@ -286,26 +286,6 @@ WindowBase* WindowCreate(
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBase* WindowCreate(
|
|
||||||
const ScreenCoordsXY& pos, int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags)
|
|
||||||
{
|
|
||||||
auto w = std::make_unique<WindowBase>();
|
|
||||||
w->event_handlers = event_handlers;
|
|
||||||
return WindowCreate(std::move(w), cls, pos, width, height, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBase* WindowCreateAutoPos(int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags)
|
|
||||||
{
|
|
||||||
auto pos = GetAutoPositionForNewWindow(width, height);
|
|
||||||
return WindowCreate(pos, width, height, event_handlers, cls, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBase* WindowCreateCentred(int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags)
|
|
||||||
{
|
|
||||||
auto pos = GetCentrePositionForNewWindow(width, height);
|
|
||||||
return WindowCreate(pos, width, height, event_handlers, cls, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t WindowGetWidgetIndex(const WindowBase& w, Widget* widget)
|
static int32_t WindowGetWidgetIndex(const WindowBase& w, Widget* widget)
|
||||||
{
|
{
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|||||||
@@ -1413,119 +1413,70 @@ void ToolCancel()
|
|||||||
|
|
||||||
void WindowEventCloseCall(WindowBase* w)
|
void WindowEventCloseCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnClose();
|
w->OnClose();
|
||||||
else if (w->event_handlers->close != nullptr)
|
|
||||||
w->event_handlers->close(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventMouseUpCall(WindowBase* w, WidgetIndex widgetIndex)
|
void WindowEventMouseUpCall(WindowBase* w, WidgetIndex widgetIndex)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnMouseUp(widgetIndex);
|
w->OnMouseUp(widgetIndex);
|
||||||
else if (w->event_handlers->mouse_up != nullptr)
|
|
||||||
w->event_handlers->mouse_up(w, widgetIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventResizeCall(WindowBase* w)
|
void WindowEventResizeCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnResize();
|
w->OnResize();
|
||||||
else if (w->event_handlers->resize != nullptr)
|
|
||||||
w->event_handlers->resize(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventMouseDownCall(WindowBase* w, WidgetIndex widgetIndex)
|
void WindowEventMouseDownCall(WindowBase* w, WidgetIndex widgetIndex)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnMouseDown(widgetIndex);
|
w->OnMouseDown(widgetIndex);
|
||||||
else if (w->event_handlers->mouse_down != nullptr)
|
|
||||||
w->event_handlers->mouse_down(w, widgetIndex, &w->widgets[widgetIndex]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventDropdownCall(WindowBase* w, WidgetIndex widgetIndex, int32_t dropdownIndex)
|
void WindowEventDropdownCall(WindowBase* w, WidgetIndex widgetIndex, int32_t dropdownIndex)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
w->OnDropdown(widgetIndex, dropdownIndex);
|
w->OnDropdown(widgetIndex, dropdownIndex);
|
||||||
}
|
}
|
||||||
else if (w->event_handlers->dropdown != nullptr)
|
|
||||||
{
|
|
||||||
w->event_handlers->dropdown(w, widgetIndex, dropdownIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowEventUnknown05Call(WindowBase* w)
|
void WindowEventUnknown05Call(WindowBase* w)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
w->OnUnknown5();
|
w->OnUnknown5();
|
||||||
}
|
}
|
||||||
else if (w->event_handlers->unknown_05 != nullptr)
|
|
||||||
{
|
|
||||||
w->event_handlers->unknown_05(w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowEventUpdateCall(WindowBase* w)
|
void WindowEventUpdateCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnUpdate();
|
w->OnUpdate();
|
||||||
else if (w->event_handlers->update != nullptr)
|
|
||||||
w->event_handlers->update(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventPeriodicUpdateCall(WindowBase* w)
|
void WindowEventPeriodicUpdateCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnPeriodicUpdate();
|
w->OnPeriodicUpdate();
|
||||||
else if (w->event_handlers->periodic_update != nullptr)
|
|
||||||
w->event_handlers->periodic_update(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventToolUpdateCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventToolUpdateCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnToolUpdate(widgetIndex, screenCoords);
|
w->OnToolUpdate(widgetIndex, screenCoords);
|
||||||
else if (w->event_handlers->tool_update != nullptr)
|
|
||||||
w->event_handlers->tool_update(w, widgetIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventToolDownCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventToolDownCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnToolDown(widgetIndex, screenCoords);
|
w->OnToolDown(widgetIndex, screenCoords);
|
||||||
else if (w->event_handlers->tool_down != nullptr)
|
|
||||||
w->event_handlers->tool_down(w, widgetIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventToolDragCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventToolDragCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnToolDrag(widgetIndex, screenCoords);
|
w->OnToolDrag(widgetIndex, screenCoords);
|
||||||
else if (w->event_handlers->tool_drag != nullptr)
|
|
||||||
w->event_handlers->tool_drag(w, widgetIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventToolUpCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventToolUpCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnToolUp(widgetIndex, screenCoords);
|
w->OnToolUp(widgetIndex, screenCoords);
|
||||||
else if (w->event_handlers->tool_up != nullptr)
|
|
||||||
w->event_handlers->tool_up(w, widgetIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventToolAbortCall(WindowBase* w, WidgetIndex widgetIndex)
|
void WindowEventToolAbortCall(WindowBase* w, WidgetIndex widgetIndex)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnToolAbort(widgetIndex);
|
w->OnToolAbort(widgetIndex);
|
||||||
else if (w->event_handlers->tool_abort != nullptr)
|
|
||||||
w->event_handlers->tool_abort(w, widgetIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowGetScrollSize(WindowBase* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
void WindowGetScrollSize(WindowBase* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
auto size = w->OnScrollGetSize(scrollIndex);
|
auto size = w->OnScrollGetSize(scrollIndex);
|
||||||
if (width != nullptr)
|
if (width != nullptr)
|
||||||
@@ -1533,127 +1484,68 @@ void WindowGetScrollSize(WindowBase* w, int32_t scrollIndex, int32_t* width, int
|
|||||||
if (height != nullptr)
|
if (height != nullptr)
|
||||||
*height = size.height;
|
*height = size.height;
|
||||||
}
|
}
|
||||||
else if (w->event_handlers->get_scroll_size != nullptr)
|
|
||||||
{
|
|
||||||
w->event_handlers->get_scroll_size(w, scrollIndex, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowEventScrollMousedownCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventScrollMousedownCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnScrollMouseDown(scrollIndex, screenCoords);
|
w->OnScrollMouseDown(scrollIndex, screenCoords);
|
||||||
else if (w->event_handlers->scroll_mousedown != nullptr)
|
|
||||||
w->event_handlers->scroll_mousedown(w, scrollIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventScrollMousedragCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventScrollMousedragCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnScrollMouseDrag(scrollIndex, screenCoords);
|
w->OnScrollMouseDrag(scrollIndex, screenCoords);
|
||||||
else if (w->event_handlers->scroll_mousedrag != nullptr)
|
|
||||||
w->event_handlers->scroll_mousedrag(w, scrollIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventScrollMouseoverCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
void WindowEventScrollMouseoverCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnScrollMouseOver(scrollIndex, screenCoords);
|
w->OnScrollMouseOver(scrollIndex, screenCoords);
|
||||||
else if (w->event_handlers->scroll_mouseover != nullptr)
|
|
||||||
w->event_handlers->scroll_mouseover(w, scrollIndex, screenCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventTextinputCall(WindowBase* w, WidgetIndex widgetIndex, const char* text)
|
void WindowEventTextinputCall(WindowBase* w, WidgetIndex widgetIndex, const char* text)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
if (text != nullptr)
|
if (text != nullptr)
|
||||||
{
|
{
|
||||||
w->OnTextInput(widgetIndex, text);
|
w->OnTextInput(widgetIndex, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (w->event_handlers->text_input != nullptr)
|
|
||||||
{
|
|
||||||
w->event_handlers->text_input(w, widgetIndex, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowEventViewportRotateCall(WindowBase* w)
|
void WindowEventViewportRotateCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnViewportRotate();
|
w->OnViewportRotate();
|
||||||
else if (w->event_handlers != nullptr)
|
|
||||||
if (w->event_handlers->viewport_rotate != nullptr)
|
|
||||||
w->event_handlers->viewport_rotate(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventScrollSelectCall(WindowBase* w, int32_t scrollIndex, int32_t scrollAreaType)
|
void WindowEventScrollSelectCall(WindowBase* w, int32_t scrollIndex, int32_t scrollAreaType)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnScrollSelect(scrollIndex, scrollAreaType);
|
w->OnScrollSelect(scrollIndex, scrollAreaType);
|
||||||
else if (w->event_handlers->scroll_select != nullptr)
|
|
||||||
w->event_handlers->scroll_select(w, scrollIndex, scrollAreaType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenRCT2String WindowEventTooltipCall(WindowBase* w, const WidgetIndex widgetIndex, const StringId fallback)
|
OpenRCT2String WindowEventTooltipCall(WindowBase* w, const WidgetIndex widgetIndex, const StringId fallback)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
return w->OnTooltip(widgetIndex, fallback);
|
return w->OnTooltip(widgetIndex, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->event_handlers->tooltip != nullptr)
|
|
||||||
{
|
|
||||||
return w->event_handlers->tooltip(w, widgetIndex, fallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { fallback, {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
CursorID WindowEventCursorCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
CursorID WindowEventCursorCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
CursorID cursorId = CursorID::Arrow;
|
return w->OnCursor(widgetIndex, screenCoords, CursorID::Arrow);
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
|
||||||
cursorId = w->OnCursor(widgetIndex, screenCoords, cursorId);
|
|
||||||
}
|
|
||||||
else if (w->event_handlers->cursor != nullptr)
|
|
||||||
w->event_handlers->cursor(w, widgetIndex, screenCoords, &cursorId);
|
|
||||||
return cursorId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventMovedCall(WindowBase* w, const ScreenCoordsXY& screenCoords)
|
void WindowEventMovedCall(WindowBase* w, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
{
|
{
|
||||||
w->OnMoved(screenCoords);
|
w->OnMoved(screenCoords);
|
||||||
}
|
}
|
||||||
else if (w->event_handlers->moved != nullptr)
|
|
||||||
w->event_handlers->moved(w, screenCoords);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowEventInvalidateCall(WindowBase* w)
|
void WindowEventInvalidateCall(WindowBase* w)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnPrepareDraw();
|
w->OnPrepareDraw();
|
||||||
else if (w->event_handlers->invalidate != nullptr)
|
|
||||||
w->event_handlers->invalidate(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventPaintCall(WindowBase* w, DrawPixelInfo& dpi)
|
void WindowEventPaintCall(WindowBase* w, DrawPixelInfo& dpi)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnDraw(dpi);
|
w->OnDraw(dpi);
|
||||||
else if (w->event_handlers->paint != nullptr)
|
|
||||||
w->event_handlers->paint(w, dpi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowEventScrollPaintCall(WindowBase* w, DrawPixelInfo& dpi, int32_t scrollIndex)
|
void WindowEventScrollPaintCall(WindowBase* w, DrawPixelInfo& dpi, int32_t scrollIndex)
|
||||||
{
|
{
|
||||||
if (w->event_handlers == nullptr)
|
|
||||||
w->OnScrollDraw(scrollIndex, dpi);
|
w->OnScrollDraw(scrollIndex, dpi);
|
||||||
else if (w->event_handlers->scroll_paint != nullptr)
|
|
||||||
w->event_handlers->scroll_paint(w, dpi, scrollIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -609,13 +609,6 @@ T* WindowFocusOrCreate(WindowClass cls, int32_t width, int32_t height, uint32_t
|
|||||||
return static_cast<T*>(w);
|
return static_cast<T*>(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBase* WindowCreate(
|
|
||||||
const ScreenCoordsXY& pos, int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags);
|
|
||||||
WindowBase* WindowCreateAutoPos(
|
|
||||||
int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags);
|
|
||||||
WindowBase* WindowCreateCentred(
|
|
||||||
int32_t width, int32_t height, WindowEventList* event_handlers, WindowClass cls, uint32_t flags);
|
|
||||||
|
|
||||||
void WindowClose(WindowBase& window);
|
void WindowClose(WindowBase& window);
|
||||||
void WindowCloseByClass(WindowClass cls);
|
void WindowCloseByClass(WindowClass cls);
|
||||||
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
|
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ struct RCTObjectEntry;
|
|||||||
*/
|
*/
|
||||||
struct WindowBase
|
struct WindowBase
|
||||||
{
|
{
|
||||||
WindowEventList* event_handlers{};
|
|
||||||
Viewport* viewport{};
|
Viewport* viewport{};
|
||||||
uint64_t disabled_widgets{};
|
uint64_t disabled_widgets{};
|
||||||
uint64_t pressed_widgets{};
|
uint64_t pressed_widgets{};
|
||||||
|
|||||||
Reference in New Issue
Block a user