From 9ad21599a3dd54e5af4d40d84e9c822330d6ff70 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Fri, 26 Jun 2015 11:40:37 -0400 Subject: [PATCH 1/2] Decompiled top_toolbar tool events Also fixed bug with land rights tool gridlines --- src/interface/viewport.c | 2 ++ src/windows/park.c | 3 ++- src/windows/top_toolbar.c | 55 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index da47e8b24d..a8ea40fbbf 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -2170,6 +2170,7 @@ void show_gridlines() } } RCT2_GLOBAL(0x009E32B0, uint8)++; + printf("gridline_state: %i\n", RCT2_GLOBAL(0x009E32B0, uint8)); } /** @@ -2181,6 +2182,7 @@ void hide_gridlines() rct_window *mainWindow; RCT2_GLOBAL(0x009E32B0, uint8)--; + printf("gridline_state: %i\n", RCT2_GLOBAL(0x009E32B0, uint8)); if (RCT2_GLOBAL(0x009E32B0, uint8) == 0) { if ((mainWindow = window_get_main()) != NULL) { if (!gConfigGeneral.always_show_gridlines) { diff --git a/src/windows/park.c b/src/windows/park.c index 27318ce991..c22e6c127c 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1176,7 +1176,8 @@ static void window_park_init_viewport(rct_window *w) void toggle_land_rights_window(rct_window *parkWindow, int widgetIndex) { - if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 14) { + if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == WC_PARK_INFORMATION && + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == WIDX_BUY_LAND_RIGHTS) { tool_cancel(); } else { diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index bf256a54a2..3ef453ca1c 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -178,6 +178,8 @@ static void window_top_toolbar_dropdown(); static void window_top_toolbar_tool_update(); static void window_top_toolbar_tool_down(); static void window_top_toolbar_tool_drag(); +static void window_top_toolbar_tool_up(); +static void window_top_toolbar_tool_abort(); static void window_top_toolbar_invalidate(); static void window_top_toolbar_paint(); @@ -194,8 +196,8 @@ static void* window_top_toolbar_events[] = { window_top_toolbar_tool_update, // editor: 0x0066fB0E window_top_toolbar_tool_down, // editor: 0x0066fB5C window_top_toolbar_tool_drag, // editor: 0x0066fB37 - (void*)0x0066CC5B, // editor: 0x0066fC44 - (void*)0x0066CA58, // editor: 0x0066fA74 + window_top_toolbar_tool_up, // editor: 0x0066fC44 (Exactly the same) + window_top_toolbar_tool_abort, // editor: 0x0066fA74 (Exactly the same) window_top_toolbar_emptysub, window_top_toolbar_emptysub, window_top_toolbar_emptysub, @@ -2723,6 +2725,55 @@ static void window_top_toolbar_tool_drag() } } +/** + * + * rct2: 0x0066CC5B + */ +static void window_top_toolbar_tool_up() +{ + short widgetIndex, x, y; + rct_window *w; + + window_tool_get_registers(w, widgetIndex, x, y); + + switch (widgetIndex) { + case WIDX_LAND: + map_invalidate_selection_rect(); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = 0x12; + break; + case WIDX_WATER: + map_invalidate_selection_rect(); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = 0x13; + break; + case WIDX_CLEAR_SCENERY: + map_invalidate_selection_rect(); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = 0x0C; + break; + } +} + +/** + * + * rct2: 0x0066CA58 + */ +static void window_top_toolbar_tool_abort() +{ + short widgetIndex, x, y; + rct_window* w; + + window_tool_get_registers(w, widgetIndex, x, y); + + switch (widgetIndex) { + case WIDX_LAND: + case WIDX_WATER: + case WIDX_CLEAR_SCENERY: + hide_gridlines(); + break; + } +} void top_toolbar_init_fastforward_menu(rct_window* w, rct_widget* widget) { int num_items = 4; From c20b60652c3cc5fbbf43c46d9bbb50d9166e3ec0 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Fri, 26 Jun 2015 11:47:03 -0400 Subject: [PATCH 2/2] Removed printfs --- src/interface/viewport.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index a8ea40fbbf..da47e8b24d 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -2170,7 +2170,6 @@ void show_gridlines() } } RCT2_GLOBAL(0x009E32B0, uint8)++; - printf("gridline_state: %i\n", RCT2_GLOBAL(0x009E32B0, uint8)); } /** @@ -2182,7 +2181,6 @@ void hide_gridlines() rct_window *mainWindow; RCT2_GLOBAL(0x009E32B0, uint8)--; - printf("gridline_state: %i\n", RCT2_GLOBAL(0x009E32B0, uint8)); if (RCT2_GLOBAL(0x009E32B0, uint8) == 0) { if ((mainWindow = window_get_main()) != NULL) { if (!gConfigGeneral.always_show_gridlines) {