![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Renders a NodeBranch using ImGui/ImNodes with 4 sections. More...
#include <NodeBranchRenderer.h>
Collaboration diagram for Olympe::NodeBranchRenderer:Public Member Functions | |
| NodeBranchRenderer (ConditionPresetRegistry ®istry, DynamicDataPinManager &pinManager) | |
| Constructs the renderer with its dependencies. | |
| ~NodeBranchRenderer ()=default | |
| NodeBranchRenderer (const NodeBranchRenderer &)=delete | |
| NodeBranchRenderer & | operator= (const NodeBranchRenderer &)=delete |
| void | RenderNode (const NodeBranchData &data, const std::unordered_set< int > &connectedAttrIDs={}) |
| Renders the full NodeBranch node in the current ImNodes context. | |
| void | RenderTitleSection (const NodeBranchData &data) |
| Renders Section 1: title bar with blue background. | |
| void | RenderExecPinsSection (const NodeBranchData &data) |
| Renders Section 2: static exec pins (In / Then / Else). | |
| void | RenderConditionsSection (const NodeBranchData &data) |
| Renders Section 3: read-only conditions preview (green text). | |
| void | RenderDynamicPinsSection (const NodeBranchData &data, const std::unordered_set< int > &connectedAttrIDs={}) |
| Renders Section 4: dynamic data pins (yellow, conditional). | |
| void | SetupDynamicPinConnectors (const NodeBranchData &data) |
| Sets up ImNodes connectors for each dynamic pin. | |
| void | TriggerPinRegeneration (std::vector< NodeConditionRef > &conditionRefs) |
| Regenerates dynamic data pins from an updated condition list. | |
| int | GetLastClickedConditionIndex () const |
| Returns the index of the last condition row that was clicked, or -1 if none. | |
| void | ClearLastClickedCondition () |
| Resets the last-clicked condition index to -1. | |
| void | NotifyPresetChanged (const std::string &changedPresetID) |
| Notifies the renderer that a preset has been updated. | |
| bool | IsRefreshPending () const |
| Returns true if any preset change notification is pending (dirty). | |
| void | ClearRefreshPending () |
| Clears the refresh-pending flag (called after refresh is complete). | |
Public Attributes | |
| std::function< void(int)> | OnConditionClicked |
| Fired when the user clicks on a condition row. | |
Private Member Functions | |
| void | RenderSectionHeader (const char *label) |
| void | RenderSectionSeparator () |
Private Attributes | |
| ConditionPresetRegistry & | m_registry |
| Shared global registry. | |
| DynamicDataPinManager & | m_pinManager |
| Shared dynamic pin manager. | |
| int | m_lastClickedCondition = -1 |
| Interaction state. | |
| bool | m_refreshPending = false |
| Dirty flag. | |
Static Private Attributes | |
| static constexpr float | kTitleR = 0.0f |
| Blue title bar background color (#0066CC equivalent). | |
| static constexpr float | kTitleG = 0.4f |
| static constexpr float | kTitleB = 0.8f |
| static constexpr float | kDynPinR = 1.0f |
| Yellow dynamic-pin label color (FFD700 equivalent). | |
| static constexpr float | kDynPinG = 0.843f |
| static constexpr float | kDynPinB = 0.0f |
Renders a NodeBranch using ImGui/ImNodes with 4 sections.
The renderer is stateless with respect to node data: it reads from the NodeBranchData passed each frame. Internal state is limited to hover/click tracking for interaction.
Usage:
Definition at line 91 of file NodeBranchRenderer.h.
| Olympe::NodeBranchRenderer::NodeBranchRenderer | ( | ConditionPresetRegistry & | registry, |
| DynamicDataPinManager & | pinManager | ||
| ) |
Constructs the renderer with its dependencies.
| registry | Global ConditionPresetRegistry. |
| pinManager | DynamicDataPinManager for the node being rendered. |
Definition at line 26 of file NodeBranchRenderer.cpp.
|
default |
|
delete |
|
inline |
Resets the last-clicked condition index to -1.
Definition at line 216 of file NodeBranchRenderer.h.
References m_lastClickedCondition.
|
inline |
Clears the refresh-pending flag (called after refresh is complete).
Definition at line 254 of file NodeBranchRenderer.h.
References m_refreshPending.
|
inline |
Returns the index of the last condition row that was clicked, or -1 if none.
Definition at line 211 of file NodeBranchRenderer.h.
References m_lastClickedCondition.
|
inline |
Returns true if any preset change notification is pending (dirty).
Definition at line 249 of file NodeBranchRenderer.h.
References m_refreshPending.
Notifies the renderer that a preset has been updated.
Marks the node as needing a label refresh. The next call to RenderNode() will recompute preview strings from the registry.
| changedPresetID | UUID of the modified preset. |
Definition at line 387 of file NodeBranchRenderer.cpp.
References m_refreshPending.
|
delete |
| void Olympe::NodeBranchRenderer::RenderConditionsSection | ( | const NodeBranchData & | data | ) |
Renders Section 3: read-only conditions preview (green text).
Each condition is displayed in the format: " [mHealth] <= [2]" "And [mSpeed] <= [100.00]" Hovering shows a tooltip; clicking fires OnConditionClicked.
| data | Node data. |
Definition at line 199 of file NodeBranchRenderer.cpp.
References Olympe::And, Olympe::NodeBranchData::conditionRefs, Olympe::Equal, GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), Olympe::Greater, Olympe::GreaterEqual, Olympe::Less, Olympe::LessEqual, m_lastClickedCondition, m_registry, Olympe::NotEqual, and OnConditionClicked.
Referenced by RenderNode().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeBranchRenderer::RenderDynamicPinsSection | ( | const NodeBranchData & | data, |
| const std::unordered_set< int > & | connectedAttrIDs = {} |
||
| ) |
Renders Section 4: dynamic data pins (yellow, conditional).
Only rendered when data.dynamicPins is non-empty. Format: "In #<idx>[L/R]: <condPreview>"
| data | Node data. |
| connectedAttrIDs | Set of connected attribute IDs (for filled/outlined shape). |
Definition at line 306 of file NodeBranchRenderer.cpp.
References Olympe::NodeBranchData::dynamicPins, GetComponentTypeID_Static(), Olympe::Left, and Olympe::NodeBranchData::nodeID.
Referenced by RenderNode().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::NodeBranchRenderer::RenderExecPinsSection | ( | const NodeBranchData & | data | ) |
Renders Section 2: static exec pins (In / Then / Else).
Shows "In" on the left and "Then" / "Else" on the right. These pins are NEVER editable from this section.
| data | Node data. |
Definition at line 178 of file NodeBranchRenderer.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:| void Olympe::NodeBranchRenderer::RenderNode | ( | const NodeBranchData & | data, |
| const std::unordered_set< int > & | connectedAttrIDs = {} |
||
| ) |
Renders the full NodeBranch node in the current ImNodes context.
Must be called between ImNodes::BeginNode() and ImNodes::EndNode(). In headless builds this is a no-op.
| data | Current snapshot of the node's data. |
| connectedAttrIDs | Set of attribute IDs that are currently connected. Pins in this set are rendered filled; others outlined. |
Definition at line 37 of file NodeBranchRenderer.cpp.
References Olympe::NodeBranchData::breakpoint, Olympe::NodeBranchData::dynamicPins, GetComponentTypeID_Static(), m_refreshPending, Olympe::NodeBranchData::nodeID, Olympe::NodeBranchData::nodeName, RenderConditionsSection(), and RenderDynamicPinsSection().
Here is the call graph for this function:Definition at line 396 of file NodeBranchRenderer.cpp.
|
private |
Definition at line 403 of file NodeBranchRenderer.cpp.
| void Olympe::NodeBranchRenderer::RenderTitleSection | ( | const NodeBranchData & | data | ) |
Renders Section 1: title bar with blue background.
Displays the node name on a blue-highlighted background row.
| data | Node data. |
Definition at line 152 of file NodeBranchRenderer.cpp.
References Olympe::NodeBranchData::breakpoint, GetComponentTypeID_Static(), and Olympe::NodeBranchData::nodeName.
Here is the call graph for this function:| void Olympe::NodeBranchRenderer::SetupDynamicPinConnectors | ( | const NodeBranchData & | data | ) |
Sets up ImNodes connectors for each dynamic pin.
Call this within an ImNodes::BeginNode() / ImNodes::EndNode() block so each yellow dynamic pin becomes drag-connectable in the graph editor. Each pin receives a connector ID derived from pin.id.
In headless / test builds this is a no-op.
| data | Node data (dynamicPins are iterated). |
Definition at line 362 of file NodeBranchRenderer.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:| void Olympe::NodeBranchRenderer::TriggerPinRegeneration | ( | std::vector< NodeConditionRef > & | conditionRefs | ) |
Regenerates dynamic data pins from an updated condition list.
Call this after the user confirms changes in the edit modal so the canvas reflects the new pin set on the next render frame.
Delegates to DynamicDataPinManager::RegeneratePinsFromConditions() so the host does not need a direct reference to the pin manager.
| conditionRefs | Node's condition list (modified in-place to store updated pin IDs). |
Definition at line 377 of file NodeBranchRenderer.cpp.
References m_pinManager, and Olympe::DynamicDataPinManager::RegeneratePinsFromConditions().
Here is the call graph for this function:Definition at line 270 of file NodeBranchRenderer.h.
Definition at line 269 of file NodeBranchRenderer.h.
Yellow dynamic-pin label color (FFD700 equivalent).
Definition at line 268 of file NodeBranchRenderer.h.
Definition at line 265 of file NodeBranchRenderer.h.
Definition at line 264 of file NodeBranchRenderer.h.
Blue title bar background color (#0066CC equivalent).
Definition at line 263 of file NodeBranchRenderer.h.
|
private |
Interaction state.
Definition at line 285 of file NodeBranchRenderer.h.
Referenced by ClearLastClickedCondition(), GetLastClickedConditionIndex(), and RenderConditionsSection().
|
private |
Shared dynamic pin manager.
Definition at line 284 of file NodeBranchRenderer.h.
Referenced by TriggerPinRegeneration().
Dirty flag.
Definition at line 286 of file NodeBranchRenderer.h.
Referenced by ClearRefreshPending(), IsRefreshPending(), NotifyPresetChanged(), and RenderNode().
|
private |
Shared global registry.
Definition at line 283 of file NodeBranchRenderer.h.
Referenced by RenderConditionsSection().
Fired when the user clicks on a condition row.
Arg: zero-based condition index.
Definition at line 226 of file NodeBranchRenderer.h.
Referenced by RenderConditionsSection().