15#include "../../NodeGraphCore/GlobalTemplateBlackboard.h"
18#ifndef OLYMPE_HEADLESS
19# include "../../third_party/imgui/imgui.h"
108 std::ostringstream
oss;
110 cref.leftOperand.constValue =
oss.str();
123 default:
cref.operatorStr =
"==";
break;
126 switch (
preset->right.mode)
130 cref.rightOperand.variableName =
preset->right.stringValue;
139 std::ostringstream
oss;
141 cref.rightOperand.constValue =
oss.str();
229 std::vector<std::string> errors;
235 if (
ref.presetID.empty())
237 std::ostringstream
oss;
238 oss <<
"Condition " << (
i + 1) <<
": preset ID is empty.";
239 errors.push_back(
oss.str());
245 std::ostringstream
oss;
247 <<
"\" not found in registry.";
248 errors.push_back(
oss.str());
264std::vector<ConditionPreset>
270 std::vector<ConditionPreset> result;
275 result.push_back(*
p);
281 std::vector<ConditionPreset> result;
286 result.push_back(*
p);
297#ifndef OLYMPE_HEADLESS
298 ImGui::PushID(
"NodeConditionsPanel");
310#ifndef OLYMPE_HEADLESS
315 const bool editorOpen = ImGui::CollapsingHeader(
316 "Conditions Editor (Inline)",
318 ImGui::PopStyleColor(3);
326 ImGui::Text(
"Active Conditions:");
327 ImGui::BeginChild(
"ConditionsList##Inline",
ImVec2(0.f, 120.f),
true);
341 ImGui::Unindent(8.f);
348#ifndef OLYMPE_HEADLESS
349 ImGui::PushID(
static_cast<int>(
index));
354 ImGui::TextDisabled(
" ");
358 const char*
ops[] = {
"And",
"Or" };
360 ImGui::SetNextItemWidth(60.f);
376 ImGui::TextColored(
ImVec4(0.0f, 1.0f, 0.0f, 1.0f),
377 "[%s] %s",
preset->name.c_str(),
preset->GetPreview().c_str());
381 ImGui::TextColored(
ImVec4(1.f, 0.3f, 0.3f, 1.f),
382 "(missing: %s)",
ref.presetID.c_str());
388 if (ImGui::SmallButton(
"^##up"))
400 if (ImGui::SmallButton(
"v##dn"))
412 if (ImGui::SmallButton(
"X##del"))
429#ifndef OLYMPE_HEADLESS
431 if (ImGui::Button(
"+ Add Condition",
ImVec2(-1.f, 24.f)))
438 ImGui::TextDisabled(
"Search presets:");
447 ImGui::BeginChild(
"PresetPickerList##Inline",
ImVec2(0.f, 150.f),
true);
451 const std::string label =
preset.name +
" " +
preset.GetPreview();
452 if (ImGui::Selectable(label.c_str()))
469 ImGui::TextDisabled(
"No presets found.");
478#ifndef OLYMPE_HEADLESS
486 ImGui::PopStyleColor(4);
492#ifndef OLYMPE_HEADLESS
496 ImGui::TextDisabled(
"In");
498 ImGui::TextDisabled(
"Then");
500 ImGui::TextDisabled(
" ");
502 ImGui::TextDisabled(
"Else");
508#ifndef OLYMPE_HEADLESS
512 ImGui::TextDisabled(
"Conditions Preview:");
516 ImGui::TextDisabled(
" (no conditions)");
524 ImGui::PushID(
static_cast<int>(
i));
551 std::ostringstream
oss;
558 oss <<
"Pin-in #" << (
i + 1) <<
"L";
560 oss <<
cref.leftOperand.constValue;
564 oss <<
" " <<
cref.operatorStr <<
" ";
569 oss <<
cref.rightOperand.variableName;
571 oss <<
"Pin-in #" << (
i + 1) <<
"R";
573 oss <<
cref.rightOperand.constValue;
589 ImGui::PopStyleColor();
598 if (ImGui::Button(
"Edit Conditions",
ImVec2(-1.f, 24.f)))
609#ifndef OLYMPE_HEADLESS
617 const bool open = ImGui::CollapsingHeader(
618 "Structured Conditions (evaluated with implicit AND)",
620 ImGui::PopStyleColor();
629 size_t deleteIdx =
static_cast<size_t>(-1);
634 ImGui::PushID(
static_cast<int>(
i));
650 if (
pin.conditionIndex ==
static_cast<int>(
i))
659 ImGui::PushID(
"left");
669 ImGui::PushID(
"right");
703 if (ImGui::SmallButton(
"X"))
710 if (
deleteIdx !=
static_cast<size_t>(-1))
715 ImGui::TextDisabled(
"(no conditions — click [+ Add Condition] below)");
720 if (ImGui::Button(
"[+ Add Condition]",
ImVec2(-1.f, 0.f)))
721 ImGui::OpenPopup(
"##AddCondPopup");
723 if (ImGui::BeginPopup(
"##AddCondPopup"))
741 const std::string
rowLabel =
p.name +
" — " +
p.GetPreview();
742 if (ImGui::Selectable(
rowLabel.c_str()))
746 ImGui::CloseCurrentPopup();
754 ImGui::TextDisabled(
"(no presets in registry)");
764#ifndef OLYMPE_HEADLESS
769 const std::string displayLabel =
pin.GetDisplayLabel();
770 ImGui::TextColored(
pinColor,
"%s", displayLabel.c_str());
773 if (ImGui::IsItemHovered())
775 ImGui::SetTooltip(
"%s", displayLabel.c_str());
784#ifndef OLYMPE_HEADLESS
797 if (
pin.conditionIndex ==
cref.conditionIndex)
818 std::ostringstream
oss;
819 oss << std::fixed << std::setprecision(3) << std::stod(op.
constValue);
823 if (
dot != std::string::npos)
863 allOptions.push_back(
"--- Global Variables ---");
870 const std::vector<GlobalEntryDefinition>&
globalVars =
gtb.GetAllVariables();
883 ImGui::SetNextItemWidth(120.0f);
888 if (ImGui::BeginCombo(
"##operand_dropdown",
displayText))
944 static const size_t kBufSize = 128u;
953 ImGui::SetNextItemWidth(80.f);
971 ImGui::SetNextItemWidth(80.f);
972 if (ImGui::InputDouble(
"##constval", &
doubleVal, 0.0, 0.0,
"%.3f"))
974 std::ostringstream
oss;
985 ImGui::SetNextItemWidth(80.f);
986 ImGui::TextDisabled(
"%s",
display.c_str());
997#ifndef OLYMPE_HEADLESS
998 static const char*
kOperators[] = {
"==",
"!=",
"<",
"<=",
">",
">=" };
1011 ImGui::SetNextItemWidth(44.f);
ComponentTypeID GetComponentTypeID_Static()
UI Properties panel for a NodeBranch – 4-section layout (Phase 24-REFONTE).
Manages the global pool of ConditionPreset objects.
std::vector< std::string > GetAllPresetIDs() const
Returns all preset UUIDs in display order.
bool ValidatePresetID(const std::string &id) const
Returns true when a preset with the given UUID exists.
std::vector< ConditionPreset > GetFilteredPresets(const std::string &filter) const
Returns all presets whose name contains the filter substring.
std::vector< std::string > FindPresetsByName(const std::string &substring) const
Returns UUIDs of all presets whose name contains a substring.
ConditionPreset * GetPreset(const std::string &id)
Returns a mutable pointer to the preset, or nullptr if not found.
static GlobalTemplateBlackboard & Get()
void Open(const std::vector< NodeConditionRef > ¤tRefs, const std::vector< ConditionRef > &operandRefs=std::vector< ConditionRef >())
Opens the modal, loading the given condition refs for editing.
void RenderOperatorDropdown(ConditionRef &cref)
Renders the operator combo box (==, !=, <, <=, >, >=).
std::string m_nodeName
Node display name for title section.
std::vector< NodeConditionRef > m_conditionRefs
Current node's conditions.
void RenderTitleSection()
Section 1: title bar (blue background, node name).
const std::vector< ConditionRef > & GetConditionOperandRefs() const
Returns the current inline operand list.
void SetConditionRefs(const std::vector< NodeConditionRef > &refs)
Replaces the panel's internal condition list.
void RemoveCondition(size_t index)
Removes the condition at the given index.
void RenderInlineConditionRow(size_t index, const NodeConditionRef &ref)
Renders a single condition row with edit/move/delete controls.
void RenderConditionsPreview()
Section 3: read-only conditions preview (green text) + "Edit Conditions" button.
NodeConditionsEditModal m_editModal
Owned modal for condition editing.
std::vector< DynamicDataPin > m_dynamicPins
Read-only dynamic pins for display.
void NormalizeLogicalOps()
Fixes up the first condition's logicalOp to always be Start.
void RenderConditionList()
Renders all conditions inline as an editable list.
const std::vector< NodeConditionRef > & GetConditionRefs() const
Returns the current (possibly modified) condition list.
ConditionPresetRegistry & m_registry
Shared global registry.
NodeConditionsPanel(ConditionPresetRegistry ®istry)
Constructs the panel bound to a global preset registry.
void RenderInlineConditionEditor()
Phase 24 UX Refactor: Renders condition editor inline (no modal popup).
void AddCondition(const std::string &presetID)
Appends a new condition reference with the given preset.
void RenderExecPinsSection()
Section 2: static exec pins (In / Then / Else, never editable).
std::vector< ConditionRef > m_conditionOperandRefs
Inline operand data (parallel to m_conditionRefs)
std::vector< std::string > Validate() const
Returns a list of error strings describing validation failures.
void RenderDynamicPinsSection()
Section 4: dynamic data pins (yellow, only when non-empty).
void SetConditionOperandRefs(const std::vector< ConditionRef > &refs)
Replaces the panel's inline operand list (parallel to conditionRefs).
bool IsValid() const
Returns true when every condition ref points to an existing preset.
void OnPresetDeleted(const std::string &deletedPresetID)
Should be called by the host when a preset is deleted from the registry.
bool m_dirty
Modification flag.
std::string m_dropdownFilter
Filter text for "Add Condition" dropdown.
bool m_editModalRequested
Set when Edit button is clicked.
std::function< void()> OnDynamicPinsNeedRegeneration
Fired after the edit modal is confirmed and condition refs are updated, signalling that dynamic pins ...
void SetDynamicPins(const std::vector< DynamicDataPin > &pins)
Provides the read-only list of dynamic pins for display.
void Render()
Renders the condition list and dynamic-pin display using ImGui.
std::vector< BlackboardEntry > m_localVariables
Local variables from entity (Phase 24)
std::vector< ConditionPreset > GetFilteredPresetsForDropdown() const
Returns presets matching the current dropdown filter.
void SetLogicalOp(size_t index, LogicalOp op)
Changes the logical operator for the condition at the given index.
std::function< void(const std::string &)> OnPresetChanged
Fired when a preset is selected or changed.
void RenderInlineAddCondition()
Renders the "Add Condition" button and preset picker inline.
size_t GetConditionCount() const
Returns the number of conditions currently in the list.
void SetDropdownFilter(const std::string &filter)
Sets the search/filter string used by the "Add Condition" dropdown.
bool m_pickerOpen
Phase 24: Inline preset picker visibility.
void RenderOperandDropdown(ConditionRef &cref, bool isLeft, const std::string &pinLabel="")
Renders the operand mode selector + value field for one operand.
< Provides AssetID and INVALID_ASSET_ID
LogicalOp
How this condition is combined with the one preceding it.
@ Start
First condition in the list (no logical combinator)
@ Right
Pin provides data for the right operand of the condition.
@ Left
Pin provides data for the left operand of the condition.
@ Variable
References a blackboard variable by ID (string key)
@ Const
Literal numeric constant (double)
@ Pin
External data input pin on the node (identified by label)
A globally-stored, reusable condition expression.
Stores the complete reference for one condition including operand-to-DynamicDataPin mapping.
OperandRef leftOperand
Left-hand side of the comparison.
int conditionIndex
Index in the Branch/While node's conditions[] array.
One entry in a NodeBranch's conditions list.
std::string presetID
UUID of the referenced ConditionPreset.
References one operand of a condition (left or right).
@ Variable
References a blackboard variable by name.
@ Const
Literal constant value.
@ Pin
External data-input pin on the owning node.
std::string constValue
Literal string (mode == Const), e.g. "100.0".
std::string variableName
Blackboard key (mode == Variable), e.g. "mHealth".
std::string dynamicPinID
UUID of the DynamicDataPin that supplies this operand's value.
std::string stringValue
Variable ID or Pin label (mode == Variable|Pin)