![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
ImGui sub-panel for managing the condition list of a single NodeBranch. More...
#include <NodeConditionsPanel.h>
Collaboration diagram for Olympe::NodeConditionsPanel:Public Member Functions | |
| NodeConditionsPanel (ConditionPresetRegistry ®istry) | |
| Constructs the panel bound to a global preset registry. | |
| ~NodeConditionsPanel ()=default | |
| NodeConditionsPanel (const NodeConditionsPanel &)=delete | |
| NodeConditionsPanel & | operator= (const NodeConditionsPanel &)=delete |
| void | SetConditionRefs (const std::vector< NodeConditionRef > &refs) |
| Replaces the panel's internal condition list. | |
| const std::vector< NodeConditionRef > & | GetConditionRefs () const |
| Returns the current (possibly modified) condition list. | |
| void | SetConditionOperandRefs (const std::vector< ConditionRef > &refs) |
| Replaces the panel's inline operand list (parallel to conditionRefs). | |
| const std::vector< ConditionRef > & | GetConditionOperandRefs () const |
| Returns the current inline operand list. | |
| void | SetDynamicPins (const std::vector< DynamicDataPin > &pins) |
| Provides the read-only list of dynamic pins for display. | |
| bool | IsDirty () const |
| Returns true if the condition list has been modified since the last call to ClearDirty(). | |
| void | ClearDirty () |
| Resets the dirty flag. | |
| void | SetNodeName (const std::string &name) |
| Sets the node name displayed in the title section. | |
| const std::string & | GetNodeName () const |
| Returns the current node name shown in the title bar. | |
| bool | IsEditModalRequested () const |
| Returns true if the "Edit Conditions" button was clicked this frame. | |
| void | ClearEditModalRequest () |
| Resets the edit-modal request flag. | |
| void | Render () |
| Renders the condition list and dynamic-pin display using ImGui. | |
| void | RenderConditionList () |
| Renders all conditions inline as an editable list. | |
| void | RenderInlineConditionEditor () |
| Phase 24 UX Refactor: Renders condition editor inline (no modal popup). | |
| void | RenderInlineConditionRow (size_t index, const NodeConditionRef &ref) |
| Renders a single condition row with edit/move/delete controls. | |
| void | RenderInlineAddCondition () |
| Renders the "Add Condition" button and preset picker inline. | |
| void | OnPresetDeleted (const std::string &deletedPresetID) |
| Should be called by the host when a preset is deleted from the registry. | |
| void | SetLocalVariables (const std::vector< BlackboardEntry > &localVars) |
| Sets the list of local variables from EntityBlackboard (Phase 24). | |
| void | AddCondition (const std::string &presetID) |
| Appends a new condition reference with the given preset. | |
| void | RemoveCondition (size_t index) |
| Removes the condition at the given index. | |
| void | SetLogicalOp (size_t index, LogicalOp op) |
| Changes the logical operator for the condition at the given index. | |
| size_t | GetConditionCount () const |
| Returns the number of conditions currently in the list. | |
| bool | IsValid () const |
| Returns true when every condition ref points to an existing preset. | |
| std::vector< std::string > | Validate () const |
| Returns a list of error strings describing validation failures. | |
| void | SetDropdownFilter (const std::string &filter) |
| Sets the search/filter string used by the "Add Condition" dropdown. | |
| const std::string & | GetDropdownFilter () const |
| Returns the current dropdown filter. | |
| std::vector< ConditionPreset > | GetFilteredPresetsForDropdown () const |
| Returns presets matching the current dropdown filter. | |
Public Attributes | |
| std::function< void(const std::string &)> | OnPresetChanged |
| Fired when a preset is selected or changed. | |
| std::function< void()> | OnDynamicPinsNeedRegeneration |
| Fired after the edit modal is confirmed and condition refs are updated, signalling that dynamic pins must be regenerated. | |
Private Member Functions | |
| void | RenderTitleSection () |
| Section 1: title bar (blue background, node name). | |
| void | RenderExecPinsSection () |
| Section 2: static exec pins (In / Then / Else, never editable). | |
| void | RenderConditionsPreview () |
| Section 3: read-only conditions preview (green text) + "Edit Conditions" button. | |
| void | RenderDynamicPinsSection () |
| Section 4: dynamic data pins (yellow, only when non-empty). | |
| void | RenderOperandDropdown (ConditionRef &cref, bool isLeft, const std::string &pinLabel="") |
| Renders the operand mode selector + value field for one operand. | |
| void | RenderOperatorDropdown (ConditionRef &cref) |
| Renders the operator combo box (==, !=, <, <=, >, >=). | |
| void | NormalizeLogicalOps () |
| Fixes up the first condition's logicalOp to always be Start. | |
Private Attributes | |
| ConditionPresetRegistry & | m_registry |
| Shared global registry. | |
| std::vector< NodeConditionRef > | m_conditionRefs |
| Current node's conditions. | |
| std::vector< ConditionRef > | m_conditionOperandRefs |
| Inline operand data (parallel to m_conditionRefs) | |
| std::vector< DynamicDataPin > | m_dynamicPins |
| Read-only dynamic pins for display. | |
| std::vector< BlackboardEntry > | m_localVariables |
| Local variables from entity (Phase 24) | |
| std::string | m_nodeName |
| Node display name for title section. | |
| bool | m_dirty = false |
| Modification flag. | |
| bool | m_editModalRequested = false |
| Set when Edit button is clicked. | |
| bool | m_pickerOpen = false |
| Phase 24: Inline preset picker visibility. | |
| NodeConditionsEditModal | m_editModal |
| Owned modal for condition editing. | |
| std::string | m_dropdownFilter |
| Filter text for "Add Condition" dropdown. | |
| bool | m_dropdownOpen = false |
| Whether the add-dropdown is shown (legacy, kept for API compat) | |
ImGui sub-panel for managing the condition list of a single NodeBranch.
The panel does NOT own the registry — it holds a reference. The caller is responsible for persisting changes from GetConditionRefs() back to the node definition.
Dependency injection: NodeConditionsPanel panel(registry); panel.SetConditionRefs(node.conditions); panel.SetDynamicPins(node.dynamicPins); // optional read-only display panel.Render(); if (panel.IsDirty()) { node.conditions = panel.GetConditionRefs(); panel.ClearDirty(); }
Definition at line 73 of file NodeConditionsPanel.h.
|
explicit |
Constructs the panel bound to a global preset registry.
| registry | Global ConditionPresetRegistry (must outlive this panel). |
Definition at line 28 of file NodeConditionsPanel.cpp.
|
default |
|
delete |
Appends a new condition reference with the given preset.
The logicalOp is automatically set to LogicalOp::And (except for the first entry, which receives LogicalOp::Start).
| presetID | UUID of the ConditionPreset to reference. |
Definition at line 79 of file NodeConditionsPanel.cpp.
References Olympe::And, Olympe::ConditionRef::conditionIndex, Olympe::OperandRef::Const, Olympe::Const, Olympe::Equal, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), Olympe::Greater, Olympe::GreaterEqual, Olympe::ConditionPreset::left, Olympe::Less, Olympe::LessEqual, m_conditionOperandRefs, m_conditionRefs, m_dirty, m_registry, NormalizeLogicalOps(), Olympe::NotEqual, OnPresetChanged, Olympe::OperandRef::Pin, Olympe::Pin, Olympe::Start, Olympe::Operand::stringValue, Olympe::OperandRef::Variable, and Olympe::Variable.
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
|
inline |
Resets the edit-modal request flag.
Definition at line 176 of file NodeConditionsPanel.h.
References m_editModalRequested.
| size_t Olympe::NodeConditionsPanel::GetConditionCount | ( | ) | const |
Returns the number of conditions currently in the list.
Definition at line 185 of file NodeConditionsPanel.cpp.
References m_conditionRefs.
| const std::vector< ConditionRef > & Olympe::NodeConditionsPanel::GetConditionOperandRefs | ( | ) | const |
Returns the current inline operand list.
The host should read this after IsDirty() returns true and persist it to node.conditionOperandRefs.
Definition at line 65 of file NodeConditionsPanel.cpp.
References m_conditionOperandRefs.
| const std::vector< NodeConditionRef > & Olympe::NodeConditionsPanel::GetConditionRefs | ( | ) | const |
Returns the current (possibly modified) condition list.
Definition at line 55 of file NodeConditionsPanel.cpp.
References m_conditionRefs.
|
inline |
Returns the current dropdown filter.
Definition at line 354 of file NodeConditionsPanel.h.
References m_dropdownFilter.
| std::vector< ConditionPreset > Olympe::NodeConditionsPanel::GetFilteredPresetsForDropdown | ( | ) | const |
Returns presets matching the current dropdown filter.
Delegates to ConditionPresetRegistry::FindPresetsByName when the filter is non-empty; returns all presets otherwise.
Definition at line 265 of file NodeConditionsPanel.cpp.
References Olympe::ConditionPresetRegistry::FindPresetsByName(), Olympe::ConditionPresetRegistry::GetAllPresetIDs(), GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), m_dropdownFilter, and m_registry.
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Returns the current node name shown in the title bar.
Definition at line 159 of file NodeConditionsPanel.h.
References m_nodeName.
|
inline |
Returns true if the condition list has been modified since the last call to ClearDirty().
Definition at line 139 of file NodeConditionsPanel.h.
References m_dirty.
|
inline |
Returns true if the "Edit Conditions" button was clicked this frame.
The caller should open NodeConditionsEditModal when this is true, then call ClearEditModalRequest() to reset the flag.
Definition at line 171 of file NodeConditionsPanel.h.
References m_editModalRequested.
| bool Olympe::NodeConditionsPanel::IsValid | ( | ) | const |
Returns true when every condition ref points to an existing preset.
Definition at line 222 of file NodeConditionsPanel.cpp.
References Validate().
Here is the call graph for this function:
|
private |
Fixes up the first condition's logicalOp to always be Start.
Definition at line 1032 of file NodeConditionsPanel.cpp.
References m_conditionRefs, and Olympe::Start.
Referenced by AddCondition(), OnPresetDeleted(), RemoveCondition(), and SetConditionRefs().
Here is the caller graph for this function:Should be called by the host when a preset is deleted from the registry.
Removes any NodeConditionRef pointing to that preset.
| deletedPresetID | UUID of the preset that was removed. |
Definition at line 194 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionRefs, m_dirty, and NormalizeLogicalOps().
Here is the call graph for this function:
|
delete |
Removes the condition at the given index.
| index | Zero-based index in the condition list. |
Definition at line 154 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionOperandRefs, m_conditionRefs, m_dirty, and NormalizeLogicalOps().
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeConditionsPanel::Render | ( | ) |
Renders the condition list and dynamic-pin display using ImGui.
Must be called once per frame inside an ImGui window context. Internally wrapped in #ifndef OLYMPE_HEADLESS so tests can call the logic methods without linking ImGui.
Definition at line 295 of file NodeConditionsPanel.cpp.
References RenderInlineConditionEditor().
Here is the call graph for this function:| void Olympe::NodeConditionsPanel::RenderConditionList | ( | ) |
Renders all conditions inline as an editable list.
Each condition is displayed as a row containing:
Below the list a "[+ Add Condition]" button opens a popup that lets the user pick a preset from the registry (filtered by name).
Modifications set the dirty flag so the host can sync via GetConditionRefs().
Layout:
Guarded by #ifndef OLYMPE_HEADLESS — no-op in headless test builds.
< Width of the And/Or combo
< Width of the [X] delete button
< Max filter string length incl. NUL
Definition at line 607 of file NodeConditionsPanel.cpp.
References AddCondition(), Olympe::And, Olympe::ConditionRef::conditionIndex, GetComponentTypeID_Static(), GetFilteredPresetsForDropdown(), Olympe::Left, m_conditionOperandRefs, m_conditionRefs, m_dirty, m_dropdownFilter, m_dynamicPins, OnDynamicPinsNeedRegeneration, Olympe::Or, RemoveCondition(), RenderOperandDropdown(), RenderOperatorDropdown(), and SetDropdownFilter().
Here is the call graph for this function:
|
private |
Section 3: read-only conditions preview (green text) + "Edit Conditions" button.
Definition at line 506 of file NodeConditionsPanel.cpp.
References Olympe::And, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), Olympe::ConditionRef::leftOperand, m_conditionOperandRefs, m_conditionRefs, m_editModal, m_editModalRequested, m_registry, Olympe::NodeConditionsEditModal::Open(), Olympe::Or, Olympe::OperandRef::Pin, Olympe::OperandRef::Variable, and Olympe::OperandRef::variableName.
Here is the call graph for this function:
|
private |
Section 4: dynamic data pins (yellow, only when non-empty).
Definition at line 762 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_dynamicPins.
Here is the call graph for this function:
|
private |
Section 2: static exec pins (In / Then / Else, never editable).
Definition at line 490 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:| void Olympe::NodeConditionsPanel::RenderInlineAddCondition | ( | ) |
Renders the "Add Condition" button and preset picker inline.
When clicked, shows a filterable list of available presets from the registry.
Definition at line 427 of file NodeConditionsPanel.cpp.
References Olympe::And, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetFilteredPresets(), m_conditionRefs, m_dirty, m_pickerOpen, m_registry, OnDynamicPinsNeedRegeneration, and Olympe::Start.
Referenced by RenderInlineConditionEditor().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeConditionsPanel::RenderInlineConditionEditor | ( | ) |
Phase 24 UX Refactor: Renders condition editor inline (no modal popup).
Replaces the modal-based editing with an inline collapsible section that allows users to add, edit, reorder, and delete conditions directly in the properties panel without opening a separate modal window.
Guarded by #ifndef OLYMPE_HEADLESS.
Definition at line 308 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionRefs, RenderInlineAddCondition(), and RenderInlineConditionRow().
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeConditionsPanel::RenderInlineConditionRow | ( | size_t | index, |
| const NodeConditionRef & | ref | ||
| ) |
Renders a single condition row with edit/move/delete controls.
| index | Index of the condition in m_conditionRefs |
| ref | Reference to the NodeConditionRef being rendered |
Definition at line 345 of file NodeConditionsPanel.cpp.
References Olympe::And, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), m_conditionOperandRefs, m_conditionRefs, m_dirty, m_registry, OnDynamicPinsNeedRegeneration, Olympe::Or, and SetLogicalOp().
Referenced by RenderInlineConditionEditor().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Renders the operand mode selector + value field for one operand.
Inline widget used inside RenderConditionList() for each condition row. Renders a three-button radio group (Variable | Const | Pin) followed by a mode-specific input:
| cref | ConditionRef to modify (mode and value fields). |
| isLeft | True for the left operand, false for the right operand. |
| pinLabel | Short "Pin-in #N" label for Pin-mode display (may be empty). |
Definition at line 781 of file NodeConditionsPanel.cpp.
References Olympe::OperandRef::Const, Olympe::OperandRef::constValue, Olympe::OperandRef::dynamicPinID, Olympe::GlobalTemplateBlackboard::Get(), GetComponentTypeID_Static(), Olympe::Left, m_dirty, m_dynamicPins, m_localVariables, Olympe::OperandRef::mode, OnDynamicPinsNeedRegeneration, Olympe::OperandRef::Pin, Olympe::Right, Olympe::OperandRef::Variable, and Olympe::OperandRef::variableName.
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Renders the operator combo box (==, !=, <, <=, >, >=).
Inline widget used inside RenderConditionList() for each condition row. Updates cref.operatorStr on selection.
| cref | ConditionRef to modify. |
Definition at line 995 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_dirty.
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Section 1: title bar (blue background, node name).
Definition at line 476 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_nodeName.
Here is the call graph for this function:| void Olympe::NodeConditionsPanel::SetConditionOperandRefs | ( | const std::vector< ConditionRef > & | refs | ) |
Replaces the panel's inline operand list (parallel to conditionRefs).
Each entry corresponds 1:1 with a NodeConditionRef and stores the editable operand data (mode, variable name, const value, dynamicPinID). Typically called alongside SetConditionRefs() when a node is selected.
| refs | Inline operand refs from node.conditionOperandRefs. |
Definition at line 60 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_conditionOperandRefs.
Here is the call graph for this function:| void Olympe::NodeConditionsPanel::SetConditionRefs | ( | const std::vector< NodeConditionRef > & | refs | ) |
Replaces the panel's internal condition list.
Typically called when a new node is selected in the editor.
| refs | Condition references from node.conditions. |
Definition at line 38 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionOperandRefs, m_conditionRefs, m_dirty, and NormalizeLogicalOps().
Here is the call graph for this function:Sets the search/filter string used by the "Add Condition" dropdown.
| filter | Substring filter (empty = show all). |
Definition at line 259 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_dropdownFilter.
Referenced by RenderConditionList().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeConditionsPanel::SetDynamicPins | ( | const std::vector< DynamicDataPin > & | pins | ) |
Provides the read-only list of dynamic pins for display.
The panel shows these pins in a read-only section. Ownership stays with the DynamicDataPinManager; the panel only renders them.
| pins | Current dynamic pins associated with this node. |
Definition at line 70 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), and m_dynamicPins.
Here is the call graph for this function:
|
inline |
Sets the list of local variables from EntityBlackboard (Phase 24).
Used to populate variable dropdowns in the operand selector with both local and global variables.
| localVars | Vector of local variable definitions from the entity blackboard. |
Definition at line 284 of file NodeConditionsPanel.h.
References GetComponentTypeID_Static(), and m_localVariables.
Here is the call graph for this function:Changes the logical operator for the condition at the given index.
Index 0 is always forced to LogicalOp::Start regardless of the value passed in.
| index | Zero-based index. |
| op | New LogicalOp (And or Or; Start is ignored for index > 0). |
Definition at line 175 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionRefs, m_dirty, and Olympe::Start.
Referenced by RenderInlineConditionRow().
Here is the call graph for this function:
Here is the caller graph for this function:Sets the node name displayed in the title section.
| name | Display name (e.g. "Is Health Critical?"). |
Definition at line 154 of file NodeConditionsPanel.h.
References m_nodeName.
| std::vector< std::string > Olympe::NodeConditionsPanel::Validate | ( | ) | const |
Returns a list of error strings describing validation failures.
Empty if IsValid() returns true.
Definition at line 227 of file NodeConditionsPanel.cpp.
References GetComponentTypeID_Static(), m_conditionRefs, m_registry, Olympe::NodeConditionRef::presetID, and Olympe::ConditionPresetRegistry::ValidatePresetID().
Referenced by IsValid().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Inline operand data (parallel to m_conditionRefs)
Definition at line 422 of file NodeConditionsPanel.h.
Referenced by AddCondition(), GetConditionOperandRefs(), RemoveCondition(), RenderConditionList(), RenderConditionsPreview(), RenderInlineConditionRow(), SetConditionOperandRefs(), and SetConditionRefs().
|
private |
Current node's conditions.
Definition at line 421 of file NodeConditionsPanel.h.
Referenced by AddCondition(), GetConditionCount(), GetConditionRefs(), NormalizeLogicalOps(), OnPresetDeleted(), RemoveCondition(), RenderConditionList(), RenderConditionsPreview(), RenderInlineAddCondition(), RenderInlineConditionEditor(), RenderInlineConditionRow(), SetConditionRefs(), SetLogicalOp(), and Validate().
Modification flag.
Definition at line 426 of file NodeConditionsPanel.h.
Referenced by AddCondition(), ClearDirty(), IsDirty(), OnPresetDeleted(), RemoveCondition(), RenderConditionList(), RenderInlineAddCondition(), RenderInlineConditionRow(), RenderOperandDropdown(), RenderOperatorDropdown(), SetConditionRefs(), and SetLogicalOp().
|
private |
Filter text for "Add Condition" dropdown.
Definition at line 432 of file NodeConditionsPanel.h.
Referenced by GetDropdownFilter(), GetFilteredPresetsForDropdown(), RenderConditionList(), and SetDropdownFilter().
Whether the add-dropdown is shown (legacy, kept for API compat)
Definition at line 433 of file NodeConditionsPanel.h.
|
private |
Read-only dynamic pins for display.
Definition at line 423 of file NodeConditionsPanel.h.
Referenced by RenderConditionList(), RenderDynamicPinsSection(), RenderOperandDropdown(), and SetDynamicPins().
|
private |
Owned modal for condition editing.
Definition at line 430 of file NodeConditionsPanel.h.
Referenced by RenderConditionsPreview().
Set when Edit button is clicked.
Definition at line 427 of file NodeConditionsPanel.h.
Referenced by ClearEditModalRequest(), IsEditModalRequested(), and RenderConditionsPreview().
|
private |
Local variables from entity (Phase 24)
Definition at line 424 of file NodeConditionsPanel.h.
Referenced by RenderOperandDropdown(), and SetLocalVariables().
|
private |
Node display name for title section.
Definition at line 425 of file NodeConditionsPanel.h.
Referenced by GetNodeName(), RenderTitleSection(), and SetNodeName().
Phase 24: Inline preset picker visibility.
Definition at line 428 of file NodeConditionsPanel.h.
Referenced by RenderInlineAddCondition().
|
private |
Shared global registry.
Definition at line 420 of file NodeConditionsPanel.h.
Referenced by AddCondition(), GetFilteredPresetsForDropdown(), RenderConditionsPreview(), RenderInlineAddCondition(), RenderInlineConditionRow(), and Validate().
| std::function<void()> Olympe::NodeConditionsPanel::OnDynamicPinsNeedRegeneration |
Fired after the edit modal is confirmed and condition refs are updated, signalling that dynamic pins must be regenerated.
The host should connect this to DynamicDataPinManager::RegeneratePinsFromConditions() or NodeBranchRenderer::TriggerPinRegeneration() so that the canvas updates immediately on the next render frame.
Example:
Definition at line 266 of file NodeConditionsPanel.h.
Referenced by RenderConditionList(), RenderInlineAddCondition(), RenderInlineConditionRow(), and RenderOperandDropdown().
Fired when a preset is selected or changed.
Arg: preset ID.
Definition at line 248 of file NodeConditionsPanel.h.
Referenced by AddCondition().