/** * * rct2: 0x006E9253 */ static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex) { rct_windowclass windowClass = 255; rct_windownumber windowNumber = 0; rct_widget *widget = NULL; if (w != NULL) { windowClass = w->classification; windowNumber = w->number; widget = &w->widgets[widgetIndex]; } input_widget_over_change_check(windowClass, windowNumber, widgetIndex); if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) { sint32 eax, ebx, scroll_part, edx; widget_scroll_get_part(w, widget, x, y, &eax, &ebx, &scroll_part, &edx); if (scroll_part != SCROLL_PART_VIEW) window_tooltip_close(); else { window_event_scroll_mouseover_call(w, edx, eax, ebx); input_update_tooltip(w, widgetIndex, x, y); } } else { input_update_tooltip(w, widgetIndex, x, y); } gTooltipTimeout = 0; gTooltipCursorX = x; gTooltipCursorY = y; }
static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y) { if (gTooltipWidget.window_classification == 255) { if (gTooltipCursorX == x && gTooltipCursorY == y) { _tooltipNotShownTicks++; if (_tooltipNotShownTicks > 50) { gTooltipTimeout = 0; window_tooltip_open(w, widgetIndex, x, y); } } } else { reset_tooltip_not_shown(); if (w == NULL || gTooltipWidget.window_classification != w->classification || gTooltipWidget.window_number != w->number || gTooltipWidget.widget_index != widgetIndex ) { window_tooltip_close(); } gTooltipTimeout += gTicksSinceLastUpdate; if (gTooltipTimeout >= 8000) { window_close_by_class(WC_TOOLTIP); } } }
static void input_update_tooltip(rct_window *w, int widgetIndex, int x, int y) { if (gTooltipWidget.window_classification == 255) { if (gTooltipNotShownTicks < 500 || (gTooltipCursorX == x && gTooltipCursorY == y)) { gTooltipTimeout = RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, uint16); int time = 2000; if (gTooltipNotShownTicks >= 1) { time = 0; } if (time > gTooltipTimeout) { gTooltipNotShownTicks++; return; } window_tooltip_open(w, widgetIndex, x, y); } } else { if (( (w != NULL) && (gTooltipWidget.window_classification != w->classification || gTooltipWidget.window_number != w->number) ) || gTooltipWidget.widget_index != widgetIndex ) { window_tooltip_close(); } gTooltipTimeout += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, uint16); if (gTooltipTimeout >= 8000) { window_close_by_class(WC_TOOLTIP); } } }
/** * * rct2: 0x006E9253 */ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) { // RCT2_CALLPROC_X(0x006E9253, x, y, state, widgetIndex, w, widget, 0); rct_windowclass windowClass = 255; rct_windownumber windowNumber = 0; rct_widget *widget; if (w != NULL) { windowClass = w->classification; windowNumber = w->number; widget = &w->widgets[widgetIndex]; } input_mouseover_widget_check(windowClass, windowNumber, widgetIndex); if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; esi = w; edi = widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; ecx &= 0xFFFF; edx &= 0xFFFF; if (ecx < 0) goto showTooltip; if (ecx == 0) { RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, w, 0, 0); goto showTooltip; } else { } } else { showTooltip: if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) == 255) { if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) < 500 || (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, sint16) == x && RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, sint16) == y) ) { RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = RCT2_GLOBAL(0x009DE588, uint16); int bp = 2000; if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) <= 1000) bp = 0; if (bp > RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16)) return; window_tooltip_open(w, widgetIndex, x, y); // RCT2_CALLPROC_X(0x006EA10D, x, y, 0, widgetIndex, w, widget, 0); // window_tooltip_open(); } } else { if (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 ) { window_tooltip_close(); } RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) += RCT2_GLOBAL(0x009DE588, uint16); if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) < 8000) return; window_close_by_id(WC_TOOLTIP, 0); } } RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, sint16) = y; }
/** * * rct2: 0x006E8DA7 */ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetindex widgetIndex, rct_window *w, rct_widget *widget) { rct_windowclass cursor_w_class; rct_windownumber cursor_w_number; cursor_w_class = gPressedWidget.window_classification; cursor_w_number = gPressedWidget.window_number; rct_widgetindex cursor_widgetIndex = gPressedWidget.widget_index; rct_window *cursor_w = window_find_by_number(cursor_w_class, cursor_w_number); if (cursor_w == NULL) { _inputState = INPUT_STATE_RESET; return; } switch (state) { case MOUSE_STATE_RELEASED: if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) break; if (_clickRepeatTicks != 0) { _clickRepeatTicks++; // Handle click repeat if (_clickRepeatTicks >= 16 && (_clickRepeatTicks & 3) != 0) { if (w->hold_down_widgets & (1ULL << widgetIndex)) { window_event_mouse_down_call(w, widgetIndex); } } } if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) { if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) { gDropdownHighlightedIndex = gDropdownDefaultIndex; window_invalidate_by_class(WC_DROPDOWN); } return; } _inputFlags |= INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex); return; case MOUSE_STATE_LEFT_RELEASE: case MOUSE_STATE_RIGHT_PRESS: if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) { if (w) { sint32 dropdown_index = 0; if (w->classification == WC_DROPDOWN) { dropdown_index = dropdown_index_from_point(x, y, w); if (dropdown_index == -1) { goto dropdown_cleanup; } if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) { goto dropdown_cleanup; } if (gDropdownItemsFormat[dropdown_index] == 0) { goto dropdown_cleanup; } } else { if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) goto dropdown_cleanup; dropdown_index = -1; if (_inputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN){ if (!(_inputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)){ _inputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP; return; } } } window_close_by_class(WC_DROPDOWN); cursor_w = window_find_by_number(cursor_w_class, cursor_w_number); if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) { _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } _inputState = INPUT_STATE_NORMAL; gTooltipTimeout = 0; gTooltipWidget.widget_index = cursor_widgetIndex; gTooltipWidget.window_classification = cursor_w_class; gTooltipWidget.window_number = cursor_w_number; if (dropdown_index == -1) { if (!dropdown_is_disabled(gDropdownDefaultIndex)) { dropdown_index = gDropdownDefaultIndex; } } window_event_dropdown_call(cursor_w, cursor_widgetIndex, dropdown_index); } dropdown_cleanup: window_close_by_class(WC_DROPDOWN); } if (state == MOUSE_STATE_RIGHT_PRESS) { return; } _inputState = INPUT_STATE_NORMAL; gTooltipTimeout = 0; gTooltipWidget.widget_index = cursor_widgetIndex; if (!w) break; if (!widget) break; sint32 mid_point_x = (widget->left + widget->right) / 2 + w->x; audio_play_sound_panned(5, mid_point_x, 0, 0, 0); if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) break; widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex); window_event_mouse_up_call(w, widgetIndex); default: return; } _clickRepeatTicks = 0; if (_inputState != INPUT_STATE_DROPDOWN_ACTIVE){ // Hold down widget and drag outside of area?? if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED){ _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } return; } gDropdownHighlightedIndex = -1; window_invalidate_by_class(WC_DROPDOWN); if (w == NULL) { return; } if (w->classification == WC_DROPDOWN){ sint32 dropdown_index = dropdown_index_from_point(x, y, w); if (dropdown_index == -1) { return; } if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) { gDropdownLastColourHover = dropdown_index; window_tooltip_close(); static const rct_string_id colourTooltips[] = { STR_COLOUR_BLACK_TIP, STR_COLOUR_GREY_TIP, STR_COLOUR_WHITE_TIP, STR_COLOUR_DARK_PURPLE_TIP, STR_COLOUR_LIGHT_PURPLE_TIP, STR_COLOUR_BRIGHT_PURPLE_TIP, STR_COLOUR_DARK_BLUE_TIP, STR_COLOUR_LIGHT_BLUE_TIP, STR_COLOUR_ICY_BLUE_TIP, STR_COLOUR_TEAL_TIP, STR_COLOUR_AQUAMARINE_TIP, STR_COLOUR_SATURATED_GREEN_TIP, STR_COLOUR_DARK_GREEN_TIP, STR_COLOUR_MOSS_GREEN_TIP, STR_COLOUR_BRIGHT_GREEN_TIP, STR_COLOUR_OLIVE_GREEN_TIP, STR_COLOUR_DARK_OLIVE_GREEN_TIP, STR_COLOUR_BRIGHT_YELLOW_TIP, STR_COLOUR_YELLOW_TIP, STR_COLOUR_DARK_YELLOW_TIP, STR_COLOUR_LIGHT_ORANGE_TIP, STR_COLOUR_DARK_ORANGE_TIP, STR_COLOUR_LIGHT_BROWN_TIP, STR_COLOUR_SATURATED_BROWN_TIP, STR_COLOUR_DARK_BROWN_TIP, STR_COLOUR_SALMON_PINK_TIP, STR_COLOUR_BORDEAUX_RED_TIP, STR_COLOUR_SATURATED_RED_TIP, STR_COLOUR_BRIGHT_RED_TIP, STR_COLOUR_DARK_PINK_TIP, STR_COLOUR_BRIGHT_PINK_TIP, STR_COLOUR_LIGHT_PINK_TIP, }; window_tooltip_show(colourTooltips[dropdown_index], x, y); } if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) { return; } if (gDropdownItemsFormat[dropdown_index] == 0) { return; } gDropdownHighlightedIndex = dropdown_index; window_invalidate_by_class(WC_DROPDOWN); } else { gDropdownLastColourHover = -1; window_tooltip_close(); } }
/** * * rct2: 0x006E3B43 */ void game_handle_keyboard_input() { rct_window *w; int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) != 0) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 1) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3)) game_handle_edge_scroll(); // Handle modifier keys and key scrolling RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0; if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) { if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 1; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 2; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) game_handle_key_scroll(); } // Handle key input while ((key = get_next_key()) != 0) { if (key == 255) continue; key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8; w = window_find_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); if (w != NULL) set_shortcut(key); else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) tutorial_stop(); else handle_shortcut(key); } 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)++; } } } else { 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)++; } } // Write tutorial input RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); } }
/** * * rct2: 0x006E8DA7 */ 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; rct_windowclass cursor_w_class; rct_windownumber cursor_w_number; cursor_w_class = gPressedWidget.window_classification; cursor_w_number = gPressedWidget.window_number; int cursor_widgetIndex = gPressedWidget.widget_index; rct_window *cursor_w = window_find_by_number(cursor_w_class, cursor_w_number); if (cursor_w == NULL) { gInputState = INPUT_STATE_RESET; return; } switch (state) { case MOUSE_STATE_RELEASED: if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) break; if (RCT2_GLOBAL(0x009DE528, uint16) != 0) RCT2_GLOBAL(0x009DE528, uint16)++; if (w->hold_down_widgets & (1ULL << widgetIndex) && RCT2_GLOBAL(0x009DE528, uint16) >= 16 && !(RCT2_GLOBAL(0x009DE528, uint16) & 3) ) { window_event_mouse_down_call(w, widgetIndex); } if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED) { if (gInputState == INPUT_STATE_DROPDOWN_ACTIVE) { gDropdownHighlightedIndex = gDropdownDefaultIndex; window_invalidate_by_class(WC_DROPDOWN); } return; } gInputFlags |= INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex); return; case MOUSE_STATE_LEFT_RELEASE: case MOUSE_STATE_RIGHT_PRESS: if (gInputState == INPUT_STATE_DROPDOWN_ACTIVE) { if (w) { int dropdown_index = 0; if (w->classification == WC_DROPDOWN) { dropdown_index = dropdown_index_from_point(x, y, w); if (dropdown_index == -1) { goto dropdown_cleanup; } if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) { goto dropdown_cleanup; } if (gDropdownItemsFormat[dropdown_index] == 0) { goto dropdown_cleanup; } } else { if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) goto dropdown_cleanup; dropdown_index = -1; if (gInputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN){ if (!(gInputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)){ gInputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP; return; } } } window_close_by_class(WC_DROPDOWN); cursor_w = window_find_by_number(cursor_w_class, cursor_w_number); if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED) { gInputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } gInputState = INPUT_STATE_NORMAL; gTooltipTimeout = 0; gTooltipWidget.widget_index = cursor_widgetIndex; gTooltipWidget.window_classification = cursor_w_class; gTooltipWidget.window_number = cursor_w_number; if (dropdown_index == -1) { if (!dropdown_is_disabled(gDropdownDefaultIndex)) { dropdown_index = gDropdownDefaultIndex; } } window_event_dropdown_call(cursor_w, cursor_widgetIndex, dropdown_index); } dropdown_cleanup: window_close_by_class(WC_DROPDOWN); } if (state == MOUSE_STATE_RIGHT_PRESS) { return; } gInputState = INPUT_STATE_NORMAL; gTooltipTimeout = 0; gTooltipWidget.widget_index = cursor_widgetIndex; if (!w) break; if (!widget) break; int mid_point_x = (widget->left + widget->right) / 2 + w->x; audio_play_sound_panned(5, mid_point_x, 0, 0, 0); if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; if (w->disabled_widgets & (1ULL << widgetIndex)) break; widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex); window_event_mouse_up_call(w, widgetIndex); default: return; } RCT2_GLOBAL(0x009DE528, uint16) = 0; if (gInputState != INPUT_STATE_DROPDOWN_ACTIVE){ // Hold down widget and drag outside of area?? if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED){ gInputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } return; } gDropdownHighlightedIndex = -1; window_invalidate_by_class(WC_DROPDOWN); if (w == NULL) { return; } if (w->classification == WC_DROPDOWN){ int dropdown_index = dropdown_index_from_point(x, y, w); if (dropdown_index == -1) { return; } if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) { gDropdownLastColourHover = dropdown_index; window_tooltip_close(); window_tooltip_show(STR_COLOUR_NAMES_START + dropdown_index, x, y); } if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) { return; } if (gDropdownItemsFormat[dropdown_index] == 0) { return; } gDropdownHighlightedIndex = dropdown_index; window_invalidate_by_class(WC_DROPDOWN); } else { gDropdownLastColourHover = -1; window_tooltip_close(); } }