diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index d5e07643b6..ff95a9caa9 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -376,6 +376,37 @@ public: window_invalidate(w); } + + case INTENT_ACTION_UPDATE_CLIMATE: + gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_CLIMATE; + window_invalidate_by_class(WC_GUEST_LIST); + break; + + case INTENT_ACTION_UPDATE_PARK_RATING: + gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PARK_RATING; + window_invalidate_by_class(WC_PARK_INFORMATION); + break; + + case INTENT_ACTION_UPDATE_DATE: + gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_DATE; + break; + + case INTENT_ACTION_UPDATE_CASH: + window_invalidate_by_class(WC_FINANCES); + gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_MONEY; + break; + + case INTENT_ACTION_UPDATE_BANNER: + { + uint8 bannerIndex = static_cast(intent.GetUIntExtra(INTENT_EXTRA_BANNER_INDEX)); + + rct_window * w = window_find_by_number(WC_BANNER, bannerIndex); + if (w != nullptr) + { + window_invalidate(w); + } + } + } } diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index bd1450260b..78a4d527f5 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -68,6 +68,8 @@ static rct_widget window_game_bottom_toolbar_widgets[] = { WIDGETS_END }, }; +uint8 gToolbarDirtyFlags; + static void window_game_bottom_toolbar_mouseup(rct_window *w, rct_widgetindex widgetIndex); static void window_game_bottom_toolbar_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId); static void window_game_bottom_toolbar_invalidate(rct_window *w); diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index df9d2d721e..da21b7262a 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -150,6 +150,7 @@ void window_scenery_set_default_placement_configuration(); void window_scenery_init(); void window_scenery_reset_selected_scenery_items(); +extern uint8 gToolbarDirtyFlags; rct_window * window_game_bottom_toolbar_open(); void window_game_bottom_toolbar_invalidate_news_item(); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index d647623486..0f472df80f 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -62,7 +62,6 @@ bool gUsingWidgetTextBox = false; TextInputSession * gTextInput; uint16 gWindowUpdateTicks; -uint8 gToolbarDirtyFlags; uint16 gWindowMapFlashingFlags; colour_t gCurrentWindowColours[4]; diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index b398798e5d..b6f5c5c213 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -554,7 +554,6 @@ extern rct_window * gWindowNextSlot; extern rct_window * gWindowAudioExclusive; extern uint16 gWindowUpdateTicks; -extern uint8 gToolbarDirtyFlags; extern uint16 gWindowMapFlashingFlags; extern colour_t gCurrentWindowColours[4]; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 473617f9c9..3dab1a25d1 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -25,6 +25,8 @@ #include "../world/Park.h" #include "../world/Sprite.h" #include "Finance.h" +#include "../Context.h" +#include "../windows/Intent.h" /** * Monthly staff wages @@ -85,9 +87,8 @@ void finance_payment(money32 amount, rct_expenditure_type type) gCurrentExpenditure -= amount; } - - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_MONEY; - window_invalidate_by_class(WC_FINANCES); + auto intent = Intent(INTENT_ACTION_UPDATE_CASH); + context_broadcast_intent(&intent); } /** @@ -346,8 +347,8 @@ void game_command_set_current_loan(sint32 * eax, sint32 * ebx, sint32 * ecx, sin gBankLoan = newLoan; gInitialCash = gCash; - window_invalidate_by_class(WC_FINANCES); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_MONEY; + auto intent = Intent(INTENT_ACTION_UPDATE_CASH); + context_broadcast_intent(&intent); } *ebx = 0; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index b824769868..55d228f100 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -49,6 +49,7 @@ #include "../world/Sprite.h" #include "Peep.h" #include "Staff.h" +#include "../windows/Intent.h" #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 bool gPathFindDebug = false; @@ -2247,7 +2248,8 @@ void peep_remove(rct_peep * peep) if (peep->outside_of_park == 0) { decrement_guests_in_park(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + context_broadcast_intent(&intent); } if (peep->state == PEEP_STATE_ENTERING_PARK) { @@ -5739,7 +5741,8 @@ static void peep_update_leaving_park(rct_peep * peep) peep->outside_of_park = 1; peep->destination_tolerance = 5; decrement_guests_in_park(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + context_broadcast_intent(&intent); peep->var_37 = 1; window_invalidate_by_class(WC_GUEST_LIST); @@ -5883,8 +5886,8 @@ static void peep_update_entering_park(rct_peep * peep) peep->time_in_park = gScenarioTicks; increment_guests_in_park(); decrement_guests_heading_for_park(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; - window_invalidate_by_class(WC_GUEST_LIST); + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + context_broadcast_intent(&intent); } /** diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index d7b1d63f55..68b5ac224c 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -5266,7 +5266,8 @@ static void vehicle_kill_all_passengers(rct_vehicle * vehicle) if (peep->outside_of_park == 0) { decrement_guests_in_park(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + context_broadcast_intent(&intent); } ride->num_riders--; peep_sprite_remove(peep); diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index b4c8f1b5c1..ebea74a2cd 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -49,6 +49,7 @@ #include "Scenario.h" #include "../Context.h" #include "../ride/Track.h" +#include "../windows/Intent.h" extern "C" { @@ -318,7 +319,8 @@ static void scenario_day_update() uint16 casualtyPenaltyModifier = (gParkFlags & PARK_FLAGS_NO_MONEY) ? 40 : 7; gParkRatingCasualtyPenalty = std::max(0, gParkRatingCasualtyPenalty - casualtyPenaltyModifier); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_DATE; + auto intent = Intent(INTENT_ACTION_UPDATE_DATE); + context_broadcast_intent(&intent); } static void scenario_week_update() diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index 92b05173cc..34f9ac235a 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -69,6 +69,7 @@ extern "C" { INTENT_EXTRA_LIST, INTENT_EXTRA_LIST_COUNT, INTENT_EXTRA_PAGE, + INTENT_EXTRA_BANNER_INDEX, }; enum { @@ -89,6 +90,12 @@ extern "C" { INTENT_ACTION_SET_TILE_INSPECTOR_BUTTONS, INTENT_ACTION_REFRESH_STAFF_LIST, INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW, + INTENT_ACTION_UPDATE_CLIMATE, + INTENT_ACTION_UPDATE_GUEST_COUNT, + INTENT_ACTION_UPDATE_PARK_RATING, + INTENT_ACTION_UPDATE_DATE, + INTENT_ACTION_UPDATE_CASH, + INTENT_ACTION_UPDATE_BANNER, }; Intent *intent_create(rct_windowclass clss); diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index a1aa26c162..37f0341776 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -31,6 +31,8 @@ #include "../localisation/Localisation.h" #include "../ride/Ride.h" #include "../ride/Track.h" +#include "../windows/Intent.h" +#include "../Context.h" rct_banner gBanners[MAX_BANNERS]; @@ -159,11 +161,10 @@ static money32 BannerSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direc return MONEY32_UNDEFINED; } - rct_window* window = window_find_by_number(WC_BANNER, tileElement->properties.banner.index); - if (window != nullptr) - { - window_invalidate(window); - } + auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); + intent.putExtra(INTENT_EXTRA_BANNER_INDEX, tileElement->properties.banner.index); + context_broadcast_intent(&intent); + gBanners[tileElement->properties.banner.index].colour = colour; map_invalidate_tile_zoom1(x, y, z, z + 32); } @@ -331,11 +332,10 @@ static money32 BannerSetName(uint8 bannerIndex, rct_string_id prevStringId = banner->string_idx; banner->string_idx = stringId; user_string_free(prevStringId); - rct_window* w = window_bring_to_front_by_number(WC_BANNER, bannerIndex); - if (w != nullptr) - { - window_invalidate(w); - } + + auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); + intent.putExtra(INTENT_EXTRA_BANNER_INDEX, bannerIndex); + context_broadcast_intent(&intent); } else { @@ -398,11 +398,10 @@ static money32 BannerSetStyle(uint8 bannerIndex, uint8 colour, uint8 textColour, rct_string_id prevStringId = banner->string_idx; banner->string_idx = stringId; user_string_free(prevStringId); - rct_window* w = window_bring_to_front_by_number(WC_BANNER, bannerIndex); - if (w != nullptr) - { - window_invalidate(w); - } + + auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); + intent.putExtra(INTENT_EXTRA_BANNER_INDEX, bannerIndex); + context_broadcast_intent(&intent); } else { diff --git a/src/openrct2/world/Climate.cpp b/src/openrct2/world/Climate.cpp index 1dbac0c7f4..75ed5ae8f1 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -29,6 +29,8 @@ #include "../sprites.h" #include "../util/Util.h" #include "Climate.h" +#include "../windows/Intent.h" +#include "../Context.h" constexpr sint32 MAX_THUNDER_INSTANCES = 2; @@ -124,7 +126,8 @@ extern "C" { if (gClimateUpdateTimer == 960) { - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_CLIMATE; + auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); + context_broadcast_intent(&intent); } gClimateUpdateTimer--; } @@ -142,7 +145,8 @@ extern "C" { gClimateCurrent.Weather = gClimateNext.Weather; climate_determine_future_weather(scenario_rand()); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_CLIMATE; + auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); + context_broadcast_intent(&intent); } else if (gClimateNext.RainLevel <= RAIN_LEVEL_HEAVY) { @@ -158,7 +162,8 @@ extern "C" else { gClimateCurrent.Temperature = climate_step_weather_level(gClimateCurrent.Temperature, gClimateNext.Temperature); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_CLIMATE; + auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); + context_broadcast_intent(&intent); } } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 5a3df1971f..a9e0fa682b 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -4352,10 +4352,9 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* } } - rct_window* w = window_bring_to_front_by_number(WC_BANNER, *ecx); - if (w) { - window_invalidate(w); - } + auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); + intent.putExtra(INTENT_EXTRA_BANNER_INDEX, *ecx); + context_broadcast_intent(&intent); *ebx = 0; } diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index f1f3d3161c..92dcbe8a4d 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -39,7 +39,8 @@ #include "Map.h" #include "Park.h" #include "Sprite.h" - +#include "../windows/Intent.h" +#include "../Context.h" rct_string_id gParkName; uint32 gParkNameArgs; @@ -550,8 +551,8 @@ void park_update() gCompanyValue = calculate_company_value(); window_invalidate_by_class(WC_FINANCES); _guestGenerationProbability = park_calculate_guest_generation_probability(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PARK_RATING; - window_invalidate_by_class(WC_PARK_INFORMATION); + auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING); + context_broadcast_intent(&intent); } // Generate new guests @@ -591,7 +592,8 @@ void park_update_histories() sint32 guestsInPark = gNumGuestsInPark; sint32 lastGuestsInPark = gNumGuestsInParkLastWeek; gNumGuestsInParkLastWeek = guestsInPark; - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + context_broadcast_intent(&intent); sint32 changeInGuestsInPark = guestsInPark - lastGuestsInPark; sint32 guestChangeModifier = 1; @@ -1050,8 +1052,8 @@ void set_forced_park_rating(sint32 rating) { _forcedParkRating = rating; gParkRating = calculate_park_rating(); - gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_PARK_RATING; - window_invalidate_by_class(WC_PARK_INFORMATION); + auto intent = Intent(INTENT_ACTION_UPDATE_PARK_RATING); + context_broadcast_intent(&intent); } sint32 get_forced_park_rating()