1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Move keyboard shortcut code to libopenrct2ui.

This commit is contained in:
Ted John
2017-06-11 12:30:00 +01:00
parent c8e4e6dae1
commit dfa1b47a4f
14 changed files with 779 additions and 340 deletions

View File

@@ -32,6 +32,7 @@
#include <openrct2/Version.h>
#include "CursorRepository.h"
#include "drawing/engines/DrawingEngines.h"
#include "input/KeyboardShortcuts.h"
#include "SDLException.h"
#include "TextComposition.h"
#include "UiContext.h"
@@ -45,6 +46,7 @@ extern "C"
using namespace OpenRCT2;
using namespace OpenRCT2::Drawing;
using namespace OpenRCT2::Input;
using namespace OpenRCT2::Ui;
#ifdef __MACOSX__
@@ -59,7 +61,6 @@ class UiContext final : public IUiContext
private:
constexpr static uint32 TOUCH_DOUBLE_TIMEOUT = 300;
IPlatformEnvironment * const _env;
IPlatformUiContext * const _platformUiContext;
CursorRepository _cursorRepository;
@@ -76,27 +77,27 @@ private:
bool _steamOverlayActive = false;
// Input
TextComposition _textComposition;
CursorState _cursorState = { 0 };
uint32 _lastKeyPressed = 0;
const uint8 * _keysState = nullptr;
uint8 _keysPressed[256] = { 0 };
uint32 _lastGestureTimestamp = 0;
float _gestureRadius = 0;
KeyboardShortcuts _keyboardShortcuts;
TextComposition _textComposition;
CursorState _cursorState = { 0 };
uint32 _lastKeyPressed = 0;
const uint8 * _keysState = nullptr;
uint8 _keysPressed[256] = { 0 };
uint32 _lastGestureTimestamp = 0;
float _gestureRadius = 0;
public:
UiContext(IPlatformEnvironment * env)
: _env(env),
_platformUiContext(CreatePlatformUiContext())
: _platformUiContext(CreatePlatformUiContext()),
_keyboardShortcuts(env)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
SDLException::Throw("SDL_Init(SDL_INIT_VIDEO)");
}
_cursorRepository.LoadCursors();
// Temporary to prevent warning, will be used for keyboard shortcuts
UNUSED(_env);
_keyboardShortcuts.Reset();
_keyboardShortcuts.Load();
}
~UiContext() override