2017-12-03 00:15:05 +01:00
|
|
|
|
/*****************************************************************************
|
2024-12-31 20:30:04 +01:00
|
|
|
|
* Copyright (c) 2014-2025 OpenRCT2 developers
|
2017-12-03 00:15:05 +01:00
|
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-12-03 00:15:05 +01:00
|
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-12-03 00:15:05 +01:00
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "EditorObjectSelectionSession.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
|
|
|
|
|
|
|
#include "Context.h"
|
2024-07-09 16:23:31 +02:00
|
|
|
|
#include "Diagnostic.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
|
#include "Editor.h"
|
2017-12-03 00:15:05 +01:00
|
|
|
|
#include "Game.h"
|
2024-03-01 20:26:20 +00:00
|
|
|
|
#include "GameState.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
|
#include "OpenRCT2.h"
|
2021-01-18 21:25:57 +01:00
|
|
|
|
#include "drawing/Drawing.h"
|
2025-03-01 17:32:32 +01:00
|
|
|
|
#include "entity/EntityList.h"
|
2024-12-06 19:50:14 +01:00
|
|
|
|
#include "entity/Guest.h"
|
|
|
|
|
|
#include "entity/Staff.h"
|
2021-12-11 18:06:06 -05:00
|
|
|
|
#include "localisation/Formatter.h"
|
2018-03-19 23:28:40 +01:00
|
|
|
|
#include "management/Research.h"
|
2018-02-02 23:11:41 +01:00
|
|
|
|
#include "object/DefaultObjects.h"
|
2023-01-27 19:44:58 +00:00
|
|
|
|
#include "object/FootpathEntry.h"
|
2018-02-13 15:20:55 +01:00
|
|
|
|
#include "object/ObjectList.h"
|
2017-12-03 00:15:05 +01:00
|
|
|
|
#include "object/ObjectManager.h"
|
|
|
|
|
|
#include "object/ObjectRepository.h"
|
2025-03-25 08:51:44 +01:00
|
|
|
|
#include "object/WaterObject.h"
|
2018-01-10 00:00:09 +01:00
|
|
|
|
#include "ride/RideData.h"
|
2024-12-11 15:54:45 +01:00
|
|
|
|
#include "ride/RideManager.hpp"
|
2021-03-16 11:18:06 +00:00
|
|
|
|
#include "ride/TrainManager.h"
|
2021-02-23 09:30:16 +01:00
|
|
|
|
#include "ride/Vehicle.h"
|
2017-12-03 00:15:05 +01:00
|
|
|
|
#include "windows/Intent.h"
|
2025-09-04 21:57:41 +02:00
|
|
|
|
#include "world/Map.h"
|
2024-10-14 14:26:10 +02:00
|
|
|
|
#include "world/tile_element/BannerElement.h"
|
2024-10-03 12:42:53 +02:00
|
|
|
|
#include "world/tile_element/EntranceElement.h"
|
2024-10-15 22:02:31 +02:00
|
|
|
|
#include "world/tile_element/LargeSceneryElement.h"
|
|
|
|
|
|
#include "world/tile_element/PathElement.h"
|
|
|
|
|
|
#include "world/tile_element/SmallSceneryElement.h"
|
|
|
|
|
|
#include "world/tile_element/SurfaceElement.h"
|
|
|
|
|
|
#include "world/tile_element/TileElement.h"
|
2024-10-03 21:09:30 +01:00
|
|
|
|
#include "world/tile_element/WallElement.h"
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2018-11-21 23:16:04 +01:00
|
|
|
|
#include <iterator>
|
2018-06-22 23:25:16 +02:00
|
|
|
|
#include <vector>
|
2018-02-13 15:20:55 +01:00
|
|
|
|
|
2024-07-26 09:59:58 +02:00
|
|
|
|
using namespace OpenRCT2;
|
|
|
|
|
|
|
2022-07-31 14:22:58 +02:00
|
|
|
|
std::optional<StringId> _gSceneryGroupPartialSelectError;
|
2018-06-20 17:28:51 +02:00
|
|
|
|
std::vector<uint8_t> _objectSelectionFlags;
|
2025-02-13 23:07:55 +01:00
|
|
|
|
uint32_t _numSelectedObjectsForType[EnumValue(ObjectType::count)];
|
|
|
|
|
|
static int32_t _numAvailableObjectsForType[EnumValue(ObjectType::count)];
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
static void SetupInUseSelectionFlags();
|
|
|
|
|
|
static void SetupTrackDesignerObjects();
|
|
|
|
|
|
static void SetupTrackManagerObjects();
|
2025-03-25 21:50:37 +01:00
|
|
|
|
static void selectScenarioEditorObjects();
|
|
|
|
|
|
static void selectTrackDesignerObjects();
|
2021-01-18 21:25:57 +01:00
|
|
|
|
static void ReplaceSelectedWaterPalette(const ObjectRepositoryItem* item);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2022-07-30 18:04:59 +02:00
|
|
|
|
/**
|
2023-08-13 07:23:06 -04:00
|
|
|
|
* Master objects are objects that are not optional / required dependants of an object.
|
2022-07-30 18:04:59 +02:00
|
|
|
|
*/
|
2022-07-31 14:22:58 +02:00
|
|
|
|
static constexpr ResultWithMessage ObjectSelectionError(bool isMasterObject, StringId message)
|
2022-07-30 18:04:59 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (!isMasterObject)
|
2023-01-17 13:24:51 +01:00
|
|
|
|
ResetSelectedObjectCountAndSize();
|
2022-07-30 18:04:59 +02:00
|
|
|
|
|
|
|
|
|
|
return { false, message };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-03 00:15:05 +01:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006ABCD1
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
static void SetupTrackManagerObjects()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2018-06-20 17:28:51 +02:00
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
|
uint8_t* selectionFlags = &_objectSelectionFlags[i];
|
|
|
|
|
|
const ObjectRepositoryItem* item = &items[i];
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (item->Type == ObjectType::ride)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags |= ObjectSelectionFlags::Flag6;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2018-05-14 13:05:59 +01:00
|
|
|
|
for (auto rideType : item->RideInfo.RideType)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2024-08-13 22:20:25 +02:00
|
|
|
|
if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::hasTrack))
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags &= ~ObjectSelectionFlags::Flag6;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006ABC1E
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
static void SetupTrackDesignerObjects()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2025-03-25 21:50:37 +01:00
|
|
|
|
selectTrackDesignerObjects();
|
2018-06-20 17:28:51 +02:00
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
|
uint8_t* selectionFlags = &_objectSelectionFlags[i];
|
|
|
|
|
|
const ObjectRepositoryItem* item = &items[i];
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (item->Type == ObjectType::ride)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags |= ObjectSelectionFlags::Flag6;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2022-08-13 21:49:19 +02:00
|
|
|
|
for (auto rideType : item->RideInfo.RideType)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2025-01-22 17:16:55 +01:00
|
|
|
|
if (rideType != kRideTypeNull)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2024-08-13 22:20:25 +02:00
|
|
|
|
if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::showInTrackDesigner))
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags &= ~ObjectSelectionFlags::Flag6;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AA82B
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
void SetupInUseSelectionFlags()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2018-12-05 20:33:45 +00:00
|
|
|
|
auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager();
|
|
|
|
|
|
|
2024-03-27 19:51:57 +01:00
|
|
|
|
for (auto objectType : getTransientObjectTypes())
|
2018-02-11 17:56:12 +00:00
|
|
|
|
{
|
2024-03-27 20:13:10 +01:00
|
|
|
|
for (auto i = 0u; i < getObjectEntryGroupCount(objectType); i++)
|
2018-02-11 17:56:12 +00:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
Editor::ClearSelectedObject(static_cast<ObjectType>(objectType), i, ObjectSelectionFlags::AllFlags);
|
2018-12-05 20:33:45 +00:00
|
|
|
|
|
2020-11-09 11:53:29 +01:00
|
|
|
|
auto loadedObj = objectMgr.GetLoadedObject(static_cast<ObjectType>(objectType), i);
|
2018-12-05 20:33:45 +00:00
|
|
|
|
if (loadedObj != nullptr)
|
2018-02-11 17:56:12 +00:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
Editor::SetSelectedObject(static_cast<ObjectType>(objectType), i, ObjectSelectionFlags::Selected);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-19 15:13:23 +00:00
|
|
|
|
TileElementIterator iter;
|
2022-10-12 13:14:45 +01:00
|
|
|
|
TileElementIteratorBegin(&iter);
|
2018-06-22 23:25:16 +02:00
|
|
|
|
do
|
|
|
|
|
|
{
|
2020-04-27 15:01:37 +02:00
|
|
|
|
ObjectEntryIndex type;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
|
switch (iter.element->GetType())
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
|
|
|
|
|
default:
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Surface:
|
2021-10-27 14:21:14 +02:00
|
|
|
|
{
|
|
|
|
|
|
auto surfaceEl = iter.element->AsSurface();
|
2023-08-26 20:50:06 +03:00
|
|
|
|
auto surfaceIndex = surfaceEl->GetSurfaceObjectIndex();
|
2023-08-26 21:01:27 +03:00
|
|
|
|
auto edgeIndex = surfaceEl->GetEdgeObjectIndex();
|
2021-10-27 14:21:14 +02:00
|
|
|
|
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::terrainSurface, surfaceIndex, ObjectSelectionFlags::InUse);
|
|
|
|
|
|
Editor::SetSelectedObject(ObjectType::terrainEdge, edgeIndex, ObjectSelectionFlags::InUse);
|
2021-10-27 14:21:14 +02:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Track:
|
2017-12-03 00:15:05 +01:00
|
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Path:
|
2021-10-27 14:21:14 +02:00
|
|
|
|
{
|
|
|
|
|
|
auto footpathEl = iter.element->AsPath();
|
|
|
|
|
|
auto legacyPathEntryIndex = footpathEl->GetLegacyPathEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
|
if (legacyPathEntryIndex == kObjectEntryIndexNull)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2021-10-27 14:21:14 +02:00
|
|
|
|
auto surfaceEntryIndex = footpathEl->GetSurfaceEntryIndex();
|
|
|
|
|
|
auto railingEntryIndex = footpathEl->GetRailingsEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::footpathSurface, surfaceEntryIndex, ObjectSelectionFlags::InUse);
|
|
|
|
|
|
Editor::SetSelectedObject(ObjectType::footpathRailings, railingEntryIndex, ObjectSelectionFlags::InUse);
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::paths, legacyPathEntryIndex, ObjectSelectionFlags::InUse);
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
if (footpathEl->HasAddition())
|
|
|
|
|
|
{
|
|
|
|
|
|
auto pathAdditionEntryIndex = footpathEl->GetAdditionEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::pathAdditions, pathAdditionEntryIndex, ObjectSelectionFlags::InUse);
|
2018-06-22 23:25:16 +02:00
|
|
|
|
}
|
2017-12-25 12:53:23 +01:00
|
|
|
|
break;
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::SmallScenery:
|
2018-09-13 17:02:38 +02:00
|
|
|
|
type = iter.element->AsSmallScenery()->GetEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::smallScenery, type, ObjectSelectionFlags::InUse);
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Entrance:
|
2021-10-27 14:21:14 +02:00
|
|
|
|
{
|
|
|
|
|
|
auto parkEntranceEl = iter.element->AsEntrance();
|
|
|
|
|
|
if (parkEntranceEl->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2024-08-05 01:02:16 +02:00
|
|
|
|
type = iter.element->AsEntrance()->getEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::parkEntrance, type, ObjectSelectionFlags::InUse);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2021-10-27 14:21:14 +02:00
|
|
|
|
// Skip if not the middle part
|
|
|
|
|
|
if (parkEntranceEl->GetSequenceIndex() != 0)
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
auto legacyPathEntryIndex = parkEntranceEl->GetLegacyPathEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
|
if (legacyPathEntryIndex == kObjectEntryIndexNull)
|
2021-10-27 14:21:14 +02:00
|
|
|
|
{
|
|
|
|
|
|
auto surfaceEntryIndex = parkEntranceEl->GetSurfaceEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::footpathSurface, surfaceEntryIndex, ObjectSelectionFlags::InUse);
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::paths, legacyPathEntryIndex, ObjectSelectionFlags::InUse);
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2021-10-27 14:21:14 +02:00
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Wall:
|
2018-09-17 15:42:34 +02:00
|
|
|
|
type = iter.element->AsWall()->GetEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::walls, type, ObjectSelectionFlags::InUse);
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::LargeScenery:
|
2018-09-14 12:12:22 +02:00
|
|
|
|
type = iter.element->AsLargeScenery()->GetEntryIndex();
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::largeScenery, type, ObjectSelectionFlags::InUse);
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
|
case TileElementType::Banner:
|
2019-07-21 15:16:44 +01:00
|
|
|
|
{
|
2019-07-25 17:51:22 +01:00
|
|
|
|
auto banner = iter.element->AsBanner()->GetBanner();
|
|
|
|
|
|
if (banner != nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
type = banner->type;
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::banners, type, ObjectSelectionFlags::InUse);
|
2019-07-25 17:51:22 +01:00
|
|
|
|
}
|
2018-06-22 23:25:16 +02:00
|
|
|
|
break;
|
2019-07-21 15:16:44 +01:00
|
|
|
|
}
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
2022-10-12 13:14:45 +01:00
|
|
|
|
} while (TileElementIteratorNext(&iter));
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2021-08-02 09:07:53 +03:00
|
|
|
|
for (auto& ride : GetRideManager())
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::ride, ride.subtype, ObjectSelectionFlags::InUse);
|
2025-03-09 00:26:25 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::station, ride.entranceStyle, ObjectSelectionFlags::InUse);
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::music, ride.music, ObjectSelectionFlags::InUse);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-22 17:16:55 +01:00
|
|
|
|
ObjectEntryIndex lastIndex = kObjectEntryIndexNull;
|
2024-12-06 19:50:14 +01:00
|
|
|
|
for (auto* peep : EntityList<Guest>())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (peep->AnimationObjectIndex == lastIndex)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
lastIndex = peep->AnimationObjectIndex;
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::peepAnimations, lastIndex, ObjectSelectionFlags::InUse);
|
2024-12-06 19:50:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
for (auto* peep : EntityList<Staff>())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (peep->AnimationObjectIndex == lastIndex)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
lastIndex = peep->AnimationObjectIndex;
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::peepAnimations, lastIndex, ObjectSelectionFlags::InUse);
|
2024-12-06 19:50:14 +01:00
|
|
|
|
}
|
2024-11-29 22:10:18 +01:00
|
|
|
|
|
2021-02-10 18:14:23 +00:00
|
|
|
|
// Apply selected object status for hacked vehicles that may not have an associated ride
|
2021-03-16 11:18:06 +00:00
|
|
|
|
for (auto* vehicle : TrainManager::View())
|
2021-02-10 18:14:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
ObjectEntryIndex type = vehicle->ride_subtype;
|
2025-01-22 17:16:55 +01:00
|
|
|
|
if (type != kObjectEntryIndexNull) // cable lifts use index null. Ignore them
|
2021-02-10 18:14:23 +00:00
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::ride, type, ObjectSelectionFlags::InUse);
|
2021-02-10 18:14:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-16 11:18:06 +00:00
|
|
|
|
for (auto vehicle : EntityList<Vehicle>())
|
2021-02-10 18:14:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
ObjectEntryIndex type = vehicle->ride_subtype;
|
2025-01-22 17:16:55 +01:00
|
|
|
|
if (type != kObjectEntryIndexNull) // cable lifts use index null. Ignore them
|
2021-02-10 18:14:23 +00:00
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
Editor::SetSelectedObject(ObjectType::ride, type, ObjectSelectionFlags::InUse);
|
2021-02-10 18:14:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
|
auto numObjects = ObjectRepositoryGetItemsCount();
|
|
|
|
|
|
const auto* items = ObjectRepositoryGetItems();
|
2021-10-27 14:21:14 +02:00
|
|
|
|
for (size_t i = 0; i < numObjects; i++)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2021-10-27 14:21:14 +02:00
|
|
|
|
auto* selectionFlags = &_objectSelectionFlags[i];
|
|
|
|
|
|
const auto* item = &items[i];
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags &= ~ObjectSelectionFlags::InUse;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2021-10-27 14:21:14 +02:00
|
|
|
|
if (item->LoadedObject != nullptr)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2021-10-27 14:21:14 +02:00
|
|
|
|
auto objectType = item->LoadedObject->GetObjectType();
|
|
|
|
|
|
auto entryIndex = objectMgr.GetLoadedObjectEntryIndex(item->LoadedObject.get());
|
2022-01-19 17:33:54 +00:00
|
|
|
|
*selectionFlags |= Editor::GetSelectedObjectFlags(objectType, entryIndex);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AB211
|
|
|
|
|
|
*/
|
2023-01-17 19:05:14 +01:00
|
|
|
|
void Sub6AB211()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
2018-06-20 17:28:51 +02:00
|
|
|
|
_objectSelectionFlags = std::vector<uint8_t>(numObjects);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2025-02-13 23:07:55 +01:00
|
|
|
|
for (uint8_t objectType = 0; objectType < EnumValue(ObjectType::count); objectType++)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2017-12-03 00:15:05 +01:00
|
|
|
|
_numSelectedObjectsForType[objectType] = 0;
|
|
|
|
|
|
_numAvailableObjectsForType[objectType] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2018-06-22 23:25:16 +02:00
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
|
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectType objectType = items[i].Type;
|
2020-11-09 12:07:38 +01:00
|
|
|
|
_numAvailableObjectsForType[EnumValue(objectType)]++;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-05 21:45:04 +01:00
|
|
|
|
if (gLegacyScene == LegacyScene::trackDesigner)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
SetupTrackDesignerObjects();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-05 21:45:04 +01:00
|
|
|
|
if (gLegacyScene == LegacyScene::trackDesignsManager)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
SetupTrackManagerObjects();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
SetupInUseSelectionFlags();
|
|
|
|
|
|
ResetSelectedObjectCountAndSize();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2025-03-05 21:45:04 +01:00
|
|
|
|
if (!(isInTrackDesignerOrManager()))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2017-12-03 00:15:05 +01:00
|
|
|
|
// To prevent it breaking in scenario mode.
|
2025-03-05 21:45:04 +01:00
|
|
|
|
if (gLegacyScene == LegacyScene::scenarioEditor)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2025-03-25 21:50:37 +01:00
|
|
|
|
selectScenarioEditorObjects();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
ResetSelectedObjectCountAndSize();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AB316
|
|
|
|
|
|
*/
|
2025-03-22 22:59:40 +01:00
|
|
|
|
void EditorObjectFlagsClear()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2018-02-11 17:56:12 +00:00
|
|
|
|
_objectSelectionFlags.clear();
|
|
|
|
|
|
_objectSelectionFlags.shrink_to_fit();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x00685791
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
static void RemoveSelectedObjectsFromResearch(const ObjectEntryDescriptor& descriptor)
|
2018-06-15 10:39:38 +02:00
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
|
|
|
|
|
|
auto obj = objManager.GetLoadedObject(descriptor);
|
|
|
|
|
|
if (obj != nullptr)
|
2018-06-15 10:39:38 +02:00
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
auto entryIndex = objManager.GetLoadedObjectEntryIndex(obj);
|
|
|
|
|
|
switch (obj->GetObjectType())
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
case ObjectType::ride:
|
2021-09-12 21:25:22 +02:00
|
|
|
|
{
|
2023-01-17 17:42:29 +01:00
|
|
|
|
auto rideEntry = GetRideEntryByIndex(entryIndex);
|
2021-09-12 21:25:22 +02:00
|
|
|
|
for (auto rideType : rideEntry->ride_type)
|
|
|
|
|
|
{
|
|
|
|
|
|
ResearchItem tmp = {};
|
|
|
|
|
|
tmp.type = Research::EntryType::Ride;
|
|
|
|
|
|
tmp.entryIndex = entryIndex;
|
|
|
|
|
|
tmp.baseRideType = rideType;
|
2021-10-15 17:01:04 +02:00
|
|
|
|
ResearchRemove(tmp);
|
2021-09-12 21:25:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-02-13 23:07:55 +01:00
|
|
|
|
case ObjectType::sceneryGroup:
|
2021-09-12 21:25:22 +02:00
|
|
|
|
{
|
|
|
|
|
|
ResearchItem tmp = {};
|
|
|
|
|
|
tmp.type = Research::EntryType::Scenery;
|
|
|
|
|
|
tmp.entryIndex = entryIndex;
|
2021-11-19 23:09:34 +00:00
|
|
|
|
tmp.baseRideType = 0;
|
2021-10-15 17:01:04 +02:00
|
|
|
|
ResearchRemove(tmp);
|
2021-09-12 21:25:22 +02:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006ABB66
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
void UnloadUnselectedObjects()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
auto numItems = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
|
|
|
|
|
const auto* items = ObjectRepositoryGetItems();
|
2021-09-12 21:25:22 +02:00
|
|
|
|
std::vector<ObjectEntryDescriptor> objectsToUnload;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
|
for (int32_t i = 0; i < numItems; i++)
|
|
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (!(_objectSelectionFlags[i] & ObjectSelectionFlags::Selected))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
auto descriptor = ObjectEntryDescriptor(items[i]);
|
2022-05-30 22:34:29 +01:00
|
|
|
|
if (!IsIntransientObjectType(items[i].Type))
|
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
RemoveSelectedObjectsFromResearch(descriptor);
|
2022-05-30 22:34:29 +01:00
|
|
|
|
objectsToUnload.push_back(descriptor);
|
|
|
|
|
|
}
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-17 20:46:55 +01:00
|
|
|
|
ObjectManagerUnloadObjects(objectsToUnload);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:25:16 +02:00
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AA805
|
|
|
|
|
|
*/
|
2025-03-25 21:50:37 +01:00
|
|
|
|
static void selectScenarioEditorObjects()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
|
if (_numSelectedObjectsForType[0] == 0)
|
|
|
|
|
|
{
|
2025-03-25 21:50:37 +01:00
|
|
|
|
for (auto designerSelectedObject : kCommonScenarioAndTrackDesignerObjects)
|
|
|
|
|
|
{
|
|
|
|
|
|
WindowEditorObjectSelectionSelectObject(
|
2025-03-25 17:57:28 +01:00
|
|
|
|
0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup },
|
2025-03-25 21:50:37 +01:00
|
|
|
|
ObjectEntryDescriptor(designerSelectedObject));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (auto defaultSelectedObject : kDefaultScenarioObjects)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
WindowEditorObjectSelectionSelectObject(
|
2025-03-25 17:57:28 +01:00
|
|
|
|
0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup },
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectEntryDescriptor(defaultSelectedObject));
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 21:50:37 +01:00
|
|
|
|
static void selectTrackDesignerObjects()
|
2020-12-14 15:02:43 -06:00
|
|
|
|
{
|
|
|
|
|
|
if (_numSelectedObjectsForType[0] == 0)
|
|
|
|
|
|
{
|
2025-03-25 21:50:37 +01:00
|
|
|
|
for (auto designerSelectedObject : kCommonScenarioAndTrackDesignerObjects)
|
2020-12-14 15:02:43 -06:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
WindowEditorObjectSelectionSelectObject(
|
2025-03-25 17:57:28 +01:00
|
|
|
|
0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup },
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectEntryDescriptor(designerSelectedObject));
|
2020-12-14 15:02:43 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-18 21:25:57 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Replaces the previously selected water palette with the palette in the specified item immediately.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static void ReplaceSelectedWaterPalette(const ObjectRepositoryItem* item)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto& objectManager = OpenRCT2::GetContext()->GetObjectManager();
|
2025-03-25 08:51:44 +01:00
|
|
|
|
auto* oldPalette = objectManager.GetLoadedObject<WaterObject>(0);
|
2021-01-18 21:25:57 +01:00
|
|
|
|
|
|
|
|
|
|
if (oldPalette != nullptr)
|
|
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
const std::vector<ObjectEntryDescriptor> oldEntries = { oldPalette->GetDescriptor() };
|
2021-01-18 21:25:57 +01:00
|
|
|
|
objectManager.UnloadObjects(oldEntries);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-12 21:25:22 +02:00
|
|
|
|
auto newPaletteEntry = ObjectEntryDescriptor(*item);
|
|
|
|
|
|
if (objectManager.GetLoadedObject(newPaletteEntry) != nullptr || objectManager.LoadObject(newPaletteEntry) != nullptr)
|
2021-01-18 21:25:57 +01:00
|
|
|
|
{
|
2023-01-16 13:50:43 +00:00
|
|
|
|
LoadPalette();
|
2021-01-18 21:25:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
LOG_ERROR("Failed to load selected palette %s", std::string(newPaletteEntry.GetName()).c_str());
|
2021-01-18 21:25:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-03 00:15:05 +01:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AA770
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
void ResetSelectedObjectCountAndSize()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
|
for (auto& objectType : _numSelectedObjectsForType)
|
2017-12-20 02:50:18 +01:00
|
|
|
|
{
|
|
|
|
|
|
objectType = 0;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2018-06-22 23:25:16 +02:00
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
|
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectType objectType = items[i].Type;
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (_objectSelectionFlags[i] & ObjectSelectionFlags::Selected)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2020-11-09 12:07:38 +01:00
|
|
|
|
_numSelectedObjectsForType[EnumValue(objectType)]++;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
void FinishObjectSelection()
|
2020-04-25 01:19:06 +10:00
|
|
|
|
{
|
2025-03-20 19:47:53 +01:00
|
|
|
|
auto& gameState = getGameState();
|
2025-03-05 21:45:04 +01:00
|
|
|
|
if (gLegacyScene == LegacyScene::trackDesigner)
|
2020-04-25 01:19:06 +10:00
|
|
|
|
{
|
2023-01-18 00:13:39 +01:00
|
|
|
|
SetEveryRideTypeInvented();
|
|
|
|
|
|
SetEveryRideEntryInvented();
|
2024-01-19 23:42:44 +01:00
|
|
|
|
|
|
|
|
|
|
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
|
2025-03-20 19:47:53 +01:00
|
|
|
|
gameState.lastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
|
|
|
|
|
|
if (gameState.lastEntranceStyle == kObjectEntryIndexNull)
|
2024-01-19 23:42:44 +01:00
|
|
|
|
{
|
2025-03-20 19:47:53 +01:00
|
|
|
|
gameState.lastEntranceStyle = 0;
|
2024-01-19 23:42:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-20 19:47:53 +01:00
|
|
|
|
gameState.editorStep = EditorStep::RollercoasterDesigner;
|
2023-01-16 13:50:43 +00:00
|
|
|
|
GfxInvalidateScreen();
|
2020-04-25 01:19:06 +10:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-01-18 00:13:39 +01:00
|
|
|
|
SetAllSceneryItemsInvented();
|
2024-07-31 15:54:16 +02:00
|
|
|
|
|
|
|
|
|
|
auto intent = Intent(INTENT_ACTION_SET_DEFAULT_SCENERY_CONFIG);
|
|
|
|
|
|
ContextBroadcastIntent(&intent);
|
|
|
|
|
|
|
2025-03-20 19:47:53 +01:00
|
|
|
|
gameState.editorStep = EditorStep::LandscapeEditor;
|
2023-01-16 13:50:43 +00:00
|
|
|
|
GfxInvalidateScreen();
|
2020-04-25 01:19:06 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-03 00:15:05 +01:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* rct2: 0x006AB54F
|
|
|
|
|
|
*/
|
2023-01-17 13:24:51 +01:00
|
|
|
|
ResultWithMessage WindowEditorObjectSelectionSelectObject(
|
2025-03-25 17:57:28 +01:00
|
|
|
|
uint8_t isMasterObject, EditorInputFlags flags, const ObjectRepositoryItem* item)
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
|
if (item == nullptr)
|
|
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_OBJECT_DATA_NOT_FOUND);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
2017-12-03 00:15:05 +01:00
|
|
|
|
// Get repository item index
|
2018-06-20 17:28:51 +02:00
|
|
|
|
int32_t index = -1;
|
2023-01-17 20:46:55 +01:00
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2018-06-22 23:25:16 +02:00
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (&items[i] == item)
|
|
|
|
|
|
{
|
2017-12-03 00:15:05 +01:00
|
|
|
|
index = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
|
uint8_t* selectionFlags = &_objectSelectionFlags[index];
|
2025-03-25 17:57:28 +01:00
|
|
|
|
if (!flags.has(EditorInputFlag::select))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (!(*selectionFlags & ObjectSelectionFlags::Selected))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return { true };
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (*selectionFlags & ObjectSelectionFlags::InUse)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_CURRENTLY_IN_USE);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (*selectionFlags & ObjectSelectionFlags::AlwaysRequired)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_ALWAYS_REQUIRED);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectType objectType = item->Type;
|
2025-03-25 17:57:28 +01:00
|
|
|
|
if (objectType == ObjectType::sceneryGroup && flags.has(EditorInputFlag::selectObjectsInSceneryGroup))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2018-05-14 13:05:59 +01:00
|
|
|
|
for (const auto& sgEntry : item->SceneryGroupInfo.Entries)
|
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
WindowEditorObjectSelectionSelectObject(++isMasterObject, flags, sgEntry);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-09 11:53:29 +01:00
|
|
|
|
_numSelectedObjectsForType[EnumValue(objectType)]--;
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags &= ~ObjectSelectionFlags::Selected;
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return { true };
|
2018-06-22 23:25:16 +02:00
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
|
|
|
if (isMasterObject == 0)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2025-03-25 17:57:28 +01:00
|
|
|
|
if (flags.has(EditorInputFlag::objectAlwaysRequired))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags |= ObjectSelectionFlags::AlwaysRequired;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
}
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (*selectionFlags & ObjectSelectionFlags::Selected)
|
2021-09-15 22:22:15 +02:00
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return { true };
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
2022-08-10 23:47:13 +02:00
|
|
|
|
if (item->Flags & ObjectItemFlags::IsCompatibilityObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_COMPAT_OBJECT);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-15 22:22:15 +02:00
|
|
|
|
ObjectType objectType = item->Type;
|
2024-03-27 20:13:10 +01:00
|
|
|
|
auto maxObjects = getObjectEntryGroupCount(objectType);
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
|
|
|
if (maxObjects <= _numSelectedObjectsForType[EnumValue(objectType)])
|
|
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
2021-09-15 22:22:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 17:57:28 +01:00
|
|
|
|
if (objectType == ObjectType::sceneryGroup && flags.has(EditorInputFlag::selectObjectsInSceneryGroup))
|
2021-09-15 22:22:15 +02:00
|
|
|
|
{
|
|
|
|
|
|
for (const auto& sgEntry : item->SceneryGroupInfo.Entries)
|
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
const auto selectionResult = WindowEditorObjectSelectionSelectObject(++isMasterObject, flags, sgEntry);
|
2022-07-30 18:04:59 +02:00
|
|
|
|
if (!selectionResult.Successful)
|
2021-09-15 22:22:15 +02:00
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
_gSceneryGroupPartialSelectError = selectionResult.Message;
|
2023-01-18 02:11:56 -06:00
|
|
|
|
LOG_ERROR("Could not find object: %s", std::string(sgEntry.GetName()).c_str());
|
2021-09-15 22:22:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-13 23:07:55 +01:00
|
|
|
|
else if (objectType == ObjectType::water)
|
2021-09-15 22:22:15 +02:00
|
|
|
|
{
|
|
|
|
|
|
// Replace old palette with newly selected palette immediately.
|
|
|
|
|
|
ReplaceSelectedWaterPalette(item);
|
|
|
|
|
|
}
|
2025-02-13 23:07:55 +01:00
|
|
|
|
else if (objectType == ObjectType::peepNames)
|
2024-09-29 15:05:55 +02:00
|
|
|
|
{
|
|
|
|
|
|
PeepUpdateNames();
|
|
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
2025-03-25 17:57:28 +01:00
|
|
|
|
if (isMasterObject != 0 && !flags.has(EditorInputFlag::unk1))
|
2021-09-15 22:22:15 +02:00
|
|
|
|
{
|
|
|
|
|
|
char objectName[64];
|
2023-01-17 20:46:55 +01:00
|
|
|
|
ObjectCreateIdentifierName(objectName, 64, &item->ObjectEntry);
|
2021-09-15 22:22:15 +02:00
|
|
|
|
auto ft = Formatter::Common();
|
|
|
|
|
|
ft.Add<const char*>(objectName);
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_SHOULD_SELECT_X_FIRST);
|
2021-09-15 22:22:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (maxObjects <= _numSelectedObjectsForType[EnumValue(objectType)])
|
|
|
|
|
|
{
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
2021-09-15 22:22:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_numSelectedObjectsForType[EnumValue(objectType)]++;
|
|
|
|
|
|
|
2022-01-19 17:41:24 +00:00
|
|
|
|
*selectionFlags |= ObjectSelectionFlags::Selected;
|
2022-07-30 18:04:59 +02:00
|
|
|
|
return { true };
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
ResultWithMessage WindowEditorObjectSelectionSelectObject(
|
2025-03-25 17:57:28 +01:00
|
|
|
|
uint8_t isMasterObject, EditorInputFlags flags, const ObjectEntryDescriptor& descriptor)
|
2020-11-07 20:28:01 +01:00
|
|
|
|
{
|
|
|
|
|
|
auto& objectRepository = OpenRCT2::GetContext()->GetObjectRepository();
|
2021-09-12 21:25:22 +02:00
|
|
|
|
const auto* item = objectRepository.FindObject(descriptor);
|
2023-01-17 13:24:51 +01:00
|
|
|
|
return WindowEditorObjectSelectionSelectObject(isMasterObject, flags, item);
|
2020-11-07 20:28:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
bool EditorCheckObjectGroupAtLeastOneSelected(ObjectType checkObjectType)
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
auto numObjects = std::min(ObjectRepositoryGetItemsCount(), _objectSelectionFlags.size());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2021-02-12 23:06:05 +01:00
|
|
|
|
for (size_t i = 0; i < numObjects; i++)
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2021-09-12 21:25:22 +02:00
|
|
|
|
auto objectType = items[i].Type;
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (checkObjectType == objectType && (_objectSelectionFlags[i] & ObjectSelectionFlags::Selected))
|
2018-06-22 23:25:16 +02:00
|
|
|
|
{
|
2017-12-03 00:15:05 +01:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-07 13:40:30 +01:00
|
|
|
|
bool EditorCheckObjectGroupAtLeastOneOfPeepTypeSelected(uint8_t peepType)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto numObjects = std::min(ObjectRepositoryGetItemsCount(), _objectSelectionFlags.size());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < numObjects; i++)
|
|
|
|
|
|
{
|
2025-02-13 23:07:55 +01:00
|
|
|
|
const auto isAnimObjectType = items[i].Type == ObjectType::peepAnimations;
|
2024-12-07 13:40:30 +01:00
|
|
|
|
const bool isSelected = _objectSelectionFlags[i] & ObjectSelectionFlags::Selected;
|
|
|
|
|
|
if (isAnimObjectType && isSelected && items[i].PeepAnimationsInfo.PeepType == peepType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
bool EditorCheckObjectGroupAtLeastOneSurfaceSelected(bool queue)
|
2021-09-12 21:25:22 +02:00
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
|
auto numObjects = std::min(ObjectRepositoryGetItemsCount(), _objectSelectionFlags.size());
|
|
|
|
|
|
const auto* items = ObjectRepositoryGetItems();
|
2021-09-12 21:25:22 +02:00
|
|
|
|
for (size_t i = 0; i < numObjects; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
const auto& ori = items[i];
|
|
|
|
|
|
auto isQueue = (ori.FootpathSurfaceInfo.Flags & FOOTPATH_ENTRY_FLAG_IS_QUEUE) != 0;
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (ori.Type == ObjectType::footpathSurface && (_objectSelectionFlags[i] & ObjectSelectionFlags::Selected)
|
2021-09-12 21:25:22 +02:00
|
|
|
|
&& queue == isQueue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-17 13:24:51 +01:00
|
|
|
|
int32_t EditorRemoveUnusedObjects()
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2023-01-17 19:05:14 +01:00
|
|
|
|
Sub6AB211();
|
2023-01-17 13:24:51 +01:00
|
|
|
|
SetupInUseSelectionFlags();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
|
int32_t numObjects = static_cast<int32_t>(ObjectRepositoryGetItemsCount());
|
|
|
|
|
|
const ObjectRepositoryItem* items = ObjectRepositoryGetItems();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
|
int32_t numUnselectedObjects = 0;
|
|
|
|
|
|
for (int32_t i = 0; i < numObjects; i++)
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (_objectSelectionFlags[i] & ObjectSelectionFlags::Selected)
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2022-01-19 17:41:24 +00:00
|
|
|
|
if (!(_objectSelectionFlags[i] & ObjectSelectionFlags::InUse)
|
|
|
|
|
|
&& !(_objectSelectionFlags[i] & ObjectSelectionFlags::AlwaysRequired))
|
2017-12-03 00:15:05 +01:00
|
|
|
|
{
|
2019-10-01 21:30:11 +01:00
|
|
|
|
const ObjectRepositoryItem* item = &items[i];
|
2021-09-12 21:25:22 +02:00
|
|
|
|
ObjectType objectType = item->Type;
|
2023-03-02 20:26:19 +01:00
|
|
|
|
if (ObjectTypeIsIntransient(objectType))
|
|
|
|
|
|
continue;
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
2024-08-05 01:02:16 +02:00
|
|
|
|
// The water type controls the entire palette. Removing that object can badly break the game state.
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (objectType == ObjectType::water)
|
2019-10-01 21:30:11 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
|
2024-10-23 11:24:14 +02:00
|
|
|
|
// Avoid the used peep names object being deleted as no in-use checks are performed.
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (objectType == ObjectType::peepNames)
|
2024-10-23 11:24:14 +02:00
|
|
|
|
continue;
|
|
|
|
|
|
|
2024-12-29 21:04:41 +01:00
|
|
|
|
// Avoid deleting peep animation objects, as it ensures we don't delete the last ones for a kind of peep.
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (objectType == ObjectType::peepAnimations)
|
2024-12-29 21:04:41 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
|
2025-03-01 19:34:30 +01:00
|
|
|
|
// Avoid deleting climate objects, as they're not bound to entities.
|
|
|
|
|
|
if (objectType == ObjectType::climate)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
2023-03-18 14:52:36 +01:00
|
|
|
|
// It’s hard to determine exactly if a scenery group is used, so do not remove these automatically.
|
2025-02-13 23:07:55 +01:00
|
|
|
|
if (objectType == ObjectType::sceneryGroup)
|
2023-03-18 14:52:36 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
|
2020-11-09 12:07:38 +01:00
|
|
|
|
_numSelectedObjectsForType[EnumValue(objectType)]--;
|
2022-01-19 17:41:24 +00:00
|
|
|
|
_objectSelectionFlags[i] &= ~ObjectSelectionFlags::Selected;
|
2019-10-01 21:30:11 +01:00
|
|
|
|
numUnselectedObjects++;
|
|
|
|
|
|
}
|
2017-12-03 00:15:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-17 13:24:51 +01:00
|
|
|
|
UnloadUnselectedObjects();
|
2025-03-22 22:59:40 +01:00
|
|
|
|
EditorObjectFlagsClear();
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
|
|
|
|
|
auto intent = Intent(INTENT_ACTION_REFRESH_SCENERY);
|
2022-11-06 20:49:07 +00:00
|
|
|
|
ContextBroadcastIntent(&intent);
|
2017-12-03 00:15:05 +01:00
|
|
|
|
|
|
|
|
|
|
return numUnselectedObjects;
|
|
|
|
|
|
}
|