From d02976695df7f69a474ab10340557f3a3aecb5e9 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 Oct 2017 01:28:00 +0200 Subject: [PATCH] Move new ride and research windows --- src/openrct2-ui/WindowManager.cpp | 45 +++++++++++++++++-- src/openrct2-ui/input/keyboard_shortcut.c | 7 +-- .../windows/NewRide.cpp | 37 +++++++-------- .../windows/Research.cpp | 20 +++++---- src/openrct2-ui/windows/Window.h | 9 ++++ src/openrct2/Editor.cpp | 5 ++- src/openrct2/game.c | 7 ++- src/openrct2/interface/console.c | 5 ++- src/openrct2/interface/window.h | 12 +---- src/openrct2/management/news_item.c | 13 +++--- src/openrct2/title/TitleSequencePlayer.cpp | 3 +- src/openrct2/windows/EditorBottomToolbar.cpp | 2 +- .../windows/EditorObjectSelection.cpp | 4 +- src/openrct2/windows/Intent.h | 4 ++ src/openrct2/windows/TopToolbar.cpp | 4 +- src/openrct2/windows/TrackList.cpp | 2 +- 16 files changed, 116 insertions(+), 63 deletions(-) rename src/{openrct2 => openrct2-ui}/windows/NewRide.cpp (98%) rename src/{openrct2 => openrct2-ui}/windows/Research.cpp (98%) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index eb4fab72ae..9e50c6bc95 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "input/input.h" #include "input/KeyboardShortcuts.h" #include "WindowManager.h" @@ -29,11 +30,13 @@ public: void Init() override { window_guest_list_init_vars(); + window_new_ride_init_vars(); } rct_window * OpenWindow(rct_windowclass wc) override { - switch (wc) { + switch (wc) + { case WC_ABOUT: return window_about_open(); case WC_CHANGELOG: @@ -72,10 +75,14 @@ public: return window_multiplayer_open(); case WC_MUSIC_CREDITS: return window_music_credits_open(); + case WC_CONSTRUCT_RIDE: + return window_new_ride_open(); case WC_PARK_INFORMATION: return window_park_entrance_open(); case WC_RECENT_NEWS: return window_news_open(); + case WC_RESEARCH: + return window_research_open(); case WC_NOTIFICATION_OPTIONS: return window_news_options_open(); case WC_OPTIONS: @@ -114,7 +121,8 @@ public: rct_window * OpenView(uint8 view) override { - switch (view) { + switch (view) + { case WV_PARK_AWARDS: return window_park_awards_open(); case WV_PARK_RATING: @@ -125,6 +133,15 @@ public: return window_park_guests_open(); case WV_FINANCES_RESEARCH: return window_finances_research_open(); + case WV_RIDE_RESEARCH: + if (gConfigInterface.toolbar_show_research) + { + return this->OpenWindow(WC_RESEARCH); + } + else + { + return window_new_ride_open_research(); + } default: return nullptr; } @@ -160,7 +177,8 @@ public: rct_window * OpenIntent(Intent * intent) override { - switch(intent->GetWindowClass()) { + switch (intent->GetWindowClass()) + { case WC_PEEP: return window_guest_open((rct_peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); case WC_FIRE_PROMPT: @@ -185,6 +203,20 @@ public: return window_track_place_open((track_design_file_ref *) intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)); case WC_SCENARIO_SELECT: return window_scenarioselect_open((scenarioselect_callback) intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)); + case INTENT_ACTION_NEW_RIDE_OF_TYPE: + { + // Open ride list window + auto w = window_new_ride_open(); + + // Switch to right tab and scroll to ride location + ride_list_item rideItem; + rideItem.type = intent->GetUIntExtra(INTENT_EXTRA_RIDE_TYPE); + rideItem.entry_index = intent->GetUIntExtra(INTENT_EXTRA_RIDE_ENTRY_INDEX); + window_new_ride_focus(rideItem); + + return w; + } + break; default: Console::Error::WriteLine("Unhandled window class for intent (%d)", intent->GetWindowClass()); return nullptr; @@ -193,10 +225,15 @@ public: void BroadcastIntent(Intent * intent) override { - switch (intent->GetWindowClass()) { + switch (intent->GetWindowClass()) + { case INTENT_ACTION_MAP: window_map_reset(); break; + + case INTENT_ACTION_REFRESH_NEW_RIDES: + window_new_ride_init_vars(); + break; } } diff --git a/src/openrct2-ui/input/keyboard_shortcut.c b/src/openrct2-ui/input/keyboard_shortcut.c index 0c9b3ab05d..240619ea45 100644 --- a/src/openrct2-ui/input/keyboard_shortcut.c +++ b/src/openrct2-ui/input/keyboard_shortcut.c @@ -373,7 +373,7 @@ static void shortcut_build_new_ride() if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window_new_ride_open(); + context_open_window(WC_CONSTRUCT_RIDE); } } } @@ -394,10 +394,7 @@ static void shortcut_show_research_information() return; if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - if (gConfigInterface.toolbar_show_research) - window_research_open(); - else - window_new_ride_open_research(); + context_open_window_view(WV_RIDE_RESEARCH); } } diff --git a/src/openrct2/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp similarity index 98% rename from src/openrct2/windows/NewRide.cpp rename to src/openrct2-ui/windows/NewRide.cpp index bde59c5123..1b736c9138 100644 --- a/src/openrct2/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -14,25 +14,26 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "../network/network.h" -#include "../OpenRCT2.h" -#include "../ride/RideGroupManager.h" -#include "../ride/TrackDesignRepository.h" -#include "../core/Util.hpp" -#include "../core/Math.hpp" -#include "../Context.h" +#include -#include "../audio/audio.h" -#include "../game.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" -#include "../management/news_item.h" -#include "../rct1.h" -#include "../ride/ride_data.h" -#include "../ride/track_data.h" -#include "../sprites.h" -#include "../util/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static uint8 _windowNewRideCurrentTab; static ride_list_item _windowNewRideHighlightedItem[6]; diff --git a/src/openrct2/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp similarity index 98% rename from src/openrct2/windows/Research.cpp rename to src/openrct2-ui/windows/Research.cpp index 2fb245b625..d9261a3176 100644 --- a/src/openrct2/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -14,13 +14,15 @@ *****************************************************************************/ #pragma endregion -#include "../game.h" -#include "../localisation/localisation.h" -#include "../interface/widget.h" -#include "../management/news_item.h" -#include "../sprites.h" -#include "../world/scenery.h" -#include "dropdown.h" +#include + +#include +#include +#include +#include +#include +#include +#include enum { WINDOW_RESEARCH_PAGE_DEVELOPMENT, @@ -228,7 +230,7 @@ static void window_research_set_page(rct_window *w, sint32 page); static void window_research_set_pressed_tab(rct_window *w); static void window_research_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); -void window_research_open() +rct_window * window_research_open() { rct_window *w; @@ -257,6 +259,8 @@ void window_research_open() w->pressed_widgets = 0; w->disabled_widgets = 0; window_init_scroll_widgets(w); + + return w; } #pragma region Development page diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 23e4451241..55e8fd78f3 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -95,3 +95,12 @@ rct_window * window_track_manage_open(struct track_design_file_ref *tdFileRef); rct_window * window_map_open(); void window_map_reset(); + +rct_window * window_research_open(); +void window_research_development_page_paint(rct_window * w, rct_drawpixelinfo * dpi, rct_widgetindex baseWidgetIndex); +void window_research_funding_page_paint(rct_window * w, rct_drawpixelinfo * dpi, rct_widgetindex baseWidgetIndex); + +rct_window * window_new_ride_open(); +rct_window * window_new_ride_open_research(); +void window_new_ride_init_vars(); +void window_new_ride_focus(ride_list_item rideItem); diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index b3c059d2ec..3a4e3f3de5 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -469,7 +469,10 @@ namespace Editor window_invalidate(w); reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); - window_new_ride_init_vars(); + + auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES); + context_broadcast_intent(&intent); + gWindowUpdateTicks = 0; load_palette(); window_tile_inspector_clear_clipboard(); diff --git a/src/openrct2/game.c b/src/openrct2/game.c index da208aeb01..c458832e2b 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1191,7 +1191,11 @@ void game_load_init() } reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); - window_new_ride_init_vars(); + + Intent * intent = intent_create(INTENT_ACTION_REFRESH_NEW_RIDES); + context_broadcast_intent(intent); + intent_release(intent); + gWindowUpdateTicks = 0; load_palette(); @@ -1477,7 +1481,6 @@ void game_init_all(sint32 mapSize) gNextGuestNumber = 1; context_init(); - window_new_ride_init_vars(); scenery_set_default_placement_configuration(); window_tile_inspector_clear_clipboard(); load_palette(); diff --git a/src/openrct2/interface/console.c b/src/openrct2/interface/console.c index e3d176ce28..c8337ef0be 100644 --- a/src/openrct2/interface/console.c +++ b/src/openrct2/interface/console.c @@ -1148,7 +1148,10 @@ static sint32 cc_load_object(const utf8 **argv, sint32 argc) { gSilentResearch = false; } scenery_set_default_placement_configuration(); - window_new_ride_init_vars(); + + Intent * intent = intent_create(INTENT_ACTION_REFRESH_NEW_RIDES); + context_broadcast_intent(intent); + intent_release(intent); gWindowUpdateTicks = 0; gfx_invalidate_screen(); diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 0bd8c3b5c9..a96466325e 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -499,7 +499,8 @@ enum { WV_PARK_RATING, WV_PARK_OBJECTIVE, WV_PARK_GUESTS, - WV_FINANCES_RESEARCH + WV_FINANCES_RESEARCH, + WV_RIDE_RESEARCH, }; @@ -725,16 +726,10 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY); void window_maze_construction_update_pressed_widgets(); -rct_window *window_new_ride_open(); -rct_window *window_new_ride_open_research(); void window_network_status_open(const char* text, close_callback onClose); void window_network_status_close(); void window_network_status_open_password(); -void window_research_open(); -void window_research_development_page_paint(rct_window *w, rct_drawpixelinfo *dpi, rct_widgetindex baseWidgetIndex); -void window_research_funding_page_paint(rct_window *w, rct_drawpixelinfo *dpi, rct_widgetindex baseWidgetIndex); - void window_scenery_open(); void window_tile_inspector_open(); void window_tile_inspector_clear_clipboard(); @@ -751,9 +746,6 @@ void window_bubble_list_item(rct_window* w, sint32 item_position); void window_align_tabs( rct_window *w, rct_widgetindex start_tab_id, rct_widgetindex end_tab_id ); -void window_new_ride_init_vars(); -void window_new_ride_focus(ride_list_item rideItem); - void window_map_tooltip_update_visibility(); void window_staff_list_init_vars(); diff --git a/src/openrct2/management/news_item.c b/src/openrct2/management/news_item.c index 38e8d7798b..f419e00add 100644 --- a/src/openrct2/management/news_item.c +++ b/src/openrct2/management/news_item.c @@ -345,14 +345,11 @@ void news_item_open_subject(sint32 type, sint32 subject) break; case NEWS_ITEM_RESEARCH: if (subject >= RESEARCH_ENTRY_RIDE_MASK) { - // Open ride list window - window_new_ride_open(); - - // Switch to right tab and scroll to ride location - ride_list_item rideItem; - rideItem.type = subject >> 8; - rideItem.entry_index = subject & 0xFF; - window_new_ride_focus(rideItem); + Intent * intent = intent_create(INTENT_ACTION_NEW_RIDE_OF_TYPE); + intent_set_sint(intent, INTENT_EXTRA_RIDE_TYPE, subject >> 8); + intent_set_sint(intent, INTENT_EXTRA_RIDE_ENTRY_INDEX, subject & 0xFF); + context_open_intent(intent); + intent_release(intent); break; } diff --git a/src/openrct2/title/TitleSequencePlayer.cpp b/src/openrct2/title/TitleSequencePlayer.cpp index c7f74e93f4..0268240736 100644 --- a/src/openrct2/title/TitleSequencePlayer.cpp +++ b/src/openrct2/title/TitleSequencePlayer.cpp @@ -430,7 +430,8 @@ private: window_invalidate(w); reset_sprite_spatial_index(); reset_all_sprite_quadrant_placements(); - window_new_ride_init_vars(); + auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES); + context_broadcast_intent(&intent); scenery_set_default_placement_configuration(); news_item_init_queue(); load_palette(); diff --git a/src/openrct2/windows/EditorBottomToolbar.cpp b/src/openrct2/windows/EditorBottomToolbar.cpp index cba2977683..02cc996837 100644 --- a/src/openrct2/windows/EditorBottomToolbar.cpp +++ b/src/openrct2/windows/EditorBottomToolbar.cpp @@ -222,7 +222,7 @@ void window_editor_bottom_toolbar_jump_forward_from_object_selection() if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) { reset_researched_ride_types_and_entries(); - window_new_ride_open(); + context_open_window(WC_CONSTRUCT_RIDE); gS6Info.editor_step = EDITOR_STEP_ROLLERCOASTER_DESIGNER; gfx_invalidate_screen(); } else { diff --git a/src/openrct2/windows/EditorObjectSelection.cpp b/src/openrct2/windows/EditorObjectSelection.cpp index 0ad73565fd..4491a4cf18 100644 --- a/src/openrct2/windows/EditorObjectSelection.cpp +++ b/src/openrct2/windows/EditorObjectSelection.cpp @@ -729,7 +729,9 @@ static void window_editor_object_selection_close(rct_window *w) gSilentResearch = false; } research_remove_non_separate_vehicle_types(); - window_new_ride_init_vars(); + + auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES); + context_broadcast_intent(&intent); visible_list_dispose(); } diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index df4a1b7daa..28293ccbe8 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -58,10 +58,14 @@ extern "C" { INTENT_EXTRA_LOADSAVE_TYPE, INTENT_EXTRA_CALLBACK, INTENT_EXTRA_TRACK_DESIGN, + INTENT_EXTRA_RIDE_TYPE, + INTENT_EXTRA_RIDE_ENTRY_INDEX, }; enum { INTENT_ACTION_MAP, + INTENT_ACTION_NEW_RIDE_OF_TYPE, + INTENT_ACTION_REFRESH_NEW_RIDES, }; Intent *intent_create(rct_windowclass clss); diff --git a/src/openrct2/windows/TopToolbar.cpp b/src/openrct2/windows/TopToolbar.cpp index 6e3ce91fe4..d895d3d682 100644 --- a/src/openrct2/windows/TopToolbar.cpp +++ b/src/openrct2/windows/TopToolbar.cpp @@ -343,7 +343,7 @@ static void window_top_toolbar_mouseup(rct_window *w, rct_widgetindex widgetInde toggle_footpath_window(); break; case WIDX_CONSTRUCT_RIDE: - window_new_ride_open(); + context_open_window(WC_CONSTRUCT_RIDE); break; case WIDX_RIDES: window_ride_list_open(); @@ -361,7 +361,7 @@ static void window_top_toolbar_mouseup(rct_window *w, rct_widgetindex widgetInde context_open_window(WC_FINANCES); break; case WIDX_RESEARCH: - window_research_open(); + context_open_window(WC_RESEARCH); break; case WIDX_NEWS: context_open_window(WC_RECENT_NEWS); diff --git a/src/openrct2/windows/TrackList.cpp b/src/openrct2/windows/TrackList.cpp index cdf0062eb5..9076078b8a 100644 --- a/src/openrct2/windows/TrackList.cpp +++ b/src/openrct2/windows/TrackList.cpp @@ -268,7 +268,7 @@ static void window_track_list_mouseup(rct_window *w, rct_widgetindex widgetIndex case WIDX_BACK: window_close(w); if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { - window_new_ride_open(); + context_open_window(WC_CONSTRUCT_RIDE); } break; }