From 670b879235a346b0206723029207a201f7bd0a25 Mon Sep 17 00:00:00 2001 From: Michiel Bos Date: Sun, 24 May 2020 18:44:00 +0200 Subject: [PATCH 1/6] Added a shortcut key for disabling/enabling clearance checks. --- data/language/en-GB.txt | 1 + distribution/changelog.txt | 1 + src/openrct2-ui/input/KeyboardShortcut.cpp | 8 ++++++++ src/openrct2-ui/input/KeyboardShortcuts.cpp | 1 + src/openrct2-ui/input/KeyboardShortcuts.h | 1 + src/openrct2-ui/windows/ShortcutKeys.cpp | 1 + src/openrct2/localisation/StringIds.h | 2 ++ 7 files changed, 15 insertions(+) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 9e00a17e5f..39e336cf57 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3667,6 +3667,7 @@ STR_6369 :Allow building track at invalid heights STR_6370 :{SMALLFONT}{BLACK}Allows placing track pieces at any height interval STR_6371 :The specified path contains a RollerCoaster Tycoon 1 installation, but the “csg1i.dat” file is missing. This file needs to be copied from the RollerCoaster Tycoon 1 CD to the “Data” folder of the RollerCoaster Tycoon 1 install on your hard drive. STR_6372 :The specified path contains a RollerCoaster Tycoon 1 installation, but this version is not suitable. OpenRCT2 needs a Loopy Landscapes or RCT Deluxe install in order to use RollerCoaster Tycoon 1 assets. +STR_6373 :Toggle clearance checks ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 4599892137..15889e08c2 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Feature: [#11231] Change shortcut window list order to be more intuitive, and split it into logical sections. - Feature: [#11306] Path additions are now kept when replacing the path. - Feature: [#11320] Support for custom JavaScript plugins. +- Feature: [#11422] Added a shortcut key for disabling/enabling clearance checks. - Feature: [#11788] Command to extract images from a .DAT file. - Change: [#11209] Warn when user is running OpenRCT2 through Wine. - Change: [#11358] Switch copy and paste button positions in tile inspector. diff --git a/src/openrct2-ui/input/KeyboardShortcut.cpp b/src/openrct2-ui/input/KeyboardShortcut.cpp index 8caafd2ccb..2f23f7e3b1 100644 --- a/src/openrct2-ui/input/KeyboardShortcut.cpp +++ b/src/openrct2-ui/input/KeyboardShortcut.cpp @@ -34,6 +34,7 @@ #include #include #include +#include extern bool gWindowSceneryEyedropperEnabled; @@ -1020,6 +1021,12 @@ static void shortcut_decrease_element_height() } } +static void shortcut_toggle_clearance_checks() +{ + auto setCheatAction = SetCheatAction(CheatType::DisableClearanceChecks, gCheatsDisableClearanceChecks == 0 ? 1 : 0); + GameActions::Execute(&setCheatAction); +} + namespace { const shortcut_action shortcut_table[SHORTCUT_COUNT] = { @@ -1109,6 +1116,7 @@ namespace shortcut_decrease_y_coord, shortcut_increase_element_height, shortcut_decrease_element_height, + shortcut_toggle_clearance_checks, }; } // anonymous namespace diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp index df3af380d9..455e882da6 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.cpp +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -371,4 +371,5 @@ const uint16_t KeyboardShortcuts::DefaultKeys[SHORTCUT_COUNT] = { SHORTCUT_UNDEFINED, // SHORTCUT_SCENERY_PICKER SHORTCUT_UNDEFINED, // SHORTCUT_SCALE_UP SHORTCUT_UNDEFINED, // SHORTCUT_SCALE_DOWN + SHORTCUT_UNDEFINED, // SHORTCUT_TOGGLE_CLEARANCE_CHECKS }; diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index 8499a2c205..8b56240417 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -111,6 +111,7 @@ enum KeyboardShortcut SHORTCUT_DECREASE_Y_COORD, SHORTCUT_INCREASE_ELEM_HEIGHT, SHORTCUT_DECREASE_ELEM_HEIGHT, + SHORTCUT_TOGGLE_CLEARANCE_CHECKS, SHORTCUT_COUNT, diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index ee187a1363..ac36ffcab6 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -204,6 +204,7 @@ static const ShortcutStringPair ShortcutList[] = { SHORTCUT_ADVANCE_TO_NEXT_TICK, STR_ADVANCE_TO_NEXT_TICK }, { SHORTCUT_PAINT_ORIGINAL_TOGGLE, STR_SHORTCUT_PAINT_ORIGINAL }, { SHORTCUT_DEBUG_PAINT_TOGGLE, STR_SHORTCUT_DEBUG_PAINT_TOGGLE }, + { SHORTCUT_TOGGLE_CLEARANCE_CHECKS, STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS }, }; // clang-format on diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 59392c8a1d..e802c1e297 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3906,6 +3906,8 @@ enum STR_PATH_TO_RCT1_DOES_NOT_CONTAIN_CSG1I_DAT = 6371, STR_PATH_TO_RCT1_IS_WRONG_VERSION = 6372, + STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS = 6373, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings }; From 67ffc5642b3b2a6c26fa9c246037826b6aa0389f Mon Sep 17 00:00:00 2001 From: Michiel Bos Date: Sun, 24 May 2020 19:29:03 +0200 Subject: [PATCH 2/6] Fixed the include order in KeyboardShortcut.cpp to match with clang. --- src/openrct2-ui/input/KeyboardShortcut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2-ui/input/KeyboardShortcut.cpp b/src/openrct2-ui/input/KeyboardShortcut.cpp index 2f23f7e3b1..657b0dd61e 100644 --- a/src/openrct2-ui/input/KeyboardShortcut.cpp +++ b/src/openrct2-ui/input/KeyboardShortcut.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include extern bool gWindowSceneryEyedropperEnabled; From 31e4029a22cefb65a5f8c9b47b544440e7268117 Mon Sep 17 00:00:00 2001 From: Michiel Bos Date: Sun, 24 May 2020 20:00:21 +0200 Subject: [PATCH 3/6] Moved 'Open cheat menu' and 'Toggle clearance checks' to new category --- src/openrct2-ui/windows/ShortcutKeys.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index ac36ffcab6..4bdc68a03e 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -102,7 +102,11 @@ static const ShortcutStringPair ShortcutList[] = { SHORTCUT_SHOW_OPTIONS, STR_SHORTCUT_SHOW_OPTIONS }, { SHORTCUT_SCREENSHOT, STR_SHORTCUT_SCREENSHOT }, { SHORTCUT_MUTE_SOUND, STR_SHORTCUT_MUTE_SOUND }, + + { SHORTCUT_UNDEFINED, STR_NONE }, + { SHORTCUT_OPEN_CHEAT_WINDOW, STR_SHORTCUT_OPEN_CHEATS_WINDOW }, + { SHORTCUT_TOGGLE_CLEARANCE_CHECKS, STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS }, { SHORTCUT_UNDEFINED, STR_NONE }, @@ -204,7 +208,6 @@ static const ShortcutStringPair ShortcutList[] = { SHORTCUT_ADVANCE_TO_NEXT_TICK, STR_ADVANCE_TO_NEXT_TICK }, { SHORTCUT_PAINT_ORIGINAL_TOGGLE, STR_SHORTCUT_PAINT_ORIGINAL }, { SHORTCUT_DEBUG_PAINT_TOGGLE, STR_SHORTCUT_DEBUG_PAINT_TOGGLE }, - { SHORTCUT_TOGGLE_CLEARANCE_CHECKS, STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS }, }; // clang-format on From 3fdab8e7d9563cf6d2a413109a4c869aba2ab57c Mon Sep 17 00:00:00 2001 From: Michiel Bos Date: Mon, 25 May 2020 20:18:39 +0200 Subject: [PATCH 4/6] Added icon to Cheats button to indicate clearance checks are disabled --- data/language/en-GB.txt | 1 + src/openrct2-ui/windows/TopToolbar.cpp | 7 +++++++ src/openrct2/actions/SetCheatAction.hpp | 2 ++ src/openrct2/localisation/StringIds.h | 1 + 4 files changed, 11 insertions(+) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 39e336cf57..87edb4cd9b 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3668,6 +3668,7 @@ STR_6370 :{SMALLFONT}{BLACK}Allows placing track pieces at any height interva STR_6371 :The specified path contains a RollerCoaster Tycoon 1 installation, but the “csg1i.dat” file is missing. This file needs to be copied from the RollerCoaster Tycoon 1 CD to the “Data” folder of the RollerCoaster Tycoon 1 install on your hard drive. STR_6372 :The specified path contains a RollerCoaster Tycoon 1 installation, but this version is not suitable. OpenRCT2 needs a Loopy Landscapes or RCT Deluxe install in order to use RollerCoaster Tycoon 1 assets. STR_6373 :Toggle clearance checks +STR_6374 :C ############# # Scenarios # diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 8722c53cb3..cae3a1f54f 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -887,6 +887,13 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) y++; imgId = SPR_G2_SANDBOX; gfx_draw_sprite(dpi, imgId, x, y, 3); + + // Draw an icon if clearance checks are disabled + if (gCheatsDisableClearanceChecks != 0) + { + gfx_draw_string_right( + dpi, STR_ICON_CLEARANCE_CHECKS_DISABLED, nullptr, COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, x + 26, y + 2); + } } // Draw chat button diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 474da7a9a5..1ecc9a8c49 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -104,6 +104,8 @@ public: break; case CheatType::DisableClearanceChecks: gCheatsDisableClearanceChecks = _param1 != 0; + // Required to update the clearance checks icon on the Cheats button. + window_invalidate_by_class(WC_TOP_TOOLBAR); break; case CheatType::DisableSupportLimits: gCheatsDisableSupportLimits = _param1 != 0; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index e802c1e297..3f6c0b2a84 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3907,6 +3907,7 @@ enum STR_PATH_TO_RCT1_IS_WRONG_VERSION = 6372, STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS = 6373, + STR_ICON_CLEARANCE_CHECKS_DISABLED = 6374, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings From ac8dce44fddbcc0d6958bd25cc3ea4e9d2c8851f Mon Sep 17 00:00:00 2001 From: Michiel Date: Sat, 30 May 2020 00:12:07 +0200 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Michael Steenbeek --- src/openrct2-ui/windows/TopToolbar.cpp | 4 ++-- src/openrct2/actions/SetCheatAction.hpp | 2 +- src/openrct2/localisation/StringIds.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index cae3a1f54f..8e53dddea3 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -888,11 +888,11 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) imgId = SPR_G2_SANDBOX; gfx_draw_sprite(dpi, imgId, x, y, 3); - // Draw an icon if clearance checks are disabled + // Draw an overlay if clearance checks are disabled if (gCheatsDisableClearanceChecks != 0) { gfx_draw_string_right( - dpi, STR_ICON_CLEARANCE_CHECKS_DISABLED, nullptr, COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, x + 26, y + 2); + dpi, STR_OVERLAY_CLEARANCE_CHECKS_DISABLED, nullptr, COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, x + 26, y + 2); } } diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 1ecc9a8c49..b9dd7e0730 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -104,7 +104,7 @@ public: break; case CheatType::DisableClearanceChecks: gCheatsDisableClearanceChecks = _param1 != 0; - // Required to update the clearance checks icon on the Cheats button. + // Required to update the clearance checks overlay on the Cheats button. window_invalidate_by_class(WC_TOP_TOOLBAR); break; case CheatType::DisableSupportLimits: diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 3f6c0b2a84..01f36cb1f7 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3907,7 +3907,7 @@ enum STR_PATH_TO_RCT1_IS_WRONG_VERSION = 6372, STR_SHORTCUT_TOGGLE_CLEARANCE_CHECKS = 6373, - STR_ICON_CLEARANCE_CHECKS_DISABLED = 6374, + STR_OVERLAY_CLEARANCE_CHECKS_DISABLED = 6374, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings From 6d13f7ba68fa2109981a38ccad530053be23c23b Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sat, 30 May 2020 11:59:54 +0200 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Aaron van Geffen --- src/openrct2-ui/input/KeyboardShortcut.cpp | 2 +- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/input/KeyboardShortcut.cpp b/src/openrct2-ui/input/KeyboardShortcut.cpp index 657b0dd61e..b2eff4bd3a 100644 --- a/src/openrct2-ui/input/KeyboardShortcut.cpp +++ b/src/openrct2-ui/input/KeyboardShortcut.cpp @@ -1023,7 +1023,7 @@ static void shortcut_decrease_element_height() static void shortcut_toggle_clearance_checks() { - auto setCheatAction = SetCheatAction(CheatType::DisableClearanceChecks, gCheatsDisableClearanceChecks == 0 ? 1 : 0); + auto setCheatAction = SetCheatAction(CheatType::DisableClearanceChecks, gCheatsDisableClearanceChecks ? 1 : 0); GameActions::Execute(&setCheatAction); } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 8e53dddea3..0eab43fa49 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -889,7 +889,7 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_draw_sprite(dpi, imgId, x, y, 3); // Draw an overlay if clearance checks are disabled - if (gCheatsDisableClearanceChecks != 0) + if (gCheatsDisableClearanceChecks) { gfx_draw_string_right( dpi, STR_OVERLAY_CLEARANCE_CHECKS_DISABLED, nullptr, COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, x + 26, y + 2);