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::NodeConditionsEditModal Class Reference

Modal dialog for adding, removing, and reordering conditions on a node. More...

#include <NodeConditionsEditModal.h>

+ Collaboration diagram for Olympe::NodeConditionsEditModal:

Public Member Functions

 NodeConditionsEditModal (ConditionPresetRegistry &registry)
 Constructs the modal bound to a global preset registry.
 
 ~NodeConditionsEditModal ()=default
 
 NodeConditionsEditModal (const NodeConditionsEditModal &)=delete
 
NodeConditionsEditModaloperator= (const NodeConditionsEditModal &)=delete
 
bool IsOpen () const
 Returns true if the modal is currently open.
 
void Open (const std::vector< NodeConditionRef > &currentRefs, const std::vector< ConditionRef > &operandRefs=std::vector< ConditionRef >())
 Opens the modal, loading the given condition refs for editing.
 
void Close ()
 Closes the modal without confirming changes.
 
bool IsConfirmed () const
 Returns true if the user clicked "Apply" and the modal was closed.
 
const std::vector< NodeConditionRef > & GetConditionRefs () const
 Returns the edited condition ref list.
 
const std::vector< ConditionRef > & GetConditionOperandRefs () const
 Returns the edited operand ref list (Phase 24).
 
size_t GetConditionCount () const
 Returns the number of conditions in the working copy.
 
void AddCondition (const std::string &presetID)
 Appends a new condition for the given preset to the working copy.
 
void RemoveCondition (size_t index)
 Removes the condition at the given index from the working copy.
 
void SetLogicalOp (size_t index, LogicalOp op)
 Sets the logical operator for the condition at the given index.
 
void MoveConditionUp (size_t index)
 Moves the condition at index one position earlier (swap with index-1).
 
void MoveConditionDown (size_t index)
 Moves the condition at index one position later (swap with index+1).
 
void Confirm ()
 Programmatically confirms the modal (equivalent to clicking Apply).
 
void SetLocalVariables (const std::vector< BlackboardEntry > &localVars)
 Sets the list of local variables for combo population.
 
void SetDropdownFilter (const std::string &filter)
 Sets the search filter for the "Add Condition" preset picker.
 
const std::string & GetDropdownFilter () const
 Returns the current dropdown filter string.
 
std::vector< ConditionPresetGetFilteredPresetsForDropdown () const
 Returns presets matching the current dropdown filter.
 
void Render ()
 Renders the modal dialog using ImGui.
 

Public Attributes

std::function< void()> OnApply
 Optional callback fired when the user clicks "Apply" (Confirm).
 

Private Member Functions

void RenderConditionRow (size_t index, const NodeConditionRef &ref)
 
void RenderAddConditionPicker ()
 
void RenderFooterButtons ()
 
void NormalizeLogicalOps ()
 Ensures the first condition's logicalOp is always Start.
 

Private Attributes

ConditionPresetRegistrym_registry
 Shared global registry.
 
std::vector< NodeConditionRefm_workingCopy
 Editable in-progress copy.
 
std::vector< ConditionRefm_workingCopyOperandRefs
 Phase 24: Operand data.
 
bool m_isOpen = false
 
bool m_isConfirmed = false
 
std::string m_dropdownFilter
 Preset-picker search filter.
 
bool m_pickerOpen = false
 Whether the add-preset picker is open.
 
std::vector< BlackboardEntrym_localVariables
 Phase 24: Local variables for combo.
 

Detailed Description

Modal dialog for adding, removing, and reordering conditions on a node.

The modal contains:

Definition at line 62 of file NodeConditionsEditModal.h.

Constructor & Destructor Documentation

◆ NodeConditionsEditModal() [1/2]

Olympe::NodeConditionsEditModal::NodeConditionsEditModal ( ConditionPresetRegistry registry)
explicit

Constructs the modal bound to a global preset registry.

Parameters
registryGlobal ConditionPresetRegistry (must outlive this modal).

Definition at line 26 of file NodeConditionsEditModal.cpp.

◆ ~NodeConditionsEditModal()

Olympe::NodeConditionsEditModal::~NodeConditionsEditModal ( )
default

◆ NodeConditionsEditModal() [2/2]

Olympe::NodeConditionsEditModal::NodeConditionsEditModal ( const NodeConditionsEditModal )
delete

Member Function Documentation

◆ AddCondition()

void Olympe::NodeConditionsEditModal::AddCondition ( const std::string &  presetID)

Appends a new condition for the given preset to the working copy.

The logicalOp defaults to And (Start for the first condition).

Parameters
presetIDUUID of the preset to add.

Definition at line 76 of file NodeConditionsEditModal.cpp.

References Olympe::And, m_workingCopy, NormalizeLogicalOps(), and Olympe::Start.

Referenced by RenderAddConditionPicker().

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

◆ Close()

void Olympe::NodeConditionsEditModal::Close ( )

Closes the modal without confirming changes.

Definition at line 47 of file NodeConditionsEditModal.cpp.

References m_isOpen, and m_pickerOpen.

Referenced by Confirm(), and RenderFooterButtons().

+ Here is the caller graph for this function:

◆ Confirm()

void Olympe::NodeConditionsEditModal::Confirm ( )

Programmatically confirms the modal (equivalent to clicking Apply).

Marks the modal as confirmed and closes it. Always succeeds. Fires the OnApply callback (if set) before closing.

Definition at line 121 of file NodeConditionsEditModal.cpp.

References Close(), m_isConfirmed, and OnApply.

Referenced by RenderFooterButtons().

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

◆ GetConditionCount()

size_t Olympe::NodeConditionsEditModal::GetConditionCount ( ) const

Returns the number of conditions in the working copy.

Definition at line 71 of file NodeConditionsEditModal.cpp.

References m_workingCopy.

◆ GetConditionOperandRefs()

const std::vector< ConditionRef > & Olympe::NodeConditionsEditModal::GetConditionOperandRefs ( ) const

Returns the edited operand ref list (Phase 24).

Only meaningful when IsConfirmed() is true.

Definition at line 62 of file NodeConditionsEditModal.cpp.

References m_workingCopyOperandRefs.

◆ GetConditionRefs()

const std::vector< NodeConditionRef > & Olympe::NodeConditionsEditModal::GetConditionRefs ( ) const

Returns the edited condition ref list.

Only meaningful when IsConfirmed() is true.

Definition at line 57 of file NodeConditionsEditModal.cpp.

References m_workingCopy.

◆ GetDropdownFilter()

const std::string & Olympe::NodeConditionsEditModal::GetDropdownFilter ( ) const
inline

Returns the current dropdown filter string.

Definition at line 229 of file NodeConditionsEditModal.h.

References m_dropdownFilter.

◆ GetFilteredPresetsForDropdown()

std::vector< ConditionPreset > Olympe::NodeConditionsEditModal::GetFilteredPresetsForDropdown ( ) const

Returns presets matching the current dropdown filter.

Definition at line 139 of file NodeConditionsEditModal.cpp.

References Olympe::ConditionPresetRegistry::FindPresetsByName(), Olympe::ConditionPresetRegistry::GetAllPresetIDs(), GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), m_dropdownFilter, and m_registry.

Referenced by RenderAddConditionPicker().

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

◆ IsConfirmed()

bool Olympe::NodeConditionsEditModal::IsConfirmed ( ) const
inline

Returns true if the user clicked "Apply" and the modal was closed.

Reset by Open().

Definition at line 106 of file NodeConditionsEditModal.h.

References m_isConfirmed.

◆ IsOpen()

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

Returns true if the modal is currently open.

Definition at line 84 of file NodeConditionsEditModal.h.

References m_isOpen.

◆ MoveConditionDown()

void Olympe::NodeConditionsEditModal::MoveConditionDown ( size_t  index)

Moves the condition at index one position later (swap with index+1).

No-op when index is the last element.

Parameters
indexZero-based index.

Definition at line 112 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_workingCopy, and NormalizeLogicalOps().

Referenced by RenderConditionRow().

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

◆ MoveConditionUp()

void Olympe::NodeConditionsEditModal::MoveConditionUp ( size_t  index)

Moves the condition at index one position earlier (swap with index-1).

No-op when index == 0.

Parameters
indexZero-based index.

Definition at line 103 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_workingCopy, and NormalizeLogicalOps().

Referenced by RenderConditionRow().

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

◆ NormalizeLogicalOps()

void Olympe::NodeConditionsEditModal::NormalizeLogicalOps ( )
private

Ensures the first condition's logicalOp is always Start.

Definition at line 305 of file NodeConditionsEditModal.cpp.

References m_workingCopy, and Olympe::Start.

Referenced by AddCondition(), MoveConditionDown(), MoveConditionUp(), Open(), and RemoveCondition().

+ Here is the caller graph for this function:

◆ Open()

void Olympe::NodeConditionsEditModal::Open ( const std::vector< NodeConditionRef > &  currentRefs,
const std::vector< ConditionRef > &  operandRefs = std::vector<ConditionRef>() 
)

Opens the modal, loading the given condition refs for editing.

Resets the confirmed flag and takes a COPY of the refs to edit.

Parameters
currentRefsCondition refs from the selected node.

Definition at line 35 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_dropdownFilter, m_isConfirmed, m_isOpen, m_pickerOpen, m_workingCopy, m_workingCopyOperandRefs, and NormalizeLogicalOps().

Referenced by Olympe::NodeConditionsPanel::RenderConditionsPreview().

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

◆ operator=()

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

◆ RemoveCondition()

void Olympe::NodeConditionsEditModal::RemoveCondition ( size_t  index)

Removes the condition at the given index from the working copy.

Parameters
indexZero-based index.

Definition at line 86 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_workingCopy, and NormalizeLogicalOps().

Referenced by RenderConditionRow().

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

◆ Render()

void Olympe::NodeConditionsEditModal::Render ( )

Renders the modal dialog using ImGui.

Must be called once per frame from the host's render loop. No-op when !IsOpen().

Definition at line 169 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_isOpen, m_workingCopy, RenderAddConditionPicker(), RenderConditionRow(), and RenderFooterButtons().

+ Here is the call graph for this function:

◆ RenderAddConditionPicker()

void Olympe::NodeConditionsEditModal::RenderAddConditionPicker ( )
private

Definition at line 257 of file NodeConditionsEditModal.cpp.

References AddCondition(), GetComponentTypeID_Static(), GetFilteredPresetsForDropdown(), m_pickerOpen, and SetDropdownFilter().

Referenced by Render().

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

◆ RenderConditionRow()

void Olympe::NodeConditionsEditModal::RenderConditionRow ( size_t  index,
const NodeConditionRef ref 
)
private

Definition at line 204 of file NodeConditionsEditModal.cpp.

References Olympe::And, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), m_registry, MoveConditionDown(), MoveConditionUp(), Olympe::Or, RemoveCondition(), and SetLogicalOp().

Referenced by Render().

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

◆ RenderFooterButtons()

void Olympe::NodeConditionsEditModal::RenderFooterButtons ( )
private

Definition at line 288 of file NodeConditionsEditModal.cpp.

References Close(), Confirm(), and GetComponentTypeID_Static().

Referenced by Render().

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

◆ SetDropdownFilter()

void Olympe::NodeConditionsEditModal::SetDropdownFilter ( const std::string &  filter)

Sets the search filter for the "Add Condition" preset picker.

Parameters
filterSubstring filter (empty = show all).

Definition at line 133 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), and m_dropdownFilter.

Referenced by RenderAddConditionPicker().

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

◆ SetLocalVariables()

void Olympe::NodeConditionsEditModal::SetLocalVariables ( const std::vector< BlackboardEntry > &  localVars)
inline

Sets the list of local variables for combo population.

Parameters
localVarsVector of local blackboard entries.

Definition at line 211 of file NodeConditionsEditModal.h.

References GetComponentTypeID_Static(), and m_localVariables.

+ Here is the call graph for this function:

◆ SetLogicalOp()

void Olympe::NodeConditionsEditModal::SetLogicalOp ( size_t  index,
LogicalOp  op 
)

Sets the logical operator for the condition at the given index.

Index 0 is always forced to LogicalOp::Start.

Parameters
indexZero-based index.
opDesired operator (And or Or).

Definition at line 95 of file NodeConditionsEditModal.cpp.

References GetComponentTypeID_Static(), m_workingCopy, and Olympe::Start.

Referenced by RenderConditionRow().

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

Member Data Documentation

◆ m_dropdownFilter

std::string Olympe::NodeConditionsEditModal::m_dropdownFilter
private

Preset-picker search filter.

Definition at line 275 of file NodeConditionsEditModal.h.

Referenced by GetDropdownFilter(), GetFilteredPresetsForDropdown(), Open(), and SetDropdownFilter().

◆ m_isConfirmed

bool Olympe::NodeConditionsEditModal::m_isConfirmed = false
private

Definition at line 273 of file NodeConditionsEditModal.h.

Referenced by Confirm(), IsConfirmed(), and Open().

◆ m_isOpen

bool Olympe::NodeConditionsEditModal::m_isOpen = false
private

Definition at line 272 of file NodeConditionsEditModal.h.

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

◆ m_localVariables

std::vector<BlackboardEntry> Olympe::NodeConditionsEditModal::m_localVariables
private

Phase 24: Local variables for combo.

Definition at line 277 of file NodeConditionsEditModal.h.

Referenced by SetLocalVariables().

◆ m_pickerOpen

bool Olympe::NodeConditionsEditModal::m_pickerOpen = false
private

Whether the add-preset picker is open.

Definition at line 276 of file NodeConditionsEditModal.h.

Referenced by Close(), Open(), and RenderAddConditionPicker().

◆ m_registry

ConditionPresetRegistry& Olympe::NodeConditionsEditModal::m_registry
private

Shared global registry.

Definition at line 269 of file NodeConditionsEditModal.h.

Referenced by GetFilteredPresetsForDropdown(), and RenderConditionRow().

◆ m_workingCopy

std::vector<NodeConditionRef> Olympe::NodeConditionsEditModal::m_workingCopy
private

◆ m_workingCopyOperandRefs

std::vector<ConditionRef> Olympe::NodeConditionsEditModal::m_workingCopyOperandRefs
private

Phase 24: Operand data.

Definition at line 271 of file NodeConditionsEditModal.h.

Referenced by GetConditionOperandRefs(), and Open().

◆ OnApply

std::function<void()> Olympe::NodeConditionsEditModal::OnApply

Optional callback fired when the user clicks "Apply" (Confirm).

Set this before opening the modal. The callback is invoked from within Confirm() after m_isConfirmed is set but before Close() is called, allowing the host to read GetConditionRefs() synchronously.

Example:

modal.OnApply = [&]() {
node.conditionRefs = modal.GetConditionRefs();
pinManager.RegeneratePinsFromConditions(node.conditionRefs);
};
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56

Definition at line 201 of file NodeConditionsEditModal.h.

Referenced by Confirm().


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