From 77a36a48bbaf2f87428d8890b213834211c0ef07 Mon Sep 17 00:00:00 2001 From: Trevor Finney <8711258+finneyt@users.noreply.github.com> Date: Mon, 20 Feb 2023 13:02:12 -0500 Subject: [PATCH] Set up new cheat for special colors --- data/language/en-GB.txt | 2 ++ src/openrct2-ui/windows/Cheats.cpp | 8 +++++++- src/openrct2-ui/windows/Dropdown.cpp | 4 +++- src/openrct2/Cheats.cpp | 8 ++++++++ src/openrct2/Cheats.h | 2 ++ src/openrct2/actions/CheatSetAction.cpp | 3 +++ src/openrct2/interface/Colour.h | 1 + src/openrct2/localisation/StringIds.h | 2 ++ src/openrct2/scripting/bindings/game/ScCheats.hpp | 14 ++++++++++++++ 9 files changed, 42 insertions(+), 2 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 6c12b48fa4..594049de41 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3677,6 +3677,8 @@ STR_6571 :Umber STR_6572 :Beige STR_6573 :Invisible STR_6574 :Void +STR_6575 :Allow special color schemes +STR_6576 :Adds special colors to color dropdown ############# # Scenarios # diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index 39a1280e9a..5edbbfa11b 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -153,6 +153,7 @@ enum WindowCheatsWidgetIdx WIDX_STAFF_SPEED_DROPDOWN_BUTTON, WIDX_PARK_CONSTRUCTION_GROUP, WIDX_ALLOW_REGULAR_PATH_AS_QUEUE, + WIDX_ALLOW_SPECIAL_COLOR_SCHEMES, WIDX_FIX_ALL = WIDX_TAB_CONTENT, WIDX_RENEW_RIDES, @@ -287,8 +288,9 @@ static Widget window_cheats_misc_widgets[] = MakeWidget ({126, 361}, {111, 14}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Staff speed MakeWidget ({225, 362}, { 11, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH ), // Staff speed - MakeWidget ({ 5, 392}, {238, 35}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_CHEAT_GROUP_CONSTRUCTION ), // Construction group + MakeWidget ({ 5, 392}, {238, 56}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_CHEAT_GROUP_CONSTRUCTION ), // Construction group MakeWidget ({ 11, 407}, CHEAT_CHECK, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_CHEAT_ALLOW_PATH_AS_QUEUE, STR_CHEAT_ALLOW_PATH_AS_QUEUE_TIP ), // Allow regular footpaths as queue path + MakeWidget ({ 11, 428}, CHEAT_CHECK, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_CHEAT_ALLOW_SPECIAL_COLOR_SCHEMES, STR_CHEAT_ALLOW_SPECIAL_COLOR_SCHEMES_TIP ), // Allow special colors in dropdown WIDGETS_END, }; @@ -484,6 +486,7 @@ public: SetCheckboxValue(WIDX_NEVERENDING_MARKETING, gCheatsNeverendingMarketing); SetCheckboxValue(WIDX_DISABLE_PLANT_AGING, gCheatsDisablePlantAging); SetCheckboxValue(WIDX_ALLOW_REGULAR_PATH_AS_QUEUE, gCheatsAllowRegularPathAsQueue); + SetCheckboxValue(WIDX_ALLOW_SPECIAL_COLOR_SCHEMES, gCheatsAllowSpecialColorSchemes); break; case WINDOW_CHEATS_PAGE_RIDES: SetCheckboxValue(WIDX_UNLOCK_OPERATING_LIMITS, gCheatsUnlockOperatingLimits); @@ -911,6 +914,9 @@ private: case WIDX_ALLOW_REGULAR_PATH_AS_QUEUE: CheatsSet(CheatType::AllowRegularPathAsQueue, !gCheatsAllowRegularPathAsQueue); break; + case WIDX_ALLOW_SPECIAL_COLOR_SCHEMES: + CheatsSet(CheatType::AllowSpecialColorSchemes, !gCheatsAllowSpecialColorSchemes); + break; } } diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index cfa070c6c7..a69740ff93 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -461,8 +461,10 @@ int32_t DropdownIndexFromPoint(const ScreenCoordsXY& loc, WindowBase* w) void WindowDropdownShowColour(WindowBase* w, Widget* widget, uint8_t dropdownColour, uint8_t selectedColour) { int32_t defaultIndex = -1; + + auto numColors = (gCheatsAllowSpecialColorSchemes) ? COLOUR_NUM_NORMAL : COLOUR_COUNT; // Set items - for (uint64_t i = 0; i < COLOUR_COUNT; i++) + for (uint64_t i = 0; i < numColors; i++) { if (selectedColour == COLOUR_UI_ORDER[i]) defaultIndex = selectedColour; diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 88839eb1f2..30e8d3c08e 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -53,6 +53,7 @@ bool gCheatsIgnoreResearchStatus = false; bool gCheatsEnableAllDrawableTrackPieces = false; bool gCheatsAllowTrackPlaceInvalidHeights = false; bool gCheatsAllowRegularPathAsQueue = false; +bool gCheatsAllowSpecialColorSchemes = false; void CheatsReset() { @@ -79,6 +80,7 @@ void CheatsReset() gCheatsEnableAllDrawableTrackPieces = false; gCheatsAllowTrackPlaceInvalidHeights = false; gCheatsAllowRegularPathAsQueue = false; + gCheatsAllowSpecialColorSchemes = false; } void CheatsSet(CheatType cheatType, int32_t param1 /* = 0*/, int32_t param2 /* = 0*/) @@ -128,6 +130,7 @@ void CheatsSerialise(DataSerialiser& ds) CheatEntrySerialise(ds, CheatType::EnableAllDrawableTrackPieces, gCheatsEnableAllDrawableTrackPieces, count); CheatEntrySerialise(ds, CheatType::AllowTrackPlaceInvalidHeights, gCheatsAllowTrackPlaceInvalidHeights, count); CheatEntrySerialise(ds, CheatType::AllowRegularPathAsQueue, gCheatsAllowRegularPathAsQueue, count); + CheatEntrySerialise(ds, CheatType::AllowSpecialColorSchemes, gCheatsAllowSpecialColorSchemes, count); // Remember current position and update count. uint64_t endOffset = stream.GetPosition(); @@ -223,6 +226,9 @@ void CheatsSerialise(DataSerialiser& ds) case CheatType::AllowRegularPathAsQueue: ds << gCheatsAllowRegularPathAsQueue; break; + case CheatType::AllowSpecialColorSchemes: + ds << gCheatsAllowSpecialColorSchemes; + break; default: break; } @@ -328,6 +334,8 @@ const char* CheatsGetName(CheatType cheatType) return LanguageGetString(STR_CHEAT_ALLOW_TRACK_PLACE_INVALID_HEIGHTS); case CheatType::AllowRegularPathAsQueue: return LanguageGetString(STR_CHEAT_ALLOW_PATH_AS_QUEUE); + case CheatType::AllowSpecialColorSchemes: + return LanguageGetString(STR_CHEAT_ALLOW_SPECIAL_COLOR_SCHEMES); default: return "Unknown Cheat"; } diff --git a/src/openrct2/Cheats.h b/src/openrct2/Cheats.h index fafd5c42f5..d840e9a0bd 100644 --- a/src/openrct2/Cheats.h +++ b/src/openrct2/Cheats.h @@ -34,6 +34,7 @@ extern bool gCheatsIgnoreResearchStatus; extern bool gCheatsEnableAllDrawableTrackPieces; extern bool gCheatsAllowTrackPlaceInvalidHeights; extern bool gCheatsAllowRegularPathAsQueue; +extern bool gCheatsAllowSpecialColorSchemes; enum class CheatType : int32_t { @@ -88,6 +89,7 @@ enum class CheatType : int32_t AllowTrackPlaceInvalidHeights, NoCapOnQueueLengthDummy, // Removed; this dummy exists only for deserialisation parks that had it saved AllowRegularPathAsQueue, + AllowSpecialColorSchemes, Count, }; diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index b712dd6a31..30ce7db7b1 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -244,6 +244,9 @@ GameActions::Result CheatSetAction::Execute() const case CheatType::AllowRegularPathAsQueue: gCheatsAllowRegularPathAsQueue = _param1 != 0; break; + case CheatType::AllowSpecialColorSchemes: + gCheatsAllowSpecialColorSchemes = _param1 != 0; + break; default: { LOG_ERROR("Unabled cheat: %d", _cheatType.id); diff --git a/src/openrct2/interface/Colour.h b/src/openrct2/interface/Colour.h index 0b67c6ad76..44fe60f23c 100644 --- a/src/openrct2/interface/Colour.h +++ b/src/openrct2/interface/Colour.h @@ -204,6 +204,7 @@ constexpr uint8_t PALETTE_OFFSET_ANIMATED = PALETTE_INDEX_230; constexpr uint8_t PALETTE_LENGTH_ANIMATED = 16; constexpr uint8_t COLOUR_NUM_ORIGINAL = 32; +constexpr uint8_t COLOUR_NUM_NORMAL = 54; #define TEXT_COLOUR_254 (254) #define TEXT_COLOUR_255 (255) diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 3dea22ebc4..1ac9854ad4 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3974,6 +3974,8 @@ enum : uint16_t STR_COLOUR_DULL_BROWN_LIGHT_TIP = 6572, STR_COLOUR_INVISIBLE_TIP = 6573, STR_COLOUR_VOID_TIP = 6574, + STR_CHEAT_ALLOW_SPECIAL_COLOR_SCHEMES = 6575, + STR_CHEAT_ALLOW_SPECIAL_COLOR_SCHEMES_TIP = 6576, // 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 diff --git a/src/openrct2/scripting/bindings/game/ScCheats.hpp b/src/openrct2/scripting/bindings/game/ScCheats.hpp index f578e0b8bc..c6ea1befc5 100644 --- a/src/openrct2/scripting/bindings/game/ScCheats.hpp +++ b/src/openrct2/scripting/bindings/game/ScCheats.hpp @@ -42,6 +42,9 @@ namespace OpenRCT2::Scripting ctx, &ScCheats::disablePlantAging_get, &ScCheats::disablePlantAging_set, "disablePlantAging"); dukglue_register_property( ctx, &ScCheats::allowRegularPathAsQueue_get, &ScCheats::allowRegularPathAsQueue_set, "allowRegularPathAsQueue"); + dukglue_register_property( + ctx, &ScCheats::allowSpecialColorSchemes_get, &ScCheats::allowSpecialColorSchemes_set, + "allowSpecialColorSchemes"); dukglue_register_property( ctx, &ScCheats::disableRideValueAging_get, &ScCheats::disableRideValueAging_set, "disableRideValueAging"); dukglue_register_property( @@ -172,6 +175,17 @@ namespace OpenRCT2::Scripting gCheatsAllowRegularPathAsQueue = value; } + bool allowSpecialColorSchemes_get() + { + return gCheatsAllowSpecialColorSchemes; + } + + void allowSpecialColorSchemes_set(bool value) + { + ThrowIfGameStateNotMutable(); + gCheatsAllowSpecialColorSchemes = value; + } + bool disableRideValueAging_get() { return gCheatsDisableRideValueAging;