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

Modal dialog for adding, removing, and reordering switch cases on a node. More...

#include <SwitchCaseEditorModal.h>

Public Member Functions

 SwitchCaseEditorModal ()
 Constructs the modal.
 
 ~SwitchCaseEditorModal ()=default
 
 SwitchCaseEditorModal (const SwitchCaseEditorModal &)=delete
 
SwitchCaseEditorModaloperator= (const SwitchCaseEditorModal &)=delete
 
bool IsOpen () const
 Returns true if the modal is currently open.
 
void Open (const std::vector< SwitchCaseDefinition > &currentCases, const std::string &switchVarName="", const std::string &switchVarType="", const std::string &currentVarValue="")
 Opens the modal, loading the given switch cases for editing.
 
void Close ()
 Closes the modal without confirming changes.
 
bool IsConfirmed () const
 Returns true if the modal was closed via "Apply" rather than "Cancel".
 
const std::vector< SwitchCaseDefinition > & GetSwitchCases () const
 Returns the edited switch cases (only valid after IsConfirmed() == true).
 
void Render ()
 Renders the modal dialog.
 

Private Member Functions

void RenderCaseList ()
 Renders the scrollable list of case rows.
 
bool RenderCaseRow (size_t caseIndex)
 Renders a single case row with all controls.
 
void RenderActionButtons ()
 Renders the "Add Case" and action buttons (Apply / Cancel).
 

Private Attributes

bool m_isOpen = false
 True if the modal is currently open.
 
bool m_confirmed = false
 True if the user clicked "Apply" (set to false on Close)
 
std::vector< SwitchCaseDefinitionm_editingCases
 Working copy of switch cases being edited.
 
std::vector< std::string > m_caseValueBuffers
 Temporary edit buffers for value and label fields.
 
std::vector< std::string > m_caseLabelBuffers
 One per case, synced before render.
 
std::string m_switchVarName
 Variable being switched (e.g. "mHealth")
 
std::string m_switchVarType
 Variable type (e.g. "Int", "String")
 
std::string m_currentVarValue
 Current value for context display.
 
bool m_hasValidationError = false
 Set to true if any case has errors (prevents Apply)
 

Detailed Description

Modal dialog for adding, removing, and reordering switch cases on a node.

The modal contains:

Definition at line 57 of file SwitchCaseEditorModal.h.

Constructor & Destructor Documentation

◆ SwitchCaseEditorModal() [1/2]

Olympe::SwitchCaseEditorModal::SwitchCaseEditorModal ( )

Constructs the modal.

Definition at line 14 of file SwitchCaseEditorModal.cpp.

◆ ~SwitchCaseEditorModal()

Olympe::SwitchCaseEditorModal::~SwitchCaseEditorModal ( )
default

◆ SwitchCaseEditorModal() [2/2]

Olympe::SwitchCaseEditorModal::SwitchCaseEditorModal ( const SwitchCaseEditorModal )
delete

Member Function Documentation

◆ Close()

void Olympe::SwitchCaseEditorModal::Close ( )

Closes the modal without confirming changes.

Definition at line 47 of file SwitchCaseEditorModal.cpp.

References m_caseLabelBuffers, m_caseValueBuffers, m_confirmed, m_editingCases, and m_isOpen.

Referenced by Render().

+ Here is the caller graph for this function:

◆ GetSwitchCases()

const std::vector< SwitchCaseDefinition > & Olympe::SwitchCaseEditorModal::GetSwitchCases ( ) const
inline

Returns the edited switch cases (only valid after IsConfirmed() == true).

Definition at line 109 of file SwitchCaseEditorModal.h.

References m_editingCases.

◆ IsConfirmed()

bool Olympe::SwitchCaseEditorModal::IsConfirmed ( ) const
inline

Returns true if the modal was closed via "Apply" rather than "Cancel".

After reading, call Close() to reset the flag for the next edit.

Definition at line 104 of file SwitchCaseEditorModal.h.

References m_confirmed.

◆ IsOpen()

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

Returns true if the modal is currently open.

Definition at line 78 of file SwitchCaseEditorModal.h.

References m_isOpen.

◆ Open()

void Olympe::SwitchCaseEditorModal::Open ( const std::vector< SwitchCaseDefinition > &  currentCases,
const std::string &  switchVarName = "",
const std::string &  switchVarType = "",
const std::string &  currentVarValue = "" 
)

Opens the modal, loading the given switch cases for editing.

Resets the confirmed flag and takes a COPY of the cases to edit.

Parameters
currentCasesSwitch cases from the selected node.
switchVarNameName of the variable being switched (e.g. "mHealth")
switchVarTypeType of the variable (e.g. "Int")
currentVarValueCurrent value of the variable for display (optional)

Definition at line 20 of file SwitchCaseEditorModal.cpp.

References GetComponentTypeID_Static(), m_caseLabelBuffers, m_caseValueBuffers, m_confirmed, m_currentVarValue, m_editingCases, m_hasValidationError, m_isOpen, m_switchVarName, and m_switchVarType.

+ Here is the call graph for this function:

◆ operator=()

SwitchCaseEditorModal & Olympe::SwitchCaseEditorModal::operator= ( const SwitchCaseEditorModal )
delete

◆ Render()

void Olympe::SwitchCaseEditorModal::Render ( )

Renders the modal dialog.

Must be called once per frame while IsOpen(). Handles ImGui::OpenPopupOnItemClick, ImGui::BeginPopupModal, etc.

Definition at line 56 of file SwitchCaseEditorModal.cpp.

References Close(), GetComponentTypeID_Static(), m_isOpen, RenderActionButtons(), and RenderCaseList().

+ Here is the call graph for this function:

◆ RenderActionButtons()

void Olympe::SwitchCaseEditorModal::RenderActionButtons ( )
private

Renders the "Add Case" and action buttons (Apply / Cancel).

Definition at line 323 of file SwitchCaseEditorModal.cpp.

References GetComponentTypeID_Static(), m_caseLabelBuffers, m_caseValueBuffers, m_confirmed, m_editingCases, m_hasValidationError, and m_isOpen.

Referenced by Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderCaseList()

void Olympe::SwitchCaseEditorModal::RenderCaseList ( )
private

Renders the scrollable list of case rows.

Definition at line 92 of file SwitchCaseEditorModal.cpp.

References GetComponentTypeID_Static(), m_caseLabelBuffers, m_caseValueBuffers, m_currentVarValue, m_editingCases, m_hasValidationError, m_switchVarName, m_switchVarType, and RenderCaseRow().

Referenced by Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderCaseRow()

bool Olympe::SwitchCaseEditorModal::RenderCaseRow ( size_t  caseIndex)
private

Renders a single case row with all controls.

Parameters
caseIndex0-based index in m_editingCases
Returns
True if any field was modified

Definition at line 184 of file SwitchCaseEditorModal.cpp.

References GetComponentTypeID_Static(), m_caseLabelBuffers, m_caseValueBuffers, m_editingCases, and m_hasValidationError.

Referenced by RenderCaseList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_caseLabelBuffers

std::vector<std::string> Olympe::SwitchCaseEditorModal::m_caseLabelBuffers
private

One per case, synced before render.

Definition at line 159 of file SwitchCaseEditorModal.h.

Referenced by Close(), Open(), RenderActionButtons(), RenderCaseList(), and RenderCaseRow().

◆ m_caseValueBuffers

std::vector<std::string> Olympe::SwitchCaseEditorModal::m_caseValueBuffers
private

Temporary edit buffers for value and label fields.

One per case, synced before render

Definition at line 158 of file SwitchCaseEditorModal.h.

Referenced by Close(), Open(), RenderActionButtons(), RenderCaseList(), and RenderCaseRow().

◆ m_confirmed

bool Olympe::SwitchCaseEditorModal::m_confirmed = false
private

True if the user clicked "Apply" (set to false on Close)

Definition at line 152 of file SwitchCaseEditorModal.h.

Referenced by Close(), IsConfirmed(), Open(), and RenderActionButtons().

◆ m_currentVarValue

std::string Olympe::SwitchCaseEditorModal::m_currentVarValue
private

Current value for context display.

Definition at line 164 of file SwitchCaseEditorModal.h.

Referenced by Open(), and RenderCaseList().

◆ m_editingCases

std::vector<SwitchCaseDefinition> Olympe::SwitchCaseEditorModal::m_editingCases
private

Working copy of switch cases being edited.

Definition at line 155 of file SwitchCaseEditorModal.h.

Referenced by Close(), GetSwitchCases(), Open(), RenderActionButtons(), RenderCaseList(), and RenderCaseRow().

◆ m_hasValidationError

bool Olympe::SwitchCaseEditorModal::m_hasValidationError = false
private

Set to true if any case has errors (prevents Apply)

Definition at line 165 of file SwitchCaseEditorModal.h.

Referenced by Open(), RenderActionButtons(), RenderCaseList(), and RenderCaseRow().

◆ m_isOpen

bool Olympe::SwitchCaseEditorModal::m_isOpen = false
private

True if the modal is currently open.

Definition at line 149 of file SwitchCaseEditorModal.h.

Referenced by Close(), IsOpen(), Open(), Render(), and RenderActionButtons().

◆ m_switchVarName

std::string Olympe::SwitchCaseEditorModal::m_switchVarName
private

Variable being switched (e.g. "mHealth")

Definition at line 162 of file SwitchCaseEditorModal.h.

Referenced by Open(), and RenderCaseList().

◆ m_switchVarType

std::string Olympe::SwitchCaseEditorModal::m_switchVarType
private

Variable type (e.g. "Int", "String")

Definition at line 163 of file SwitchCaseEditorModal.h.

Referenced by Open(), and RenderCaseList().


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