From 666809fb8b1cb46a8d79101238c7950a0ddec0f6 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 23 Oct 2017 00:44:55 +0200 Subject: [PATCH] Move object load error window to UI module --- src/openrct2-ui/WindowManager.cpp | 7 +++++++ .../windows/ObjectLoadError.cpp | 11 ++++++----- src/openrct2-ui/windows/Window.h | 2 ++ src/openrct2/game.c | 9 ++++++--- src/openrct2/interface/window.h | 2 -- src/openrct2/windows/Intent.h | 2 ++ 6 files changed, 23 insertions(+), 10 deletions(-) rename src/{openrct2 => openrct2-ui}/windows/ObjectLoadError.cpp (98%) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 001c4f2962..4c14862939 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -211,6 +211,13 @@ public: close_callback callback = intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK); return window_network_status_open(message.c_str(), callback); } + case WC_OBJECT_LOAD_ERROR: + { + std::string path = intent->GetStringExtra(INTENT_EXTRA_PATH); + const rct_object_entry * objects = (rct_object_entry *) intent->GetPointerExtra(INTENT_EXTRA_LIST); + size_t count = intent->GetUIntExtra(INTENT_EXTRA_LIST_COUNT); + window_object_load_error_open(const_cast(path.c_str()), count, objects); + } case WC_RIDE: return window_ride_main_open(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID)); case WC_TRACK_DESIGN_PLACE: diff --git a/src/openrct2/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp similarity index 98% rename from src/openrct2/windows/ObjectLoadError.cpp rename to src/openrct2-ui/windows/ObjectLoadError.cpp index 8469a36c1b..0eb1b8fa31 100644 --- a/src/openrct2/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -14,12 +14,13 @@ *****************************************************************************/ #pragma endregion -#include "../object/ObjectManager.h" -#include "../core/Memory.hpp" +#include -#include "../interface/widget.h" -#include "../localisation/localisation.h" -#include "../platform/platform.h" +#include +#include +#include +#include +#include enum WINDOW_OBJECT_LOAD_ERROR_WIDGET_IDX { WIDX_BACKGROUND, diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 586ca72c44..ca958cdc79 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -129,3 +129,5 @@ void window_network_status_close(); void window_text_input_key(rct_window * w, char keychar); void window_text_input_open(rct_window * call_w, rct_widgetindex call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uintptr_t existing_args, sint32 maxLength); void window_text_input_raw_open(rct_window * call_w, rct_widgetindex call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, sint32 maxLength); + +rct_window * window_object_load_error_open(utf8 * path, size_t numMissingObjects, const rct_object_entry * missingObjects); diff --git a/src/openrct2/game.c b/src/openrct2/game.c index f685a794b3..fc213ec935 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1148,9 +1148,12 @@ void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, cons } // The path needs to be duplicated as it's a const here // which the window function doesn't like - window_object_load_error_open(strndup(path, strnlen(path, MAX_PATH)), - ParkLoadResult_GetMissingObjectsCount(result), - ParkLoadResult_GetMissingObjects(result)); + Intent * intent = intent_create(WC_OBJECT_LOAD_ERROR); + intent_set_string(intent, INTENT_EXTRA_PATH, strndup(path, strnlen(path, MAX_PATH))); + intent_set_pointer(intent, INTENT_EXTRA_LIST, (void *) ParkLoadResult_GetMissingObjects(result)); + intent_set_uint(intent, INTENT_EXTRA_LIST_COUNT, (uint32) ParkLoadResult_GetMissingObjectsCount(result)); + context_open_intent(intent); + intent_release(intent); } else if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG) { diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 8dc8324184..3353bc85cf 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -726,8 +726,6 @@ void window_scenery_open(); void window_tile_inspector_open(); void window_tile_inspector_clear_clipboard(); -rct_window * window_object_load_error_open(utf8 * path, size_t numMissingObjects, const rct_object_entry * missingObjects); - rct_window * window_editor_main_open(); void window_editor_bottom_toolbar_open(); void window_editor_object_selection_open(); diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index ef8f0bba9b..29cfaab506 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -66,6 +66,8 @@ extern "C" { INTENT_EXTRA_TILE_ELEMENT, INTENT_EXTRA_VEHICLE, INTENT_EXTRA_MESSAGE, + INTENT_EXTRA_LIST, + INTENT_EXTRA_LIST_COUNT, }; enum {