14#include "../system/system_utils.h"
15#include "../NodeGraphCore/GlobalTemplateBlackboard.h"
16#include "../third_party/imgui/imgui.h"
20#include <unordered_map>
27 ImGui::TextDisabled(
"Local Blackboard");
43 ImGui::TextUnformatted(
"[!] Invalid entries will be skipped on save");
44 ImGui::PopStyleColor();
47 if (ImGui::Button(
"+##vsbbAdd"))
49 BlackboardEntry
entry;
50 entry.Key =
"NewVariable";
53 entry.IsGlobal =
false;
58 ImGui::TextDisabled(
"Add key");
68 ImGui::SetNextItemWidth(120.0f);
76 const char*
typeLabels[] = {
"Bool",
"Int",
"Float",
"Vector",
"EntityID",
"String"};
83 ImGui::SetNextItemWidth(80.0f);
93 ImGui::Checkbox(
"G##bbglob", &
entry.IsGlobal);
96 if (ImGui::SmallButton(
"x##bbdel"))
105 ImGui::TextDisabled(
"Default:");
112 if (ImGui::Checkbox(
"##bbval", &
bVal))
122 ImGui::SetNextItemWidth(70.0f);
123 if (ImGui::InputInt(
"##bbval", &
iVal))
132 float fVal =
entry.Default.IsNone() ? 0.0f :
entry.Default.AsFloat();
133 ImGui::SetNextItemWidth(70.0f);
134 if (ImGui::InputFloat(
"##bbval", &
fVal, 0.0f, 0.0f,
"%.3f"))
143 std::string
sVal =
entry.Default.IsNone() ?
"" :
entry.Default.AsString();
146 ImGui::SetNextItemWidth(100.0f);
147 if (ImGui::InputText(
"##bbval",
sBuf,
sizeof(
sBuf)))
149 entry.Default = TaskValue(std::string(
sBuf));
156 ImGui::BeginDisabled(
true);
157 float vecVal[3] = { 0.0f, 0.0f, 0.0f };
158 ImGui::SetNextItemWidth(140.0f);
159 ImGui::DragFloat3(
"##bbval",
vecVal, 0.1f);
160 ImGui::EndDisabled();
162 ImGui::TextDisabled(
"(auto from entity position)");
167 ImGui::BeginDisabled(
true);
169 ImGui::SetNextItemWidth(70.0f);
170 ImGui::InputInt(
"##bbval", &entityId);
171 ImGui::EndDisabled();
173 ImGui::TextDisabled(
"(assigned at runtime)");
177 ImGui::TextDisabled(
"(n/a)");
187 ImGui::TextDisabled(
"Local Blackboard");
203 ImGui::TextUnformatted(
"[!] Invalid entries will be skipped on save");
204 ImGui::PopStyleColor();
207 if (ImGui::Button(
"+##vsbbAdd"))
209 BlackboardEntry
entry;
210 entry.Key =
"NewVariable";
213 entry.IsGlobal =
false;
218 ImGui::TextDisabled(
"Add key");
230 ImGui::SetNextItemWidth(140.0f);
231 if (ImGui::InputText(
"##bbkey",
keyBuf,
sizeof(
keyBuf)))
254 ImGui::TextDisabled(
"/!\\ %s",
validation.ErrorMessage.c_str());
255 ImGui::PopStyleColor();
261 ImGui::TextDisabled(
"[i] %s",
validation.WarningMessage.c_str());
262 ImGui::PopStyleColor();
268 const char*
typeNames[] = {
"None",
"Bool",
"Int",
"Float",
"String",
"Vector" };
274 for (
int ti = 0;
ti < 6; ++
ti)
278 ImGui::SetNextItemWidth(80.0f);
289 ImGui::TextDisabled(
"Default:");
295 bool isGlobal =
entry.IsGlobal;
296 if (ImGui::Checkbox(
"G##bbglobal", &isGlobal))
298 entry.IsGlobal = isGlobal;
301 if (ImGui::IsItemHovered())
302 ImGui::SetTooltip(
"Mark as global variable");
305 if (ImGui::Button(
"X##bbdel"))
318 ImGui::TextDisabled(
"Global Variables (Editor Instance)");
322 const std::vector<GlobalEntryDefinition>&
globalVars =
gtb.GetAllVariables();
324 if (ImGui::Button(
"+##globalVarAdd",
ImVec2(30, 0)))
326 ImGui::OpenPopup(
"AddGlobalVariablePopup");
329 ImGui::TextDisabled(
"Add global variable");
348 ImGui::TextUnformatted(
validation.ErrorMessage.c_str());
349 ImGui::PopStyleColor();
354 ImGui::TextUnformatted(
validation.WarningMessage.c_str());
355 ImGui::PopStyleColor();
362 ImGui::TextUnformatted(
"/!\\ Variable already exists in global registry");
363 ImGui::PopStyleColor();
367 const char*
typeOptions[] = {
"Bool",
"Int",
"Float",
"String",
"Vector",
"EntityID" };
380 ImGui::BeginDisabled(
true);
382 if (ImGui::Button(
"Create",
ImVec2(120, 0)))
402 ImGui::CloseCurrentPopup();
407 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
409 ImGui::CloseCurrentPopup();
413 ImGui::EndDisabled();
422 ImGui::TextDisabled(
"(no global variables defined)");
423 ImGui::TextDisabled(
"Click [+] above to create new global variables");
427 ImGui::TextDisabled(
"Global variables from project registry");
428 ImGui::TextDisabled(
"Values shown are editor-specific (persisted with graph)");
433 ImGui::TextColored(
ImVec4(1.0f, 0.5f, 0.5f, 1.0f),
"[ERROR] EntityBlackboard not initialized");
441 ImGui::PushID(
static_cast<int>(
gi));
443 ImGui::TextColored(
ImVec4(0.8f, 0.95f, 1.0f, 1.0f),
"(%s) %s",
448 ImGui::TextDisabled(
"(%.1f KB)", 0.1f);
451 if (ImGui::SmallButton(
"Delete##globalvar"))
469 ImGui::TextDisabled(
" %s",
globalDef.Description.c_str());
472 std::string
tableId =
"##GlobalVarTable_" + std::to_string(
gi);
475 ImGui::TableSetupColumn(
"Label", 0);
476 ImGui::TableSetupColumn(
"Value", 0);
478 ImGui::TableNextRow();
479 ImGui::TableSetColumnIndex(0);
480 ImGui::TextDisabled(
"Default:");
481 ImGui::TableSetColumnIndex(1);
483 const TaskValue& defaultValue =
globalDef.DefaultValue;
488 defaultStr = defaultValue.IsNone() ?
"false" : (defaultValue.AsBool() ?
"true" :
"false");
491 defaultStr = defaultValue.IsNone() ?
"0" : std::to_string(defaultValue.AsInt());
495 std::ostringstream
oss;
496 oss << std::fixed << std::setprecision(2);
497 oss << (defaultValue.IsNone() ? 0.0f : defaultValue.AsFloat());
502 defaultStr = defaultValue.IsNone() ?
"" : defaultValue.AsString();
508 defaultStr = defaultValue.IsNone() ?
"0" : std::to_string(
static_cast<int>(defaultValue.AsEntityID()));
514 ImGui::TextDisabled(
"%s",
defaultStr.c_str());
516 ImGui::TableNextRow();
517 ImGui::TableSetColumnIndex(0);
518 ImGui::TextDisabled(
"Current:");
519 ImGui::TableSetColumnIndex(1);
530 if (ImGui::Checkbox(
"##bool_val", &
bVal))
541 if (ImGui::InputInt(
"##int_val", &
iVal))
552 if (ImGui::InputFloat(
"##float_val", &
fVal))
562 static std::unordered_map<size_t, std::vector<char>>
stringBuffers;
572 ImGui::SetNextItemWidth(-1.0f);
586 if (ImGui::InputFloat3(
"##vector_val",
vArray))
598 if (ImGui::InputInt(
"##entityid_val", &
eID))
607 ImGui::TextDisabled(
"(unsupported type)");
613 ImGui::TableNextRow();
614 ImGui::TableSetColumnIndex(0);
615 ImGui::TextDisabled(
"Flags:");
616 ImGui::TableSetColumnIndex(1);
617 ImGui::TextColored(
ImVec4(0.7f, 0.9f, 0.5f, 1.0f),
"[Persistent]");
647 if (ImGui::Button(
"Presets##tab0",
ImVec2(0, 0)))
650 ImGui::PopStyleColor();
663 if (ImGui::Button(
"Local Variables##tab1",
ImVec2(0, 0)))
666 ImGui::PopStyleColor();
679 if (ImGui::Button(
"Global Variables##tab2",
ImVec2(0, 0)))
682 ImGui::PopStyleColor();
685 ImGui::PopStyleVar(2);
ComponentTypeID GetComponentTypeID_Static()
ImNodes-based graph editor for ATS Visual Script graphs (Phase 5).
static void Reload()
Force reload of the registry from file (useful for hot reload)
static GlobalTemplateBlackboard & Get()
std::vector< BlackboardEntry > Blackboard
Local blackboard declared in this graph.
TaskGraphTemplate m_template
The template currently being edited.
void RenderRightPanelTabs()
Phase 26 — Tab system: Renders the tab bar for the 3-panel right section Displays tabs for Presets,...
std::unique_ptr< EntityBlackboard > m_entityBlackboard
Per-entity blackboard instance (combines local + global variables) Created in Initialize() and manage...
std::unordered_map< int, std::string > m_pendingBlackboardEdits
Deferred key-name edits for blackboard entries: index -> pending new key.
void RenderGlobalVariablesPanel()
Phase 24 Global Blackboard — Renders global variables panel.
void RenderLocalVariablesPanel()
Part C: Local Variables reference panel (bottom of right panel)
void RenderConstValueInput(TaskValue &value, VariableType varType, const char *label)
Renders a type-aware const value input widget.
void RenderRightPanelTabContent()
Phase 26 — Tab system: Renders the content of the active tab Dispatches to appropriate render functio...
BlackboardValidationResult ValidateBlackboardKey(const std::string &key, bool isGlobal, int excludeIndex=-1)
Validates a blackboard key according to schema rules.
int m_rightPanelTabSelection
Phase 26 — Right panel tab selection 0 = Presets, 1 = Local Variables, 2 = Global Variables.
void RenderPresetBankPanel()
Part B: Preset Bank panel (middle of right panel)
< Provides AssetID and INVALID_ASSET_ID
VariableType
Type tags used by TaskValue to identify stored data.
@ Int
32-bit signed integer
@ Float
Single-precision float.
@ Vector
3-component vector (Vector from vector.h)
@ None
Uninitialized / empty value.
@ EntityID
Entity identifier (uint64_t)
static std::string VariableTypeToString(VariableType type)
Converts a VariableType to its canonical string representation.
static TaskValue GetDefaultValueForType(VariableType type)
Returns a correctly-typed default TaskValue for the given VariableType.