From 1fed6ac32c377b617ed73aa13eb78fe56a855c6c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 Jan 2015 20:25:48 +0000 Subject: [PATCH] Added missing btm toolbar functions. Added dirty enum --- src/interface/window.h | 9 +++++ src/management/finance.c | 2 +- src/peep/peep.c | 6 ++-- src/scenario.c | 2 +- src/windows/game_bottom_toolbar.c | 59 +++++++++++++++++++++++-------- src/world/climate.c | 7 ++-- src/world/park.c | 2 +- 7 files changed, 63 insertions(+), 24 deletions(-) diff --git a/src/interface/window.h b/src/interface/window.h index 7bb0013d67..df38f2047f 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -407,6 +407,15 @@ enum PROMPT_MODE { PM_QUIT }; +typedef enum { + BTM_TB_DIRTY_FLAG_MONEY = (1 << 0), + BTM_TB_DIRTY_FLAG_DATE = (1 << 1), + BTM_TB_DIRTY_FLAG_PEEP_COUNT = (1 << 2), + BTM_TB_DIRTY_FLAG_CLIMATE = (1 << 3), + BTM_TB_DIRTY_FLAG_PARK_RATING = (1 << 4) +} BTM_TOOLBAR_DIRTY_FLAGS; + + // rct2: 0x01420078 extern rct_window* g_window_list; diff --git a/src/management/finance.c b/src/management/finance.c index eaa7602382..d8426ed1ef 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -60,7 +60,7 @@ void finance_payment(money32 amount, rct_expenditure_type type) RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= 1; // money dirty flag + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_MONEY; window_invalidate_by_class(WC_FINANCES); } diff --git a/src/peep/peep.c b/src/peep/peep.c index e637f5a942..3eb7d8f395 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -313,7 +313,7 @@ void peep_remove(rct_peep* peep){ if (peep->type == PEEP_TYPE_GUEST){ if (peep->var_2A == 0){ RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)--; - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= (1 << 2); + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; } if (peep->state == PEEP_STATE_ENTERING_PARK){ RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16)--; @@ -916,7 +916,7 @@ static void peep_update_leaving_park(rct_peep* peep){ peep->var_2A = 1; peep->destination_tolerence = 5; RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)--; - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= (1 << 0); + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; peep->var_37 = 1; window_invalidate_by_class(WC_GUEST_LIST); @@ -1037,7 +1037,7 @@ static void peep_update_entering_park(rct_peep* peep){ peep->time_in_park = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, sint32); RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)++; RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16)--; - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= (1 << 2); + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= BTM_TB_DIRTY_FLAG_PEEP_COUNT; window_invalidate_by_class(WC_GUEST_LIST); } diff --git a/src/scenario.c b/src/scenario.c index ecbf59daef..561bffec60 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -650,7 +650,7 @@ void scenario_update() if (next_month_tick >= 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= 2; + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_DATE; RCT2_CALLPROC_EBPSAFE(0x0069DEAD); scenario_objectives_check(); scenario_entrance_fee_too_high_check(); diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 2cbe70e80c..77649a94e2 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -70,13 +70,15 @@ static void window_game_bottom_toolbar_mouseup(); static void window_game_bottom_toolbar_tooltip(); static void window_game_bottom_toolbar_invalidate(); static void window_game_bottom_toolbar_paint(); +static void window_game_bottom_toobar_update(rct_window* w); +static void window_game_bottom_toolbar_cursor(); +static void window_game_bottom_toolbar_unknown05(); static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, rct_window *w); static void window_game_bottom_toolbar_draw_park_rating(rct_drawpixelinfo *dpi, rct_window *w, int colour, int x, int y, uint8 factor); static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, rct_window *w); static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w); static void window_game_bottom_toolbar_draw_tutorial_text(rct_drawpixelinfo *dpi, rct_window *w); -static void window_game_bottom_toobar_update(rct_window* w); /* rct2: 0x0097BFDC */ static void* window_game_bottom_toolbar_events[] = { @@ -85,8 +87,8 @@ static void* window_game_bottom_toolbar_events[] = { window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_emptysub, - window_game_bottom_toolbar_emptysub,//0x66c6f2 - window_game_bottom_toobar_update,//0x66c6d8 + window_game_bottom_toolbar_unknown05, + window_game_bottom_toobar_update, window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_emptysub, @@ -103,7 +105,7 @@ static void* window_game_bottom_toolbar_events[] = { window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_tooltip, - window_game_bottom_toolbar_emptysub,//0x66c644 + window_game_bottom_toolbar_cursor, window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_invalidate, window_game_bottom_toolbar_paint, @@ -683,28 +685,55 @@ static void window_game_bottom_toobar_update(rct_window* w){ w->frame_no++; if (w->frame_no >= 24)w->frame_no = 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & 1){ - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~1; + // Due to windows not fully finished use callproc to save on duplicate code. + RCT2_CALLPROC_X((int)window_game_bottom_toolbar_unknown05, 0, 0, 0, 0, (int)w, 0, 0); +} + +/* rct2: 0x006C644 */ +static void window_game_bottom_toolbar_cursor(){ + rct_window *w; + short widgetIndex, x, y; + + window_cursor_get_registers(w, widgetIndex, x, y); + + switch (widgetIndex){ + case WIDX_MONEY: + case WIDX_GUESTS: + case WIDX_PARK_RATING: + case WIDX_DATE: + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 2000; + break; + } +} + +/* rct2: 0x0066C6F2 */ +static void window_game_bottom_toolbar_unknown05(){ + rct_window* w; + + window_get_register(w); + + if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & BTM_TB_DIRTY_FLAG_MONEY){ + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~BTM_TB_DIRTY_FLAG_MONEY; widget_invalidate(w, WIDX_LEFT_INSET); } - if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & 2){ - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~2; + if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & BTM_TB_DIRTY_FLAG_DATE){ + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~BTM_TB_DIRTY_FLAG_DATE; widget_invalidate(w, WIDX_RIGHT_INSET); } - if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & 4){ - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~4; + if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & BTM_TB_DIRTY_FLAG_PEEP_COUNT){ + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~BTM_TB_DIRTY_FLAG_PEEP_COUNT; widget_invalidate(w, WIDX_LEFT_INSET); } - if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & 8){ - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~8; + if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & BTM_TB_DIRTY_FLAG_CLIMATE){ + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~BTM_TB_DIRTY_FLAG_CLIMATE; widget_invalidate(w, WIDX_RIGHT_INSET); } - if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & 16){ - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~16; + if (RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) & BTM_TB_DIRTY_FLAG_PARK_RATING){ + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) &= ~BTM_TB_DIRTY_FLAG_PARK_RATING; widget_invalidate(w, WIDX_LEFT_INSET); } -} \ No newline at end of file +} diff --git a/src/world/climate.c b/src/world/climate.c index f21702eb1a..e50af29358 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -24,6 +24,7 @@ #include "../drawing/drawing.h" #include "../localisation/date.h" #include "../scenario.h" +#include "../interface/window.h" #include "climate.h" enum { @@ -158,7 +159,7 @@ void climate_update() if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16)) { if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) == 960) - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= 8; // climate dirty flag? + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_CLIMATE; RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16)--; @@ -173,7 +174,7 @@ void climate_update() if (cur_rain == next_rain) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = gClimateNextWeather; climate_determine_future_weather(); - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= 8; // climate dirty flag? + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_CLIMATE; } else if (next_rain <= 2) { // Safe-guard RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8) = step_weather_level(cur_rain, next_rain); } @@ -184,7 +185,7 @@ void climate_update() } else { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8) = step_weather_level(temperature, target_temperature); - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= 8; // climate dirty flag? + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_CLIMATE; } } } diff --git a/src/world/park.c b/src/world/park.c index 72e90bfed9..4b1e8cde19 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -540,7 +540,7 @@ void park_update() RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = calculate_company_value(); window_invalidate_by_class(WC_FINANCES); _guestGenerationProbability = park_calculate_guest_generation_probability(); - RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= 0x10; + RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint16) |= BTM_TB_DIRTY_FLAG_PARK_RATING; window_invalidate_by_class(WC_PARK_INFORMATION); }