From 00667c81b6a2463e44d9753b09a0bee0b09a85a0 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 15 Dec 2017 23:48:40 +0100 Subject: [PATCH] Reformat MouseInput --- src/openrct2-ui/input/MouseInput.cpp | 625 ++++++++++++++++----------- 1 file changed, 362 insertions(+), 263 deletions(-) diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 8bcbe4ce6c..7bc42e4dcb 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -14,14 +14,19 @@ *****************************************************************************/ #pragma endregion -#include -#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include #include #include -#include #include #include #include @@ -29,17 +34,13 @@ #include #include #include -#include #include #include -#include #include -#include -#include -#include -#include +#include -typedef struct rct_mouse_data { +typedef struct rct_mouse_data +{ uint32 x; uint32 y; uint32 state; @@ -68,37 +69,39 @@ sint32 gTooltipCursorY; static sint16 _clickRepeatTicks; -static sint32 game_get_next_input(sint32 *x, sint32 *y); -static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex); -static void input_widget_over_change_check(rct_windowclass windowClass, rct_windownumber windowNumber, rct_widgetindex widgetIndex); +static sint32 game_get_next_input(sint32 * x, sint32 * y); +static void input_widget_over(sint32 x, sint32 y, rct_window * w, rct_widgetindex widgetIndex); +static void input_widget_over_change_check(rct_windowclass windowClass, rct_windownumber windowNumber, + rct_widgetindex widgetIndex); static void input_widget_over_flatbutton_invalidate(); void process_mouse_over(sint32 x, sint32 y); void process_mouse_tool(sint32 x, sint32 y); void invalidate_scroll(); -static rct_mouse_data* get_mouse_input(); -void tile_element_right_click(sint32 type, rct_tile_element *tileElement, sint32 x, sint32 y); +static rct_mouse_data * get_mouse_input(); +void tile_element_right_click(sint32 type, rct_tile_element * tileElement, sint32 x, sint32 y); static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state); -static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex); -void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetindex widgetIndex, rct_window* w, rct_widget* widget); +static void input_widget_left(sint32 x, sint32 y, rct_window * w, rct_widgetindex widgetIndex); +void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetindex widgetIndex, rct_window * w, + rct_widget * widget); void set_cursor(uint8 cursor_id); -static void input_window_position_continue(rct_window *w, sint32 lastX, sint32 lastY, sint32 newX, sint32 newY); -static void input_window_position_end(rct_window *w, sint32 x, sint32 y); -static void input_window_resize_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y); -static void input_window_resize_continue(rct_window *w, sint32 x, sint32 y); +static void input_window_position_continue(rct_window * w, sint32 lastX, sint32 lastY, sint32 newX, sint32 newY); +static void input_window_position_end(rct_window * w, sint32 x, sint32 y); +static void input_window_resize_begin(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void input_window_resize_continue(rct_window * w, sint32 x, sint32 y); static void input_window_resize_end(); -static void input_viewport_drag_begin(rct_window *w, sint32 x, sint32 y); +static void input_viewport_drag_begin(rct_window * w, sint32 x, sint32 y); static void input_viewport_drag_continue(); static void input_viewport_drag_end(); -static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y); -static void input_scroll_continue(rct_window *w, rct_widgetindex widgetIndex, sint32 state, sint32 x, sint32 y); +static void input_scroll_begin(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void input_scroll_continue(rct_window * w, rct_widgetindex widgetIndex, sint32 state, sint32 x, sint32 y); static void input_scroll_end(); -static void input_scroll_part_update_hthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 scroll_id); -static void input_scroll_part_update_hleft(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id); -static void input_scroll_part_update_hright(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id); -static void input_scroll_part_update_vthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id); -static void input_scroll_part_update_vtop(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id); -static void input_scroll_part_update_vbottom(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id); -static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void input_scroll_part_update_hthumb(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 scroll_id); +static void input_scroll_part_update_hleft(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id); +static void input_scroll_part_update_hright(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id); +static void input_scroll_part_update_vthumb(rct_window * w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id); +static void input_scroll_part_update_vtop(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id); +static void input_scroll_part_update_vbottom(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id); +static void input_update_tooltip(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y); #pragma region Mouse input @@ -108,20 +111,25 @@ static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sin */ void game_handle_input() { - for (rct_window *w = g_window_list; w < gWindowNextSlot; w++) { + for (rct_window * w = g_window_list; w < gWindowNextSlot; w++) + { window_event_unknown_07_call(w); } invalidate_all_windows_after_input(); sint32 x, y, state; - while ((state = game_get_next_input(&x, &y)) != MOUSE_STATE_RELEASED) { + while ((state = game_get_next_input(&x, &y)) != MOUSE_STATE_RELEASED) + { game_handle_input_mouse(x, y, state & 0xFF); } - if (_inputFlags & INPUT_FLAG_5) { + if (_inputFlags & INPUT_FLAG_5) + { game_handle_input_mouse(x, y, state); - } else if (x != MONEY32_UNDEFINED) { + } + else if (x != MONEY32_UNDEFINED) + { sint32 screenWidth = context_get_width(); sint32 screenHeight = context_get_height(); x = Math::Clamp(0, x, screenWidth - 1); @@ -132,7 +140,8 @@ void game_handle_input() process_mouse_tool(x, y); } - for (rct_window *w = g_window_list; w < gWindowNextSlot; w++) { + for (rct_window * w = g_window_list; w < gWindowNextSlot; w++) + { window_event_unknown_08_call(w); } } @@ -140,16 +149,19 @@ void game_handle_input() /** * * rct2: 0x006E83C7 -*/ -static sint32 game_get_next_input(sint32 *x, sint32 *y) + */ +static sint32 game_get_next_input(sint32 * x, sint32 * y) { - rct_mouse_data *input = get_mouse_input(); - if (input == NULL) { + rct_mouse_data * input = get_mouse_input(); + if (input == NULL) + { const CursorState * cursorState = context_get_cursor_state(); *x = cursorState->x; *y = cursorState->y; return 0; - } else { + } + else + { *x = input->x; *y = input->y; return input->state; @@ -160,13 +172,16 @@ static sint32 game_get_next_input(sint32 *x, sint32 *y) * * rct2: 0x00407074 */ -static rct_mouse_data *get_mouse_input() +static rct_mouse_data * get_mouse_input() { // Check if that location has been written to yet - if (_mouseInputQueueReadIndex == _mouseInputQueueWriteIndex) { + if (_mouseInputQueueReadIndex == _mouseInputQueueWriteIndex) + { return NULL; - } else { - rct_mouse_data *result = &_mouseInputQueue[_mouseInputQueueReadIndex]; + } + else + { + rct_mouse_data * result = &_mouseInputQueue[_mouseInputQueueReadIndex]; _mouseInputQueueReadIndex = (_mouseInputQueueReadIndex + 1) % Util::CountOf(_mouseInputQueue); return result; } @@ -176,7 +191,7 @@ static rct_mouse_data *get_mouse_input() * * rct2: 0x006E957F */ -static void input_scroll_drag_begin(sint32 x, sint32 y, rct_window* w, rct_widget* widget, rct_widgetindex widgetIndex) +static void input_scroll_drag_begin(sint32 x, sint32 y, rct_window * w, rct_widget * widget, rct_widgetindex widgetIndex) { _inputState = INPUT_STATE_SCROLL_RIGHT; gInputDragLastX = x; @@ -194,19 +209,20 @@ static void input_scroll_drag_begin(sint32 x, sint32 y, rct_window* w, rct_widge * Based on (heavily changed) * rct2: 0x006E9E0E, 0x006E9ED0 */ -static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window* w) +static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window * w) { rct_widgetindex widgetIndex = _dragWidget.widget_index; uint8 scrollIndex = _dragScrollIndex; - rct_widget* widget = &w->widgets[widgetIndex]; - rct_scroll* scroll = &w->scrolls[scrollIndex]; + rct_widget * widget = &w->widgets[widgetIndex]; + rct_scroll * scroll = &w->scrolls[scrollIndex]; sint32 dx, dy; dx = x - gInputDragLastX; dy = y - gInputDragLastY; - if (scroll->flags & HSCROLLBAR_VISIBLE) { + if (scroll->flags & HSCROLLBAR_VISIBLE) + { sint16 size = widget->right - widget->left - 1; if (scroll->flags & VSCROLLBAR_VISIBLE) size -= 11; @@ -214,8 +230,9 @@ static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window* w) scroll->h_left = Math::Min(Math::Max(0, scroll->h_left + dx), size); } - if (scroll->flags & VSCROLLBAR_VISIBLE) { - sint16 size = widget->bottom - widget->top - 1; + if (scroll->flags & VSCROLLBAR_VISIBLE) + { + sint16 size = widget->bottom - widget->top - 1; if (scroll->flags & HSCROLLBAR_VISIBLE) size -= 11; size = Math::Max(0, scroll->v_bottom - size); @@ -225,8 +242,8 @@ static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window* w) widget_scroll_update_thumbs(w, widgetIndex); window_invalidate_by_number(w->classification, w->number); - sint32 fixedCursorPositionX = (sint32) ceilf(gInputDragLastX * gConfigGeneral.window_scale); - sint32 fixedCursorPositionY = (sint32) ceilf(gInputDragLastY * gConfigGeneral.window_scale); + sint32 fixedCursorPositionX = (sint32)ceilf(gInputDragLastX * gConfigGeneral.window_scale); + sint32 fixedCursorPositionY = (sint32)ceilf(gInputDragLastY * gConfigGeneral.window_scale); context_set_cursor_position(fixedCursorPositionX, fixedCursorPositionY); } @@ -237,17 +254,20 @@ static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window* w) */ static void input_scroll_right(sint32 x, sint32 y, sint32 state) { - rct_window* w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number); - if (w == NULL) { + rct_window * w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number); + if (w == NULL) + { context_show_cursor(); _inputState = INPUT_STATE_RESET; return; } - switch (state) { + switch (state) + { case MOUSE_STATE_RELEASED: _ticksSinceDragStart += gTicksSinceLastUpdate; - if (x != 0 || y != 0) { + if (x != 0 || y != 0) + { _ticksSinceDragStart = 1000; input_scroll_drag_continue(x, y, w); } @@ -265,8 +285,8 @@ static void input_scroll_right(sint32 x, sint32 y, sint32 state) */ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) { - rct_window *w; - rct_widget *widget; + rct_window * w; + rct_widget * widget; rct_widgetindex widgetIndex; // Get window and widget under cursor position @@ -274,12 +294,14 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y); widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex]; - switch (_inputState) { + switch (_inputState) + { case INPUT_STATE_RESET: window_tooltip_reset(x, y); // fall-through case INPUT_STATE_NORMAL: - switch (state) { + switch (state) + { case MOUSE_STATE_RELEASED: input_widget_over(x, y, w, widgetIndex); break; @@ -289,14 +311,18 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) case MOUSE_STATE_RIGHT_PRESS: window_close_by_class(WC_TOOLTIP); - if (w != NULL) { + if (w != NULL) + { w = window_bring_to_front(w); } - if (widgetIndex != -1) { - switch (widget->type) { + if (widgetIndex != -1) + { + switch (widget->type) + { case WWT_VIEWPORT: - if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TITLE_DEMO))) { + if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TITLE_DEMO))) + { input_viewport_drag_begin(w, x, y); } break; @@ -313,21 +339,29 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) break; case INPUT_STATE_POSITIONING_WINDOW: w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number); - if (w == NULL) { + if (w == NULL) + { _inputState = INPUT_STATE_RESET; - } else { + } + else + { input_window_position_continue(w, gInputDragLastX, gInputDragLastY, x, y); - if (state == MOUSE_STATE_LEFT_RELEASE) { + if (state == MOUSE_STATE_LEFT_RELEASE) + { input_window_position_end(w, x, y); } } break; case INPUT_STATE_VIEWPORT_RIGHT: - if (state == MOUSE_STATE_RELEASED) { + if (state == MOUSE_STATE_RELEASED) + { input_viewport_drag_continue(); - } else if (state == MOUSE_STATE_RIGHT_RELEASE) { + } + else if (state == MOUSE_STATE_RIGHT_RELEASE) + { input_viewport_drag_end(); - if (_ticksSinceDragStart < 500) { + if (_ticksSinceDragStart < 500) + { // If the user pressed the right mouse button for less than 500 ticks, interpret as right click viewport_interaction_right_click(x, y); } @@ -338,30 +372,30 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) break; case INPUT_STATE_VIEWPORT_LEFT: w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number); - if (w == NULL) { + if (w == NULL) + { _inputState = INPUT_STATE_RESET; break; } - switch (state) { + switch (state) + { case MOUSE_STATE_RELEASED: - if (w->viewport == NULL) { + if (w->viewport == NULL) + { _inputState = INPUT_STATE_RESET; break; } - if (w->classification != _dragWidget.window_classification || - w->number != _dragWidget.window_number || - !(_inputFlags & INPUT_FLAG_TOOL_ACTIVE) - ) { + if (w->classification != _dragWidget.window_classification || w->number != _dragWidget.window_number || + !(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + { break; } - w = window_find_by_number( - gCurrentToolWidget.window_classification, - gCurrentToolWidget.window_number - ); - if (w == NULL) { + w = window_find_by_number(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); + if (w == NULL) + { break; } @@ -369,16 +403,18 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) break; case MOUSE_STATE_LEFT_RELEASE: _inputState = INPUT_STATE_RESET; - if (_dragWidget.window_number == w->number) { - if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) { - w = window_find_by_number( - gCurrentToolWidget.window_classification, - gCurrentToolWidget.window_number - ); - if (w != NULL) { + if (_dragWidget.window_number == w->number) + { + if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + { + w = window_find_by_number(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); + if (w != NULL) + { window_event_tool_up_call(w, gCurrentToolWidget.widget_index, x, y); } - } else if (!(_inputFlags & INPUT_FLAG_4)) { + } + else if (!(_inputFlags & INPUT_FLAG_4)) + { viewport_interaction_left_click(x, y); } } @@ -386,7 +422,8 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) } break; case INPUT_STATE_SCROLL_LEFT: - switch (state) { + switch (state) + { case MOUSE_STATE_RELEASED: input_scroll_continue(w, widgetIndex, state, x, y); break; @@ -397,13 +434,18 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) break; case INPUT_STATE_RESIZING: w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number); - if (w == NULL) { + if (w == NULL) + { _inputState = INPUT_STATE_RESET; - } else { - if (state == MOUSE_STATE_LEFT_RELEASE) { + } + else + { + if (state == MOUSE_STATE_LEFT_RELEASE) + { input_window_resize_end(); } - if (state == MOUSE_STATE_RELEASED || state == MOUSE_STATE_LEFT_RELEASE) { + if (state == MOUSE_STATE_RELEASED || state == MOUSE_STATE_LEFT_RELEASE) + { input_window_resize_continue(w, x, y); } } @@ -416,7 +458,7 @@ static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state) #pragma region Window positioning / resizing -void input_window_position_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +void input_window_position_begin(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y) { _inputState = INPUT_STATE_POSITIONING_WINDOW; gInputDragLastX = x - w->x; @@ -426,7 +468,7 @@ void input_window_position_begin(rct_window *w, rct_widgetindex widgetIndex, sin _dragWidget.widget_index = widgetIndex; } -static void input_window_position_continue(rct_window *w, sint32 lastX, sint32 lastY, sint32 newX, sint32 newY) +static void input_window_position_continue(rct_window * w, sint32 lastX, sint32 lastY, sint32 newX, sint32 newY) { sint32 snapProximity; @@ -434,7 +476,7 @@ static void input_window_position_continue(rct_window *w, sint32 lastX, sint32 l window_move_and_snap(w, newX - lastX, newY - lastY, snapProximity); } -static void input_window_position_end(rct_window *w, sint32 x, sint32 y) +static void input_window_position_end(rct_window * w, sint32 x, sint32 y) { _inputState = INPUT_STATE_NORMAL; gTooltipTimeout = 0; @@ -442,7 +484,7 @@ static void input_window_position_end(rct_window *w, sint32 x, sint32 y) window_event_moved_call(w, x, y); } -static void input_window_resize_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +static void input_window_resize_begin(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y) { _inputState = INPUT_STATE_RESIZING; gInputDragLastX = x; @@ -454,20 +496,17 @@ static void input_window_resize_begin(rct_window *w, rct_widgetindex widgetIndex _originalWindowHeight = w->height; } -static void input_window_resize_continue(rct_window *w, sint32 x, sint32 y) +static void input_window_resize_continue(rct_window * w, sint32 x, sint32 y) { - if (y < (sint32)context_get_height() - 2) { + if (y < (sint32)context_get_height() - 2) + { sint32 dx, dy, targetWidth, targetHeight; dx = x - gInputDragLastX; dy = y - gInputDragLastY; targetWidth = _originalWindowWidth + dx; targetHeight = _originalWindowHeight + dy; - window_resize( - w, - targetWidth - w->width, - targetHeight - w->height - ); + window_resize(w, targetWidth - w->width, targetHeight - w->height); } } @@ -482,7 +521,7 @@ static void input_window_resize_end() #pragma region Viewport dragging -static void input_viewport_drag_begin(rct_window *w, sint32 x, sint32 y) +static void input_viewport_drag_begin(rct_window * w, sint32 x, sint32 y) { w->flags &= ~WF_SCROLLING_TO_LOCATION; _inputState = INPUT_STATE_VIEWPORT_RIGHT; @@ -498,8 +537,8 @@ static void input_viewport_drag_begin(rct_window *w, sint32 x, sint32 y) static void input_viewport_drag_continue() { sint32 dx, dy, newDragX, newDragY; - rct_window *w; - rct_viewport *viewport; + rct_window * w; + rct_viewport * viewport; context_get_cursor_position(&newDragX, &newDragY); @@ -509,18 +548,23 @@ static void input_viewport_drag_continue() // #3294: Window can be closed during a drag session, so just finish // the session if the window no longer exists - if (w == NULL) { + if (w == NULL) + { input_viewport_drag_end(); return; } viewport = w->viewport; _ticksSinceDragStart += gTicksSinceLastUpdate; - if (viewport == NULL) { + if (viewport == NULL) + { context_show_cursor(); _inputState = INPUT_STATE_RESET; - } else if (dx != 0 || dy != 0) { - if (!(w->flags & WF_NO_SCROLLING)) { + } + else if (dx != 0 || dy != 0) + { + if (!(w->flags & WF_NO_SCROLLING)) + { // User dragged a scrollable viewport // If the drag time is less than 500 the "drag" is usually interpreted as a right click. @@ -529,10 +573,13 @@ static void input_viewport_drag_continue() dx *= 1 << (viewport->zoom + 1); dy *= 1 << (viewport->zoom + 1); - if (gConfigGeneral.invert_viewport_drag){ + if (gConfigGeneral.invert_viewport_drag) + { w->saved_view_x -= dx; w->saved_view_y -= dy; - } else { + } + else + { w->saved_view_x += dx; w->saved_view_y += dy; } @@ -552,9 +599,9 @@ static void input_viewport_drag_end() #pragma region Scroll bars -static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +static void input_scroll_begin(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 y) { - rct_widget *widget; + rct_widget * widget; widget = &w->widgets[widgetIndex]; @@ -572,13 +619,14 @@ static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint3 _currentScrollArea = scroll_area; _currentScrollIndex = scroll_id; window_event_unknown_15_call(w, scroll_id, scroll_area); - if (scroll_area == SCROLL_PART_VIEW){ + if (scroll_area == SCROLL_PART_VIEW) + { window_event_scroll_mousedown_call(w, scroll_id, eax, ebx); return; } - rct_widget* widg = &w->widgets[widgetIndex]; - rct_scroll* scroll = &w->scrolls[scroll_id]; + rct_widget * widg = &w->widgets[widgetIndex]; + rct_scroll * scroll = &w->scrolls[scroll_id]; sint32 widget_width = widg->right - widg->left - 1; if (scroll->flags & VSCROLLBAR_VISIBLE) @@ -590,7 +638,8 @@ static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint3 widget_height -= 11; sint32 widget_content_height = Math::Max(scroll->v_bottom - widget_height, 0); - switch (scroll_area) { + switch (scroll_area) + { case SCROLL_PART_HSCROLLBAR_LEFT: scroll->h_left = Math::Max(scroll->h_left - 3, 0); break; @@ -622,33 +671,34 @@ static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint3 window_invalidate_by_number(widgetIndex, w->classification); } -static void input_scroll_continue(rct_window *w, rct_widgetindex widgetIndex, sint32 state, sint32 x, sint32 y) +static void input_scroll_continue(rct_window * w, rct_widgetindex widgetIndex, sint32 state, sint32 x, sint32 y) { - rct_widget *widget; + rct_widget * widget; sint32 scroll_part, scroll_id; sint32 x2, y2; assert(w != NULL); widget = &w->widgets[widgetIndex]; - if (w->classification != gPressedWidget.window_classification || - w->number != gPressedWidget.window_number || - widgetIndex != gPressedWidget.widget_index - ) { + if (w->classification != gPressedWidget.window_classification || w->number != gPressedWidget.window_number || + widgetIndex != gPressedWidget.widget_index) + { invalidate_scroll(); return; } widget_scroll_get_part(w, widget, x, y, &x2, &y2, &scroll_part, &scroll_id); - if (_currentScrollArea == SCROLL_PART_HSCROLLBAR_THUMB){ + if (_currentScrollArea == SCROLL_PART_HSCROLLBAR_THUMB) + { sint32 originalTooltipCursorX = gTooltipCursorX; gTooltipCursorX = x; input_scroll_part_update_hthumb(w, widgetIndex, x - originalTooltipCursorX, scroll_id); return; } - if (_currentScrollArea == SCROLL_PART_VSCROLLBAR_THUMB){ + if (_currentScrollArea == SCROLL_PART_VSCROLLBAR_THUMB) + { sint32 originalTooltipCursorY = gTooltipCursorY; gTooltipCursorY = y; input_scroll_part_update_vthumb(w, widgetIndex, y - originalTooltipCursorY, scroll_id); @@ -658,12 +708,14 @@ static void input_scroll_continue(rct_window *w, rct_widgetindex widgetIndex, si x = x2; y = y2; - if (scroll_part != _currentScrollArea) { + if (scroll_part != _currentScrollArea) + { invalidate_scroll(); return; } - switch (scroll_part){ + switch (scroll_part) + { case SCROLL_PART_VIEW: window_event_scroll_mousedrag_call(w, scroll_id, x, y); break; @@ -692,11 +744,12 @@ static void input_scroll_end() * * rct2: 0x006E98F2 */ -static void input_scroll_part_update_hthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 scroll_id) +static void input_scroll_part_update_hthumb(rct_window * w, rct_widgetindex widgetIndex, sint32 x, sint32 scroll_id) { - rct_widget *widget = &w->widgets[widgetIndex]; + rct_widget * widget = &w->widgets[widgetIndex]; - if (window_find_by_number(w->classification, w->number)) { + if (window_find_by_number(w->classification, w->number)) + { sint32 newLeft; newLeft = w->scrolls[scroll_id].h_right; newLeft *= x; @@ -729,12 +782,13 @@ static void input_scroll_part_update_hthumb(rct_window *w, rct_widgetindex widge * * rct2: 0x006E99A9 */ -static void input_scroll_part_update_vthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id) +static void input_scroll_part_update_vthumb(rct_window * w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id) { assert(w != NULL); - rct_widget *widget = &w->widgets[widgetIndex]; + rct_widget * widget = &w->widgets[widgetIndex]; - if (window_find_by_number(w->classification, w->number)) { + if (window_find_by_number(w->classification, w->number)) + { sint32 newTop; newTop = w->scrolls[scroll_id].v_bottom; newTop *= y; @@ -767,10 +821,11 @@ static void input_scroll_part_update_vthumb(rct_window *w, rct_widgetindex widge * * rct2: 0x006E9A60 */ -static void input_scroll_part_update_hleft(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) +static void input_scroll_part_update_hleft(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); - if (window_find_by_number(w->classification, w->number)) { + if (window_find_by_number(w->classification, w->number)) + { w->scrolls[scroll_id].flags |= HSCROLLBAR_LEFT_PRESSED; if (w->scrolls[scroll_id].h_left >= 3) w->scrolls[scroll_id].h_left -= 3; @@ -783,11 +838,12 @@ static void input_scroll_part_update_hleft(rct_window *w, rct_widgetindex widget * * rct2: 0x006E9ABF */ -static void input_scroll_part_update_hright(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) +static void input_scroll_part_update_hright(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); - rct_widget *widget = &w->widgets[widgetIndex]; - if (window_find_by_number(w->classification, w->number)) { + rct_widget * widget = &w->widgets[widgetIndex]; + if (window_find_by_number(w->classification, w->number)) + { w->scrolls[scroll_id].flags |= HSCROLLBAR_RIGHT_PRESSED; w->scrolls[scroll_id].h_left += 3; sint32 newLeft = widget->right - widget->left - 1; @@ -808,10 +864,11 @@ static void input_scroll_part_update_hright(rct_window *w, rct_widgetindex widge * * rct2: 0x006E9C37 */ -static void input_scroll_part_update_vtop(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) +static void input_scroll_part_update_vtop(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); - if (window_find_by_number(w->classification, w->number)) { + if (window_find_by_number(w->classification, w->number)) + { w->scrolls[scroll_id].flags |= VSCROLLBAR_UP_PRESSED; if (w->scrolls[scroll_id].v_top >= 3) w->scrolls[scroll_id].v_top -= 3; @@ -824,11 +881,12 @@ static void input_scroll_part_update_vtop(rct_window *w, rct_widgetindex widgetI * * rct2: 0x006E9C96 */ -static void input_scroll_part_update_vbottom(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) +static void input_scroll_part_update_vbottom(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); - rct_widget *widget = &w->widgets[widgetIndex]; - if (window_find_by_number(w->classification, w->number)) { + rct_widget * widget = &w->widgets[widgetIndex]; + if (window_find_by_number(w->classification, w->number)) + { w->scrolls[scroll_id].flags |= VSCROLLBAR_DOWN_PRESSED; w->scrolls[scroll_id].v_top += 3; sint32 newTop = widget->bottom - widget->top - 1; @@ -853,13 +911,14 @@ static void input_scroll_part_update_vbottom(rct_window *w, rct_widgetindex widg * * rct2: 0x006E9253 */ -static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex) +static void input_widget_over(sint32 x, sint32 y, rct_window * w, rct_widgetindex widgetIndex) { rct_windowclass windowClass = WC_NULL; rct_windownumber windowNumber = 0; - rct_widget *widget = NULL; + rct_widget * widget = NULL; - if (w != NULL) { + if (w != NULL) + { windowClass = w->classification; windowNumber = w->number; widget = &w->widgets[widgetIndex]; @@ -867,18 +926,21 @@ static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex input_widget_over_change_check(windowClass, windowNumber, widgetIndex); - if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) { + 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 { + else + { window_event_scroll_mouseover_call(w, edx, eax, ebx); input_update_tooltip(w, widgetIndex, x, y); } } - else { + else + { input_update_tooltip(w, widgetIndex, x, y); } @@ -891,17 +953,17 @@ static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex * * rct2: 0x006E9269 */ -static void input_widget_over_change_check(rct_windowclass windowClass, rct_windownumber windowNumber, rct_widgetindex widgetIndex) +static void input_widget_over_change_check(rct_windowclass windowClass, rct_windownumber windowNumber, + rct_widgetindex widgetIndex) { // Prevents invalid widgets being clicked source of bug is elsewhere if (widgetIndex == -1) return; // Check if the widget that the cursor was over, has changed - if (windowClass != gHoverWidget.window_classification || - windowNumber != gHoverWidget.window_number || - widgetIndex != gHoverWidget.widget_index - ) { + if (windowClass != gHoverWidget.window_classification || windowNumber != gHoverWidget.window_number || + widgetIndex != gHoverWidget.widget_index) + { // Invalidate last widget cursor was on if widget is a flat button input_widget_over_flatbutton_invalidate(); @@ -922,15 +984,14 @@ static void input_widget_over_change_check(rct_windowclass windowClass, rct_wind */ static void input_widget_over_flatbutton_invalidate() { - rct_window *w = window_find_by_number(gHoverWidget.window_classification, gHoverWidget.window_number); - if (w != NULL) { + rct_window * w = window_find_by_number(gHoverWidget.window_classification, gHoverWidget.window_number); + if (w != NULL) + { window_event_invalidate_call(w); - if (w->widgets[gHoverWidget.widget_index].type == WWT_FLATBTN) { - widget_invalidate_by_number( - gHoverWidget.window_classification, - gHoverWidget.window_number, - gHoverWidget.widget_index - ); + if (w->widgets[gHoverWidget.widget_index].type == WWT_FLATBTN) + { + widget_invalidate_by_number(gHoverWidget.window_classification, gHoverWidget.window_number, + gHoverWidget.widget_index); } } } @@ -939,13 +1000,14 @@ static void input_widget_over_flatbutton_invalidate() * * rct2: 0x006E95F9 */ -static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex) +static void input_widget_left(sint32 x, sint32 y, rct_window * w, rct_widgetindex widgetIndex) { rct_windowclass windowClass = WC_NULL; rct_windownumber windowNumber = 0; - rct_widget *widget; + rct_widget * widget; - if (w != NULL) { + if (w != NULL) + { windowClass = w->classification; windowNumber = w->number; } @@ -962,15 +1024,16 @@ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex if (widgetIndex == -1) return; - if (windowClass != gCurrentTextBox.window.classification || - windowNumber != gCurrentTextBox.window.number || - widgetIndex != gCurrentTextBox.widget_index) { + if (windowClass != gCurrentTextBox.window.classification || windowNumber != gCurrentTextBox.window.number || + widgetIndex != gCurrentTextBox.widget_index) + { window_cancel_textbox(); } widget = &w->widgets[widgetIndex]; - switch (widget->type) { + switch (widget->type) + { case WWT_FRAME: case WWT_RESIZE: if (window_can_resize(w) && (x >= w->x + w->width - 19 && y >= w->y + w->height - 19)) @@ -982,12 +1045,11 @@ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex gInputDragLastY = y; _dragWidget.window_classification = windowClass; _dragWidget.window_number = windowNumber; - if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) { - w = window_find_by_number( - gCurrentToolWidget.window_classification, - gCurrentToolWidget.window_number - ); - if (w != NULL) { + if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) + { + w = window_find_by_number(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); + if (w != NULL) + { window_event_tool_down_call(w, gCurrentToolWidget.widget_index, x, y); _inputFlags |= INPUT_FLAG_4; } @@ -1000,7 +1062,8 @@ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex input_scroll_begin(w, widgetIndex, x, y); break; default: - if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) { + if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) + { audio_play_sound(SOUND_CLICK_1, 0, w->x + ((widget->left + widget->right) / 2)); // Set new cursor down widget @@ -1022,11 +1085,11 @@ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex /** * -* rct2: 0x006ED833 + * rct2: 0x006ED833 */ void process_mouse_over(sint32 x, sint32 y) { - rct_window* window; + rct_window * window; sint32 cursorId; @@ -1034,26 +1097,28 @@ void process_mouse_over(sint32 x, sint32 y) set_map_tooltip_format_arg(0, rct_string_id, STR_NONE); window = window_find_from_point(x, y); - if (window != NULL) { + if (window != NULL) + { sint32 ebx, edi; - rct_window* subWindow; + rct_window * subWindow; rct_widgetindex widgetId = window_find_widget_from_point(window, x, y); - if (widgetId != -1) { - switch (window->widgets[widgetId].type){ + if (widgetId != -1) + { + switch (window->widgets[widgetId].type) + { case WWT_VIEWPORT: - if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) { - if (viewport_interaction_left_over(x, y)) { + if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + { + if (viewport_interaction_left_over(x, y)) + { set_cursor(CURSOR_HAND_POINT); return; } break; } cursorId = gCurrentToolId; - subWindow = window_find_by_number( - gCurrentToolWidget.window_classification, - gCurrentToolWidget.window_number - ); + subWindow = window_find_by_number(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); if (subWindow == NULL) break; @@ -1090,7 +1155,8 @@ void process_mouse_over(sint32 x, sint32 y) { sint32 output_scroll_area, scroll_id; sint32 scroll_x, scroll_y; - widget_scroll_get_part(window, &window->widgets[widgetId], x, y, &scroll_x, &scroll_y, &output_scroll_area, &scroll_id); + widget_scroll_get_part(window, &window->widgets[widgetId], x, y, &scroll_x, &scroll_y, &output_scroll_area, + &scroll_id); cursorId = scroll_id; if (output_scroll_area != SCROLL_PART_VIEW) { @@ -1124,16 +1190,12 @@ void process_mouse_tool(sint32 x, sint32 y) { if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) { - rct_window* w = window_find_by_number( - gCurrentToolWidget.window_classification, - gCurrentToolWidget.window_number - ); + rct_window * w = window_find_by_number(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); if (!w) tool_cancel(); else window_event_tool_update_call(w, gCurrentToolWidget.widget_index, x, y); - } } @@ -1141,7 +1203,8 @@ void process_mouse_tool(sint32 x, sint32 y) * * rct2: 0x006E8DA7 */ -void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetindex widgetIndex, rct_window *w, rct_widget *widget) +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; @@ -1149,13 +1212,15 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde 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) { + 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) { + switch (state) + { case MOUSE_STATE_RELEASED: if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; @@ -1163,19 +1228,24 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde if (w->disabled_widgets & (1ULL << widgetIndex)) break; - if (_clickRepeatTicks != 0) { + if (_clickRepeatTicks != 0) + { _clickRepeatTicks++; // Handle click repeat - if (_clickRepeatTicks >= 16 && (_clickRepeatTicks & 3) == 0) { - if (w->hold_down_widgets & (1ULL << widgetIndex)) { + 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) { + if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + { + if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) + { gDropdownHighlightedIndex = gDropdownDefaultIndex; window_invalidate_by_class(WC_DROPDOWN); } @@ -1187,30 +1257,40 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde return; case MOUSE_STATE_LEFT_RELEASE: case MOUSE_STATE_RIGHT_PRESS: - if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) { - if (w) { + if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) + { + if (w) + { sint32 dropdown_index = 0; - if (w->classification == WC_DROPDOWN) { + if (w->classification == WC_DROPDOWN) + { dropdown_index = dropdown_index_from_point(x, y, w); - if (dropdown_index == -1) { + if (dropdown_index == -1) + { goto dropdown_cleanup; } - if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) { + if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) + { goto dropdown_cleanup; } - if (gDropdownItemsFormat[dropdown_index] == DROPDOWN_SEPARATOR) { + if (gDropdownItemsFormat[dropdown_index] == DROPDOWN_SEPARATOR) + { goto dropdown_cleanup; } } - else { - if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) + 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)){ + if (_inputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN) + { + if (!(_inputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)) + { _inputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP; return; } @@ -1219,7 +1299,8 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde window_close_by_class(WC_DROPDOWN); cursor_w = window_find_by_number(cursor_w_class, cursor_w_number); - if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) { + if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + { _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } @@ -1230,8 +1311,10 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde gTooltipWidget.window_classification = cursor_w_class; gTooltipWidget.window_number = cursor_w_number; - if (dropdown_index == -1) { - if (!dropdown_is_disabled(gDropdownDefaultIndex)) { + if (dropdown_index == -1) + { + if (!dropdown_is_disabled(gDropdownDefaultIndex)) + { dropdown_index = gDropdownDefaultIndex; } } @@ -1240,13 +1323,14 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde dropdown_cleanup: window_close_by_class(WC_DROPDOWN); } - + _inputState = INPUT_STATE_NORMAL; - - if (state == MOUSE_STATE_RIGHT_PRESS) { + + if (state == MOUSE_STATE_RIGHT_PRESS) + { return; } - + gTooltipTimeout = 0; gTooltipWidget.widget_index = cursor_widgetIndex; @@ -1273,9 +1357,11 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde } _clickRepeatTicks = 0; - if (_inputState != INPUT_STATE_DROPDOWN_ACTIVE){ + if (_inputState != INPUT_STATE_DROPDOWN_ACTIVE) + { // Hold down widget and drag outside of area?? - if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED){ + if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + { _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex); } @@ -1284,17 +1370,21 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde gDropdownHighlightedIndex = -1; window_invalidate_by_class(WC_DROPDOWN); - if (w == NULL) { + if (w == NULL) + { return; } - if (w->classification == WC_DROPDOWN){ + if (w->classification == WC_DROPDOWN) + { sint32 dropdown_index = dropdown_index_from_point(x, y, w); - if (dropdown_index == -1) { + if (dropdown_index == -1) + { return; } - if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) { + if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) + { gDropdownLastColourHover = dropdown_index; window_tooltip_close(); @@ -1336,52 +1426,58 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde window_tooltip_show(colourTooltips[dropdown_index], x, y); } - if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) { + if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index)) + { return; } - if (gDropdownItemsFormat[dropdown_index] == DROPDOWN_SEPARATOR) { + if (gDropdownItemsFormat[dropdown_index] == DROPDOWN_SEPARATOR) + { return; } gDropdownHighlightedIndex = dropdown_index; window_invalidate_by_class(WC_DROPDOWN); - } else { + } + else + { gDropdownLastColourHover = -1; window_tooltip_close(); } } -static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 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) { + if (gTooltipWidget.window_classification == 255) + { + if (gTooltipCursorX == x && gTooltipCursorY == y) + { _tooltipNotShownTicks++; - if (_tooltipNotShownTicks > 50) { + if (_tooltipNotShownTicks > 50) + { gTooltipTimeout = 0; window_tooltip_open(w, widgetIndex, x, y); } } - } else { + } + else + { reset_tooltip_not_shown(); - if (w == NULL || - gTooltipWidget.window_classification != w->classification || - gTooltipWidget.window_number != w->number || - gTooltipWidget.widget_index != widgetIndex - ) { + 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) { + if (gTooltipTimeout >= 8000) + { window_close_by_class(WC_TOOLTIP); } } } - - #pragma endregion #pragma region Keyboard input @@ -1393,8 +1489,10 @@ static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sin sint32 get_next_key() { uint8 * keysPressed = (uint8 *)context_get_keys_pressed(); - for (sint32 i = 0; i < 221; i++) { - if (keysPressed[i]) { + for (sint32 i = 0; i < 221; i++) + { + if (keysPressed[i]) + { keysPressed[i] = 0; return i; } @@ -1406,27 +1504,27 @@ sint32 get_next_key() #pragma endregion /** -* -* rct2: 0x006ED990 -*/ + * + * rct2: 0x006ED990 + */ void set_cursor(uint8 cursor_id) { - if (_inputState == INPUT_STATE_RESIZING) { + if (_inputState == INPUT_STATE_RESIZING) + { cursor_id = CURSOR_DIAGONAL_ARROWS; } context_setcurrentcursor(cursor_id); } - - /** * * rct2: 0x006E876D */ void invalidate_scroll() { - rct_window* w = window_find_by_number(gPressedWidget.window_classification, gPressedWidget.window_number); - if (w != NULL) { + rct_window * w = window_find_by_number(gPressedWidget.window_classification, gPressedWidget.window_number); + if (w != NULL) + { // Reset to basic scroll w->scrolls[_currentScrollIndex].flags &= 0xFF11; window_invalidate_by_number(gPressedWidget.window_classification, gPressedWidget.window_number); @@ -1434,16 +1532,17 @@ void invalidate_scroll() } /** -* rct2: 0x00406C96 -*/ + * rct2: 0x00406C96 + */ void store_mouse_input(sint32 state, sint32 x, sint32 y) { uint32 writeIndex = _mouseInputQueueWriteIndex; uint32 nextWriteIndex = (writeIndex + 1) % Util::CountOf(_mouseInputQueue); // Check if the queue is full - if (nextWriteIndex != _mouseInputQueueReadIndex) { - rct_mouse_data *item = &_mouseInputQueue[writeIndex]; + if (nextWriteIndex != _mouseInputQueueReadIndex) + { + rct_mouse_data * item = &_mouseInputQueue[writeIndex]; item->x = x; item->y = y; item->state = state; @@ -1454,7 +1553,7 @@ void store_mouse_input(sint32 state, sint32 x, sint32 y) void game_handle_edge_scroll() { - rct_window *mainWindow; + rct_window * mainWindow; sint32 scrollX, scrollY; mainWindow = window_get_main();