mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implement onClose event for custom windows
This commit is contained in:
parent
c0aa5bdcc8
commit
ca98ffc697
|
@ -192,6 +192,9 @@ namespace OpenRCT2::Ui::Windows
|
|||
std::vector<CustomWidgetDesc> Widgets;
|
||||
std::vector<colour_t> Colours;
|
||||
|
||||
// Event handlers
|
||||
DukValue OnClose;
|
||||
|
||||
CustomWindowDesc() = default;
|
||||
|
||||
bool IsResizable() const
|
||||
|
@ -235,6 +238,8 @@ namespace OpenRCT2::Ui::Windows
|
|||
});
|
||||
}
|
||||
|
||||
result.OnClose = desc["onClose"];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -338,8 +343,13 @@ namespace OpenRCT2::Ui::Windows
|
|||
|
||||
static void window_custom_close(rct_window* w)
|
||||
{
|
||||
delete static_cast<CustomWindowInfo*>(w->custom_info);
|
||||
w->custom_info = nullptr;
|
||||
auto info = static_cast<CustomWindowInfo*>(w->custom_info);
|
||||
if (info != nullptr)
|
||||
{
|
||||
InvokeEventHandler(info->Owner, info->Desc.OnClose);
|
||||
delete info;
|
||||
w->custom_info = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_custom_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
|
|
Loading…
Reference in New Issue