From 35180cbefe578122558ee1db136fc8adfd69115e Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 27 Jun 2026 14:49:12 +0200 Subject: [PATCH] Fold remaining Editor unit into EditorController --- src/openrct2-ui/input/Shortcuts.cpp | 1 - src/openrct2-ui/interface/FileBrowser.cpp | 1 - .../interface/ViewportInteraction.cpp | 1 - .../windows/EditorBottomToolbar.cpp | 1 - .../windows/EditorInventionsList.cpp | 2 +- .../windows/EditorObjectSelection.cpp | 1 - .../windows/EditorScenarioOptions.cpp | 1 - src/openrct2-ui/windows/LoadSave.cpp | 1 - src/openrct2-ui/windows/TitleMenu.cpp | 1 - src/openrct2-ui/windows/TopToolbar.cpp | 1 - src/openrct2/Context.cpp | 1 - src/openrct2/Editor.cpp | 242 ------------------ src/openrct2/Editor.h | 32 --- src/openrct2/Game.cpp | 1 - src/openrct2/interface/Window.cpp | 1 - src/openrct2/libopenrct2.vcxproj | 2 - src/openrct2/park/ParkFile.cpp | 1 - src/openrct2/rct1/S4Importer.cpp | 1 - src/openrct2/ride/Ride.cpp | 1 - src/openrct2/ride/Vehicle.cpp | 1 - .../scenes/editor/EditorController.cpp | 190 +++++++++++++- src/openrct2/scenes/editor/EditorController.h | 9 + src/openrct2/scenes/editor/EditorScene.cpp | 2 +- .../scenes/editor/TrackDesignerScene.cpp | 2 +- .../scenes/editor/TrackManagerScene.cpp | 2 +- 25 files changed, 202 insertions(+), 297 deletions(-) delete mode 100644 src/openrct2/Editor.cpp delete mode 100644 src/openrct2/Editor.h diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index 22b6fd03cb..ea12cd9349 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/interface/FileBrowser.cpp b/src/openrct2-ui/interface/FileBrowser.cpp index 9744da68f0..a216d66451 100644 --- a/src/openrct2-ui/interface/FileBrowser.cpp +++ b/src/openrct2-ui/interface/FileBrowser.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 5eb1720276..edd61b0703 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -16,7 +16,6 @@ #include "Window.h" #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index 93a869083b..8160adaa0c 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 2fdbccffcc..0738a086c7 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 6efdc10955..8ef54b2d0c 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index c81fe2d132..5b056cc5f6 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index c78ded546f..ada6e6d71a 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/TitleMenu.cpp b/src/openrct2-ui/windows/TitleMenu.cpp index 95feacca17..59da5e6951 100644 --- a/src/openrct2-ui/windows/TitleMenu.cpp +++ b/src/openrct2-ui/windows/TitleMenu.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index b64e739cbf..65a63ca986 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 1253bebde7..85ba85126a 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -14,7 +14,6 @@ #include "AssetPackManager.h" #include "Context.h" -#include "Editor.h" #include "FileClassifier.h" #include "Game.h" #include "GameState.h" diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp deleted file mode 100644 index 5642e25a82..0000000000 --- a/src/openrct2/Editor.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2026 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#include "Editor.h" - -#include "Context.h" -#include "FileClassifier.h" -#include "Game.h" -#include "GameState.h" -#include "OpenRCT2.h" -#include "ParkImporter.h" -#include "actions/GameActionRunner.h" -#include "actions/ResultWithMessage.h" -#include "actions/park/LandBuyRightsAction.h" -#include "actions/park/LandSetRightsAction.h" -#include "audio/Audio.h" -#include "core/EnumUtils.hpp" -#include "core/Path.hpp" -#include "core/String.hpp" -#include "drawing/Drawing.h" -#include "entity/EntityList.h" -#include "entity/EntityRegistry.h" -#include "entity/Guest.h" -#include "entity/PatrolArea.h" -#include "entity/Staff.h" -#include "interface/WindowBase.h" -#include "localisation/LocalisationService.h" -#include "management/Finance.h" -#include "management/NewsItem.h" -#include "object/DefaultObjects.h" -#include "object/ObjectManager.h" -#include "object/ObjectRepository.h" -#include "peep/PeepAnimations.h" -#include "rct1/RCT1.h" -#include "scenario/Scenario.h" -#include "scenes/SceneManager.h" -#include "scenes/editor/EditorController.h" -#include "scripting/ScriptEngine.h" -#include "ui/WindowManager.h" -#include "windows/Intent.h" -#include "world/Entrance.h" -#include "world/Footpath.h" -#include "world/Map.h" -#include "world/MapLimits.h" -#include "world/Park.h" -#include "world/Scenery.h" -#include "world/Weather.h" - -#include -#include -#include - -using namespace OpenRCT2; - -namespace OpenRCT2::Editor -{ - static std::array, EnumValue(ObjectType::count)> _editorSelectedObjectFlags; - - void ObjectListLoad() - { - auto* context = GetContext(); - context->OpenProgress(STR_LOADING_GENERIC); - - // Unload objects first, the repository is re-populated which owns the objects. - auto& objectManager = context->GetObjectManager(); - objectManager.UnloadAll(); - - // Scan objects if necessary - const auto& localisationService = context->GetLocalisationService(); - auto& objectRepository = context->GetObjectRepository(); - objectRepository.LoadOrConstruct(localisationService.GetCurrentLanguage()); - - Audio::LoadAudioObjects(); - - // Reset loaded objects to just defaults - // Load minimum required objects (like surface and edge) - for (const auto& entry : kMinimumRequiredObjects) - { - objectManager.LoadObject(entry); - } - - context->CloseProgress(); - } - - /** - * - * rct2: 0x006AB9B8 - */ - std::pair CheckObjectSelection() - { - constexpr std::pair kBasicCheckPairs[] = { - { ObjectType::ride, STR_AT_LEAST_ONE_RIDE_OBJECT_MUST_BE_SELECTED }, - { ObjectType::station, STR_AT_LEAST_ONE_STATION_OBJECT_MUST_BE_SELECTED }, - { ObjectType::terrainSurface, STR_AT_LEAST_ONE_TERRAIN_SURFACE_OBJECT_MUST_BE_SELECTED }, - { ObjectType::terrainEdge, STR_AT_LEAST_ONE_TERRAIN_EDGE_OBJECT_MUST_BE_SELECTED }, - }; - - for (auto& pair : kBasicCheckPairs) - { - if (!Editor::CheckObjectGroupAtLeastOneSelected(pair.first)) - { - return { pair.first, pair.second }; - } - } - - // No checks beyond this point apply to the track designer or track designs manager. - const bool isTrackDesignerManager = isInTrackDesignerOrManager(); - if (isTrackDesignerManager) - { - return { ObjectType::none, kStringIdNone }; - } - - if (!Editor::CheckObjectGroupAtLeastOneSurfaceSelected(false)) - { - return { ObjectType::footpathSurface, STR_AT_LEAST_ONE_FOOTPATH_NON_QUEUE_SURFACE_OBJECT_MUST_BE_SELECTED }; - } - if (!Editor::CheckObjectGroupAtLeastOneSurfaceSelected(true)) - { - return { ObjectType::footpathSurface, STR_AT_LEAST_ONE_FOOTPATH_QUEUE_SURFACE_OBJECT_MUST_BE_SELECTED }; - } - - constexpr std::pair kParkCheckPairs[] = { - { ObjectType::footpathRailings, STR_AT_LEAST_ONE_FOOTPATH_RAILING_OBJECT_MUST_BE_SELECTED }, - { ObjectType::parkEntrance, STR_PARK_ENTRANCE_TYPE_MUST_BE_SELECTED }, - { ObjectType::water, STR_WATER_TYPE_MUST_BE_SELECTED }, - { ObjectType::peepNames, STR_AT_LEAST_ONE_PEEP_NAMES_OBJECT_MUST_BE_SELECTED }, - }; - - for (auto& pair : kParkCheckPairs) - { - if (!Editor::CheckObjectGroupAtLeastOneSelected(pair.first)) - { - return { pair.first, pair.second }; - } - } - - using OpenRCT2::AnimationPeepType; - constexpr std::pair kPeepCheckPairs[] = { - { AnimationPeepType::guest, STR_AT_LEAST_ONE_GUEST_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, - { AnimationPeepType::handyman, STR_AT_LEAST_ONE_HANDYMAN_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, - { AnimationPeepType::mechanic, STR_AT_LEAST_ONE_MECHANIC_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, - { AnimationPeepType::security, STR_AT_LEAST_ONE_SECURITY_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, - { AnimationPeepType::entertainer, STR_AT_LEAST_ONE_ENTERTAINER_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, - }; - - for (auto& pair : kPeepCheckPairs) - { - if (!Editor::CheckObjectGroupAtLeastOneOfPeepTypeSelected(EnumValue(pair.first))) - { - return { ObjectType::peepAnimations, pair.second }; - } - } - - return { ObjectType::none, kStringIdNone }; - } - - /** - * - * rct2: 0x0066FEAC - */ - ResultWithMessage CheckPark() - { - auto& gameState = getGameState(); - auto& park = gameState.park; - int32_t parkSize = Park::UpdateSize(park); - if (parkSize == 0) - { - return { false, STR_PARK_MUST_OWN_SOME_LAND }; - } - - if (gameState.park.entrances.empty()) - { - return { false, STR_NO_PARK_ENTRANCES }; - } - - for (const auto& parkEntrance : gameState.park.entrances) - { - int32_t direction = DirectionReverse(parkEntrance.direction); - - switch (FootpathIsConnectedToMapEdge(parkEntrance, direction, 0)) - { - case FOOTPATH_SEARCH_NOT_FOUND: - return { false, STR_PARK_ENTRANCE_WRONG_DIRECTION_OR_NO_PATH }; - case FOOTPATH_SEARCH_INCOMPLETE: - case FOOTPATH_SEARCH_TOO_COMPLEX: - return { false, STR_PARK_ENTRANCE_PATH_INCOMPLETE_OR_COMPLEX }; - case FOOTPATH_SEARCH_SUCCESS: - // Run the search again and unown the path - FootpathIsConnectedToMapEdge(parkEntrance, direction, (1 << 5)); - break; - } - } - - if (gameState.peepSpawns.empty()) - { - return { false, STR_PEEP_SPAWNS_NOT_SET }; - } - - return { true, kStringIdNone }; - } - - uint8_t GetSelectedObjectFlags(ObjectType objectType, size_t index) - { - uint8_t result = 0; - auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; - if (list.size() > index) - { - result = list[index]; - } - return result; - } - - void ClearSelectedObject(ObjectType objectType, size_t index, uint32_t flags) - { - auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; - if (list.size() <= index) - { - list.resize(index + 1); - } - list[index] &= ~flags; - } - - void SetSelectedObject(ObjectType objectType, size_t index, uint32_t flags) - { - if (index != kObjectEntryIndexNull) - { - assert(static_cast(objectType) < getObjectEntryGroupCount(ObjectType::paths)); - auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; - if (list.size() <= index) - { - list.resize(index + 1); - } - list[index] |= flags; - } - } -} // namespace OpenRCT2::Editor diff --git a/src/openrct2/Editor.h b/src/openrct2/Editor.h deleted file mode 100644 index 8bc4647f58..0000000000 --- a/src/openrct2/Editor.h +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2026 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#include "core/StringTypes.h" -#include "localisation/StringIdType.h" -#include "object/ObjectTypes.h" - -struct ResultWithMessage; - -namespace OpenRCT2 -{ - struct WindowBase; -} - -namespace OpenRCT2::Editor -{ - void ObjectListLoad(); - ResultWithMessage CheckPark(); - std::pair CheckObjectSelection(); - - uint8_t GetSelectedObjectFlags(ObjectType objectType, size_t index); - void ClearSelectedObject(ObjectType objectType, size_t index, uint32_t flags); - void SetSelectedObject(ObjectType objectType, size_t index, uint32_t flags); -} // namespace OpenRCT2::Editor diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 62663383be..c77186421b 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -12,7 +12,6 @@ #include "Cheats.h" #include "Context.h" #include "Diagnostic.h" -#include "Editor.h" #include "FileClassifier.h" #include "GameState.h" #include "GameStateSnapshots.h" diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 622aca4dcf..20a0ef2eac 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -11,7 +11,6 @@ #include "../Context.h" #include "../Diagnostic.h" -#include "../Editor.h" #include "../Game.h" #include "../GameState.h" #include "../Input.h" diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index c83ef694ad..d0da17b412 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -274,7 +274,6 @@ - @@ -911,7 +910,6 @@ - diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 37f773ed98..d388e5d03b 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -12,7 +12,6 @@ #include "../Cheats.h" #include "../Context.h" #include "../Diagnostic.h" -#include "../Editor.h" #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 7ec0dfcf82..ccf5a41679 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -10,7 +10,6 @@ #include "../Cheats.h" #include "../Context.h" #include "../Diagnostic.h" -#include "../Editor.h" #include "../Game.h" #include "../GameState.h" #include "../ParkImporter.h" diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 70606d004d..e221a43eee 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -12,7 +12,6 @@ #include "../Cheats.h" #include "../Context.h" #include "../Diagnostic.h" -#include "../Editor.h" #include "../GameState.h" #include "../Input.h" #include "../OpenRCT2.h" diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 3765c812fa..6062f753d2 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -11,7 +11,6 @@ #include "../Context.h" #include "../Diagnostic.h" -#include "../Editor.h" #include "../GameState.h" #include "../OpenRCT2.h" #include "../actions/ride/RideSetStatusAction.h" diff --git a/src/openrct2/scenes/editor/EditorController.cpp b/src/openrct2/scenes/editor/EditorController.cpp index 082029c771..c88a2ed18b 100644 --- a/src/openrct2/scenes/editor/EditorController.cpp +++ b/src/openrct2/scenes/editor/EditorController.cpp @@ -11,16 +11,18 @@ #include "../../Context.h" #include "../../Diagnostic.h" -#include "../../Editor.h" #include "../../Game.h" #include "../../GameState.h" #include "../../OpenRCT2.h" #include "../../actions/ResultWithMessage.h" +#include "../../audio/Audio.h" +#include "../../core/EnumUtils.hpp" #include "../../drawing/Drawing.h" #include "../../entity/EntityList.h" #include "../../entity/Guest.h" #include "../../entity/Staff.h" #include "../../localisation/Formatting.h" +#include "../../localisation/LocalisationService.h" #include "../../management/Research.h" #include "../../object/DefaultObjects.h" #include "../../object/FootpathEntry.h" @@ -28,12 +30,15 @@ #include "../../object/ObjectManager.h" #include "../../object/ObjectRepository.h" #include "../../object/WaterObject.h" +#include "../../peep/PeepAnimations.h" #include "../../ride/RideData.h" #include "../../ride/RideManager.hpp" #include "../../ride/TrainManager.h" #include "../../ride/Vehicle.h" #include "../../windows/Intent.h" +#include "../../world/Footpath.h" #include "../../world/Map.h" +#include "../../world/Park.h" #include "../../world/tile_element/BannerElement.h" #include "../../world/tile_element/EntranceElement.h" #include "../../world/tile_element/LargeSceneryElement.h" @@ -43,6 +48,8 @@ #include "../../world/tile_element/TileElement.h" #include "../../world/tile_element/WallElement.h" +#include +#include #include #include @@ -51,8 +58,189 @@ namespace OpenRCT2::Editor u8string gSceneryGroupPartialSelectError; std::vector _objectSelectionFlags; uint32_t _numSelectedObjectsForType[EnumValue(ObjectType::count)]; + static int32_t _numAvailableObjectsForType[EnumValue(ObjectType::count)]; + static std::array, EnumValue(ObjectType::count)> _editorSelectedObjectFlags; + + void ObjectListLoad() + { + auto* context = GetContext(); + context->OpenProgress(STR_LOADING_GENERIC); + + // Unload objects first, the repository is re-populated which owns the objects. + auto& objectManager = context->GetObjectManager(); + objectManager.UnloadAll(); + + // Scan objects if necessary + const auto& localisationService = context->GetLocalisationService(); + auto& objectRepository = context->GetObjectRepository(); + objectRepository.LoadOrConstruct(localisationService.GetCurrentLanguage()); + + Audio::LoadAudioObjects(); + + // Reset loaded objects to just defaults + // Load minimum required objects (like surface and edge) + for (const auto& entry : kMinimumRequiredObjects) + { + objectManager.LoadObject(entry); + } + + context->CloseProgress(); + } + + /** + * + * rct2: 0x006AB9B8 + */ + std::pair CheckObjectSelection() + { + constexpr std::pair kBasicCheckPairs[] = { + { ObjectType::ride, STR_AT_LEAST_ONE_RIDE_OBJECT_MUST_BE_SELECTED }, + { ObjectType::station, STR_AT_LEAST_ONE_STATION_OBJECT_MUST_BE_SELECTED }, + { ObjectType::terrainSurface, STR_AT_LEAST_ONE_TERRAIN_SURFACE_OBJECT_MUST_BE_SELECTED }, + { ObjectType::terrainEdge, STR_AT_LEAST_ONE_TERRAIN_EDGE_OBJECT_MUST_BE_SELECTED }, + }; + + for (auto& pair : kBasicCheckPairs) + { + if (!CheckObjectGroupAtLeastOneSelected(pair.first)) + { + return { pair.first, pair.second }; + } + } + + // No checks beyond this point apply to the track designer or track designs manager. + const bool isTrackDesignerManager = isInTrackDesignerOrManager(); + if (isTrackDesignerManager) + { + return { ObjectType::none, kStringIdNone }; + } + + if (!CheckObjectGroupAtLeastOneSurfaceSelected(false)) + { + return { ObjectType::footpathSurface, STR_AT_LEAST_ONE_FOOTPATH_NON_QUEUE_SURFACE_OBJECT_MUST_BE_SELECTED }; + } + if (!CheckObjectGroupAtLeastOneSurfaceSelected(true)) + { + return { ObjectType::footpathSurface, STR_AT_LEAST_ONE_FOOTPATH_QUEUE_SURFACE_OBJECT_MUST_BE_SELECTED }; + } + + constexpr std::pair kParkCheckPairs[] = { + { ObjectType::footpathRailings, STR_AT_LEAST_ONE_FOOTPATH_RAILING_OBJECT_MUST_BE_SELECTED }, + { ObjectType::parkEntrance, STR_PARK_ENTRANCE_TYPE_MUST_BE_SELECTED }, + { ObjectType::water, STR_WATER_TYPE_MUST_BE_SELECTED }, + { ObjectType::peepNames, STR_AT_LEAST_ONE_PEEP_NAMES_OBJECT_MUST_BE_SELECTED }, + }; + + for (auto& pair : kParkCheckPairs) + { + if (!CheckObjectGroupAtLeastOneSelected(pair.first)) + { + return { pair.first, pair.second }; + } + } + + using OpenRCT2::AnimationPeepType; + constexpr std::pair kPeepCheckPairs[] = { + { AnimationPeepType::guest, STR_AT_LEAST_ONE_GUEST_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, + { AnimationPeepType::handyman, STR_AT_LEAST_ONE_HANDYMAN_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, + { AnimationPeepType::mechanic, STR_AT_LEAST_ONE_MECHANIC_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, + { AnimationPeepType::security, STR_AT_LEAST_ONE_SECURITY_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, + { AnimationPeepType::entertainer, STR_AT_LEAST_ONE_ENTERTAINER_PEEP_ANIMATIONS_OBJECT_MUST_BE_SELECTED }, + }; + + for (auto& pair : kPeepCheckPairs) + { + if (!CheckObjectGroupAtLeastOneOfPeepTypeSelected(EnumValue(pair.first))) + { + return { ObjectType::peepAnimations, pair.second }; + } + } + + return { ObjectType::none, kStringIdNone }; + } + + /** + * + * rct2: 0x0066FEAC + */ + ResultWithMessage CheckPark() + { + auto& gameState = getGameState(); + auto& park = gameState.park; + int32_t parkSize = Park::UpdateSize(park); + if (parkSize == 0) + { + return { false, STR_PARK_MUST_OWN_SOME_LAND }; + } + + if (gameState.park.entrances.empty()) + { + return { false, STR_NO_PARK_ENTRANCES }; + } + + for (const auto& parkEntrance : gameState.park.entrances) + { + int32_t direction = DirectionReverse(parkEntrance.direction); + + switch (FootpathIsConnectedToMapEdge(parkEntrance, direction, 0)) + { + case FOOTPATH_SEARCH_NOT_FOUND: + return { false, STR_PARK_ENTRANCE_WRONG_DIRECTION_OR_NO_PATH }; + case FOOTPATH_SEARCH_INCOMPLETE: + case FOOTPATH_SEARCH_TOO_COMPLEX: + return { false, STR_PARK_ENTRANCE_PATH_INCOMPLETE_OR_COMPLEX }; + case FOOTPATH_SEARCH_SUCCESS: + // Run the search again and unown the path + FootpathIsConnectedToMapEdge(parkEntrance, direction, (1 << 5)); + break; + } + } + + if (gameState.peepSpawns.empty()) + { + return { false, STR_PEEP_SPAWNS_NOT_SET }; + } + + return { true, kStringIdNone }; + } + + uint8_t GetSelectedObjectFlags(ObjectType objectType, size_t index) + { + uint8_t result = 0; + auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; + if (list.size() > index) + { + result = list[index]; + } + return result; + } + + void ClearSelectedObject(ObjectType objectType, size_t index, uint32_t flags) + { + auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; + if (list.size() <= index) + { + list.resize(index + 1); + } + list[index] &= ~flags; + } + + void SetSelectedObject(ObjectType objectType, size_t index, uint32_t flags) + { + if (index != kObjectEntryIndexNull) + { + assert(static_cast(objectType) < getObjectEntryGroupCount(ObjectType::paths)); + auto& list = _editorSelectedObjectFlags[EnumValue(objectType)]; + if (list.size() <= index) + { + list.resize(index + 1); + } + list[index] |= flags; + } + } + static void SetupInUseSelectionFlags(); static void SetupTrackDesignerObjects(); static void SetupTrackManagerObjects(); diff --git a/src/openrct2/scenes/editor/EditorController.h b/src/openrct2/scenes/editor/EditorController.h index 7c3c95c303..0326e223e8 100644 --- a/src/openrct2/scenes/editor/EditorController.h +++ b/src/openrct2/scenes/editor/EditorController.h @@ -12,6 +12,7 @@ #include "../../core/EnumUtils.hpp" #include "../../core/FlagHolder.hpp" #include "../../core/StringTypes.h" +#include "../../localisation/StringIdType.h" #include "../../object/ObjectTypes.h" #include @@ -41,6 +42,14 @@ namespace OpenRCT2::Editor extern std::vector _objectSelectionFlags; extern uint32_t _numSelectedObjectsForType[EnumValue(ObjectType::count)]; + void ObjectListLoad(); + ResultWithMessage CheckPark(); + std::pair CheckObjectSelection(); + + uint8_t GetSelectedObjectFlags(ObjectType objectType, size_t index); + void ClearSelectedObject(ObjectType objectType, size_t index, uint32_t flags); + void SetSelectedObject(ObjectType objectType, size_t index, uint32_t flags); + bool CheckObjectGroupAtLeastOneSelected(ObjectType checkObjectType); bool CheckObjectGroupAtLeastOneOfPeepTypeSelected(uint8_t peepType); bool CheckObjectGroupAtLeastOneSurfaceSelected(bool queue); diff --git a/src/openrct2/scenes/editor/EditorScene.cpp b/src/openrct2/scenes/editor/EditorScene.cpp index 1370a24636..29a60fed3a 100644 --- a/src/openrct2/scenes/editor/EditorScene.cpp +++ b/src/openrct2/scenes/editor/EditorScene.cpp @@ -11,7 +11,6 @@ #include "../../Context.h" #include "../../Diagnostic.h" -#include "../../Editor.h" #include "../../Game.h" #include "../../GameState.h" #include "../../OpenRCT2.h" @@ -31,6 +30,7 @@ #include "../../localisation/Language.h" #include "../../object/ObjectManager.h" #include "../../scenario/Scenario.h" +#include "../../scenes/editor/EditorController.h" #include "../../scripting/ScriptEngine.h" #include "../../ui/WindowManager.h" #include "../../windows/Intent.h" diff --git a/src/openrct2/scenes/editor/TrackDesignerScene.cpp b/src/openrct2/scenes/editor/TrackDesignerScene.cpp index f4c4ffbab2..15f08179fc 100644 --- a/src/openrct2/scenes/editor/TrackDesignerScene.cpp +++ b/src/openrct2/scenes/editor/TrackDesignerScene.cpp @@ -11,7 +11,6 @@ #include "../../Context.h" #include "../../Diagnostic.h" -#include "../../Editor.h" #include "../../Game.h" #include "../../GameState.h" #include "../../OpenRCT2.h" @@ -20,6 +19,7 @@ #include "../../interface/WindowBase.h" #include "../../localisation/Language.h" #include "../../world/Map.h" +#include "EditorController.h" using namespace OpenRCT2; diff --git a/src/openrct2/scenes/editor/TrackManagerScene.cpp b/src/openrct2/scenes/editor/TrackManagerScene.cpp index c28ab4505e..da45c26047 100644 --- a/src/openrct2/scenes/editor/TrackManagerScene.cpp +++ b/src/openrct2/scenes/editor/TrackManagerScene.cpp @@ -11,7 +11,6 @@ #include "../../Context.h" #include "../../Diagnostic.h" -#include "../../Editor.h" #include "../../Game.h" #include "../../GameState.h" #include "../../OpenRCT2.h" @@ -20,6 +19,7 @@ #include "../../interface/WindowBase.h" #include "../../localisation/Language.h" #include "../../world/Map.h" +#include "EditorController.h" using namespace OpenRCT2;