![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Centralized ImGui modal dialog for file selection across all editors. More...
#include <FilePickerModal.h>
Public Member Functions | |
| FilePickerModal (FilePickerType fileType) | |
| Constructs a file picker modal for the given file type. | |
| ~FilePickerModal ()=default | |
| void | Open (const std::string ¤tPath="") |
| Opens the modal with optional initial path. | |
| 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 "Select" button. | |
| const std::string & | GetSelectedFile () const |
| Returns the selected file path (only valid if IsConfirmed() is true). | |
| FilePickerType | 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 | GetFilePattern () const |
| Returns the file pattern for this file type (e.g., "*.bt.json"). | |
| std::string | GetModalTitle () const |
| Returns the modal title for this file type (e.g., "Select BehaviorTree File"). | |
| std::string | GetDescriptionText () const |
| Returns the description text for this file type. | |
| void | RefreshFileList () |
| Refreshes file list from current directory. | |
| void | RenderFileList () |
| Renders the file list UI component with scrolling and selection. | |
| void | RenderActionButtons () |
| Renders the action buttons (Select, Cancel). | |
| std::vector< std::string > | GetFilteredFiles () const |
| Filters and returns files matching the search buffer. | |
Private Attributes | |
| FilePickerType | m_fileType |
| Type of files to browse. | |
| bool | m_isOpen = false |
| Is modal currently visible. | |
| bool | m_confirmed = false |
| Did user click Select. | |
| std::string | m_selectedFile = "" |
| Full path to selected file. | |
| std::string | m_currentPath = "" |
| Current directory being browsed. | |
| std::vector< std::string > | m_fileList |
| Files found in current directory. | |
| std::vector< std::string > | m_folderList |
| Folders in current directory. | |
| int | m_selectedIndex = -1 |
| Currently highlighted file (-1 = none) | |
| char | m_pathBuffer [512] = "" |
| Path input text buffer. | |
| char | m_searchBuffer [128] = "" |
| Search filter text buffer. | |
| int | m_selectedFilterIndex = 0 |
| Current filter type (0=default, 1=.bt.json, etc.) | |
| std::string | m_currentFilter = "" |
| Current file extension filter. | |
Centralized ImGui modal dialog for file selection across all editors.
Usage:
Features:
Definition at line 52 of file FilePickerModal.h.
|
explicit |
Constructs a file picker modal for the given file type.
| fileType | Type of files to browse (BehaviorTree, SubGraph, etc.) |
Definition at line 29 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), GetDefaultDirectory(), m_currentPath, m_pathBuffer, and RefreshFileList().
Here is the call graph for this function:
|
default |
| void Olympe::FilePickerModal::Close | ( | ) |
Closes the modal without confirming changes.
User cancelled the dialog. IsConfirmed() will return false.
Definition at line 66 of file FilePickerModal.cpp.
References m_confirmed, m_isOpen, and m_selectedFile.
|
private |
Returns the default directory for this file type.
Definition at line 255 of file FilePickerModal.cpp.
References Olympe::Audio, Olympe::BehaviorTree, m_fileType, Olympe::SubGraph, and Olympe::Tileset.
Referenced by FilePickerModal(), and Open().
Here is the caller graph for this function:
|
private |
Returns the description text for this file type.
Definition at line 306 of file FilePickerModal.cpp.
References Olympe::Audio, Olympe::BehaviorTree, m_fileType, Olympe::SubGraph, and Olympe::Tileset.
Referenced by Render().
Here is the caller graph for this function:
|
private |
Returns the file pattern for this file type (e.g., "*.bt.json").
Definition at line 272 of file FilePickerModal.cpp.
References Olympe::Audio, Olympe::BehaviorTree, m_fileType, Olympe::SubGraph, and Olympe::Tileset.
Referenced by Open(), and RefreshFileList().
Here is the caller graph for this function:
|
inline |
Returns the file type this modal handles.
Definition at line 116 of file FilePickerModal.h.
References m_fileType.
|
private |
Filters and returns files matching the search buffer.
Definition at line 497 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), m_fileList, and m_searchBuffer.
Referenced by RenderFileList().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Returns the modal title for this file type (e.g., "Select BehaviorTree File").
Definition at line 289 of file FilePickerModal.cpp.
References Olympe::Audio, Olympe::BehaviorTree, m_fileType, Olympe::SubGraph, and Olympe::Tileset.
Referenced by Render().
Here is the caller graph for this function:
|
inline |
Returns the selected file path (only valid if IsConfirmed() is true).
Path format depends on file type:
Definition at line 111 of file FilePickerModal.h.
References m_selectedFile.
|
inline |
Returns true if user clicked "Select" button.
Call this after modal closes to check if user made a selection. Only use GetSelectedFile() if this returns true.
Definition at line 102 of file FilePickerModal.h.
References m_confirmed.
|
inline |
Returns true if modal is currently visible.
Definition at line 94 of file FilePickerModal.h.
References m_isOpen.
Opens the modal with optional initial path.
| currentPath | If non-empty, shows this path as starting location |
Initializes all modal state and refreshes the file list.
Definition at line 42 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), GetDefaultDirectory(), GetFilePattern(), m_confirmed, m_currentFilter, m_currentPath, m_isOpen, m_pathBuffer, m_searchBuffer, m_selectedFile, m_selectedFilterIndex, m_selectedIndex, and RefreshFileList().
Here is the call graph for this function:
|
private |
Refreshes file list from current directory.
Searches for files matching the pattern for this file type. Logs results to SYSTEM_LOG.
Definition at line 323 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), GetFilePattern(), m_currentFilter, m_currentPath, m_fileList, m_folderList, m_selectedIndex, and SYSTEM_LOG.
Referenced by FilePickerModal(), Open(), and Render().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::FilePickerModal::Render | ( | ) |
Renders the modal UI.
Must be called every frame while open.
Call this within the main ImGui rendering loop.
Definition at line 73 of file FilePickerModal.cpp.
References Olympe::BehaviorTree, GetComponentTypeID_Static(), GetDescriptionText(), GetModalTitle(), m_currentFilter, m_currentPath, m_fileList, m_fileType, m_folderList, m_isOpen, m_pathBuffer, m_searchBuffer, m_selectedFilterIndex, m_selectedIndex, RefreshFileList(), RenderActionButtons(), RenderFileList(), and Olympe::SubGraph.
Here is the call graph for this function:
|
private |
Renders the action buttons (Select, Cancel).
Select button is disabled if no file is selected.
Definition at line 465 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), m_confirmed, m_currentPath, m_fileList, m_isOpen, m_selectedFile, and m_selectedIndex.
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Renders the file list UI component with scrolling and selection.
Definition at line 422 of file FilePickerModal.cpp.
References GetComponentTypeID_Static(), GetFilteredFiles(), m_fileList, and m_selectedIndex.
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:Did user click Select.
Definition at line 125 of file FilePickerModal.h.
Referenced by Close(), IsConfirmed(), Open(), and RenderActionButtons().
|
private |
Current file extension filter.
Definition at line 144 of file FilePickerModal.h.
Referenced by Open(), RefreshFileList(), and Render().
|
private |
Current directory being browsed.
Definition at line 127 of file FilePickerModal.h.
Referenced by FilePickerModal(), Open(), RefreshFileList(), Render(), and RenderActionButtons().
|
private |
Files found in current directory.
Definition at line 133 of file FilePickerModal.h.
Referenced by GetFilteredFiles(), RefreshFileList(), Render(), RenderActionButtons(), and RenderFileList().
|
private |
Type of files to browse.
Definition at line 123 of file FilePickerModal.h.
Referenced by GetDefaultDirectory(), GetDescriptionText(), GetFilePattern(), GetFileType(), GetModalTitle(), and Render().
|
private |
Folders in current directory.
Definition at line 134 of file FilePickerModal.h.
Referenced by RefreshFileList(), and Render().
Is modal currently visible.
Definition at line 124 of file FilePickerModal.h.
Referenced by Close(), IsOpen(), Open(), Render(), and RenderActionButtons().
|
private |
Path input text buffer.
Definition at line 141 of file FilePickerModal.h.
Referenced by FilePickerModal(), Open(), and Render().
|
private |
Search filter text buffer.
Definition at line 142 of file FilePickerModal.h.
Referenced by GetFilteredFiles(), Open(), and Render().
|
private |
Full path to selected file.
Definition at line 126 of file FilePickerModal.h.
Referenced by Close(), GetSelectedFile(), Open(), and RenderActionButtons().
|
private |
Current filter type (0=default, 1=.bt.json, etc.)
Definition at line 143 of file FilePickerModal.h.
|
private |
Currently highlighted file (-1 = none)
Definition at line 135 of file FilePickerModal.h.
Referenced by Open(), RefreshFileList(), Render(), RenderActionButtons(), and RenderFileList().