13#include "../../NodeGraphCore/GlobalTemplateBlackboard.h"
15#ifndef OLYMPE_HEADLESS
16#include "../../third_party/imgui/imgui.h"
25 static const std::vector<std::string>
ops = {
"==",
"!=",
"<",
"<=",
">",
">=" };
31 static const std::vector<std::string>
modes = {
"Variable",
"Const",
"Pin" };
38 : m_mode(
Mode::Create)
68 if (mode ==
"Variable")
70 else if (mode ==
"Const")
72 else if (mode ==
"Pin")
98 if (mode ==
"Variable")
100 else if (mode ==
"Const")
102 else if (mode ==
"Pin")
133 const auto&
ops = GetValidOperators();
134 return std::find(
ops.begin(),
ops.end(), op) !=
ops.end();
139 const auto&
modes = GetValidModes();
146 return !
operand.stringValue.empty();
148 return !
operand.stringValue.empty();
165 if (!
IsValid()) {
return false; }
174#ifndef OLYMPE_HEADLESS
178 ?
"Create Condition Preset"
179 :
"Edit Condition Preset";
182 ImGui::OpenPopup(title);
184 if (ImGui::BeginPopupModal(title, &
m_isOpen,
215#ifndef OLYMPE_HEADLESS
218 ImGui::PushID(label);
219 ImGui::Text(
"%s:", label);
221 const char*
const modeItems[] = {
"Variable",
"Const",
"Pin" };
226 ImGui::SetNextItemWidth(90.f);
243 const std::vector<GlobalEntryDefinition>&
globalVars =
gtb.GetAllVariables();
280 ImGui::TextDisabled(
"(no variables)");
284 ImGui::SetNextItemWidth(120.f);
307 float fval =
static_cast<float>(
operand.constValue);
308 ImGui::SetNextItemWidth(80.f);
309 if (ImGui::InputFloat(
"##const", &
fval, 0.f, 0.f,
"%.2f"))
321 ImGui::SetNextItemWidth(120.f);
322 if (ImGui::InputText(
"##pin",
buf,
sizeof(
buf)))
334#ifndef OLYMPE_HEADLESS
335 const auto&
ops = GetValidOperators();
344 const char* items[] = {
"==",
"!=",
"<",
"<=",
">",
">=" };
345 ImGui::SetNextItemWidth(70.f);
346 if (ImGui::Combo(
"Operator", &
opIdx, items,
static_cast<int>(
ops.size())))
355#ifndef OLYMPE_HEADLESS
357 ImGui::Text(
"Preview: %s",
preview.c_str());
363#ifndef OLYMPE_HEADLESS
364 const bool canSave =
IsValid();
365 if (!canSave) { ImGui::BeginDisabled(); }
367 if (ImGui::Button(
"Save"))
371 ImGui::CloseCurrentPopup();
374 if (!canSave) { ImGui::EndDisabled(); }
377 if (ImGui::Button(
"Cancel"))
380 ImGui::CloseCurrentPopup();
Modal dialog for creating and editing Condition Presets (Phase 24.1).
ComponentTypeID GetComponentTypeID_Static()
void SetOperator(const std::string &op)
Sets the comparison operator.
void SetName(const std::string &name)
Sets the display name of the working preset.
ConditionPresetEditDialog()
Constructs the dialog in Create mode with a blank preset.
ConditionPreset m_workingCopy
In-progress edits.
bool Confirm()
Confirms the dialog programmatically (equivalent to pressing Save).
ConditionPreset GetResult() const
Returns a copy of the working preset (contains the current form state).
static bool IsValidOperator(const std::string &op)
Returns true if the given operator string is recognised.
void SetRightVariable(const std::string &varName)
Sets the right variable name.
void SetRightPin(const std::string &pinRef)
Sets the right pin reference (relevant when rightMode == "Pin").
std::vector< BlackboardEntry > m_localVariables
Local variables from entity (Phase 24)
static bool IsOperandFilled(const Operand &operand)
Returns true if the operand is sufficiently filled.
static bool IsValidMode(const std::string &mode)
Returns true if the given mode string is recognised.
void RenderOperatorSelector()
void SetLeftPin(const std::string &pinRef)
Sets the left pin reference.
std::string GetPreview() const
Returns a live preview string of the current condition.
void RenderOperandSelector(const char *label, bool isLeft)
void RenderConfirmButtons()
void SetLeftVariable(const std::string &varName)
Sets the left variable name (relevant when leftMode == "Variable").
void SetLeftConst(double value)
Sets the left constant value.
bool IsValid() const
Returns true if the current condition is valid and can be saved.
void Render()
Renders the modal dialog using ImGui.
Mode
Whether the dialog creates a new preset or edits an existing one.
@ Create
New preset (form starts empty)
@ Edit
Existing preset (form pre-populated)
void SetRightMode(const std::string &mode)
Sets the right operand mode.
void SetLeftMode(const std::string &mode)
Sets the left operand mode.
void SetRightConst(double value)
Sets the right constant value.
static GlobalTemplateBlackboard & Get()
const std::vector< std::string > & GetValidModes()
const std::vector< std::string > & GetValidOperators()
< Provides AssetID and INVALID_ASSET_ID
A globally-stored, reusable condition expression.
std::string GetPreview() const
Returns a human-readable preview string.
static std::string OpToString(ComparisonOp o)
Returns the operator as a display string (e.g. "<=").
static ComparisonOp OpFromString(const std::string &s)
Parses a display string back to a ComparisonOp.
std::string name
Human-readable display name (e.g. "Condition #1")
One side of a ConditionPreset comparison expression.
static Operand CreateVariable(const std::string &variableID)
Factory — creates a Variable-mode operand.
static Operand CreatePin(const std::string &pinLabel)
Factory — creates a Pin-mode operand.
static Operand CreateConst(double constVal)
Factory — creates a Const-mode operand.