![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
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. | |
Centralized ImGui modal dialog for file saving across all editors.
Usage:
Features:
Definition at line 48 of file SaveFilePickerModal.h.
|
explicit |
Constructs a save file picker modal for the given file type.
| fileType | Type 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:
|
default |
| 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.
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:
|
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:
|
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:
|
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:
|
inline |
Returns the file type this modal handles.
Definition at line 104 of file SaveFilePickerModal.h.
References m_fileType.
|
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:
|
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.
|
inline |
Returns true if user clicked "Save" button.
Definition at line 92 of file SaveFilePickerModal.h.
References m_confirmed.
|
inline |
Returns true if modal is currently visible.
Definition at line 87 of file SaveFilePickerModal.h.
References m_isOpen.
| void Olympe::SaveFilePickerModal::Open | ( | const std::string & | directory, |
| const std::string & | suggestedFilename = "" |
||
| ) |
Opens the modal with initial directory and filename.
| directory | Starting directory path |
| suggestedFilename | Suggested 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:
|
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:| void Olympe::SaveFilePickerModal::Render | ( | ) |
Renders the modal UI.
Must be called every frame while open.
Definition at line 80 of file SaveFilePickerModal.cpp.
References GetComponentTypeID_Static(), GetDescriptionText(), GetModalTitle(), m_currentPath, m_isOpen, m_pathBuffer, m_showOverwriteConfirm, RefreshFileList(), RenderActionButtons(), RenderFileList(), RenderFilenameInput(), RenderFolderList(), and RenderOverwriteConfirmation().
Here is the call graph for this function:
|
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:
|
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:
|
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:
|
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:
|
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:Did user click Save.
Definition at line 113 of file SaveFilePickerModal.h.
Referenced by Close(), IsConfirmed(), Open(), RenderActionButtons(), and RenderOverwriteConfirmation().
|
private |
Current directory.
Definition at line 115 of file SaveFilePickerModal.h.
Referenced by Open(), RefreshFileList(), Render(), RenderActionButtons(), RenderFilenameInput(), RenderFolderList(), and SaveFilePickerModal().
|
private |
Files in current directory.
Definition at line 121 of file SaveFilePickerModal.h.
Referenced by RefreshFileList(), and RenderFileList().
|
private |
Filename input (without extension)
Definition at line 129 of file SaveFilePickerModal.h.
Referenced by Open(), RenderActionButtons(), RenderFileList(), and RenderFilenameInput().
|
private |
Type of file to save.
Definition at line 111 of file SaveFilePickerModal.h.
Referenced by GetDefaultDirectory(), GetDescriptionText(), GetFileExtension(), GetFileType(), and GetModalTitle().
|
private |
Folders in current directory.
Definition at line 122 of file SaveFilePickerModal.h.
Referenced by RefreshFileList(), and RenderFolderList().
Is modal currently visible.
Definition at line 112 of file SaveFilePickerModal.h.
Referenced by Close(), IsOpen(), Open(), Render(), RenderActionButtons(), and RenderOverwriteConfirmation().
|
private |
Path input text buffer.
Definition at line 128 of file SaveFilePickerModal.h.
Referenced by Open(), Render(), RenderFolderList(), and SaveFilePickerModal().
|
private |
Full path with extension.
Definition at line 114 of file SaveFilePickerModal.h.
Referenced by Close(), GetSelectedFile(), Open(), RenderActionButtons(), and RenderOverwriteConfirmation().
Show overwrite confirmation dialog.
Definition at line 130 of file SaveFilePickerModal.h.
Referenced by Close(), Open(), Render(), RenderActionButtons(), and RenderOverwriteConfirmation().