From 1373db3fe0bdbe94b7e572d72269a44bbeb95867 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Sep 2014 20:49:34 +0100 Subject: [PATCH 01/10] Added rough widget_state_pressed function --- src/input.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/input.c b/src/input.c index 1fa02fbb77..f1d8fe50f7 100644 --- a/src/input.c +++ b/src/input.c @@ -549,6 +549,64 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) } } +/* rct2: 0x6E8DA7 */ +void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_window* w, rct_widget* widget ){ + RCT2_GLOBAL(0x1420054, uint16) = x; + RCT2_GLOBAL(0x1420056, uint16) = y; + + w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); + if (!w){ + RCT2_GLOBAL(0x9DE51D, uint8) = 0; + } + + switch (state){ + case 0: + { + int eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + int ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + if (!w) { + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + return; + //jmp to 0x6E9103? Will never happen + } + if (eax != w->classification || ebx != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + return; + //jmp to 0x6E9103 + } + if (w->disabled_widgets & (1ULL << widgetIndex)){ + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + return; + //jmp to 0x6E9103 + } + + if (RCT2_GLOBAL(0x9DE528, uint16) != 0) RCT2_GLOBAL(0x9DE528, uint16)++; + + if (w->var_020 & (1ULL << widgetIndex)){ + if (RCT2_GLOBAL(0x9DE528, uint16) >= 0x10){ + if (!(RCT2_GLOBAL(0x9DE528, uint16) & 0x3)){ + RCT2_CALLPROC_WE_MOUSE_DOWN(w->event_handlers[WE_MOUSE_DOWN], widgetIndex, w, widget); + } + } + } + + if (RCT2_GLOBAL(0x9DE518, uint32) & 1) return; + + RCT2_GLOBAL(0x9DE518, uint32) |= 1; + eax |= 0x80; + eax |= (widgetIndex & 0xFF) << 8; + window_invalidate_by_id(eax, ebx); + } + break; + case 2: + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + break; + case 3: + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + break; + } +} + /** * * rct2: 0x006E8655 @@ -612,7 +670,8 @@ static void game_handle_input_mouse(int x, int y, int state) break; case INPUT_STATE_WIDGET_PRESSED: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + input_state_widget_pressed(x, y, state, widgetIndex, w, widget); + //RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_DRAGGING: // RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0); @@ -728,7 +787,8 @@ static void game_handle_input_mouse(int x, int y, int state) break; } case INPUT_STATE_DROPDOWN_ACTIVE: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + input_state_widget_pressed(x, y, state, widgetIndex, w, widget); + //RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_VIEWPORT_LEFT: //RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, (int)w, (int)widget, 0); From 7746ae784d7c207475d5b0a85add977d708d4405 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 10 Sep 2014 17:34:12 +0100 Subject: [PATCH 02/10] Started adding dropdown control --- src/input.c | 81 ++++++++++++++++++++++++++++++++++++++-------------- src/window.c | 3 +- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/input.c b/src/input.c index f1d8fe50f7..6361bbc75c 100644 --- a/src/input.c +++ b/src/input.c @@ -556,25 +556,27 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); if (!w){ - RCT2_GLOBAL(0x9DE51D, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0; + return; } + rct_windowclass cursor_w_class; + rct_windownumber cursor_w_number; + switch (state){ case 0: { - int eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); - int ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - if (!w) { - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - return; - //jmp to 0x6E9103? Will never happen - } - if (eax != w->classification || ebx != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ + cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ + break; RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); return; //jmp to 0x6E9103 } if (w->disabled_widgets & (1ULL << widgetIndex)){ + break; RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); return; //jmp to 0x6E9103 @@ -582,29 +584,66 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w if (RCT2_GLOBAL(0x9DE528, uint16) != 0) RCT2_GLOBAL(0x9DE528, uint16)++; - if (w->var_020 & (1ULL << widgetIndex)){ - if (RCT2_GLOBAL(0x9DE528, uint16) >= 0x10){ - if (!(RCT2_GLOBAL(0x9DE528, uint16) & 0x3)){ - RCT2_CALLPROC_WE_MOUSE_DOWN(w->event_handlers[WE_MOUSE_DOWN], widgetIndex, w, widget); - } - } + if (w->var_020 & (1ULL << widgetIndex) && + RCT2_GLOBAL(0x9DE528, uint16) >= 0x10 && + (!(RCT2_GLOBAL(0x9DE528, uint16) & 0x3))){ + RCT2_CALLPROC_WE_MOUSE_DOWN(w->event_handlers[WE_MOUSE_DOWN], widgetIndex, w, widget); } if (RCT2_GLOBAL(0x9DE518, uint32) & 1) return; RCT2_GLOBAL(0x9DE518, uint32) |= 1; - eax |= 0x80; - eax |= (widgetIndex & 0xFF) << 8; - window_invalidate_by_id(eax, ebx); + widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex); + return; } break; case 2: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - break; + return; case 3: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - break; + return; } + + //6e9103 + RCT2_GLOBAL(0x9DE528, uint16) = 0; + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) != 5){ + // Hold down widget and drag outside of area?? + if (RCT2_GLOBAL(0x9DE518, uint32) & 1){ + RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE; + widget_invalidate(cursor_w_class, cursor_w_number, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8)); + } + return; + } + + if (!w) return; + + if (w->classification != WC_DROPDOWN) return; + + int left = x - w->x; + if (left < 0) return; + if (left >= w->width) return; + + int top = y - w->y - 2; + if (top < 0) return; + + // _dropdown_item_height + int row_no = top / RCT2_GLOBAL(0x9DED3C,uint8); + // _dropdown_no_items + if (row_no >= RCT2_GLOBAL(0x009DEBA0, sint16)) return; + + left -= 2; + if (left < 0) return; + // _dropdown_item_width + int column_no = left / RCT2_GLOBAL(0x009DED40, sint32); + // _dropdown_no_columns + if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)) return; + // _dropdown_no_rows + if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)) return; + + int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32); //6e91be + + //6e9141 } /** @@ -816,7 +855,7 @@ static void game_handle_input_mouse(int x, int y, int state) } else if (state == 2){ - RCT2_GLOBAL(0x9DE51D, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0; if (RCT2_GLOBAL(0x9DE52E, rct_windownumber) != w->number)break; if ((RCT2_GLOBAL(0x9DE518, uint32)&(1 << 3))){ w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)); diff --git a/src/window.c b/src/window.c index af22ebfc4a..6fba666fe7 100644 --- a/src/window.c +++ b/src/window.c @@ -658,7 +658,8 @@ void window_invalidate(rct_window *window) /** * * rct2: 0x006EC3AC - * + * See also widget_invalidate that will probably be used + * when cls is > 0x7F. * @param cls (ax) * @param number (bx) */ From 5d438ac723a6d95c140fca182ad4be5542dc148f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 10 Sep 2014 19:53:09 +0100 Subject: [PATCH 03/10] Finished dropdown part. --- src/input.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/input.c b/src/input.c index 6361bbc75c..06c37492a2 100644 --- a/src/input.c +++ b/src/input.c @@ -33,6 +33,7 @@ #include "widget.h" #include "window.h" #include "window_tooltip.h" +#include "window_dropdown.h" POINT _dragPosition; @@ -616,6 +617,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w return; } + //6e9141 if (!w) return; if (w->classification != WC_DROPDOWN) return; @@ -641,9 +643,18 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w // _dropdown_no_rows if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)) return; - int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32); //6e91be + // _dropdown_no_columns + int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; + // _dropdown_no_items + if (item_no >= RCT2_GLOBAL(0x009DEBA0, sint16)) return; - //6e9141 + if (item_no < 32 && gDropdownItemsChecked & (1 << item_no))return; + + if (gDropdownItemsFormat[item_no] == 0)return; + + // _dropdown_highlighted_index + RCT2_GLOBAL(0x009DEBA2, sint16) = item_no; + window_invalidate_by_id(WC_DROPDOWN, 0); } /** From 5b0642535a2d169359ca7baac99653488865553d Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 11 Sep 2014 18:02:06 +0100 Subject: [PATCH 04/10] Fix mistake with dropdown window. Still a mistake in dropdown code --- src/input.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index 06c37492a2..2d0a3c4c9d 100644 --- a/src/input.c +++ b/src/input.c @@ -552,11 +552,13 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) /* rct2: 0x6E8DA7 */ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_window* w, rct_widget* widget ){ + //RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + //return; RCT2_GLOBAL(0x1420054, uint16) = x; RCT2_GLOBAL(0x1420056, uint16) = y; - w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); - if (!w){ + rct_window* temp_w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); + if (!temp_w){ RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0; return; } @@ -570,7 +572,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ + if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ break; RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); return; @@ -604,6 +606,8 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w case 3: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); return; + default: + return; } //6e9103 @@ -617,7 +621,6 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w return; } - //6e9141 if (!w) return; if (w->classification != WC_DROPDOWN) return; From 173083f4474557162227d8ccfe7598941d859006 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 12 Sep 2014 17:35:33 +0100 Subject: [PATCH 05/10] Fixed dropdown bug. Added mouse up code. --- src/input.c | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/input.c b/src/input.c index 2d0a3c4c9d..3f6d6992e6 100644 --- a/src/input.c +++ b/src/input.c @@ -557,8 +557,8 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(0x1420054, uint16) = x; RCT2_GLOBAL(0x1420056, uint16) = y; - rct_window* temp_w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); - if (!temp_w){ + rct_window* cursor_w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); + if (!cursor_w){ RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0; return; } @@ -572,18 +572,11 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)){ + if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) break; - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - return; - //jmp to 0x6E9103 - } - if (w->disabled_widgets & (1ULL << widgetIndex)){ + + if (w->disabled_widgets & (1ULL << widgetIndex)) break; - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - return; - //jmp to 0x6E9103 - } if (RCT2_GLOBAL(0x9DE528, uint16) != 0) RCT2_GLOBAL(0x9DE528, uint16)++; @@ -601,10 +594,38 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w } break; case 2: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ + //6e8e04 + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + return; + } + + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; + RCT2_GLOBAL(0x9DE53C, uint16) = 0; + RCT2_GLOBAL(0x9DE536,uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + + if (!w) + break; + + int mid_point_x = (widget->left + widget->right) / 2 + w->x; + sound_play_panned(5, mid_point_x); + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) + break; + + if (w->disabled_widgets & (1ULL << widgetIndex)) + break; + + widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex); + window_event_helper(w, widgetIndex, WE_MOUSE_UP); return; case 3: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ + //6e8e04 + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); + return; + } return; default: return; @@ -651,7 +672,8 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w // _dropdown_no_items if (item_no >= RCT2_GLOBAL(0x009DEBA0, sint16)) return; - if (item_no < 32 && gDropdownItemsChecked & (1 << item_no))return; + // _dropdown_unknown?? highlighted? + if (item_no < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << item_no))return; if (gDropdownItemsFormat[item_no] == 0)return; From 00634e60964146ab9bef19bf9e29e251662a40cc Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 12 Sep 2014 19:05:26 +0100 Subject: [PATCH 06/10] Added state==5 code --- src/input.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/src/input.c b/src/input.c index 3f6d6992e6..6ab1b33776 100644 --- a/src/input.c +++ b/src/input.c @@ -593,12 +593,82 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w return; } break; + case 3: case 2: if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ + cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); //6e8e04 + if (w) { + if (w->classification == WC_DROPDOWN){ + int left = x - w->x; + if (left < 0); //6e8fb7; + if (left >= w->width); //6e8fb7; + + int top = y - w->y - 2; + if (top < 0); //6e8fb7; + + // _dropdown_item_height + int row_no = top / RCT2_GLOBAL(0x9DED3C, uint8); + // _dropdown_no_items + if (row_no >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; + + left -= 2; + if (left < 0); //6e8fb7; + // _dropdown_item_width + int column_no = left / RCT2_GLOBAL(0x009DED40, sint32); + // _dropdown_no_columns + if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)); //6e8fb7; + // _dropdown_no_rows + if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)); //6e8fb7; + + // _dropdown_no_columns + int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; + // _dropdown_no_items + if (item_no >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; + + // _dropdown_unknown?? highlighted? + if (item_no < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << item_no)); //6e8fb7; + + if (gDropdownItemsFormat[item_no] == 0); //6e8fb7; + } + else{ + //6e8ed3 + + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)); + //6e8fb7 ax = -1 + if (RCT2_GLOBAL(0x9DE518, uint32) & 2){ + if (!(RCT2_GLOBAL(0x9DE518, uint32) & 4)){ + RCT2_GLOBAL(0x9DE518, uint32) |= (1 << 2); + return; + } + } + } + //6e8f1a + rct_window* temp_w = window_find_by_id(cursor_w_class, cursor_w_number); + if (!temp_w);//6e8fb7 + + window_close_by_id(WC_DROPDOWN, 0); + temp_w = window_find_by_id(cursor_w_class, cursor_w_number); + if (RCT2_GLOBAL(0x9DE518, uint32) & 1){ + RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE; + widget_invalidate(cursor_w_class, cursor_w_number, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8)); + } + + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; + RCT2_GLOBAL(0x9DE53C, uint16) = 0; + RCT2_GLOBAL(0x9DE536, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + window_event_helper(w, widgetIndex, WE_DROPDOWN); + + //6e8fb7 + window_close_by_id(WC_DROPDOWN, 0); + } RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); return; } + if (state == 3) return; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(0x9DE53C, uint16) = 0; @@ -620,13 +690,6 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex); window_event_helper(w, widgetIndex, WE_MOUSE_UP); return; - case 3: - if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ - //6e8e04 - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - return; - } - return; default: return; } From b3822247a55aadb58d62df3e8542a50412404934 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 12 Sep 2014 20:41:41 +0100 Subject: [PATCH 07/10] Fixed dropdown issues need to add error handler --- src/input.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/input.c b/src/input.c index 6ab1b33776..2b11d0ecfe 100644 --- a/src/input.c +++ b/src/input.c @@ -600,6 +600,8 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); //6e8e04 if (w) { + int dropdown_index = 0; + if (w->classification == WC_DROPDOWN){ int left = x - w->x; if (left < 0); //6e8fb7; @@ -623,20 +625,21 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)); //6e8fb7; // _dropdown_no_columns - int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; + dropdown_index = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; // _dropdown_no_items - if (item_no >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; + if (dropdown_index >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; // _dropdown_unknown?? highlighted? - if (item_no < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << item_no)); //6e8fb7; + if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index)); //6e8fb7; - if (gDropdownItemsFormat[item_no] == 0); //6e8fb7; + if (gDropdownItemsFormat[dropdown_index] == 0); //6e8fb7; } else{ //6e8ed3 if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)); - //6e8fb7 ax = -1 + //6e8fb7 + dropdown_index = -1; if (RCT2_GLOBAL(0x9DE518, uint32) & 2){ if (!(RCT2_GLOBAL(0x9DE518, uint32) & 4)){ RCT2_GLOBAL(0x9DE518, uint32) |= (1 << 2); @@ -660,13 +663,10 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(0x9DE536, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - window_event_helper(w, widgetIndex, WE_DROPDOWN); - - //6e8fb7 - window_close_by_id(WC_DROPDOWN, 0); + RCT2_CALLPROC_X(temp_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8), (int)w, 0, 0); } - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); - return; + //6e8fb7 + window_close_by_id(WC_DROPDOWN, 0); } if (state == 3) return; From e7d2ec359459d5594bdfcc063e4ed662da1cfe38 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 08:29:27 +0100 Subject: [PATCH 08/10] Added new function to window_dropdown. Cleaned up input code --- src/input.c | 86 +++++++++---------------------------------- src/window_dropdown.c | 30 +++++++++++++++ src/window_dropdown.h | 1 + 3 files changed, 49 insertions(+), 68 deletions(-) diff --git a/src/input.c b/src/input.c index 2b11d0ecfe..6a8c2d7fde 100644 --- a/src/input.c +++ b/src/input.c @@ -598,47 +598,21 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - //6e8e04 if (w) { int dropdown_index = 0; if (w->classification == WC_DROPDOWN){ - int left = x - w->x; - if (left < 0); //6e8fb7; - if (left >= w->width); //6e8fb7; - - int top = y - w->y - 2; - if (top < 0); //6e8fb7; - - // _dropdown_item_height - int row_no = top / RCT2_GLOBAL(0x9DED3C, uint8); - // _dropdown_no_items - if (row_no >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; - - left -= 2; - if (left < 0); //6e8fb7; - // _dropdown_item_width - int column_no = left / RCT2_GLOBAL(0x009DED40, sint32); - // _dropdown_no_columns - if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)); //6e8fb7; - // _dropdown_no_rows - if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)); //6e8fb7; - - // _dropdown_no_columns - dropdown_index = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; - // _dropdown_no_items - if (dropdown_index >= RCT2_GLOBAL(0x009DEBA0, sint16)); //6e8fb7; + dropdown_index = dropdown_index_from_point(x, y, w); + if (dropdown_index == -1)goto dropdown_cleanup; // _dropdown_unknown?? highlighted? - if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index)); //6e8fb7; + if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))goto dropdown_cleanup; - if (gDropdownItemsFormat[dropdown_index] == 0); //6e8fb7; + if (gDropdownItemsFormat[dropdown_index] == 0)goto dropdown_cleanup; } else{ - //6e8ed3 - - if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)); - //6e8fb7 + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) + goto dropdown_cleanup; dropdown_index = -1; if (RCT2_GLOBAL(0x9DE518, uint32) & 2){ if (!(RCT2_GLOBAL(0x9DE518, uint32) & 4)){ @@ -647,9 +621,8 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w } } } - //6e8f1a rct_window* temp_w = window_find_by_id(cursor_w_class, cursor_w_number); - if (!temp_w);//6e8fb7 + if (!temp_w) goto dropdown_cleanup; window_close_by_id(WC_DROPDOWN, 0); temp_w = window_find_by_id(cursor_w_class, cursor_w_number); @@ -659,20 +632,20 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w } RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; - RCT2_GLOBAL(0x9DE53C, uint16) = 0; - RCT2_GLOBAL(0x9DE536, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); RCT2_CALLPROC_X(temp_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8), (int)w, 0, 0); } - //6e8fb7 + dropdown_cleanup: window_close_by_id(WC_DROPDOWN, 0); } if (state == 3) return; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; - RCT2_GLOBAL(0x9DE53C, uint16) = 0; - RCT2_GLOBAL(0x9DE536,uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); @@ -694,7 +667,6 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w return; } - //6e9103 RCT2_GLOBAL(0x9DE528, uint16) = 0; if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) != 5){ // Hold down widget and drag outside of area?? @@ -709,39 +681,17 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w if (w->classification != WC_DROPDOWN) return; - int left = x - w->x; - if (left < 0) return; - if (left >= w->width) return; - - int top = y - w->y - 2; - if (top < 0) return; - - // _dropdown_item_height - int row_no = top / RCT2_GLOBAL(0x9DED3C,uint8); - // _dropdown_no_items - if (row_no >= RCT2_GLOBAL(0x009DEBA0, sint16)) return; - - left -= 2; - if (left < 0) return; - // _dropdown_item_width - int column_no = left / RCT2_GLOBAL(0x009DED40, sint32); - // _dropdown_no_columns - if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)) return; - // _dropdown_no_rows - if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)) return; - - // _dropdown_no_columns - int item_no = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; - // _dropdown_no_items - if (item_no >= RCT2_GLOBAL(0x009DEBA0, sint16)) return; + int dropdown_index = dropdown_index_from_point(x, y, w); + + if (dropdown_index == -1) return; // _dropdown_unknown?? highlighted? - if (item_no < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << item_no))return; + if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))return; - if (gDropdownItemsFormat[item_no] == 0)return; + if (gDropdownItemsFormat[dropdown_index] == 0)return; // _dropdown_highlighted_index - RCT2_GLOBAL(0x009DEBA2, sint16) = item_no; + RCT2_GLOBAL(0x009DEBA2, sint16) = dropdown_index; window_invalidate_by_id(WC_DROPDOWN, 0); } diff --git a/src/window_dropdown.c b/src/window_dropdown.c index c7298e9bf2..eba3061ed0 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -349,3 +349,33 @@ static void window_dropdown_paint() } } } + +/* New function based on 6e914e + * returns -1 if index is invalid + */ +int dropdown_index_from_point(int x, int y, rct_window* w){ + int top = y - w->y - 2; + if (top < 0) return -1; + + int left = x - w->x; + if (left >= w->width) return -1; + left -= 2; + if (left < 0) return -1; + + // _dropdown_item_width + int column_no = left / RCT2_GLOBAL(0x009DED40, sint32); + // _dropdown_no_columns + if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)) return -1; + + // _dropdown_item_height + int row_no = top / RCT2_GLOBAL(0x9DED3C, uint8); + // _dropdown_no_rows + if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)) return -1; + + // _dropdown_no_columns + int dropdown_index = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no; + // _dropdown_no_items + if (dropdown_index >= RCT2_GLOBAL(0x009DEBA0, sint16)) return -1; + + return dropdown_index; +} diff --git a/src/window_dropdown.h b/src/window_dropdown.h index b98598abac..9a63f80bb4 100644 --- a/src/window_dropdown.h +++ b/src/window_dropdown.h @@ -35,5 +35,6 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width); void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns); void window_dropdown_close(); +int dropdown_index_from_point(int x, int y, rct_window* w); #endif \ No newline at end of file From b282908bbd63fce68b21f362020e6bd6738bdeae Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 08:33:22 +0100 Subject: [PATCH 09/10] Fix compile warnings. --- src/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input.c b/src/input.c index 6a8c2d7fde..292199e706 100644 --- a/src/input.c +++ b/src/input.c @@ -633,7 +633,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); RCT2_CALLPROC_X(temp_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8), (int)w, 0, 0); @@ -645,7 +645,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16); cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); From 919da774788eca87bdbaf2b6dcf014239c26ef0c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 08:58:46 +0100 Subject: [PATCH 10/10] More cleanup of code. Reverted to old dropdown format --- src/input.c | 70 ++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/input.c b/src/input.c index 292199e706..67bee3606e 100644 --- a/src/input.c +++ b/src/input.c @@ -557,22 +557,23 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(0x1420054, uint16) = x; RCT2_GLOBAL(0x1420056, uint16) = y; - rct_window* cursor_w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber)); + rct_windowclass cursor_w_class; + rct_windownumber cursor_w_number; + cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); + cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + int cursor_widgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32); + + rct_window* cursor_w = window_find_by_id(cursor_w_class, cursor_w_number); if (!cursor_w){ RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0; return; } - rct_windowclass cursor_w_class; - rct_windownumber cursor_w_number; + switch (state){ case 0: - { - cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); - cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - - if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) + if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) @@ -591,13 +592,9 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(0x9DE518, uint32) |= 1; widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex); return; - } - break; case 3: case 2: if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){ - cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); - cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); if (w) { int dropdown_index = 0; @@ -608,10 +605,11 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w // _dropdown_unknown?? highlighted? if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))goto dropdown_cleanup; - if (gDropdownItemsFormat[dropdown_index] == 0)goto dropdown_cleanup; + // gDropdownItemsFormat[dropdown_index] will not work until all windows that use dropdown decompiled + if (RCT2_ADDRESS(0x9DEBA4, uint16)[dropdown_index] == 0)goto dropdown_cleanup; } else{ - if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) goto dropdown_cleanup; dropdown_index = -1; if (RCT2_GLOBAL(0x9DE518, uint32) & 2){ @@ -621,22 +619,20 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w } } } - rct_window* temp_w = window_find_by_id(cursor_w_class, cursor_w_number); - if (!temp_w) goto dropdown_cleanup; window_close_by_id(WC_DROPDOWN, 0); - temp_w = window_find_by_id(cursor_w_class, cursor_w_number); + cursor_w = window_find_by_id(cursor_w_class, cursor_w_number); if (RCT2_GLOBAL(0x9DE518, uint32) & 1){ RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE; - widget_invalidate(cursor_w_class, cursor_w_number, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8)); + widget_invalidate(cursor_w_class, cursor_w_number, cursor_widgetIndex); } RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16); - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); - RCT2_CALLPROC_X(temp_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8), (int)w, 0, 0); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = cursor_widgetIndex; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = cursor_w_class; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = cursor_w_number; + RCT2_CALLPROC_X(cursor_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, cursor_widgetIndex, (int)cursor_w, 0, 0); } dropdown_cleanup: window_close_by_id(WC_DROPDOWN, 0); @@ -645,16 +641,14 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16); - cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); - cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = cursor_widgetIndex; if (!w) break; int mid_point_x = (widget->left + widget->right) / 2 + w->x; sound_play_panned(5, mid_point_x); - if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32)) + if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) @@ -662,7 +656,6 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex); window_event_helper(w, widgetIndex, WE_MOUSE_UP); - return; default: return; } @@ -672,27 +665,28 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w // Hold down widget and drag outside of area?? if (RCT2_GLOBAL(0x9DE518, uint32) & 1){ RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE; - widget_invalidate(cursor_w_class, cursor_w_number, RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint8)); + widget_invalidate(cursor_w_class, cursor_w_number, cursor_widgetIndex); } return; } if (!w) return; - if (w->classification != WC_DROPDOWN) return; + if (w->classification == WC_DROPDOWN){ + int dropdown_index = dropdown_index_from_point(x, y, w); - int dropdown_index = dropdown_index_from_point(x, y, w); - - if (dropdown_index == -1) return; + if (dropdown_index == -1) return; - // _dropdown_unknown?? highlighted? - if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))return; + // _dropdown_unknown?? highlighted? + if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))return; - if (gDropdownItemsFormat[dropdown_index] == 0)return; + // gDropdownItemsFormat[dropdown_index] will not work until all windows that use dropdown decompiled + if (RCT2_ADDRESS(0x9DEBA4, uint16)[dropdown_index] == 0)return; - // _dropdown_highlighted_index - RCT2_GLOBAL(0x009DEBA2, sint16) = dropdown_index; - window_invalidate_by_id(WC_DROPDOWN, 0); + // _dropdown_highlighted_index + RCT2_GLOBAL(0x009DEBA2, sint16) = dropdown_index; + window_invalidate_by_id(WC_DROPDOWN, 0); + } } /**