From ac910a5979a705cee994962a12f82bf1091bc625 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 6 Sep 2017 16:09:35 +0200 Subject: [PATCH] Move Error, Campaign and Ride Demolition windows --- src/openrct2-ui/UiContext.cpp | 5 +- src/openrct2-ui/WindowManager.cpp | 8 ++++ src/openrct2-ui/windows/Cheats.cpp | 9 ++-- .../windows/DemolishRidePrompt.cpp | 20 ++++---- .../windows/EditorObjectiveOptions.cpp | 26 +++++------ .../windows/EditorScenarioOptions.cpp | 46 +++++++++---------- .../windows/Error.cpp | 24 +++++----- src/openrct2-ui/windows/Finances.cpp | 3 +- .../windows/NewCampaign.cpp | 21 +++++---- src/openrct2-ui/windows/Options.cpp | 9 ++-- src/openrct2-ui/windows/ServerList.cpp | 7 ++- src/openrct2-ui/windows/StaffList.cpp | 4 +- src/openrct2-ui/windows/Themes.cpp | 22 ++++----- src/openrct2-ui/windows/Window.h | 4 ++ src/openrct2/Context.cpp | 6 +++ src/openrct2/Context.h | 1 + src/openrct2/game.c | 5 +- src/openrct2/interface/Screenshot.cpp | 7 ++- src/openrct2/interface/window.h | 4 +- src/openrct2/network/Network.cpp | 5 +- src/openrct2/ride/TrackDesign.cpp | 1 - src/openrct2/ride/ride.c | 9 ++-- src/openrct2/ride/track.c | 1 - src/openrct2/ride/track_design_save.c | 16 +++---- src/openrct2/ui/DummyWindowManager.cpp | 1 + src/openrct2/ui/WindowManager.h | 1 + src/openrct2/windows/EditorBottomToolbar.cpp | 7 ++- .../windows/EditorObjectSelection.cpp | 5 +- src/openrct2/windows/InstallTrack.cpp | 9 ++-- src/openrct2/windows/LoadSave.cpp | 18 ++++---- src/openrct2/windows/Map.cpp | 5 +- src/openrct2/windows/Ride.cpp | 12 ++--- src/openrct2/windows/Scenery.cpp | 2 +- src/openrct2/windows/TitleEditor.cpp | 20 ++++---- src/openrct2/windows/TrackList.cpp | 5 +- src/openrct2/windows/TrackManage.cpp | 9 ++-- src/openrct2/windows/_legacy.c | 2 + src/openrct2/world/mapgen.c | 11 ++--- 38 files changed, 188 insertions(+), 182 deletions(-) rename src/{openrct2 => openrct2-ui}/windows/DemolishRidePrompt.cpp (92%) rename src/{openrct2 => openrct2-ui}/windows/Error.cpp (92%) rename src/{openrct2 => openrct2-ui}/windows/NewCampaign.cpp (97%) diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 20a24d4614..0dea756030 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -43,7 +43,6 @@ #include #include #include -#include using namespace OpenRCT2; using namespace OpenRCT2::Drawing; @@ -561,7 +560,7 @@ public: sint32 numChannels = bitmap->format->BytesPerPixel; if (numChannels < 3 || bitmap->format->BitsPerPixel < 24) { - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_24_BIT_BITMAP); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_24_BIT_BITMAP); SDL_FreeSurface(bitmap); return false; } @@ -611,7 +610,7 @@ public: else { log_warning("Failed to load bitmap: %s", SDL_GetError()); - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_BITMAP); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_BITMAP); return false; } } diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 4ada8ab024..ffd4713e52 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -125,6 +125,10 @@ public: { case WD_BANNER: return window_banner_open(id); + case WD_DEMOLISH_RIDE: + return window_ride_demolish_prompt_open(id); + case WD_NEW_CAMPAIGN: + return window_new_campaign_open(id); case WD_SIGN: return window_sign_open(id); case WD_SIGN_SMALL: @@ -138,6 +142,10 @@ public: } } + rct_window * ShowError(rct_string_id title, rct_string_id message) override + { + return window_error_open(title, message); + } void HandleKeyboard(bool isTitle) override { diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index 6c2eb87748..914ccf9dbf 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #define CHEATS_MONEY_DEFAULT MONEY(10000,00) @@ -807,19 +806,19 @@ static void window_cheats_rides_mouseup(rct_window *w, rct_widgetindex widgetInd case WIDX_SHOW_ALL_OPERATING_MODES: game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SHOWALLOPERATINGMODES, !gCheatsShowAllOperatingModes, GAME_COMMAND_CHEAT, 0, 0); if (gCheatsShowAllOperatingModes) { - window_error_open(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); + context_show_error(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); } break; case WIDX_SHOW_VEHICLES_FROM_OTHER_TRACK_TYPES: game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SHOWVEHICLESFROMOTHERTRACKTYPES, !gCheatsShowVehiclesFromOtherTrackTypes, GAME_COMMAND_CHEAT, 0, 0); if (gCheatsShowVehiclesFromOtherTrackTypes) { - window_error_open(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); + context_show_error(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); } break; case WIDX_DISABLE_TRAIN_LENGTH_LIMITS: game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_DISABLETRAINLENGTHLIMIT, !gCheatsDisableTrainLengthLimit, GAME_COMMAND_CHEAT, 0, 0); if (gCheatsDisableTrainLengthLimit) { - window_error_open(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); + context_show_error(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); } break; case WIDX_ENABLE_CHAIN_LIFT_ON_ALL_TRACK: @@ -828,7 +827,7 @@ static void window_cheats_rides_mouseup(rct_window *w, rct_widgetindex widgetInd case WIDX_ENABLE_ARBITRARY_RIDE_TYPE_CHANGES: game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_ALLOW_ARBITRARY_RIDE_TYPE_CHANGES, !gCheatsAllowArbitraryRideTypeChanges, GAME_COMMAND_CHEAT, 0, 0); if (gCheatsAllowArbitraryRideTypeChanges) { - window_error_open(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); + context_show_error(STR_WARNING_IN_CAPS, STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE); } break; case WIDX_DISABLE_RIDE_VALUE_AGING: diff --git a/src/openrct2/windows/DemolishRidePrompt.cpp b/src/openrct2-ui/windows/DemolishRidePrompt.cpp similarity index 92% rename from src/openrct2/windows/DemolishRidePrompt.cpp rename to src/openrct2-ui/windows/DemolishRidePrompt.cpp index ac4da57a0b..96b705bab5 100644 --- a/src/openrct2/windows/DemolishRidePrompt.cpp +++ b/src/openrct2-ui/windows/DemolishRidePrompt.cpp @@ -14,9 +14,10 @@ *****************************************************************************/ #pragma endregion -#include "../game.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" +#include +#include +#include +#include #define WW 200 #define WH 100 @@ -75,19 +76,21 @@ static rct_window_event_list window_ride_demolish_events = { }; /** Based off of rct2: 0x006B486A */ -static void _window_ride_demolish_prompt_open(sint32 rideIndex) +rct_window * window_ride_demolish_prompt_open(sint32 rideIndex) { rct_window *w; w = window_bring_to_front_by_number(WC_DEMOLISH_RIDE_PROMPT, rideIndex); if (w != nullptr) - return; + return w; w = window_create_centred(WW, WH, &window_ride_demolish_events, WC_DEMOLISH_RIDE_PROMPT, WF_TRANSPARENT); w->widgets = window_ride_demolish_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_DEMOLISH); window_init_scroll_widgets(w); w->number = rideIndex; + + return w; } @@ -136,10 +139,3 @@ static void window_ride_demolish_paint(rct_window *w, rct_drawpixelinfo *dpi) gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_DEMOLISH_RIDE_ID, COLOUR_BLACK); } - -extern "C" { - void window_ride_demolish_prompt_open(sint32 rideIndex) - { - _window_ride_demolish_prompt_open(rideIndex); - } -} diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index f5d265ff03..36db3c7d03 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #pragma region Widgets @@ -571,7 +571,7 @@ static void window_editor_objective_options_arg_1_increase(rct_window *w) case OBJECTIVE_MONTHLY_RIDE_INCOME: case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE: if (gScenarioObjectiveCurrency >= MONEY(2000000,00)) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency += MONEY(1000,0); window_invalidate(w); @@ -579,7 +579,7 @@ static void window_editor_objective_options_arg_1_increase(rct_window *w) break; case OBJECTIVE_MONTHLY_FOOD_INCOME: if (gScenarioObjectiveCurrency >= MONEY(2000000,00)) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency += MONEY(100,0); window_invalidate(w); @@ -587,7 +587,7 @@ static void window_editor_objective_options_arg_1_increase(rct_window *w) break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: if (gScenarioObjectiveNumGuests >= 5000) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveNumGuests += 100; window_invalidate(w); @@ -595,7 +595,7 @@ static void window_editor_objective_options_arg_1_increase(rct_window *w) break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: if (gScenarioObjectiveCurrency >= FIXED_2DP(9,90)) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency += FIXED_2DP(0,10); window_invalidate(w); @@ -603,7 +603,7 @@ static void window_editor_objective_options_arg_1_increase(rct_window *w) break; default: if (gScenarioObjectiveNumGuests >= 5000) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveNumGuests += 50; window_invalidate(w); @@ -619,7 +619,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) case OBJECTIVE_MONTHLY_RIDE_INCOME: case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE: if (gScenarioObjectiveCurrency <= MONEY(1000,00)) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency -= MONEY(1000,0); window_invalidate(w); @@ -627,7 +627,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) break; case OBJECTIVE_MONTHLY_FOOD_INCOME: if (gScenarioObjectiveCurrency <= MONEY(1000,00)) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency -= MONEY(100,0); window_invalidate(w); @@ -635,7 +635,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: if (gScenarioObjectiveNumGuests <= 1000) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveNumGuests -= 100; window_invalidate(w); @@ -643,7 +643,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: if (gScenarioObjectiveCurrency <= FIXED_2DP(4,00)) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveCurrency -= FIXED_2DP(0,10); window_invalidate(w); @@ -651,7 +651,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) break; default: if (gScenarioObjectiveNumGuests <= 250) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveNumGuests -= 50; window_invalidate(w); @@ -663,7 +663,7 @@ static void window_editor_objective_options_arg_1_decrease(rct_window *w) static void window_editor_objective_options_arg_2_increase(rct_window *w) { if (gScenarioObjectiveYear >= 25) { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } else { gScenarioObjectiveYear++; window_invalidate(w); @@ -673,7 +673,7 @@ static void window_editor_objective_options_arg_2_increase(rct_window *w) static void window_editor_objective_options_arg_2_decrease(rct_window *w) { if (gScenarioObjectiveYear <= 1) { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } else { gScenarioObjectiveYear--; window_invalidate(w); diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 22a7ca4e1c..01a46e87e7 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include #pragma region Widgets @@ -569,7 +569,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_INCREASE_CASH, STR_NONE); + context_show_error(STR_CANT_INCREASE_CASH, STR_NONE); } window_invalidate(w); break; @@ -585,7 +585,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_REDUCE_CASH, STR_NONE); + context_show_error(STR_CANT_REDUCE_CASH, STR_NONE); } window_invalidate(w); break; @@ -601,7 +601,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_INCREASE_INIT_LOAN, STR_NONE); + context_show_error(STR_CANT_INCREASE_INIT_LOAN, STR_NONE); } window_invalidate(w); break; @@ -617,7 +617,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_REDUCE_INIT_LOAN, STR_NONE); + context_show_error(STR_CANT_REDUCE_INIT_LOAN, STR_NONE); } window_invalidate(w); break; @@ -633,7 +633,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_INCREASE_MAX_LOAN, STR_NONE); + context_show_error(STR_CANT_INCREASE_MAX_LOAN, STR_NONE); } window_invalidate(w); break; @@ -649,7 +649,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc 0 ); } else { - window_error_open(STR_CANT_REDUCE_MAX_LOAN, STR_NONE); + context_show_error(STR_CANT_REDUCE_MAX_LOAN, STR_NONE); } window_invalidate(w); break; @@ -677,7 +677,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc ); } } else { - window_error_open(STR_CANT_INCREASE_INTEREST_RATE, STR_NONE); + context_show_error(STR_CANT_INCREASE_INTEREST_RATE, STR_NONE); } window_invalidate(w); break; @@ -705,7 +705,7 @@ static void window_editor_scenario_options_financial_mousedown(rct_window *w, rc ); } } else { - window_error_open(STR_CANT_REDUCE_INTEREST_RATE, STR_NONE); + context_show_error(STR_CANT_REDUCE_INTEREST_RATE, STR_NONE); } window_invalidate(w); break; @@ -902,7 +902,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -918,7 +918,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -934,7 +934,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -950,7 +950,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -966,7 +966,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -982,7 +982,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -998,7 +998,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1014,7 +1014,7 @@ static void window_editor_scenario_options_guests_mousedown(rct_window *w, rct_w 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1246,7 +1246,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1262,7 +1262,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1278,7 +1278,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1294,7 +1294,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1310,7 +1310,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_INCREASE_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_FURTHER, STR_NONE); } window_invalidate(w); break; @@ -1326,7 +1326,7 @@ static void window_editor_scenario_options_park_mousedown(rct_window *w, rct_wid 0 ); } else { - window_error_open(STR_CANT_REDUCE_FURTHER, STR_NONE); + context_show_error(STR_CANT_REDUCE_FURTHER, STR_NONE); } window_invalidate(w); break; diff --git a/src/openrct2/windows/Error.cpp b/src/openrct2-ui/windows/Error.cpp similarity index 92% rename from src/openrct2/windows/Error.cpp rename to src/openrct2-ui/windows/Error.cpp index 752aa46ea1..d2b8446248 100644 --- a/src/openrct2/windows/Error.cpp +++ b/src/openrct2-ui/windows/Error.cpp @@ -14,16 +14,14 @@ *****************************************************************************/ #pragma endregion -#include "../Context.h" -#include "../OpenRCT2.h" -#include "../core/Math.hpp" +#include +#include +#include +#include -#include "../audio/audio.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" -#include "error.h" - -bool gDisableErrorWindowSound = false; +#include +#include +#include enum { WIDX_BACKGROUND @@ -80,7 +78,7 @@ extern "C" { * bx: title * dx: message */ -void window_error_open(rct_string_id title, rct_string_id message) +rct_window * window_error_open(rct_string_id title, rct_string_id message) { utf8 *dst; sint32 numLines, fontHeight, x, y, width, height, maxY; @@ -107,12 +105,12 @@ void window_error_open(rct_string_id title, rct_string_id message) // Don't do unnecessary work in headless. Also saves checking if cursor state is null. if (gOpenRCT2Headless) { - return; + return nullptr; } // Check if there is any text to display if (dst == _window_error_text + 1) - return; + return nullptr; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; width = gfx_get_string_width_new_lined(_window_error_text); @@ -148,6 +146,8 @@ void window_error_open(rct_string_id title, rct_string_id message) if (!gDisableErrorWindowSound) { audio_play_sound(SOUND_ERROR, 0, w->x + (w->width / 2)); } + + return w; } } diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index fa8c21dba8..02a6c15293 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1094,7 +1095,7 @@ static void window_finances_marketing_mouseup(rct_window *w, rct_widgetindex wid else if (widgetIndex >= WIDX_TAB_1 && widgetIndex <= WIDX_TAB_6) window_finances_set_page(w, widgetIndex - WIDX_TAB_1); else if (widgetIndex >= WIDX_CAMPAIGN_1 && widgetIndex <= WIDX_CAMPAIGN_6) - window_new_campaign_open(widgetIndex - WIDX_CAMPAIGN_1); + context_open_detail_window(WD_NEW_CAMPAIGN, widgetIndex - WIDX_CAMPAIGN_1); } diff --git a/src/openrct2/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp similarity index 97% rename from src/openrct2/windows/NewCampaign.cpp rename to src/openrct2-ui/windows/NewCampaign.cpp index a4445a5363..7c326c567c 100644 --- a/src/openrct2/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -14,14 +14,15 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "../core/Math.hpp" +#include +#include +#include -#include "../game.h" -#include "../localisation/localisation.h" -#include "../interface/widget.h" -#include "../ride/ride_data.h" -#include "dropdown.h" +#include +#include +#include +#include +#include #define SELECTED_RIDE_UNDEFINED ((uint16)0xFFFF) @@ -122,7 +123,7 @@ static sint32 ride_name_compare(const void *a, const void *b) * * rct2: 0x0069E16F */ -void window_new_campaign_open(sint16 campaignType) +rct_window * window_new_campaign_open(sint16 campaignType) { rct_window *w; Ride *ride; @@ -131,7 +132,7 @@ void window_new_campaign_open(sint16 campaignType) w = window_bring_to_front_by_class(WC_NEW_CAMPAIGN); if (w != nullptr) { if (w->campaign.campaign_type == campaignType) - return; + return w; window_close(w); } @@ -189,6 +190,8 @@ void window_new_campaign_open(sint16 campaignType) qsort(window_new_campaign_rides, numApplicableRides, sizeof(uint8), ride_name_compare); window_new_campaign_rides[numApplicableRides] = 255; + + return w; } /** diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 1ea0b17d3a..fcc638d729 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -45,7 +45,6 @@ #include #include #include -#include enum WINDOW_OPTIONS_PAGE { WINDOW_OPTIONS_PAGE_DISPLAY, @@ -885,10 +884,10 @@ static void window_options_mouseup(rct_window *w, rct_widgetindex widgetIndex) SafeFree(gConfigGeneral.rct1_path); gConfigGeneral.rct1_path = rct1path; config_save_default(); - window_error_open(STR_RESTART_REQUIRED, STR_NONE); + context_show_error(STR_RESTART_REQUIRED, STR_NONE); } else { SafeFree(rct1path); - window_error_open(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE); + context_show_error(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE); } } window_invalidate(w); @@ -1386,7 +1385,7 @@ static void window_options_dropdown(rct_window *w, rct_widgetindex widgetIndex, if (language_open(fallbackLanguage)) { // It worked, so we can say it with error message in-game - window_error_open(STR_LANGUAGE_LOAD_FAILED, STR_NONE); + context_show_error(STR_LANGUAGE_LOAD_FAILED, STR_NONE); } // report error to console regardless log_error("Failed to open language file."); @@ -1431,7 +1430,7 @@ static void window_options_dropdown(rct_window *w, rct_widgetindex widgetIndex, break; case WIDX_TITLE_MUSIC_DROPDOWN: if ((dropdownIndex == 1 || dropdownIndex == 3) && !platform_file_exists(context_get_path_legacy(PATH_ID_CSS50))) { - window_error_open(STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND, STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND_HINT); + context_show_error(STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND, STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND_HINT); } else { gConfigSound.title_music = (sint8)dropdownIndex; diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index bb6bc9ab7c..a10501d294 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #define WWIDTH_MIN 500 #define WHEIGHT_MIN 300 @@ -200,7 +199,7 @@ static void window_server_list_mouseup(rct_window *w, rct_widgetindex widgetInde if (serverIndex >= 0 && serverIndex < _numServerEntries) { if (strcmp(_serverEntries[serverIndex].version, NETWORK_STREAM_ID) != 0 && strcmp(_serverEntries[serverIndex].version, "") != 0) { set_format_arg(0, void *, _serverEntries[serverIndex].version); - window_error_open(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_MULTIPLAYER_INCORRECT_SOFTWARE_VERSION); + context_show_error(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_MULTIPLAYER_INCORRECT_SOFTWARE_VERSION); break; } char *serverAddress = _serverEntries[serverIndex].address; @@ -236,7 +235,7 @@ static void window_server_list_dropdown(rct_window *w, rct_widgetindex widgetInd case DDIDX_JOIN: if (strcmp(_serverEntries[serverIndex].version, NETWORK_STREAM_ID) != 0 && strcmp(_serverEntries[serverIndex].version, "") != 0) { set_format_arg(0, void *, _serverEntries[serverIndex].version); - window_error_open(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_MULTIPLAYER_INCORRECT_SOFTWARE_VERSION); + context_show_error(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_MULTIPLAYER_INCORRECT_SOFTWARE_VERSION); break; } join_server(serverAddress); @@ -646,7 +645,7 @@ static void join_server(char *address) } if (!network_begin_client(address, port)) { - window_error_open(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_NONE); + context_show_error(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_NONE); } if (addresscopied) { diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index d22b517ba9..1473b3970c 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include enum { WINDOW_STAFF_LIST_TAB_HANDYMEN, @@ -375,7 +375,7 @@ static void window_staff_list_tooldown(rct_window *w, rct_widgetindex widgetInde window_event_dropdown_call(staffWindow, WC_PEEP__WIDX_PATROL, 0); } else { set_format_arg(0, rct_string_id, StaffNamingConvention[selectedPeepType].plural); - window_error_open(STR_NO_THING_IN_PARK_YET, STR_NONE); + context_show_error(STR_NO_THING_IN_PARK_YET, STR_NONE); } } } diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index 1a6ba32732..b5f8b4db22 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include #include enum { @@ -372,14 +372,14 @@ static void window_themes_mouseup(rct_window *w, rct_widgetindex widgetIndex) break; case WIDX_THEMES_DELETE_BUTTON: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_delete(); } break; case WIDX_THEMES_RENAME_BUTTON: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { activeAvailableThemeIndex = theme_manager_get_active_available_theme_index(); activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex); @@ -511,7 +511,7 @@ static void window_themes_mousedown(rct_window *w, rct_widgetindex widgetIndex, break; case WIDX_THEMES_RCT1_RIDE_LIGHTS: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_LIGHTS_RIDE); theme_save(); @@ -520,7 +520,7 @@ static void window_themes_mousedown(rct_window *w, rct_widgetindex widgetIndex, break; case WIDX_THEMES_RCT1_PARK_LIGHTS: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_LIGHTS_PARK); theme_save(); @@ -529,7 +529,7 @@ static void window_themes_mousedown(rct_window *w, rct_widgetindex widgetIndex, break; case WIDX_THEMES_RCT1_SCENARIO_FONT: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT); theme_save(); @@ -538,7 +538,7 @@ static void window_themes_mousedown(rct_window *w, rct_widgetindex widgetIndex, break; case WIDX_THEMES_RCT1_BOTTOM_TOOLBAR: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR); theme_save(); @@ -614,7 +614,7 @@ void window_themes_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, if (_colour_index_2 < numColours) { if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 && y2 >= _button_offset_y && y2 < _button_offset_y + 11) { if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); } else { window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].type = WWT_COLOURBTN; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].left = _button_offset_x + _colour_index_2 * 12 + window_themes_widgets[WIDX_THEMES_LIST].left; @@ -629,7 +629,7 @@ void window_themes_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, } else if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 - 1 && y2 >= _check_offset_y && y2 < _check_offset_y + 11) { if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { - window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); + context_show_error(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); } else { uint8 colour = theme_get_colour(wc, _colour_index_2); if (colour & COLOUR_FLAG_TRANSLUCENT) { @@ -667,7 +667,7 @@ static void window_themes_textinput(rct_window *w, rct_widgetindex widgetIndex, const utf8 * themeName = theme_manager_get_available_theme_name(i); if (strcmp(themeName, text) == 0) { if (widgetIndex != WIDX_THEMES_RENAME_BUTTON) { - window_error_open(STR_THEMES_ERR_NAME_ALREADY_EXISTS, STR_NONE); + context_show_error(STR_THEMES_ERR_NAME_ALREADY_EXISTS, STR_NONE); } nameTaken = true; break; @@ -682,7 +682,7 @@ static void window_themes_textinput(rct_window *w, rct_widgetindex widgetIndex, window_invalidate(w); } } else { - window_error_open(STR_ERROR_INVALID_CHARACTERS, STR_NONE); + context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); } break; } diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 27235c4ce0..df57870494 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -66,6 +66,10 @@ rct_window * window_park_objective_open(); rct_window * window_park_rating_open(); rct_window * window_banner_open(rct_windownumber number); +rct_window * window_ride_demolish_prompt_open(sint32 rideIndex); rct_window * window_sign_open(rct_windownumber number); rct_window * window_sign_small_open(rct_windownumber number); rct_window * window_player_open(uint8 id); +rct_window * window_new_campaign_open(sint16 campaignType); + +rct_window * window_error_open(rct_string_id title, rct_string_id message); diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 48d91dbb3e..acf8bf9636 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1005,6 +1005,12 @@ extern "C" return windowManager->OpenDetails(type, id); } + rct_window * context_show_error(rct_string_id title, rct_string_id message) + { + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + return windowManager->ShowError(title, message); + } + void context_input_handle_keyboard(bool isTitle) { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 5357616c91..89c6e180f2 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -205,6 +205,7 @@ extern "C" rct_window * context_open_window(rct_windowclass wc); rct_window * context_open_detail_window(uint8 type, sint32 id); rct_window * context_open_window_view(uint8 view); + rct_window * context_show_error(rct_string_id title, rct_string_id message); void context_input_handle_keyboard(bool isTitle); bool context_read_bmp(void * * outPixels, uint32 * outWidth, uint32 * outHeight, const utf8 * path); void context_quit(); diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 5face9510e..2d92e754a5 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -48,7 +48,6 @@ #include "title/TitleScreen.h" #include "util/sawyercoding.h" #include "util/util.h" -#include "windows/error.h" #include "windows/tooltip.h" #include "world/banner.h" #include "world/Climate.h" @@ -438,7 +437,7 @@ void game_logic_update() } gErrorType = ERROR_TYPE_NONE; - window_error_open(title_text, body_text); + context_show_error(title_text, body_text); } // Start autosave timer after update @@ -630,7 +629,7 @@ sint32 game_do_command_p(sint32 command, sint32 *eax, sint32 *ebx, sint32 *ecx, // Show error window if (gGameCommandNestLevel == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && gUnk141F568 == gUnk13CA740 && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) - window_error_open(gGameCommandErrorTitle, gGameCommandErrorText); + context_show_error(gGameCommandErrorTitle, gGameCommandErrorText); return MONEY32_UNDEFINED; } diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index b3e1e9e5cc..5fe3e634d3 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -29,7 +29,6 @@ #include "../localisation/localisation.h" #include "../platform/platform.h" #include "../util/util.h" -#include "../windows/error.h" #include "viewport.h" using namespace OpenRCT2; @@ -55,7 +54,7 @@ void screenshot_check() if (screenshotIndex != -1) { audio_play_sound(SOUND_WINDOW_OPEN, 100, context_get_width() / 2); } else { - window_error_open(STR_SCREENSHOT_FAILED, STR_NONE); + context_show_error(STR_SCREENSHOT_FAILED, STR_NONE); } // redraw_rain(); @@ -226,7 +225,7 @@ void screenshot_giant() sint32 index; if ((index = screenshot_get_next_path(path, MAX_PATH)) == -1) { log_error("Giant screenshot failed, unable to find a suitable destination path."); - window_error_open(STR_SCREENSHOT_FAILED, STR_NONE); + context_show_error(STR_SCREENSHOT_FAILED, STR_NONE); return; } @@ -240,7 +239,7 @@ void screenshot_giant() // Show user that screenshot saved successfully set_format_arg(0, rct_string_id, STR_STRING); set_format_arg(2, char *, path_get_filename(path)); - window_error_open(STR_SCREENSHOT_SAVED_AS, STR_NONE); + context_show_error(STR_SCREENSHOT_SAVED_AS, STR_NONE); } sint32 cmdline_for_gfxbench(const char **argv, sint32 argc) diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 31424f5111..45d4022259 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -505,6 +505,8 @@ enum { enum { WD_BANNER, + WD_NEW_CAMPAIGN, + WD_DEMOLISH_RIDE, WD_SIGN, WD_SIGN_SMALL, @@ -715,12 +717,10 @@ void window_map_open(); void window_guest_open(rct_peep* peep); rct_window *window_staff_open(rct_peep* peep); void window_staff_fire_prompt_open(rct_peep* peep); -void window_new_campaign_open(sint16 campaignType); rct_window *window_ride_main_open(sint32 rideIndex); rct_window *window_ride_open_station(sint32 rideIndex, sint32 stationIndex); rct_window *window_ride_open_track(rct_map_element *mapElement); rct_window *window_ride_open_vehicle(rct_vehicle *vehicle); -void window_ride_demolish_prompt_open(sint32 rideIndex); void window_ride_construct(rct_window *w); void window_ride_list_open(); void window_ride_list_refresh_list(rct_window *w); diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 42738be2a6..41c6ab3782 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -63,7 +63,6 @@ extern "C" { #include "../management/finance.h" #include "../network/http.h" #include "../scenario/scenario.h" -#include "../windows/error.h" #include "../util/util.h" #include "../cheats.h" @@ -490,7 +489,7 @@ void Network::UpdateClient() Close(); window_network_status_close(); - window_error_open(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_NONE); + context_show_error(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_NONE); break; } } @@ -2192,7 +2191,7 @@ void Network::Client_Handle_SHOWERROR(NetworkConnection& connection, NetworkPack { rct_string_id title, message; packet >> title >> message; - window_error_open(title, message); + context_show_error(title, message); } void Network::Client_Handle_GROUPLIST(NetworkConnection& connection, NetworkPacket& packet) diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 1111eaa580..5c35136ca9 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -34,7 +34,6 @@ extern "C" #include "../rct1.h" #include "../util/sawyercoding.h" #include "../util/util.h" - #include "../windows/error.h" #include "../world/footpath.h" #include "../world/scenery.h" #include "ride.h" diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index c767367bea..5c0b2b91e2 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -38,7 +38,6 @@ #include "../rct2/addresses.h" #include "../scenario/scenario.h" #include "../util/util.h" -#include "../windows/error.h" #include "../world/banner.h" #include "../world/Climate.h" #include "../world/footpath.h" @@ -980,20 +979,20 @@ static sint32 ride_check_if_construction_allowed(Ride *ride) { rct_ride_entry *rideType = get_ride_entry_by_ride(ride); if (rideType == NULL) { - window_error_open(STR_INVALID_RIDE_TYPE, STR_CANT_EDIT_INVALID_RIDE_TYPE); + context_show_error(STR_INVALID_RIDE_TYPE, STR_CANT_EDIT_INVALID_RIDE_TYPE); return 0; } if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) { set_format_arg(6, rct_string_id, ride->name); set_format_arg(8, uint32, ride->name_arguments); - window_error_open(STR_CANT_START_CONSTRUCTION_ON, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); + context_show_error(STR_CANT_START_CONSTRUCTION_ON, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); return 0; } if (ride->status != RIDE_STATUS_CLOSED) { set_format_arg(6, rct_string_id, ride->name); set_format_arg(8, uint32, ride->name_arguments); - window_error_open(STR_CANT_START_CONSTRUCTION_ON, STR_MUST_BE_CLOSED_FIRST); + context_show_error(STR_CANT_START_CONSTRUCTION_ON, STR_MUST_BE_CLOSED_FIRST); return 0; } @@ -1849,7 +1848,7 @@ sint32 ride_modify(rct_xy_element *input) if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) { set_format_arg(6, rct_string_id, ride->name); set_format_arg(8, uint32, ride->name_arguments); - window_error_open(STR_CANT_START_CONSTRUCTION_ON, STR_LOCAL_AUTHORITY_FORBIDS_DEMOLITION_OR_MODIFICATIONS_TO_THIS_RIDE); + context_show_error(STR_CANT_START_CONSTRUCTION_ON, STR_LOCAL_AUTHORITY_FORBIDS_DEMOLITION_OR_MODIFICATIONS_TO_THIS_RIDE); return 0; } diff --git a/src/openrct2/ride/track.c b/src/openrct2/ride/track.c index 3ee917c561..fab2ad4e70 100644 --- a/src/openrct2/ride/track.c +++ b/src/openrct2/ride/track.c @@ -30,7 +30,6 @@ #include "../world/park.h" #include "../world/scenery.h" #include "../world/footpath.h" -#include "../windows/error.h" #include "ride.h" #include "ride_data.h" #include "ride_ratings.h" diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index cd1f1fc11c..4cdbd7b0bd 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -22,13 +22,13 @@ #include "../interface/viewport.h" #include "../util/sawyercoding.h" #include "../util/util.h" -#include "../windows/error.h" #include "../world/scenery.h" #include "ride_data.h" #include "track.h" #include "track_data.h" #include "TrackDesign.h" #include "TrackDesignRepository.h" +#include "../Context.h" #define TRACK_MAX_SAVED_MAP_ELEMENTS 1500 #define TRACK_NEARBY_SCENERY_DISTANCE 1 @@ -85,7 +85,7 @@ void track_design_save_select_map_element(sint32 interactionType, sint32 x, sint } else { if (collect) { if (!track_design_save_add_map_element(interactionType, x, y, mapElement)) { - window_error_open( + context_show_error( STR_SAVE_TRACK_SCENERY_UNABLE_TO_SELECT_ADDITIONAL_ITEM_OF_SCENERY, STR_SAVE_TRACK_SCENERY_TOO_MANY_ITEMS_SELECTED ); @@ -148,23 +148,23 @@ bool track_design_save(uint8 rideIndex) Ride* ride = get_ride(rideIndex); if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_TESTED)){ - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); return false; } if (!ride_has_ratings(ride)) { - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); return false; } if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_TRACK)) { - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); return false; } _trackDesign = track_design_save_to_td6(rideIndex); if (_trackDesign == NULL) { - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); return false; } @@ -692,7 +692,7 @@ static bool track_design_save_copy_scenery_to_td6(rct_track_td6 *td6) y /= 32; if (x > 127 || y > 127 || x < -126 || y < -126){ - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY); SafeFree(td6->scenery_elements); return false; } @@ -703,7 +703,7 @@ static bool track_design_save_copy_scenery_to_td6(rct_track_td6 *td6) sint32 z = scenery->z * 8 - gTrackPreviewOrigin.z; z /= 8; if (z > 127 || z < -126) { - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY); SafeFree(td6->scenery_elements); return false; } diff --git a/src/openrct2/ui/DummyWindowManager.cpp b/src/openrct2/ui/DummyWindowManager.cpp index 317c984961..7aa429cbcf 100644 --- a/src/openrct2/ui/DummyWindowManager.cpp +++ b/src/openrct2/ui/DummyWindowManager.cpp @@ -23,6 +23,7 @@ namespace OpenRCT2 { namespace Ui rct_window * OpenWindow(rct_windowclass wc) override { return nullptr; } rct_window * OpenView(uint8 view) override { return nullptr; } rct_window * OpenDetails(uint8 type, sint32 id) override { return nullptr; } + rct_window * ShowError(rct_string_id title, rct_string_id message) override { return nullptr; } void HandleKeyboard(bool isTitle) override { } std::string GetKeyboardShortcutString(sint32 shortcut) override { return std::string(); } }; diff --git a/src/openrct2/ui/WindowManager.h b/src/openrct2/ui/WindowManager.h index 9746d34794..7a47ffd9d5 100644 --- a/src/openrct2/ui/WindowManager.h +++ b/src/openrct2/ui/WindowManager.h @@ -36,6 +36,7 @@ namespace OpenRCT2 virtual rct_window * OpenWindow(rct_windowclass wc) abstract; virtual rct_window * OpenView(uint8 view) abstract; virtual rct_window * OpenDetails(uint8 type, sint32 id) abstract; + virtual rct_window * ShowError(rct_string_id title, rct_string_id message) abstract; virtual void HandleKeyboard(bool isTitle) abstract; virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract; diff --git a/src/openrct2/windows/EditorBottomToolbar.cpp b/src/openrct2/windows/EditorBottomToolbar.cpp index 9c6f52f01b..de68ff563f 100644 --- a/src/openrct2/windows/EditorBottomToolbar.cpp +++ b/src/openrct2/windows/EditorBottomToolbar.cpp @@ -26,7 +26,6 @@ #include "../interface/themes.h" #include "../interface/widget.h" #include "../world/scenery.h" -#include "error.h" enum { WIDX_PREVIOUS_IMAGE, // 1 @@ -203,7 +202,7 @@ static bool window_editor_bottom_toolbar_check_object_selection() return true; } - window_error_open(STR_INVALID_SELECTION_OF_OBJECTS, gGameCommandErrorText); + context_show_error(STR_INVALID_SELECTION_OF_OBJECTS, gGameCommandErrorText); w = window_find_by_class(WC_EDITOR_OBJECT_SELECTION); if (w != nullptr) { // Click tab with missing object @@ -249,7 +248,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() } else { - window_error_open(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, gGameCommandErrorText); + context_show_error(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, gGameCommandErrorText); } gfx_invalidate_screen(); @@ -285,7 +284,7 @@ void window_editor_bottom_toolbar_jump_forward_to_objective_selection() { void window_editor_bottom_toolbar_jump_forward_to_save_scenario() { if (!scenario_prepare_for_save()) { - window_error_open(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText); + context_show_error(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText); gfx_invalidate_screen(); return; } diff --git a/src/openrct2/windows/EditorObjectSelection.cpp b/src/openrct2/windows/EditorObjectSelection.cpp index 921e22fe5e..4cc53e3ca0 100644 --- a/src/openrct2/windows/EditorObjectSelection.cpp +++ b/src/openrct2/windows/EditorObjectSelection.cpp @@ -33,7 +33,6 @@ #include "../ride/ride_data.h" #include "../util/util.h" #include "dropdown.h" -#include "error.h" #include "../sprites.h" #include "_legacy.h" @@ -990,7 +989,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, sint3 STR_UNABLE_TO_SELECT_THIS_OBJECT : STR_UNABLE_TO_DE_SELECT_THIS_OBJECT; - window_error_open(error_title, gGameCommandErrorText); + context_show_error(error_title, gGameCommandErrorText); return; } @@ -1001,7 +1000,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, sint3 } if (_maxObjectsWasHit) { - window_error_open(STR_WARNING_TOO_MANY_OBJECTS_SELECTED, STR_NOT_ALL_OBJECTS_IN_THIS_SCENERY_GROUP_COULD_BE_SELECTED); + context_show_error(STR_WARNING_TOO_MANY_OBJECTS_SELECTED, STR_NOT_ALL_OBJECTS_IN_THIS_SCENERY_GROUP_COULD_BE_SELECTED); } } diff --git a/src/openrct2/windows/InstallTrack.cpp b/src/openrct2/windows/InstallTrack.cpp index 42e59cf64c..d33bf82da5 100644 --- a/src/openrct2/windows/InstallTrack.cpp +++ b/src/openrct2/windows/InstallTrack.cpp @@ -26,7 +26,6 @@ #include "../platform/platform.h" #include "../sprites.h" #include "../util/util.h" -#include "error.h" enum { WIDX_BACKGROUND, @@ -110,7 +109,7 @@ void window_install_track_open(const utf8 *path) { _trackDesign = track_design_open(path); if (_trackDesign == nullptr) { - window_error_open(STR_UNABLE_TO_LOAD_FILE, STR_NONE); + context_show_error(STR_UNABLE_TO_LOAD_FILE, STR_NONE); return; } @@ -406,7 +405,7 @@ static void window_install_track_design(rct_window *w) platform_get_user_directory(destPath, "track", sizeof(destPath)); if (!platform_ensure_directory_exists(destPath)) { log_error("Unable to create directory '%s'", destPath); - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, STR_NONE); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, STR_NONE); return; } @@ -415,7 +414,7 @@ static void window_install_track_design(rct_window *w) if (platform_file_exists(destPath)) { log_info("%s already exists, prompting user for a different track design name", destPath); - window_error_open(STR_UNABLE_TO_INSTALL_THIS_TRACK_DESIGN, STR_NONE); + context_show_error(STR_UNABLE_TO_INSTALL_THIS_TRACK_DESIGN, STR_NONE); window_text_input_raw_open( w, WIDX_INSTALL, @@ -428,7 +427,7 @@ static void window_install_track_design(rct_window *w) if (track_repository_install(_trackPath)) { window_close(w); } else { - window_error_open(STR_CANT_SAVE_TRACK_DESIGN, STR_NONE); + context_show_error(STR_CANT_SAVE_TRACK_DESIGN, STR_NONE); } } } diff --git a/src/openrct2/windows/LoadSave.cpp b/src/openrct2/windows/LoadSave.cpp index e0539a2138..fa64027e34 100644 --- a/src/openrct2/windows/LoadSave.cpp +++ b/src/openrct2/windows/LoadSave.cpp @@ -17,6 +17,7 @@ #include "../config/Config.h" #include "../title/TitleScreen.h" #include "../core/Memory.hpp" +#include "../Context.h" #include #include "../core/Guard.hpp" @@ -26,7 +27,6 @@ #include "../localisation/localisation.h" #include "../platform/platform.h" #include "../util/util.h" -#include "../windows/error.h" #pragma region Widgets @@ -434,7 +434,7 @@ static void window_loadsave_textinput(rct_window *w, rct_widgetindex widgetIndex switch (widgetIndex) { case WIDX_NEW_FOLDER: if (!filename_valid_characters(text)) { - window_error_open(STR_ERROR_INVALID_CHARACTERS, STR_NONE); + context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); return; } @@ -442,7 +442,7 @@ static void window_loadsave_textinput(rct_window *w, rct_widgetindex widgetIndex safe_strcat_path(path, text, sizeof(path)); if (!platform_ensure_directory_exists(path)) { - window_error_open(STR_UNABLE_TO_CREATE_FOLDER, STR_NONE); + context_show_error(STR_UNABLE_TO_CREATE_FOLDER, STR_NONE); return; } w->no_list_items = 0; @@ -751,7 +751,7 @@ static bool is_valid_path(const char * path) static void window_loadsave_select(rct_window *w, const char *path) { if (!is_valid_path(path)) { - window_error_open(STR_ERROR_INVALID_CHARACTERS, STR_NONE); + context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); return; } @@ -779,7 +779,7 @@ static void window_loadsave_select(rct_window *w, const char *path) window_loadsave_invoke_callback(MODAL_RESULT_OK, pathBuffer); } else { - window_error_open(STR_SAVE_GAME, STR_GAME_SAVE_FAILED); + context_show_error(STR_SAVE_GAME, STR_GAME_SAVE_FAILED); window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } break; @@ -791,7 +791,7 @@ static void window_loadsave_select(rct_window *w, const char *path) window_loadsave_invoke_callback(MODAL_RESULT_OK, pathBuffer); } else { // Not the best message... - window_error_open(STR_LOAD_LANDSCAPE, STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA); + context_show_error(STR_LOAD_LANDSCAPE, STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA); window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } break; @@ -804,7 +804,7 @@ static void window_loadsave_select(rct_window *w, const char *path) gfx_invalidate_screen(); window_loadsave_invoke_callback(MODAL_RESULT_OK, pathBuffer); } else { - window_error_open(STR_SAVE_LANDSCAPE, STR_LANDSCAPE_SAVE_FAILED); + context_show_error(STR_SAVE_LANDSCAPE, STR_LANDSCAPE_SAVE_FAILED); window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } break; @@ -823,7 +823,7 @@ static void window_loadsave_select(rct_window *w, const char *path) window_loadsave_invoke_callback(MODAL_RESULT_OK, pathBuffer); title_load(); } else { - window_error_open(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED); + context_show_error(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED); gS6Info.editor_step = EDITOR_STEP_OBJECTIVE_SELECTION; window_loadsave_invoke_callback(MODAL_RESULT_FAIL, pathBuffer); } @@ -845,7 +845,7 @@ static void window_loadsave_select(rct_window *w, const char *path) window_ride_measurements_design_cancel(); window_loadsave_invoke_callback(MODAL_RESULT_OK, path); } else { - window_error_open(STR_FILE_DIALOG_TITLE_SAVE_TRACK, STR_TRACK_SAVE_FAILED); + context_show_error(STR_FILE_DIALOG_TITLE_SAVE_TRACK, STR_TRACK_SAVE_FAILED); window_loadsave_invoke_callback(MODAL_RESULT_FAIL, path); } break; diff --git a/src/openrct2/windows/Map.cpp b/src/openrct2/windows/Map.cpp index 6e2c399d5a..518e7f521f 100644 --- a/src/openrct2/windows/Map.cpp +++ b/src/openrct2/windows/Map.cpp @@ -31,7 +31,6 @@ #include "../world/entrance.h" #include "../world/footpath.h" #include "../world/scenery.h" -#include "error.h" #define MAP_COLOUR_2(colourA, colourB) ((colourA << 8) | colourB) #define MAP_COLOUR(colour) MAP_COLOUR_2(colour, colour) @@ -1396,7 +1395,7 @@ static void window_map_set_peep_spawn_tool_down(sint32 x, sint32 y) static void map_window_increase_map_size() { if (gMapSize >= MAXIMUM_MAP_SIZE_TECHNICAL) { - window_error_open(STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); + context_show_error(STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); return; } @@ -1417,7 +1416,7 @@ static void map_window_increase_map_size() static void map_window_decrease_map_size() { if (gMapSize < 16) { - window_error_open(STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); + context_show_error(STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); return; } diff --git a/src/openrct2/windows/Ride.cpp b/src/openrct2/windows/Ride.cpp index f7bd796f8e..2b37e389f6 100644 --- a/src/openrct2/windows/Ride.cpp +++ b/src/openrct2/windows/Ride.cpp @@ -22,6 +22,7 @@ #include "../ride/RideGroupManager.h" #include "../core/Math.hpp" #include "../core/Util.hpp" +#include "../Context.h" #include "../audio/audio.h" #include "../cheats.h" @@ -38,7 +39,6 @@ #include "../ride/track.h" #include "../ride/track_data.h" #include "../sprites.h" -#include "../windows/error.h" #include "dropdown.h" enum { @@ -1960,7 +1960,7 @@ static void window_ride_main_mouseup(rct_window *w, rct_widgetindex widgetIndex) window_scroll_to_viewport(w); break; case WIDX_DEMOLISH: - window_ride_demolish_prompt_open(w->number); + context_open_detail_window(WD_DEMOLISH_RIDE, w->number); break; case WIDX_CLOSE_LIGHT: case WIDX_TEST_LIGHT: @@ -3652,7 +3652,7 @@ static void window_ride_locate_mechanic(rct_window *w) mechanic = ride_find_closest_mechanic(ride, 1); if (mechanic == nullptr) - window_error_open(STR_UNABLE_TO_LOCATE_MECHANIC, STR_NONE); + context_show_error(STR_UNABLE_TO_LOCATE_MECHANIC, STR_NONE); else window_staff_open(mechanic); } @@ -3770,7 +3770,7 @@ static void window_ride_maintenance_mousedown(rct_window *w, rct_widgetindex wid } } if (num_items == 1) { - window_error_open(STR_DEBUG_NO_BREAKDOWNS_AVAILABLE, STR_NONE); + context_show_error(STR_DEBUG_NO_BREAKDOWNS_AVAILABLE, STR_NONE); } else { window_dropdown_show_text( @@ -3866,10 +3866,10 @@ static void window_ride_maintenance_dropdown(rct_window *w, rct_widgetindex widg break; } if (ride->lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) { - window_error_open(STR_DEBUG_CANT_FORCE_BREAKDOWN, STR_DEBUG_RIDE_ALREADY_BROKEN); + context_show_error(STR_DEBUG_CANT_FORCE_BREAKDOWN, STR_DEBUG_RIDE_ALREADY_BROKEN); } else if (ride->status == RIDE_STATUS_CLOSED) { - window_error_open(STR_DEBUG_CANT_FORCE_BREAKDOWN, STR_DEBUG_RIDE_IS_CLOSED); + context_show_error(STR_DEBUG_CANT_FORCE_BREAKDOWN, STR_DEBUG_RIDE_IS_CLOSED); } else { sint32 j; diff --git a/src/openrct2/windows/Scenery.cpp b/src/openrct2/windows/Scenery.cpp index e8cfd238d5..738e06793c 100644 --- a/src/openrct2/windows/Scenery.cpp +++ b/src/openrct2/windows/Scenery.cpp @@ -581,7 +581,7 @@ static void window_scenery_mouseup(rct_window *w, rct_widgetindex widgetIndex) gWindowSceneryClusterEnabled ^= 1; } else { - window_error_open(STR_CANT_DO_THIS, STR_PERMISSION_DENIED); + context_show_error(STR_CANT_DO_THIS, STR_PERMISSION_DENIED); } window_invalidate(w); break; diff --git a/src/openrct2/windows/TitleEditor.cpp b/src/openrct2/windows/TitleEditor.cpp index d46389a9a9..ee99ab60cd 100644 --- a/src/openrct2/windows/TitleEditor.cpp +++ b/src/openrct2/windows/TitleEditor.cpp @@ -23,6 +23,7 @@ #include "../title/TitleSequence.h" #include "../title/TitleSequenceManager.h" #include "../title/TitleSequencePlayer.h" +#include "../Context.h" #include "../game.h" #include "../input.h" @@ -31,7 +32,6 @@ #include "../sprites.h" #include "../util/util.h" #include "dropdown.h" -#include "error.h" enum WINDOW_TITLE_EDITOR_TAB { WINDOW_TITLE_EDITOR_TAB_PRESETS, @@ -498,7 +498,7 @@ static void window_title_editor_mousedown(rct_window *w, rct_widgetindex widgetI } case WIDX_TITLE_EDITOR_PRESETS_DROPDOWN: if (window_find_by_class(WC_TITLE_COMMAND_EDITOR) != nullptr) { - window_error_open(STR_TITLE_EDITOR_ERR_CANT_CHANGE_WHILE_EDITOR_IS_OPEN, STR_NONE); + context_show_error(STR_TITLE_EDITOR_ERR_CANT_CHANGE_WHILE_EDITOR_IS_OPEN, STR_NONE); } else { sint32 numItems = (sint32)title_sequence_manager_get_count(); for (sint32 i = 0; i < numItems; i++) { @@ -631,10 +631,10 @@ static void window_title_editor_textinput(rct_window *w, rct_widgetindex widgetI config_save_default(); window_invalidate(w); } else { - window_error_open(STR_ERROR_EXISTING_NAME, STR_NONE); + context_show_error(STR_ERROR_EXISTING_NAME, STR_NONE); } } else { - window_error_open(STR_ERROR_INVALID_CHARACTERS, STR_NONE); + context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); } break; case WIDX_TITLE_EDITOR_RENAME_SAVE: @@ -950,7 +950,7 @@ static void window_title_editor_load_sequence(size_t index) const char * path = title_sequence_manager_get_path(index); TitleSequence * titleSequence = LoadTitleSequence(path); if (titleSequence == nullptr) { - window_error_open(STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA, STR_NONE); + context_show_error(STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA, STR_NONE); return; } @@ -973,11 +973,11 @@ static bool window_title_editor_check_can_edit() { bool commandEditorOpen = (window_find_by_class(WC_TITLE_COMMAND_EDITOR) != nullptr); if (_isSequenceReadOnly) { - window_error_open(STR_ERROR_CANT_CHANGE_TITLE_SEQUENCE, STR_NONE); + context_show_error(STR_ERROR_CANT_CHANGE_TITLE_SEQUENCE, STR_NONE); } else if (_isSequencePlaying) { - window_error_open(STR_TITLE_EDITOR_ERR_CANT_EDIT_WHILE_PLAYING, STR_TITLE_EDITOR_PRESS_STOP_TO_CONTINUE_EDITING); + context_show_error(STR_TITLE_EDITOR_ERR_CANT_EDIT_WHILE_PLAYING, STR_TITLE_EDITOR_PRESS_STOP_TO_CONTINUE_EDITING); } else if (commandEditorOpen) { - window_error_open(STR_TITLE_EDITOR_ERR_CANT_CHANGE_WHILE_EDITOR_IS_OPEN, STR_NONE); + context_show_error(STR_TITLE_EDITOR_ERR_CANT_CHANGE_WHILE_EDITOR_IS_OPEN, STR_NONE); } else { return true; } @@ -1019,7 +1019,7 @@ static void window_title_editor_add_park_callback(sint32 result, const utf8 * pa static void window_title_editor_rename_park(size_t index, const utf8 * name) { if (!filename_valid_characters(name)) { - window_error_open(STR_ERROR_INVALID_CHARACTERS, STR_NONE); + context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); return; } @@ -1027,7 +1027,7 @@ static void window_title_editor_rename_park(size_t index, const utf8 * name) if (i != index) { const utf8 * savePath = _editingTitleSequence->Saves[i]; if (_strcmpi(savePath, name) == 0) { - window_error_open(STR_ERROR_EXISTING_NAME, STR_NONE); + context_show_error(STR_ERROR_EXISTING_NAME, STR_NONE); return; } } diff --git a/src/openrct2/windows/TrackList.cpp b/src/openrct2/windows/TrackList.cpp index 6b2fa6dba0..c28de8749f 100644 --- a/src/openrct2/windows/TrackList.cpp +++ b/src/openrct2/windows/TrackList.cpp @@ -27,7 +27,6 @@ #include "../localisation/localisation.h" #include "../rct1.h" #include "../sprites.h" -#include "error.h" enum { WIDX_BACKGROUND, @@ -196,7 +195,7 @@ static void window_track_list_select(rct_window *w, sint32 index) { // Displays a message if the ride can't load, fix #4080 if (_loadedTrackDesign == nullptr) { - window_error_open(STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TRACK_LOAD_FAILED_ERROR); + context_show_error(STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TRACK_LOAD_FAILED_ERROR); return; } @@ -220,7 +219,7 @@ static void window_track_list_select(rct_window *w, sint32 index) window_track_manage_open(tdRef); } else { if (_loadedTrackDesignIndex != TRACK_DESIGN_INDEX_UNLOADED && (_loadedTrackDesign->track_flags & TRACK_DESIGN_FLAG_VEHICLE_UNAVAILABLE)) { - window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE); + context_show_error(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE); } window_track_place_open(tdRef); diff --git a/src/openrct2/windows/TrackManage.cpp b/src/openrct2/windows/TrackManage.cpp index ad5f4debd3..69f16b0233 100644 --- a/src/openrct2/windows/TrackManage.cpp +++ b/src/openrct2/windows/TrackManage.cpp @@ -21,7 +21,6 @@ #include "../interface/widget.h" #include "../localisation/localisation.h" #include "../util/util.h" -#include "error.h" #pragma region Widgets @@ -216,12 +215,12 @@ static void window_track_manage_textinput(rct_window *w, rct_widgetindex widgetI } if (str_is_null_or_empty(text)) { - window_error_open(STR_CANT_RENAME_TRACK_DESIGN, STR_NONE); + context_show_error(STR_CANT_RENAME_TRACK_DESIGN, STR_NONE); return; } if (!filename_valid_characters(text)) { - window_error_open(STR_CANT_RENAME_TRACK_DESIGN, STR_NEW_NAME_CONTAINS_INVALID_CHARACTERS); + context_show_error(STR_CANT_RENAME_TRACK_DESIGN, STR_NEW_NAME_CONTAINS_INVALID_CHARACTERS); return; } @@ -230,7 +229,7 @@ static void window_track_manage_textinput(rct_window *w, rct_widgetindex widgetI window_close(w); window_track_design_list_reload_tracks(); } else { - window_error_open(STR_CANT_RENAME_TRACK_DESIGN, STR_ANOTHER_FILE_EXISTS_WITH_NAME_OR_FILE_IS_WRITE_PROTECTED); + context_show_error(STR_CANT_RENAME_TRACK_DESIGN, STR_ANOTHER_FILE_EXISTS_WITH_NAME_OR_FILE_IS_WRITE_PROTECTED); } } @@ -289,7 +288,7 @@ static void window_track_delete_prompt_mouseup(rct_window *w, rct_widgetindex wi window_close_by_class(WC_MANAGE_TRACK_DESIGN); window_track_design_list_reload_tracks(); } else { - window_error_open(STR_CANT_DELETE_TRACK_DESIGN, STR_FILE_IS_WRITE_PROTECTED_OR_LOCKED); + context_show_error(STR_CANT_DELETE_TRACK_DESIGN, STR_FILE_IS_WRITE_PROTECTED_OR_LOCKED); } break; } diff --git a/src/openrct2/windows/_legacy.c b/src/openrct2/windows/_legacy.c index 4d41f1b533..efd053a06d 100644 --- a/src/openrct2/windows/_legacy.c +++ b/src/openrct2/windows/_legacy.c @@ -18,6 +18,8 @@ #pragma warning(disable : 4295) // 'identifier': array is too small to include a terminating null character +bool gDisableErrorWindowSound = false; + /** rct2: 0x0098DA74 */ const rct_object_entry RequiredSelectedObjects[7] = { // Objects that are always required diff --git a/src/openrct2/world/mapgen.c b/src/openrct2/world/mapgen.c index 2846b99837..6683067f2c 100644 --- a/src/openrct2/world/mapgen.c +++ b/src/openrct2/world/mapgen.c @@ -25,7 +25,6 @@ #include "../object.h" #include "../platform/platform.h" #include "../util/util.h" -#include "../windows/error.h" #include "map.h" #include "map_helpers.h" #include "mapgen.h" @@ -798,7 +797,7 @@ bool mapgen_load_heightmap(const utf8 *path) if (strcicmp(extension, ".png") == 0) { if (!image_io_png_read(&pixels, &width, &height, path)) { log_warning("Error reading PNG"); - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_PNG); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_PNG); return false; } @@ -807,7 +806,7 @@ bool mapgen_load_heightmap(const utf8 *path) } else if (strcicmp(extension, ".bmp") == 0) { if (!context_read_bmp((void *)&pixels, &width, &height, path)) { - // ReadBMP contains window_error_open calls + // ReadBMP contains context_show_error calls return false; } @@ -821,13 +820,13 @@ bool mapgen_load_heightmap(const utf8 *path) } if (width != height) { - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_WIDTH_AND_HEIGHT_DO_NOT_MATCH); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_WIDTH_AND_HEIGHT_DO_NOT_MATCH); free(pixels); return false; } if (width > MAXIMUM_MAP_SIZE_PRACTICAL) { - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_HEIHGT_MAP_TOO_BIG); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_HEIHGT_MAP_TOO_BIG); width = height = min(height, MAXIMUM_MAP_SIZE_PRACTICAL); } @@ -949,7 +948,7 @@ void mapgen_generate_from_heightmap(mapgen_settings *settings) if (minValue == maxValue) { - window_error_open(STR_HEIGHT_MAP_ERROR, STR_ERROR_CANNOT_NORMALIZE); + context_show_error(STR_HEIGHT_MAP_ERROR, STR_ERROR_CANNOT_NORMALIZE); free(dest); return; }