diff --git a/src/game.c b/src/game.c index f204ede49a..1ff9d3cddb 100644 --- a/src/game.c +++ b/src/game.c @@ -1130,7 +1130,6 @@ void game_load_or_quit_no_save_prompt() game_do_command(0, 1, 0, 1, GAME_COMMAND_LOAD_OR_QUIT, 0, 0); tool_cancel(); if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_5) { - // RCT2_CALLPROC_EBPSAFE(0x0040705E); Function not required resets cursor position. RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~INPUT_FLAG_5; } gGameSpeed = 1; diff --git a/src/input.c b/src/input.c index 666fcbb6aa..2f3ca89b54 100644 --- a/src/input.c +++ b/src/input.c @@ -93,7 +93,6 @@ static void input_scroll_part_update_vtop(rct_window *w, int widgetIndex, int sc static void input_scroll_part_update_vbottom(rct_window *w, int widgetIndex, int scroll_id); static void input_update_tooltip(rct_window *w, int widgetIndex, int x, int y); static void update_cursor_position(); -static void sub_6EA2AA(rct_window *w, int widgetIndex, int x, int y, int edi); #pragma region Mouse input @@ -1479,11 +1478,9 @@ void game_handle_keyboard_input() w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != NULL) { keyboard_shortcut_set(key); - } - else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { + } else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { tutorial_stop(); - } - else { + } else { w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { window_text_input_key(w, key); @@ -1493,77 +1490,9 @@ void game_handle_keyboard_input() } } - if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) - return; - - // Tutorial and the modifier key - if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { - int eax, ebx, ecx, edx, esi, edi, ebp; - RCT2_CALLFUNC_X(0x0066EEB4, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - eax &= 0xFF; - RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = eax; - if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { - window_tooltip_close(); - if ((w = window_get_main()) != NULL) { - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); - RCT2_GLOBAL(0x009DEA72, uint16)++; - } - } + if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { + game_handle_keyboard_input_for_tutorial(); } - else { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { - window_tooltip_close(); - if ((w = window_get_main()) != NULL) { - sub_6EA2AA(w, 0, 0, 0, RCT2_GLOBAL(0x009DEA72, uint16)); - RCT2_GLOBAL(0x009DEA72, uint16)++; - } - } - - // Write tutorial input - RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); - } -} - -static void sub_6EA2AA(rct_window *w, int widgetIndex, int x, int y, int edi) -{ - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); - return; - - rct_window *tooltipWindow; - - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = w->classification; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = w->number; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = widgetIndex; - - rct_string_id stringId = window_event_tooltip_call(w, widgetIndex); - if (stringId == (rct_string_id)STR_NONE) - return; - - tooltipWindow = window_find_by_class(WC_TOOLTIP); - if (tooltipWindow == NULL) - return; - - char *buffer = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; - - RCT2_GLOBAL(0x0142006C, uint32) = edi; - format_string(buffer, edi, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - int width = gfx_get_string_width_new_lined(buffer); - width = min(width, 196); - - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - - int numLines, fontHeight; - gfx_wrap_string(buffer, width + 1, &numLines, &fontHeight); - - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, uint16) = numLines; - tooltipWindow->widgets[0].right = width + 3; - tooltipWindow->widgets[0].bottom = ((numLines + 1) * 10) + 4; - - char *tooltipBuffer = (char*)RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER; - memcpy(tooltipBuffer, buffer, 512); - - window_tooltip_open(w, widgetIndex, x, y); } /** diff --git a/src/input.h b/src/input.h index e8d2117a95..e6322a68e8 100644 --- a/src/input.h +++ b/src/input.h @@ -50,6 +50,7 @@ enum { void title_handle_keyboard_input(); void game_handle_input(); void game_handle_keyboard_input(); +void game_handle_keyboard_input_for_tutorial(); void store_mouse_input(int state); diff --git a/src/interface/window.c b/src/interface/window.c index 0ba2ba70d3..54d69c2cad 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -153,8 +153,6 @@ void window_dispatch_update_all() //RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16)++; for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) window_event_update_call(w); - - RCT2_CALLPROC_EBPSAFE(0x006EE411); // handle_text_input } void window_update_all_viewports() @@ -1459,16 +1457,6 @@ void window_zoom_out(rct_window *w) window_zoom_set(w, w->viewport->zoom + 1); } -/** - * - * rct2: 0x006EE308 - * DEPRECIATED please use the new text_input window. - */ -void window_show_textinput(rct_window *w, int widgetIndex, uint16 title, uint16 text, int value) -{ - RCT2_CALLPROC_X(0x006EE308, title, text, value, widgetIndex, (int)w, 0, 0); -} - /** * Draws a window that is in the specified region. * rct2: 0x006E756C @@ -2425,7 +2413,6 @@ void textinput_cancel() window_close_by_class(WC_TEXTINPUT); if (RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WINDOWCLASS, uint8) != 255) { - RCT2_CALLPROC_EBPSAFE(0x006EE4E2); w = window_find_by_number( RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WINDOWNUMBER, rct_windownumber) diff --git a/src/tutorial.c b/src/tutorial.c index d4e5f31ab5..56c2655872 100644 --- a/src/tutorial.c +++ b/src/tutorial.c @@ -19,9 +19,13 @@ *****************************************************************************/ #include "addresses.h" +#include "interface/window.h" #include "localisation/localisation.h" #include "tutorial.h" #include "windows/error.h" +#include "windows/tooltip.h" + +static void sub_6EA2AA(rct_window *w, int widgetIndex, int x, int y, int edi); /** * @@ -39,5 +43,90 @@ void tutorial_start(int type) */ void tutorial_stop() { - RCT2_CALLPROC_EBPSAFE(0x0066EE25); + // RCT2_CALLPROC_EBPSAFE(0x0066EE25); +} + +void game_handle_keyboard_input_for_tutorial() +{ +#ifdef ENABLE_TUTORIAL + rct_window *w; + + if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { + int eax, ebx, ecx, edx, esi, edi, ebp; + RCT2_CALLFUNC_X(0x0066EEB4, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + eax &= 0xFF; + RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = eax; + if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { + window_tooltip_close(); + if ((w = window_get_main()) != NULL) { + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + RCT2_GLOBAL(0x009DEA72, uint16)++; + } + } + } else { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { + window_tooltip_close(); + if ((w = window_get_main()) != NULL) { + sub_6EA2AA(w, 0, 0, 0, RCT2_GLOBAL(0x009DEA72, uint16)); + RCT2_GLOBAL(0x009DEA72, uint16)++; + } + } + + // Write tutorial input + RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); + } +#endif +} + +static void sub_6EA2AA(rct_window *w, int widgetIndex, int x, int y, int edi) +{ +#ifdef ENABLE_TUTORIAL + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + return; + + rct_window *tooltipWindow; + + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = w->classification; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = w->number; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = widgetIndex; + + rct_string_id stringId = window_event_tooltip_call(w, widgetIndex); + if (stringId == (rct_string_id)STR_NONE) + return; + + tooltipWindow = window_find_by_class(WC_TOOLTIP); + if (tooltipWindow == NULL) + return; + + char *buffer = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; + + RCT2_GLOBAL(0x0142006C, uint32) = edi; + format_string(buffer, edi, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + int width = gfx_get_string_width_new_lined(buffer); + width = min(width, 196); + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + + int numLines, fontHeight; + gfx_wrap_string(buffer, width + 1, &numLines, &fontHeight); + + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, uint16) = numLines; + tooltipWindow->widgets[0].right = width + 3; + tooltipWindow->widgets[0].bottom = ((numLines + 1) * 10) + 4; + + char *tooltipBuffer = (char*)RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER; + memcpy(tooltipBuffer, buffer, 512); + + window_tooltip_open(w, widgetIndex, x, y); +#endif +} + +/** + * + * rct2: 0x0066EE54 + */ +void sub_66EE54() +{ + // RCT2_CALLPROC_EBPSAFE(0x0066EE54); } diff --git a/src/tutorial.h b/src/tutorial.h index d1b2eced61..a3de1993a3 100644 --- a/src/tutorial.h +++ b/src/tutorial.h @@ -23,5 +23,6 @@ void tutorial_start(int type); void tutorial_stop(); +void sub_66EE54(); #endif diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 3d77c2294c..60058185e7 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -23,12 +23,12 @@ #include "../config.h" #include "../game.h" #include "../localisation/localisation.h" +#include "../interface/themes.h" #include "../interface/widget.h" #include "../interface/window.h" #include "../openrct2.h" #include "../sprites.h" #include "../tutorial.h" -#include "../interface/themes.h" enum WINDOW_SAVE_PROMPT_WIDGET_IDX { WIDX_BACKGROUND, @@ -136,7 +136,7 @@ void window_save_prompt_open() if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { - RCT2_CALLPROC_EBPSAFE(0x0066EE54); + sub_66EE54(); game_load_or_quit_no_save_prompt(); return; } @@ -252,7 +252,7 @@ static void window_save_prompt_mouseup(rct_window *w, int widgetIndex) if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) { - RCT2_CALLPROC_EBPSAFE(0x0066EE54); + sub_66EE54(); game_load_or_quit_no_save_prompt(); return; } else { diff --git a/src/world/map.c b/src/world/map.c index 640851372f..8962ed1033 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3794,7 +3794,6 @@ static void map_obstruction_set_error_text(rct_map_element *mapElement) */ int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *clearFunc, uint8 bl) { - // return (RCT2 CALLPROC X(0x0068B932, x, bl, y, (zHigh << 8) | zLow, 0, 0, (int)clearFunc) & 0x100) == 0; RCT2_GLOBAL(0x00F1AD40, void*) = clearFunc; RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) = 1; if (x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) || x < 32 || y < 32) {