From 37110f386d4d25e12238b41f34bcd617e68ad457 Mon Sep 17 00:00:00 2001 From: Kevin Strehl Date: Tue, 31 Dec 2019 02:34:38 -0600 Subject: [PATCH] Add Keyboard Shortcuts to the Tile Inspector (#10430) --- contributors.md | 1 + data/language/en-GB.txt | 12 ++ src/openrct2-ui/input/KeyboardShortcut.cpp | 216 +++++++++++++++++++++ src/openrct2-ui/input/KeyboardShortcuts.h | 12 ++ src/openrct2-ui/windows/ShortcutKeys.cpp | 12 ++ src/openrct2/interface/Window.h | 38 ++++ src/openrct2/localisation/StringIds.h | 13 ++ 7 files changed, 304 insertions(+) diff --git a/contributors.md b/contributors.md index b0d4753f72..33a0f890fb 100644 --- a/contributors.md +++ b/contributors.md @@ -78,6 +78,7 @@ The following people are not part of the development team, but have been contrib * Olivier Wervers (oli414) - Remove unused objects command, various bugfixes * Christian Schubert (Osmodium) - Ensuring custom user content folders, incl. open folder. * (Xkeeper0) - Improved banner tooltips; multiplayer status in toolbar. +* Kevin Strehl (bitman2049) - Tile inspector keybindings ## Bug fixes * (halfbro) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 66b8d7597b..b63c9995a4 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3654,6 +3654,18 @@ STR_6331 :Create Ducks STR_6332 :Remove Ducks STR_6333 :Increase scale factor STR_6334 :Decrease scale factor +STR_6335 :Tile Inspector: Insert corrupt element +STR_6336 :Tile Inspector: Copy element +STR_6337 :Tile Inspector: Paste element +STR_6338 :Tile Inspector: Delete element +STR_6339 :Tile Inspector: Move element up +STR_6340 :Tile Inspector: Move element down +STR_6341 :Tile Inspector: Increase X coordinate +STR_6342 :Tile Inspector: Decrease X coordinate +STR_6343 :Tile Inspector: Increase Y coordinate +STR_6344 :Tile Inspector: Decrease Y coordinate +STR_6345 :Tile Inspector: Increase element height +STR_6346 :Tile Inspector: Decrease element height ############# # Scenarios # diff --git a/src/openrct2-ui/input/KeyboardShortcut.cpp b/src/openrct2-ui/input/KeyboardShortcut.cpp index 7b5c3b2436..b0de33ad8d 100644 --- a/src/openrct2-ui/input/KeyboardShortcut.cpp +++ b/src/openrct2-ui/input/KeyboardShortcut.cpp @@ -201,6 +201,15 @@ static void shortcut_rotate_construction_object() window_event_mouse_up_call(w, WC_MAP__WIDX_ROTATE_90); return; } + + // Rotate selected element in tile inspector + w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE); + return; + } } static void shortcut_underground_view_toggle() @@ -814,6 +823,201 @@ static void shortcut_scale_down() context_update_cursor_scale(); } +// Tile inspector shortcuts +static void shortcut_insert_corrupt_element() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT); + return; + } +} + +static void shortcut_copy_element() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_COPY) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_COPY].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_COPY); + return; + } +} + +static void shortcut_paste_element() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE); + return; + } +} + +static void shortcut_remove_element() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE); + return; + } +} + +static void shortcut_move_element_up() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP); + return; + } +} + +static void shortcut_move_element_down() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN) + && w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN].type != WWT_EMPTY) + { + window_event_mouse_up_call(w, WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN); + return; + } +} + +static void shortcut_increase_x_coord() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE].type != WWT_EMPTY) + { + window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE); + return; + } +} + +static void shortcut_decrease_x_coord() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE].type != WWT_EMPTY) + { + window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE); + return; + } +} + +static void shortcut_increase_y_coord() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE].type != WWT_EMPTY) + { + window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE); + return; + } +} + +static void shortcut_decrease_y_coord() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr && !widget_is_disabled(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE) + && w->widgets[WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE].type != WWT_EMPTY) + { + window_event_mouse_down_call(w, WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE); + return; + } +} + +static void shortcut_increase_element_height() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr) + { + int action = -1; + switch (w->page) + { + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SURFACE: + action = WC_TILE_INSPECTOR__WIDX_SURFACE_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_PATH: + action = WC_TILE_INSPECTOR__WIDX_PATH_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_TRACK: + action = WC_TILE_INSPECTOR__WIDX_TRACK_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SCENERY: + action = WC_TILE_INSPECTOR__WIDX_SCENERY_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_ENTRANCE: + action = WC_TILE_INSPECTOR__WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_WALL: + action = WC_TILE_INSPECTOR__WIDX_WALL_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_LARGE_SCENERY: + action = WC_TILE_INSPECTOR__WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_BANNER: + action = WC_TILE_INSPECTOR__WIDX_BANNER_SPINNER_HEIGHT_INCREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_CORRUPT: + action = WC_TILE_INSPECTOR__WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE; + break; + } + if (action != -1 && !widget_is_disabled(w, action) && w->widgets[action].type != WWT_EMPTY) + window_event_mouse_down_call(w, action); + return; + } +} + +static void shortcut_decrease_element_height() +{ + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w != nullptr) + { + int action = -1; + switch (w->page) + { + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SURFACE: + action = WC_TILE_INSPECTOR__WIDX_SURFACE_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_PATH: + action = WC_TILE_INSPECTOR__WIDX_PATH_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_TRACK: + action = WC_TILE_INSPECTOR__WIDX_TRACK_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SCENERY: + action = WC_TILE_INSPECTOR__WIDX_SCENERY_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_ENTRANCE: + action = WC_TILE_INSPECTOR__WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_WALL: + action = WC_TILE_INSPECTOR__WIDX_WALL_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_LARGE_SCENERY: + action = WC_TILE_INSPECTOR__WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_BANNER: + action = WC_TILE_INSPECTOR__WIDX_BANNER_SPINNER_HEIGHT_DECREASE; + break; + case WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_CORRUPT: + action = WC_TILE_INSPECTOR__WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE; + break; + } + if (action != -1 && !widget_is_disabled(w, action) && w->widgets[action].type != WWT_EMPTY) + window_event_mouse_down_call(w, action); + return; + } +} + namespace { const shortcut_action shortcut_table[SHORTCUT_COUNT] = { @@ -891,6 +1095,18 @@ namespace shortcut_open_scenery_picker, shortcut_scale_up, shortcut_scale_down, + shortcut_insert_corrupt_element, + shortcut_copy_element, + shortcut_paste_element, + shortcut_remove_element, + shortcut_move_element_up, + shortcut_move_element_down, + shortcut_increase_x_coord, + shortcut_decrease_x_coord, + shortcut_increase_y_coord, + shortcut_decrease_y_coord, + shortcut_increase_element_height, + shortcut_decrease_element_height, }; } // anonymous namespace diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index 935ff2040f..0ce841a8b9 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -99,6 +99,18 @@ enum SHORTCUT_SCENERY_PICKER, SHORTCUT_SCALE_UP, SHORTCUT_SCALE_DOWN, + SHORTCUT_INSERT_CORRUPT_ELEMENT, + SHORTCUT_COPY_ELEMENT, + SHORTCUT_PASTE_ELEMENT, + SHORTCUT_REMOVE_ELEMENT, + SHORTCUT_MOVE_ELEMENT_UP, + SHORTCUT_MOVE_ELEMENT_DOWN, + SHORTCUT_INCREASE_X_COORD, + SHORTCUT_DECREASE_X_COORD, + SHORTCUT_INCREASE_Y_COORD, + SHORTCUT_DECREASE_Y_COORD, + SHORTCUT_INCREASE_ELEM_HEIGHT, + SHORTCUT_DECREASE_ELEM_HEIGHT, SHORTCUT_COUNT, diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index e306282f43..100cb505d5 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -153,6 +153,18 @@ const rct_string_id ShortcutStringIds[SHORTCUT_COUNT] = { STR_SHORTCUT_OPEN_SCENERY_PICKER, STR_SHORTCUT_SCALE_UP, STR_SHORTCUT_SCALE_DOWN, + STR_SHORTCUT_INSERT_CORRPUT_ELEMENT, + STR_SHORTCUT_COPY_ELEMENT, + STR_SHORTCUT_PASTE_ELEMENT, + STR_SHORTCUT_REMOVE_ELEMENT, + STR_SHORTCUT_MOVE_ELEMENT_UP, + STR_SHORTCUT_MOVE_ELEMENT_DOWN, + STR_SHORTCUT_INCREASE_X_COORD, + STR_SHORTCUT_DECREASE_X_COORD, + STR_SHORTCUT_INCREASE_Y_COORD, + STR_SHORTCUT_DECREASE_Y_COORD, + STR_SHORTCUT_INCREASE_ELEM_HEIGHT, + STR_SHORTCUT_DECREASE_ELEM_HEIGHT, }; // clang-format on diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 63a986e309..c6ba5e265e 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -500,6 +500,44 @@ enum #define WC_MAP__WIDX_ROTATE_90 20 #define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 21 #define WC_STAFF__WIDX_PICKUP 10 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE 14 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT 10 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_COPY 16 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE 17 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE 11 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_UP 12 +#define WC_TILE_INSPECTOR__WIDX_BUTTON_MOVE_DOWN 13 +#define WC_TILE_INSPECTOR__WIDX_SPINNER_X_INCREASE 5 +#define WC_TILE_INSPECTOR__WIDX_SPINNER_X_DECREASE 6 +#define WC_TILE_INSPECTOR__WIDX_SPINNER_Y_INCREASE 8 +#define WC_TILE_INSPECTOR__WIDX_SPINNER_Y_DECREASE 9 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SURFACE 1 +#define WC_TILE_INSPECTOR__WIDX_SURFACE_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_SURFACE_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_PATH 2 +#define WC_TILE_INSPECTOR__WIDX_PATH_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_PATH_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_TRACK 3 +#define WC_TILE_INSPECTOR__WIDX_TRACK_SPINNER_HEIGHT_INCREASE 27 +#define WC_TILE_INSPECTOR__WIDX_TRACK_SPINNER_HEIGHT_DECREASE 28 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_SCENERY 4 +#define WC_TILE_INSPECTOR__WIDX_SCENERY_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_SCENERY_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_ENTRANCE 5 +#define WC_TILE_INSPECTOR__WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_WALL 6 +#define WC_TILE_INSPECTOR__WIDX_WALL_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_WALL_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_LARGE_SCENERY 7 +#define WC_TILE_INSPECTOR__WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_BANNER 8 +#define WC_TILE_INSPECTOR__WIDX_BANNER_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_BANNER_SPINNER_HEIGHT_DECREASE 27 +#define WC_TILE_INSPECTOR__TILE_INSPECTOR_PAGE_CORRUPT 9 +#define WC_TILE_INSPECTOR__WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE 26 +#define WC_TILE_INSPECTOR__WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE 27 enum PROMPT_MODE { diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 2d8895187a..0ccbea9e66 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3878,6 +3878,19 @@ enum STR_REMOVE_DUCKS = 6332, STR_SHORTCUT_SCALE_UP = 6333, STR_SHORTCUT_SCALE_DOWN = 6334, + + STR_SHORTCUT_INSERT_CORRPUT_ELEMENT = 6335, + STR_SHORTCUT_COPY_ELEMENT = 6336, + STR_SHORTCUT_PASTE_ELEMENT = 6337, + STR_SHORTCUT_REMOVE_ELEMENT = 6338, + STR_SHORTCUT_MOVE_ELEMENT_UP = 6339, + STR_SHORTCUT_MOVE_ELEMENT_DOWN = 6340, + STR_SHORTCUT_INCREASE_X_COORD = 6341, + STR_SHORTCUT_DECREASE_X_COORD = 6342, + STR_SHORTCUT_INCREASE_Y_COORD = 6343, + STR_SHORTCUT_DECREASE_Y_COORD = 6344, + STR_SHORTCUT_INCREASE_ELEM_HEIGHT = 6345, + STR_SHORTCUT_DECREASE_ELEM_HEIGHT = 6346, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 };