/** * Closes the specified window. * rct2: 0x006ECD4C * * @param window The window to close (esi). */ void window_close(rct_window* window) { int num_windows; if (window == NULL) return; // Call close event of window RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, (int)window, 0, 0); window = window_find_by_id(window->classification, window->number); // Remove viewport if (window->viewport != NULL) { window->viewport->width = 0; window->viewport = NULL; } // Invalidate the window (area) window_invalidate(window); // Remove window from list and reshift all windows RCT2_NEW_WINDOW--; num_windows = (RCT2_NEW_WINDOW - window); if (num_windows > 0) memmove(window, window + 1, num_windows * sizeof(rct_window)); viewport_update_pointers(); }
/** * * rct2: 0x00663E7D */ void window_land_open() { rct_window* window; // Check if window is already open if (window_find_by_id(WC_LAND, 0) != NULL) return; window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 126, window_land_events, WC_LAND, 0); window->widgets = window_land_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_DECREMENT) | (1 << WIDX_INCREMENT) | (1 << WIDX_FLOOR) | (1 << WIDX_WALL); window_init_scroll_widgets(window); window_push_others_below(window); RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) = 255; RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; _selectedFloorTexture = 0; _selectedWallTexture = 0; RCT2_GLOBAL(0x009E2E1C, sint32) = 0x80000000; RCT2_GLOBAL(0x009E2E20, sint32) = 0x80000000; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; }
static void input_mouseover_widget_flatbutton_invalidate() { rct_window *w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber)); if (w == NULL) return; RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); if (w->widgets[RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)].type == WWT_FLATBTN) widget_invalidate(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)); }
/* Get current mouse window if any. */ struct winlink * cmd_mouse_window(struct mouse_event *m, struct session **sp) { struct session *s; struct window *w; if (!m->valid || m->s == -1 || m->w == -1) return (NULL); if ((s = session_find_by_id(m->s)) == NULL) return (NULL); if ((w = window_find_by_id(m->w)) == NULL) return (NULL); if (sp != NULL) *sp = s; return (winlink_find_by_window(&s->windows, w)); }
/** * * rct2: 0x006E6A40 */ void window_water_open() { rct_window* window; // Check if window is already open if (window_find_by_id(WC_WATER, 0) != NULL) return; window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, (uint32*)window_water_events, WC_WATER, 0); window->widgets = window_water_widgets; window->enabled_widgets = 0x04 | 0x10 | 0x20; window_init_scroll_widgets(window); window_push_others_below(window); RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = MONEY32_UNDEFINED; RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = MONEY32_UNDEFINED; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; }
/** * * rct2: 0x006E6A40 */ void window_water_open() { rct_window* window; // Check if window is already open if (window_find_by_id(WC_WATER, 0) != NULL) return; window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, window_water_events, WC_WATER, 0); window->widgets = window_water_widgets; window->enabled_widgets = 0x04 | 0x10 | 0x20; window_init_scroll_widgets(window); window_push_others_below(window); RCT2_GLOBAL(0x0141F738, uint32) = 0x80000000; RCT2_GLOBAL(0x0141F73C, uint32) = 0x80000000; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; }
/** * * rct2: 0x0066C810 */ static void window_game_top_toolbar_invalidate() { int x; rct_window *w; __asm mov w, esi // Anchor the right half of the buttons to the right x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); if (x < 640) x = 640; x--; window_game_top_toolbar_widgets[WIDX_GUESTS].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_GUESTS].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_STAFF].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_STAFF].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_PARK].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_PARK].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_RIDES].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_RIDES].left = x; x -= 11; window_game_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_PATH].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_PATH].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_SCENERY].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_SCENERY].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_WATER].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_WATER].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_LAND].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_LAND].left = x; x -= 1; window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].left = x; // Footpath button pressed down if (window_find_by_id(0x80 | 0x20, 0) == NULL) w->pressed_widgets &= ~(1 << WIDX_PATH); else w->pressed_widgets |= (1 << WIDX_PATH); // Fast forward button pressed down if (0) w->pressed_widgets |= (1 << WIDX_FASTFORWARD); else w->pressed_widgets &= ~(1 << WIDX_FASTFORWARD); }
/** * * rct2: 0x0066C957 */ static void window_game_top_toolbar_mouseup() { short widgetIndex; rct_window *w, *mainWindow; __asm mov widgetIndex, dx __asm mov w, esi switch (widgetIndex) { case WIDX_PAUSE: game_do_command(0, 1, 0, 0, 2, 0, 0); break; case WIDX_FASTFORWARD: window_cheats_open(); break; case WIDX_ZOOM_OUT: if ((mainWindow = window_get_main()) != NULL) window_zoom_out(mainWindow); break; case WIDX_ZOOM_IN: if ((mainWindow = window_get_main()) != NULL) window_zoom_in(mainWindow); break; case WIDX_ROTATE: if ((mainWindow = window_get_main()) != NULL) window_rotate_camera(mainWindow); break; case WIDX_MAP: RCT2_CALLPROC_EBPSAFE(0x0068C88A); break; case WIDX_CLEAR_SCENERY: if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 16) { tool_cancel(); } else { show_gridlines(); tool_set(w, WIDX_CLEAR_SCENERY, 12); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 2; window_clear_scenery_open(); } break; case WIDX_LAND: if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 7) { tool_cancel(); } else { show_gridlines(); tool_set(w, WIDX_LAND, 18); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1; window_land_open(); } break; case WIDX_WATER: if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 8) { tool_cancel(); } else { show_gridlines(); tool_set(w, WIDX_WATER, 19); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1; window_water_open(); } break; case WIDX_SCENERY: tool_set(w, WIDX_SCENERY, 0); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); RCT2_CALLPROC_EBPSAFE(0x006E0FEF); break; case WIDX_PATH: if (window_find_by_id(WC_FOOTPATH, 0) == NULL) { window_footpath_open(); } else { tool_cancel(); window_close_by_id(0x80 | WC_FOOTPATH, 0); } break; case WIDX_CONSTRUCT_RIDE: RCT2_CALLPROC_EBPSAFE(0x006B3CFF); break; case WIDX_RIDES: window_ride_list_open(); break; case WIDX_PARK: window_park_entrance_open(); break; case WIDX_STAFF: RCT2_CALLPROC_EBPSAFE(0x006BD3CC); break; case WIDX_GUESTS: RCT2_CALLPROC_EBPSAFE(0x006992E3); break; } }
/** * * rct2: 0x006E95F9 */ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) { // RCT2_CALLPROC_X(0x006E95F9, 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]; } window_close_by_id(WC_ERROR, 0); window_close_by_id(WC_TOOLTIP, 0); w = window_find_by_id(windowClass, windowNumber); if (w == NULL) return; window_bring_to_front(w); if (widgetIndex == -1) return; switch (widget->type) { case WWT_FRAME: case WWT_RESIZE: if (!(w->flags & WF_RESIZABLE)) break; if (w->min_width == w->max_width && w->min_height == w->max_height) break; if (x < w->x + w->width - 19 || y < w->y + w->height - 19) break; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESIZING; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; break; case WWT_VIEWPORT: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_LEFT; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))) break; w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)); if (w == NULL) break; RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 4); break; case WWT_CAPTION: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_DRAGGING; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; break; case WWT_SCROLL: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_SCROLL_LEFT; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y; 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; RCT2_GLOBAL(0x009DE548, uint16) = ecx; RCT2_GLOBAL(0x009DE54C, uint32) = edx; RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, w, widget, 0); switch (ecx) { case SCROLL_PART_VIEW: RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, w, widget, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT: // 0x006E9A60 RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT: // 0x006E9ABF RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH: // 0x006E9B47 RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH: // 0x006E9BB7 RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP: // 0x006E9C37 RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM: // 0x006E9C96 RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP_TROUGH: // 0x006E9D1E RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH: // 0x006E9D8E RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0); break; } break; default: if (!widget_is_enabled(w, widgetIndex)) break; if (widget_is_disabled(w, widgetIndex)) break; sound_play_panned(4, w->x + (widget->left + widget->right) / 2); // Set new cursor down widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, rct_windowclass) = widgetIndex; RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 0); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_WIDGET_PRESSED; RCT2_GLOBAL(0x009DE528, uint16) = 1; widget_invalidate(windowClass, windowNumber, widgetIndex); RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0); break; } }
/** * * rct2: 0x006E8655 */ static void game_handle_input_mouse(int x, int y, int state) { rct_window *w, *w2; rct_widget *widget; int widgetIndex; rct_windowclass windowClass; rct_windownumber windowNumber; // Get window and widget under cursor position w = window_find_from_point(x, y); widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y); widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex]; switch (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8)) { case INPUT_STATE_RESET: window_tooltip_reset(x, y); // fall-through case INPUT_STATE_NORMAL: switch (state) { case 0: input_mouseover(x, y, w, widgetIndex); break; case 1: input_leftmousedown(x, y, w, widgetIndex); break; case 3: // Close tooltip window_close_by_id(5, 0); if (w != NULL) window_bring_to_front(w); if (widgetIndex == -1) break; if (widget->type == WWT_VIEWPORT) { if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9) break; w->flags &= ~(1 << 3); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_DRAG; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; RCT2_GLOBAL(0x009DE530, rct_windowclass) = w->classification; RCT2_GLOBAL(0x009DE52E, rct_windownumber) = w->number; RCT2_GLOBAL(0x009DE540, sint16) = 0; // hide cursor // RCT2_CALLPROC_X(0x00407045, 0, 0, 0, 0, 0, 0, 0); // RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 5); GetCursorPos(&_dragPosition); ShowCursor(FALSE); } else if (widget->type == WWT_SCROLL) { } break; } break; case INPUT_STATE_WIDGET_PRESSED: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_DRAGGING: // RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0); w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber)); if (w == NULL) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; break; } if (state == 0) { y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34); window_move_position( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; } else if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); 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); y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34); window_move_position( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0); } break; case INPUT_STATE_VIEWPORT_DRAG: { int dx, dy; dx = x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16); dy = y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16); w = window_find_by_id(RCT2_GLOBAL(0x009DE530, rct_windowclass), RCT2_GLOBAL(0x009DE52E, rct_windownumber)); if (state == 0) { rct_viewport *viewport = w->viewport; RCT2_GLOBAL(0x009DE540, sint16) += RCT2_GLOBAL(0x009DE588, sint16); if (viewport == NULL) { ShowCursor(TRUE); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; } else if (dx != 0 || dy != 0) { if (!(w->flags & (1 << 2))) { RCT2_GLOBAL(0x009DE540, sint16) = 1000; dx <<= viewport->zoom + 1; dy <<= viewport->zoom + 1; w->var_4B2 += dx; w->var_4B4 += dy; } } } else if (state == 4) { ShowCursor(TRUE); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; if (RCT2_GLOBAL(0x009DE540, sint16) < 500) { // Right click { int eax, ebx, ecx, edx, esi, edi, ebp; eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16); ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16); RCT2_CALLFUNC_X(0x006EDE88, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); switch (ebx & 0xFF) { case 2: if (*((uint8*)edx) == 0) RCT2_CALLPROC_X(0x006B4857, eax, 0, ecx, 0, 0, 0, 0); break; case 3: RCT2_CALLPROC_X(0x006CC056, eax, 0, ecx, edx, 0, 0, 0); break; case 5: RCT2_CALLPROC_X(0x006E08D2, eax, 0, ecx, edx, 0, 0, 0); break; case 6: RCT2_CALLPROC_X(0x006A614A, eax, 0, ecx, edx, 0, 0, 0); break; case 7: RCT2_CALLPROC_X(0x006A61AB, eax, 0, ecx, edx, 0, 0, 0); break; case 8: RCT2_CALLPROC_X(0x00666C0E, eax, 0, ecx, edx, 0, 0, 0); break; case 9: RCT2_CALLPROC_X(0x006E57A9, eax, 0, ecx, edx, 0, 0, 0); break; case 10: RCT2_CALLPROC_X(0x006B88DC, eax, 0, ecx, edx, 0, 0, 0); break; case 12: RCT2_CALLPROC_X(0x006BA233, eax, 0, ecx, edx, 0, 0, 0); break; default: break; } } } } // // SetCursorPos(_dragPosition.x, _dragPosition.y); // RCT2_CALLPROC_X(0x006E89C6, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16), state, widgetIndex, w, widget, 0); break; } case INPUT_STATE_DROPDOWN_ACTIVE: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_VIEWPORT_LEFT: RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_SCROLL_LEFT: RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_RESIZING: // RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0); w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber)); if (w == NULL) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; break; } if (state != 0 && state != 2) break; if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); 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); } if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) { window_resize( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); } RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; break; case 9: RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0); break; } }
void handle_shortcut_command(int shortcutIndex) { rct_window *window; switch (shortcutIndex) { case SHORTCUT_CLOSE_TOP_MOST_WINDOW: window_close_top(); break; case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) window_close_all(); else if (RCT2_GLOBAL(0x0141F570, uint8) == 1) window_close_top(); break; case SHORTCUT_CANCEL_CONSTRUCTION_MODE: window = window_find_by_id(WC_ERROR, 0); if (window != NULL) window_close(window); else if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) tool_cancel(); break; case SHORTCUT_PAUSE_GAME: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 0, WE_MOUSE_UP); } } break; case SHORTCUT_ZOOM_VIEW_OUT: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 2, WE_MOUSE_UP); } } } break; case SHORTCUT_ZOOM_VIEW_IN: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 3, WE_MOUSE_UP); } } } break; case SHORTCUT_ROTATE_VIEW: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 4, WE_MOUSE_UP); } } } break; case SHORTCUT_ROTATE_CONSTRUCTION_OBJECT: RCT2_CALLPROC_EBPSAFE(0x006E4182); break; case SHORTCUT_UNDERGROUND_VIEW_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 0, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_REMOVE_BASE_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 1, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 2, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_SEE_THROUGH_RIDES_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 4, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 5, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 6, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_INVISIBLE_PEOPLE_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 7, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 9, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 10, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_ADJUST_LAND: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 7, WE_MOUSE_UP); } } } break; case SHORTCUT_ADJUST_WATER: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 8, WE_MOUSE_UP); } } } break; case SHORTCUT_BUILD_SCENERY: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 9, WE_MOUSE_UP); } } } break; case SHORTCUT_BUILD_PATHS: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 10, WE_MOUSE_UP); } } } break; case SHORTCUT_BUILD_NEW_RIDE: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 11, WE_MOUSE_UP); } } } break; case SHORTCUT_SHOW_FINANCIAL_INFORMATION: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) RCT2_CALLPROC_EBPSAFE(0x0069DDF1); break; case SHORTCUT_SHOW_RESEARCH_INFORMATION: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { // Open new ride window RCT2_CALLPROC_EBPSAFE(0x006B3CFF); window = window_find_by_id(WC_CONSTRUCT_RIDE, 0); if (window != NULL) window_event_helper(window, 10, WE_MOUSE_DOWN); } break; case SHORTCUT_SHOW_RIDES_LIST: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 12, WE_MOUSE_UP); } } break; case SHORTCUT_SHOW_PARK_INFORMATION: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 13, WE_MOUSE_UP); } } break; case SHORTCUT_SHOW_GUEST_LIST: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 15, WE_MOUSE_UP); } } break; case SHORTCUT_SHOW_STAFF_LIST: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 14, WE_MOUSE_UP); } } break; case SHORTCUT_SHOW_RECENT_MESSAGES: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) window_news_open(); break; case SHORTCUT_SHOW_MAP: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 6, WE_MOUSE_UP); } } } break; case SHORTCUT_SCREENSHOT: RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2 break; } }
/** * * 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: 0x006EA10D */ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y) { rct_window *w; rct_widget *widget; int width, height; if (widgetWindow == NULL || widgetIndex == -1) return; widget = &widgetWindow->widgets[widgetIndex]; RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, widgetWindow, 0, 0); if (widget->tooltip == 0xFFFF) return; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = widgetWindow->classification; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = widgetWindow->number; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = widgetIndex; int eax, ebx, ecx, edx, esi, edi, ebp; eax = widgetIndex; esi = widgetWindow; RCT2_CALLFUNC_X(widgetWindow->event_handlers[WE_TOOLTIP], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if ((eax & 0xFFFF) == 0xFFFF) return; w = window_find_by_id(WC_ERROR, 0); if (w != NULL) return; RCT2_GLOBAL(0x0142006C, sint32) = -1; format_string(0x0141ED68, widget->tooltip, 0x013CE952); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; esi = 0x0141ED68; RCT2_CALLFUNC_X(0x006C23B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ecx &= 0xFFFF; if (ecx > 196) ecx = 196; esi = 0x0141ED68; edi = ecx + 1; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; RCT2_CALLFUNC_X(0x006C21E2, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ecx &= 0xFFFF; edi &= 0xFFFF; RCT2_GLOBAL(0x01420044, sint16) = edi; width = ecx + 3; height = ((edi + 1) * 10) + 4; window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; memcpy(0x0141FE44, 0x0141ED68, 512); x = clamp(0, x - (width / 2), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width); y = clamp(22, y + 26, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height - 40); w = window_create(x, y, width, height, window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); w->widgets = window_tooltip_widgets; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) = 0; }