2014-08-24 19:45:47 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2014-08-24 19:45:47 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2014-08-24 19:45:47 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-08-24 19:45:47 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _INPUT_H_
|
|
|
|
#define _INPUT_H_
|
|
|
|
|
2018-01-06 01:05:16 +01:00
|
|
|
#include "interface/Window.h"
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
enum INPUT_FLAGS
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
INPUT_FLAG_WIDGET_PRESSED = (1 << 0),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2020-11-03 09:16:06 +01:00
|
|
|
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen
|
2017-06-06 23:24:18 +02:00
|
|
|
INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// The mouse has been released and the dropdown is still open
|
|
|
|
// INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens
|
|
|
|
INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
INPUT_FLAG_TOOL_ACTIVE = (1 << 3),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Left click on a viewport
|
|
|
|
INPUT_FLAG_4 = (1 << 4),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
INPUT_FLAG_5 = (1 << 5),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Some of the map tools (clear, footpath, scenery)
|
|
|
|
// never read as far as I know.
|
|
|
|
INPUT_FLAG_6 = (1 << 6),
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7)
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2016-01-05 23:33:47 +01:00
|
|
|
|
2020-11-03 22:41:19 +01:00
|
|
|
enum class MouseState : uint32_t
|
2018-06-22 23:25:16 +02:00
|
|
|
{
|
2020-11-03 22:41:19 +01:00
|
|
|
Released,
|
|
|
|
LeftPress,
|
|
|
|
LeftRelease,
|
|
|
|
RightPress,
|
|
|
|
RightRelease
|
2016-09-05 21:50:33 +02:00
|
|
|
};
|
|
|
|
|
2020-07-28 00:51:10 +02:00
|
|
|
enum class InputState
|
2018-06-22 23:25:16 +02:00
|
|
|
{
|
2020-07-28 00:51:10 +02:00
|
|
|
Reset,
|
|
|
|
Normal,
|
|
|
|
WidgetPressed,
|
|
|
|
PositioningWindow,
|
|
|
|
ViewportRight,
|
|
|
|
DropdownActive,
|
|
|
|
ViewportLeft,
|
|
|
|
ScrollLeft,
|
|
|
|
Resizing,
|
|
|
|
ScrollRight
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-02-27 20:20:41 +01:00
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
enum PLACE_OBJECT_MODIFIER
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
PLACE_OBJECT_MODIFIER_NONE = 0,
|
|
|
|
PLACE_OBJECT_MODIFIER_SHIFT_Z = (1 << 0),
|
|
|
|
PLACE_OBJECT_MODIFIER_COPY_Z = (1 << 1),
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-02-27 20:20:41 +01:00
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
struct widget_ref
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_windowclass window_classification;
|
|
|
|
rct_windownumber window_number;
|
|
|
|
rct_widgetindex widget_index;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2016-01-05 01:02:23 +01:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
extern uint8_t gInputPlaceObjectModifier;
|
2016-01-04 23:45:51 +01:00
|
|
|
|
2019-12-17 18:38:20 +01:00
|
|
|
extern ScreenCoordsXY gInputDragLast;
|
2016-01-06 19:31:25 +01:00
|
|
|
|
2016-01-05 23:05:00 +01:00
|
|
|
extern widget_ref gHoverWidget;
|
2016-01-05 22:46:38 +01:00
|
|
|
extern widget_ref gPressedWidget;
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
extern uint16_t gTooltipTimeout;
|
2016-01-05 01:02:23 +01:00
|
|
|
extern widget_ref gTooltipWidget;
|
2020-10-17 10:10:08 +02:00
|
|
|
extern ScreenCoordsXY gTooltipCursor;
|
2016-01-05 01:02:23 +01:00
|
|
|
|
2020-12-23 05:11:15 +01:00
|
|
|
extern Tool gCurrentToolId;
|
2016-04-15 19:26:47 +02:00
|
|
|
extern widget_ref gCurrentToolWidget;
|
|
|
|
|
2017-12-07 22:16:20 +01:00
|
|
|
// TODO: Move to openrct2-ui and make static again
|
2020-07-28 00:51:10 +02:00
|
|
|
extern InputState _inputState;
|
2018-06-20 17:28:51 +02:00
|
|
|
extern uint8_t _inputFlags;
|
|
|
|
extern uint16_t _tooltipNotShownTicks;
|
2017-12-07 22:16:20 +01:00
|
|
|
|
2020-11-02 14:43:35 +01:00
|
|
|
void InputWindowPositionBegin(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
2017-02-27 20:20:41 +01:00
|
|
|
|
2014-11-24 18:18:21 +01:00
|
|
|
void title_handle_keyboard_input();
|
2020-11-02 14:43:35 +01:00
|
|
|
void GameHandleInput();
|
2014-08-24 19:45:47 +02:00
|
|
|
void game_handle_keyboard_input();
|
2020-11-02 14:43:35 +01:00
|
|
|
void GameHandleEdgeScroll();
|
|
|
|
int32_t GetNextKey();
|
2014-08-24 19:45:47 +02:00
|
|
|
|
2020-11-03 22:41:19 +01:00
|
|
|
void StoreMouseInput(MouseState state, const ScreenCoordsXY& screenCoords);
|
2014-08-29 10:23:57 +02:00
|
|
|
|
2017-02-27 20:20:41 +01:00
|
|
|
void input_set_flag(INPUT_FLAGS flag, bool on);
|
|
|
|
bool input_test_flag(INPUT_FLAGS flag);
|
|
|
|
void input_reset_flags();
|
|
|
|
|
2020-11-02 14:43:35 +01:00
|
|
|
bool InputTestPlaceObjectModifier(PLACE_OBJECT_MODIFIER modifier);
|
2017-02-27 20:20:41 +01:00
|
|
|
|
2020-07-28 00:51:10 +02:00
|
|
|
void input_set_state(InputState state);
|
|
|
|
InputState input_get_state();
|
2017-02-27 20:20:41 +01:00
|
|
|
|
|
|
|
void reset_tooltip_not_shown();
|
|
|
|
|
|
|
|
void input_reset_place_obj_modifier();
|
2014-12-16 02:24:13 +01:00
|
|
|
|
2020-11-02 14:43:35 +01:00
|
|
|
void InputScrollViewport(const ScreenCoordsXY& screenCoords);
|
2017-11-08 17:43:50 +01:00
|
|
|
|
2015-12-21 05:03:37 +01:00
|
|
|
#endif
|