diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 05ce2a82e2..d3a6649541 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -615,7 +615,7 @@ namespace OpenRCT2::Ui::Windows if (gLegacyScene == LegacyScene::trackDesignsManager) { const auto objectSelectResult = WindowEditorObjectSelectionSelectObject( - 0, INPUT_FLAG_EDITOR_OBJECT_SELECT, listItem->repositoryItem); + 0, { EditorInputFlag::select }, listItem->repositoryItem); if (!objectSelectResult.Successful) return; @@ -636,17 +636,17 @@ namespace OpenRCT2::Ui::Windows return; } - uint32_t inputFlags = INPUT_FLAG_EDITOR_OBJECT_1 | INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP; + EditorInputFlags inputFlags = { EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup }; // If already selected if (!(object_selection_flags & ObjectSelectionFlags::Selected)) - inputFlags |= INPUT_FLAG_EDITOR_OBJECT_SELECT; + inputFlags.set(EditorInputFlag::select); _gSceneryGroupPartialSelectError = std::nullopt; const auto objectSelectResult = WindowEditorObjectSelectionSelectObject(0, inputFlags, listItem->repositoryItem); if (!objectSelectResult.Successful) { - StringId error_title = (inputFlags & INPUT_FLAG_EDITOR_OBJECT_SELECT) ? STR_UNABLE_TO_SELECT_THIS_OBJECT - : STR_UNABLE_TO_DE_SELECT_THIS_OBJECT; + StringId error_title = (inputFlags.has(EditorInputFlag::select)) ? STR_UNABLE_TO_SELECT_THIS_OBJECT + : STR_UNABLE_TO_DE_SELECT_THIS_OBJECT; ContextShowError(error_title, objectSelectResult.Message, {}); return; diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index f3a6d02add..90c182f1c6 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -438,17 +438,13 @@ static void selectScenarioEditorObjects() for (auto designerSelectedObject : kCommonScenarioAndTrackDesignerObjects) { WindowEditorObjectSelectionSelectObject( - 0, - INPUT_FLAG_EDITOR_OBJECT_SELECT | INPUT_FLAG_EDITOR_OBJECT_1 - | INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP, + 0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup }, ObjectEntryDescriptor(designerSelectedObject)); } for (auto defaultSelectedObject : kDefaultScenarioObjects) { WindowEditorObjectSelectionSelectObject( - 0, - INPUT_FLAG_EDITOR_OBJECT_SELECT | INPUT_FLAG_EDITOR_OBJECT_1 - | INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP, + 0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup }, ObjectEntryDescriptor(defaultSelectedObject)); } } @@ -461,9 +457,7 @@ static void selectTrackDesignerObjects() for (auto designerSelectedObject : kCommonScenarioAndTrackDesignerObjects) { WindowEditorObjectSelectionSelectObject( - 0, - INPUT_FLAG_EDITOR_OBJECT_SELECT | INPUT_FLAG_EDITOR_OBJECT_1 - | INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP, + 0, { EditorInputFlag::select, EditorInputFlag::unk1, EditorInputFlag::selectObjectsInSceneryGroup }, ObjectEntryDescriptor(designerSelectedObject)); } } @@ -552,7 +546,7 @@ void FinishObjectSelection() * rct2: 0x006AB54F */ ResultWithMessage WindowEditorObjectSelectionSelectObject( - uint8_t isMasterObject, int32_t flags, const ObjectRepositoryItem* item) + uint8_t isMasterObject, EditorInputFlags flags, const ObjectRepositoryItem* item) { if (item == nullptr) { @@ -572,7 +566,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( } uint8_t* selectionFlags = &_objectSelectionFlags[index]; - if (!(flags & INPUT_FLAG_EDITOR_OBJECT_SELECT)) + if (!flags.has(EditorInputFlag::select)) { if (!(*selectionFlags & ObjectSelectionFlags::Selected)) { @@ -590,7 +584,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( } ObjectType objectType = item->Type; - if (objectType == ObjectType::sceneryGroup && (flags & INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP)) + if (objectType == ObjectType::sceneryGroup && flags.has(EditorInputFlag::selectObjectsInSceneryGroup)) { for (const auto& sgEntry : item->SceneryGroupInfo.Entries) { @@ -605,7 +599,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( if (isMasterObject == 0) { - if (flags & INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED) + if (flags.has(EditorInputFlag::objectAlwaysRequired)) { *selectionFlags |= ObjectSelectionFlags::AlwaysRequired; } @@ -629,7 +623,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( return ObjectSelectionError(isMasterObject, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED); } - if (objectType == ObjectType::sceneryGroup && (flags & INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP)) + if (objectType == ObjectType::sceneryGroup && flags.has(EditorInputFlag::selectObjectsInSceneryGroup)) { for (const auto& sgEntry : item->SceneryGroupInfo.Entries) { @@ -651,7 +645,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( PeepUpdateNames(); } - if (isMasterObject != 0 && !(flags & INPUT_FLAG_EDITOR_OBJECT_1)) + if (isMasterObject != 0 && !flags.has(EditorInputFlag::unk1)) { char objectName[64]; ObjectCreateIdentifierName(objectName, 64, &item->ObjectEntry); @@ -672,7 +666,7 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject( } ResultWithMessage WindowEditorObjectSelectionSelectObject( - uint8_t isMasterObject, int32_t flags, const ObjectEntryDescriptor& descriptor) + uint8_t isMasterObject, EditorInputFlags flags, const ObjectEntryDescriptor& descriptor) { auto& objectRepository = OpenRCT2::GetContext()->GetObjectRepository(); const auto* item = objectRepository.FindObject(descriptor); diff --git a/src/openrct2/EditorObjectSelectionSession.h b/src/openrct2/EditorObjectSelectionSession.h index b6af31af1e..6dfc3f7507 100644 --- a/src/openrct2/EditorObjectSelectionSession.h +++ b/src/openrct2/EditorObjectSelectionSession.h @@ -10,19 +10,21 @@ #pragma once #include "core/EnumUtils.hpp" +#include "core/FlagHolder.hpp" #include "object/Object.h" #include struct ResultWithMessage; -enum EDITOR_INPUT_FLAGS +enum class EditorInputFlag : uint8_t { - INPUT_FLAG_EDITOR_OBJECT_SELECT = (1 << 0), // Set when you want to select an object, not set when you want to deselect it. - INPUT_FLAG_EDITOR_OBJECT_1 = (1 << 1), - INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP = (1 << 2), - INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED = (1 << 3) + select, // Set when you want to select an object, not set when you want to deselect it. + unk1, + selectObjectsInSceneryGroup, + objectAlwaysRequired, }; +using EditorInputFlags = FlagHolder; extern std::optional _gSceneryGroupPartialSelectError; extern std::vector _objectSelectionFlags; @@ -37,9 +39,9 @@ void Sub6AB211(); void ResetSelectedObjectCountAndSize(); void FinishObjectSelection(); ResultWithMessage WindowEditorObjectSelectionSelectObject( - uint8_t isMasterObject, int32_t flags, const ObjectRepositoryItem* item); + uint8_t isMasterObject, EditorInputFlags flags, const ObjectRepositoryItem* item); ResultWithMessage WindowEditorObjectSelectionSelectObject( - uint8_t isMasterObject, int32_t flags, const ObjectEntryDescriptor& entry); + uint8_t isMasterObject, EditorInputFlags flags, const ObjectEntryDescriptor& entry); /** * Removes all unused objects from the object selection.