Implement onClose event for custom windows

This commit is contained in:
Ted John 2020-04-26 16:01:03 +01:00
parent c0aa5bdcc8
commit ca98ffc697
1 changed files with 12 additions and 2 deletions

View File

@ -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)