Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
VariablePropertyPanel.cpp
Go to the documentation of this file.
1/**
2 * @file VariablePropertyPanel.cpp
3 * @brief Implementation of VariablePropertyPanel.
4 * @author Olympe Engine
5 * @date 2026-03-20
6 *
7 * Phase 24.1: Data Pure Nodes
8 *
9 * C++14 compliant.
10 */
11
13#include "../../third_party/imgui/imgui.h"
14#include "../../system/system_utils.h"
15
16namespace Olympe {
17
19 : m_template(nullptr)
20 , m_dirty(false)
21{
22}
23
24void VariablePropertyPanel::SetNodeName(const std::string& name)
25{
26 m_nodeName = name;
27}
28
34
35void VariablePropertyPanel::SetBBKey(const std::string& key)
36{
37 if (m_selectedBBKey != key)
38 {
40 m_dirty = true;
41 }
42}
43
44const std::string& VariablePropertyPanel::GetBBKey() const
45{
46 return m_selectedBBKey;
47}
48
50{
52
53 if (m_template == nullptr)
54 return;
55
56 for (size_t i = 0; i < m_template->Blackboard.size(); ++i)
57 {
59 m_availableVariables.push_back(entry.Key);
60 }
61}
62
64{
65 if (m_template == nullptr)
66 {
67 ImGui::TextColored(ImVec4(1, 0, 0, 1), "No template loaded");
68 return;
69 }
70
71 ImGui::Spacing();
72 ImGui::Separator();
73 ImGui::Text("Variable: %s", m_nodeName.c_str());
74 ImGui::Separator();
75 ImGui::Spacing();
76
77 ImGui::TextUnformatted("Select Variable:");
78
79 // Dropdown for variable selection
80 if (ImGui::BeginCombo("##variable_selector", m_selectedBBKey.c_str()))
81 {
82 for (size_t i = 0; i < m_availableVariables.size(); ++i)
83 {
84 const std::string& varName = m_availableVariables[i];
85 bool isSelected = (m_selectedBBKey == varName);
86
87 if (ImGui::Selectable(varName.c_str(), isSelected))
88 {
90 }
91
92 if (isSelected)
93 ImGui::SetItemDefaultFocus();
94 }
95 ImGui::EndCombo();
96 }
97
98 ImGui::Spacing();
99
100 // Show variable info if selected
101 if (!m_selectedBBKey.empty() && m_template != nullptr)
102 {
103 for (size_t i = 0; i < m_template->Blackboard.size(); ++i)
104 {
106 if (entry.Key == m_selectedBBKey)
107 {
108 ImGui::TextDisabled("Type: %s",
109 (entry.Type == VariableType::Bool ? "Bool" :
110 entry.Type == VariableType::Int ? "Int" :
111 entry.Type == VariableType::Float ? "Float" :
112 entry.Type == VariableType::Vector ? "Vector" :
113 entry.Type == VariableType::EntityID ? "EntityID" :
114 entry.Type == VariableType::String ? "String" : "Unknown"));
115 break;
116 }
117 }
118 }
119}
120
121} // namespace Olympe
122
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
UI Properties panel for a Variable node – variable selector.
Immutable, shareable task graph asset.
std::vector< BlackboardEntry > Blackboard
Local blackboard declared in this graph.
std::vector< std::string > m_availableVariables
const std::string & GetBBKey() const
Returns the current (possibly modified) BB key.
void Render()
Renders the panel into the current ImGui context.
void RebuildVariableList()
Rebuilds the list of available blackboard variables.
const TaskGraphTemplate * m_template
void SetBBKey(const std::string &key)
Sets the currently selected BB key.
void SetTemplate(const TaskGraphTemplate *tmpl)
Sets the template reference for blackboard variable lookup.
VariablePropertyPanel()
Constructs the panel.
void SetNodeName(const std::string &name)
Sets the node name displayed in the title section.
< Provides AssetID and INVALID_ASSET_ID
@ Int
32-bit signed integer
@ Float
Single-precision float.
@ String
std::string
@ Vector
3-component vector (Vector from vector.h)
@ EntityID
Entity identifier (uint64_t)
Single entry in the graph's declared blackboard schema (local or global).