Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
SetBBValuePropertyPanel.cpp
Go to the documentation of this file.
1/**
2 * @file SetBBValuePropertyPanel.cpp
3 * @brief Implementation of SetBBValue properties panel.
4 */
5
7#include "../../third_party/imgui/imgui.h"
8#include "../../BlueprintEditor/BBVariableRegistry.h"
9
10namespace Olympe {
11
16
17void SetBBValuePropertyPanel::SetNodeName(const std::string& name)
18{
19 m_nodeName = name;
20}
21
26
27void SetBBValuePropertyPanel::SetBBKey(const std::string& key)
28{
29 m_bbKey = key;
30}
31
32const std::string& SetBBValuePropertyPanel::GetBBKey() const
33{
34 return m_bbKey;
35}
36
38{
40 ImGui::Spacing();
41
43 ImGui::Spacing();
44
46}
47
49{
50 ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.8f, 0.4f, 0.0f, 1.0f));
51 ImGui::Text("SetBBValue: %s", m_nodeName.c_str());
52 ImGui::PopStyleColor();
53}
54
56{
57 if (!m_template)
58 {
59 ImGui::TextDisabled("(no template)");
60 return;
61 }
62
65 const std::vector<VarSpec>& vars = bbReg.GetAllVariables();
66
67 ImGui::Text("Target Variable:");
68 ImGui::Indent();
69
70 const char* previewLabel = m_bbKey.empty() ? "(select variable...)" : m_bbKey.c_str();
71 ImGui::SetNextItemWidth(200.0f);
72
73 if (ImGui::BeginCombo("##bbvar_target", previewLabel))
74 {
75 for (size_t i = 0; i < vars.size(); ++i)
76 {
77 const VarSpec& v = vars[i];
78 bool selected = (v.name == m_bbKey);
79
80 // Display with type info (displayLabel already includes type and scope)
81 if (ImGui::Selectable(v.displayLabel.c_str(), selected))
82 {
83 if (m_bbKey != v.name)
84 {
85 m_bbKey = v.name;
86 m_dirty = true;
87 }
88 }
89
90 if (selected)
91 ImGui::SetItemDefaultFocus();
92 }
93 ImGui::EndCombo();
94 }
95
96 ImGui::Unindent();
97}
98
100{
101 if (m_bbKey.empty() || !m_template)
102 return;
103
104 ImGui::Separator();
105 ImGui::Text("Value Input:");
106 ImGui::Indent();
107
108 // Find the variable to get its type
109 for (const auto& entry : m_template->Blackboard)
110 {
111 if (entry.Key == m_bbKey)
112 {
113 std::string typeStr;
114 switch (entry.Type)
115 {
116 case VariableType::Bool: typeStr = "Bool"; break;
117 case VariableType::Int: typeStr = "Int"; break;
118 case VariableType::Float: typeStr = "Float"; break;
119 case VariableType::String: typeStr = "String"; break;
120 case VariableType::Vector: typeStr = "Vector"; break;
121 default: typeStr = "Unknown"; break;
122 }
123
124 ImGui::Text("Type: %s", typeStr.c_str());
125 ImGui::TextDisabled("(Value set at runtime via incoming exec or parameter binding)");
126
127 break;
128 }
129 }
130
131 ImGui::Unindent();
132}
133
134} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
UI Properties panel for a SetBBValue node – variable and value editor.
Non-singleton registry populated from the active TaskGraphTemplate.
void LoadFromTemplate(const TaskGraphTemplate &tmpl)
Rebuilds the registry from the blackboard entries of a template.
void SetTemplate(const TaskGraphTemplate *tmpl)
void SetNodeName(const std::string &name)
void SetBBKey(const std::string &key)
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")