mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 03:23:15 +01:00
@@ -134,7 +134,7 @@ void input_handle_keyboard(bool isTitle)
|
||||
if (!isTitle)
|
||||
{
|
||||
// Handle mouse scrolling
|
||||
if (input_get_state() == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling)
|
||||
if (input_get_state() == InputState::Normal && gConfigGeneral.edge_scrolling)
|
||||
{
|
||||
if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z)))
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ static rct_mouse_data* get_mouse_input()
|
||||
*/
|
||||
static void input_scroll_drag_begin(const ScreenCoordsXY& screenCoords, rct_window* w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
_inputState = INPUT_STATE_SCROLL_RIGHT;
|
||||
_inputState = InputState::ScrollRight;
|
||||
gInputDragLast = screenCoords;
|
||||
_dragWidget.window_classification = w->classification;
|
||||
_dragWidget.window_number = w->number;
|
||||
@@ -243,7 +243,7 @@ static void input_scroll_right(const ScreenCoordsXY& screenCoords, int32_t state
|
||||
if (w == nullptr)
|
||||
{
|
||||
context_show_cursor();
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ static void input_scroll_right(const ScreenCoordsXY& screenCoords, int32_t state
|
||||
}
|
||||
break;
|
||||
case MOUSE_STATE_RIGHT_RELEASE:
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
context_show_cursor();
|
||||
break;
|
||||
}
|
||||
@@ -281,10 +281,10 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
|
||||
switch (_inputState)
|
||||
{
|
||||
case INPUT_STATE_RESET:
|
||||
case InputState::Reset:
|
||||
window_tooltip_reset(screenCoords);
|
||||
// fall-through
|
||||
case INPUT_STATE_NORMAL:
|
||||
case InputState::Normal:
|
||||
switch (state)
|
||||
{
|
||||
case MOUSE_STATE_RELEASED:
|
||||
@@ -319,14 +319,14 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_WIDGET_PRESSED:
|
||||
case InputState::WidgetPressed:
|
||||
input_state_widget_pressed(screenCoords, state, widgetIndex, w, widget);
|
||||
break;
|
||||
case INPUT_STATE_POSITIONING_WINDOW:
|
||||
case InputState::PositioningWindow:
|
||||
w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
|
||||
if (w == nullptr)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -337,7 +337,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_VIEWPORT_RIGHT:
|
||||
case InputState::ViewportRight:
|
||||
if (state == MOUSE_STATE_RELEASED)
|
||||
{
|
||||
input_viewport_drag_continue();
|
||||
@@ -352,14 +352,14 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_DROPDOWN_ACTIVE:
|
||||
case InputState::DropdownActive:
|
||||
input_state_widget_pressed(screenCoords, state, widgetIndex, w, widget);
|
||||
break;
|
||||
case INPUT_STATE_VIEWPORT_LEFT:
|
||||
case InputState::ViewportLeft:
|
||||
w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
|
||||
if (w == nullptr)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
case MOUSE_STATE_RELEASED:
|
||||
if (w->viewport == nullptr)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
window_event_tool_drag_call(w, gCurrentToolWidget.widget_index, screenCoords);
|
||||
break;
|
||||
case MOUSE_STATE_LEFT_RELEASE:
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
if (_dragWidget.window_number == w->number)
|
||||
{
|
||||
if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
||||
@@ -407,7 +407,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_SCROLL_LEFT:
|
||||
case InputState::ScrollLeft:
|
||||
switch (state)
|
||||
{
|
||||
case MOUSE_STATE_RELEASED:
|
||||
@@ -418,11 +418,11 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_RESIZING:
|
||||
case InputState::Resizing:
|
||||
w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
|
||||
if (w == nullptr)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -436,7 +436,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INPUT_STATE_SCROLL_RIGHT:
|
||||
case InputState::ScrollRight:
|
||||
input_scroll_right(screenCoords, state);
|
||||
break;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ static void game_handle_input_mouse(const ScreenCoordsXY& screenCoords, int32_t
|
||||
|
||||
void input_window_position_begin(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
_inputState = INPUT_STATE_POSITIONING_WINDOW;
|
||||
_inputState = InputState::PositioningWindow;
|
||||
gInputDragLast = screenCoords - w->windowPos;
|
||||
_dragWidget.window_classification = w->classification;
|
||||
_dragWidget.window_number = w->number;
|
||||
@@ -464,7 +464,7 @@ static void input_window_position_continue(
|
||||
|
||||
static void input_window_position_end(rct_window* w, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
_inputState = INPUT_STATE_NORMAL;
|
||||
_inputState = InputState::Normal;
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget = _dragWidget;
|
||||
window_event_moved_call(w, screenCoords);
|
||||
@@ -472,7 +472,7 @@ static void input_window_position_end(rct_window* w, const ScreenCoordsXY& scree
|
||||
|
||||
static void input_window_resize_begin(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESIZING;
|
||||
_inputState = InputState::Resizing;
|
||||
gInputDragLast = screenCoords;
|
||||
_dragWidget.window_classification = w->classification;
|
||||
_dragWidget.window_number = w->number;
|
||||
@@ -495,7 +495,7 @@ static void input_window_resize_continue(rct_window* w, const ScreenCoordsXY& sc
|
||||
|
||||
static void input_window_resize_end()
|
||||
{
|
||||
_inputState = INPUT_STATE_NORMAL;
|
||||
_inputState = InputState::Normal;
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget = _dragWidget;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ static void input_window_resize_end()
|
||||
static void input_viewport_drag_begin(rct_window* w)
|
||||
{
|
||||
w->flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
_inputState = INPUT_STATE_VIEWPORT_RIGHT;
|
||||
_inputState = InputState::ViewportRight;
|
||||
_dragWidget.window_classification = w->classification;
|
||||
_dragWidget.window_number = w->number;
|
||||
_ticksSinceDragStart = 0;
|
||||
@@ -543,7 +543,7 @@ static void input_viewport_drag_continue()
|
||||
if (viewport == nullptr)
|
||||
{
|
||||
context_show_cursor();
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
}
|
||||
else if (differentialCoords.x != 0 || differentialCoords.y != 0)
|
||||
{
|
||||
@@ -580,7 +580,7 @@ static void input_viewport_drag_continue()
|
||||
|
||||
static void input_viewport_drag_end()
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
context_show_cursor();
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ static void input_scroll_begin(rct_window* w, rct_widgetindex widgetIndex, const
|
||||
|
||||
widget = &w->widgets[widgetIndex];
|
||||
|
||||
_inputState = INPUT_STATE_SCROLL_LEFT;
|
||||
_inputState = InputState::ScrollLeft;
|
||||
gPressedWidget.window_classification = w->classification;
|
||||
gPressedWidget.window_number = w->number;
|
||||
gPressedWidget.widget_index = widgetIndex;
|
||||
@@ -723,7 +723,7 @@ static void input_scroll_continue(rct_window* w, rct_widgetindex widgetIndex, co
|
||||
|
||||
static void input_scroll_end()
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
invalidate_scroll();
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,7 @@ static void input_widget_left(const ScreenCoordsXY& screenCoords, rct_window* w,
|
||||
input_window_resize_begin(w, widgetIndex, screenCoords);
|
||||
break;
|
||||
case WWT_VIEWPORT:
|
||||
_inputState = INPUT_STATE_VIEWPORT_LEFT;
|
||||
_inputState = InputState::ViewportLeft;
|
||||
gInputDragLast = screenCoords;
|
||||
_dragWidget.window_classification = windowClass;
|
||||
_dragWidget.window_number = windowNumber;
|
||||
@@ -1059,7 +1059,7 @@ static void input_widget_left(const ScreenCoordsXY& screenCoords, rct_window* w,
|
||||
gPressedWidget.window_number = windowNumber;
|
||||
gPressedWidget.widget_index = widgetIndex;
|
||||
_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
|
||||
_inputState = INPUT_STATE_WIDGET_PRESSED;
|
||||
_inputState = InputState::WidgetPressed;
|
||||
_clickRepeatTicks = 1;
|
||||
|
||||
widget_invalidate_by_number(windowClass, windowNumber, widgetIndex);
|
||||
@@ -1204,7 +1204,7 @@ void input_state_widget_pressed(
|
||||
rct_window* cursor_w = window_find_by_number(cursor_w_class, cursor_w_number);
|
||||
if (cursor_w == nullptr)
|
||||
{
|
||||
_inputState = INPUT_STATE_RESET;
|
||||
_inputState = InputState::Reset;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1233,7 +1233,7 @@ void input_state_widget_pressed(
|
||||
|
||||
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
|
||||
{
|
||||
if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE)
|
||||
if (_inputState == InputState::DropdownActive)
|
||||
{
|
||||
gDropdownHighlightedIndex = gDropdownDefaultIndex;
|
||||
window_invalidate_by_class(WC_DROPDOWN);
|
||||
@@ -1246,7 +1246,7 @@ void input_state_widget_pressed(
|
||||
return;
|
||||
case MOUSE_STATE_LEFT_RELEASE:
|
||||
case MOUSE_STATE_RIGHT_PRESS:
|
||||
if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE)
|
||||
if (_inputState == InputState::DropdownActive)
|
||||
{
|
||||
if (w)
|
||||
{
|
||||
@@ -1300,7 +1300,7 @@ void input_state_widget_pressed(
|
||||
widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex);
|
||||
}
|
||||
|
||||
_inputState = INPUT_STATE_NORMAL;
|
||||
_inputState = InputState::Normal;
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget.widget_index = cursor_widgetIndex;
|
||||
gTooltipWidget.window_classification = cursor_w_class;
|
||||
@@ -1318,7 +1318,7 @@ void input_state_widget_pressed(
|
||||
}
|
||||
}
|
||||
|
||||
_inputState = INPUT_STATE_NORMAL;
|
||||
_inputState = InputState::Normal;
|
||||
|
||||
if (state == MOUSE_STATE_RIGHT_PRESS)
|
||||
{
|
||||
@@ -1353,7 +1353,7 @@ void input_state_widget_pressed(
|
||||
}
|
||||
|
||||
_clickRepeatTicks = 0;
|
||||
if (_inputState != INPUT_STATE_DROPDOWN_ACTIVE)
|
||||
if (_inputState != InputState::DropdownActive)
|
||||
{
|
||||
// Hold down widget and drag outside of area??
|
||||
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
|
||||
@@ -1505,7 +1505,7 @@ int32_t get_next_key()
|
||||
*/
|
||||
void set_cursor(uint8_t cursor_id)
|
||||
{
|
||||
if (_inputState == INPUT_STATE_RESIZING)
|
||||
if (_inputState == InputState::Resizing)
|
||||
{
|
||||
cursor_id = CURSOR_DIAGONAL_ARROWS;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ bool widget_is_pressed(rct_window* w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (input_get_state() == INPUT_STATE_WIDGET_PRESSED || input_get_state() == INPUT_STATE_DROPDOWN_ACTIVE)
|
||||
if (input_get_state() == InputState::WidgetPressed || input_get_state() == InputState::DropdownActive)
|
||||
{
|
||||
if (!(input_test_flag(INPUT_FLAG_WIDGET_PRESSED)))
|
||||
return false;
|
||||
|
||||
@@ -223,7 +223,7 @@ void window_dropdown_show_text_custom_width(
|
||||
_dropdownItemsChecked.reset();
|
||||
gDropdownIsColour = false;
|
||||
gDropdownDefaultIndex = -1;
|
||||
input_set_state(INPUT_STATE_DROPDOWN_ACTIVE);
|
||||
input_set_state(InputState::DropdownActive);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +303,7 @@ void window_dropdown_show_image(
|
||||
_dropdownItemsChecked.reset();
|
||||
gDropdownIsColour = false;
|
||||
gDropdownDefaultIndex = -1;
|
||||
input_set_state(INPUT_STATE_DROPDOWN_ACTIVE);
|
||||
input_set_state(InputState::DropdownActive);
|
||||
}
|
||||
|
||||
void window_dropdown_close()
|
||||
|
||||
@@ -766,7 +766,7 @@ static void window_scenery_update(rct_window* w)
|
||||
w->scenery.hover_counter++;
|
||||
if (w->scenery.hover_counter < 8)
|
||||
{
|
||||
if (input_get_state() != INPUT_STATE_SCROLL_LEFT)
|
||||
if (input_get_state() != InputState::ScrollLeft)
|
||||
{
|
||||
w->min_width = WINDOW_SCENERY_WIDTH;
|
||||
w->max_width = WINDOW_SCENERY_WIDTH;
|
||||
@@ -792,7 +792,7 @@ static void window_scenery_update(rct_window* w)
|
||||
else
|
||||
{
|
||||
w->scenery.hover_counter = 0;
|
||||
if (input_get_state() != INPUT_STATE_SCROLL_LEFT)
|
||||
if (input_get_state() != InputState::ScrollLeft)
|
||||
{
|
||||
w->min_width = WINDOW_SCENERY_WIDTH;
|
||||
w->max_width = WINDOW_SCENERY_WIDTH;
|
||||
|
||||
@@ -69,7 +69,7 @@ void window_tooltip_reset(const ScreenCoordsXY& screenCoords)
|
||||
gTooltipCursorY = screenCoords.y;
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget.window_classification = 255;
|
||||
input_set_state(INPUT_STATE_NORMAL);
|
||||
input_set_state(InputState::Normal);
|
||||
input_set_flag(INPUT_FLAG_4, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void GameState::Update()
|
||||
UpdateLogic();
|
||||
if (gGameSpeed == 1)
|
||||
{
|
||||
if (input_get_state() == INPUT_STATE_RESET || input_get_state() == INPUT_STATE_NORMAL)
|
||||
if (input_get_state() == InputState::Reset || input_get_state() == InputState::Normal)
|
||||
{
|
||||
if (input_test_flag(INPUT_FLAG_VIEWPORT_SCROLLING))
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "Context.h"
|
||||
|
||||
INPUT_STATE _inputState;
|
||||
InputState _inputState;
|
||||
uint8_t _inputFlags;
|
||||
uint8_t gInputPlaceObjectModifier;
|
||||
|
||||
@@ -63,12 +63,12 @@ void input_reset_flags()
|
||||
_inputFlags = 0;
|
||||
}
|
||||
|
||||
void input_set_state(INPUT_STATE state)
|
||||
void input_set_state(InputState state)
|
||||
{
|
||||
_inputState = state;
|
||||
}
|
||||
|
||||
INPUT_STATE input_get_state()
|
||||
InputState input_get_state()
|
||||
{
|
||||
return _inputState;
|
||||
}
|
||||
|
||||
@@ -46,18 +46,18 @@ enum MOUSE_STATE
|
||||
MOUSE_STATE_RIGHT_RELEASE
|
||||
};
|
||||
|
||||
enum INPUT_STATE
|
||||
enum class InputState
|
||||
{
|
||||
INPUT_STATE_RESET,
|
||||
INPUT_STATE_NORMAL,
|
||||
INPUT_STATE_WIDGET_PRESSED,
|
||||
INPUT_STATE_POSITIONING_WINDOW,
|
||||
INPUT_STATE_VIEWPORT_RIGHT,
|
||||
INPUT_STATE_DROPDOWN_ACTIVE,
|
||||
INPUT_STATE_VIEWPORT_LEFT,
|
||||
INPUT_STATE_SCROLL_LEFT,
|
||||
INPUT_STATE_RESIZING,
|
||||
INPUT_STATE_SCROLL_RIGHT
|
||||
Reset,
|
||||
Normal,
|
||||
WidgetPressed,
|
||||
PositioningWindow,
|
||||
ViewportRight,
|
||||
DropdownActive,
|
||||
ViewportLeft,
|
||||
ScrollLeft,
|
||||
Resizing,
|
||||
ScrollRight
|
||||
};
|
||||
|
||||
enum PLACE_OBJECT_MODIFIER
|
||||
@@ -90,7 +90,7 @@ extern TOOL_IDX gCurrentToolId;
|
||||
extern widget_ref gCurrentToolWidget;
|
||||
|
||||
// TODO: Move to openrct2-ui and make static again
|
||||
extern INPUT_STATE _inputState;
|
||||
extern InputState _inputState;
|
||||
extern uint8_t _inputFlags;
|
||||
extern uint16_t _tooltipNotShownTicks;
|
||||
|
||||
@@ -110,8 +110,8 @@ void input_reset_flags();
|
||||
|
||||
bool input_test_place_object_modifier(PLACE_OBJECT_MODIFIER modifier);
|
||||
|
||||
void input_set_state(INPUT_STATE state);
|
||||
INPUT_STATE input_get_state();
|
||||
void input_set_state(InputState state);
|
||||
InputState input_get_state();
|
||||
|
||||
void reset_tooltip_not_shown();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void viewport_init_all()
|
||||
|
||||
// ?
|
||||
input_reset_flags();
|
||||
input_set_state(INPUT_STATE_RESET);
|
||||
input_set_state(InputState::Reset);
|
||||
gPressedWidget.window_classification = 255;
|
||||
gPickupPeepImage = UINT32_MAX;
|
||||
reset_tooltip_not_shown();
|
||||
|
||||
Reference in New Issue
Block a user