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::SaveFilePickerModal Class Reference

Centralized ImGui modal dialog for file saving across all editors. More...

#include <SaveFilePickerModal.h>

Public Member Functions

 SaveFilePickerModal (SaveFileType fileType)
 Constructs a save file picker modal for the given file type.
 
 ~SaveFilePickerModal ()=default
 
void Open (const std::string &directory, const std::string &suggestedFilename="")
 Opens the modal with initial directory and filename.
 
void Close ()
 Closes the modal without confirming changes.
 
void Render ()
 Renders the modal UI.
 
bool IsOpen () const
 Returns true if modal is currently visible.
 
bool IsConfirmed () const
 Returns true if user clicked "Save" button.
 
const std::string & GetSelectedFile () const
 Returns the selected file path with extension (only valid if IsConfirmed() is true).
 
SaveFileType GetFileType () const
 Returns the file type this modal handles.
 

Private Member Functions

std::string GetDefaultDirectory () const
 Returns the default directory for this file type.
 
std::string GetFileExtension () const
 Returns the file extension for this file type (e.g., ".bt.json").
 
std::string GetModalTitle () const
 Returns a description of this file type for the modal title.
 
std::string GetDescriptionText () const
 Returns user-friendly description text.
 
void RefreshFileList ()
 Refreshes the file and folder lists for the current directory.
 
void RenderFileList ()
 Renders the file list in the modal.
 
void RenderFolderList ()
 Renders folder navigation.
 
void RenderFilenameInput ()
 Renders filename input and extension display.
 
void RenderActionButtons ()
 Renders action buttons (Save/Cancel).
 
bool FileExists (const std::string &path) const
 Checks if a file exists at the given path.
 
void RenderOverwriteConfirmation ()
 Renders the overwrite confirmation dialog.
 

Private Attributes

SaveFileType m_fileType
 Type of file to save.
 
bool m_isOpen = false
 Is modal currently visible.
 
bool m_confirmed = false
 Did user click Save.
 
std::string m_selectedFile = ""
 Full path with extension.
 
std::string m_currentPath = ""
 Current directory.
 
std::vector< std::string > m_fileList
 Files in current directory.
 
std::vector< std::string > m_folderList
 Folders in current directory.
 
char m_pathBuffer [512] = ""
 Path input text buffer.
 
char m_filenameBuffer [256] = ""
 Filename input (without extension)
 
bool m_showOverwriteConfirm = false
 Show overwrite confirmation dialog.
 

Detailed Description

Centralized ImGui modal dialog for file saving across all editors.

Usage:

  1. SaveFilePickerModal modal(SaveFileType::BehaviorTree);
  2. modal.Open(defaultDirectory, suggestedFilename);
  3. During ImGui loop: modal.Render();
  4. After frame: if (modal.IsConfirmed()) { path = modal.GetSelectedFile(); }

Features:

Definition at line 48 of file SaveFilePickerModal.h.

Constructor & Destructor Documentation

◆ SaveFilePickerModal()

Olympe::SaveFilePickerModal::SaveFilePickerModal ( SaveFileType  fileType)
explicit

Constructs a save file picker modal for the given file type.

Parameters
fileTypeType of file to save (BehaviorTree, Blueprint, etc.)

Definition at line 30 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), GetDefaultDirectory(), m_currentPath, m_pathBuffer, and RefreshFileList().

+ Here is the call graph for this function:

◆ ~SaveFilePickerModal()

Olympe::SaveFilePickerModal::~SaveFilePickerModal ( )
default

Member Function Documentation

◆ Close()

void Olympe::SaveFilePickerModal::Close ( )

Closes the modal without confirming changes.

Definition at line 72 of file SaveFilePickerModal.cpp.

References m_confirmed, m_isOpen, m_selectedFile, and m_showOverwriteConfirm.

◆ FileExists()

bool Olympe::SaveFilePickerModal::FileExists ( const std::string &  path) const
private

Checks if a file exists at the given path.

Definition at line 455 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static().

Referenced by RenderActionButtons().

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

◆ GetDefaultDirectory()

std::string Olympe::SaveFilePickerModal::GetDefaultDirectory ( ) const
private

Returns the default directory for this file type.

Definition at line 195 of file SaveFilePickerModal.cpp.

References Olympe::Audio, Olympe::BehaviorTree, Olympe::Blueprint, Olympe::EntityPrefab, and m_fileType.

Referenced by Open(), and SaveFilePickerModal().

+ Here is the caller graph for this function:

◆ GetDescriptionText()

std::string Olympe::SaveFilePickerModal::GetDescriptionText ( ) const
private

Returns user-friendly description text.

Definition at line 246 of file SaveFilePickerModal.cpp.

References Olympe::Audio, Olympe::BehaviorTree, Olympe::Blueprint, Olympe::EntityPrefab, and m_fileType.

Referenced by Render().

+ Here is the caller graph for this function:

◆ GetFileExtension()

std::string Olympe::SaveFilePickerModal::GetFileExtension ( ) const
private

Returns the file extension for this file type (e.g., ".bt.json").

Definition at line 212 of file SaveFilePickerModal.cpp.

References Olympe::Audio, Olympe::BehaviorTree, Olympe::Blueprint, Olympe::EntityPrefab, and m_fileType.

Referenced by RefreshFileList(), RenderActionButtons(), RenderFileList(), and RenderFilenameInput().

+ Here is the caller graph for this function:

◆ GetFileType()

SaveFileType Olympe::SaveFilePickerModal::GetFileType ( ) const
inline

Returns the file type this modal handles.

Definition at line 104 of file SaveFilePickerModal.h.

References m_fileType.

◆ GetModalTitle()

std::string Olympe::SaveFilePickerModal::GetModalTitle ( ) const
private

Returns a description of this file type for the modal title.

Definition at line 229 of file SaveFilePickerModal.cpp.

References Olympe::Audio, Olympe::BehaviorTree, Olympe::Blueprint, Olympe::EntityPrefab, and m_fileType.

Referenced by Render().

+ Here is the caller graph for this function:

◆ GetSelectedFile()

const std::string & Olympe::SaveFilePickerModal::GetSelectedFile ( ) const
inline

Returns the selected file path with extension (only valid if IsConfirmed() is true).

Example: "Gamedata/MyTree.bt.json"

Definition at line 99 of file SaveFilePickerModal.h.

References m_selectedFile.

◆ IsConfirmed()

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

Returns true if user clicked "Save" button.

Definition at line 92 of file SaveFilePickerModal.h.

References m_confirmed.

◆ IsOpen()

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

Returns true if modal is currently visible.

Definition at line 87 of file SaveFilePickerModal.h.

References m_isOpen.

◆ Open()

void Olympe::SaveFilePickerModal::Open ( const std::string &  directory,
const std::string &  suggestedFilename = "" 
)

Opens the modal with initial directory and filename.

Parameters
directoryStarting directory path
suggestedFilenameSuggested filename (without extension)

Extension will be automatically appended based on file type.

Definition at line 42 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), GetDefaultDirectory(), m_confirmed, m_currentPath, m_filenameBuffer, m_isOpen, m_pathBuffer, m_selectedFile, m_showOverwriteConfirm, and RefreshFileList().

+ Here is the call graph for this function:

◆ RefreshFileList()

void Olympe::SaveFilePickerModal::RefreshFileList ( )
private

Refreshes the file and folder lists for the current directory.

Definition at line 263 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), GetFileExtension(), m_currentPath, m_fileList, m_folderList, and SYSTEM_LOG.

Referenced by Open(), Render(), RenderFolderList(), and SaveFilePickerModal().

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

◆ Render()

void Olympe::SaveFilePickerModal::Render ( )

◆ RenderActionButtons()

void Olympe::SaveFilePickerModal::RenderActionButtons ( )
private

Renders action buttons (Save/Cancel).

Definition at line 408 of file SaveFilePickerModal.cpp.

References FileExists(), GetComponentTypeID_Static(), GetFileExtension(), m_confirmed, m_currentPath, m_filenameBuffer, m_isOpen, m_selectedFile, m_showOverwriteConfirm, and SYSTEM_LOG.

Referenced by Render().

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

◆ RenderFileList()

void Olympe::SaveFilePickerModal::RenderFileList ( )
private

Renders the file list in the modal.

Definition at line 357 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), GetFileExtension(), m_fileList, and m_filenameBuffer.

Referenced by Render().

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

◆ RenderFilenameInput()

void Olympe::SaveFilePickerModal::RenderFilenameInput ( )
private

Renders filename input and extension display.

Definition at line 394 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), GetFileExtension(), m_currentPath, and m_filenameBuffer.

Referenced by Render().

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

◆ RenderFolderList()

void Olympe::SaveFilePickerModal::RenderFolderList ( )
private

Renders folder navigation.

Definition at line 381 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), m_currentPath, m_folderList, m_pathBuffer, and RefreshFileList().

Referenced by Render().

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

◆ RenderOverwriteConfirmation()

void Olympe::SaveFilePickerModal::RenderOverwriteConfirmation ( )
private

Renders the overwrite confirmation dialog.

Definition at line 461 of file SaveFilePickerModal.cpp.

References GetComponentTypeID_Static(), m_confirmed, m_isOpen, m_selectedFile, m_showOverwriteConfirm, and SYSTEM_LOG.

Referenced by Render().

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

Member Data Documentation

◆ m_confirmed

bool Olympe::SaveFilePickerModal::m_confirmed = false
private

Did user click Save.

Definition at line 113 of file SaveFilePickerModal.h.

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

◆ m_currentPath

std::string Olympe::SaveFilePickerModal::m_currentPath = ""
private

◆ m_fileList

std::vector<std::string> Olympe::SaveFilePickerModal::m_fileList
private

Files in current directory.

Definition at line 121 of file SaveFilePickerModal.h.

Referenced by RefreshFileList(), and RenderFileList().

◆ m_filenameBuffer

char Olympe::SaveFilePickerModal::m_filenameBuffer[256] = ""
private

Filename input (without extension)

Definition at line 129 of file SaveFilePickerModal.h.

Referenced by Open(), RenderActionButtons(), RenderFileList(), and RenderFilenameInput().

◆ m_fileType

SaveFileType Olympe::SaveFilePickerModal::m_fileType
private

Type of file to save.

Definition at line 111 of file SaveFilePickerModal.h.

Referenced by GetDefaultDirectory(), GetDescriptionText(), GetFileExtension(), GetFileType(), and GetModalTitle().

◆ m_folderList

std::vector<std::string> Olympe::SaveFilePickerModal::m_folderList
private

Folders in current directory.

Definition at line 122 of file SaveFilePickerModal.h.

Referenced by RefreshFileList(), and RenderFolderList().

◆ m_isOpen

bool Olympe::SaveFilePickerModal::m_isOpen = false
private

Is modal currently visible.

Definition at line 112 of file SaveFilePickerModal.h.

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

◆ m_pathBuffer

char Olympe::SaveFilePickerModal::m_pathBuffer[512] = ""
private

Path input text buffer.

Definition at line 128 of file SaveFilePickerModal.h.

Referenced by Open(), Render(), RenderFolderList(), and SaveFilePickerModal().

◆ m_selectedFile

std::string Olympe::SaveFilePickerModal::m_selectedFile = ""
private

Full path with extension.

Definition at line 114 of file SaveFilePickerModal.h.

Referenced by Close(), GetSelectedFile(), Open(), RenderActionButtons(), and RenderOverwriteConfirmation().

◆ m_showOverwriteConfirm

bool Olympe::SaveFilePickerModal::m_showOverwriteConfirm = false
private

Show overwrite confirmation dialog.

Definition at line 130 of file SaveFilePickerModal.h.

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


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