1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Add more shortcuts

This commit is contained in:
Ted John
2020-12-13 14:29:10 +00:00
parent f009b9a804
commit 3339089235
3 changed files with 292 additions and 426 deletions

View File

@@ -79,82 +79,37 @@ void KeyboardShortcutHandleCommand(Input::Shortcut shortcut)
#pragma region Shortcut Commands
static void ToggleViewFlag(int32_t viewportFlag)
static void OpenWindow(rct_windowclass wc)
{
rct_window* window;
window = window_get_main();
if (window != nullptr)
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
window->viewport->flags ^= viewportFlag;
window->Invalidate();
context_open_window(wc);
}
}
static void ShortcutCloseTopMostWindow()
static void RotateCamera(int32_t direction)
{
window_close_top();
}
static void ShortcutCloseAllFloatingWindow()
{
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR))
window_close_all();
else if (gS6Info.editor_step == EditorStep::LandscapeEditor)
window_close_top();
}
static void ShortcutCancelConstructionMode()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* window = window_find_by_class(WC_ERROR);
if (window != nullptr)
window_close(window);
else if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
tool_cancel();
}
static void ShortcutPauseGame()
{
if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER)))
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
rct_window* window = window_find_by_class(WC_TOP_TOOLBAR);
auto window = window_get_main();
if (window != nullptr)
{
window->Invalidate();
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_PAUSE);
window_rotate_camera(window, direction);
}
}
}
static void ShortcutZoomViewOut()
static void ToggleViewFlag(int32_t viewportFlag)
{
main_window_zoom(false, false);
}
static void ShortcutZoomViewIn()
{
main_window_zoom(true, false);
}
static void ShortcutRotateViewClockwise()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* w = window_get_main();
window_rotate_camera(w, 1);
}
static void ShortcutRotateViewAnticlockwise()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* w = window_get_main();
window_rotate_camera(w, -1);
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
auto window = window_get_main();
if (window != nullptr)
{
window->viewport->flags ^= viewportFlag;
window->Invalidate();
}
}
}
static void ShortcutRotateConstructionObject()
@@ -221,30 +176,6 @@ static void ShortcutRotateConstructionObject()
}
}
static void ShortcutUndergroundViewToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_UNDERGROUND_INSIDE);
}
static void ShortcutRemoveBaseLandToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_HIDE_BASE);
}
static void ShortcutRemoveVerticalLandToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_HIDE_VERTICAL);
}
static void ShortcutRemoveTopBottomToolbarToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -287,78 +218,6 @@ static void ShortcutRemoveTopBottomToolbarToggle()
gfx_invalidate_screen();
}
static void ShortcutSeeThroughRidesToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_RIDES);
}
static void ShortcutSeeThroughSceneryToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_SCENERY);
}
static void ShortcutSeeThroughPathsToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_PATHS);
}
static void ShortcutInvisibleSupportsToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_SUPPORTS);
}
static void ShortcutInvisiblePeopleToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_PEEPS);
}
static void ShortcutGridlinesToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_GRIDLINES);
}
static void ShortcutHeightMarksOnLandToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_LAND_HEIGHTS);
}
static void ShortcutHeightMarksOnRideTracksToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_TRACK_HEIGHTS);
}
static void ShortcutHeightMarksOnPathsToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_PATH_HEIGHTS);
}
static void ShortcutAdjustLand()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -533,11 +392,6 @@ static void ShortcutShowMap()
context_open_window(WC_MAP);
}
static void ShortcutScreenshot()
{
gScreenshotCountdown = 2;
}
static void ShortcutReduceGameSpeed()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -590,14 +444,6 @@ static void ShortcutClearScenery()
}
}
static void ShortcutOpenChatWindow()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
chat_toggle();
}
static void ShortcutQuickSaveGame()
{
// Do a quick save in playing mode and a regular save in Scenario Editor mode. In other cases, don't do anything.
@@ -615,40 +461,6 @@ static void ShortcutQuickSaveGame()
}
}
static void ShortcutShowOptions()
{
context_open_window(WC_OPTIONS);
}
static void ShortcutMuteSound()
{
OpenRCT2::Audio::ToggleAllSounds();
}
static void ShortcutWindowsModeToggle()
{
platform_toggle_windowed_mode();
}
static void ShortcutShowMultiplayer()
{
if (network_get_mode() != NETWORK_MODE_NONE)
context_open_window(WC_MULTIPLAYER);
}
static void ShortcutDebugPaintToggle()
{
rct_window* window = window_find_by_class(WC_DEBUG_PAINT);
if (window != nullptr)
{
window_close(window);
}
else
{
context_open_window(WC_DEBUG_PAINT);
}
}
static void ShortcutRideConstructionTurnLeft()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -754,38 +566,6 @@ static void ShortcutLoadGame()
}
}
static void ShortcutViewClipping()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
context_open_window(WC_VIEW_CLIPPING);
}
static void ShortcutHighlightPathIssuesToggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
ToggleViewFlag(VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES);
}
static void ShortcutOpenTileInspector()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO || !gConfigInterface.toolbar_show_cheats)
return;
context_open_window(WC_TILE_INSPECTOR);
}
static void ShortcutAdvanceToNextTick()
{
if (gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER))
return;
gDoSingleUpdate = true;
}
static void ShortcutOpenSceneryPicker()
{
if ((gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
@@ -833,113 +613,21 @@ static void ShortcutScaleDown()
}
// Tile inspector shortcuts
static void ShortcutInsertCorruptElement()
static void TileInspectorMouseUp(rct_widgetindex widgetIndex)
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT].type != WindowWidgetType::Empty)
auto w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, widgetIndex) && w->widgets[widgetIndex].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT);
return;
window_event_mouse_up_call(w, widgetIndex);
}
}
static void ShortcutCopyElement()
static void TileInspectorMouseDown(rct_widgetindex widgetIndex)
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_COPY)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_COPY].type != WindowWidgetType::Empty)
auto w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, widgetIndex) && w->widgets[widgetIndex].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_COPY);
return;
}
}
static void ShortcutPasteElement()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE);
return;
}
}
static void ShortcutRemoveElement()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE);
return;
}
}
static void ShortcutMoveElementUp()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP);
return;
}
}
static void ShortcutMoveElementDown()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN].type != WindowWidgetType::Empty)
{
window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN);
return;
}
}
static void ShortcutIncreaseXCoord()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE].type != WindowWidgetType::Empty)
{
window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE);
return;
}
}
static void ShortcutDecreaseXCoord()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE].type != WindowWidgetType::Empty)
{
window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE);
return;
}
}
static void ShortcutIncreaseYCoord()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE].type != WindowWidgetType::Empty)
{
window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE);
return;
}
}
static void ShortcutDecreaseYCoord()
{
rct_window* w = window_find_by_class(WC_TILE_INSPECTOR);
if (w != nullptr && !WidgetIsDisabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE].type != WindowWidgetType::Empty)
{
window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE);
return;
window_event_mouse_down_call(w, widgetIndex);
}
}
@@ -1041,25 +729,6 @@ namespace
{
using namespace OpenRCT2::Input;
const shortcut_action shortcut_table[ShortcutsCount] = {
ShortcutCloseTopMostWindow,
ShortcutCloseAllFloatingWindow,
ShortcutCancelConstructionMode,
ShortcutPauseGame,
ShortcutZoomViewOut,
ShortcutZoomViewIn,
ShortcutRotateViewClockwise,
ShortcutRotateViewAnticlockwise,
ShortcutRotateConstructionObject,
ShortcutUndergroundViewToggle,
ShortcutRemoveBaseLandToggle,
ShortcutRemoveVerticalLandToggle,
ShortcutSeeThroughRidesToggle,
ShortcutSeeThroughSceneryToggle,
ShortcutInvisibleSupportsToggle,
ShortcutInvisiblePeopleToggle,
ShortcutHeightMarksOnLandToggle,
ShortcutHeightMarksOnRideTracksToggle,
ShortcutHeightMarksOnPathsToggle,
ShortcutAdjustLand,
ShortcutAdjustWater,
ShortcutBuildScenery,
@@ -1073,7 +742,6 @@ namespace
ShortcutShowStaffList,
ShortcutShowRecentMessages,
ShortcutShowMap,
ShortcutScreenshot,
// new
ShortcutReduceGameSpeed,
@@ -1084,15 +752,8 @@ namespace
nullptr,
nullptr,
nullptr,
ShortcutOpenChatWindow,
ShortcutQuickSaveGame,
ShortcutShowOptions,
ShortcutMuteSound,
ShortcutWindowsModeToggle,
ShortcutShowMultiplayer,
nullptr,
ShortcutDebugPaintToggle,
ShortcutSeeThroughPathsToggle,
ShortcutRideConstructionTurnLeft,
ShortcutRideConstructionTurnRight,
ShortcutRideConstructionUseTrackDefault,
@@ -1107,24 +768,9 @@ namespace
ShortcutRideConstructionDemolishCurrent,
ShortcutLoadGame,
ShortcutClearScenery,
ShortcutGridlinesToggle,
ShortcutViewClipping,
ShortcutHighlightPathIssuesToggle,
ShortcutOpenTileInspector,
ShortcutAdvanceToNextTick,
ShortcutOpenSceneryPicker,
ShortcutScaleUp,
ShortcutScaleDown,
ShortcutInsertCorruptElement,
ShortcutCopyElement,
ShortcutPasteElement,
ShortcutRemoveElement,
ShortcutMoveElementUp,
ShortcutMoveElementDown,
ShortcutIncreaseXCoord,
ShortcutDecreaseXCoord,
ShortcutIncreaseYCoord,
ShortcutDecreaseYCoord,
ShortcutIncreaseElementHeight,
ShortcutDecreaseElementHeight,
ShortcutToggleClearanceChecks,
@@ -1138,62 +784,202 @@ using namespace OpenRCT2::Ui;
void ShortcutManager::RegisterDefaultShortcuts()
{
// clang-format off
RegisterShortcut(RegisteredShortcut("interface.close_top", STR_SHORTCUT_CLOSE_TOP_MOST_WINDOW, "BACKSPACE", []() { window_close_top(); }));
RegisterShortcut(RegisteredShortcut("interface.close_all", STR_SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS, "SHIFT+BACKSPACE", []() {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR))
window_close_all();
else if (gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
window_close_top();
}));
RegisterShortcut(RegisteredShortcut("interface.cancel_construction", STR_SHORTCUT_CANCEL_CONSTRUCTION_MODE, "ESCAPE", []() {
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* window = window_find_by_class(WC_ERROR);
if (window != nullptr)
window_close(window);
else if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
tool_cancel();
}));
RegisterShortcut(RegisteredShortcut("interface.pause", STR_SHORTCUT_PAUSE_GAME, "PAUSE", []() {
// Interface 0
RegisterShortcut("interface0.close_top", STR_SHORTCUT_CLOSE_TOP_MOST_WINDOW, "BACKSPACE", []() { window_close_top(); });
RegisterShortcut("interface0.close_all", STR_SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS, "SHIFT+BACKSPACE", []() {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR))
{
window_close_all();
}
else if (gS6Info.editor_step == EditorStep::LandscapeEditor)
{
window_close_top();
}
});
RegisterShortcut("interface0.cancel_construction", STR_SHORTCUT_CANCEL_CONSTRUCTION_MODE, "ESCAPE", []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
auto window = window_find_by_class(WC_ERROR);
if (window != nullptr)
{
window_close(window);
}
else if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
{
tool_cancel();
}
}
});
RegisterShortcut("interface0.toggle_toolbars", STR_SHORTCUT_TOGGLE_VISIBILITY_OF_TOOLBARS, "T", []() {
ShortcutRemoveTopBottomToolbarToggle();
});
// Interface 1
RegisterShortcut("interface1.pause", STR_SHORTCUT_PAUSE_GAME, "PAUSE", []() {
if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window* window = window_find_by_class(WC_TOP_TOOLBAR);
auto window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != nullptr)
{
window->Invalidate();
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_PAUSE);
}
}
}));
RegisterShortcut(RegisteredShortcut("interface.zoom_out", STR_SHORTCUT_ZOOM_VIEW_OUT, "PAGEUP", []() {
main_window_zoom(false, false);
}));
RegisterShortcut(RegisteredShortcut("interface.zoom_in", STR_SHORTCUT_ZOOM_VIEW_IN, "PAGEDOWN", []() {
main_window_zoom(true, false);
}));
RegisterShortcut(RegisteredShortcut("interface.rotate_clockwise", STR_SHORTCUT_ROTATE_VIEW_CLOCKWISE, "RETURN", "MOUSE:5", []() {
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
});
RegisterShortcut("interface1.decrease_speed", STR_SHORTCUT_REDUCE_GAME_SPEED , "-", []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && network_get_mode() == NETWORK_MODE_NONE)
{
game_reduce_game_speed();
}
});
RegisterShortcut("interface1.increase_speed", STR_SHORTCUT_INCREASE_GAME_SPEED , "=", []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && network_get_mode() == NETWORK_MODE_NONE)
{
game_increase_game_speed();
}
});
RegisterShortcut("interface1.load_game", STR_LOAD_GAME, "CTRL+L", []() {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::OpenSavePrompt);
GameActions::Execute(&loadOrQuitAction);
}
});
RegisterShortcut("interface1.save_game", STR_LOAD_GAME, "CTRL+F10", []() { ShortcutQuickSaveGame(); });
RegisterShortcut("interface1.show_options", STR_SHORTCUT_SHOW_OPTIONS, []() { context_open_window(WC_OPTIONS); });
RegisterShortcut("interface1.screenshot", STR_SHORTCUT_SCREENSHOT, "CTRL+S", []() { gScreenshotCountdown = 2; });
RegisterShortcut("interface1.mute", STR_SHORTCUT_MUTE_SOUND, []() { OpenRCT2::Audio::ToggleAllSounds(); });
rct_window* w = window_get_main();
window_rotate_camera(w, 1);
}));
RegisterShortcut(RegisteredShortcut("interface.rotate_anticlockwise", STR_SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE, "SHIFT+RETURN", "MOUSE:4", []() {
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
// Interface 2
RegisterShortcut("interface2.open_cheats", STR_SHORTCUT_OPEN_CHEATS_WINDOW, "CTRL+ALT+C", []() { OpenWindow(WC_CHEATS); });
RegisterShortcut("interface2.disable_clearance", STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS, []() { ShortcutToggleClearanceChecks(); });
rct_window* w = window_get_main();
window_rotate_camera(w, -1);
}));
RegisterShortcut(RegisteredShortcut("interface.rotate_construction", STR_SHORTCUT_ROTATE_CONSTRUCTION_OBJECT, "Z", []() {
ShortcutRotateConstructionObject();
}));
RegisterShortcut(RegisteredShortcut("view.underground_view_toggle", STR_SHORTCUT_UNDERGROUND_VIEW_TOGGLE, "1", []() {
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
// Interface 3
RegisterShortcut("interface3.zoom_out", STR_SHORTCUT_ZOOM_VIEW_OUT, "PAGEUP", []() { main_window_zoom(false, false); });
RegisterShortcut("interface3.zoom_in", STR_SHORTCUT_ZOOM_VIEW_IN, "PAGEDOWN", []() { main_window_zoom(true, false); });
RegisterShortcut("interface3.rotate_clockwise", STR_SHORTCUT_ROTATE_VIEW_CLOCKWISE, "RETURN", "MOUSE:5", []() { RotateCamera(1); });
RegisterShortcut("interface3.rotate_anticlockwise", STR_SHORTCUT_ROTATE_VIEW_ANTICLOCKWISE, "SHIFT+RETURN", "MOUSE:4", []() { RotateCamera(-1); });
RegisterShortcut("interface3.show_map", STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS, "TAB", []() { ShortcutShowMap(); });
ToggleViewFlag(VIEWPORT_FLAG_UNDERGROUND_INSIDE);
}));
// Interface 4
RegisterShortcut("interface4.clear_scenery", STR_SHORTCUT_CLEAR_SCENERY, "B", []() { ShortcutClearScenery(); });
RegisterShortcut("interface4.adjust_land", STR_SHORTCUT_ADJUST_LAND, "F1", []() { ShortcutAdjustLand(); });
RegisterShortcut("interface4.adjust_water", STR_SHORTCUT_ADJUST_WATER, "F2", []() { ShortcutAdjustWater(); });
RegisterShortcut("interface4.build_scenery", STR_SHORTCUT_BUILD_SCENERY, "F3", []() { ShortcutBuildScenery(); });
RegisterShortcut("interface4.build_footpaths", STR_SHORTCUT_BUILD_PATHS, "F4", []() { ShortcutBuildPaths(); });
RegisterShortcut("interface4.build_new_ride", STR_SHORTCUT_BUILD_NEW_RIDE, "F5", []() { ShortcutBuildNewRide(); });
// Interface 5
RegisterShortcut("interface5.show_finances", STR_SHORTCUT_SHOW_FINANCIAL_INFORMATION, "F", []() { OpenWindow(WC_FINANCES); });
RegisterShortcut("interface5.show_research", STR_SHORTCUT_SHOW_RESEARCH_INFORMATION, "D", []() { OpenWindow(WC_RESEARCH); });
RegisterShortcut("interface5.show_rides", STR_SHORTCUT_SHOW_RIDES_LIST, "R", []() { OpenWindow(WC_RIDE_LIST); });
RegisterShortcut("interface5.show_park", STR_SHORTCUT_SHOW_PARK_INFORMATION, "P", []() { OpenWindow(WC_PARK_INFORMATION); });
RegisterShortcut("interface5.show_guests", STR_SHORTCUT_SHOW_GUEST_LIST, "G", []() { OpenWindow(WC_GUEST_LIST); });
RegisterShortcut("interface5.show_staff", STR_SHORTCUT_SHOW_STAFF_LIST, "S", []() { OpenWindow(WC_STAFF_LIST); });
RegisterShortcut("interface5.show_messages", STR_SHORTCUT_SHOW_RECENT_MESSAGES, "M", []() { OpenWindow(WC_RECENT_NEWS); });
// Multiplayer
RegisterShortcut("multiplayer.show", STR_SHORTCUT_SHOW_MULTIPLAYER, []() {
if (network_get_mode() != NETWORK_MODE_NONE)
{
OpenWindow(WC_MULTIPLAYER);
}
});
RegisterShortcut("multiplayer.chat", STR_SEND_MESSAGE, "C", []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
chat_toggle();
}
});
// View
RegisterShortcut("view.show_underground", STR_SHORTCUT_UNDERGROUND_VIEW_TOGGLE, "1", []() { ToggleViewFlag(VIEWPORT_FLAG_UNDERGROUND_INSIDE); });
RegisterShortcut("view.hide_base_land", STR_SHORTCUT_REMOVE_BASE_LAND_TOGGLE, "H", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_BASE); });
RegisterShortcut("view.hide_vertical_land", STR_SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE, "V", []() { ToggleViewFlag(VIEWPORT_FLAG_HIDE_BASE); });
RegisterShortcut("view.transparent_rides", STR_SHORTCUT_SEE_THROUGH_RIDES_TOGGLE, "3", []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_RIDES); });
RegisterShortcut("view.transparent_scenery", STR_SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE, "4", []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_SCENERY); });
RegisterShortcut("view.transparent_scenery", STR_SHORTCUT_SEE_THROUGH_PATHS_TOGGLE, []() { ToggleViewFlag(VIEWPORT_FLAG_SEETHROUGH_PATHS); });
RegisterShortcut("view.hide_supports", STR_SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE, "5", []() { ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_SUPPORTS); });
RegisterShortcut("view.hide_peeps", STR_SHORTCUT_INVISIBLE_PEOPLE_TOGGLE, "6", []() { ToggleViewFlag(VIEWPORT_FLAG_INVISIBLE_PEEPS); });
RegisterShortcut("view.show_land_height", STR_SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE, "8", []() { ToggleViewFlag(VIEWPORT_FLAG_LAND_HEIGHTS); });
RegisterShortcut("view.show_track_height", STR_SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE, "9", []() { ToggleViewFlag(VIEWPORT_FLAG_TRACK_HEIGHTS); });
RegisterShortcut("view.show_footpath_height", STR_SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE, "0", []() { ToggleViewFlag(VIEWPORT_FLAG_PATH_HEIGHTS); });
RegisterShortcut("view.toggle_cut_away", STR_SHORTCUT_VIEW_CLIPPING, []() { OpenWindow(WC_VIEW_CLIPPING); });
RegisterShortcut("view.highlight_path_issues", STR_SHORTCUT_HIGHLIGHT_PATH_ISSUES_TOGGLE, "I", []() { ToggleViewFlag(VIEWPORT_FLAG_PATH_HEIGHTS); });
RegisterShortcut("view.show_gridlines", STR_SHORTCUT_GRIDLINES_DISPLAY_TOGGLE, "7", []() { ToggleViewFlag(VIEWPORT_FLAG_GRIDLINES); });
// Interface 6
RegisterShortcut("interface6.open_scenery", STR_SHORTCUT_OPEN_SCENERY_PICKER, []() { ShortcutBuildScenery(); });
RegisterShortcut("interface6.rotate_construction", STR_SHORTCUT_ROTATE_CONSTRUCTION_OBJECT, "Z", []() { ShortcutRotateConstructionObject(); });
// Ride construction
// Map scrolling
RegisterShortcut("scroll.up", STR_SHORTCUT_SCROLL_MAP_UP, "UP", []() { });
RegisterShortcut("scroll.left", STR_SHORTCUT_SCROLL_MAP_LEFT, "LEFT", []() { });
RegisterShortcut("scroll.right", STR_SHORTCUT_SCROLL_MAP_RIGHT, "RIGHT", []() { });
RegisterShortcut("scroll.down", STR_SHORTCUT_SCROLL_MAP_DOWN, "DOWN", []() { });
// Window scale
RegisterShortcut("scale.toggle_window_mode", STR_SHORTCUT_WINDOWED_MODE_TOGGLE, "ALT+RETURN", []() { platform_toggle_windowed_mode(); });
RegisterShortcut("scale.increase", STR_SHORTCUT_SCALE_UP, []() { ShortcutScaleUp(); });
RegisterShortcut("scale.decrease", STR_SHORTCUT_SCALE_DOWN, []() { ShortcutScaleDown(); });
// Ride construction
RegisterShortcut("rideconstruction.turn_left", STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT, "KEYPAD 4", []() { window_ride_construction_keyboard_shortcut_turn_left(); });
RegisterShortcut("rideconstruction.turn_right", STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT, "KEYPAD 6", []() { window_ride_construction_keyboard_shortcut_turn_right(); });
RegisterShortcut("rideconstruction.default", STR_SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT, "KEYPAD 5", []() { window_ride_construction_keyboard_shortcut_use_track_default(); });
RegisterShortcut("rideconstruction.slope_down", STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN, "KEYPAD 2", []() { window_ride_construction_keyboard_shortcut_slope_down(); });
RegisterShortcut("rideconstruction.slope_up", STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP, "KEYPAD 8", []() { window_ride_construction_keyboard_shortcut_slope_up(); });
RegisterShortcut("rideconstruction.chain_lift", STR_SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE, "KEYPAD +", []() { window_ride_construction_keyboard_shortcut_chain_lift_toggle(); });
RegisterShortcut("rideconstruction.bank_left", STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT, "KEYPAD 1", []() { window_ride_construction_keyboard_shortcut_bank_left(); });
RegisterShortcut("rideconstruction.bank_right", STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT, "KEYPAD 3", []() { window_ride_construction_keyboard_shortcut_bank_right(); });
RegisterShortcut("rideconstruction.previous", STR_SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK, "KEYPAD 7", []() { window_ride_construction_keyboard_shortcut_previous_track(); });
RegisterShortcut("rideconstruction.next", STR_SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK, "KEYPAD 9", []() { window_ride_construction_keyboard_shortcut_next_track(); });
RegisterShortcut("rideconstruction.build", STR_SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT, "KEYPAD 0", []() { window_ride_construction_keyboard_shortcut_build_current(); });
RegisterShortcut("rideconstruction.demolish", STR_SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT, "KEYPAD -", []() { window_ride_construction_keyboard_shortcut_demolish_current(); });
// Tile inspector
RegisterShortcut("tileinspector.open", STR_SHORTCUT_OPEN_TILE_INSPECTOR, []() {
if (gConfigInterface.toolbar_show_cheats)
{
OpenWindow(WC_TILE_INSPECTOR);
}
});
RegisterShortcut("tileinspector.insert_corrupt", STR_SHORTCUT_INSERT_CORRPUT_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT); });
RegisterShortcut("tileinspector.copy", STR_SHORTCUT_COPY_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_COPY); });
RegisterShortcut("tileinspector.paste", STR_SHORTCUT_PASTE_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE); });
RegisterShortcut("tileinspector.remove", STR_SHORTCUT_REMOVE_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE); });
RegisterShortcut("tileinspector.move_up", STR_SHORTCUT_MOVE_ELEMENT_UP, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP); });
RegisterShortcut("tileinspector.move_down", STR_SHORTCUT_MOVE_ELEMENT_DOWN, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN); });
RegisterShortcut("tileinspector.increase_x", STR_SHORTCUT_INCREASE_X_COORD, []() { TileInspectorMouseDown(WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE); });
RegisterShortcut("tileinspector.decrease_x", STR_SHORTCUT_DECREASE_X_COORD, []() { TileInspectorMouseDown(WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE); });
RegisterShortcut("tileinspector.increase_y", STR_SHORTCUT_INCREASE_Y_COORD, []() { TileInspectorMouseDown(WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE); });
RegisterShortcut("tileinspector.decrease_y", STR_SHORTCUT_DECREASE_Y_COORD, []() { TileInspectorMouseDown(WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE); });
RegisterShortcut("tileinspector.increase_height", STR_SHORTCUT_INCREASE_ELEM_HEIGHT, []() { ShortcutIncreaseElementHeight(); });
RegisterShortcut("tileinspector.decrease_height", STR_SHORTCUT_DECREASE_ELEM_HEIGHT, []() { ShortcutDecreaseElementHeight(); });
// Debug
RegisterShortcut("debug.advance_tick", STR_ADVANCE_TO_NEXT_TICK, []() {
if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER)))
{
gDoSingleUpdate = true;
}
});
RegisterShortcut("debug.toggle_paint_debug_window", STR_SHORTCUT_DEBUG_PAINT_TOGGLE, []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
auto window = window_find_by_class(WC_DEBUG_PAINT);
if (window != nullptr)
{
window_close(window);
}
else
{
context_open_window(WC_DEBUG_PAINT);
}
}
});
// clang-format on
}

View File

@@ -84,18 +84,36 @@ static uint32_t ParseKey(const std::string_view& text)
return 0;
}
size_t FindPlus(std::string_view s, size_t index)
{
while (true)
{
index = s.find('+', index);
if (index != std::string::npos && index != 0 && s[index - 1] == ' ')
{
index++;
continue;
}
else
{
break;
}
}
return index;
}
ShortcutInput::ShortcutInput(const std::string_view& value)
{
uint32_t modifiers = 0;
size_t index = 0;
auto sepIndex = value.find('+', index);
auto sepIndex = FindPlus(value, index);
while (sepIndex != std::string::npos)
{
auto text = value.substr(index, sepIndex);
auto mod = ParseModifier(text);
modifiers |= mod;
index = sepIndex + 1;
sepIndex = value.find('+', index);
sepIndex = FindPlus(value, index);
}
auto kind = ShortcutInputKind::Keyboard;
@@ -156,6 +174,56 @@ std::string ShortcutInput::ToString() const
case SDLK_PAGEDOWN:
result += "PAGE DOWN";
break;
case SDLK_KP_DIVIDE:
result += "NUMPAD /";
break;
case SDLK_KP_MULTIPLY:
result += "NUMPAD *";
break;
case SDLK_KP_MINUS:
result += "NUMPAD -";
break;
case SDLK_KP_PLUS:
result += "NUMPAD +";
break;
case SDLK_KP_ENTER:
result += "NUMPAD RETURN";
break;
case SDLK_KP_1:
result += "NUMPAD 1";
break;
case SDLK_KP_2:
result += "NUMPAD 2";
break;
case SDLK_KP_3:
result += "NUMPAD 3";
break;
case SDLK_KP_4:
result += "NUMPAD 4";
break;
case SDLK_KP_5:
result += "NUMPAD 5";
break;
case SDLK_KP_6:
result += "NUMPAD 6";
break;
case SDLK_KP_7:
result += "NUMPAD 7";
break;
case SDLK_KP_8:
result += "NUMPAD 8";
break;
case SDLK_KP_9:
result += "NUMPAD 9";
break;
case SDLK_KP_0:
result += "NUMPAD 0";
break;
case SDLK_KP_PERIOD:
result += "NUMPAD .";
break;
default:
if (Key & SDLK_SCANCODE_MASK)
{

View File

@@ -17,6 +17,7 @@
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace OpenRCT2::Ui
@@ -56,6 +57,13 @@ namespace OpenRCT2::Ui
std::function<void()> Action;
RegisteredShortcut() = default;
RegisteredShortcut(const std::string_view& id, rct_string_id localisedName, const std::function<void()>& action)
: Id(id)
, LocalisedName(localisedName)
, Action(action)
{
}
RegisteredShortcut(
const std::string_view& id, rct_string_id localisedName, const std::string_view& defaultChord,
const std::function<void()>& action)
@@ -97,6 +105,10 @@ namespace OpenRCT2::Ui
ShortcutManager(const ShortcutManager&) = delete;
void RegisterShortcut(RegisteredShortcut&& shortcut);
template<typename... Args> void RegisterShortcut(Args&&... args)
{
RegisterShortcut(RegisteredShortcut(std::forward<Args>(args)...));
}
void RegisterDefaultShortcuts();
RegisteredShortcut* GetShortcut(std::string_view id);
void SetPendingShortcutChange(std::string_view id);