MCPcopy Create free account
hub / github.com/ddnet/ddnet / ShowFileDialog

Method ShowFileDialog

src/game/editor/file_browser.cpp:18–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 ".opus"};
17
18void CFileBrowser::ShowFileDialog(
19 int StorageType, EFileType FileType,
20 const char *pTitle, const char *pButtonText,
21 const char *pInitialPath, const char *pInitialFilename,
22 FFileDialogOpenCallback pfnOpenCallback, void *pOpenCallbackUser)
23{
24 m_StorageType = StorageType;
25 m_FileType = FileType;
26 if(m_StorageType == IStorage::TYPE_ALL)
27 {
28 int NumStoragesWithFolder = 0;
29 for(int CheckStorageType = IStorage::TYPE_SAVE; CheckStorageType < Storage()->NumPaths(); ++CheckStorageType)
30 {
31 if(Storage()->FolderExists(pInitialPath, CheckStorageType))
32 {
33 NumStoragesWithFolder++;
34 }
35 }
36 m_MultipleStorages = NumStoragesWithFolder > 1;
37 }
38 else
39 {
40 m_MultipleStorages = false;
41 }
42 m_SaveAction = m_StorageType == IStorage::TYPE_SAVE;
43
44 Ui()->ClosePopupMenus();
45 str_copy(m_aTitle, pTitle);
46 str_copy(m_aButtonText, pButtonText);
47 m_pfnOpenCallback = pfnOpenCallback;
48 m_pOpenCallbackUser = pOpenCallbackUser;
49 m_ShowingRoot = false;
50 str_copy(m_aInitialFolder, pInitialPath);
51 str_copy(m_aCurrentFolder, pInitialPath);
52 m_aCurrentLink[0] = '\0';
53 m_pCurrentPath = m_aCurrentFolder;
54 m_FilenameInput.Set(pInitialFilename);
55 m_FilterInput.Clear();
56 dbg_assert(m_PreviewState == EPreviewState::UNLOADED, "Preview was not unloaded before showing file dialog");
57 m_ListBox.Reset();
58
59 FilelistPopulate(m_StorageType, false);
60
61 if(m_SaveAction)
62 {
63 Ui()->SetActiveItem(&m_FilenameInput);
64 if(!m_FilenameInput.IsEmpty())
65 {
66 UpdateSelectedIndex(m_FilenameInput.GetString());
67 }
68 }
69 else
70 {
71 Ui()->SetActiveItem(&m_FilterInput);
72 UpdateFilenameInput();
73 }
74
75 Editor()->m_Dialog = DIALOG_FILE;

Callers 9

RenderSoundsMethod · 0.80
RenderMethod · 0.80
PopupMenuFileMethod · 0.80
PopupMenuToolsMethod · 0.80
PopupImageMethod · 0.80
PopupSoundMethod · 0.80
PopupEventMethod · 0.80
PopupEntitiesMethod · 0.80
quick_actions.hFile · 0.80

Calls 12

StorageFunction · 0.85
UiFunction · 0.85
NumPathsMethod · 0.80
FolderExistsMethod · 0.80
ClosePopupMenusMethod · 0.80
SetActiveItemMethod · 0.80
str_copyFunction · 0.50
SetMethod · 0.45
ClearMethod · 0.45
ResetMethod · 0.45
IsEmptyMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected