mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Merge #6282
6282: Add a refresh button to the editor file browser r=heinrich5991 a=Robyt3 ![screenshot_2023-01-13_22-51-07](https://user-images.githubusercontent.com/23437060/212426385-f8c03e58-8e5d-4c47-9f19-865946c5be9c.png) ## Checklist - [X] Tested the change ingame - [X] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
911bd0e69a
|
@ -4483,6 +4483,7 @@ void CEditor::RenderFileDialog()
|
||||||
// the buttons
|
// the buttons
|
||||||
static int s_OkButton = 0;
|
static int s_OkButton = 0;
|
||||||
static int s_CancelButton = 0;
|
static int s_CancelButton = 0;
|
||||||
|
static int s_RefreshButton = 0;
|
||||||
static int s_NewFolderButton = 0;
|
static int s_NewFolderButton = 0;
|
||||||
static int s_MapInfoButton = 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)
|
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
|
||||||
{
|
{
|
||||||
ButtonBar.VSplitLeft(40.0f, nullptr, &ButtonBar);
|
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();
|
m_vCompleteFileList.clear();
|
||||||
if(m_FileDialogStorageType != IStorage::TYPE_SAVE && !str_comp(m_pFileDialogPath, "maps"))
|
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);
|
Storage()->ListDirectory(StorageType, m_pFileDialogPath, EditorListdirCallback, this);
|
||||||
std::sort(m_vCompleteFileList.begin(), m_vCompleteFileList.end());
|
std::sort(m_vCompleteFileList.begin(), m_vCompleteFileList.end());
|
||||||
RefreshFilteredFileList();
|
RefreshFilteredFileList();
|
||||||
m_FilesSelectedIndex = m_vpFilteredFileList.empty() ? -1 : 0;
|
if(!KeepSelection)
|
||||||
if(m_FilesSelectedIndex >= 0)
|
{
|
||||||
str_copy(m_aFilesSelectedName, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aName);
|
m_FilesSelectedIndex = m_vpFilteredFileList.empty() ? -1 : 0;
|
||||||
else
|
if(m_FilesSelectedIndex >= 0)
|
||||||
m_aFilesSelectedName[0] = '\0';
|
str_copy(m_aFilesSelectedName, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aName);
|
||||||
|
else
|
||||||
|
m_aFilesSelectedName[0] = '\0';
|
||||||
|
}
|
||||||
m_PreviewImageIsLoaded = false;
|
m_PreviewImageIsLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -786,6 +786,7 @@ public:
|
||||||
m_MouseInsidePopup = false;
|
m_MouseInsidePopup = false;
|
||||||
|
|
||||||
m_FileDialogStorageType = 0;
|
m_FileDialogStorageType = 0;
|
||||||
|
m_FileDialogLastPopulatedStorageType = 0;
|
||||||
m_pFileDialogTitle = nullptr;
|
m_pFileDialogTitle = nullptr;
|
||||||
m_pFileDialogButtonText = nullptr;
|
m_pFileDialogButtonText = nullptr;
|
||||||
m_pFileDialogUser = nullptr;
|
m_pFileDialogUser = nullptr;
|
||||||
|
@ -872,7 +873,7 @@ public:
|
||||||
CLayerGroup *m_apSavedBrushes[10];
|
CLayerGroup *m_apSavedBrushes[10];
|
||||||
|
|
||||||
void RefreshFilteredFileList();
|
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,
|
void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText,
|
||||||
const char *pBasepath, const char *pDefaultName,
|
const char *pBasepath, const char *pDefaultName,
|
||||||
void (*pfnFunc)(const char *pFilename, int StorageType, void *pUser), void *pUser);
|
void (*pfnFunc)(const char *pFilename, int StorageType, void *pUser), void *pUser);
|
||||||
|
@ -947,6 +948,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int m_FileDialogStorageType;
|
int m_FileDialogStorageType;
|
||||||
|
int m_FileDialogLastPopulatedStorageType;
|
||||||
const char *m_pFileDialogTitle;
|
const char *m_pFileDialogTitle;
|
||||||
const char *m_pFileDialogButtonText;
|
const char *m_pFileDialogButtonText;
|
||||||
void (*m_pfnFileDialogFunc)(const char *pFileName, int StorageType, void *pUser);
|
void (*m_pfnFileDialogFunc)(const char *pFileName, int StorageType, void *pUser);
|
||||||
|
|
Loading…
Reference in a new issue