diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 17ae1fe1fd..b776b0a1e3 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3293,18 +3293,18 @@ STR_6014 :Guests will only pay entrance tickets for rides and services.{NEWLI STR_6015 :Sloped STR_6016 :Modify Tile STR_6017 :Please slow down -STR_6018 :Ride construction - Turn left -STR_6019 :Ride construction - Turn right -STR_6020 :Ride construction - Use default track -STR_6021 :Ride construction - Slope down -STR_6022 :Ride construction - Slope up -STR_6023 :Ride construction - Toggle chain lift -STR_6024 :Ride construction - Bank left -STR_6025 :Ride construction - Bank right -STR_6026 :Ride construction - Previous track -STR_6027 :Ride construction - Next track -STR_6028 :Ride construction - Build current -STR_6029 :Ride construction - Demolish current +STR_6018 :Construction - Turn left +STR_6019 :Construction - Turn right +STR_6020 :Construction - Use default track +STR_6021 :Construction - Slope down +STR_6022 :Construction - Slope up +STR_6023 :Construction - Toggle chain lift +STR_6024 :Construction - Bank left +STR_6025 :Construction - Bank right +STR_6026 :Construction - Previous track +STR_6027 :Construction - Next track +STR_6028 :Construction - Build current +STR_6029 :Construction - Demolish current STR_6030 :Scenery picker. Click any scenery on the map to select the same piece for construction. STR_6031 :Server Description: STR_6032 :Server Greeting: diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 94d4104c01..c63ad504b0 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -20,6 +20,7 @@ - Feature: [#13675] [Plugin] Add context.setInterval and context.setTimeout. - Feature: [#13848] Replace shortcut engine allowing multiple bindings from different input devices. - Feature: [#13927] [Plugin] Add isVisible and text box widget. +- Feature: [#13965] Make ride construction shortcuts work for footpath, too. - Feature: [#13969] [Plugin] Add APIs for editing title sequences. - Feature: [#14002] [Plugin] Use allowed_hosts when checking the binding IP for listening. - Feature: [#14059] [Plugin] Add optional filter to custom tools. diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index ed0354c942..6f61b58bb6 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -609,6 +609,101 @@ static void ShortcutToggleConsole() } } +static void ShortcutConstructionTurnLeft() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_turn_left(); + } + else + { + window_ride_construction_keyboard_shortcut_turn_left(); + } +} + +static void ShortcutConstructionTurnRight() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_turn_right(); + } + else + { + window_ride_construction_keyboard_shortcut_turn_right(); + } +} + +static void ShortcutConstructionSlopeUp() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_slope_up(); + } + else + { + window_ride_construction_keyboard_shortcut_slope_up(); + } +} + +static void ShortcutConstructionBuildCurrent() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_build_current(); + } + else + { + window_ride_construction_keyboard_shortcut_build_current(); + } +} + +static void ShortcutConstructionSlopeDown() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_slope_down(); + } + else + { + window_ride_construction_keyboard_shortcut_slope_down(); + } +} + +static void ShortcutConstructionDemolishCurrent() +{ + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + + rct_window* window = window_find_by_class(WC_FOOTPATH); + if (window != nullptr) + { + window_footpath_keyboard_shortcut_demolish_current(); + } + else + { + window_ride_construction_keyboard_shortcut_demolish_current(); + } +} + #pragma endregion using namespace OpenRCT2::Ui; @@ -737,18 +832,18 @@ void ShortcutManager::RegisterDefaultShortcuts() RegisterShortcut(ShortcutId::ViewToggleGridlines, STR_SHORTCUT_GRIDLINES_DISPLAY_TOGGLE, "7", []() { ToggleViewFlag(VIEWPORT_FLAG_GRIDLINES); }); // Window - RegisterShortcut(ShortcutId::WindowRideConstructionTurnLeft, STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT, "NUMPAD 4", []() { window_ride_construction_keyboard_shortcut_turn_left(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionTurnRight, STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT, "NUMPAD 6", []() { window_ride_construction_keyboard_shortcut_turn_right(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionDefault, STR_SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT, "NUMPAD 5", []() { window_ride_construction_keyboard_shortcut_use_track_default(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionSlopeDown, STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN, "NUMPAD 2", []() { window_ride_construction_keyboard_shortcut_slope_down(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionSlopeUp, STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP, "NUMPAD 8", []() { window_ride_construction_keyboard_shortcut_slope_up(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionChainLift, STR_SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE, "NUMPAD +", []() { window_ride_construction_keyboard_shortcut_chain_lift_toggle(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionBankLeft, STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT, "NUMPAD 1", []() { window_ride_construction_keyboard_shortcut_bank_left(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionBankRight, STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT, "NUMPAD 3", []() { window_ride_construction_keyboard_shortcut_bank_right(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionPrevious, STR_SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK, "NUMPAD 7", []() { window_ride_construction_keyboard_shortcut_previous_track(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionNext, STR_SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK, "NUMPAD 9", []() { window_ride_construction_keyboard_shortcut_next_track(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionBuild, STR_SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT, "NUMPAD 0", []() { window_ride_construction_keyboard_shortcut_build_current(); }); - RegisterShortcut(ShortcutId::WindowRideConstructionDemolish, STR_SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT, "NUMPAD -", []() { window_ride_construction_keyboard_shortcut_demolish_current(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionTurnLeft, STR_SHORTCUT_CONSTRUCTION_TURN_LEFT, "NUMPAD 4", []() { ShortcutConstructionTurnLeft(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionTurnRight, STR_SHORTCUT_CONSTRUCTION_TURN_RIGHT, "NUMPAD 6", []() { ShortcutConstructionTurnRight(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionDefault, STR_SHORTCUT_CONSTRUCTION_USE_TRACK_DEFAULT, "NUMPAD 5", []() { window_ride_construction_keyboard_shortcut_use_track_default(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionSlopeDown, STR_SHORTCUT_CONSTRUCTION_SLOPE_DOWN, "NUMPAD 2", []() { ShortcutConstructionSlopeDown(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionSlopeUp, STR_SHORTCUT_CONSTRUCTION_SLOPE_UP, "NUMPAD 8", []() { ShortcutConstructionSlopeUp(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionChainLift, STR_SHORTCUT_CONSTRUCTION_CHAIN_LIFT_TOGGLE, "NUMPAD +", []() { window_ride_construction_keyboard_shortcut_chain_lift_toggle(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionBankLeft, STR_SHORTCUT_CONSTRUCTION_BANK_LEFT, "NUMPAD 1", []() { window_ride_construction_keyboard_shortcut_bank_left(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionBankRight, STR_SHORTCUT_CONSTRUCTION_BANK_RIGHT, "NUMPAD 3", []() { window_ride_construction_keyboard_shortcut_bank_right(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionPrevious, STR_SHORTCUT_CONSTRUCTION_PREVIOUS_TRACK, "NUMPAD 7", []() { window_ride_construction_keyboard_shortcut_previous_track(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionNext, STR_SHORTCUT_CONSTRUCTION_NEXT_TRACK, "NUMPAD 9", []() { window_ride_construction_keyboard_shortcut_next_track(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionBuild, STR_SHORTCUT_CONSTRUCTION_BUILD_CURRENT, "NUMPAD 0", []() { ShortcutConstructionBuildCurrent(); }); + RegisterShortcut(ShortcutId::WindowRideConstructionDemolish, STR_SHORTCUT_CONSTRUCTION_DEMOLISH_CURRENT, "NUMPAD -", []() { ShortcutConstructionDemolishCurrent(); }); RegisterShortcut(ShortcutId::WindowTileInspectorInsertCorrupt, STR_SHORTCUT_INSERT_CORRPUT_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_CORRUPT); }); RegisterShortcut(ShortcutId::WindowTileInspectorCopy, STR_SHORTCUT_COPY_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_COPY); }); diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 0225b2139a..1854c3e1e5 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1242,3 +1242,98 @@ static bool footpath_select_default() return true; } } + +void window_footpath_keyboard_shortcut_turn_left() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_DIRECTION_NW) || WidgetIsDisabled(w, WIDX_DIRECTION_NE) + || WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || gFootpathConstructionMode != 2) + { + return; + } + int32_t currentRotation = get_current_rotation(); + int32_t turnedRotation = gFootpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? 1 : -1); + window_footpath_mousedown_direction(turnedRotation); +} + +void window_footpath_keyboard_shortcut_turn_right() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_DIRECTION_NW) || WidgetIsDisabled(w, WIDX_DIRECTION_NE) + || WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || gFootpathConstructionMode != 2) + { + return; + } + int32_t currentRotation = get_current_rotation(); + int32_t turnedRotation = gFootpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? -1 : 1); + window_footpath_mousedown_direction(turnedRotation); +} + +void window_footpath_keyboard_shortcut_slope_down() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_SLOPEDOWN) || WidgetIsDisabled(w, WIDX_LEVEL) + || WidgetIsDisabled(w, WIDX_SLOPEUP) || w->widgets[WIDX_LEVEL].type == WindowWidgetType::Empty) + { + return; + } + + switch (gFootpathConstructSlope) + { + case 0: + window_event_mouse_down_call(w, WIDX_SLOPEDOWN); + break; + case 2: + window_event_mouse_down_call(w, WIDX_LEVEL); + break; + default: + case 6: + return; + } +} + +void window_footpath_keyboard_shortcut_slope_up() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_SLOPEDOWN) || WidgetIsDisabled(w, WIDX_LEVEL) + || WidgetIsDisabled(w, WIDX_SLOPEUP) || w->widgets[WIDX_LEVEL].type == WindowWidgetType::Empty) + { + return; + } + + switch (gFootpathConstructSlope) + { + case 6: + window_event_mouse_down_call(w, WIDX_LEVEL); + break; + case 0: + window_event_mouse_down_call(w, WIDX_SLOPEUP); + break; + default: + case 2: + return; + } +} + +void window_footpath_keyboard_shortcut_demolish_current() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_REMOVE) || w->widgets[WIDX_REMOVE].type == WindowWidgetType::Empty + || (!gCheatsBuildInPauseMode && game_is_paused())) + { + return; + } + + window_footpath_remove(); +} + +void window_footpath_keyboard_shortcut_build_current() +{ + rct_window* w = window_find_by_class(WC_FOOTPATH); + if (w == nullptr || WidgetIsDisabled(w, WIDX_CONSTRUCT) || w->widgets[WIDX_CONSTRUCT].type == WindowWidgetType::Empty) + { + return; + } + + window_event_mouse_up_call(w, WIDX_CONSTRUCT); +} diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index a83aadc053..22007500e6 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -877,6 +877,13 @@ void window_ride_construction_keyboard_shortcut_next_track(); void window_ride_construction_keyboard_shortcut_build_current(); void window_ride_construction_keyboard_shortcut_demolish_current(); +void window_footpath_keyboard_shortcut_turn_left(); +void window_footpath_keyboard_shortcut_turn_right(); +void window_footpath_keyboard_shortcut_slope_down(); +void window_footpath_keyboard_shortcut_slope_up(); +void window_footpath_keyboard_shortcut_build_current(); +void window_footpath_keyboard_shortcut_demolish_current(); + void window_follow_sprite(rct_window* w, size_t spriteIndex); void window_unfollow_sprite(rct_window* w); diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index e4945c0318..9098d866d9 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3426,18 +3426,18 @@ enum STR_TILE_INSPECTOR_PATH_SLOPED = 6015, STR_ACTION_MODIFY_TILE = 6016, STR_NETWORK_ACTION_RATE_LIMIT_MESSAGE = 6017, - STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT = 6018, - STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT = 6019, - STR_SHORTCUT_RIDE_CONSTRUCTION_USE_TRACK_DEFAULT = 6020, - STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN = 6021, - STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP = 6022, - STR_SHORTCUT_RIDE_CONSTRUCTION_CHAIN_LIFT_TOGGLE = 6023, - STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_LEFT = 6024, - STR_SHORTCUT_RIDE_CONSTRUCTION_BANK_RIGHT = 6025, - STR_SHORTCUT_RIDE_CONSTRUCTION_PREVIOUS_TRACK = 6026, - STR_SHORTCUT_RIDE_CONSTRUCTION_NEXT_TRACK = 6027, - STR_SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT = 6028, - STR_SHORTCUT_RIDE_CONSTRUCTION_DEMOLISH_CURRENT = 6029, + STR_SHORTCUT_CONSTRUCTION_TURN_LEFT = 6018, + STR_SHORTCUT_CONSTRUCTION_TURN_RIGHT = 6019, + STR_SHORTCUT_CONSTRUCTION_USE_TRACK_DEFAULT = 6020, + STR_SHORTCUT_CONSTRUCTION_SLOPE_DOWN = 6021, + STR_SHORTCUT_CONSTRUCTION_SLOPE_UP = 6022, + STR_SHORTCUT_CONSTRUCTION_CHAIN_LIFT_TOGGLE = 6023, + STR_SHORTCUT_CONSTRUCTION_BANK_LEFT = 6024, + STR_SHORTCUT_CONSTRUCTION_BANK_RIGHT = 6025, + STR_SHORTCUT_CONSTRUCTION_PREVIOUS_TRACK = 6026, + STR_SHORTCUT_CONSTRUCTION_NEXT_TRACK = 6027, + STR_SHORTCUT_CONSTRUCTION_BUILD_CURRENT = 6028, + STR_SHORTCUT_CONSTRUCTION_DEMOLISH_CURRENT = 6029, STR_SCENERY_EYEDROPPER_TIP = 6030,