From a35289fc9fce8530f62ed5546db32d9c1a6b2aa0 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:08:52 +0200 Subject: [PATCH 1/4] Add functions to open park window to awards/rating Also update replace some address that have constants/functions --- src/window.h | 2 + src/window_footpath.c | 2 +- src/window_game_bottom_toolbar.c | 2 +- src/window_park.c | 66 ++++++++++++++++++++++++++++++-- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/window.h b/src/window.h index 1f52eee128..dff987d918 100644 --- a/src/window.h +++ b/src/window.h @@ -359,8 +359,10 @@ void window_clear_scenery_open(); void window_land_open(); void window_water_open(); void window_guest_list_open(); +void window_park_awards_open(); void window_park_entrance_open(); void window_park_objective_open(); +void window_park_rating_open(); void window_ride_list_open(); void window_cheats_open(); diff --git a/src/window_footpath.c b/src/window_footpath.c index d88cf014a3..44ab834559 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -270,7 +270,7 @@ static void window_footpath_mouseup() break; _window_footpath_cost = 0x80000000; - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 32b4a01251..6be78ee35b 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -166,7 +166,7 @@ static void window_game_bottom_toolbar_mouseup() RCT2_CALLPROC_EBPSAFE(0x00667D35); break; case WIDX_PARK_RATING: - RCT2_CALLPROC_EBPSAFE(0x00667CA4); + window_park_rating_open(); break; case WIDX_MIDDLE_INSET: news_item_close_current(); diff --git a/src/window_park.c b/src/window_park.c index 4700b6f479..3ed83cd0e0 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -646,7 +646,7 @@ static void window_park_entrance_close() if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); } /** @@ -1083,6 +1083,35 @@ static void window_park_scroll_to_viewport(rct_window *w) #pragma region Rating page +/** +* +* rct2: 0x00667CA4 +*/ +void window_park_rating_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_RATING; + window_invalidate(window); + window->widgets = window_park_rating_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_RATING]; + window->var_020 = 0; + window->event_handlers = window_park_rating_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00668A06 @@ -1570,7 +1599,7 @@ static void window_park_stats_paint() y = w->y + window_park_awards_widgets[WIDX_PAGE_BACKGROUND].top + 4; // Draw park size - parkSize = RCT2_GLOBAL(0x013580EA, sint16) * 10; + parkSize = RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16) * 10; stringIndex = STR_PARK_SIZE_METRIC_LABEL; if (!RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) { stringIndex = STR_PARK_SIZE_IMPERIAL_LABEL; @@ -1619,7 +1648,7 @@ void window_park_objective_open() if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); window->viewport = NULL; window->page = WINDOW_PARK_PAGE_OBJECTIVE; @@ -1773,6 +1802,35 @@ static void window_park_objective_paint() #pragma region Awards page +/** +* +* rct2: 0x00667DC6 +*/ +void window_park_awards_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_AWARDS; + window_invalidate(window); + window->widgets = window_park_awards_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_AWARDS]; + window->var_020 = 0; + window->event_handlers = window_park_awards_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00669851 @@ -1896,7 +1954,7 @@ static void window_park_set_page(rct_window *w, int page) if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); // Set listen only to viewport listen = 0; From c94fd530229171617cf69d42989ae1620c3213b6 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:14:08 +0200 Subject: [PATCH 2/4] Add news_item_open_subject() --- src/news_item.c | 68 ++++++++++++++++++++++++++++++++ src/news_item.h | 1 + src/window_game_bottom_toolbar.c | 2 +- src/window_news.c | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 3bc978f7bb..7e4aa2cd4a 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -276,3 +276,71 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) newsItem++; newsItem->type = 0; } + +/** + * Opens the window/tab for the subject of the news item + * + * rct2: 0x0066EBE6 + * + **/ +void news_item_open_subject(int type, int subject) { + + int eax; + rct_peep* peep; + rct_window* window; + + switch (type) { + case NEWS_ITEM_RIDE: + RCT2_CALLPROC_X(0x006ACC28, subject, 0, 0, 0, 0, 0, 0); + break; + case NEWS_ITEM_PEEP_ON_RIDE: + case NEWS_ITEM_PEEP: + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + break; + case NEWS_ITEM_MONEY: + // Open finances window + RCT2_CALLPROC_EBPSAFE(0x0069DDF1); + break; + case NEWS_ITEM_SCENERY: + + if (subject >= 0x10000) { + // Open ride list window + RCT2_CALLPROC_EBPSAFE(0x006B3CFF); + eax = (subject & 0xFF00) >> 8; + eax += (subject & 0xFF) << 8; + // Switch to right tab and scroll to ride location + RCT2_CALLPROC_X(0x006B3EBA, eax, 0, subject, 0, 0, 0, 0); + break; + } + + // Check if window is already open + window = window_bring_to_front_by_id(WC_SCENERY, 0); + if (window == NULL) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + if (tool_set(window, 9, 0)){ + RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0); + } + RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); + // Open scenery window + RCT2_CALLPROC_EBPSAFE(0x006E0FEF); + } + } + // Switch to new scenery tab + RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0); + + break; + case NEWS_ITEM_PEEPS: + // Open guest list to right tab + RCT2_CALLPROC_X(0x006993BA, 3, subject, 0, 0, 0, 0, 0); + break; + case NEWS_ITEM_AWARD: + window_park_awards_open(); + break; + case NEWS_ITEM_GRAPH: + window_park_rating_open(); + break; + } +} diff --git a/src/news_item.h b/src/news_item.h index 3de7ada5a5..8775fa1581 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -61,5 +61,6 @@ void news_item_update_current(); void news_item_close_current(); void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z); void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc); +void news_item_open_subject(int type, int subject); #endif diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 6be78ee35b..4169876f68 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -173,7 +173,7 @@ static void window_game_bottom_toolbar_mouseup() break; case WIDX_NEWS_SUBJECT: newsItem = &(RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0]); - RCT2_CALLPROC_X(0x0066EBE6, 0, newsItem->type, newsItem->assoc, 0, 0, 0, 0); + news_item_open_subject(newsItem->type, newsItem->assoc); break; case WIDX_NEWS_LOCATE: newsItem = &(RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0]); diff --git a/src/window_news.c b/src/window_news.c index daa4f53939..cdfb22104c 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -169,7 +169,7 @@ static void window_news_update() if (newsItems[i].flags & 1) return; if (w->var_482 == 1) { - RCT2_CALLPROC_X(0x0066EBE6, 0, newsItems[i].type, newsItems[i].assoc, 0, 0, 0, 0); + news_item_open_subject(newsItems[i].type, newsItems[i].assoc); return; } else if (w->var_482 > 1) { news_item_get_subject_location(newsItems[i].type, newsItems[i].assoc, &x, &y, &z); From c1ac6edb96bd516bb41abda9deaef5c18bed9299 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:35:32 +0200 Subject: [PATCH 3/4] Add function to open park window to guests tab --- src/window.h | 1 + src/window_game_bottom_toolbar.c | 2 +- src/window_park.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/window.h b/src/window.h index dff987d918..3b80f58142 100644 --- a/src/window.h +++ b/src/window.h @@ -361,6 +361,7 @@ void window_water_open(); void window_guest_list_open(); void window_park_awards_open(); void window_park_entrance_open(); +void window_park_guests_open(); void window_park_objective_open(); void window_park_rating_open(); void window_ride_list_open(); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 4169876f68..a5914cf9ef 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -163,7 +163,7 @@ static void window_game_bottom_toolbar_mouseup() RCT2_CALLPROC_EBPSAFE(0x0069DDF1); break; case WIDX_GUESTS: - RCT2_CALLPROC_EBPSAFE(0x00667D35); + window_park_guests_open(); break; case WIDX_PARK_RATING: window_park_rating_open(); diff --git a/src/window_park.c b/src/window_park.c index 3ed83cd0e0..e01ca4550a 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -1226,6 +1226,35 @@ static void window_park_rating_paint() #pragma region Guests page +/** +* +* rct2: 0x00667D35 +*/ +void window_park_guests_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_GUESTS; + window_invalidate(window); + window->widgets = window_park_guests_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_GUESTS]; + window->var_020 = 0; + window->event_handlers = window_park_guests_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00668DEB From 85b102c5b0408cb8c4172070930f4824f4846c40 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:53:57 +0200 Subject: [PATCH 4/4] Change NEWS_ITEM_SCENERY to NEWS_ITEM_RESEARCH --- src/news_item.c | 2 +- src/news_item.h | 2 +- src/window_game_bottom_toolbar.c | 2 +- src/window_news.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 7e4aa2cd4a..70c0f1f01e 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -302,7 +302,7 @@ void news_item_open_subject(int type, int subject) { // Open finances window RCT2_CALLPROC_EBPSAFE(0x0069DDF1); break; - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: if (subject >= 0x10000) { // Open ride list window diff --git a/src/news_item.h b/src/news_item.h index 8775fa1581..f7e5333af1 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -33,7 +33,7 @@ enum { NEWS_ITEM_PEEP, NEWS_ITEM_MONEY, NEWS_ITEM_BLANK, - NEWS_ITEM_SCENERY, + NEWS_ITEM_RESEARCH, NEWS_ITEM_PEEPS, NEWS_ITEM_AWARD, NEWS_ITEM_GRAPH diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index a5914cf9ef..00eacc24e3 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -615,7 +615,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc break; case NEWS_ITEM_MONEY: gfx_draw_sprite(dpi, SPR_FINANCE, x, y); - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: gfx_draw_sprite(dpi, (newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY), x, y); break; case NEWS_ITEM_PEEPS: diff --git a/src/window_news.c b/src/window_news.c index cdfb22104c..1e849ce080 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -352,7 +352,7 @@ static void window_news_scrollpaint() case NEWS_ITEM_MONEY: gfx_draw_sprite(dpi, SPR_FINANCE, x, yy); break; - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy); break; case NEWS_ITEM_PEEPS: