Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Olympe::ConditionPresetEditDialog Class Reference

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 OperandGetLeftOperand () const
 Returns the current left operand.
 
const OperandGetRightOperand () 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< BlackboardEntrym_localVariables
 Local variables from entity (Phase 24)
 

Detailed Description

Modal dialog for creating or editing a single ConditionPreset.

Definition at line 49 of file ConditionPresetEditDialog.h.

Member Enumeration Documentation

◆ Mode

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.

Constructor & Destructor Documentation

◆ ConditionPresetEditDialog() [1/2]

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:

◆ ConditionPresetEditDialog() [2/2]

Olympe::ConditionPresetEditDialog::ConditionPresetEditDialog ( Mode  mode,
const ConditionPreset existingPreset = nullptr 
)
explicit

Constructs the dialog in the given mode.

Parameters
modeCreate or Edit.
existingPresetIf 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:

◆ ~ConditionPresetEditDialog()

Olympe::ConditionPresetEditDialog::~ConditionPresetEditDialog ( )
default

Member Function Documentation

◆ Close()

void Olympe::ConditionPresetEditDialog::Close ( )
inline

Closes the dialog without confirming.

Definition at line 93 of file ConditionPresetEditDialog.h.

References m_isOpen.

◆ Confirm()

bool Olympe::ConditionPresetEditDialog::Confirm ( )

Confirms the dialog programmatically (equivalent to pressing Save).

Only succeeds if IsValid() returns true.

Returns
true if confirmation succeeded, false if the condition is invalid.

Definition at line 163 of file ConditionPresetEditDialog.cpp.

References IsValid(), m_isConfirmed, and m_isOpen.

+ Here is the call graph for this function:

◆ GetLeftOperand()

const Operand & Olympe::ConditionPresetEditDialog::GetLeftOperand ( ) const
inline

Returns the current left operand.

Definition at line 123 of file ConditionPresetEditDialog.h.

References Olympe::ConditionPreset::left, and m_workingCopy.

◆ GetMode()

Mode Olympe::ConditionPresetEditDialog::GetMode ( ) const
inline

Returns the dialog mode (Create or Edit).

Definition at line 109 of file ConditionPresetEditDialog.h.

References m_mode.

◆ GetOperator()

ComparisonOp Olympe::ConditionPresetEditDialog::GetOperator ( ) const
inline

Returns the current comparison operator.

Definition at line 133 of file ConditionPresetEditDialog.h.

References m_workingCopy, and Olympe::ConditionPreset::op.

◆ GetPreview()

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:

◆ GetResult()

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.

◆ GetRightOperand()

const Operand & Olympe::ConditionPresetEditDialog::GetRightOperand ( ) const
inline

Returns the current right operand.

Definition at line 128 of file ConditionPresetEditDialog.h.

References m_workingCopy, and Olympe::ConditionPreset::right.

◆ IsConfirmed()

bool Olympe::ConditionPresetEditDialog::IsConfirmed ( ) const
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.

◆ IsOpen()

bool Olympe::ConditionPresetEditDialog::IsOpen ( ) const
inline

Returns true if the dialog is open.

Definition at line 87 of file ConditionPresetEditDialog.h.

References m_isOpen.

◆ IsOperandFilled()

bool Olympe::ConditionPresetEditDialog::IsOperandFilled ( const Operand operand)
staticprivate

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:

◆ IsValid()

bool Olympe::ConditionPresetEditDialog::IsValid ( ) const

Returns true if the current condition is valid and can be saved.

A condition is valid when:

  • left mode is non-empty and the corresponding operand is filled
  • operator is a valid comparison string
  • right mode is non-empty and the corresponding operand is filled

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:

◆ IsValidMode()

bool Olympe::ConditionPresetEditDialog::IsValidMode ( const std::string &  mode)
staticprivate

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:

◆ IsValidOperator()

bool Olympe::ConditionPresetEditDialog::IsValidOperator ( const std::string &  op)
staticprivate

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:

◆ Open()

void Olympe::ConditionPresetEditDialog::Open ( )
inline

Opens the dialog.

Definition at line 90 of file ConditionPresetEditDialog.h.

References m_isConfirmed, and m_isOpen.

◆ Render()

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:

◆ RenderConfirmButtons()

void Olympe::ConditionPresetEditDialog::RenderConfirmButtons ( )
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:

◆ RenderOperandSelector()

void Olympe::ConditionPresetEditDialog::RenderOperandSelector ( const char label,
bool  isLeft 
)
private

◆ RenderOperatorSelector()

void Olympe::ConditionPresetEditDialog::RenderOperatorSelector ( )
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:

◆ RenderPreview()

void Olympe::ConditionPresetEditDialog::RenderPreview ( )
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:

◆ SetLeftConst()

void Olympe::ConditionPresetEditDialog::SetLeftConst ( double  value)

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:

◆ SetLeftMode()

void Olympe::ConditionPresetEditDialog::SetLeftMode ( const std::string &  mode)

Sets the left operand mode.

Parameters
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:

◆ SetLeftPin()

void Olympe::ConditionPresetEditDialog::SetLeftPin ( const std::string &  pinRef)

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:

◆ SetLeftVariable()

void Olympe::ConditionPresetEditDialog::SetLeftVariable ( const std::string &  varName)

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:

◆ SetLocalVariables()

void Olympe::ConditionPresetEditDialog::SetLocalVariables ( const std::vector< BlackboardEntry > &  localVars)
inline

Sets the list of local variables from EntityBlackboard.

Parameters
localVarsVector 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:

◆ SetName()

void Olympe::ConditionPresetEditDialog::SetName ( const std::string &  name)

Sets the display name of the working preset.

Definition at line 121 of file ConditionPresetEditDialog.cpp.

References m_workingCopy, and Olympe::ConditionPreset::name.

◆ SetOperator()

void Olympe::ConditionPresetEditDialog::SetOperator ( const std::string &  op)

Sets the comparison operator.

Parameters
opOne 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:

◆ SetRightConst()

void Olympe::ConditionPresetEditDialog::SetRightConst ( double  value)

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:

◆ SetRightMode()

void Olympe::ConditionPresetEditDialog::SetRightMode ( const std::string &  mode)

Sets the right operand mode.

Parameters
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:

◆ SetRightPin()

void Olympe::ConditionPresetEditDialog::SetRightPin ( const std::string &  pinRef)

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:

◆ SetRightVariable()

void Olympe::ConditionPresetEditDialog::SetRightVariable ( const std::string &  varName)

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:

Member Data Documentation

◆ m_isConfirmed

bool Olympe::ConditionPresetEditDialog::m_isConfirmed = false
private

Definition at line 285 of file ConditionPresetEditDialog.h.

Referenced by Confirm(), IsConfirmed(), Open(), and RenderConfirmButtons().

◆ m_isOpen

bool Olympe::ConditionPresetEditDialog::m_isOpen = false
private

Definition at line 284 of file ConditionPresetEditDialog.h.

Referenced by Close(), Confirm(), IsOpen(), Open(), Render(), and RenderConfirmButtons().

◆ m_localVariables

std::vector<BlackboardEntry> Olympe::ConditionPresetEditDialog::m_localVariables
private

Local variables from entity (Phase 24)

Definition at line 286 of file ConditionPresetEditDialog.h.

Referenced by RenderOperandSelector(), and SetLocalVariables().

◆ m_mode

Mode Olympe::ConditionPresetEditDialog::m_mode
private

Definition at line 282 of file ConditionPresetEditDialog.h.

Referenced by GetMode(), and Render().

◆ m_workingCopy

ConditionPreset Olympe::ConditionPresetEditDialog::m_workingCopy
private

The documentation for this class was generated from the following files: