Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Olympe::ConditionPresetLibraryPanel Class Reference

ImGui panel for creating, editing, duplicating, and deleting global condition presets. More...

#include <ConditionPresetLibraryPanel.h>

+ Collaboration diagram for Olympe::ConditionPresetLibraryPanel:

Public Member Functions

 ConditionPresetLibraryPanel (ConditionPresetRegistry &registry)
 Constructs the panel with a reference to the preset registry.
 
 ~ConditionPresetLibraryPanel ()=default
 
 ConditionPresetLibraryPanel (const ConditionPresetLibraryPanel &)=delete
 
ConditionPresetLibraryPaneloperator= (const ConditionPresetLibraryPanel &)=delete
 
bool IsOpen () const
 Returns true if the panel window is open.
 
void Open ()
 Opens the panel window.
 
void Close ()
 Closes the panel window.
 
void Render ()
 Renders the full panel window using ImGui.
 
void SetSearchFilter (const std::string &filter)
 Sets the search filter string (case-insensitive substring).
 
const std::string & GetSearchFilter () const
 Returns the current search filter string.
 
void SetSelectedPresetID (const std::string &id)
 Selects the preset with the given ID.
 
const std::string & GetSelectedPresetID () const
 Returns the currently selected preset ID (empty if none).
 
bool IsDeleteConfirmationVisible () const
 Returns true if the delete confirmation dialog is currently shown.
 
const std::string & GetPresetToDelete () const
 Returns the ID of the preset pending deletion confirmation.
 
ConditionPresetRegistryGetRegistry ()
 Returns a reference to the registry managed by this panel.
 
std::vector< ConditionPresetGetFilteredPresets () const
 Returns filtered presets based on the current search filter.
 
void SetReferenceMap (const std::map< std::string, std::vector< std::string > > &refMap)
 Sets the reference analysis map (nodeID -> list of preset IDs used).
 
std::vector< std::string > GetReferencingNodes (const std::string &presetID) const
 Returns a list of node IDs that reference the given preset.
 
std::string OnAddPresetClicked ()
 Handles the "Add Preset" button.
 
std::string OnDuplicatePresetClicked (const std::string &presetID)
 Handles the "Duplicate" button for a preset.
 
void OnDeletePresetClicked (const std::string &presetID)
 Handles the "Delete" button for a preset.
 
void OnDeleteConfirmed (const std::string &presetID)
 Confirms the pending deletion.
 
void OnDeleteCancelled ()
 Cancels the pending deletion and hides the confirmation dialog.
 
void OnPresetSelected (const std::string &presetID)
 Selects a preset (highlights it in the list).
 

Public Attributes

std::function< void(const std::string &)> OnPresetCreated
 Invoked after a new preset is added.
 
std::function< void(const std::string &)> OnPresetModified
 Invoked after an existing preset is modified.
 
std::function< void(const std::string &)> OnPresetDeleted
 Invoked after a preset is deleted.
 

Private Member Functions

void RenderToolbar ()
 
void RenderPresetList ()
 
void RenderPresetItem (const std::string &presetID, const ConditionPreset &preset)
 
void RenderDeleteConfirmationDialog ()
 
void RenderReferenceAnalysis (const std::string &presetID)
 

Private Attributes

ConditionPresetRegistrym_registry
 Global preset registry.
 
bool m_isOpen = false
 
std::string m_selectedPresetID
 Highlighted preset ID.
 
std::string m_searchFilter
 Current search text.
 
bool m_showDeleteConfirmation = false
 
std::string m_presetToDelete
 ID queued for deletion.
 
std::map< std::string, std::vector< std::string > > m_refMap
 External reference map: nodeID -> list of preset IDs that node references.
 

Detailed Description

ImGui panel for creating, editing, duplicating, and deleting global condition presets.

The panel uses ConditionPresetEditDialog internally for the create/edit workflow. Deletion requires confirmation via a modal dialog.

Optional callbacks allow the host (e.g. the Blueprint Editor) to react to preset lifecycle events:

Definition at line 58 of file ConditionPresetLibraryPanel.h.

Constructor & Destructor Documentation

◆ ConditionPresetLibraryPanel() [1/2]

Olympe::ConditionPresetLibraryPanel::ConditionPresetLibraryPanel ( ConditionPresetRegistry registry)
explicit

Constructs the panel with a reference to the preset registry.

Parameters
registryThe global ConditionPresetRegistry to operate on.

Definition at line 27 of file ConditionPresetLibraryPanel.cpp.

◆ ~ConditionPresetLibraryPanel()

Olympe::ConditionPresetLibraryPanel::~ConditionPresetLibraryPanel ( )
default

◆ ConditionPresetLibraryPanel() [2/2]

Olympe::ConditionPresetLibraryPanel::ConditionPresetLibraryPanel ( const ConditionPresetLibraryPanel )
delete

Member Function Documentation

◆ Close()

void Olympe::ConditionPresetLibraryPanel::Close ( )
inline

Closes the panel window.

Definition at line 84 of file ConditionPresetLibraryPanel.h.

References m_isOpen.

◆ GetFilteredPresets()

std::vector< ConditionPreset > Olympe::ConditionPresetLibraryPanel::GetFilteredPresets ( ) const

Returns filtered presets based on the current search filter.

Delegates to ConditionPresetRegistry::GetFilteredPresets().

Definition at line 60 of file ConditionPresetLibraryPanel.cpp.

References Olympe::ConditionPresetRegistry::GetFilteredPresets(), m_registry, and m_searchFilter.

Referenced by RenderPresetList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPresetToDelete()

const std::string & Olympe::ConditionPresetLibraryPanel::GetPresetToDelete ( ) const
inline

Returns the ID of the preset pending deletion confirmation.

Definition at line 145 of file ConditionPresetLibraryPanel.h.

References m_presetToDelete.

◆ GetReferencingNodes()

std::vector< std::string > Olympe::ConditionPresetLibraryPanel::GetReferencingNodes ( const std::string &  presetID) const

Returns a list of node IDs that reference the given preset.

Parameters
presetIDPreset ID to query.

Definition at line 76 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), and m_refMap.

Referenced by RenderDeleteConfirmationDialog(), and RenderReferenceAnalysis().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRegistry()

ConditionPresetRegistry & Olympe::ConditionPresetLibraryPanel::GetRegistry ( )
inline

Returns a reference to the registry managed by this panel.

Definition at line 150 of file ConditionPresetLibraryPanel.h.

References m_registry.

◆ GetSearchFilter()

const std::string & Olympe::ConditionPresetLibraryPanel::GetSearchFilter ( ) const
inline

Returns the current search filter string.

Definition at line 124 of file ConditionPresetLibraryPanel.h.

References m_searchFilter.

◆ GetSelectedPresetID()

const std::string & Olympe::ConditionPresetLibraryPanel::GetSelectedPresetID ( ) const
inline

Returns the currently selected preset ID (empty if none).

Definition at line 135 of file ConditionPresetLibraryPanel.h.

References m_selectedPresetID.

◆ IsDeleteConfirmationVisible()

bool Olympe::ConditionPresetLibraryPanel::IsDeleteConfirmationVisible ( ) const
inline

Returns true if the delete confirmation dialog is currently shown.

Definition at line 140 of file ConditionPresetLibraryPanel.h.

References m_showDeleteConfirmation.

◆ IsOpen()

bool Olympe::ConditionPresetLibraryPanel::IsOpen ( ) const
inline

Returns true if the panel window is open.

Definition at line 78 of file ConditionPresetLibraryPanel.h.

References m_isOpen.

◆ OnAddPresetClicked()

std::string Olympe::ConditionPresetLibraryPanel::OnAddPresetClicked ( )

Handles the "Add Preset" button.

Creates a new empty ConditionPreset in the registry. Fires OnPresetCreated with the new ID.

Returns
The new preset's ID.

Definition at line 101 of file ConditionPresetLibraryPanel.cpp.

References Olympe::Operand::CreateConst(), Olympe::ConditionPresetRegistry::CreatePreset(), Olympe::Operand::CreateVariable(), Olympe::Equal, GetComponentTypeID_Static(), m_registry, m_selectedPresetID, Olympe::ConditionPreset::name, OnPresetCreated, ResolveResourcePath(), and Olympe::ConditionPresetRegistry::Save().

+ Here is the call graph for this function:

◆ OnDeleteCancelled()

void Olympe::ConditionPresetLibraryPanel::OnDeleteCancelled ( )

Cancels the pending deletion and hides the confirmation dialog.

Definition at line 176 of file ConditionPresetLibraryPanel.cpp.

References m_presetToDelete, and m_showDeleteConfirmation.

Referenced by RenderDeleteConfirmationDialog().

+ Here is the caller graph for this function:

◆ OnDeleteConfirmed()

void Olympe::ConditionPresetLibraryPanel::OnDeleteConfirmed ( const std::string &  presetID)

Confirms the pending deletion.

Removes the preset from the registry and fires OnPresetDeleted. Resets m_showDeleteConfirmation to false.

Parameters
presetIDID of the preset to delete (must match m_presetToDelete).

Definition at line 149 of file ConditionPresetLibraryPanel.cpp.

References Olympe::ConditionPresetRegistry::DeletePreset(), m_presetToDelete, m_registry, m_selectedPresetID, m_showDeleteConfirmation, OnPresetDeleted, ResolveResourcePath(), and Olympe::ConditionPresetRegistry::Save().

Referenced by RenderDeleteConfirmationDialog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnDeletePresetClicked()

void Olympe::ConditionPresetLibraryPanel::OnDeletePresetClicked ( const std::string &  presetID)

Handles the "Delete" button for a preset.

Sets m_showDeleteConfirmation = true and records m_presetToDelete. Does NOT delete immediately; call OnDeleteConfirmed() to confirm.

Parameters
presetIDID of the preset the user wants to delete.

Definition at line 143 of file ConditionPresetLibraryPanel.cpp.

References m_presetToDelete, and m_showDeleteConfirmation.

Referenced by RenderPresetItem().

+ Here is the caller graph for this function:

◆ OnDuplicatePresetClicked()

std::string Olympe::ConditionPresetLibraryPanel::OnDuplicatePresetClicked ( const std::string &  presetID)

Handles the "Duplicate" button for a preset.

Duplicates the preset in the registry. Fires OnPresetCreated with the new ID.

Parameters
presetIDID of the preset to duplicate.
Returns
The new preset's ID, or empty string if presetID not found.

Definition at line 126 of file ConditionPresetLibraryPanel.cpp.

References Olympe::ConditionPresetRegistry::DuplicatePreset(), GetComponentTypeID_Static(), m_registry, OnPresetCreated, ResolveResourcePath(), and Olympe::ConditionPresetRegistry::Save().

Referenced by RenderPresetItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnPresetSelected()

void Olympe::ConditionPresetLibraryPanel::OnPresetSelected ( const std::string &  presetID)

Selects a preset (highlights it in the list).

Parameters
presetIDID of the preset to select.

Definition at line 51 of file ConditionPresetLibraryPanel.cpp.

References m_selectedPresetID.

Referenced by RenderPresetItem().

+ Here is the caller graph for this function:

◆ Open()

void Olympe::ConditionPresetLibraryPanel::Open ( )
inline

Opens the panel window.

Definition at line 81 of file ConditionPresetLibraryPanel.h.

References m_isOpen.

◆ operator=()

ConditionPresetLibraryPanel & Olympe::ConditionPresetLibraryPanel::operator= ( const ConditionPresetLibraryPanel )
delete

◆ Render()

void Olympe::ConditionPresetLibraryPanel::Render ( )

Renders the full panel window using ImGui.

Must be called once per frame while the panel is open. No-op when !IsOpen().

Definition at line 186 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), m_isOpen, m_showDeleteConfirmation, RenderDeleteConfirmationDialog(), RenderPresetList(), and RenderToolbar().

+ Here is the call graph for this function:

◆ RenderDeleteConfirmationDialog()

void Olympe::ConditionPresetLibraryPanel::RenderDeleteConfirmationDialog ( )
private

Definition at line 291 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), GetReferencingNodes(), m_presetToDelete, m_registry, OnDeleteCancelled(), and OnDeleteConfirmed().

Referenced by Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderPresetItem()

void Olympe::ConditionPresetLibraryPanel::RenderPresetItem ( const std::string &  presetID,
const ConditionPreset preset 
)
private

Definition at line 247 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), m_selectedPresetID, OnDeletePresetClicked(), OnDuplicatePresetClicked(), OnPresetSelected(), and RenderReferenceAnalysis().

Referenced by RenderPresetList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderPresetList()

void Olympe::ConditionPresetLibraryPanel::RenderPresetList ( )
private

Definition at line 235 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), GetFilteredPresets(), and RenderPresetItem().

Referenced by Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderReferenceAnalysis()

void Olympe::ConditionPresetLibraryPanel::RenderReferenceAnalysis ( const std::string &  presetID)
private

Definition at line 328 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), and GetReferencingNodes().

Referenced by RenderPresetItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderToolbar()

void Olympe::ConditionPresetLibraryPanel::RenderToolbar ( )
private

Definition at line 215 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), and m_searchFilter.

Referenced by Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetReferenceMap()

void Olympe::ConditionPresetLibraryPanel::SetReferenceMap ( const std::map< std::string, std::vector< std::string > > &  refMap)

Sets the reference analysis map (nodeID -> list of preset IDs used).

This data is supplied externally by the host (e.g. Blueprint Editor) and used to display "Used by: Node_A, Node_C" in the panel.

Parameters
refMapMap from nodeID to vector of preset IDs that node uses.

Definition at line 69 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), and m_refMap.

+ Here is the call graph for this function:

◆ SetSearchFilter()

void Olympe::ConditionPresetLibraryPanel::SetSearchFilter ( const std::string &  filter)

Sets the search filter string (case-insensitive substring).

Parameters
filterFilter text. Empty string shows all presets.

Definition at line 37 of file ConditionPresetLibraryPanel.cpp.

References GetComponentTypeID_Static(), and m_searchFilter.

+ Here is the call graph for this function:

◆ SetSelectedPresetID()

void Olympe::ConditionPresetLibraryPanel::SetSelectedPresetID ( const std::string &  id)

Selects the preset with the given ID.

Parameters
idPreset ID to select, or empty string to deselect.

Definition at line 46 of file ConditionPresetLibraryPanel.cpp.

References m_selectedPresetID.

Member Data Documentation

◆ m_isOpen

bool Olympe::ConditionPresetLibraryPanel::m_isOpen = false
private

Definition at line 248 of file ConditionPresetLibraryPanel.h.

Referenced by Close(), IsOpen(), Open(), and Render().

◆ m_presetToDelete

std::string Olympe::ConditionPresetLibraryPanel::m_presetToDelete
private

◆ m_refMap

std::map<std::string, std::vector<std::string> > Olympe::ConditionPresetLibraryPanel::m_refMap
private

External reference map: nodeID -> list of preset IDs that node references.

Definition at line 255 of file ConditionPresetLibraryPanel.h.

Referenced by GetReferencingNodes(), and SetReferenceMap().

◆ m_registry

ConditionPresetRegistry& Olympe::ConditionPresetLibraryPanel::m_registry
private

◆ m_searchFilter

std::string Olympe::ConditionPresetLibraryPanel::m_searchFilter
private

Current search text.

Definition at line 250 of file ConditionPresetLibraryPanel.h.

Referenced by GetFilteredPresets(), GetSearchFilter(), RenderToolbar(), and SetSearchFilter().

◆ m_selectedPresetID

std::string Olympe::ConditionPresetLibraryPanel::m_selectedPresetID
private

◆ m_showDeleteConfirmation

bool Olympe::ConditionPresetLibraryPanel::m_showDeleteConfirmation = false
private

◆ OnPresetCreated

std::function<void(const std::string&)> Olympe::ConditionPresetLibraryPanel::OnPresetCreated

Invoked after a new preset is added.

Arg: preset ID.

Definition at line 103 of file ConditionPresetLibraryPanel.h.

Referenced by OnAddPresetClicked(), and OnDuplicatePresetClicked().

◆ OnPresetDeleted

std::function<void(const std::string&)> Olympe::ConditionPresetLibraryPanel::OnPresetDeleted

Invoked after a preset is deleted.

Arg: preset ID.

Definition at line 109 of file ConditionPresetLibraryPanel.h.

Referenced by OnDeleteConfirmed().

◆ OnPresetModified

std::function<void(const std::string&)> Olympe::ConditionPresetLibraryPanel::OnPresetModified

Invoked after an existing preset is modified.

Arg: preset ID.

Definition at line 106 of file ConditionPresetLibraryPanel.h.


The documentation for this class was generated from the following files: