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

Renders a NodeBranch using ImGui/ImNodes with 4 sections. More...

#include <NodeBranchRenderer.h>

+ Collaboration diagram for Olympe::NodeBranchRenderer:

Public Member Functions

 NodeBranchRenderer (ConditionPresetRegistry &registry, DynamicDataPinManager &pinManager)
 Constructs the renderer with its dependencies.
 
 ~NodeBranchRenderer ()=default
 
 NodeBranchRenderer (const NodeBranchRenderer &)=delete
 
NodeBranchRendereroperator= (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

ConditionPresetRegistrym_registry
 Shared global registry.
 
DynamicDataPinManagerm_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
 

Detailed Description

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:

// In the ImNodes frame:
renderer.RenderNode(nodeID, branchData);
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static SDL_Renderer * renderer
Renders a NodeBranch using ImGui/ImNodes with 4 sections.

Definition at line 91 of file NodeBranchRenderer.h.

Constructor & Destructor Documentation

◆ NodeBranchRenderer() [1/2]

Olympe::NodeBranchRenderer::NodeBranchRenderer ( ConditionPresetRegistry registry,
DynamicDataPinManager pinManager 
)

Constructs the renderer with its dependencies.

Parameters
registryGlobal ConditionPresetRegistry.
pinManagerDynamicDataPinManager for the node being rendered.

Definition at line 26 of file NodeBranchRenderer.cpp.

◆ ~NodeBranchRenderer()

Olympe::NodeBranchRenderer::~NodeBranchRenderer ( )
default

◆ NodeBranchRenderer() [2/2]

Olympe::NodeBranchRenderer::NodeBranchRenderer ( const NodeBranchRenderer )
delete

Member Function Documentation

◆ ClearLastClickedCondition()

void Olympe::NodeBranchRenderer::ClearLastClickedCondition ( )
inline

Resets the last-clicked condition index to -1.

Definition at line 216 of file NodeBranchRenderer.h.

References m_lastClickedCondition.

◆ ClearRefreshPending()

void Olympe::NodeBranchRenderer::ClearRefreshPending ( )
inline

Clears the refresh-pending flag (called after refresh is complete).

Definition at line 254 of file NodeBranchRenderer.h.

References m_refreshPending.

◆ GetLastClickedConditionIndex()

int Olympe::NodeBranchRenderer::GetLastClickedConditionIndex ( ) const
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.

◆ IsRefreshPending()

bool Olympe::NodeBranchRenderer::IsRefreshPending ( ) const
inline

Returns true if any preset change notification is pending (dirty).

Definition at line 249 of file NodeBranchRenderer.h.

References m_refreshPending.

◆ NotifyPresetChanged()

void Olympe::NodeBranchRenderer::NotifyPresetChanged ( const std::string &  changedPresetID)

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.

Parameters
changedPresetIDUUID of the modified preset.

Definition at line 387 of file NodeBranchRenderer.cpp.

References m_refreshPending.

◆ operator=()

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

◆ RenderConditionsSection()

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.

Parameters
dataNode 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:

◆ RenderDynamicPinsSection()

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>"

Parameters
dataNode data.
connectedAttrIDsSet 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:

◆ RenderExecPinsSection()

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.

Parameters
dataNode data.

Definition at line 178 of file NodeBranchRenderer.cpp.

References GetComponentTypeID_Static().

+ Here is the call graph for this function:

◆ RenderNode()

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.

Parameters
dataCurrent snapshot of the node's data.
connectedAttrIDsSet 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:

◆ RenderSectionHeader()

void Olympe::NodeBranchRenderer::RenderSectionHeader ( const char label)
private

Definition at line 396 of file NodeBranchRenderer.cpp.

◆ RenderSectionSeparator()

void Olympe::NodeBranchRenderer::RenderSectionSeparator ( )
private

Definition at line 403 of file NodeBranchRenderer.cpp.

◆ RenderTitleSection()

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.

Parameters
dataNode 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:

◆ SetupDynamicPinConnectors()

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.

Parameters
dataNode data (dynamicPins are iterated).

Definition at line 362 of file NodeBranchRenderer.cpp.

References GetComponentTypeID_Static().

+ Here is the call graph for this function:

◆ TriggerPinRegeneration()

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.

Parameters
conditionRefsNode'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:

Member Data Documentation

◆ kDynPinB

constexpr float Olympe::NodeBranchRenderer::kDynPinB = 0.0f
staticconstexprprivate

Definition at line 270 of file NodeBranchRenderer.h.

◆ kDynPinG

constexpr float Olympe::NodeBranchRenderer::kDynPinG = 0.843f
staticconstexprprivate

Definition at line 269 of file NodeBranchRenderer.h.

◆ kDynPinR

constexpr float Olympe::NodeBranchRenderer::kDynPinR = 1.0f
staticconstexprprivate

Yellow dynamic-pin label color (FFD700 equivalent).

Definition at line 268 of file NodeBranchRenderer.h.

◆ kTitleB

constexpr float Olympe::NodeBranchRenderer::kTitleB = 0.8f
staticconstexprprivate

Definition at line 265 of file NodeBranchRenderer.h.

◆ kTitleG

constexpr float Olympe::NodeBranchRenderer::kTitleG = 0.4f
staticconstexprprivate

Definition at line 264 of file NodeBranchRenderer.h.

◆ kTitleR

constexpr float Olympe::NodeBranchRenderer::kTitleR = 0.0f
staticconstexprprivate

Blue title bar background color (#0066CC equivalent).

Definition at line 263 of file NodeBranchRenderer.h.

◆ m_lastClickedCondition

int Olympe::NodeBranchRenderer::m_lastClickedCondition = -1
private

Interaction state.

Definition at line 285 of file NodeBranchRenderer.h.

Referenced by ClearLastClickedCondition(), GetLastClickedConditionIndex(), and RenderConditionsSection().

◆ m_pinManager

DynamicDataPinManager& Olympe::NodeBranchRenderer::m_pinManager
private

Shared dynamic pin manager.

Definition at line 284 of file NodeBranchRenderer.h.

Referenced by TriggerPinRegeneration().

◆ m_refreshPending

bool Olympe::NodeBranchRenderer::m_refreshPending = false
private

Dirty flag.

Definition at line 286 of file NodeBranchRenderer.h.

Referenced by ClearRefreshPending(), IsRefreshPending(), NotifyPresetChanged(), and RenderNode().

◆ m_registry

ConditionPresetRegistry& Olympe::NodeBranchRenderer::m_registry
private

Shared global registry.

Definition at line 283 of file NodeBranchRenderer.h.

Referenced by RenderConditionsSection().

◆ OnConditionClicked

std::function<void(int)> Olympe::NodeBranchRenderer::OnConditionClicked

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().


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