diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index d7a0e1bf5b..68fdd81788 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -281,7 +281,7 @@ public: { switch (e.type) { case SDL_QUIT: - rct2_quit(); + context_quit(); break; case SDL_WINDOWEVENT: // HACK: Fix #2158, OpenRCT2 does not draw if it does not think that the window is diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index db27a70fd9..5a9ffe4d21 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -167,6 +167,12 @@ namespace OpenRCT2 _finished = true; } + void Quit() override + { + gSavePromptMode = PM_QUIT; + window_save_prompt_open(); + } + bool Initialise() final override { if (_initialised) @@ -856,6 +862,11 @@ extern "C" return GetContext()->GetUiContext()->ReadBMP(outPixels, outWidth, outHeight, std::string(path)); } + void context_quit() + { + GetContext()->Quit(); + } + bool platform_open_common_file_dialog(utf8 * outFilename, file_dialog_desc * desc, size_t outSize) { try diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index de28d51995..dafca8d401 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -98,6 +98,7 @@ namespace OpenRCT2 virtual bool Initialise() abstract; virtual void Open(const std::string &path) abstract; virtual void Finish() abstract; + virtual void Quit() abstract; }; IContext * CreateContext(); @@ -147,6 +148,7 @@ extern "C" rct_window * context_open_window(rct_windowclass wc); void context_input_handle_keyboard(bool isTitle); bool context_read_bmp(void * * outPixels, uint32 * outWidth, uint32 * outHeight, const utf8 * path); + void context_quit(); #ifdef __cplusplus } #endif diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index c797a653ed..b200acc9f7 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -87,12 +87,6 @@ uint8 gSavePromptMode; char gRCT2AddressAppPath[MAX_PATH]; -void rct2_quit() -{ - gSavePromptMode = PM_QUIT; - window_save_prompt_open(); -} - /** * * rct2: 0x00683499 diff --git a/src/openrct2/rct2.h b/src/openrct2/rct2.h index 9e6a18e9a0..48a848ceeb 100644 --- a/src/openrct2/rct2.h +++ b/src/openrct2/rct2.h @@ -157,7 +157,6 @@ extern char gRCT2AddressAppPath[]; sint32 rct2_init_directories(); const char *get_file_path(sint32 pathId); -void rct2_quit(); #ifdef __cplusplus } diff --git a/src/openrct2/windows/title_exit.c b/src/openrct2/windows/title_exit.c index db931eee0c..f1f8d61db9 100644 --- a/src/openrct2/windows/title_exit.c +++ b/src/openrct2/windows/title_exit.c @@ -98,7 +98,7 @@ static void window_title_exit_mouseup(rct_window *w, rct_widgetindex widgetIndex switch (widgetIndex) { case WIDX_EXIT: - rct2_quit(); + context_quit(); //game_do_command(0, 1, 0, 0, 5, 3, 0); break; }; diff --git a/src/openrct2/windows/top_toolbar.c b/src/openrct2/windows/top_toolbar.c index bb75f79c09..e6ef335059 100644 --- a/src/openrct2/windows/top_toolbar.c +++ b/src/openrct2/windows/top_toolbar.c @@ -585,7 +585,7 @@ static void window_top_toolbar_dropdown(rct_window *w, rct_widgetindex widgetInd game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 1, 0); break; case DDIDX_EXIT_OPENRCT2: - rct2_quit(); + context_quit(); break; #ifndef DISABLE_TWITCH case DDIDX_ENABLE_TWITCH: