DDNet documentation
Loading...
Searching...
No Matches
CFileBrowser Class Reference

#include <file_browser.h>

Inheritance diagram for CFileBrowser:
[legend]
Collaboration diagram for CFileBrowser:
[legend]

Classes

class  CFilelistItem
class  CPopupNewFolder
class  CPopupConfirmDelete
class  CPopupConfirmOverwrite

Public Types

enum class  EFileType { MAP , IMAGE , SOUND }
typedef bool(*) FFileDialogOpenCallback(const char *pFilename, int StorageType, void *pUser)

Public Member Functions

void ShowFileDialog (int StorageType, EFileType FileType, const char *pTitle, const char *pButtonText, const char *pInitialPath, const char *pInitialFilename, FFileDialogOpenCallback pfnOpenCallback, void *pOpenCallbackUser)
void Render ()
bool IsValidSaveFilename () const
void OnEditorClose ()
void OnDialogClose ()
Public Member Functions inherited from CEditorComponent
void OnInit (CEditor *pEditor) override
virtual void OnReset ()
virtual void OnMapLoad ()
virtual bool OnInput (const IInput::CEvent &Event)
virtual void OnUpdate ()
void InitSubComponents ()
void RegisterSubComponent (CEditorComponent &Component)
Public Member Functions inherited from CEditorObject
virtual ~CEditorObject ()=default
CEditor * Editor ()
const CEditor * Editor () const
CEditorMap * Map ()
const CEditorMap * Map () const
IInput * Input ()
const IInput * Input () const
IClient * Client ()
const IClient * Client () const
CConfig * Config ()
const CConfig * Config () const
IEngine * Engine ()
const IEngine * Engine () const
IGraphics * Graphics ()
const IGraphics * Graphics () const
ISound * Sound ()
const ISound * Sound () const
ITextRender * TextRender ()
const ITextRender * TextRender () const
IStorage * Storage ()
const IStorage * Storage () const
CUi * Ui ()
const CUi * Ui () const
CRenderMap * RenderMap ()
const CRenderMap * RenderMap () const

Private Types

enum class  ESortDirection { NEUTRAL , ASCENDING , DESCENDING }
enum class  EPreviewState { UNLOADED , LOADED , ERROR }

Private Member Functions

bool CanPreviewFile () const
void UpdateFilePreview ()
void RenderFilePreview (CUIRect Preview)
const char * DetermineFileFontIcon (const CFilelistItem *pItem) const
void UpdateFilenameInput ()
void UpdateSelectedIndex (const char *pDisplayName)
void SortFilteredFileList ()
void RefreshFilteredFileList ()
void FilelistPopulate (int StorageType, bool KeepSelection)

Static Private Member Functions

static int DirectoryListingCallback (const CFsFileInfo *pInfo, int IsDir, int StorageType, void *pUser)
static std::optional< bool > CompareCommon (const CFilelistItem *pLhs, const CFilelistItem *pRhs)
static bool CompareFilenameAscending (const CFilelistItem *pLhs, const CFilelistItem *pRhs)
static bool CompareFilenameDescending (const CFilelistItem *pLhs, const CFilelistItem *pRhs)
static bool CompareTimeModifiedAscending (const CFilelistItem *pLhs, const CFilelistItem *pRhs)
static bool CompareTimeModifiedDescending (const CFilelistItem *pLhs, const CFilelistItem *pRhs)

Private Attributes

int m_StorageType = 0
EFileType m_FileType = EFileType::MAP
bool m_SaveAction = false
bool m_MultipleStorages = false
char m_aTitle [128] = ""
char m_aButtonText [64] = ""
FFileDialogOpenCallback m_pfnOpenCallback = nullptr
void * m_pOpenCallbackUser = nullptr
bool m_ShowingRoot = false
char m_aInitialFolder [IO_MAX_PATH_LENGTH] = ""
char m_aCurrentFolder [IO_MAX_PATH_LENGTH] = ""
char m_aCurrentLink [IO_MAX_PATH_LENGTH] = ""
char * m_pCurrentPath = m_aCurrentFolder
CLineInputBuffered< IO_MAX_PATH_LENGTH > m_FilenameInput
CLineInputBuffered< IO_MAX_PATH_LENGTH > m_FilterInput
int m_SelectedFileIndex = -1
char m_aSelectedFileDisplayName [IO_MAX_PATH_LENGTH] = ""
std::vector< CFilelistItem > m_vCompleteFileList
std::vector< const CFilelistItem * > m_vpFilteredFileList
ESortDirection m_SortByFilename = ESortDirection::ASCENDING
ESortDirection m_SortByTimeModified = ESortDirection::NEUTRAL
EPreviewState m_PreviewState = EPreviewState::UNLOADED
IGraphics::CTextureHandle m_PreviewImage
int m_PreviewImageWidth = 0
int m_PreviewImageHeight = 0
int m_PreviewSound = -1
CListBox m_ListBox
const char m_ButtonSortTimeModifiedId = 0
const char m_ButtonSortFilenameId = 0
const char m_ButtonPlayPauseId = 0
const char m_ButtonStopId = 0
const char m_SeekBarId = 0
const char m_ButtonOkId = 0
const char m_ButtonCancelId = 0
const char m_ButtonRefreshId = 0
const char m_ButtonShowDirectoryId = 0
const char m_ButtonDeleteId = 0
const char m_ButtonNewFolderId = 0
CPopupNewFolder m_PopupNewFolder
CPopupConfirmDelete m_PopupConfirmDelete
CPopupConfirmOverwrite m_PopupConfirmOverwrite

Member Typedef Documentation

◆ FFileDialogOpenCallback

typedef bool(*) CFileBrowser::FFileDialogOpenCallback(const char *pFilename, int StorageType, void *pUser)

Member Enumeration Documentation

◆ EFileType

enum class CFileBrowser::EFileType
strong
Enumerator
MAP 
IMAGE 
SOUND 

◆ EPreviewState

enum class CFileBrowser::EPreviewState
strongprivate
Enumerator
UNLOADED 
LOADED 
ERROR 

◆ ESortDirection

enum class CFileBrowser::ESortDirection
strongprivate
Enumerator
NEUTRAL 
ASCENDING 
DESCENDING 

Member Function Documentation

◆ CanPreviewFile()

bool CFileBrowser::CanPreviewFile ( ) const
private

◆ CompareCommon()

std::optional< bool > CFileBrowser::CompareCommon ( const CFilelistItem * pLhs,
const CFilelistItem * pRhs )
staticprivate

◆ CompareFilenameAscending()

bool CFileBrowser::CompareFilenameAscending ( const CFilelistItem * pLhs,
const CFilelistItem * pRhs )
staticprivate

◆ CompareFilenameDescending()

bool CFileBrowser::CompareFilenameDescending ( const CFilelistItem * pLhs,
const CFilelistItem * pRhs )
staticprivate

◆ CompareTimeModifiedAscending()

bool CFileBrowser::CompareTimeModifiedAscending ( const CFilelistItem * pLhs,
const CFilelistItem * pRhs )
staticprivate

◆ CompareTimeModifiedDescending()

bool CFileBrowser::CompareTimeModifiedDescending ( const CFilelistItem * pLhs,
const CFilelistItem * pRhs )
staticprivate

◆ DetermineFileFontIcon()

const char * CFileBrowser::DetermineFileFontIcon ( const CFilelistItem * pItem) const
private

◆ DirectoryListingCallback()

int CFileBrowser::DirectoryListingCallback ( const CFsFileInfo * pInfo,
int IsDir,
int StorageType,
void * pUser )
staticprivate

◆ FilelistPopulate()

void CFileBrowser::FilelistPopulate ( int StorageType,
bool KeepSelection )
private

◆ IsValidSaveFilename()

bool CFileBrowser::IsValidSaveFilename ( ) const

◆ OnDialogClose()

void CFileBrowser::OnDialogClose ( )

◆ OnEditorClose()

void CFileBrowser::OnEditorClose ( )

◆ RefreshFilteredFileList()

void CFileBrowser::RefreshFilteredFileList ( )
private

◆ Render()

void CFileBrowser::Render ( )

◆ RenderFilePreview()

void CFileBrowser::RenderFilePreview ( CUIRect Preview)
private

◆ ShowFileDialog()

void CFileBrowser::ShowFileDialog ( int StorageType,
EFileType FileType,
const char * pTitle,
const char * pButtonText,
const char * pInitialPath,
const char * pInitialFilename,
FFileDialogOpenCallback pfnOpenCallback,
void * pOpenCallbackUser )

◆ SortFilteredFileList()

void CFileBrowser::SortFilteredFileList ( )
private

◆ UpdateFilenameInput()

void CFileBrowser::UpdateFilenameInput ( )
private

◆ UpdateFilePreview()

void CFileBrowser::UpdateFilePreview ( )
private

◆ UpdateSelectedIndex()

void CFileBrowser::UpdateSelectedIndex ( const char * pDisplayName)
private

Member Data Documentation

◆ m_aButtonText

char CFileBrowser::m_aButtonText[64] = ""
private

Text of the confirmation button that opens/saves the file.

◆ m_aCurrentFolder

char CFileBrowser::m_aCurrentFolder[IO_MAX_PATH_LENGTH] = ""
private

Path of the current folder being shown in the file browser.

◆ m_aCurrentLink

char CFileBrowser::m_aCurrentLink[IO_MAX_PATH_LENGTH] = ""
private

Path of the current link being shown in the file browser.

◆ m_aInitialFolder

char CFileBrowser::m_aInitialFolder[IO_MAX_PATH_LENGTH] = ""
private

Path of the initial folder that the file browser was opened with.

◆ m_aSelectedFileDisplayName

char CFileBrowser::m_aSelectedFileDisplayName[IO_MAX_PATH_LENGTH] = ""
private

Display name of the selected file list entry in m_vpFilteredFileList and m_vCompleteFileList.

◆ m_aTitle

char CFileBrowser::m_aTitle[128] = ""
private

Title text of the file dialog.

◆ m_ButtonCancelId

const char CFileBrowser::m_ButtonCancelId = 0
private

◆ m_ButtonDeleteId

const char CFileBrowser::m_ButtonDeleteId = 0
private

◆ m_ButtonNewFolderId

const char CFileBrowser::m_ButtonNewFolderId = 0
private

◆ m_ButtonOkId

const char CFileBrowser::m_ButtonOkId = 0
private

◆ m_ButtonPlayPauseId

const char CFileBrowser::m_ButtonPlayPauseId = 0
private

◆ m_ButtonRefreshId

const char CFileBrowser::m_ButtonRefreshId = 0
private

◆ m_ButtonShowDirectoryId

const char CFileBrowser::m_ButtonShowDirectoryId = 0
private

◆ m_ButtonSortFilenameId

const char CFileBrowser::m_ButtonSortFilenameId = 0
private

◆ m_ButtonSortTimeModifiedId

const char CFileBrowser::m_ButtonSortTimeModifiedId = 0
private

◆ m_ButtonStopId

const char CFileBrowser::m_ButtonStopId = 0
private

◆ m_FilenameInput

CLineInputBuffered<IO_MAX_PATH_LENGTH> CFileBrowser::m_FilenameInput
private

Input for the filename when saving files and also buffer for the selected file's name in general.

◆ m_FileType

EFileType CFileBrowser::m_FileType = EFileType::MAP
private

File type for which the file browser is currently showing entries.

◆ m_FilterInput

CLineInputBuffered<IO_MAX_PATH_LENGTH> CFileBrowser::m_FilterInput
private

Input for the file search when opening files for reading.

◆ m_ListBox

CListBox CFileBrowser::m_ListBox
private

◆ m_MultipleStorages

bool CFileBrowser::m_MultipleStorages = false
private

Whether multiple storage locations with the initial folder are available.

◆ m_pCurrentPath

char* CFileBrowser::m_pCurrentPath = m_aCurrentFolder
private

Current path being shown in the file browser, which either points to m_aCurrentFolder or m_aCurrentLink.

◆ m_pfnOpenCallback

FFileDialogOpenCallback CFileBrowser::m_pfnOpenCallback = nullptr
private

Callback function that will be called when the confirmation button is pressed.

◆ m_pOpenCallbackUser

void* CFileBrowser::m_pOpenCallbackUser = nullptr
private

User data for m_pfnOpenCallback.

◆ m_PopupConfirmDelete

CPopupConfirmDelete CFileBrowser::m_PopupConfirmDelete
private

◆ m_PopupConfirmOverwrite

CPopupConfirmOverwrite CFileBrowser::m_PopupConfirmOverwrite
private

◆ m_PopupNewFolder

CPopupNewFolder CFileBrowser::m_PopupNewFolder
private

◆ m_PreviewImage

IGraphics::CTextureHandle CFileBrowser::m_PreviewImage
private

◆ m_PreviewImageHeight

int CFileBrowser::m_PreviewImageHeight = 0
private

◆ m_PreviewImageWidth

int CFileBrowser::m_PreviewImageWidth = 0
private

◆ m_PreviewSound

int CFileBrowser::m_PreviewSound = -1
private

◆ m_PreviewState

EPreviewState CFileBrowser::m_PreviewState = EPreviewState::UNLOADED
private

◆ m_SaveAction

bool CFileBrowser::m_SaveAction = false
private

true if file browser was opened with the intent to save a file. false if file browser was opened with the intent to open an existing file for reading.

◆ m_SeekBarId

const char CFileBrowser::m_SeekBarId = 0
private

◆ m_SelectedFileIndex

int CFileBrowser::m_SelectedFileIndex = -1
private

Index of the selected file list entry in m_vpFilteredFileList.

◆ m_ShowingRoot

bool CFileBrowser::m_ShowingRoot = false
private

Whether the list of storages is currently being shown, if m_MultipleStorages is true.

◆ m_SortByFilename

ESortDirection CFileBrowser::m_SortByFilename = ESortDirection::ASCENDING
private

◆ m_SortByTimeModified

ESortDirection CFileBrowser::m_SortByTimeModified = ESortDirection::NEUTRAL
private

◆ m_StorageType

int CFileBrowser::m_StorageType = 0
private

Storage type for which the file browser is currently showing entries.

◆ m_vCompleteFileList

std::vector<CFilelistItem> CFileBrowser::m_vCompleteFileList
private

◆ m_vpFilteredFileList

std::vector<const CFilelistItem *> CFileBrowser::m_vpFilteredFileList
private

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