From c8e4e6dae14af14005963511a1c0f12931cd2557 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 15:41:09 +0100 Subject: [PATCH 1/8] Remove usages of MAX_PATH --- src/openrct2/interface/window.h | 2 +- src/openrct2/paint/map_element/entrance.c | 12 ++++++------ src/openrct2/paint/map_element/fence.c | 6 +++--- src/openrct2/paint/map_element/scenery_multiple.c | 10 +++++----- src/openrct2/ride/track_design_save.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 88150bec61..adfc81acae 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -25,7 +25,6 @@ #include "../ride/track_design.h" #include "../ride/vehicle.h" #include "../scenario/scenario.h" -#include "../scenario/ScenarioRepository.h" #include "../world/park.h" #include "colour.h" @@ -34,6 +33,7 @@ union rct_window_event; struct track_design_file_ref; struct TitleSequence; struct TextInputSession; +typedef struct scenario_index_entry scenario_index_entry; #define TEXT_INPUT_SIZE 1024 #define TOP_TOOLBAR_HEIGHT 27 diff --git a/src/openrct2/paint/map_element/entrance.c b/src/openrct2/paint/map_element/entrance.c index 3f7ba3aeac..ea9edbd551 100644 --- a/src/openrct2/paint/map_element/entrance.c +++ b/src/openrct2/paint/map_element/entrance.c @@ -154,11 +154,11 @@ static void ride_entrance_exit_paint(uint8 direction, sint32 height, rct_map_ele string_id = STR_RIDE_ENTRANCE_NAME; } - utf8 entrance_string[MAX_PATH]; + utf8 entrance_string[256]; if (gConfigGeneral.upper_case_banners) { - format_string_to_upper(entrance_string, MAX_PATH, string_id, gCommonFormatArgs); + format_string_to_upper(entrance_string, sizeof(entrance_string), string_id, gCommonFormatArgs); } else { - format_string(entrance_string, MAX_PATH, string_id, gCommonFormatArgs); + format_string(entrance_string, sizeof(entrance_string), string_id, gCommonFormatArgs); } gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; @@ -237,11 +237,11 @@ static void park_entrance_paint(uint8 direction, sint32 height, rct_map_element* park_text_id = STR_BANNER_TEXT_FORMAT; } - utf8 park_name[MAX_PATH]; + utf8 park_name[256]; if (gConfigGeneral.upper_case_banners) { - format_string_to_upper(park_name, MAX_PATH, park_text_id, gCommonFormatArgs); + format_string_to_upper(park_name, sizeof(park_name), park_text_id, gCommonFormatArgs); } else { - format_string(park_name, MAX_PATH, park_text_id, gCommonFormatArgs); + format_string(park_name, sizeof(park_name), park_text_id, gCommonFormatArgs); } gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 0efa160dea..76b06b8fdc 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -369,12 +369,12 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) set_format_arg(2, uint32, ride->name_arguments); } - utf8 signString[MAX_PATH]; + utf8 signString[256]; rct_string_id stringId = STR_SCROLLING_SIGN_TEXT; if (gConfigGeneral.upper_case_banners) { - format_string_to_upper(signString, MAX_PATH, stringId, gCommonFormatArgs); + format_string_to_upper(signString, sizeof(signString), stringId, gCommonFormatArgs); } else { - format_string(signString, MAX_PATH, stringId, gCommonFormatArgs); + format_string(signString, sizeof(signString), stringId, gCommonFormatArgs); } gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; diff --git a/src/openrct2/paint/map_element/scenery_multiple.c b/src/openrct2/paint/map_element/scenery_multiple.c index 6752283d71..ed4c41ca83 100644 --- a/src/openrct2/paint/map_element/scenery_multiple.c +++ b/src/openrct2/paint/map_element/scenery_multiple.c @@ -262,8 +262,8 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map stringId = ride->name; set_format_arg(0, uint32, ride->name_arguments); } - utf8 signString[MAX_PATH]; - format_string(signString, MAX_PATH, stringId, gCommonFormatArgs); + utf8 signString[256]; + format_string(signString, sizeof(signString), stringId, gCommonFormatArgs); rct_large_scenery_text *text = entry->large_scenery.text; sint32 y_offset = (text->offset[(direction & 1)].y * 2); if (text->flags & LARGE_SCENERY_TEXT_FLAG_VERTICAL) { @@ -352,12 +352,12 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map set_format_arg(0, rct_string_id, ride->name); set_format_arg(2, uint32, ride->name_arguments); } - utf8 signString[MAX_PATH]; + utf8 signString[256]; rct_string_id stringId = STR_SCROLLING_SIGN_TEXT; if (gConfigGeneral.upper_case_banners) { - format_string_to_upper(signString, MAX_PATH, stringId, gCommonFormatArgs); + format_string_to_upper(signString, sizeof(signString), stringId, gCommonFormatArgs); } else { - format_string(signString, MAX_PATH, stringId, gCommonFormatArgs); + format_string(signString, sizeof(signString), stringId, gCommonFormatArgs); } gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY; diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index 6c9ff939c2..783ca88afe 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -177,8 +177,8 @@ bool track_design_save(uint8 rideIndex) } } - utf8 track_name[MAX_PATH]; - format_string(track_name, MAX_PATH, ride->name, &ride->name_arguments); + utf8 track_name[256]; + format_string(track_name, sizeof(track_name), ride->name, &ride->name_arguments); window_loadsave_open(LOADSAVETYPE_TRACK | LOADSAVETYPE_SAVE, track_name); window_loadsave_set_loadsave_callback(track_design_save_callback); From dfa1b47a4f0bde57d93b6c2c3e45b112294abcdc Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 12:30:00 +0100 Subject: [PATCH 2/8] Move keyboard shortcut code to libopenrct2ui. --- src/openrct2-ui/UiContext.cpp | 27 +- src/openrct2-ui/input/KeyboardShortcuts.cpp | 262 ++++++++++++++ src/openrct2-ui/input/KeyboardShortcuts.h | 78 ++++ .../input}/keyboard_shortcut.c | 101 +----- .../input}/keyboard_shortcut.h | 16 +- src/openrct2-ui/libopenrct2ui.vcxproj | 6 + .../windows/shortcut_key_change.c | 10 +- .../windows/shortcut_keys.c | 18 +- src/openrct2/config/KeyboardShortcuts.cpp | 173 --------- src/openrct2/input.c | 85 +++-- src/openrct2/libopenrct2.vcxproj | 335 +++++++++++++++++- src/openrct2/network/network.cpp | 3 +- src/openrct2/platform/shared.c | 1 - src/openrct2/rct2.c | 4 - 14 files changed, 779 insertions(+), 340 deletions(-) create mode 100644 src/openrct2-ui/input/KeyboardShortcuts.cpp create mode 100644 src/openrct2-ui/input/KeyboardShortcuts.h rename src/{openrct2/interface => openrct2-ui/input}/keyboard_shortcut.c (89%) rename src/{openrct2/interface => openrct2-ui/input}/keyboard_shortcut.h (94%) rename src/{openrct2 => openrct2-ui}/windows/shortcut_key_change.c (93%) rename src/{openrct2 => openrct2-ui}/windows/shortcut_keys.c (96%) delete mode 100644 src/openrct2/config/KeyboardShortcuts.cpp diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index d9e275b3b1..7fa89d74d3 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -32,6 +32,7 @@ #include #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 diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp new file mode 100644 index 0000000000..4ae54c6597 --- /dev/null +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -0,0 +1,262 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "KeyboardShortcuts.h" + +extern "C" +{ + #include +} + +using namespace OpenRCT2; +using namespace OpenRCT2::Input; + +// Remove when the C calls are removed +static KeyboardShortcuts * _instance; + +KeyboardShortcuts::KeyboardShortcuts(IPlatformEnvironment * env) + : _env(env) +{ + _instance = this; +} + +void KeyboardShortcuts::Reset() +{ + for (size_t i = 0; i < SHORTCUT_COUNT; i++) + { + _keys[i] = DefaultKeys[i]; + } +} + +bool KeyboardShortcuts::Load() +{ + bool result = false; + try + { + std::string path = _env->GetFilePath(PATHID::CONFIG_KEYBOARD); + if (File::Exists(path)) + { + auto fs = FileStream(path, FILE_MODE_OPEN); + uint16 version = fs.ReadValue(); + if (version == KeyboardShortcuts::CURRENT_FILE_VERSION) + { + for (sint32 i = 0; i < SHORTCUT_COUNT; i++) + { + _keys[i] = fs.ReadValue(); + } + result = true; + } + } + } + catch (const Exception &ex) + { + Console::WriteLine("Error reading shortcut keys: %s", ex.GetMessage()); + } + return result; +} + +bool KeyboardShortcuts::Save() +{ + bool result = false; + try + { + std::string path = _env->GetFilePath(PATHID::CONFIG_KEYBOARD); + auto fs = FileStream(path, FILE_MODE_WRITE); + fs.WriteValue(KeyboardShortcuts::CURRENT_FILE_VERSION); + for (sint32 i = 0; i < SHORTCUT_COUNT; i++) + { + fs.WriteValue(_keys[i]); + } + result = true; + } + catch (const Exception &ex) + { + Console::WriteLine("Error writing shortcut keys: %s", ex.GetMessage()); + } + return result; +} + +void KeyboardShortcuts::Set(sint32 key) +{ + // Unmap shortcut that already uses this key + sint32 shortcut = GetFromKey(key); + if (shortcut != SHORTCUT_UNDEFINED) + { + _keys[shortcut] = SHORTCUT_UNDEFINED; + } + + // Map shortcut to this key + _keys[gKeyboardShortcutChangeId] = key; + // window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); + // window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); + Save(); +} + +sint32 KeyboardShortcuts::GetFromKey(sint32 key) +{ + for (sint32 i = 0; i < SHORTCUT_COUNT; i++) + { + if (key == _keys[i]) + { + return i; + } + } + return SHORTCUT_UNDEFINED; +} + +std::string KeyboardShortcuts::GetShortcutString(sint32 shortcut) const +{ + utf8 buffer[256] = { 0 }; + utf8 formatBuffer[256] = { 0 }; + uint16 shortcutKey = _keys[shortcut]; + if (shortcutKey == SHORTCUT_UNDEFINED) return std::string(); + if (shortcutKey & SHIFT) + { + format_string(formatBuffer, sizeof(formatBuffer), STR_SHIFT_PLUS, NULL); + String::Append(buffer, sizeof(buffer), formatBuffer); + } + if (shortcutKey & CTRL) + { + format_string(formatBuffer, sizeof(formatBuffer), STR_CTRL_PLUS, NULL); + String::Append(buffer, sizeof(buffer), formatBuffer); + } + if (shortcutKey & ALT) + { +#ifdef __MACOSX__ + format_string(formatBuffer, sizeof(formatBuffer), STR_OPTION_PLUS, NULL); +#else + format_string(formatBuffer, sizeof(formatBuffer), STR_ALT_PLUS, NULL); +#endif + String::Append(buffer, sizeof(buffer), formatBuffer); + } + if (shortcutKey & CMD) + { + format_string(formatBuffer, sizeof(formatBuffer), STR_CMD_PLUS, NULL); + String::Append(buffer, sizeof(buffer), formatBuffer); + } + String::Append(buffer, sizeof(buffer), SDL_GetScancodeName((SDL_Scancode)(shortcutKey & 0xFF))); + return std::string(buffer); +} + +extern "C" +{ + void keyboard_shortcuts_reset() + { + _instance->Reset(); + } + + bool keyboard_shortcuts_load() + { + return _instance->Load(); + } + + bool keyboard_shortcuts_save() + { + return _instance->Save(); + } + + void keyboard_shortcuts_set(sint32 key) + { + return _instance->Set(key); + } + + sint32 keyboard_shortcuts_get_from_key(sint32 key) + { + return _instance->GetFromKey(key); + } + + void keyboard_shortcuts_format_string(char * buffer, size_t bufferSize, sint32 shortcut) + { + auto str = _instance->GetShortcutString(shortcut); + String::Set(buffer, bufferSize, str.c_str()); + } +} + +// Default keyboard shortcuts +const uint16 KeyboardShortcuts::DefaultKeys[SHORTCUT_COUNT] = +{ + SDL_SCANCODE_BACKSPACE, // SHORTCUT_CLOSE_TOP_MOST_WINDOW + SHIFT | SDL_SCANCODE_BACKSPACE, // SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS + SDL_SCANCODE_ESCAPE, // SHORTCUT_CANCEL_CONSTRUCTION_MODE + SDL_SCANCODE_PAUSE, // SHORTCUT_PAUSE_GAME + SDL_SCANCODE_PAGEUP, // SHORTCUT_ZOOM_VIEW_OUT + SDL_SCANCODE_PAGEDOWN, // SHORTCUT_ZOOM_VIEW_IN + SDL_SCANCODE_RETURN, // SHORTCUT_ROTATE_VIEW_CLOCKWISE + SHIFT | SDL_SCANCODE_RETURN, // SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE + SDL_SCANCODE_Z, // SHORTCUT_ROTATE_CONSTRUCTION_OBJECT + SDL_SCANCODE_1, // SHORTCUT_UNDERGROUND_VIEW_TOGGLE + SDL_SCANCODE_H, // SHORTCUT_REMOVE_BASE_LAND_TOGGLE + SDL_SCANCODE_V, // SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE + SDL_SCANCODE_3, // SHORTCUT_SEE_THROUGH_RIDES_TOGGLE + SDL_SCANCODE_4, // SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE + SDL_SCANCODE_5, // SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE + SDL_SCANCODE_6, // SHORTCUT_INVISIBLE_PEOPLE_TOGGLE + SDL_SCANCODE_8, // SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE + SDL_SCANCODE_9, // SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE + SDL_SCANCODE_0, // SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE + SDL_SCANCODE_F1, // SHORTCUT_ADJUST_LAND + SDL_SCANCODE_F2, // SHORTCUT_ADJUST_WATER + SDL_SCANCODE_F3, // SHORTCUT_BUILD_SCENERY + SDL_SCANCODE_F4, // SHORTCUT_BUILD_PATHS + SDL_SCANCODE_F5, // SHORTCUT_BUILD_NEW_RIDE + SDL_SCANCODE_F, // SHORTCUT_SHOW_FINANCIAL_INFORMATION + SDL_SCANCODE_D, // SHORTCUT_SHOW_RESEARCH_INFORMATION + SDL_SCANCODE_R, // SHORTCUT_SHOW_RIDES_LIST + SDL_SCANCODE_P, // SHORTCUT_SHOW_PARK_INFORMATION + SDL_SCANCODE_G, // SHORTCUT_SHOW_GUEST_LIST + SDL_SCANCODE_S, // SHORTCUT_SHOW_STAFF_LIST + SDL_SCANCODE_M, // SHORTCUT_SHOW_RECENT_MESSAGES + SDL_SCANCODE_TAB, // SHORTCUT_SHOW_MAP + PLATFORM_MODIFIER | SDL_SCANCODE_S, // SHORTCUT_SCREENSHOT + SDL_SCANCODE_MINUS, // SHORTCUT_REDUCE_GAME_SPEED, + SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED, + PLATFORM_MODIFIER | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW, + SDL_SCANCODE_T, // SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE, + SDL_SCANCODE_UP, // SHORTCUT_SCROLL_MAP_UP + SDL_SCANCODE_LEFT, // SHORTCUT_SCROLL_MAP_LEFT + SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN + SDL_SCANCODE_RIGHT, // SHORTCUT_SCROLL_MAP_RIGHT + SDL_SCANCODE_C, // SHORTCUT_OPEN_CHAT_WINDOW + PLATFORM_MODIFIER | SDL_SCANCODE_F10, // SHORTCUT_QUICK_SAVE_GAME + SHORTCUT_UNDEFINED, // SHORTCUT_SHOW_OPTIONS + SHORTCUT_UNDEFINED, // SHORTCUT_MUTE_SOUND + ALT | SDL_SCANCODE_RETURN, // SHORTCUT_WINDOWED_MODE_TOGGLE + SHORTCUT_UNDEFINED, // SHORTCUT_SHOW_MULTIPLAYER + SHORTCUT_UNDEFINED, // SHORTCUT_PAINT_ORIGINAL_TOGGLE + SHORTCUT_UNDEFINED, // SHORTCUT_DEBUG_PAINT_TOGGLE + SHORTCUT_UNDEFINED, // SHORTCUT_SEE_THROUGH_PATHS_TOGGLE + SDL_SCANCODE_KP_4, // SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT + SDL_SCANCODE_KP_6, // SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT + SDL_SCANCODE_KP_5, // SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT + SDL_SCANCODE_KP_2, // SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN + SDL_SCANCODE_KP_8, // SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP + SDL_SCANCODE_KP_PLUS, // SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE + SDL_SCANCODE_KP_1, // SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT + SDL_SCANCODE_KP_3, // SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT + SDL_SCANCODE_KP_7, // SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK + SDL_SCANCODE_KP_9, // SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK + SDL_SCANCODE_KP_0, // SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT + SDL_SCANCODE_KP_MINUS, // SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT +}; diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h new file mode 100644 index 0000000000..f8bab0aa27 --- /dev/null +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -0,0 +1,78 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + #include "../input/keyboard_shortcut.h" +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus + +#include + +namespace OpenRCT2 +{ + interface IPlatformEnvironment; + + namespace Input + { + class KeyboardShortcuts + { + private: + constexpr static sint32 CURRENT_FILE_VERSION = 1; + static const uint16 DefaultKeys[SHORTCUT_COUNT]; + + IPlatformEnvironment * const _env; + uint16 _keys[SHORTCUT_COUNT]; + + public: + KeyboardShortcuts(IPlatformEnvironment * env); + + void Reset(); + bool Load(); + bool Save(); + + std::string GetShortcutString(sint32 shortcut) const; + + void Set(sint32 key); + sint32 GetFromKey(sint32 key); + }; + } +} + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + void keyboard_shortcuts_reset(); + bool keyboard_shortcuts_load(); + bool keyboard_shortcuts_save(); + void keyboard_shortcuts_set(sint32 key); + sint32 keyboard_shortcuts_get_from_key(sint32 key); + void keyboard_shortcuts_format_string(char * buffer, size_t bufferSize, sint32 shortcut); +#ifdef __cplusplus +} +#endif diff --git a/src/openrct2/interface/keyboard_shortcut.c b/src/openrct2-ui/input/keyboard_shortcut.c similarity index 89% rename from src/openrct2/interface/keyboard_shortcut.c rename to src/openrct2-ui/input/keyboard_shortcut.c index 486bc5d3f0..6f7adae9d6 100644 --- a/src/openrct2/interface/keyboard_shortcut.c +++ b/src/openrct2-ui/input/keyboard_shortcut.c @@ -14,24 +14,24 @@ *****************************************************************************/ #pragma endregion -#include "../audio/audio.h" -#include "../config/Config.h" -#include "../editor.h" -#include "../game.h" -#include "../input.h" -#include "../interface/chat.h" -#include "../interface/Screenshot.h" -#include "../localisation/localisation.h" -#include "../network/network.h" -#include "../platform/platform.h" -#include "../ride/track.h" -#include "../ride/track_paint.h" -#include "../title/TitleScreen.h" -#include "../util/util.h" -#include "keyboard_shortcut.h" -#include "viewport.h" -#include "widget.h" -#include "window.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "KeyboardShortcuts.h" uint8 gKeyboardShortcutChangeId; @@ -39,46 +39,13 @@ typedef void (*shortcut_action)(); static const shortcut_action shortcut_table[SHORTCUT_COUNT]; -/** - * - * rct2: 0x006E3E91 - */ -void keyboard_shortcut_set(sint32 key) -{ - sint32 i; - - // Unmap shortcut that already uses this key - for (i = 0; i < SHORTCUT_COUNT; i++) { - if (key == gShortcutKeys[i]) { - gShortcutKeys[i] = SHORTCUT_UNDEFINED; - break; - } - } - - // Map shortcut to this key - gShortcutKeys[gKeyboardShortcutChangeId] = key; - window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); - window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); - config_shortcut_keys_save(); -} - -static sint32 keyboard_shortcut_get_from_key(sint32 key) -{ - for (sint32 i = 0; i < SHORTCUT_COUNT; i++) { - if (key == gShortcutKeys[i]) { - return i; - } - } - return -1; -} - /** * * rct2: 0x006E3E68 */ void keyboard_shortcut_handle(sint32 key) { - sint32 shortcut = keyboard_shortcut_get_from_key(key); + sint32 shortcut = keyboard_shortcuts_get_from_key(key); if (shortcut != -1) { keyboard_shortcut_handle_command(shortcut); } @@ -94,36 +61,6 @@ void keyboard_shortcut_handle_command(sint32 shortcutIndex) } } -void keyboard_shortcut_format_string(char *buffer, size_t size, uint16 shortcutKey) -{ - char formatBuffer[256]; - - if (size == 0) return; - *buffer = 0; - if (shortcutKey == SHORTCUT_UNDEFINED) return; - if (shortcutKey & 0x100) { - format_string(formatBuffer, 256, STR_SHIFT_PLUS, NULL); - safe_strcat(buffer, formatBuffer, size); - } - if (shortcutKey & 0x200) { - format_string(formatBuffer, 256, STR_CTRL_PLUS, NULL); - safe_strcat(buffer, formatBuffer, size); - } - if (shortcutKey & 0x400) { -#ifdef __MACOSX__ - format_string(formatBuffer, 256, STR_OPTION_PLUS, NULL); -#else - format_string(formatBuffer, 256, STR_ALT_PLUS, NULL); -#endif - safe_strcat(buffer, formatBuffer, size); - } - if (shortcutKey & 0x800) { - format_string(formatBuffer, 256, STR_CMD_PLUS, NULL); - safe_strcat(buffer, formatBuffer, size); - } - safe_strcat(buffer, SDL_GetScancodeName(shortcutKey & 0xFF), size); -} - #pragma region Shortcut Commands static void toggle_view_flag(sint32 viewportFlag) diff --git a/src/openrct2/interface/keyboard_shortcut.h b/src/openrct2-ui/input/keyboard_shortcut.h similarity index 94% rename from src/openrct2/interface/keyboard_shortcut.h rename to src/openrct2-ui/input/keyboard_shortcut.h index 8b1dab7533..a897e2562c 100644 --- a/src/openrct2/interface/keyboard_shortcut.h +++ b/src/openrct2-ui/input/keyboard_shortcut.h @@ -17,7 +17,7 @@ #ifndef _INTERFACE_KEYBOARD_SHORTCUT_H_ #define _INTERFACE_KEYBOARD_SHORTCUT_H_ -#include "../common.h" +#include #define SHORTCUT_UNDEFINED 0xFFFF @@ -29,10 +29,6 @@ void keyboard_shortcut_handle(sint32 key); void keyboard_shortcut_handle_command(sint32 shortcutIndex); void keyboard_shortcut_format_string(char *buffer, size_t size, uint16 shortcutKey); -void config_reset_shortcut_keys(); -bool config_shortcut_keys_load(); -bool config_shortcut_keys_save(); - typedef struct shortcut_entry { uint8 key; uint8 modifier; @@ -107,6 +103,14 @@ enum { SHORTCUT_COUNT }; -extern uint16 gShortcutKeys[SHORTCUT_COUNT]; +#define SHIFT 0x100 +#define CTRL 0x200 +#define ALT 0x400 +#define CMD 0x800 +#ifdef __MACOSX__ +#define PLATFORM_MODIFIER CMD +#else +#define PLATFORM_MODIFIER CTRL +#endif #endif diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 8f22ec0203..54b0ced030 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -41,11 +41,15 @@ + + + + @@ -63,6 +67,8 @@ + + diff --git a/src/openrct2/windows/shortcut_key_change.c b/src/openrct2-ui/windows/shortcut_key_change.c similarity index 93% rename from src/openrct2/windows/shortcut_key_change.c rename to src/openrct2-ui/windows/shortcut_key_change.c index 817b421186..c5686caf5c 100644 --- a/src/openrct2/windows/shortcut_key_change.c +++ b/src/openrct2-ui/windows/shortcut_key_change.c @@ -14,11 +14,11 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "../interface/keyboard_shortcut.h" -#include "../interface/window.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" +#include +#include +#include +#include +#include "../input/keyboard_shortcut.h" extern const rct_string_id ShortcutStringIds[]; diff --git a/src/openrct2/windows/shortcut_keys.c b/src/openrct2-ui/windows/shortcut_keys.c similarity index 96% rename from src/openrct2/windows/shortcut_keys.c rename to src/openrct2-ui/windows/shortcut_keys.c index 7652e69837..023596334d 100644 --- a/src/openrct2/windows/shortcut_keys.c +++ b/src/openrct2-ui/windows/shortcut_keys.c @@ -14,12 +14,12 @@ *****************************************************************************/ #pragma endregion -#include "../config/Config.h" -#include "../interface/window.h" -#include "../interface/widget.h" -#include "../localisation/localisation.h" -#include "../platform/platform.h" -#include "../interface/keyboard_shortcut.h" +#include +#include +#include +#include +#include +#include "../input/KeyboardShortcuts.h" #define WW 420 #define WH 280 @@ -188,8 +188,8 @@ static void window_shortcut_mouseup(rct_window *w, rct_widgetindex widgetIndex) window_close(w); break; case WIDX_RESET: - config_reset_shortcut_keys(); - config_shortcut_keys_save(); + keyboard_shortcuts_reset(); + keyboard_shortcuts_save(); window_invalidate(w); break; } @@ -289,7 +289,7 @@ static void window_shortcut_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, s } char templateString[128]; - keyboard_shortcut_format_string(templateString, 128, gShortcutKeys[i]); + keyboard_shortcuts_format_string(templateString, 128, i); set_format_arg(0, rct_string_id, STR_SHORTCUT_ENTRY_FORMAT); set_format_arg(2, rct_string_id, ShortcutStringIds[i]); diff --git a/src/openrct2/config/KeyboardShortcuts.cpp b/src/openrct2/config/KeyboardShortcuts.cpp deleted file mode 100644 index 7ef482ef40..0000000000 --- a/src/openrct2/config/KeyboardShortcuts.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers -/***************************************************************************** - * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. - * - * OpenRCT2 is the work of many authors, a full list can be found in contributors.md - * For more information, visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * A full copy of the GNU General Public License can be found in licence.txt - *****************************************************************************/ -#pragma endregion - -#include "../common.h" -#include "../core/Console.hpp" -#include "../core/File.h" -#include "../core/FileStream.hpp" -#include "../core/Memory.hpp" -#include "../core/Path.hpp" -#include "../core/String.hpp" - -extern "C" -{ - #include "../interface/keyboard_shortcut.h" - #include "../platform/platform.h" -} - -// Current keyboard shortcuts -uint16 gShortcutKeys[SHORTCUT_COUNT]; - -namespace KeyboardShortcuts -{ - // Default keyboard shortcuts - static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = - { - SDL_SCANCODE_BACKSPACE, // SHORTCUT_CLOSE_TOP_MOST_WINDOW - SHIFT | SDL_SCANCODE_BACKSPACE, // SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS - SDL_SCANCODE_ESCAPE, // SHORTCUT_CANCEL_CONSTRUCTION_MODE - SDL_SCANCODE_PAUSE, // SHORTCUT_PAUSE_GAME - SDL_SCANCODE_PAGEUP, // SHORTCUT_ZOOM_VIEW_OUT - SDL_SCANCODE_PAGEDOWN, // SHORTCUT_ZOOM_VIEW_IN - SDL_SCANCODE_RETURN, // SHORTCUT_ROTATE_VIEW_CLOCKWISE - SHIFT | SDL_SCANCODE_RETURN, // SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE - SDL_SCANCODE_Z, // SHORTCUT_ROTATE_CONSTRUCTION_OBJECT - SDL_SCANCODE_1, // SHORTCUT_UNDERGROUND_VIEW_TOGGLE - SDL_SCANCODE_H, // SHORTCUT_REMOVE_BASE_LAND_TOGGLE - SDL_SCANCODE_V, // SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE - SDL_SCANCODE_3, // SHORTCUT_SEE_THROUGH_RIDES_TOGGLE - SDL_SCANCODE_4, // SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE - SDL_SCANCODE_5, // SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE - SDL_SCANCODE_6, // SHORTCUT_INVISIBLE_PEOPLE_TOGGLE - SDL_SCANCODE_8, // SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE - SDL_SCANCODE_9, // SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE - SDL_SCANCODE_0, // SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE - SDL_SCANCODE_F1, // SHORTCUT_ADJUST_LAND - SDL_SCANCODE_F2, // SHORTCUT_ADJUST_WATER - SDL_SCANCODE_F3, // SHORTCUT_BUILD_SCENERY - SDL_SCANCODE_F4, // SHORTCUT_BUILD_PATHS - SDL_SCANCODE_F5, // SHORTCUT_BUILD_NEW_RIDE - SDL_SCANCODE_F, // SHORTCUT_SHOW_FINANCIAL_INFORMATION - SDL_SCANCODE_D, // SHORTCUT_SHOW_RESEARCH_INFORMATION - SDL_SCANCODE_R, // SHORTCUT_SHOW_RIDES_LIST - SDL_SCANCODE_P, // SHORTCUT_SHOW_PARK_INFORMATION - SDL_SCANCODE_G, // SHORTCUT_SHOW_GUEST_LIST - SDL_SCANCODE_S, // SHORTCUT_SHOW_STAFF_LIST - SDL_SCANCODE_M, // SHORTCUT_SHOW_RECENT_MESSAGES - SDL_SCANCODE_TAB, // SHORTCUT_SHOW_MAP - PLATFORM_MODIFIER | SDL_SCANCODE_S, // SHORTCUT_SCREENSHOT - SDL_SCANCODE_MINUS, // SHORTCUT_REDUCE_GAME_SPEED, - SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED, - PLATFORM_MODIFIER | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW, - SDL_SCANCODE_T, // SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE, - SDL_SCANCODE_UP, // SHORTCUT_SCROLL_MAP_UP - SDL_SCANCODE_LEFT, // SHORTCUT_SCROLL_MAP_LEFT - SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN - SDL_SCANCODE_RIGHT, // SHORTCUT_SCROLL_MAP_RIGHT - SDL_SCANCODE_C, // SHORTCUT_OPEN_CHAT_WINDOW - PLATFORM_MODIFIER | SDL_SCANCODE_F10, // SHORTCUT_QUICK_SAVE_GAME - SHORTCUT_UNDEFINED, // SHORTCUT_SHOW_OPTIONS - SHORTCUT_UNDEFINED, // SHORTCUT_MUTE_SOUND - ALT | SDL_SCANCODE_RETURN, // SHORTCUT_WINDOWED_MODE_TOGGLE - SHORTCUT_UNDEFINED, // SHORTCUT_SHOW_MULTIPLAYER - SHORTCUT_UNDEFINED, // SHORTCUT_PAINT_ORIGINAL_TOGGLE - SHORTCUT_UNDEFINED, // SHORTCUT_DEBUG_PAINT_TOGGLE - SHORTCUT_UNDEFINED, // SHORTCUT_SEE_THROUGH_PATHS_TOGGLE - SDL_SCANCODE_KP_4, // SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT - SDL_SCANCODE_KP_6, // SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT - SDL_SCANCODE_KP_5, // SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT - SDL_SCANCODE_KP_2, // SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN - SDL_SCANCODE_KP_8, // SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP - SDL_SCANCODE_KP_PLUS, // SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE - SDL_SCANCODE_KP_1, // SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT - SDL_SCANCODE_KP_3, // SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT - SDL_SCANCODE_KP_7, // SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK - SDL_SCANCODE_KP_9, // SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK - SDL_SCANCODE_KP_0, // SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT - SDL_SCANCODE_KP_MINUS, // SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT - }; - - constexpr sint32 CURRENT_FILE_VERSION = 1; - - static void Reset() - { - Memory::Copy(gShortcutKeys, _defaultShortcutKeys, sizeof(gShortcutKeys)); - } - - static std::string GetPath() - { - utf8 path[MAX_PATH]; - platform_get_user_directory(path, nullptr, sizeof(path)); - Path::Append(path, sizeof(path), "hotkeys.cfg"); - return path; - } -} - -extern "C" -{ - void config_reset_shortcut_keys() - { - KeyboardShortcuts::Reset(); - } - - bool config_shortcut_keys_load() - { - bool result = false; - try - { - std::string path = KeyboardShortcuts::GetPath(); - if (File::Exists(path)) - { - auto fs = FileStream(path, FILE_MODE_OPEN); - uint16 version = fs.ReadValue(); - if (version == KeyboardShortcuts::CURRENT_FILE_VERSION) - { - for (sint32 i = 0; i < SHORTCUT_COUNT; i++) - { - gShortcutKeys[i] = fs.ReadValue(); - } - result = true; - } - } - } - catch (const Exception &ex) - { - Console::WriteLine("Error reading shortcut keys: %s", ex.GetMessage()); - } - return result; - } - - bool config_shortcut_keys_save() - { - bool result = false; - try - { - std::string path = KeyboardShortcuts::GetPath(); - auto fs = FileStream(path, FILE_MODE_WRITE); - fs.WriteValue(KeyboardShortcuts::CURRENT_FILE_VERSION); - for (sint32 i = 0; i < SHORTCUT_COUNT; i++) - { - fs.WriteValue(gShortcutKeys[i]); - } - result = true; - } - catch (const Exception &ex) - { - Console::WriteLine("Error writing shortcut keys: %s", ex.GetMessage()); - } - return result; - } -} diff --git a/src/openrct2/input.c b/src/openrct2/input.c index f9a627d6e2..490bca269e 100644 --- a/src/openrct2/input.c +++ b/src/openrct2/input.c @@ -23,7 +23,6 @@ #include "interface/chat.h" #include "interface/console.h" #include "interface/Cursors.h" -#include "interface/keyboard_shortcut.h" #include "interface/viewport.h" #include "interface/widget.h" #include "interface/window.h" @@ -1485,14 +1484,14 @@ void title_handle_keyboard_input() w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != NULL) { - keyboard_shortcut_set(key); + // keyboard_shortcut_set(key); } else { w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { window_text_input_key(w, key); } else if (!gUsingWidgetTextBox) { - keyboard_shortcut_handle(key); + // keyboard_shortcut_handle(key); } } } @@ -1564,13 +1563,13 @@ void game_handle_keyboard_input() w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != NULL) { - keyboard_shortcut_set(key); + // keyboard_shortcut_set(key); } else { w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { window_text_input_key(w, key); } else if (!gUsingWidgetTextBox) { - keyboard_shortcut_handle(key); + // keyboard_shortcut_handle(key); } } } @@ -1706,44 +1705,44 @@ void game_handle_key_scroll() scrollX = 0; scrollY = 0; - const uint8 * keysState = context_get_keys_state(); - for (sint32 shortcutId = SHORTCUT_SCROLL_MAP_UP; shortcutId <= SHORTCUT_SCROLL_MAP_RIGHT; shortcutId++) { - uint16 shortcutKey = gShortcutKeys[shortcutId]; - uint8 scancode = shortcutKey & 0xFF; - - if (shortcutKey == 0xFFFF) continue; - if (!keysState[scancode]) continue; - - if (shortcutKey & SHIFT) { - if (!keysState[SDL_SCANCODE_LSHIFT] && !keysState[SDL_SCANCODE_RSHIFT]) continue; - } - if (shortcutKey & CTRL) { - if (!keysState[SDL_SCANCODE_LCTRL] && !keysState[SDL_SCANCODE_RCTRL]) continue; - } - if (shortcutKey & ALT) { - if (!keysState[SDL_SCANCODE_LALT] && !keysState[SDL_SCANCODE_RALT]) continue; - } -#ifdef __MACOSX__ - if (shortcutKey & CMD) { - if (!keysState[SDL_SCANCODE_LGUI] && !keysState[SDL_SCANCODE_RGUI]) continue; - } -#endif - - switch (shortcutId) { - case SHORTCUT_SCROLL_MAP_UP: - scrollY = -1; - break; - case SHORTCUT_SCROLL_MAP_LEFT: - scrollX = -1; - break; - case SHORTCUT_SCROLL_MAP_DOWN: - scrollY = 1; - break; - case SHORTCUT_SCROLL_MAP_RIGHT: - scrollX = 1; - break; - } - } +// const uint8 * keysState = context_get_keys_state(); +// for (sint32 shortcutId = SHORTCUT_SCROLL_MAP_UP; shortcutId <= SHORTCUT_SCROLL_MAP_RIGHT; shortcutId++) { +// uint16 shortcutKey = gShortcutKeys[shortcutId]; +// uint8 scancode = shortcutKey & 0xFF; +// +// if (shortcutKey == 0xFFFF) continue; +// if (!keysState[scancode]) continue; +// +// if (shortcutKey & SHIFT) { +// if (!keysState[SDL_SCANCODE_LSHIFT] && !keysState[SDL_SCANCODE_RSHIFT]) continue; +// } +// if (shortcutKey & CTRL) { +// if (!keysState[SDL_SCANCODE_LCTRL] && !keysState[SDL_SCANCODE_RCTRL]) continue; +// } +// if (shortcutKey & ALT) { +// if (!keysState[SDL_SCANCODE_LALT] && !keysState[SDL_SCANCODE_RALT]) continue; +// } +// #ifdef __MACOSX__ +// if (shortcutKey & CMD) { +// if (!keysState[SDL_SCANCODE_LGUI] && !keysState[SDL_SCANCODE_RGUI]) continue; +// } +// #endif +// +// switch (shortcutId) { +// case SHORTCUT_SCROLL_MAP_UP: +// scrollY = -1; +// break; +// case SHORTCUT_SCROLL_MAP_LEFT: +// scrollX = -1; +// break; +// case SHORTCUT_SCROLL_MAP_DOWN: +// scrollY = 1; +// break; +// case SHORTCUT_SCROLL_MAP_RIGHT: +// scrollX = 1; +// break; +// } +// } // Scroll viewport if (scrollX != 0) { diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 4326c7dced..408bdb7eb7 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -59,8 +59,339 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/openrct2/network/network.cpp b/src/openrct2/network/network.cpp index 6f65c3c895..a7bcb1eb18 100644 --- a/src/openrct2/network/network.cpp +++ b/src/openrct2/network/network.cpp @@ -57,7 +57,6 @@ extern "C" { #include "../game.h" #include "../interface/chat.h" #include "../interface/window.h" -#include "../interface/keyboard_shortcut.h" #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../management/finance.h" @@ -2364,7 +2363,7 @@ void network_chat_show_connected_message() { char templateBuffer[128]; char *templateString = templateBuffer; - keyboard_shortcut_format_string(templateBuffer, 128, gShortcutKeys[SHORTCUT_OPEN_CHAT_WINDOW]); + // keyboard_shortcuts_format_string(templateBuffer, sizeof(templateBuffer), SHORTCUT_OPEN_CHAT_WINDOW); utf8 buffer[256]; NetworkPlayer server; server.Name = "Server"; diff --git a/src/openrct2/platform/shared.c b/src/openrct2/platform/shared.c index 4529818f1a..6cbcd3856d 100644 --- a/src/openrct2/platform/shared.c +++ b/src/openrct2/platform/shared.c @@ -27,7 +27,6 @@ #include "../input.h" #include "../interface/console.h" #include "../interface/Cursors.h" -#include "../interface/keyboard_shortcut.h" #include "../interface/window.h" #include "../localisation/currency.h" #include "../localisation/localisation.h" diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index 2669ac7d7f..6e242fa305 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -28,7 +28,6 @@ #include "input.h" #include "interface/chat.h" #include "interface/console.h" -#include "interface/keyboard_shortcut.h" #include "interface/viewport.h" #include "intro.h" #include "localisation/date.h" @@ -151,10 +150,7 @@ bool rct2_init() gScenarioTicks = 0; util_srand((uint32)time(0)); - config_reset_shortcut_keys(); - config_shortcut_keys_load(); input_reset_place_obj_modifier(); - // config_load(); if (!gfx_load_g1()) { return false; From f62a6713ff4ab6b73cded422ef82d01c5dd0c685 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 17:21:55 +0100 Subject: [PATCH 3/8] Fix libopenrct2.vcxproj --- src/openrct2/libopenrct2.vcxproj | 335 +------------------------------ 1 file changed, 2 insertions(+), 333 deletions(-) diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 408bdb7eb7..4326c7dced 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -59,339 +59,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + From cbd53f920c89ace417d41563993e6286b4ca0a43 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 15:16:47 +0100 Subject: [PATCH 4/8] Create IWindowManager to open window from libopenrct2 --- src/openrct2-ui/UiContext.cpp | 8 ++++ src/openrct2-ui/WindowManager.cpp | 40 +++++++++++++++++ src/openrct2-ui/WindowManager.h | 24 ++++++++++ src/openrct2-ui/input/KeyboardShortcuts.h | 5 +++ src/openrct2-ui/windows/shortcut_key_change.c | 8 ++-- src/openrct2-ui/windows/shortcut_keys.c | 33 +++++++------- src/openrct2/Context.cpp | 7 +++ src/openrct2/Context.h | 12 ++++- src/openrct2/interface/window.h | 2 - src/openrct2/ui/DummyUiContext.cpp | 45 ++++++++++++------- src/openrct2/ui/DummyWindowManager.cpp | 30 +++++++++++++ src/openrct2/ui/UiContext.h | 5 +++ src/openrct2/ui/WindowManager.h | 41 +++++++++++++++++ src/openrct2/windows/options.c | 2 +- 14 files changed, 221 insertions(+), 41 deletions(-) create mode 100644 src/openrct2-ui/WindowManager.cpp create mode 100644 src/openrct2-ui/WindowManager.h create mode 100644 src/openrct2/ui/DummyWindowManager.cpp create mode 100644 src/openrct2/ui/WindowManager.h diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 7fa89d74d3..22a551d5b9 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -36,6 +36,7 @@ #include "SDLException.h" #include "TextComposition.h" #include "UiContext.h" +#include "WindowManager.h" extern "C" { @@ -62,6 +63,7 @@ private: constexpr static uint32 TOUCH_DOUBLE_TIMEOUT = 300; IPlatformUiContext * const _platformUiContext; + IWindowManager * const _windowManager; CursorRepository _cursorRepository; @@ -89,6 +91,7 @@ private: public: UiContext(IPlatformEnvironment * env) : _platformUiContext(CreatePlatformUiContext()), + _windowManager(CreateWindowManager()), _keyboardShortcuts(env) { if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -566,6 +569,11 @@ public: return _platformUiContext->ShowDirectoryDialog(_window, title); } + IWindowManager * GetWindowManager() override + { + return _windowManager; + } + private: void OnResize(sint32 width, sint32 height) { diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp new file mode 100644 index 0000000000..c62d264eb0 --- /dev/null +++ b/src/openrct2-ui/WindowManager.cpp @@ -0,0 +1,40 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#include +#include "input/KeyboardShortcuts.h" +#include "WindowManager.h" + +using namespace OpenRCT2::Ui; + +class WindowManager final : public IWindowManager +{ +public: + rct_window * OpenWindow(rct_windowclass wc) override + { + switch (wc) { + case WC_KEYBOARD_SHORTCUT_LIST: + return window_shortcut_keys_open(); + default: + return nullptr; + } + } +}; + +IWindowManager * OpenRCT2::Ui::CreateWindowManager() +{ + return new WindowManager(); +} diff --git a/src/openrct2-ui/WindowManager.h b/src/openrct2-ui/WindowManager.h new file mode 100644 index 0000000000..9828776397 --- /dev/null +++ b/src/openrct2-ui/WindowManager.h @@ -0,0 +1,24 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#include + +namespace OpenRCT2 { namespace Ui +{ + interface IWindowManager; + + IWindowManager * CreateWindowManager(); +} } diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index f8bab0aa27..f08038d80a 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -67,12 +67,17 @@ namespace OpenRCT2 extern "C" { #endif + typedef struct rct_window rct_window; + void keyboard_shortcuts_reset(); bool keyboard_shortcuts_load(); bool keyboard_shortcuts_save(); void keyboard_shortcuts_set(sint32 key); sint32 keyboard_shortcuts_get_from_key(sint32 key); void keyboard_shortcuts_format_string(char * buffer, size_t bufferSize, sint32 shortcut); + + rct_window * window_shortcut_keys_open(); + rct_window * window_shortcut_change_open(sint32 selected_key); #ifdef __cplusplus } #endif diff --git a/src/openrct2-ui/windows/shortcut_key_change.c b/src/openrct2-ui/windows/shortcut_key_change.c index c5686caf5c..3c7c106225 100644 --- a/src/openrct2-ui/windows/shortcut_key_change.c +++ b/src/openrct2-ui/windows/shortcut_key_change.c @@ -18,7 +18,7 @@ #include #include #include -#include "../input/keyboard_shortcut.h" +#include "../input/KeyboardShortcuts.h" extern const rct_string_id ShortcutStringIds[]; @@ -74,16 +74,18 @@ static rct_window_event_list window_shortcut_change_events = { NULL }; -void window_shortcut_change_open(sint32 selected_key){ +rct_window * window_shortcut_change_open(sint32 selected_key) +{ // Move this to window_shortcut_change_open window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); // Save the item we are selecting for new window gKeyboardShortcutChangeId = selected_key; - rct_window* w = window_create_centred(WW, WH, &window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); + rct_window * w = window_create_centred(WW, WH, &window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); w->widgets = window_shortcut_change_widgets; w->enabled_widgets = (1ULL << WIDX_CLOSE); window_init_scroll_widgets(w); + return w; } /** diff --git a/src/openrct2-ui/windows/shortcut_keys.c b/src/openrct2-ui/windows/shortcut_keys.c index 023596334d..08609264e7 100644 --- a/src/openrct2-ui/windows/shortcut_keys.c +++ b/src/openrct2-ui/windows/shortcut_keys.c @@ -155,26 +155,25 @@ const rct_string_id ShortcutStringIds[] = { * * rct2: 0x006E3884 */ -void window_shortcut_keys_open() +rct_window * window_shortcut_keys_open() { - rct_window* w; + rct_window * w = window_bring_to_front_by_class(WC_KEYBOARD_SHORTCUT_LIST); + if (w == NULL) + { + w = window_create_auto_pos(WW, WH, &window_shortcut_events, WC_KEYBOARD_SHORTCUT_LIST, WF_RESIZABLE); - w = window_bring_to_front_by_class(WC_KEYBOARD_SHORTCUT_LIST); + w->widgets = window_shortcut_widgets; + w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_RESET); + window_init_scroll_widgets(w); - if (w) return; - - w = window_create_auto_pos(WW, WH, &window_shortcut_events, WC_KEYBOARD_SHORTCUT_LIST, WF_RESIZABLE); - - w->widgets = window_shortcut_widgets; - w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_RESET); - window_init_scroll_widgets(w); - - w->no_list_items = SHORTCUT_COUNT; - w->selected_list_item = -1; - w->min_width = WW; - w->min_height = WH; - w->max_width = WW_SC_MAX; - w->max_height = WH_SC_MAX; + w->no_list_items = SHORTCUT_COUNT; + w->selected_list_item = -1; + w->min_width = WW; + w->min_height = WH; + w->max_width = WW_SC_MAX; + w->max_height = WH_SC_MAX; + } + return w; } /** diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 2ec3bb7684..659e6a67ef 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -37,6 +37,7 @@ #include "scenario/ScenarioRepository.h" #include "title/TitleScreen.h" #include "title/TitleSequenceManager.h" +#include "ui/WindowManager.h" #include "Version.h" extern "C" @@ -652,6 +653,12 @@ extern "C" GetContext()->GetUiContext()->SetCursorTrap(value); } + rct_window * context_open_window(rct_windowclass wc) + { + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + return windowManager->OpenWindow(wc); + } + bool platform_open_common_file_dialog(utf8 * outFilename, file_dialog_desc * desc, size_t outSize) { try diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 62cee65864..8b027da6fc 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -18,6 +18,16 @@ #include "common.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + #include "interface/window.h" +#ifdef __cplusplus +} +#endif + typedef struct CursorState { sint32 x, y; @@ -117,7 +127,7 @@ extern "C" sint32 context_get_height(); bool context_has_focus(); void context_set_cursor_trap(bool value); - + rct_window * context_open_window(rct_windowclass wc); #ifdef __cplusplus } #endif diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index adfc81acae..2d634391ee 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -702,8 +702,6 @@ void window_guest_list_open(); void window_guest_list_open_with_filter(sint32 type, sint32 index); void window_map_open(); void window_options_open(); -void window_shortcut_keys_open(); -void window_shortcut_change_open(sint32 selected_key); void window_guest_open(rct_peep* peep); rct_window *window_staff_open(rct_peep* peep); void window_staff_fire_prompt_open(rct_peep* peep); diff --git a/src/openrct2/ui/DummyUiContext.cpp b/src/openrct2/ui/DummyUiContext.cpp index ce666cd405..3ca2c013ba 100644 --- a/src/openrct2/ui/DummyUiContext.cpp +++ b/src/openrct2/ui/DummyUiContext.cpp @@ -16,6 +16,7 @@ #include "../drawing/X8DrawingEngine.h" #include "UiContext.h" +#include "WindowManager.h" using namespace OpenRCT2::Drawing; @@ -26,6 +27,10 @@ namespace OpenRCT2 { namespace Ui */ class DummyUiContext final : public IUiContext { + private: + IWindowManager * const _windowManager = CreateDummyWindowManager(); + + public: void CreateWindow() override { } void CloseWindow() override { } void * GetWindow() override { return nullptr; } @@ -39,32 +44,38 @@ namespace OpenRCT2 { namespace Ui void ProcessMessages() override { } void TriggerResize() override { } - virtual void ShowMessageBox(const std::string &message) override { } - virtual std::string ShowFileDialog(const FileDialogDesc &desc) override { return std::string(); } - virtual std::string ShowDirectoryDialog(const std::string &title) override { return std::string(); } + void ShowMessageBox(const std::string &message) override { } + std::string ShowFileDialog(const FileDialogDesc &desc) override { return std::string(); } + std::string ShowDirectoryDialog(const std::string &title) override { return std::string(); } // Input - virtual const CursorState * GetCursorState() override { return nullptr; } - virtual CURSOR_ID GetCursor() override { return CURSOR_ARROW; } - virtual void SetCursor(CURSOR_ID cursor) override { } - virtual void SetCursorVisible(bool value) override { } - virtual void GetCursorPosition(sint32 * x, sint32 * y) override { } - virtual void SetCursorPosition(sint32 x, sint32 y) override { } - virtual void SetCursorTrap(bool value) override { } - virtual const uint8 * GetKeysState() override { return nullptr; } - virtual const uint8 * GetKeysPressed() override { return nullptr; } - virtual void SetKeysPressed(uint32 keysym, uint8 scancode) override { } + const CursorState * GetCursorState() override { return nullptr; } + CURSOR_ID GetCursor() override { return CURSOR_ARROW; } + void SetCursor(CURSOR_ID cursor) override { } + void SetCursorVisible(bool value) override { } + void GetCursorPosition(sint32 * x, sint32 * y) override { } + void SetCursorPosition(sint32 x, sint32 y) override { } + void SetCursorTrap(bool value) override { } + const uint8 * GetKeysState() override { return nullptr; } + const uint8 * GetKeysPressed() override { return nullptr; } + void SetKeysPressed(uint32 keysym, uint8 scancode) override { } // Drawing - virtual Drawing::IDrawingEngine * CreateDrawingEngine(Drawing::DRAWING_ENGINE_TYPE type) override + Drawing::IDrawingEngine * CreateDrawingEngine(Drawing::DRAWING_ENGINE_TYPE type) override { return new X8DrawingEngine(); } // Text input - virtual bool IsTextInputActive() override { return false; } - virtual TextInputSession * StartTextInput(utf8 * buffer, size_t bufferSize) override { return nullptr; } - virtual void StopTextInput() override { } + bool IsTextInputActive() override { return false; } + TextInputSession * StartTextInput(utf8 * buffer, size_t bufferSize) override { return nullptr; } + void StopTextInput() override { } + + // In-game UI + IWindowManager * GetWindowManager() override + { + return _windowManager; + } }; IUiContext * CreateDummyUiContext() diff --git a/src/openrct2/ui/DummyWindowManager.cpp b/src/openrct2/ui/DummyWindowManager.cpp new file mode 100644 index 0000000000..5ffdc361e9 --- /dev/null +++ b/src/openrct2/ui/DummyWindowManager.cpp @@ -0,0 +1,30 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#include "WindowManager.h" + +namespace OpenRCT2 { namespace Ui +{ + class DummyWindowManager final : public IWindowManager + { + rct_window * OpenWindow(rct_windowclass wc) override { return nullptr; } + }; + + IWindowManager * CreateDummyWindowManager() + { + return new DummyWindowManager(); + } +} } diff --git a/src/openrct2/ui/UiContext.h b/src/openrct2/ui/UiContext.h index 201bd290ae..df3c89f862 100644 --- a/src/openrct2/ui/UiContext.h +++ b/src/openrct2/ui/UiContext.h @@ -32,6 +32,8 @@ namespace OpenRCT2 namespace Ui { + interface IWindowManager; + enum class FULLSCREEN_MODE { WINDOWED, @@ -126,6 +128,9 @@ namespace OpenRCT2 virtual bool IsTextInputActive() abstract; virtual TextInputSession * StartTextInput(utf8 * buffer, size_t bufferSize) abstract; virtual void StopTextInput() abstract; + + // In-game UI + virtual IWindowManager * GetWindowManager() abstract; }; IUiContext * CreateDummyUiContext(); diff --git a/src/openrct2/ui/WindowManager.h b/src/openrct2/ui/WindowManager.h new file mode 100644 index 0000000000..96db0dae17 --- /dev/null +++ b/src/openrct2/ui/WindowManager.h @@ -0,0 +1,41 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../common.h" + +extern "C" +{ + #include "../interface/window.h" +} + +namespace OpenRCT2 +{ + namespace Ui + { + /** + * Manager of in-game windows and widgets. + */ + interface IWindowManager + { + virtual ~IWindowManager() = default; + virtual rct_window * OpenWindow(rct_windowclass wc) abstract; + }; + + IWindowManager * CreateDummyWindowManager(); + } +} diff --git a/src/openrct2/windows/options.c b/src/openrct2/windows/options.c index d1de6a6231..474b6db8dd 100644 --- a/src/openrct2/windows/options.c +++ b/src/openrct2/windows/options.c @@ -738,7 +738,7 @@ static void window_options_mouseup(rct_window *w, rct_widgetindex widgetIndex) case WINDOW_OPTIONS_PAGE_CONTROLS_AND_INTERFACE: switch (widgetIndex) { case WIDX_HOTKEY_DROPDOWN: - window_shortcut_keys_open(); + context_open_window(WC_KEYBOARD_SHORTCUT_LIST); break; case WIDX_SCREEN_EDGE_SCROLLING: gConfigGeneral.edge_scrolling ^= 1; From 89ea9064deff7019966e96fdd1bada4a0565514f Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 15:59:19 +0100 Subject: [PATCH 5/8] Move things in keyboard_shortcut.h into KeyboardShortcuts.h --- src/openrct2-ui/input/KeyboardShortcuts.h | 95 ++++++++++++++++-- src/openrct2-ui/input/keyboard_shortcut.h | 116 ---------------------- 2 files changed, 88 insertions(+), 123 deletions(-) delete mode 100644 src/openrct2-ui/input/keyboard_shortcut.h diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index f08038d80a..cc7dd93a83 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -18,14 +18,87 @@ #include -#ifdef __cplusplus -extern "C" +#define SHIFT 0x100 +#define CTRL 0x200 +#define ALT 0x400 +#define CMD 0x800 +#ifdef __MACOSX__ + #define PLATFORM_MODIFIER CMD +#else + #define PLATFORM_MODIFIER CTRL +#endif + +enum { -#endif - #include "../input/keyboard_shortcut.h" -#ifdef __cplusplus -} -#endif + SHORTCUT_CLOSE_TOP_MOST_WINDOW, + SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS, + SHORTCUT_CANCEL_CONSTRUCTION_MODE, + SHORTCUT_PAUSE_GAME, + SHORTCUT_ZOOM_VIEW_OUT, + SHORTCUT_ZOOM_VIEW_IN, + SHORTCUT_ROTATE_VIEW_CLOCKWISE, + SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE, + SHORTCUT_ROTATE_CONSTRUCTION_OBJECT, + SHORTCUT_UNDERGROUND_VIEW_TOGGLE, + SHORTCUT_REMOVE_BASE_LAND_TOGGLE, + SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE, + SHORTCUT_SEE_THROUGH_RIDES_TOGGLE, + SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE, + SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE, + SHORTCUT_INVISIBLE_PEOPLE_TOGGLE, + SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE, + SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE, + SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE, + SHORTCUT_ADJUST_LAND, + SHORTCUT_ADJUST_WATER, + SHORTCUT_BUILD_SCENERY, + SHORTCUT_BUILD_PATHS, + SHORTCUT_BUILD_NEW_RIDE, + SHORTCUT_SHOW_FINANCIAL_INFORMATION, + SHORTCUT_SHOW_RESEARCH_INFORMATION, + SHORTCUT_SHOW_RIDES_LIST, + SHORTCUT_SHOW_PARK_INFORMATION, + SHORTCUT_SHOW_GUEST_LIST, + SHORTCUT_SHOW_STAFF_LIST, + SHORTCUT_SHOW_RECENT_MESSAGES, + SHORTCUT_SHOW_MAP, + SHORTCUT_SCREENSHOT, + + // New + SHORTCUT_REDUCE_GAME_SPEED, + SHORTCUT_INCREASE_GAME_SPEED, + SHORTCUT_OPEN_CHEAT_WINDOW, + SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE, + SHORTCUT_SCROLL_MAP_UP, + SHORTCUT_SCROLL_MAP_LEFT, + SHORTCUT_SCROLL_MAP_DOWN, + SHORTCUT_SCROLL_MAP_RIGHT, + SHORTCUT_OPEN_CHAT_WINDOW, + SHORTCUT_QUICK_SAVE_GAME, + SHORTCUT_SHOW_OPTIONS, + SHORTCUT_MUTE_SOUND, + SHORTCUT_WINDOWED_MODE_TOGGLE, + SHORTCUT_SHOW_MULTIPLAYER, + SHORTCUT_PAINT_ORIGINAL_TOGGLE, + SHORTCUT_DEBUG_PAINT_TOGGLE, + SHORTCUT_SEE_THROUGH_PATHS_TOGGLE, + SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT, + SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT, + SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT, + SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN, + SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP, + SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE, + SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT, + SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT, + SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK, + SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK, + SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT, + SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT, + + SHORTCUT_COUNT, + + SHORTCUT_UNDEFINED = 0xFFFF, +}; #ifdef __cplusplus @@ -69,6 +142,9 @@ extern "C" #endif typedef struct rct_window rct_window; + /** The current shortcut being changed. */ + extern uint8 gKeyboardShortcutChangeId; + void keyboard_shortcuts_reset(); bool keyboard_shortcuts_load(); bool keyboard_shortcuts_save(); @@ -78,6 +154,11 @@ extern "C" rct_window * window_shortcut_keys_open(); rct_window * window_shortcut_change_open(sint32 selected_key); + + void keyboard_shortcut_set(sint32 key); + void keyboard_shortcut_handle(sint32 key); + void keyboard_shortcut_handle_command(sint32 shortcutIndex); + void keyboard_shortcut_format_string(char *buffer, size_t size, uint16 shortcutKey); #ifdef __cplusplus } #endif diff --git a/src/openrct2-ui/input/keyboard_shortcut.h b/src/openrct2-ui/input/keyboard_shortcut.h deleted file mode 100644 index a897e2562c..0000000000 --- a/src/openrct2-ui/input/keyboard_shortcut.h +++ /dev/null @@ -1,116 +0,0 @@ -#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers -/***************************************************************************** - * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. - * - * OpenRCT2 is the work of many authors, a full list can be found in contributors.md - * For more information, visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * A full copy of the GNU General Public License can be found in licence.txt - *****************************************************************************/ -#pragma endregion - -#ifndef _INTERFACE_KEYBOARD_SHORTCUT_H_ -#define _INTERFACE_KEYBOARD_SHORTCUT_H_ - -#include - -#define SHORTCUT_UNDEFINED 0xFFFF - -/** The current shortcut being changed. */ -extern uint8 gKeyboardShortcutChangeId; - -void keyboard_shortcut_set(sint32 key); -void keyboard_shortcut_handle(sint32 key); -void keyboard_shortcut_handle_command(sint32 shortcutIndex); -void keyboard_shortcut_format_string(char *buffer, size_t size, uint16 shortcutKey); - -typedef struct shortcut_entry { - uint8 key; - uint8 modifier; -} shortcut_entry; - -enum { - SHORTCUT_CLOSE_TOP_MOST_WINDOW, - SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS, - SHORTCUT_CANCEL_CONSTRUCTION_MODE, - SHORTCUT_PAUSE_GAME, - SHORTCUT_ZOOM_VIEW_OUT, - SHORTCUT_ZOOM_VIEW_IN, - SHORTCUT_ROTATE_VIEW_CLOCKWISE, - SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE, - SHORTCUT_ROTATE_CONSTRUCTION_OBJECT, - SHORTCUT_UNDERGROUND_VIEW_TOGGLE, - SHORTCUT_REMOVE_BASE_LAND_TOGGLE, - SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE, - SHORTCUT_SEE_THROUGH_RIDES_TOGGLE, - SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE, - SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE, - SHORTCUT_INVISIBLE_PEOPLE_TOGGLE, - SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE, - SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE, - SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE, - SHORTCUT_ADJUST_LAND, - SHORTCUT_ADJUST_WATER, - SHORTCUT_BUILD_SCENERY, - SHORTCUT_BUILD_PATHS, - SHORTCUT_BUILD_NEW_RIDE, - SHORTCUT_SHOW_FINANCIAL_INFORMATION, - SHORTCUT_SHOW_RESEARCH_INFORMATION, - SHORTCUT_SHOW_RIDES_LIST, - SHORTCUT_SHOW_PARK_INFORMATION, - SHORTCUT_SHOW_GUEST_LIST, - SHORTCUT_SHOW_STAFF_LIST, - SHORTCUT_SHOW_RECENT_MESSAGES, - SHORTCUT_SHOW_MAP, - SHORTCUT_SCREENSHOT, - - // New - SHORTCUT_REDUCE_GAME_SPEED, - SHORTCUT_INCREASE_GAME_SPEED, - SHORTCUT_OPEN_CHEAT_WINDOW, - SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE, - SHORTCUT_SCROLL_MAP_UP, - SHORTCUT_SCROLL_MAP_LEFT, - SHORTCUT_SCROLL_MAP_DOWN, - SHORTCUT_SCROLL_MAP_RIGHT, - SHORTCUT_OPEN_CHAT_WINDOW, - SHORTCUT_QUICK_SAVE_GAME, - SHORTCUT_SHOW_OPTIONS, - SHORTCUT_MUTE_SOUND, - SHORTCUT_WINDOWED_MODE_TOGGLE, - SHORTCUT_SHOW_MULTIPLAYER, - SHORTCUT_PAINT_ORIGINAL_TOGGLE, - SHORTCUT_DEBUG_PAINT_TOGGLE, - SHORTCUT_SEE_THROUGH_PATHS_TOGGLE, - SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT, - SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT, - SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT, - SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN, - SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP, - SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE, - SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT, - SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT, - SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK, - SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK, - SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT, - SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT, - - SHORTCUT_COUNT -}; - -#define SHIFT 0x100 -#define CTRL 0x200 -#define ALT 0x400 -#define CMD 0x800 -#ifdef __MACOSX__ -#define PLATFORM_MODIFIER CMD -#else -#define PLATFORM_MODIFIER CTRL -#endif - -#endif From 524248cfec457250d808e8a0c1653c7cb58312b6 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 17:22:07 +0100 Subject: [PATCH 6/8] Fix libopenrct2ui.vcxproj --- src/openrct2-ui/libopenrct2ui.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 54b0ced030..36efcad5b6 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -68,7 +68,6 @@ - From 7a86fc2cb50307f9d0b65247adf64604c00e10ce Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 11 Jun 2017 16:31:54 +0100 Subject: [PATCH 7/8] Link back shortcut functions Some of this will be temporary until input and windows move over to libopenrct2ui. --- src/openrct2-ui/WindowManager.cpp | 17 ++ src/openrct2-ui/input/KeyboardShortcuts.cpp | 55 ++++++- src/openrct2-ui/input/KeyboardShortcuts.h | 4 +- src/openrct2-ui/libopenrct2ui.vcxproj | 2 + src/openrct2/Context.cpp | 12 ++ src/openrct2/Context.h | 2 + src/openrct2/input.c | 162 +++++--------------- src/openrct2/ui/DummyWindowManager.cpp | 2 + src/openrct2/ui/WindowManager.h | 3 + 9 files changed, 130 insertions(+), 129 deletions(-) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index c62d264eb0..041502635e 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -32,6 +32,23 @@ public: return nullptr; } } + + void HandleKeyboardShortcut(sint32 key) override + { + rct_window * w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); + if (w != NULL) { + keyboard_shortcuts_set(key); + window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); + window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); + } else { + keyboard_shortcut_handle(key); + } + } + + void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) override + { + get_keyboard_map_scroll(keysState, x, y); + } }; IWindowManager * OpenRCT2::Ui::CreateWindowManager() diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp index 4ae54c6597..817d90e38d 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.cpp +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -109,8 +109,6 @@ void KeyboardShortcuts::Set(sint32 key) // Map shortcut to this key _keys[gKeyboardShortcutChangeId] = key; - // window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); - // window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); Save(); } @@ -160,6 +158,54 @@ std::string KeyboardShortcuts::GetShortcutString(sint32 shortcut) const return std::string(buffer); } +void KeyboardShortcuts::GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) const +{ + for (sint32 shortcutId = SHORTCUT_SCROLL_MAP_UP; shortcutId <= SHORTCUT_SCROLL_MAP_RIGHT; shortcutId++) + { + uint16 shortcutKey = _keys[shortcutId]; + uint8 scancode = shortcutKey & 0xFF; + + if (shortcutKey == 0xFFFF) continue; + if (!keysState[scancode]) continue; + + if (shortcutKey & SHIFT) { + if (!keysState[SDL_SCANCODE_LSHIFT] && !keysState[SDL_SCANCODE_RSHIFT]) continue; + } + if (shortcutKey & CTRL) { + if (!keysState[SDL_SCANCODE_LCTRL] && !keysState[SDL_SCANCODE_RCTRL]) continue; + } + if (shortcutKey & ALT) { + if (!keysState[SDL_SCANCODE_LALT] && !keysState[SDL_SCANCODE_RALT]) continue; + } +#ifdef __MACOSX__ + if (shortcutKey & CMD) { + if (!keysState[SDL_SCANCODE_LGUI] && !keysState[SDL_SCANCODE_RGUI]) continue; + } +#endif + switch (shortcutId) { + case SHORTCUT_SCROLL_MAP_UP: + *x = 0; + *y = -1; + break; + case SHORTCUT_SCROLL_MAP_LEFT: + *x = -1; + *y = 0; + break; + case SHORTCUT_SCROLL_MAP_DOWN: + *x = 0; + *y = 1; + break; + case SHORTCUT_SCROLL_MAP_RIGHT: + *x = 1; + *y = 0; + break; + default: + *x = 0; + *y = 0; + } + } +} + extern "C" { void keyboard_shortcuts_reset() @@ -192,6 +238,11 @@ extern "C" auto str = _instance->GetShortcutString(shortcut); String::Set(buffer, bufferSize, str.c_str()); } + + void get_keyboard_map_scroll(const uint8 * keysState, sint32 * x, sint32 * y) + { + _instance->GetKeyboardMapScroll(keysState, x, y); + } } // Default keyboard shortcuts diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index cc7dd93a83..7e0f58e5f4 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -130,6 +130,7 @@ namespace OpenRCT2 void Set(sint32 key); sint32 GetFromKey(sint32 key); + void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) const; }; } } @@ -155,10 +156,11 @@ extern "C" rct_window * window_shortcut_keys_open(); rct_window * window_shortcut_change_open(sint32 selected_key); - void keyboard_shortcut_set(sint32 key); void keyboard_shortcut_handle(sint32 key); void keyboard_shortcut_handle_command(sint32 shortcutIndex); void keyboard_shortcut_format_string(char *buffer, size_t size, uint16 shortcutKey); + + void get_keyboard_map_scroll(const uint8 * keysState, sint32 * x, sint32 * y); #ifdef __cplusplus } #endif diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 36efcad5b6..391cbe7109 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -48,6 +48,7 @@ + @@ -72,6 +73,7 @@ + {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 659e6a67ef..7766a9df51 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -659,6 +659,18 @@ extern "C" return windowManager->OpenWindow(wc); } + void context_handle_keyboard_shortcut(sint32 key) + { + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + windowManager->HandleKeyboardShortcut(key); + } + + void context_get_keyboard_map_scroll(const uint8 * keysState, sint32 * x, sint32 * y) + { + auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); + windowManager->GetKeyboardMapScroll(keysState, x, y); + } + bool platform_open_common_file_dialog(utf8 * outFilename, file_dialog_desc * desc, size_t outSize) { try diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 8b027da6fc..45c52eca91 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -128,6 +128,8 @@ extern "C" bool context_has_focus(); void context_set_cursor_trap(bool value); rct_window * context_open_window(rct_windowclass wc); + void context_handle_keyboard_shortcut(sint32 key); + void context_get_keyboard_map_scroll(const uint8 * keysState, sint32 * x, sint32 * y); #ifdef __cplusplus } #endif diff --git a/src/openrct2/input.c b/src/openrct2/input.c index 490bca269e..94d21de70d 100644 --- a/src/openrct2/input.c +++ b/src/openrct2/input.c @@ -1434,87 +1434,19 @@ static void input_handle_chat(sint32 key) } } -/** - * - * rct2: 0x006E3B43 - */ -void title_handle_keyboard_input() +static void input_handle_keyboard(bool isTitle) { - rct_window *w; - sint32 key; - if (gOpenRCT2Headless) { return; } if (!gConsoleOpen) { - // Handle modifier keys and key scrolling - gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE; - const uint8 * keysState = context_get_keys_state(); - if (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT]) - gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z; - if (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL]) - gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z; - if (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT]) - gInputPlaceObjectModifier |= 4; -#ifdef __MACOSX__ - if (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI]) { - gInputPlaceObjectModifier |= 8; - } -#endif - } - - while ((key = get_next_key()) != 0) { - if (key == 255) - continue; - - // Reserve backtick for console - if (key == SDL_SCANCODE_GRAVE) { - if ((gConfigGeneral.debugging_tools && !context_is_input_active()) || gConsoleOpen) { - window_cancel_textbox(); - console_toggle(); - } - continue; - } else if (gConsoleOpen) { - input_handle_console(key); - continue; - } - - key |= gInputPlaceObjectModifier << 8; - - w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); - if (w != NULL) { - // keyboard_shortcut_set(key); - } else { - w = window_find_by_class(WC_TEXTINPUT); - if (w != NULL) { - window_text_input_key(w, key); - } - else if (!gUsingWidgetTextBox) { - // keyboard_shortcut_handle(key); - } - } - } -} - -/** - * - * rct2: 0x006E3B43 - */ -void game_handle_keyboard_input() -{ - rct_window *w; - sint32 key; - - if (gOpenRCT2Headless) { - return; - } - - if (!gConsoleOpen) { - // Handle mouse scrolling - if (_inputState == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling) { - if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z))) { - game_handle_edge_scroll(); + if (!isTitle) { + // Handle mouse scrolling + if (_inputState == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling) { + if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z))) { + game_handle_edge_scroll(); + } } } @@ -1535,11 +1467,13 @@ void game_handle_keyboard_input() gInputPlaceObjectModifier |= 8; } #endif - game_handle_key_scroll(); + if (!isTitle) { + game_handle_key_scroll(); + } } - // Handle key input + sint32 key; while (!gOpenRCT2Headless && (key = get_next_key()) != 0) { if (key == 255) continue; @@ -1554,27 +1488,40 @@ void game_handle_keyboard_input() } else if (gConsoleOpen) { input_handle_console(key); continue; - } else if (gChatOpen) { + } else if (!isTitle && gChatOpen) { input_handle_chat(key); continue; } key |= gInputPlaceObjectModifier << 8; - w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); + rct_window * w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { - // keyboard_shortcut_set(key); - } else { - w = window_find_by_class(WC_TEXTINPUT); - if (w != NULL) { - window_text_input_key(w, key); - } else if (!gUsingWidgetTextBox) { - // keyboard_shortcut_handle(key); - } + window_text_input_key(w, key); + } else if (!gUsingWidgetTextBox) { + context_handle_keyboard_shortcut(key); } } } +/** + * + * rct2: 0x006E3B43 + */ +void title_handle_keyboard_input() +{ + input_handle_keyboard(true); +} + +/** + * + * rct2: 0x006E3B43 + */ +void game_handle_keyboard_input() +{ + input_handle_keyboard(false); +} + /** * * rct2: 0x00406CD2 @@ -1704,45 +1651,8 @@ void game_handle_key_scroll() scrollX = 0; scrollY = 0; - -// const uint8 * keysState = context_get_keys_state(); -// for (sint32 shortcutId = SHORTCUT_SCROLL_MAP_UP; shortcutId <= SHORTCUT_SCROLL_MAP_RIGHT; shortcutId++) { -// uint16 shortcutKey = gShortcutKeys[shortcutId]; -// uint8 scancode = shortcutKey & 0xFF; -// -// if (shortcutKey == 0xFFFF) continue; -// if (!keysState[scancode]) continue; -// -// if (shortcutKey & SHIFT) { -// if (!keysState[SDL_SCANCODE_LSHIFT] && !keysState[SDL_SCANCODE_RSHIFT]) continue; -// } -// if (shortcutKey & CTRL) { -// if (!keysState[SDL_SCANCODE_LCTRL] && !keysState[SDL_SCANCODE_RCTRL]) continue; -// } -// if (shortcutKey & ALT) { -// if (!keysState[SDL_SCANCODE_LALT] && !keysState[SDL_SCANCODE_RALT]) continue; -// } -// #ifdef __MACOSX__ -// if (shortcutKey & CMD) { -// if (!keysState[SDL_SCANCODE_LGUI] && !keysState[SDL_SCANCODE_RGUI]) continue; -// } -// #endif -// -// switch (shortcutId) { -// case SHORTCUT_SCROLL_MAP_UP: -// scrollY = -1; -// break; -// case SHORTCUT_SCROLL_MAP_LEFT: -// scrollX = -1; -// break; -// case SHORTCUT_SCROLL_MAP_DOWN: -// scrollY = 1; -// break; -// case SHORTCUT_SCROLL_MAP_RIGHT: -// scrollX = 1; -// break; -// } -// } + const uint8 * keysState = context_get_keys_state(); + context_get_keyboard_map_scroll(keysState, &scrollX, &scrollY); // Scroll viewport if (scrollX != 0) { diff --git a/src/openrct2/ui/DummyWindowManager.cpp b/src/openrct2/ui/DummyWindowManager.cpp index 5ffdc361e9..8d3102fc54 100644 --- a/src/openrct2/ui/DummyWindowManager.cpp +++ b/src/openrct2/ui/DummyWindowManager.cpp @@ -21,6 +21,8 @@ namespace OpenRCT2 { namespace Ui class DummyWindowManager final : public IWindowManager { rct_window * OpenWindow(rct_windowclass wc) override { return nullptr; } + void HandleKeyboardShortcut(sint32 key) override { } + void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) override { } }; IWindowManager * CreateDummyWindowManager() diff --git a/src/openrct2/ui/WindowManager.h b/src/openrct2/ui/WindowManager.h index 96db0dae17..12bbb6aef9 100644 --- a/src/openrct2/ui/WindowManager.h +++ b/src/openrct2/ui/WindowManager.h @@ -34,6 +34,9 @@ namespace OpenRCT2 { virtual ~IWindowManager() = default; virtual rct_window * OpenWindow(rct_windowclass wc) abstract; + + virtual void HandleKeyboardShortcut(sint32 key) abstract; + virtual void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) abstract; }; IWindowManager * CreateDummyWindowManager(); From 2a3dda9838ec34a0aafecbcf823f8e40d6643eaf Mon Sep 17 00:00:00 2001 From: Richard Jenkins Date: Sun, 11 Jun 2017 17:14:51 +0100 Subject: [PATCH 8/8] Xcode fix --- OpenRCT2.xcodeproj/project.pbxproj | 68 +++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index e1289c94ba..7f643076b4 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -91,7 +91,6 @@ F76C85C41EC4E88300FA49E2 /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C836E1EC4E7CC00FA49E2 /* Config.cpp */; }; F76C85C71EC4E88300FA49E2 /* IniReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83711EC4E7CC00FA49E2 /* IniReader.cpp */; }; F76C85C91EC4E88300FA49E2 /* IniWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83731EC4E7CC00FA49E2 /* IniWriter.cpp */; }; - F76C85CB1EC4E88300FA49E2 /* KeyboardShortcuts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83751EC4E7CC00FA49E2 /* KeyboardShortcuts.cpp */; }; F76C85CC1EC4E88300FA49E2 /* Context.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83761EC4E7CC00FA49E2 /* Context.cpp */; }; F76C85CF1EC4E88300FA49E2 /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C837A1EC4E7CC00FA49E2 /* Console.cpp */; }; F76C85D11EC4E88300FA49E2 /* Diagnostics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C837C1EC4E7CC00FA49E2 /* Diagnostics.cpp */; }; @@ -128,7 +127,6 @@ F76C86131EC4E88300FA49E2 /* console.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83C01EC4E7CC00FA49E2 /* console.c */; }; F76C86161EC4E88300FA49E2 /* Fonts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83C31EC4E7CC00FA49E2 /* Fonts.cpp */; }; F76C86181EC4E88300FA49E2 /* graph.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83C51EC4E7CC00FA49E2 /* graph.c */; }; - F76C861A1EC4E88300FA49E2 /* keyboard_shortcut.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83C71EC4E7CC00FA49E2 /* keyboard_shortcut.c */; }; F76C861E1EC4E88300FA49E2 /* Theme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83CB1EC4E7CC00FA49E2 /* Theme.cpp */; }; F76C86201EC4E88300FA49E2 /* viewport.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83CD1EC4E7CC00FA49E2 /* viewport.c */; }; F76C86221EC4E88300FA49E2 /* viewport_interaction.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83CF1EC4E7CC00FA49E2 /* viewport_interaction.c */; }; @@ -368,8 +366,6 @@ F76C87771EC4E88400FA49E2 /* scenery.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C853E1EC4E7CD00FA49E2 /* scenery.c */; }; F76C87781EC4E88400FA49E2 /* server_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C853F1EC4E7CD00FA49E2 /* server_list.cpp */; }; F76C87791EC4E88400FA49E2 /* server_start.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85401EC4E7CD00FA49E2 /* server_start.c */; }; - F76C877A1EC4E88400FA49E2 /* shortcut_key_change.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85411EC4E7CD00FA49E2 /* shortcut_key_change.c */; }; - F76C877B1EC4E88400FA49E2 /* shortcut_keys.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85421EC4E7CD00FA49E2 /* shortcut_keys.c */; }; F76C877C1EC4E88400FA49E2 /* sign.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85431EC4E7CD00FA49E2 /* sign.c */; }; F76C877D1EC4E88400FA49E2 /* staff.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85441EC4E7CD00FA49E2 /* staff.c */; }; F76C877E1EC4E88400FA49E2 /* staff_fire_prompt.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C85451EC4E7CD00FA49E2 /* staff_fire_prompt.c */; }; @@ -438,6 +434,13 @@ F775F5351EE35A89001F00E7 /* DummyUiContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F775F5331EE35A6B001F00E7 /* DummyUiContext.cpp */; }; F775F5371EE3724F001F00E7 /* DummyAudioContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F775F5361EE3724F001F00E7 /* DummyAudioContext.cpp */; }; F775F5381EE3725C001F00E7 /* DummyAudioContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F775F5361EE3724F001F00E7 /* DummyAudioContext.cpp */; }; + F7CB863F1EEDA0B50030C877 /* WindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB863D1EEDA0B50030C877 /* WindowManager.cpp */; }; + F7CB86431EEDA0F50030C877 /* shortcut_key_change.c in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86411EEDA0F50030C877 /* shortcut_key_change.c */; }; + F7CB86441EEDA0F50030C877 /* shortcut_keys.c in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86421EEDA0F50030C877 /* shortcut_keys.c */; }; + F7CB86491EEDA1330030C877 /* keyboard_shortcut.c in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */; }; + F7CB864A1EEDA1330030C877 /* KeyboardShortcuts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */; }; + F7CB864D1EEDA1A80030C877 /* DummyWindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */; }; + F7CB864E1EEDA2050030C877 /* DummyWindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */; }; F7D7747B1EC5EB6D00BE6EBC /* lay_down_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84951EC4E7CC00FA49E2 /* lay_down_roller_coaster.c */; }; F7D7747F1EC61E5100BE6EBC /* UiContext.macOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F7D7747E1EC61E5100BE6EBC /* UiContext.macOS.mm */; }; F7D7748D1EC66F8600BE6EBC /* libopenrct2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F76C809A1EC4D9FA00FA49E2 /* libopenrct2.a */; }; @@ -798,7 +801,6 @@ F76C83721EC4E7CC00FA49E2 /* IniReader.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IniReader.hpp; sourceTree = ""; }; F76C83731EC4E7CC00FA49E2 /* IniWriter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IniWriter.cpp; sourceTree = ""; }; F76C83741EC4E7CC00FA49E2 /* IniWriter.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IniWriter.hpp; sourceTree = ""; }; - F76C83751EC4E7CC00FA49E2 /* KeyboardShortcuts.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardShortcuts.cpp; sourceTree = ""; }; F76C83761EC4E7CC00FA49E2 /* Context.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Context.cpp; sourceTree = ""; }; F76C83771EC4E7CC00FA49E2 /* Context.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Context.h; sourceTree = ""; }; F76C83791EC4E7CC00FA49E2 /* Collections.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Collections.hpp; sourceTree = ""; }; @@ -877,8 +879,6 @@ F76C83C41EC4E7CC00FA49E2 /* Fonts.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fonts.h; sourceTree = ""; }; F76C83C51EC4E7CC00FA49E2 /* graph.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = graph.c; sourceTree = ""; }; F76C83C61EC4E7CC00FA49E2 /* graph.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = graph.h; sourceTree = ""; }; - F76C83C71EC4E7CC00FA49E2 /* keyboard_shortcut.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = keyboard_shortcut.c; sourceTree = ""; }; - F76C83C81EC4E7CC00FA49E2 /* keyboard_shortcut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = keyboard_shortcut.h; sourceTree = ""; }; F76C83CA1EC4E7CC00FA49E2 /* screenshot.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = screenshot.h; sourceTree = ""; }; F76C83CB1EC4E7CC00FA49E2 /* Theme.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Theme.cpp; sourceTree = ""; }; F76C83CC1EC4E7CC00FA49E2 /* themes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = themes.h; sourceTree = ""; }; @@ -1228,8 +1228,6 @@ F76C853E1EC4E7CD00FA49E2 /* scenery.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = scenery.c; sourceTree = ""; }; F76C853F1EC4E7CD00FA49E2 /* server_list.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = server_list.cpp; sourceTree = ""; }; F76C85401EC4E7CD00FA49E2 /* server_start.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = server_start.c; sourceTree = ""; }; - F76C85411EC4E7CD00FA49E2 /* shortcut_key_change.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = shortcut_key_change.c; sourceTree = ""; }; - F76C85421EC4E7CD00FA49E2 /* shortcut_keys.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = shortcut_keys.c; sourceTree = ""; }; F76C85431EC4E7CD00FA49E2 /* sign.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sign.c; sourceTree = ""; }; F76C85441EC4E7CD00FA49E2 /* staff.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = staff.c; sourceTree = ""; }; F76C85451EC4E7CD00FA49E2 /* staff_fire_prompt.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = staff_fire_prompt.c; sourceTree = ""; }; @@ -1331,6 +1329,15 @@ F775F5321EE35A48001F00E7 /* Ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Ui.h; sourceTree = ""; }; F775F5331EE35A6B001F00E7 /* DummyUiContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DummyUiContext.cpp; sourceTree = ""; }; F775F5361EE3724F001F00E7 /* DummyAudioContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DummyAudioContext.cpp; sourceTree = ""; }; + F7CB863D1EEDA0B50030C877 /* WindowManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowManager.cpp; sourceTree = ""; }; + F7CB863E1EEDA0B50030C877 /* WindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowManager.h; sourceTree = ""; }; + F7CB86411EEDA0F50030C877 /* shortcut_key_change.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = shortcut_key_change.c; path = windows/shortcut_key_change.c; sourceTree = ""; }; + F7CB86421EEDA0F50030C877 /* shortcut_keys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = shortcut_keys.c; path = windows/shortcut_keys.c; sourceTree = ""; }; + F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = keyboard_shortcut.c; path = input/keyboard_shortcut.c; sourceTree = ""; }; + F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KeyboardShortcuts.cpp; path = input/KeyboardShortcuts.cpp; sourceTree = ""; }; + F7CB86481EEDA1330030C877 /* KeyboardShortcuts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyboardShortcuts.h; path = input/KeyboardShortcuts.h; sourceTree = ""; }; + F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DummyWindowManager.cpp; sourceTree = ""; }; + F7CB864C1EEDA1A80030C877 /* WindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowManager.h; sourceTree = ""; }; F7D7747E1EC61E5100BE6EBC /* UiContext.macOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UiContext.macOS.mm; sourceTree = ""; usesTabs = 0; }; F7D774841EC66CD700BE6EBC /* OpenRCT2-cli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "OpenRCT2-cli"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -1813,7 +1820,6 @@ F76C83721EC4E7CC00FA49E2 /* IniReader.hpp */, F76C83731EC4E7CC00FA49E2 /* IniWriter.cpp */, F76C83741EC4E7CC00FA49E2 /* IniWriter.hpp */, - F76C83751EC4E7CC00FA49E2 /* KeyboardShortcuts.cpp */, ); path = config; sourceTree = ""; @@ -1902,8 +1908,6 @@ F76C83C41EC4E7CC00FA49E2 /* Fonts.h */, F76C83C51EC4E7CC00FA49E2 /* graph.c */, F76C83C61EC4E7CC00FA49E2 /* graph.h */, - F76C83C71EC4E7CC00FA49E2 /* keyboard_shortcut.c */, - F76C83C81EC4E7CC00FA49E2 /* keyboard_shortcut.h */, F76C83CA1EC4E7CC00FA49E2 /* screenshot.h */, F76C83CB1EC4E7CC00FA49E2 /* Theme.cpp */, F76C83CC1EC4E7CC00FA49E2 /* themes.h */, @@ -2340,6 +2344,8 @@ F76C85041EC4E7CD00FA49E2 /* ui */ = { isa = PBXGroup; children = ( + F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */, + F7CB864C1EEDA1A80030C877 /* WindowManager.h */, F775F5331EE35A6B001F00E7 /* DummyUiContext.cpp */, F76C85051EC4E7CD00FA49E2 /* UiContext.h */, ); @@ -2411,8 +2417,6 @@ F76C853E1EC4E7CD00FA49E2 /* scenery.c */, F76C853F1EC4E7CD00FA49E2 /* server_list.cpp */, F76C85401EC4E7CD00FA49E2 /* server_start.c */, - F76C85411EC4E7CD00FA49E2 /* shortcut_key_change.c */, - F76C85421EC4E7CD00FA49E2 /* shortcut_keys.c */, F76C85431EC4E7CD00FA49E2 /* sign.c */, F76C85441EC4E7CD00FA49E2 /* staff.c */, F76C85451EC4E7CD00FA49E2 /* staff_fire_prompt.c */, @@ -2492,21 +2496,25 @@ F76C85801EC4E82600FA49E2 /* openrct2-ui */ = { isa = PBXGroup; children = ( - F775F5321EE35A48001F00E7 /* Ui.h */, F76C85811EC4E82600FA49E2 /* audio */, F76C858D1EC4E82600FA49E2 /* drawing */, + F7CB86451EEDA1200030C877 /* input */, + F7CB86401EEDA0E20030C877 /* windows */, F76C858A1EC4E82600FA49E2 /* CursorData.cpp */, F76C858B1EC4E82600FA49E2 /* CursorRepository.cpp */, F76C858C1EC4E82600FA49E2 /* CursorRepository.h */, F76C85A81EC4E82600FA49E2 /* SDLException.h */, F76C85A91EC4E82600FA49E2 /* TextComposition.cpp */, F76C85AA1EC4E82600FA49E2 /* TextComposition.h */, + F775F5321EE35A48001F00E7 /* Ui.h */, F76C85AB1EC4E82600FA49E2 /* Ui.cpp */, F76C85AC1EC4E82600FA49E2 /* UiContext.cpp */, F76C85AD1EC4E82600FA49E2 /* UiContext.h */, F76C85AE1EC4E82600FA49E2 /* UiContext.Linux.cpp */, F7D7747E1EC61E5100BE6EBC /* UiContext.macOS.mm */, F76C85AF1EC4E82600FA49E2 /* UiContext.Win32.cpp */, + F7CB863E1EEDA0B50030C877 /* WindowManager.h */, + F7CB863D1EEDA0B50030C877 /* WindowManager.cpp */, ); name = "openrct2-ui"; path = "src/openrct2-ui"; @@ -2573,6 +2581,25 @@ path = opengl; sourceTree = ""; }; + F7CB86401EEDA0E20030C877 /* windows */ = { + isa = PBXGroup; + children = ( + F7CB86411EEDA0F50030C877 /* shortcut_key_change.c */, + F7CB86421EEDA0F50030C877 /* shortcut_keys.c */, + ); + name = windows; + sourceTree = ""; + }; + F7CB86451EEDA1200030C877 /* input */ = { + isa = PBXGroup; + children = ( + F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */, + F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */, + F7CB86481EEDA1330030C877 /* KeyboardShortcuts.h */, + ); + name = input; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -2931,21 +2958,27 @@ 4C8B42721EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp in Sources */, F76C887A1EC5324E00FA49E2 /* AudioMixer.cpp in Sources */, F76C887B1EC5324E00FA49E2 /* FileAudioSource.cpp in Sources */, + F7CB864D1EEDA1A80030C877 /* DummyWindowManager.cpp in Sources */, F76C887C1EC5324E00FA49E2 /* MemoryAudioSource.cpp in Sources */, F76C887D1EC5324E00FA49E2 /* CursorData.cpp in Sources */, F7D7747F1EC61E5100BE6EBC /* UiContext.macOS.mm in Sources */, F76C887E1EC5324E00FA49E2 /* CursorRepository.cpp in Sources */, F775F5341EE35A6B001F00E7 /* DummyUiContext.cpp in Sources */, F76C887F1EC5324E00FA49E2 /* CopyFramebufferShader.cpp in Sources */, + F7CB864A1EEDA1330030C877 /* KeyboardShortcuts.cpp in Sources */, + F7CB86431EEDA0F50030C877 /* shortcut_key_change.c in Sources */, F76C88801EC5324E00FA49E2 /* DrawImageShader.cpp in Sources */, F775F5371EE3724F001F00E7 /* DummyAudioContext.cpp in Sources */, F76C88811EC5324E00FA49E2 /* DrawLineShader.cpp in Sources */, F76C88821EC5324E00FA49E2 /* FillRectShader.cpp in Sources */, F76C88831EC5324E00FA49E2 /* OpenGLAPI.cpp in Sources */, + F7CB863F1EEDA0B50030C877 /* WindowManager.cpp in Sources */, 4C8B42701EEB1ABD00F015CA /* X8DrawingEngine.cpp in Sources */, + F7CB86491EEDA1330030C877 /* keyboard_shortcut.c in Sources */, F76C88841EC5324E00FA49E2 /* OpenGLDrawingEngine.cpp in Sources */, F76C88851EC5324E00FA49E2 /* OpenGLFramebuffer.cpp in Sources */, F76C88861EC5324E00FA49E2 /* OpenGLShaderProgram.cpp in Sources */, + F7CB86441EEDA0F50030C877 /* shortcut_keys.c in Sources */, F76C88871EC5324E00FA49E2 /* SwapFramebuffer.cpp in Sources */, F76C88881EC5324E00FA49E2 /* TextureCache.cpp in Sources */, F76C88891EC5324E00FA49E2 /* SoftwareDrawingEngine.cpp in Sources */, @@ -2961,6 +2994,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F7CB864E1EEDA2050030C877 /* DummyWindowManager.cpp in Sources */, F775F5381EE3725C001F00E7 /* DummyAudioContext.cpp in Sources */, F775F5351EE35A89001F00E7 /* DummyUiContext.cpp in Sources */, F7D7747B1EC5EB6D00BE6EBC /* lay_down_roller_coaster.c in Sources */, @@ -2978,7 +3012,6 @@ F76C85C41EC4E88300FA49E2 /* Config.cpp in Sources */, F76C85C71EC4E88300FA49E2 /* IniReader.cpp in Sources */, F76C85C91EC4E88300FA49E2 /* IniWriter.cpp in Sources */, - F76C85CB1EC4E88300FA49E2 /* KeyboardShortcuts.cpp in Sources */, F76C85CC1EC4E88300FA49E2 /* Context.cpp in Sources */, F76C85CF1EC4E88300FA49E2 /* Console.cpp in Sources */, F76C85D11EC4E88300FA49E2 /* Diagnostics.cpp in Sources */, @@ -3015,7 +3048,6 @@ F76C86131EC4E88300FA49E2 /* console.c in Sources */, F76C86161EC4E88300FA49E2 /* Fonts.cpp in Sources */, F76C86181EC4E88300FA49E2 /* graph.c in Sources */, - F76C861A1EC4E88300FA49E2 /* keyboard_shortcut.c in Sources */, F76C861E1EC4E88300FA49E2 /* Theme.cpp in Sources */, F76C86201EC4E88300FA49E2 /* viewport.c in Sources */, F76C86221EC4E88300FA49E2 /* viewport_interaction.c in Sources */, @@ -3255,8 +3287,6 @@ F76C87771EC4E88400FA49E2 /* scenery.c in Sources */, F76C87781EC4E88400FA49E2 /* server_list.cpp in Sources */, F76C87791EC4E88400FA49E2 /* server_start.c in Sources */, - F76C877A1EC4E88400FA49E2 /* shortcut_key_change.c in Sources */, - F76C877B1EC4E88400FA49E2 /* shortcut_keys.c in Sources */, F76C877C1EC4E88400FA49E2 /* sign.c in Sources */, F76C877D1EC4E88400FA49E2 /* staff.c in Sources */, F76C877E1EC4E88400FA49E2 /* staff_fire_prompt.c in Sources */,