![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Modal dialog for creating or editing a single ConditionPreset. More...
#include <ConditionPresetEditDialog.h>
Collaboration diagram for Olympe::ConditionPresetEditDialog:Public Types | |
| enum class | Mode { Create , Edit } |
| Whether the dialog creates a new preset or edits an existing one. More... | |
Public Member Functions | |
| ConditionPresetEditDialog () | |
| Constructs the dialog in Create mode with a blank preset. | |
| ConditionPresetEditDialog (Mode mode, const ConditionPreset *existingPreset=nullptr) | |
| Constructs the dialog in the given mode. | |
| ~ConditionPresetEditDialog ()=default | |
| bool | IsOpen () const |
| Returns true if the dialog is open. | |
| void | Open () |
| Opens the dialog. | |
| void | Close () |
| Closes the dialog without confirming. | |
| bool | IsConfirmed () const |
| Returns true if the user pressed "Save" / "OK". | |
| Mode | GetMode () const |
| Returns the dialog mode (Create or Edit). | |
| ConditionPreset | GetResult () const |
| Returns a copy of the working preset (contains the current form state). | |
| const Operand & | GetLeftOperand () const |
| Returns the current left operand. | |
| const Operand & | GetRightOperand () const |
| Returns the current right operand. | |
| ComparisonOp | GetOperator () const |
| Returns the current comparison operator. | |
| void | SetLeftMode (const std::string &mode) |
| Sets the left operand mode. | |
| void | SetLeftVariable (const std::string &varName) |
| Sets the left variable name (relevant when leftMode == "Variable"). | |
| void | SetLeftConst (double value) |
| Sets the left constant value. | |
| void | SetLeftPin (const std::string &pinRef) |
| Sets the left pin reference. | |
| void | SetOperator (const std::string &op) |
| Sets the comparison operator. | |
| void | SetRightMode (const std::string &mode) |
| Sets the right operand mode. | |
| void | SetRightVariable (const std::string &varName) |
| Sets the right variable name. | |
| void | SetRightConst (double value) |
| Sets the right constant value. | |
| void | SetRightPin (const std::string &pinRef) |
| Sets the right pin reference (relevant when rightMode == "Pin"). | |
| void | SetName (const std::string &name) |
| Sets the display name of the working preset. | |
| std::string | GetPreview () const |
| Returns a live preview string of the current condition. | |
| bool | IsValid () const |
| Returns true if the current condition is valid and can be saved. | |
| bool | Confirm () |
| Confirms the dialog programmatically (equivalent to pressing Save). | |
| void | Render () |
| Renders the modal dialog using ImGui. | |
| void | SetLocalVariables (const std::vector< BlackboardEntry > &localVars) |
| Sets the list of local variables from EntityBlackboard. | |
Private Member Functions | |
| void | RenderOperandSelector (const char *label, bool isLeft) |
| void | RenderOperatorSelector () |
| void | RenderPreview () |
| void | RenderConfirmButtons () |
Static Private Member Functions | |
| static bool | IsValidOperator (const std::string &op) |
| Returns true if the given operator string is recognised. | |
| static bool | IsValidMode (const std::string &mode) |
| Returns true if the given mode string is recognised. | |
| static bool | IsOperandFilled (const Operand &operand) |
| Returns true if the operand is sufficiently filled. | |
Private Attributes | |
| Mode | m_mode |
| ConditionPreset | m_workingCopy |
| In-progress edits. | |
| bool | m_isOpen = false |
| bool | m_isConfirmed = false |
| std::vector< BlackboardEntry > | m_localVariables |
| Local variables from entity (Phase 24) | |
Modal dialog for creating or editing a single ConditionPreset.
Definition at line 49 of file ConditionPresetEditDialog.h.
Whether the dialog creates a new preset or edits an existing one.
| Enumerator | |
|---|---|
| Create | New preset (form starts empty) |
| Edit | Existing preset (form pre-populated) |
Definition at line 56 of file ConditionPresetEditDialog.h.
| Olympe::ConditionPresetEditDialog::ConditionPresetEditDialog | ( | ) |
Constructs the dialog in Create mode with a blank preset.
Definition at line 37 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::Operand::CreateVariable(), Olympe::Equal, Olympe::ConditionPreset::left, m_workingCopy, Olympe::ConditionPreset::op, and Olympe::ConditionPreset::right.
Here is the call graph for this function:
|
explicit |
Constructs the dialog in the given mode.
| mode | Create or Edit. |
| existingPreset | If Mode::Edit, the preset to edit (copied). If nullptr or Mode::Create, the form is blank. |
Definition at line 45 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::Operand::CreateVariable(), Edit, Olympe::Equal, GetComponentTypeID_Static(), Olympe::ConditionPreset::left, m_workingCopy, Olympe::ConditionPreset::op, and Olympe::ConditionPreset::right.
Here is the call graph for this function:
|
default |
|
inline |
Closes the dialog without confirming.
Definition at line 93 of file ConditionPresetEditDialog.h.
References m_isOpen.
| bool Olympe::ConditionPresetEditDialog::Confirm | ( | ) |
Confirms the dialog programmatically (equivalent to pressing Save).
Only succeeds if IsValid() returns true.
Definition at line 163 of file ConditionPresetEditDialog.cpp.
References IsValid(), m_isConfirmed, and m_isOpen.
Here is the call graph for this function:Returns the current left operand.
Definition at line 123 of file ConditionPresetEditDialog.h.
References Olympe::ConditionPreset::left, and m_workingCopy.
|
inline |
Returns the dialog mode (Create or Edit).
Definition at line 109 of file ConditionPresetEditDialog.h.
References m_mode.
|
inline |
Returns the current comparison operator.
Definition at line 133 of file ConditionPresetEditDialog.h.
References m_workingCopy, and Olympe::ConditionPreset::op.
| std::string Olympe::ConditionPresetEditDialog::GetPreview | ( | ) | const |
Returns a live preview string of the current condition.
Example: "[mHealth] <= [2]"
Definition at line 126 of file ConditionPresetEditDialog.cpp.
References Olympe::ConditionPreset::GetPreview(), and m_workingCopy.
Referenced by RenderPreview().
Here is the call graph for this function:
Here is the caller graph for this function:| ConditionPreset Olympe::ConditionPresetEditDialog::GetResult | ( | ) | const |
Returns a copy of the working preset (contains the current form state).
Definition at line 61 of file ConditionPresetEditDialog.cpp.
References m_workingCopy.
Returns the current right operand.
Definition at line 128 of file ConditionPresetEditDialog.h.
References m_workingCopy, and Olympe::ConditionPreset::right.
|
inline |
Returns true if the user pressed "Save" / "OK".
Reset to false each time Open() is called.
Definition at line 104 of file ConditionPresetEditDialog.h.
References m_isConfirmed.
|
inline |
Returns true if the dialog is open.
Definition at line 87 of file ConditionPresetEditDialog.h.
References m_isOpen.
Returns true if the operand is sufficiently filled.
Definition at line 143 of file ConditionPresetEditDialog.cpp.
References GetComponentTypeID_Static().
Referenced by IsValid().
Here is the call graph for this function:
Here is the caller graph for this function:| bool Olympe::ConditionPresetEditDialog::IsValid | ( | ) | const |
Returns true if the current condition is valid and can be saved.
A condition is valid when:
Definition at line 154 of file ConditionPresetEditDialog.cpp.
References IsOperandFilled(), Olympe::ConditionPreset::left, m_workingCopy, and Olympe::ConditionPreset::right.
Referenced by Confirm(), and RenderConfirmButtons().
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if the given mode string is recognised.
Definition at line 137 of file ConditionPresetEditDialog.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:Returns true if the given operator string is recognised.
Definition at line 131 of file ConditionPresetEditDialog.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:
|
inline |
Opens the dialog.
Definition at line 90 of file ConditionPresetEditDialog.h.
References m_isConfirmed, and m_isOpen.
| void Olympe::ConditionPresetEditDialog::Render | ( | ) |
Renders the modal dialog using ImGui.
Must be called once per frame while the dialog is open. No-op when !IsOpen().
Definition at line 172 of file ConditionPresetEditDialog.cpp.
References Create, GetComponentTypeID_Static(), m_isOpen, m_mode, m_workingCopy, Olympe::ConditionPreset::name, RenderConfirmButtons(), RenderOperandSelector(), RenderOperatorSelector(), and RenderPreview().
Here is the call graph for this function:
|
private |
Definition at line 361 of file ConditionPresetEditDialog.cpp.
References IsValid(), m_isConfirmed, and m_isOpen.
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 213 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::Operand::CreatePin(), Olympe::Operand::CreateVariable(), Olympe::GlobalTemplateBlackboard::Get(), GetComponentTypeID_Static(), Olympe::ConditionPreset::left, m_localVariables, m_workingCopy, and Olympe::ConditionPreset::right.
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 332 of file ConditionPresetEditDialog.cpp.
References GetComponentTypeID_Static(), m_workingCopy, Olympe::ConditionPreset::op, Olympe::ConditionPreset::OpFromString(), and Olympe::ConditionPreset::OpToString().
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 353 of file ConditionPresetEditDialog.cpp.
References GetComponentTypeID_Static(), and GetPreview().
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:Sets the left constant value.
Definition at line 81 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::ConditionPreset::left, and m_workingCopy.
Here is the call graph for this function:Sets the left operand mode.
| mode | "Variable", "Const", or "Pin". |
Definition at line 66 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::Operand::CreatePin(), Olympe::Operand::CreateVariable(), Olympe::ConditionPreset::left, and m_workingCopy.
Here is the call graph for this function:Sets the left pin reference.
Definition at line 86 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreatePin(), GetComponentTypeID_Static(), Olympe::ConditionPreset::left, and m_workingCopy.
Here is the call graph for this function:Sets the left variable name (relevant when leftMode == "Variable").
Definition at line 76 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateVariable(), GetComponentTypeID_Static(), Olympe::ConditionPreset::left, and m_workingCopy.
Here is the call graph for this function:
|
inline |
Sets the list of local variables from EntityBlackboard.
| localVars | Vector of local variable definitions. |
Definition at line 249 of file ConditionPresetEditDialog.h.
References GetComponentTypeID_Static(), and m_localVariables.
Here is the call graph for this function:Sets the display name of the working preset.
Definition at line 121 of file ConditionPresetEditDialog.cpp.
References m_workingCopy, and Olympe::ConditionPreset::name.
Sets the comparison operator.
| op | One of "==", "!=", "<", "<=", ">", ">=". |
Definition at line 91 of file ConditionPresetEditDialog.cpp.
References m_workingCopy, Olympe::ConditionPreset::op, and Olympe::ConditionPreset::OpFromString().
Here is the call graph for this function:Sets the right constant value.
Definition at line 111 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), m_workingCopy, and Olympe::ConditionPreset::right.
Here is the call graph for this function:Sets the right operand mode.
| mode | "Variable", "Const", or "Pin". |
Definition at line 96 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateConst(), Olympe::Operand::CreatePin(), Olympe::Operand::CreateVariable(), m_workingCopy, and Olympe::ConditionPreset::right.
Here is the call graph for this function:Sets the right pin reference (relevant when rightMode == "Pin").
Definition at line 116 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreatePin(), GetComponentTypeID_Static(), m_workingCopy, and Olympe::ConditionPreset::right.
Here is the call graph for this function:Sets the right variable name.
Definition at line 106 of file ConditionPresetEditDialog.cpp.
References Olympe::Operand::CreateVariable(), GetComponentTypeID_Static(), m_workingCopy, and Olympe::ConditionPreset::right.
Here is the call graph for this function:Definition at line 285 of file ConditionPresetEditDialog.h.
Referenced by Confirm(), IsConfirmed(), Open(), and RenderConfirmButtons().
Definition at line 284 of file ConditionPresetEditDialog.h.
Referenced by Close(), Confirm(), IsOpen(), Open(), Render(), and RenderConfirmButtons().
|
private |
Local variables from entity (Phase 24)
Definition at line 286 of file ConditionPresetEditDialog.h.
Referenced by RenderOperandSelector(), and SetLocalVariables().
|
private |
Definition at line 282 of file ConditionPresetEditDialog.h.
|
private |
In-progress edits.
Definition at line 283 of file ConditionPresetEditDialog.h.
Referenced by ConditionPresetEditDialog(), ConditionPresetEditDialog(), GetLeftOperand(), GetOperator(), GetPreview(), GetResult(), GetRightOperand(), IsValid(), Render(), RenderOperandSelector(), RenderOperatorSelector(), SetLeftConst(), SetLeftMode(), SetLeftPin(), SetLeftVariable(), SetName(), SetOperator(), SetRightConst(), SetRightMode(), SetRightPin(), and SetRightVariable().