forked from rosebudai/OpenRCT2-Web
Fold remaining Editor unit into EditorController
This commit is contained in:
1 parent
8455d576f7
commit
35180cbefe
25 files changed
+202
-297
No files matched your search
@@ -18,7 +18,6 @@
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <functional>
|
||||
#include <openrct2-ui/UiStringIds.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/PlatformEnvironment.h>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "Window.h"
|
||||
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <openrct2-ui/input/MouseInput.h>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
@@ -30,6 +29,7 @@
|
||||
#include <openrct2/object/ObjectRepository.h>
|
||||
#include <openrct2/ride/RideData.h>
|
||||
#include <openrct2/ride/RideManager.hpp>
|
||||
#include <openrct2/scenes/editor/EditorController.h>
|
||||
#include <openrct2/ui/WindowManager.h>
|
||||
#include <openrct2/world/Scenery.h>
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Diagnostic.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Diagnostic.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/FileClassifier.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/scripting/CustomMenu.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Cheats.h>
|
||||
#include <openrct2/Diagnostic.h>
|
||||
#include <openrct2/Editor.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "AssetPackManager.h"
|
||||
#include "Context.h"
|
||||
#include "Editor.h"
|
||||
#include "FileClassifier.h"
|
||||
#include "Game.h"
|
||||
#include "GameState.h"
|
||||
|
||||
@@ -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 <array>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
namespace OpenRCT2::Editor
|
||||
{
|
||||
static std::array<std::vector<uint8_t>, 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<ObjectType, StringId> CheckObjectSelection()
|
||||
{
|
||||
constexpr std::pair<ObjectType, StringId> 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<ObjectType, StringId> 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<AnimationPeepType, StringId> 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<size_t>(objectType) < getObjectEntryGroupCount(ObjectType::paths));
|
||||
auto& list = _editorSelectedObjectFlags[EnumValue(objectType)];
|
||||
if (list.size() <= index)
|
||||
{
|
||||
list.resize(index + 1);
|
||||
}
|
||||
list[index] |= flags;
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::Editor
|
||||
@@ -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<ObjectType, StringId> 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
|
||||
@@ -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"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Diagnostic.h"
|
||||
#include "../Editor.h"
|
||||
#include "../Game.h"
|
||||
#include "../GameState.h"
|
||||
#include "../Input.h"
|
||||
|
||||
@@ -274,7 +274,6 @@
|
||||
<ClInclude Include="drawing\TTF.h" />
|
||||
<ClInclude Include="drawing\WeatherDrawer.h" />
|
||||
<ClInclude Include="drawing\X8DrawingEngine.h" />
|
||||
<ClInclude Include="Editor.h" />
|
||||
<ClInclude Include="entity\Balloon.h" />
|
||||
<ClInclude Include="entity\Duck.h" />
|
||||
<ClInclude Include="entity\EntityBase.h" />
|
||||
@@ -911,7 +910,6 @@
|
||||
<ClCompile Include="drawing\TTFSDLPort.cpp" />
|
||||
<ClCompile Include="drawing\WeatherDrawer.cpp" />
|
||||
<ClCompile Include="drawing\X8DrawingEngine.cpp" />
|
||||
<ClCompile Include="Editor.cpp" />
|
||||
<ClCompile Include="entity\Balloon.cpp" />
|
||||
<ClCompile Include="entity\Duck.cpp" />
|
||||
<ClCompile Include="entity\EntityBase.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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Diagnostic.h"
|
||||
#include "../Editor.h"
|
||||
#include "../GameState.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../actions/ride/RideSetStatusAction.h"
|
||||
|
||||
@@ -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 <array>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
@@ -51,8 +58,189 @@ namespace OpenRCT2::Editor
|
||||
u8string gSceneryGroupPartialSelectError;
|
||||
std::vector<uint8_t> _objectSelectionFlags;
|
||||
uint32_t _numSelectedObjectsForType[EnumValue(ObjectType::count)];
|
||||
|
||||
static int32_t _numAvailableObjectsForType[EnumValue(ObjectType::count)];
|
||||
|
||||
static std::array<std::vector<uint8_t>, 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<ObjectType, StringId> CheckObjectSelection()
|
||||
{
|
||||
constexpr std::pair<ObjectType, StringId> 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<ObjectType, StringId> 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<AnimationPeepType, StringId> 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<size_t>(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();
|
||||
|
||||
@@ -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 <optional>
|
||||
@@ -41,6 +42,14 @@ namespace OpenRCT2::Editor
|
||||
extern std::vector<uint8_t> _objectSelectionFlags;
|
||||
extern uint32_t _numSelectedObjectsForType[EnumValue(ObjectType::count)];
|
||||
|
||||
void ObjectListLoad();
|
||||
ResultWithMessage CheckPark();
|
||||
std::pair<ObjectType, StringId> 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);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user