Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
GetBBValuePropertyPanel.cpp
Go to the documentation of this file.
1/**
2 * @file GetBBValuePropertyPanel.cpp
3 * @brief Implementation of GetBBValue properties panel.
4 */
5
7#include "../../third_party/imgui/imgui.h"
8#include "../../BlueprintEditor/BBVariableRegistry.h"
9
10namespace Olympe {
11
12// ============================================================================
13// Constructor
14// ============================================================================
15
20
21// ============================================================================
22// State accessors
23// ============================================================================
24
25void GetBBValuePropertyPanel::SetNodeName(const std::string& name)
26{
27 m_nodeName = name;
28}
29
34
35void GetBBValuePropertyPanel::SetBBKey(const std::string& key)
36{
37 m_bbKey = key;
38}
39
40const std::string& GetBBValuePropertyPanel::GetBBKey() const
41{
42 return m_bbKey;
43}
44
45// ============================================================================
46// Rendering
47// ============================================================================
48
50{
52 ImGui::Spacing();
53
55 ImGui::Spacing();
56
58}
59
61{
62 ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.0f, 0.4f, 0.8f, 1.0f));
63 ImGui::Text("GetBBValue: %s", m_nodeName.c_str());
64 ImGui::PopStyleColor();
65}
66
68{
69 if (!m_template)
70 {
71 ImGui::TextDisabled("(no template)");
72 return;
73 }
74
77 const std::vector<VarSpec>& vars = bbReg.GetAllVariables();
78
79 ImGui::Text("Select Variable:");
80 ImGui::Indent();
81
82 const char* previewLabel = m_bbKey.empty() ? "(select variable...)" : m_bbKey.c_str();
83 ImGui::SetNextItemWidth(200.0f);
84
85 if (ImGui::BeginCombo("##bbvar_combo", previewLabel))
86 {
87 for (size_t i = 0; i < vars.size(); ++i)
88 {
89 const VarSpec& v = vars[i];
90 bool selected = (v.name == m_bbKey);
91
92 // Display with type info (displayLabel already includes type and scope)
93 if (ImGui::Selectable(v.displayLabel.c_str(), selected))
94 {
95 if (m_bbKey != v.name)
96 {
97 m_bbKey = v.name;
98 m_dirty = true;
99 }
100 }
101
102 if (selected)
103 ImGui::SetItemDefaultFocus();
104 }
105 ImGui::EndCombo();
106 }
107
108 ImGui::Unindent();
109}
110
112{
113 if (m_bbKey.empty() || !m_template)
114 return;
115
116 ImGui::Separator();
117 ImGui::Text("Variable Info:");
118 ImGui::Indent();
119
120 // Find the variable in template
121 for (const auto& entry : m_template->Blackboard)
122 {
123 if (entry.Key == m_bbKey)
124 {
125 // Display type
126 std::string typeStr;
127 switch (entry.Type)
128 {
129 case VariableType::Bool: typeStr = "Bool"; break;
130 case VariableType::Int: typeStr = "Int"; break;
131 case VariableType::Float: typeStr = "Float"; break;
132 case VariableType::String: typeStr = "String"; break;
133 case VariableType::Vector: typeStr = "Vector"; break;
134 default: typeStr = "Unknown"; break;
135 }
136 ImGui::Text("Type: %s", typeStr.c_str());
137
138 // Display default value
139 if (!entry.Default.IsNone())
140 {
141 ImGui::Text("Default: ");
142 ImGui::SameLine();
143 switch (entry.Type)
144 {
145 case VariableType::Bool: ImGui::Text("%s", entry.Default.AsBool() ? "true" : "false"); break;
146 case VariableType::Int: ImGui::Text("%d", entry.Default.AsInt()); break;
147 case VariableType::Float: ImGui::Text("%.3f", entry.Default.AsFloat()); break;
148 case VariableType::String: ImGui::Text("\"%s\"", entry.Default.AsString().c_str()); break;
150 {
151 const ::Vector v = entry.Default.AsVector();
152 ImGui::Text("(%.2f, %.2f, %.2f)", v.x, v.y, v.z);
153 break;
154 }
155 default: ImGui::Text("(N/A)"); break;
156 }
157 }
158
159 break;
160 }
161 }
162
163 ImGui::Unindent();
164}
165
166} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
UI Properties panel for a GetBBValue node – variable selector with preview.
Non-singleton registry populated from the active TaskGraphTemplate.
void LoadFromTemplate(const TaskGraphTemplate &tmpl)
Rebuilds the registry from the blackboard entries of a template.
void RenderTitleSection()
Renders the title section (node name in blue background).
void SetBBKey(const std::string &key)
Sets the currently selected BB key.
std::string m_bbKey
Current BB key selection.
void SetNodeName(const std::string &name)
Sets the node name displayed in the title section.
void RenderVariableSelector()
Renders the variable dropdown and info.
const TaskGraphTemplate * m_template
Template reference (not owned)
void RenderVariableInfo()
Renders variable type and default value information.
bool m_dirty
Changed since last ClearDirty()
void Render()
Renders the panel into the current ImGui context.
const std::string & GetBBKey() const
Returns the current (possibly modified) BB key.
std::string m_nodeName
Node name for display.
void SetTemplate(const TaskGraphTemplate *tmpl)
Sets the template reference for blackboard variable lookup.
Immutable, shareable task graph asset.
std::vector< BlackboardEntry > Blackboard
Local blackboard declared in this graph.
< 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)
Metadata for a single blackboard variable entry.
std::string name
Variable key (e.g. "health", "target")