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

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 &currentPath="")
 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.
 

Detailed Description

Centralized ImGui modal dialog for file selection across all editors.

Usage:

  1. FilePickerModal modal(FilePickerType::BehaviorTree);
  2. modal.Open(currentPath);
  3. During ImGui loop: modal.Render();
  4. After frame: if (modal.IsConfirmed()) { path = modal.GetSelectedFile(); }

Features:

Definition at line 52 of file FilePickerModal.h.

Constructor & Destructor Documentation

◆ FilePickerModal()

Olympe::FilePickerModal::FilePickerModal ( FilePickerType  fileType)
explicit

Constructs a file picker modal for the given file type.

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

◆ ~FilePickerModal()

Olympe::FilePickerModal::~FilePickerModal ( )
default

Member Function Documentation

◆ Close()

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.

◆ GetDefaultDirectory()

std::string Olympe::FilePickerModal::GetDefaultDirectory ( ) const
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:

◆ GetDescriptionText()

std::string Olympe::FilePickerModal::GetDescriptionText ( ) const
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:

◆ GetFilePattern()

std::string Olympe::FilePickerModal::GetFilePattern ( ) const
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:

◆ GetFileType()

FilePickerType Olympe::FilePickerModal::GetFileType ( ) const
inline

Returns the file type this modal handles.

Definition at line 116 of file FilePickerModal.h.

References m_fileType.

◆ GetFilteredFiles()

std::vector< std::string > Olympe::FilePickerModal::GetFilteredFiles ( ) const
private

Filters and returns files matching the search buffer.

Returns
Vector of matching filenames (case-insensitive substring matching)

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:

◆ GetModalTitle()

std::string Olympe::FilePickerModal::GetModalTitle ( ) const
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:

◆ GetSelectedFile()

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

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

Path format depends on file type:

  • BehaviorTree: "./Gamedata/MyTree.bt.json"
  • SubGraph: "Blueprints/MyBlueprint.ats"

Definition at line 111 of file FilePickerModal.h.

References m_selectedFile.

◆ IsConfirmed()

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

◆ IsOpen()

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

Returns true if modal is currently visible.

Definition at line 94 of file FilePickerModal.h.

References m_isOpen.

◆ Open()

void Olympe::FilePickerModal::Open ( const std::string &  currentPath = "")

Opens the modal with optional initial path.

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

◆ RefreshFileList()

void Olympe::FilePickerModal::RefreshFileList ( )
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:

◆ Render()

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:

◆ RenderActionButtons()

void Olympe::FilePickerModal::RenderActionButtons ( )
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:

◆ RenderFileList()

void Olympe::FilePickerModal::RenderFileList ( )
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:

Member Data Documentation

◆ m_confirmed

bool Olympe::FilePickerModal::m_confirmed = false
private

Did user click Select.

Definition at line 125 of file FilePickerModal.h.

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

◆ m_currentFilter

std::string Olympe::FilePickerModal::m_currentFilter = ""
private

Current file extension filter.

Definition at line 144 of file FilePickerModal.h.

Referenced by Open(), RefreshFileList(), and Render().

◆ m_currentPath

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

Current directory being browsed.

Definition at line 127 of file FilePickerModal.h.

Referenced by FilePickerModal(), Open(), RefreshFileList(), Render(), and RenderActionButtons().

◆ m_fileList

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

Files found in current directory.

Definition at line 133 of file FilePickerModal.h.

Referenced by GetFilteredFiles(), RefreshFileList(), Render(), RenderActionButtons(), and RenderFileList().

◆ m_fileType

FilePickerType Olympe::FilePickerModal::m_fileType
private

Type of files to browse.

Definition at line 123 of file FilePickerModal.h.

Referenced by GetDefaultDirectory(), GetDescriptionText(), GetFilePattern(), GetFileType(), GetModalTitle(), and Render().

◆ m_folderList

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

Folders in current directory.

Definition at line 134 of file FilePickerModal.h.

Referenced by RefreshFileList(), and Render().

◆ m_isOpen

bool Olympe::FilePickerModal::m_isOpen = false
private

Is modal currently visible.

Definition at line 124 of file FilePickerModal.h.

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

◆ m_pathBuffer

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

Path input text buffer.

Definition at line 141 of file FilePickerModal.h.

Referenced by FilePickerModal(), Open(), and Render().

◆ m_searchBuffer

char Olympe::FilePickerModal::m_searchBuffer[128] = ""
private

Search filter text buffer.

Definition at line 142 of file FilePickerModal.h.

Referenced by GetFilteredFiles(), Open(), and Render().

◆ m_selectedFile

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

Full path to selected file.

Definition at line 126 of file FilePickerModal.h.

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

◆ m_selectedFilterIndex

int Olympe::FilePickerModal::m_selectedFilterIndex = 0
private

Current filter type (0=default, 1=.bt.json, etc.)

Definition at line 143 of file FilePickerModal.h.

Referenced by Open(), and Render().

◆ m_selectedIndex

int Olympe::FilePickerModal::m_selectedIndex = -1
private

Currently highlighted file (-1 = none)

Definition at line 135 of file FilePickerModal.h.

Referenced by Open(), RefreshFileList(), Render(), RenderActionButtons(), and RenderFileList().


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