diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index eed96334d6..6abe903f2e 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -501,6 +501,25 @@ static void TileInspectorMouseDown(rct_widgetindex widgetIndex) } } +static void ShortcutToggleVisibility() +{ + // TODO: Once the tile inspector window has its own class, move this to its own function + if (windowTileInspectorSelectedIndex < 0) + return; + + rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); + if (w == nullptr) + return; + + extern TileCoordsXY windowTileInspectorTile; + TileElement* tileElement = map_get_nth_element_at(windowTileInspectorTile.ToCoordsXY(), windowTileInspectorSelectedIndex); + if (tileElement != nullptr) + { + tileElement->SetInvisible(!tileElement->IsInvisible()); + w->Invalidate(); + } +} + static void ShortcutIncreaseElementHeight() { rct_window* w = window_find_by_class(WC_TILE_INSPECTOR); @@ -851,7 +870,7 @@ void ShortcutManager::RegisterDefaultShortcuts() RegisterShortcut(ShortcutId::WindowRideConstructionBuild, STR_SHORTCUT_CONSTRUCTION_BUILD_CURRENT, "NUMPAD 0", []() { ShortcutConstructionBuildCurrent(); }); RegisterShortcut(ShortcutId::WindowRideConstructionDemolish, STR_SHORTCUT_CONSTRUCTION_DEMOLISH_CURRENT, "NUMPAD -", []() { ShortcutConstructionDemolishCurrent(); }); - RegisterShortcut(ShortcutId::WindowTileInspectorToggleInvisibility, STR_SHORTCUT_TOGGLE_INVISIBILITY, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_TOGGLE_INVISIBILITY); }); + RegisterShortcut(ShortcutId::WindowTileInspectorToggleInvisibility, STR_SHORTCUT_TOGGLE_INVISIBILITY, []() { ShortcutToggleVisibility(); }); RegisterShortcut(ShortcutId::WindowTileInspectorCopy, STR_SHORTCUT_COPY_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_COPY); }); RegisterShortcut(ShortcutId::WindowTileInspectorPaste, STR_SHORTCUT_PASTE_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE); }); RegisterShortcut(ShortcutId::WindowTileInspectorRemove, STR_SHORTCUT_REMOVE_ELEMENT, []() { TileInspectorMouseUp(WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE); }); diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 5dab0c93fd..01c762c538 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -531,7 +531,6 @@ enum #define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 21 #define WC_STAFF__WIDX_PICKUP 9 #define WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE 13 -#define WC_TILE_INSPECTOR__WIDX_BUTTON_TOGGLE_INVISIBILITY 10 #define WC_TILE_INSPECTOR__WIDX_BUTTON_COPY 16 #define WC_TILE_INSPECTOR__WIDX_BUTTON_PASTE 15 #define WC_TILE_INSPECTOR__WIDX_BUTTON_REMOVE 10