From d7212c1b1455a67119341cede0bc311e38f1324c Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 16 Dec 2014 01:24:13 +0000 Subject: [PATCH] implement inventions list window, fixes #630 --- data/language/english_uk.txt | 4 +- src/drawing/string.c | 22 +- src/input.c | 18 +- src/input.h | 4 + src/interface/widget.c | 2 +- src/interface/window.h | 50 +- src/localisation/language.c | 2 +- src/localisation/string_ids.h | 5 + src/management/research.h | 1 + src/windows/editor_bottom_toolbar.c | 4 +- src/windows/editor_inventions_list.c | 878 ++++++++++++++++++++++++- src/windows/editor_objective_options.c | 8 +- src/windows/guest.c | 8 +- src/windows/guest_list.c | 8 +- src/windows/new_ride.c | 8 +- src/windows/news.c | 4 +- src/windows/ride_list.c | 8 +- src/windows/scenery.c | 8 +- src/windows/shortcut_keys.c | 8 +- src/windows/staff_list.c | 8 +- src/windows/title_scenarioselect.c | 8 +- src/windows/track_list.c | 8 +- 22 files changed, 1001 insertions(+), 73 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 4e88956d80..42a9e4cfc7 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -2752,9 +2752,9 @@ STR_2746 :] STR_2747 :{ENDQUOTES} STR_2748 :Bar STR_2749 :??? -STR_2750 :??? -STR_2751 :??? # New strings used in the cheats window previously these were ??? +STR_2750 :Move all items to top +STR_2751 :Move all items to bottom STR_2752 :Clear grass STR_2753 :Mowed grass STR_2754 :Water plants diff --git a/src/drawing/string.c b/src/drawing/string.c index 8080ae8afd..25bb526ed5 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -773,8 +773,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in int max_y = y; // - uint16* current_font_flags = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16); - uint16* current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16); + uint16 *current_font_flags = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16); + sint16 *current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16); uint8* palette_pointer = text_palette; @@ -802,10 +802,10 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in *current_font_flags = 0; if (*current_font_sprite_base < 0) { *current_font_flags |= 4; - if (*current_font_sprite_base != 0xFFFF) { + if (*current_font_sprite_base != -1) { *current_font_flags |= 8; } - *current_font_sprite_base = 0xE0; + *current_font_sprite_base = 224; } if (colour & (1 << 5)) { *current_font_flags |= 2; @@ -917,11 +917,11 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in break; case FORMAT_NEWLINE://Start New Line at set y lower max_x = x; - if (*current_font_sprite_base <= 0xE0) { + if (*current_font_sprite_base <= 224) { max_y += 10; break; } - else if (*current_font_sprite_base == 0x1C0) { + else if (*current_font_sprite_base == 448) { max_y += 6; break; } @@ -929,24 +929,24 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in break; case FORMAT_NEWLINE_SMALLER://Start New Line at set y lower max_x = x; - if (*current_font_sprite_base <= 0xE0) { + if (*current_font_sprite_base <= 224) { max_y += 5; break; } - else if (*current_font_sprite_base == 0x1C0) { + else if (*current_font_sprite_base == 448) { max_y += 3; break; } max_y += 9; break; case FORMAT_TINYFONT: - *current_font_sprite_base = 0x1C0; + *current_font_sprite_base = 448; break; case FORMAT_BIGFONT: - *current_font_sprite_base = 0x2A0; + *current_font_sprite_base = 672; break; case FORMAT_MEDIUMFONT: - *current_font_sprite_base = 0xE0; + *current_font_sprite_base = 224; break; case FORMAT_SMALLFONT: *current_font_sprite_base = 0; diff --git a/src/input.c b/src/input.c index 3d1b67ce1f..da3ca92ffe 100644 --- a/src/input.c +++ b/src/input.c @@ -70,7 +70,6 @@ void game_handle_key_scroll(); static void input_widget_left(int x, int y, rct_window *w, int widgetIndex); void input_state_widget_pressed(int x, int y, int state, int widgetIndex, rct_window* w, rct_widget* widget); void sub_6ED990(char cursor_id); -static void input_window_position_begin(rct_window *w, int widgetIndex, int x, int y); static void input_window_position_continue(rct_window *w, int lastX, int lastY, int newX, int newY); static void input_window_position_end(rct_window *w, int x, int y); static void input_window_resize_begin(rct_window *w, int widgetIndex, int x, int y); @@ -337,7 +336,7 @@ static void game_handle_input_mouse(int x, int y, int state) #pragma region Window positioning / resizing -static void input_window_position_begin(rct_window *w, int widgetIndex, int x, int y) +void input_window_position_begin(rct_window *w, int widgetIndex, int x, int y) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_POSITIONING_WINDOW; _dragX = x - w->x; @@ -349,7 +348,10 @@ static void input_window_position_begin(rct_window *w, int widgetIndex, int x, i static void input_window_position_continue(rct_window *w, int wdx, int wdy, int x, int y) { - window_move_and_snap(w, x - wdx, y - wdy, gGeneral_config.window_snap_proximity); + int snapProximity; + + snapProximity = w->flags & WF_NO_SNAPPING ? 0 : gGeneral_config.window_snap_proximity; + window_move_and_snap(w, x - wdx, y - wdy, snapProximity); } static void input_window_position_end(rct_window *w, int x, int y) @@ -359,7 +361,7 @@ static void input_window_position_end(rct_window *w, int x, int y) RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = _dragWindowClass; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = _dragWindowNumber; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = _dragWidgetIndex; - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_MOVED], 0, 0, x, y, (int)w, 0, 0); } static void input_window_resize_begin(rct_window *w, int widgetIndex, int x, int y) @@ -479,7 +481,7 @@ static void input_scroll_begin(rct_window *w, int widgetIndex, int x, int y) RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SCROLL_ID, uint32) = scroll_id * sizeof(rct_scroll);//We do this because scroll id is not all decompiled RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SCROLL_ID, uint32), ebx, scroll_area, scroll_id, (int)w, (int)widget, 0); if (scroll_area == SCROLL_PART_VIEW){ - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], scroll_id / sizeof(rct_scroll), ebx, eax, ebx, (int)w, (int)widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], scroll_id, ebx, eax, ebx, (int)w, (int)widget, 0); return; } @@ -866,11 +868,11 @@ void process_mouse_over(int x, int y) edx = y; eax = widgetId; ebx = 0xFFFFFFFF; + esi = (int)window; edi = (int)&window->widgets[widgetId]; - RCT2_CALLFUNC_X(window->event_handlers[WE_UNKNOWN_17], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - if (ebx == 0xFFFFFFFF) - { + RCT2_CALLFUNC_X(window->event_handlers[WE_CURSOR], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if (ebx == 0xFFFFFFFF) { cursorId = CURSOR_ARROW; break; } diff --git a/src/input.h b/src/input.h index 80f75ad920..e28adf0b09 100644 --- a/src/input.h +++ b/src/input.h @@ -21,6 +21,8 @@ #ifndef _INPUT_H_ #define _INPUT_H_ +#include "interface/window.h" + enum { INPUT_FLAG_WIDGET_PRESSED = (1 << 0), @@ -50,4 +52,6 @@ void game_handle_keyboard_input(); void store_mouse_input(int state); +void input_window_position_begin(rct_window *w, int widgetIndex, int x, int y); + #endif \ No newline at end of file diff --git a/src/interface/widget.c b/src/interface/widget.c index b4c6ac0072..1245888807 100644 --- a/src/interface/widget.c +++ b/src/interface/widget.c @@ -830,7 +830,7 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget // Draw the scroll contents if (scroll_dpi.width > 0 && scroll_dpi.height > 0) - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, (int)w, (int)&scroll_dpi, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], scrollIndex, 0, 0, 0, (int)w, (int)&scroll_dpi, 0); } static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour) diff --git a/src/interface/window.h b/src/interface/window.h index 525ef9f608..4b33bb2746 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -272,8 +272,8 @@ typedef enum { WE_UNKNOWN_14 = 20, WE_UNKNOWN_15 = 21, // scroll mouse move? WE_TOOLTIP = 22, - WE_UNKNOWN_17 = 23, // tooltip related - WE_UNKNOWN_18 = 24, + WE_CURSOR = 23, + WE_MOVED = 24, WE_INVALIDATE = 25, WE_PAINT = 26, WE_SCROLL_PAINT = 27, @@ -302,6 +302,8 @@ typedef enum { WF_10 = (1 << 10), WF_WHITE_BORDER_ONE = (1 << 12), WF_WHITE_BORDER_MASK = (1 << 12) | (1 << 13), + + WF_NO_SNAPPING = (1 << 15) } WINDOW_FLAGS; enum SCROLL_FLAGS { @@ -386,6 +388,7 @@ enum { WC_MAP_TOOLTIP = 41, WC_EDITOR_OBJECT_SELECTION = 42, WC_EDITOR_INVENTION_LIST = 43, + WC_EDITOR_INVENTION_LIST_DRAG = 44, WC_EDITOR_SCENARIO_OPTIONS = 45, WC_EDTIOR_OBJECTIVE_OPTIONS = 46, WC_47, @@ -575,7 +578,12 @@ int window_can_resize(rct_window *w); __asm mov w, esi \ __asm mov text, edi - #define window_scrollmouse_get_registers(w, x, y) \ + #define window_scroll_get_registers(w, i) \ + __asm mov i, ax \ + __asm mov w, esi + + #define window_scrollmouse_get_registers(w, i, x, y) \ + __asm mov i, ax \ __asm mov x, cx \ __asm mov y, dx \ __asm mov w, esi @@ -596,9 +604,24 @@ int window_can_resize(rct_window *w); __asm mov w, esi \ __asm mov dpi, edi + #define window_scrollpaint_get_registers(w, dpi, i) \ + __asm mov i, ax \ + __asm mov w, esi \ + __asm mov dpi, edi + #define window_scrollsize_set_registers(width, height) \ __asm mov ecx, width \ __asm mov edx, height + + #define window_cursor_get_registers(w, widgetIndex, x, y) \ + __asm mov widgetIndex, ax \ + __asm mov x, cx \ + __asm mov y, dx \ + __asm mov w, esi + + #define window_cursor_set_registers(cursorId) \ + __asm mov ebx, cursorId + #else #define window_get_register(w) \ __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); @@ -618,7 +641,12 @@ int window_can_resize(rct_window *w); __asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \ __asm__ ( "mov %[text], edi " : [text] "+m" (text) ); - #define window_scrollmouse_get_registers(w, x, y) \ + #define window_scroll_get_registers(w, i) \ + __asm__ ( "mov %["#i"], ax " : [i] "+m" (i) ); \ + __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); + + #define window_scrollmouse_get_registers(w, i, x, y) \ + __asm__ ( "mov %["#i"], ax " : [i] "+m" (i) ); \ __asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \ __asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \ __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); @@ -639,9 +667,23 @@ int window_can_resize(rct_window *w); __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); \ __asm__ ( "mov %["#dpi"], edi " : [dpi] "+m" (dpi) ); + #define window_scrollpaint_get_registers(w, dpi, i) \ + __asm__ ( "mov %["#i"], ax " : [i] "+m" (i) ); \ + __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); \ + __asm__ ( "mov %["#dpi"], edi " : [dpi] "+m" (dpi) ); + #define window_scrollsize_set_registers(width, height) \ __asm__ ( "mov ecx, %[width] " : [width] "+m" (width) ); \ __asm__ ( "mov edx, %[height] " : [height] "+m" (height) ); + + #define window_cursor_get_registers(w, widgetIndex, x, y) \ + __asm__ ( "mov %["#widgetIndex"], ax " : [widgetIndex] "+m" (widgetIndex) ); \ + __asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \ + __asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \ + __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); + + #define window_cursor_set_registers(cursorId) \ + __asm__ ( "mov ebx, %[cursorId] " : [cursorId] "+m" (cursorId) ); #endif #endif diff --git a/src/localisation/language.c b/src/localisation/language.c index f487025676..690fa6db47 100644 --- a/src/localisation/language.c +++ b/src/localisation/language.c @@ -71,7 +71,7 @@ static int utf8_get_next(char *char_ptr, char **nextchar_ptr) result = ((char_ptr[0] & 0x1F) << 6) | (char_ptr[1] & 0x3F); numBytes = 2; } else { - numBytes++; + numBytes = 1; } if (nextchar_ptr != NULL) diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 8e7ceb56b5..b5cf2a7238 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1194,6 +1194,11 @@ enum { STR_INVALID_SELECTION_OF_OBJECTS = 3180, + STR_INVENTION_LIST = 3195, + + STR_RANDOM_SHUFFLE = 3199, + STR_RANDOM_SHUFFLE_TIP = 3200, + STR_OBJECT_SELECTION_STEP = 3201, STR_LANDSCAPE_EDITOR_STEP = 3202, STR_INVENTION_LIST_SET_UP_STEP = 3203, diff --git a/src/management/research.h b/src/management/research.h index f2789fd151..0a07d36d1c 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -31,6 +31,7 @@ typedef struct { #define RESEARCHED_ITEMS_SEPERATOR -1 #define RESEARCHED_ITEMS_END -2 +#define RESEARCHED_ITEMS_END_2 -3 enum { RESEARCH_FUNDING_NONE, diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index 7c130fc3fb..8d0a14fcc2 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -179,7 +179,7 @@ void window_editor_bottom_toolbar_jump_back_to_landscape_editor() { */ void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() { window_close_all(); - RCT2_CALLPROC_EBPSAFE(0x00684E04); // open invention list window + window_editor_inventions_list_open(); g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; gfx_invalidate_screen(); } @@ -223,7 +223,7 @@ void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() { if (!(flags & 0x100)) { window_close_all(); - RCT2_CALLPROC_EBPSAFE(0x00684E04); + window_editor_inventions_list_open(); g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP; } else { window_error_open(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16)); diff --git a/src/windows/editor_inventions_list.c b/src/windows/editor_inventions_list.c index a2353dbc0c..851f206f36 100644 --- a/src/windows/editor_inventions_list.c +++ b/src/windows/editor_inventions_list.c @@ -19,6 +19,385 @@ *****************************************************************************/ #include "../addresses.h" +#include "../input.h" +#include "../interface/widget.h" +#include "../interface/window.h" +#include "../localisation/localisation.h" +#include "../management/research.h" +#include "../object.h" +#include "../platform/osinterface.h" +#include "../world/scenery.h" + +#pragma region Widgets + +enum { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_PAGE_BACKGROUND, + WIDX_TAB_1, + WIDX_PRE_RESEARCHED_SCROLL, + WIDX_RESEARCH_ORDER_SCROLL, + WIDX_PREVIEW, + WIDX_RANDOM_SHUFFLE, + WIDX_MOVE_ITEMS_TO_BOTTOM, + WIDX_MOVE_ITEMS_TO_TOP +}; + +static rct_widget window_editor_inventions_list_widgets[] = { + { WWT_FRAME, 0, 0, 599, 0, 399, STR_NONE, STR_NONE }, + { WWT_CAPTION, 0, 1, 598, 1, 14, STR_INVENTION_LIST, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_RESIZE, 1, 0, 599, 43, 399, STR_NONE, STR_NONE }, + { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, STR_NONE }, + { WWT_SCROLL, 1, 4, 371, 56, 175, 2, STR_NONE }, + { WWT_SCROLL, 1, 4, 371, 189, 396, 2, STR_NONE }, + { WWT_FLATBTN, 1, 431, 544, 106, 219, 0xFFFFFFFF, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 375, 594, 385, 396, STR_RANDOM_SHUFFLE, STR_RANDOM_SHUFFLE_TIP }, + { WWT_DROPDOWN_BUTTON, 1, 375, 594, 372, 383, 2751, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 375, 594, 359, 370, 2750, STR_NONE }, + { WIDGETS_END } +}; + +static rct_widget window_editor_inventions_list_drag_widgets[] = { + { WWT_IMGBTN, 0, 0, 149, 0, 13, STR_NONE, STR_NONE }, + { WIDGETS_END } +}; + +#pragma endregion + +#pragma region Events + +static void window_editor_inventions_list_emptysub() { } + +static void window_editor_inventions_list_close(); +static void window_editor_inventions_list_mouseup(); +static void window_editor_inventions_list_update(rct_window *w); +static void window_editor_inventions_list_scrollgetheight(); +static void window_editor_inventions_list_scrollmousedown(); +static void window_editor_inventions_list_scrollmouseover(); +static void window_editor_inventions_list_tooltip(); +static void window_editor_inventions_list_cursor(); +static void window_editor_inventions_list_invalidate(); +static void window_editor_inventions_list_paint(); +static void window_editor_inventions_list_scrollpaint(); + +static void window_editor_inventions_list_drag_cursor(); +static void window_editor_inventions_list_drag_moved(); +static void window_editor_inventions_list_drag_paint(); + +// 0x0098177C +static void* window_editor_inventions_list_events[] = { + window_editor_inventions_list_close, + window_editor_inventions_list_mouseup, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_update, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_scrollgetheight, + window_editor_inventions_list_scrollmousedown, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_scrollmouseover, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_tooltip, + window_editor_inventions_list_cursor, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_invalidate, + window_editor_inventions_list_paint, + window_editor_inventions_list_scrollpaint +}; + +// 0x0098177C +static void* window_editor_inventions_list_drag_events[] = { + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_drag_cursor, + window_editor_inventions_list_drag_moved, + window_editor_inventions_list_emptysub, + window_editor_inventions_list_drag_paint, + window_editor_inventions_list_emptysub +}; + +#pragma endregion + +rct_research_item *_editorInventionsListDraggedItem; + +#define WindowHighlightedItem(w) *((rct_research_item**)&(w->var_494)) + +static void window_editor_inventions_list_drag_open(rct_research_item *researchItem); + +static int research_item_is_always_researched(rct_research_item *researchItem) +{ + return (researchItem->entryIndex & 0x60000000) != 0; +} + +/** + * + * rct2: 0x00685901 + */ +static void sub_685901() +{ + RCT2_CALLPROC_EBPSAFE(0x00685901); +} + +/** + * + * rct2: 0x00685A79 + */ +static void sub_685A79() +{ + RCT2_CALLPROC_EBPSAFE(0x00685A79); +} + +/** + * + * rct2: 0x0068563D + */ +static rct_string_id research_item_get_name(uint32 researchItem) +{ + rct_ride_type *rideEntry; + rct_scenery_set_entry *sceneryEntry; + + if (researchItem < 0x10000) { + sceneryEntry = g_scenerySetEntries[researchItem & 0xFF]; + if (sceneryEntry == NULL || sceneryEntry == (rct_scenery_set_entry*)0xFFFFFFFF) + return 0; + + return sceneryEntry->name; + } + + rideEntry = GET_RIDE_ENTRY(researchItem & 0xFF); + if (rideEntry == NULL || rideEntry == (rct_ride_type*)0xFFFFFFFF) + return 0; + + if (rideEntry->var_008 & 0x1000) + return rideEntry->name; + + return ((researchItem >> 8) & 0xFF) + 2; +} + +/** + * + * rct2: 0x00685A93 + */ +static void research_items_shuffle() +{ + rct_research_item *researchItem, *researchOrderBase, researchItemTemp; + int i, ri, numNonResearchedItems; + + // Skip pre-researched items + for (researchItem = gResearchItems; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) {} + researchItem++; + researchOrderBase = researchItem; + + // Count non pre-researched items + numNonResearchedItems = 0; + for (; researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++) + numNonResearchedItems++; + + // Shuffle list + for (i = 0; i < numNonResearchedItems; i++) { + ri = rand() % numNonResearchedItems; + if (ri == i) + continue; + + researchItemTemp = researchOrderBase[i]; + researchOrderBase[i] = researchOrderBase[ri]; + researchOrderBase[ri] = researchItemTemp; + } + + // RCT2_CALLPROC_EBPSAFE(0x00685A93); +} + +static void research_items_make_all_unresearched() +{ + rct_research_item *researchItem, *nextResearchItem, researchItemTemp; + + int sorted; + do { + sorted = 1; + for (researchItem = gResearchItems; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) { + if (research_item_is_always_researched(researchItem)) + continue; + + nextResearchItem = researchItem + 1; + if (nextResearchItem->entryIndex == RESEARCHED_ITEMS_SEPERATOR || research_item_is_always_researched(nextResearchItem)) { + // Bubble up always researched item or seperator + researchItemTemp = *researchItem; + *researchItem = *nextResearchItem; + *nextResearchItem = researchItemTemp; + sorted = 0; + + if (researchItem->entryIndex == RESEARCHED_ITEMS_SEPERATOR) + break; + } + } + } while (!sorted); +} + +static void research_items_make_all_researched() +{ + rct_research_item *researchItem, researchItemTemp; + + // Find seperator + for (researchItem = gResearchItems; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) { } + + // Move seperator below all items + for (; (researchItem + 1)->entryIndex != RESEARCHED_ITEMS_END; researchItem++) { + // Swap seperator with research item + researchItemTemp = *researchItem; + *researchItem = *(researchItem + 1); + *(researchItem + 1) = researchItemTemp; + } +} + +/** + * + * rct2: 0x006855E7 + */ +static void move_research_item(rct_research_item *beforeItem) +{ + rct_window *w; + rct_research_item *researchItem, draggedItem; + + if (_editorInventionsListDraggedItem == beforeItem - 1) + return; + + // Back up the dragged item + draggedItem = *_editorInventionsListDraggedItem; + + // Remove dragged item from list + researchItem = _editorInventionsListDraggedItem; + do { + *researchItem = *(researchItem + 1); + researchItem++; + } while ((researchItem - 1)->entryIndex != RESEARCHED_ITEMS_END); + + if (beforeItem > _editorInventionsListDraggedItem) + beforeItem--; + + // Add dragged item to list + do { + *researchItem = *(researchItem - 1); + researchItem--; + } while (researchItem != beforeItem); + + *researchItem = draggedItem; + + w = window_find_by_class(WC_EDITOR_INVENTION_LIST); + if (w != NULL) { + WindowHighlightedItem(w) = NULL; + window_invalidate(w); + } +} + +/** + * + * rct2: 0x0068558E + */ +static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y(int scrollIndex, int y) +{ + rct_research_item *researchItem; + + researchItem = gResearchItems; + + if (scrollIndex != 0) { + // Skip pre-researched items + for (; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) { } + researchItem++; + } + + for (; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR || researchItem->entryIndex == RESEARCHED_ITEMS_END; researchItem++) { + y -= 10; + if (y < 0) + return researchItem; + } + + return NULL; +} + +/** + * + * rct2: 0x006855BB + */ +static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y_include_seps(int scrollIndex, int y) +{ + rct_research_item *researchItem; + + researchItem = gResearchItems; + + if (scrollIndex != 0) { + // Skip pre-researched items + for (; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) { } + researchItem++; + } + + for (; researchItem->entryIndex != RESEARCHED_ITEMS_END_2; researchItem++) { + y -= 10; + if (y < 0) + return researchItem; + } + + return researchItem - 1; +} + +static rct_research_item *get_research_item_at(int x, int y) +{ + rct_window *w; + rct_widget *widget; + int scrollY, outX, outY, outScrollArea, outScrollId; + short widgetIndex; + + w = window_find_by_class(WC_EDITOR_INVENTION_LIST); + if (w != NULL && w->x <= x && w->y < y && w->x + w->width > x && w->y + w->height > y) { + widgetIndex = window_find_widget_from_point(w, x, y); + widget = &w->widgets[widgetIndex]; + if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL) { + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32) = widgetIndex; + widget_scroll_get_part(w, widget, x, y, &outX, &outY, &outScrollArea, &outScrollId); + if (outScrollArea == SCROLL_PART_VIEW) { + outScrollId = outScrollId == 0 ? 0 : 1; + + scrollY = y - (w->y + widget->top) + w->scrolls[outScrollId].v_top + 5; + return window_editor_inventions_list_get_item_from_scroll_y_include_seps(outScrollId, scrollY); + } + } + } + + return NULL; +} /** * @@ -26,5 +405,500 @@ */ void window_editor_inventions_list_open() { - RCT2_CALLPROC_EBPSAFE(0x00684E04); -} \ No newline at end of file + // RCT2_CALLPROC_EBPSAFE(0x00684E04); return; + + rct_window *w; + + w = window_bring_to_front_by_class(WC_EDITOR_INVENTION_LIST); + if (w != NULL) + return; + + sub_685901(); + + w = window_create( + (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 600) / 2, + max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 400) / 2), + 600, + 400, + (uint32*)window_editor_inventions_list_events, + WC_EDITOR_INVENTION_LIST, + WF_2 + ); + w->widgets = window_editor_inventions_list_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_TAB_1) | + (1 << WIDX_RANDOM_SHUFFLE) | + (1 << WIDX_MOVE_ITEMS_TO_BOTTOM) | + (1 << WIDX_MOVE_ITEMS_TO_TOP); + window_init_scroll_widgets(w); + w->var_4AE = 0; + w->selected_tab = 0; + WindowHighlightedItem(w) = NULL; + _editorInventionsListDraggedItem = NULL; + w->colours[0] = 4; + w->colours[1] = 1; + w->colours[2] = 1; +} + +/** + * + * rct2: 0x006853D2 + */ +static void window_editor_inventions_list_close() +{ + sub_685A79(); +} + +/** + * + * rct2: 0x0068521B + */ +static void window_editor_inventions_list_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_RANDOM_SHUFFLE: + research_items_shuffle(); + window_invalidate(w); + break; + case WIDX_MOVE_ITEMS_TO_TOP: + research_items_make_all_researched(); + window_invalidate(w); + break; + case WIDX_MOVE_ITEMS_TO_BOTTOM: + research_items_make_all_unresearched(); + window_invalidate(w); + break; + } +} + +/** + * + * rct2: 0x00685392 + */ +static void window_editor_inventions_list_update(rct_window *w) +{ + w->frame_no++; + window_event_invalidate_call(w); + widget_invalidate(w, WIDX_TAB_1); + + if (_editorInventionsListDraggedItem == NULL) + return; + + if (window_find_by_class(WC_EDITOR_INVENTION_LIST_DRAG) != NULL) + return; + + _editorInventionsListDraggedItem = NULL; + window_invalidate(w); +} + +/** + * + * rct2: 0x00685239 + */ +static void window_editor_inventions_list_scrollgetheight() +{ + rct_window *w; + short scrollIndex; + rct_research_item *researchItem; + int width, height; + + window_scroll_get_registers(w, scrollIndex); + + width = 0; + height = 0; + + // Count / skip pre-researched items + for (researchItem = gResearchItems; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) + height += 10; + + if (scrollIndex == 1) { + researchItem++; + + // Count non pre-researched items + height = 0; + for (; researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++) + height += 10; + } + + window_scrollsize_set_registers(width, height); +} + +/** + * + * rct2: 0x006852D4 + */ +static void window_editor_inventions_list_scrollmousedown() +{ + rct_window *w; + rct_research_item *researchItem; + short scrollIndex, x, y; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, y); + if (researchItem == NULL) + return; + + if (researchItem->entryIndex < (uint32)-3 && research_item_is_always_researched(researchItem)) + return; + + window_invalidate(w); + window_editor_inventions_list_drag_open(researchItem); +} + +/** + * + * rct2: 0x00685275 + */ +static void window_editor_inventions_list_scrollmouseover() +{ + rct_window *w; + short scrollIndex, x, y; + rct_research_item *researchItem; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, y); + if (researchItem != WindowHighlightedItem(w)) { + WindowHighlightedItem(w) = researchItem; + window_invalidate(w); + } +} + +/** + * + * rct2: 0x0068526B + */ +static void window_editor_inventions_list_tooltip() +{ + RCT2_GLOBAL(0x013CE952, uint16) = 3159; +} + +/** + * + * rct2: 0x00685291 + */ +static void window_editor_inventions_list_cursor() +{ + rct_window *w; + rct_research_item *researchItem; + short widgetIndex, x, y; + int scrollIndex; + + window_cursor_get_registers(w, widgetIndex, x, y); + + if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL) { + scrollIndex = 0; + } else if (widgetIndex == WIDX_RESEARCH_ORDER_SCROLL) { + scrollIndex = 1; + } else { + window_cursor_set_registers(-1); + return; + } + + researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, y); + if (researchItem == NULL) + return; + + if (researchItem->entryIndex < (uint32)-3 && research_item_is_always_researched(researchItem)) { + window_cursor_set_registers(-1); + return; + } + + window_cursor_set_registers(CURSOR_HAND_OPEN); +} + +/** + * + * rct2: 0x00685392 + */ +static void window_editor_inventions_list_invalidate() +{ + rct_window *w; + + window_get_register(w); + + w->pressed_widgets |= 1 << WIDX_PREVIEW; + w->pressed_widgets |= 1 << WIDX_TAB_1; + + w->widgets[WIDX_CLOSE].type = + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR ? WWT_EMPTY : WWT_CLOSEBOX; +} + +/** + * + * rct2: 0x00684EE0 + */ +static void window_editor_inventions_list_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + rct_widget *widget; + rct_research_item *researchItem; + rct_string_id stringId; + int x, y, width; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + // Tab image + x = w->x + w->widgets[WIDX_TAB_1].left; + y = w->y + w->widgets[WIDX_TAB_1].top; + gfx_draw_sprite(dpi, 5327 + (w->frame_no / 2) % 8, x, y, 0); + + // Pre-researched items label + x = w->x + w->widgets[WIDX_PRE_RESEARCHED_SCROLL].left; + y = w->y + w->widgets[WIDX_PRE_RESEARCHED_SCROLL].top - 11; + gfx_draw_string_left(dpi, 3197, NULL, 0, x, y); + + // Research order label + x = w->x + w->widgets[WIDX_RESEARCH_ORDER_SCROLL].left; + y = w->y + w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top - 11; + gfx_draw_string_left(dpi, 3198, NULL, 0, x, y); + + // Preview background + widget = &w->widgets[WIDX_PREVIEW]; + gfx_fill_rect( + dpi, + w->x + widget->left + 1, + w->y + widget->top + 1, + w->x + widget->right - 1, + w->y + widget->bottom - 1, + RCT2_GLOBAL(0x0141FC44 + (w->colours[1] * 8), uint8) + ); + + researchItem = _editorInventionsListDraggedItem; + if (researchItem == NULL) + researchItem = WindowHighlightedItem(w); + if (researchItem == NULL) + return; + + // Preview image + x = w->x + ((widget->left + widget->right) / 2) + 1; + y = w->y + ((widget->top + widget->bottom) / 2) + 1; + + int objectEntryType = 7; + int eax = researchItem->entryIndex & 0xFFFFFF; + if (eax >= 0x10000) + objectEntryType = 0; + + void **entries = RCT2_GLOBAL(0x0098D97C + (objectEntryType * 8), void*); + void *entry = entries[researchItem->entryIndex & 0xFF]; + if (entry == NULL || entry == (void*)0xFFFFFFFF) + return; + + object_paint(objectEntryType, 3, objectEntryType, x, y, 0, (int)dpi, (int)entry); + + // Item name + x = w->x + ((widget->left + widget->right) / 2) + 1; + y = w->y + widget->bottom + 3; + width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6; + stringId = research_item_get_name(eax); + gfx_draw_string_centred_clipped(dpi, 1193, &stringId, 0, x, y, width); + y += 15; + + // Item category + x = w->x + w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right + 4; + stringId = 2253 + researchItem->category; + gfx_draw_string_left(dpi, 3196, &stringId, 0, x, y); +} + +/** + * + * rct2: 0x006850BD + */ +static void window_editor_inventions_list_scrollpaint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + short scrollIndex; + uint32 colour; + rct_research_item *researchItem; + int left, top, bottom, itemY, disableItemMovement; + sint32 researchItemEndMarker; + rct_string_id stringId; + char buffer[256], *ptr; + + window_scrollpaint_get_registers(w, dpi, scrollIndex); + + // Draw background + colour = RCT2_GLOBAL(0x0141FC48 + (w->colours[1] * 8), uint8); + colour = (colour << 24) | (colour << 16) | (colour << 8) | colour; + gfx_clear(dpi, colour); + + researchItem = gResearchItems; + + if (scrollIndex == 1) { + // Skip pre-researched items + for (; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR; researchItem++) { } + researchItem++; + researchItemEndMarker = RESEARCHED_ITEMS_END; + } else { + researchItemEndMarker = RESEARCHED_ITEMS_SEPERATOR; + } + + itemY = 0; + for (; researchItem->entryIndex != researchItemEndMarker; researchItem++, itemY += 10) { + if (itemY + 10 < dpi->y || itemY >= dpi->y + dpi->height) + continue; + + colour = 142; + if (WindowHighlightedItem(w) == researchItem) { + if (_editorInventionsListDraggedItem == NULL) { + // Highlight + top = itemY; + bottom = itemY + 9; + } else { + // Drop horizontal rule + top = itemY - 1; + bottom = itemY; + } + gfx_fill_rect(dpi, 0, top, w->width, bottom, 0x2000031); + + if (_editorInventionsListDraggedItem == NULL) + colour = 14; + } + + if (researchItem->entryIndex == RESEARCHED_ITEMS_SEPERATOR || researchItem->entryIndex == RESEARCHED_ITEMS_END) + continue; + + if (researchItem == _editorInventionsListDraggedItem) + continue; + + disableItemMovement = research_item_is_always_researched(researchItem); + stringId = research_item_get_name(researchItem->entryIndex & 0xFFFFFF); + + ptr = buffer; + if (!disableItemMovement) + *ptr++ = colour & 0xFF; + + format_string(ptr, stringId, NULL); + + if (disableItemMovement) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1; + if ((colour & 0xFF) == 14 && _editorInventionsListDraggedItem == NULL) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -2; + colour = 64 | w->colours[1]; + } else { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = 224; + colour = 0; + } + + left = 1; + top = itemY - 1; + gfx_draw_string(dpi, buffer, colour, left, top); + } +} + +#pragma region Drag item + +/** + * + * rct2: 0x006852F4 + */ +static void window_editor_inventions_list_drag_open(rct_research_item *researchItem) +{ + char buffer[256]; + int stringWidth; + rct_string_id stringId; + rct_window *w; + + window_close_by_class(WC_EDITOR_INVENTION_LIST_DRAG); + _editorInventionsListDraggedItem = researchItem; + + stringId = research_item_get_name(researchItem->entryIndex & 0xFFFFFF); + format_string(buffer, stringId, NULL); + stringWidth = gfx_get_string_width(buffer); + window_editor_inventions_list_drag_widgets[0].right = stringWidth; + + w = window_create( + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) - (stringWidth / 2), + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) - 7, + stringWidth, + 14, + (uint32*)window_editor_inventions_list_drag_events, + WC_EDITOR_INVENTION_LIST_DRAG, + WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_SNAPPING + ); + w->widgets = window_editor_inventions_list_drag_widgets; + w->colours[1] = 2; + input_window_position_begin( + w, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) + ); +} + +/** + * + * rct2: 0x0068549C + */ +static void window_editor_inventions_list_drag_cursor() +{ + rct_window *w, *inventionListWindow; + rct_research_item *researchItem; + short widgetIndex, x, y; + + window_cursor_get_registers(w, widgetIndex, x, y); + + inventionListWindow = window_find_by_class(WC_EDITOR_INVENTION_LIST); + if (inventionListWindow != NULL) { + researchItem = get_research_item_at(x, y); + if (researchItem != WindowHighlightedItem(inventionListWindow)) { + WindowHighlightedItem(inventionListWindow) = researchItem; + window_invalidate(inventionListWindow); + } + } + + window_cursor_set_registers(CURSOR_HAND_CLOSED); +} + +/** + * + * rct2: 0x00685412 + */ +static void window_editor_inventions_list_drag_moved() +{ + rct_window *w; + rct_research_item *researchItem; + short x, y, widgetIndex; + + window_cursor_get_registers(w, widgetIndex, x, y); + + researchItem = get_research_item_at(x, y); + if (researchItem != NULL) + move_research_item(researchItem); + + window_close(w); + _editorInventionsListDraggedItem = NULL; + window_invalidate_by_class(WC_EDITOR_INVENTION_LIST); +} + +/** + * + * rct2: 0x006853D9 + */ +static void window_editor_inventions_list_drag_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + rct_string_id stringId; + int x, y; + + window_paint_get_registers(w, dpi); + + x = w->x; + y = w->y + 2; + stringId = research_item_get_name(_editorInventionsListDraggedItem->entryIndex & 0xFFFFFF); + gfx_draw_string_left(dpi, 1193, &stringId, 32, x, y); +} + +#pragma endregion \ No newline at end of file diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index 2d9735d92e..7d3ae9863b 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -1157,10 +1157,10 @@ static void window_editor_objective_options_rides_scrollmousedown() { rct_ride *ride; rct_window *w; - short x, y; + short x, y, scrollIndex; int i; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); i = y / 12; if (i < 0 || i >= w->no_list_items) @@ -1178,10 +1178,10 @@ static void window_editor_objective_options_rides_scrollmousedown() static void window_editor_objective_options_rides_scrollmouseover() { rct_window *w; - short x, y; + short x, y, scrollIndex; int i; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); i = y / 12; if (i < 0 || i >= w->no_list_items) diff --git a/src/windows/guest.c b/src/windows/guest.c index b6bb841f4d..a267270916 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -1628,10 +1628,10 @@ void window_guest_rides_scroll_get_size(){ /* rct2: 0x006978CC */ void window_guest_rides_scroll_mouse_down(){ int index; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); index = y / 10; if (index >= w->no_list_items) return; @@ -1642,10 +1642,10 @@ void window_guest_rides_scroll_mouse_down(){ /* rct2: 0x0069789C */ void window_guest_rides_scroll_mouse_over(){ int index; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); index = y / 10; if (index >= w->no_list_items)return; diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index 1d9ec23465..cef844f839 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -405,11 +405,11 @@ static void window_guest_list_scrollgetsize() static void window_guest_list_scrollmousedown() { int i, spriteIndex; - short x, y; + short x, y, scrollIndex; rct_window *w; rct_peep *peep; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); switch (_window_guest_list_selected_tab) { case PAGE_INDIVIDUAL: @@ -453,10 +453,10 @@ static void window_guest_list_scrollmousedown() static void window_guest_list_scrollmouseover() { int i; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); i = y / (_window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 10 : 21); i += _window_guest_list_selected_page * 3173; diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index a05f4277e3..e699f4e293 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -652,11 +652,11 @@ static void window_new_ride_scrollgetsize() */ static void window_new_ride_scrollmousedown() { - short x, y; + short x, y, scrollIndex; rct_window *w; ride_list_item item; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); if (RCT2_GLOBAL(0x009DEA6E, uint8) != 0) return; @@ -679,11 +679,11 @@ static void window_new_ride_scrollmousedown() */ static void window_new_ride_scrollmouseover() { - short x, y; + short x, y, scrollIndex; rct_window *w; ride_list_item item; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); if (w->new_ride.selected_ride_id != -1) return; diff --git a/src/windows/news.c b/src/windows/news.c index 38948473e1..38007d3413 100644 --- a/src/windows/news.c +++ b/src/windows/news.c @@ -209,11 +209,11 @@ static void window_news_scrollgetsize() static void window_news_scrollmousedown() { int i, buttonIndex; - short x, y; + short x, y, scrollIndex; rct_window *w; rct_news_item *newsItems; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); buttonIndex = 0; newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); diff --git a/src/windows/ride_list.c b/src/windows/ride_list.c index d4e169c9bd..d989a5b0e6 100644 --- a/src/windows/ride_list.c +++ b/src/windows/ride_list.c @@ -341,10 +341,10 @@ static void window_ride_list_scrollgetsize() static void window_ride_list_scrollmousedown() { int index; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); index = y / 10; if (index >= w->no_list_items) @@ -361,10 +361,10 @@ static void window_ride_list_scrollmousedown() static void window_ride_list_scrollmouseover() { int index; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); index = y / 10; if (index >= w->no_list_items) diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 38ae82ddd9..ffd7e91930 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -756,10 +756,10 @@ short get_scenery_id_by_cursor_pos(short x, short y) { * rct2: 0x006E1C4A */ void window_scenery_scrollmousedown() { - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); short sceneryId = get_scenery_id_by_cursor_pos(x, y); if (sceneryId == -1) @@ -780,10 +780,10 @@ void window_scenery_scrollmousedown() { * rct2: 0x006E1BB8 */ void window_scenery_scrollmouseover() { - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); short sceneryId = get_scenery_id_by_cursor_pos(x, y); if (sceneryId != -1) { w->scenery.selected_scenery_id = sceneryId; diff --git a/src/windows/shortcut_keys.c b/src/windows/shortcut_keys.c index 4d86e965c6..42b482d716 100644 --- a/src/windows/shortcut_keys.c +++ b/src/windows/shortcut_keys.c @@ -182,10 +182,10 @@ static void window_shortcut_scrollgetsize() */ static void window_shortcut_scrollmousedown() { - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); int selected_item = y / 10; @@ -200,10 +200,10 @@ static void window_shortcut_scrollmousedown() */ static void window_shortcut_scrollmouseover() { - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); int selected_item = y / 10; diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index a173993971..b3dc14a47c 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -398,11 +398,11 @@ void window_staff_list_scrollgetsize() { */ void window_staff_list_scrollmousedown() { int i, spriteIndex; - short x, y; + short x, y, scrollIndex; rct_window *w; rct_peep *peep; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); i = y / 10; FOR_ALL_PEEPS(spriteIndex, peep) { @@ -427,10 +427,10 @@ void window_staff_list_scrollmousedown() { */ void window_staff_list_scrollmouseover() { int i; - short x, y; + short x, y, scrollIndex; rct_window *w; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); i = y / 10; if (i != RCT2_GLOBAL(RCT2_ADDRESS_STAFF_HIGHLIGHTED_INDEX, short)) { diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index acc362dc7d..ab4bc96da2 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -226,11 +226,11 @@ static void window_scenarioselect_scrollgetsize() static void window_scenarioselect_scrollmousedown() { int i; - short x, y; + short x, y, scrollIndex; rct_window *w; rct_scenario_basic *scenario; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); for (i = 0; i < gScenarioListCount; i++) { scenario = &gScenarioList[i]; @@ -253,11 +253,11 @@ static void window_scenarioselect_scrollmousedown() static void window_scenarioselect_scrollmouseover() { int i; - short x, y; + short x, y, scrollIndex; rct_window *w; rct_scenario_basic *scenario, *selected; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); selected = NULL; for (i = 0; i < gScenarioListCount; i++) { diff --git a/src/windows/track_list.c b/src/windows/track_list.c index c38a17a529..0efca9ed41 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -308,9 +308,9 @@ static void window_track_list_scrollgetsize() static void window_track_list_scrollmousedown() { rct_window *w; - short i, x, y; + short i, x, y, scrollIndex; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); if (w->track_list.var_484 & 1) return; @@ -329,9 +329,9 @@ static void window_track_list_scrollmousedown() static void window_track_list_scrollmouseover() { rct_window *w; - short i, x, y; + short i, x, y, scrollIndex; - window_scrollmouse_get_registers(w, x, y); + window_scrollmouse_get_registers(w, scrollIndex, x, y); if (w->track_list.var_484 & 1) return;