diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 0cdee0a2a..688551a1d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -4483,6 +4483,7 @@ void CEditor::RenderFileDialog() // the buttons static int s_OkButton = 0; static int s_CancelButton = 0; + static int s_RefreshButton = 0; static int s_NewFolderButton = 0; static int s_MapInfoButton = 0; @@ -4558,6 +4559,11 @@ void CEditor::RenderFileDialog() } } + ButtonBar.VSplitRight(40.0f, &ButtonBar, &Button); + ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button); + if(DoButton_Editor(&s_RefreshButton, "Refresh", 0, &Button, 0, nullptr) || Input()->KeyIsPressed(KEY_F5) || (Input()->ModifierIsPressed() && Input()->KeyIsPressed(KEY_R))) + FilelistPopulate(m_FileDialogLastPopulatedStorageType, true); + if(m_FileDialogStorageType == IStorage::TYPE_SAVE) { ButtonBar.VSplitLeft(40.0f, nullptr, &ButtonBar); @@ -4608,8 +4614,9 @@ void CEditor::RefreshFilteredFileList() } } -void CEditor::FilelistPopulate(int StorageType) +void CEditor::FilelistPopulate(int StorageType, bool KeepSelection) { + m_FileDialogLastPopulatedStorageType = StorageType; m_vCompleteFileList.clear(); if(m_FileDialogStorageType != IStorage::TYPE_SAVE && !str_comp(m_pFileDialogPath, "maps")) { @@ -4624,11 +4631,14 @@ void CEditor::FilelistPopulate(int StorageType) Storage()->ListDirectory(StorageType, m_pFileDialogPath, EditorListdirCallback, this); std::sort(m_vCompleteFileList.begin(), m_vCompleteFileList.end()); RefreshFilteredFileList(); - m_FilesSelectedIndex = m_vpFilteredFileList.empty() ? -1 : 0; - if(m_FilesSelectedIndex >= 0) - str_copy(m_aFilesSelectedName, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aName); - else - m_aFilesSelectedName[0] = '\0'; + if(!KeepSelection) + { + m_FilesSelectedIndex = m_vpFilteredFileList.empty() ? -1 : 0; + if(m_FilesSelectedIndex >= 0) + str_copy(m_aFilesSelectedName, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aName); + else + m_aFilesSelectedName[0] = '\0'; + } m_PreviewImageIsLoaded = false; } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index ba9313c82..ae85acf4d 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -786,6 +786,7 @@ public: m_MouseInsidePopup = false; m_FileDialogStorageType = 0; + m_FileDialogLastPopulatedStorageType = 0; m_pFileDialogTitle = nullptr; m_pFileDialogButtonText = nullptr; m_pFileDialogUser = nullptr; @@ -872,7 +873,7 @@ public: CLayerGroup *m_apSavedBrushes[10]; void RefreshFilteredFileList(); - void FilelistPopulate(int StorageType); + void FilelistPopulate(int StorageType, bool KeepSelection = false); void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText, const char *pBasepath, const char *pDefaultName, void (*pfnFunc)(const char *pFilename, int StorageType, void *pUser), void *pUser); @@ -947,6 +948,7 @@ public: }; int m_FileDialogStorageType; + int m_FileDialogLastPopulatedStorageType; const char *m_pFileDialogTitle; const char *m_pFileDialogButtonText; void (*m_pfnFileDialogFunc)(const char *pFileName, int StorageType, void *pUser);