mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 11:33:03 +01:00
Feature: Make ride construction shortcuts work for footpath too
This commit is contained in:
@@ -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::WindowRideConstructionTurnLeft, STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_LEFT, "NUMPAD 4", []() { ShortcutConstructionTurnLeft(); });
|
||||
RegisterShortcut(ShortcutId::WindowRideConstructionTurnRight, STR_SHORTCUT_RIDE_CONSTRUCTION_TURN_RIGHT, "NUMPAD 6", []() { ShortcutConstructionTurnRight(); });
|
||||
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::WindowRideConstructionSlopeDown, STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_DOWN, "NUMPAD 2", []() { ShortcutConstructionSlopeDown(); });
|
||||
RegisterShortcut(ShortcutId::WindowRideConstructionSlopeUp, STR_SHORTCUT_RIDE_CONSTRUCTION_SLOPE_UP, "NUMPAD 8", []() { ShortcutConstructionSlopeUp(); });
|
||||
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::WindowRideConstructionBuild, STR_SHORTCUT_RIDE_CONSTRUCTION_BUILD_CURRENT, "NUMPAD 0", []() { ShortcutConstructionBuildCurrent(); });
|
||||
RegisterShortcut(ShortcutId::WindowRideConstructionDemolish, STR_SHORTCUT_RIDE_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); });
|
||||
|
||||
@@ -1242,3 +1242,100 @@ 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);
|
||||
}
|
||||
|
||||
@@ -876,6 +876,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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user