From eef3bd9af5abd0ca7f199f72da8dfb5cdc08ba7a Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 6 Oct 2017 23:21:00 +0200 Subject: [PATCH] Move staff and guest windows --- src/openrct2-ui/WindowManager.cpp | 2 + .../windows/Guest.cpp | 54 +++++--------- .../windows/Staff.cpp | 48 +++++-------- src/openrct2-ui/windows/StaffList.cpp | 6 +- src/openrct2-ui/windows/Window.h | 2 + src/openrct2/interface/viewport_interaction.c | 7 +- src/openrct2/interface/window.h | 4 +- src/openrct2/management/news_item.c | 8 ++- src/openrct2/peep/staff.c | 15 ---- src/openrct2/windows/Ride.cpp | 10 ++- src/openrct2/windows/_legacy.c | 70 +++++++++++++++++++ 11 files changed, 137 insertions(+), 89 deletions(-) rename src/{openrct2 => openrct2-ui}/windows/Guest.cpp (98%) rename src/{openrct2 => openrct2-ui}/windows/Staff.cpp (98%) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 31e96a91fb..eb4fab72ae 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -161,6 +161,8 @@ public: rct_window * OpenIntent(Intent * intent) override { switch(intent->GetWindowClass()) { + case WC_PEEP: + return window_guest_open((rct_peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); case WC_FIRE_PROMPT: return window_staff_fire_prompt_open((rct_peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); case WC_INSTALL_TRACK: diff --git a/src/openrct2/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp similarity index 98% rename from src/openrct2/windows/Guest.cpp rename to src/openrct2-ui/windows/Guest.cpp index 40315f53c0..6870679f1e 100644 --- a/src/openrct2/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -14,20 +14,21 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "../network/network.h" +#include -#include "../game.h" -#include "../input.h" -#include "../management/marketing.h" -#include "../peep/staff.h" -#include "../ride/ride_data.h" -#include "../localisation/localisation.h" -#include "../sprites.h" -#include "../interface/viewport.h" -#include "../interface/widget.h" -#include "../util/util.h" -#include "../world/footpath.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include enum WINDOW_GUEST_PAGE { WINDOW_GUEST_OVERVIEW, @@ -62,6 +63,7 @@ enum WINDOW_GUEST_WIDGET_IDX { }; validate_global_widx(WC_PEEP, WIDX_ACTION_LBL); +validate_global_widx(WC_PEEP, WIDX_PICKUP); static rct_widget window_guest_overview_widgets[] = { {WWT_FRAME, 0, 0, 191, 0, 156, 0xFFFFFFFF, STR_NONE}, // Panel / Background @@ -473,11 +475,10 @@ static const uint32 window_guest_page_enabled_widgets[] = { * rct2: 0x006989E9 * */ -void window_guest_open(rct_peep* peep){ +rct_window * window_guest_open(rct_peep* peep){ if (peep->type == PEEP_TYPE_STAFF){ - window_staff_open(peep); - return; + return window_staff_open(peep); } rct_window* window; @@ -517,6 +518,8 @@ void window_guest_open(rct_peep* peep){ window_guest_disable_widgets(window); window_init_scroll_widgets(window); window_guest_viewport_init(window); + + return window; } /** @@ -586,25 +589,6 @@ void window_guest_overview_resize(rct_window *w){ window_guest_viewport_init(w); } -void game_command_callback_pickup_guest(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) -{ - switch(ecx){ - case 0:{ - sint32 peepnum = eax; - rct_window* w = window_find_by_number(WC_PEEP, peepnum); - if (w) { - tool_set(w, WIDX_PICKUP, TOOL_PICKER); - } - }break; - case 2: - if (ebx == 0) { - tool_cancel(); - gPickupPeepImage = UINT32_MAX; - } - break; - } -} - /** * * rct2: 0x00696A06 diff --git a/src/openrct2/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp similarity index 98% rename from src/openrct2/windows/Staff.cpp rename to src/openrct2-ui/windows/Staff.cpp index 06b9f04d6b..c7b70af8fe 100644 --- a/src/openrct2/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -14,20 +14,22 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "Intent.h" -#include "../Context.h" +#include -#include "../game.h" -#include "../interface/viewport.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" -#include "../peep/staff.h" -#include "../sprites.h" -#include "../world/footpath.h" -#include "../input.h" -#include "dropdown.h" -#include "../interface/themes.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define WW 190 #define WH 180 @@ -64,6 +66,7 @@ enum WINDOW_STAFF_WIDGET_IDX { }; validate_global_widx(WC_PEEP, WIDX_PATROL); +validate_global_widx(WC_STAFF, WIDX_PICKUP); static rct_widget window_staff_overview_widgets[] = { { WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, 0xFFFFFFFF, STR_NONE }, // Panel / Background @@ -419,25 +422,6 @@ void window_staff_set_page(rct_window* w, sint32 page) if (listen && w->viewport) w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON; } -void game_command_callback_pickup_staff(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) -{ - switch(ecx){ - case 0:{ - sint32 peepnum = eax; - rct_window* w = window_find_by_number(WC_PEEP, peepnum); - if (w) { - tool_set(w, WIDX_PICKUP, TOOL_PICKER); - } - }break; - case 2: - if (ebx == 0) { - tool_cancel(); - gPickupPeepImage = UINT32_MAX; - } - break; - } -} - /** * * rct2: 0x006BDF55 diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index eb33ee53d7..589d4b7a12 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -446,7 +446,11 @@ void window_staff_list_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 if (_quick_fire_mode) game_do_command(peep->x, 1, peep->y, spriteIndex, GAME_COMMAND_FIRE_STAFF_MEMBER, 0, 0); else - window_staff_open(peep); + { + auto intent = Intent(WC_PEEP); + intent.putExtra(INTENT_EXTRA_PEEP, peep); + context_open_intent(&intent); + } break; } diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 695e0e832f..23e4451241 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -33,6 +33,7 @@ rct_window * window_editor_inventions_list_open(); rct_window * window_editor_objective_options_open(); rct_window * window_editor_scenario_options_open(); rct_window * window_footpath_open(); +rct_window * window_guest_open(rct_peep* peep); rct_window * window_land_open(); rct_window * window_land_rights_open(); rct_window * window_main_open(); @@ -48,6 +49,7 @@ rct_window * window_server_start_open(); rct_window * window_shortcut_change_open(sint32 selected_key); rct_window * window_shortcut_keys_open(); rct_window * window_staff_list_open(); +rct_window * window_staff_open(rct_peep* peep); rct_window * window_themes_open(); rct_window * window_title_exit_open(); rct_window * window_title_logo_open(); diff --git a/src/openrct2/interface/viewport_interaction.c b/src/openrct2/interface/viewport_interaction.c index 4b4f767bcf..accb5ac7e4 100644 --- a/src/openrct2/interface/viewport_interaction.c +++ b/src/openrct2/interface/viewport_interaction.c @@ -131,8 +131,13 @@ sint32 viewport_interaction_left_click(sint32 x, sint32 y) window_ride_open_vehicle(info.vehicle); break; case SPRITE_IDENTIFIER_PEEP: - window_guest_open(info.peep); + { + Intent * intent = intent_create(WC_PEEP); + intent_set_pointer(intent, INTENT_EXTRA_PEEP, info.peep); + context_open_intent(intent); + intent_release(intent); break; + } case SPRITE_IDENTIFIER_MISC: if (game_is_not_paused()) { switch (info.sprite->unknown.misc_identifier) { diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 0f2085d716..0bd8c3b5c9 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -533,6 +533,7 @@ enum { #define WC_WATER__WIDX_PREVIEW 3 #define WC_PEEP__WIDX_PATROL 11 #define WC_PEEP__WIDX_ACTION_LBL 12 +#define WC_PEEP__WIDX_PICKUP 13 #define WC_TRACK_DESIGN_LIST__WIDX_ROTATE 5 #define WC_TRACK_DESIGN_PLACE__WIDX_ROTATE 3 #define WC_MAP__WIDX_LAND_TOOL 13 @@ -540,6 +541,7 @@ enum { #define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 4 #define WC_CLEAR_SCENERY__WIDX_PREVIEW 3 #define WC_LAND_RIGHTS__WIDX_PREVIEW 3 +#define WC_STAFF__WIDX_PICKUP 10 enum PROMPT_MODE { PM_SAVE_BEFORE_LOAD = 0, @@ -708,8 +710,6 @@ void window_top_toolbar_open(); void window_game_bottom_toolbar_open(); void window_game_bottom_toolbar_invalidate_news_item(); void window_track_list_open(ride_list_item item); -void window_guest_open(rct_peep* peep); -rct_window *window_staff_open(rct_peep* peep); 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); diff --git a/src/openrct2/management/news_item.c b/src/openrct2/management/news_item.c index a9337128d4..38e8d7798b 100644 --- a/src/openrct2/management/news_item.c +++ b/src/openrct2/management/news_item.c @@ -331,9 +331,15 @@ void news_item_open_subject(sint32 type, sint32 subject) break; case NEWS_ITEM_PEEP_ON_RIDE: case NEWS_ITEM_PEEP: + { peep = GET_PEEP(subject); - window_guest_open(peep); + + Intent * intent = intent_create(WC_PEEP); + intent_set_pointer(intent, INTENT_EXTRA_PEEP, peep); + context_open_intent(intent); + intent_release(intent); break; + } case NEWS_ITEM_MONEY: context_open_window(WC_FINANCES); break; diff --git a/src/openrct2/peep/staff.c b/src/openrct2/peep/staff.c index 4481b5f659..9ff2ef17a4 100644 --- a/src/openrct2/peep/staff.c +++ b/src/openrct2/peep/staff.c @@ -367,21 +367,6 @@ void game_command_hire_new_staff_member(sint32* eax, sint32* ebx, sint32* ecx, s edi); } -void game_command_callback_hire_new_staff_member(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) -{ - sint32 sprite_index = edi; - if (sprite_index == SPRITE_INDEX_NULL) - { - rct_window *window = window_find_by_class(WC_STAFF_LIST); - window_invalidate(window); - } - else - { - rct_peep *peep = &get_sprite(sprite_index)->peep; - window_staff_open(peep); - } -} - /** rct2: 0x00982134 */ static const bool peep_slow_walking_types[] = { false, // PEEP_SPRITE_TYPE_NORMAL diff --git a/src/openrct2/windows/Ride.cpp b/src/openrct2/windows/Ride.cpp index 7dd12a061d..ef56c52fb6 100644 --- a/src/openrct2/windows/Ride.cpp +++ b/src/openrct2/windows/Ride.cpp @@ -1665,7 +1665,9 @@ rct_window *window_ride_open_vehicle(rct_vehicle *vehicle) rct_window *w2 = window_find_by_number(WC_PEEP, peepSpriteIndex); if (w2 == nullptr) { rct_peep *peep = &(get_sprite(peepSpriteIndex)->peep); - window_guest_open(peep); + auto intent = Intent(WC_PEEP); + intent.putExtra(INTENT_EXTRA_PEEP, peep); + context_open_intent(&intent); openedPeepWindow = 1; break; @@ -3655,7 +3657,11 @@ static void window_ride_locate_mechanic(rct_window *w) if (mechanic == nullptr) context_show_error(STR_UNABLE_TO_LOCATE_MECHANIC, STR_NONE); else - window_staff_open(mechanic); + { + auto intent = Intent(WC_PEEP); + intent.putExtra(INTENT_EXTRA_PEEP, mechanic); + context_open_intent(&intent); + } } /** diff --git a/src/openrct2/windows/_legacy.c b/src/openrct2/windows/_legacy.c index efd053a06d..8e33c82451 100644 --- a/src/openrct2/windows/_legacy.c +++ b/src/openrct2/windows/_legacy.c @@ -15,6 +15,10 @@ #pragma endregion #include "_legacy.h" +#include "../interface/window.h" +#include "../peep/staff.h" +#include "Intent.h" +#include "../Context.h" #pragma warning(disable : 4295) // 'identifier': array is too small to include a terminating null character @@ -63,3 +67,69 @@ const rct_object_entry DefaultSelectedObjects[26] = { { 0x00000087, { "SCGSNOW " }, 0 }, // Snow and Ice Theming { 0x00000087, { "SCGWATER" }, 0 } // Water Feature Theming }; + +void game_command_callback_pickup_guest(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) +{ + switch (ecx) + { + case 0: + { + sint32 peepnum = eax; + rct_window * w = window_find_by_number(WC_PEEP, peepnum); + if (w) + { + tool_set(w, WC_PEEP__WIDX_PICKUP, TOOL_PICKER); + } + } + break; + case 2: + if (ebx == 0) + { + tool_cancel(); + gPickupPeepImage = UINT32_MAX; + } + break; + } +} + +void game_command_callback_hire_new_staff_member(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) +{ + sint32 sprite_index = edi; + if (sprite_index == SPRITE_INDEX_NULL) + { + rct_window * window = window_find_by_class(WC_STAFF_LIST); + window_invalidate(window); + } + else + { + rct_peep * peep = &get_sprite(sprite_index)->peep; + Intent * intent = intent_create(WC_PEEP); + intent_set_pointer(intent, INTENT_EXTRA_PEEP, peep); + context_open_intent(intent); + intent_release(intent); + } +} + +void game_command_callback_pickup_staff(sint32 eax, sint32 ebx, sint32 ecx, sint32 edx, sint32 esi, sint32 edi, sint32 ebp) +{ + switch (ecx) + { + case 0: + { + sint32 peepnum = eax; + rct_window * w = window_find_by_number(WC_PEEP, peepnum); + if (w) + { + tool_set(w, WC_STAFF__WIDX_PICKUP, TOOL_PICKER); + } + } + break; + case 2: + if (ebx == 0) + { + tool_cancel(); + gPickupPeepImage = UINT32_MAX; + } + break; + } +}