![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Manages the global pool of ConditionPreset objects. More...
#include <ConditionPresetRegistry.h>
Public Member Functions | |
| ConditionPresetRegistry ()=default | |
| ConditionPresetRegistry (const ConditionPresetRegistry &)=delete | |
| ConditionPresetRegistry & | operator= (const ConditionPresetRegistry &)=delete |
| std::string | CreatePreset (const ConditionPreset &preset) |
| Adds a preset to the registry. | |
| ConditionPreset * | GetPreset (const std::string &id) |
| Returns a mutable pointer to the preset, or nullptr if not found. | |
| const ConditionPreset * | GetPreset (const std::string &id) const |
| Returns a const pointer to the preset, or nullptr if not found. | |
| void | UpdatePreset (const std::string &id, const ConditionPreset &updated) |
| Replaces the data of an existing preset (id must already exist). | |
| void | DeletePreset (const std::string &id) |
| Removes a preset from the registry. | |
| std::string | DuplicatePreset (const std::string &id) |
| Creates an independent copy of an existing preset with a new UUID. | |
| std::vector< std::string > | GetAllPresetIDs () const |
| Returns all preset UUIDs in display order. | |
| size_t | GetPresetCount () const |
| Returns the total number of presets in the registry. | |
| std::vector< std::string > | FindPresetsByName (const std::string &substring) const |
| Returns UUIDs of all presets whose name contains a substring. | |
| std::vector< ConditionPreset > | GetFilteredPresets (const std::string &filter) const |
| Returns all presets whose name contains the filter substring. | |
| bool | ValidatePresetID (const std::string &id) const |
| Returns true when a preset with the given UUID exists. | |
| std::vector< std::string > | GetAllErrors () const |
| Returns all error messages accumulated since the last Clear(). | |
| void | Clear () |
| Clears all presets and resets error state. | |
| bool | Load (const std::string &filepath) |
| Loads presets from a JSON file (clears existing data first). | |
| void | LoadFromPresetList (const std::vector< ConditionPreset > &presets) |
| Loads presets from a vector of ConditionPreset objects (clears existing data first). | |
| bool | Save (const std::string &filepath) const |
| Saves all presets to a JSON file. | |
Static Private Member Functions | |
| static std::string | GenerateID () |
| Generates a new UUID suitable for a preset ID. | |
Private Attributes | |
| std::map< std::string, ConditionPreset > | m_presets |
| UUID -> ConditionPreset. | |
| std::vector< std::string > | m_order |
| UUIDs in insertion order. | |
| std::vector< std::string > | m_errors |
| Accumulated error messages. | |
Manages the global pool of ConditionPreset objects.
Presets are stored in insertion order using a std::map keyed by UUID. An ordered list (m_order) preserves display order in the UI.
Definition at line 48 of file ConditionPresetRegistry.h.
|
default |
|
delete |
| void Olympe::ConditionPresetRegistry::Clear | ( | ) |
Clears all presets and resets error state.
Definition at line 166 of file ConditionPresetRegistry.cpp.
References m_errors, m_order, and m_presets.
Referenced by Load(), LoadFromPresetList(), and Olympe::VisualScriptEditorPanel::LoadTemplate().
Here is the caller graph for this function:| std::string Olympe::ConditionPresetRegistry::CreatePreset | ( | const ConditionPreset & | preset | ) |
Adds a preset to the registry.
If preset.id is empty a new UUID is generated. If the ID already exists the operation is a no-op and the existing ID is returned.
| preset | Preset to add (id may be empty — will be assigned). |
Definition at line 27 of file ConditionPresetRegistry.cpp.
References GenerateID(), GetComponentTypeID_Static(), Olympe::ConditionPreset::id, m_order, and m_presets.
Referenced by DuplicatePreset(), and Olympe::ConditionPresetLibraryPanel::OnAddPresetClicked().
Here is the call graph for this function:
Here is the caller graph for this function:Removes a preset from the registry.
If the ID is not found, the call is a no-op.
| id | Preset UUID to remove. |
Definition at line 74 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), m_order, and m_presets.
Referenced by Olympe::ConditionPresetLibraryPanel::OnDeleteConfirmed().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string Olympe::ConditionPresetRegistry::DuplicatePreset | ( | const std::string & | id | ) |
Creates an independent copy of an existing preset with a new UUID.
The copy's name is suffixed with " (Copy)". Returns the new UUID, or an empty string if the source ID is not found.
| id | Source preset UUID. |
Definition at line 84 of file ConditionPresetRegistry.cpp.
References CreatePreset(), GetComponentTypeID_Static(), GetPreset(), and Olympe::ConditionPreset::id.
Referenced by Olympe::ConditionPresetLibraryPanel::OnDuplicatePresetClicked().
Here is the call graph for this function:
Here is the caller graph for this function:| std::vector< std::string > Olympe::ConditionPresetRegistry::FindPresetsByName | ( | const std::string & | substring | ) | const |
Returns UUIDs of all presets whose name contains a substring.
Case-sensitive search.
| substring | Search string. |
Definition at line 112 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), m_order, and m_presets.
Referenced by Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown(), and Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Generates a new UUID suitable for a preset ID.
Definition at line 285 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static().
Referenced by CreatePreset().
Here is the call graph for this function:
Here is the caller graph for this function:| std::vector< std::string > Olympe::ConditionPresetRegistry::GetAllErrors | ( | ) | const |
Returns all error messages accumulated since the last Clear().
Definition at line 161 of file ConditionPresetRegistry.cpp.
References m_errors.
| std::vector< std::string > Olympe::ConditionPresetRegistry::GetAllPresetIDs | ( | ) | const |
Returns all preset UUIDs in display order.
Definition at line 101 of file ConditionPresetRegistry.cpp.
References m_order.
Referenced by Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown(), Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown(), and Olympe::VisualScriptEditorPanel::SyncPresetsFromRegistryToTemplate().
Here is the caller graph for this function:| std::vector< ConditionPreset > Olympe::ConditionPresetRegistry::GetFilteredPresets | ( | const std::string & | filter | ) | const |
Returns all presets whose name contains the filter substring.
If filter is empty, returns all presets in display order. Case-sensitive search.
| filter | Search string (empty = match all). |
Definition at line 129 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), m_order, and m_presets.
Referenced by Olympe::ConditionPresetLibraryPanel::GetFilteredPresets(), Olympe::PresetDropdownHelper::GetVisiblePresetCount(), Olympe::PresetDropdownHelper::Render(), and Olympe::NodeConditionsPanel::RenderInlineAddCondition().
Here is the call graph for this function:
Here is the caller graph for this function:| ConditionPreset * Olympe::ConditionPresetRegistry::GetPreset | ( | const std::string & | id | ) |
Returns a mutable pointer to the preset, or nullptr if not found.
| id | Preset UUID. |
Definition at line 43 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), and m_presets.
Referenced by Olympe::NodeConditionsPanel::AddCondition(), DuplicatePreset(), Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown(), Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown(), Olympe::PresetDropdownHelper::GetPresetDisplayName(), Olympe::PresetDropdownHelper::Render(), Olympe::NodeConditionsEditModal::RenderConditionRow(), Olympe::NodeConditionsPanel::RenderConditionsPreview(), Olympe::NodeBranchRenderer::RenderConditionsSection(), Olympe::ConditionPresetLibraryPanel::RenderDeleteConfirmationDialog(), Olympe::NodeConditionsPanel::RenderInlineConditionRow(), Olympe::DynamicDataPinManager::SyncPins(), and Olympe::VisualScriptEditorPanel::SyncPresetsFromRegistryToTemplate().
Here is the call graph for this function:
Here is the caller graph for this function:| const ConditionPreset * Olympe::ConditionPresetRegistry::GetPreset | ( | const std::string & | id | ) | const |
Returns a const pointer to the preset, or nullptr if not found.
| id | Preset UUID. |
Definition at line 52 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), and m_presets.
Here is the call graph for this function:| size_t Olympe::ConditionPresetRegistry::GetPresetCount | ( | ) | const |
Returns the total number of presets in the registry.
Definition at line 106 of file ConditionPresetRegistry.cpp.
References m_presets.
Loads presets from a JSON file (clears existing data first).
Expected format:
| filepath | Path to the JSON file. |
Definition at line 177 of file ConditionPresetRegistry.cpp.
References Clear(), Olympe::ConditionPreset::FromJson(), GetComponentTypeID_Static(), m_errors, m_order, and m_presets.
Referenced by Olympe::VSGraphExecutor::HandleBranch().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::ConditionPresetRegistry::LoadFromPresetList | ( | const std::vector< ConditionPreset > & | presets | ) |
Loads presets from a vector of ConditionPreset objects (clears existing data first).
Phase 24 — Supports graph-embedded presets. This method is used when presets are deserialized from a blueprint JSON instead of from an external file. Each preset's UUID is preserved from the preset object itself.
| presets | Vector of ConditionPreset objects to load. |
Definition at line 263 of file ConditionPresetRegistry.cpp.
References Clear(), GetComponentTypeID_Static(), m_order, and m_presets.
Referenced by Olympe::VisualScriptEditorPanel::Initialize(), and Olympe::VisualScriptEditorPanel::LoadTemplate().
Here is the call graph for this function:
Here is the caller graph for this function:
|
delete |
Saves all presets to a JSON file.
Creates the file if it does not exist; overwrites if it does. Parent directories must already exist.
| filepath | Destination path. |
Definition at line 232 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), m_errors, m_order, and m_presets.
Referenced by Olympe::ConditionPresetLibraryPanel::OnAddPresetClicked(), Olympe::ConditionPresetLibraryPanel::OnDeleteConfirmed(), and Olympe::ConditionPresetLibraryPanel::OnDuplicatePresetClicked().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::ConditionPresetRegistry::UpdatePreset | ( | const std::string & | id, |
| const ConditionPreset & | updated | ||
| ) |
Replaces the data of an existing preset (id must already exist).
If the ID is not found, logs an error and returns without modifying state. The preset's id field in updated is forced to match id.
| id | Preset UUID to update. |
| updated | New preset data. |
Definition at line 60 of file ConditionPresetRegistry.cpp.
References GetComponentTypeID_Static(), Olympe::ConditionPreset::id, m_errors, and m_presets.
Here is the call graph for this function:Returns true when a preset with the given UUID exists.
Definition at line 156 of file ConditionPresetRegistry.cpp.
References m_presets.
Referenced by Olympe::NodeConditionsPanel::Validate().
Here is the caller graph for this function:
|
mutableprivate |
Accumulated error messages.
Definition at line 214 of file ConditionPresetRegistry.h.
Referenced by Clear(), GetAllErrors(), Load(), Save(), and UpdatePreset().
|
private |
UUIDs in insertion order.
Definition at line 213 of file ConditionPresetRegistry.h.
Referenced by Clear(), CreatePreset(), DeletePreset(), FindPresetsByName(), GetAllPresetIDs(), GetFilteredPresets(), Load(), LoadFromPresetList(), and Save().
|
private |
UUID -> ConditionPreset.
Definition at line 212 of file ConditionPresetRegistry.h.
Referenced by Clear(), CreatePreset(), DeletePreset(), FindPresetsByName(), GetFilteredPresets(), GetPreset(), GetPreset(), GetPresetCount(), Load(), LoadFromPresetList(), Save(), UpdatePreset(), and ValidatePresetID().