diff options
| author | oy <Tom_Adams@web.de> | 2010-10-16 18:33:54 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-10-16 18:33:54 +0200 |
| commit | 85fd27284621d335dd76ee66da7349b19004adc1 (patch) | |
| tree | 82d377b016cb5dae093b76bb16a9eacf82f1fd05 | |
| parent | 662f43919cfb1cd449a75516a87ad2e9623636b1 (diff) | |
| download | zcatch-85fd27284621d335dd76ee66da7349b19004adc1.tar.gz zcatch-85fd27284621d335dd76ee66da7349b19004adc1.zip | |
added the possibility to create a new folder within the editor's save file dialog
| -rw-r--r-- | src/engine/shared/storage.cpp | 9 | ||||
| -rw-r--r-- | src/engine/storage.h | 1 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 21 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index cfe64e4b..46127700 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -300,6 +300,15 @@ public: return remove(GetPath(Type, pFilename, aBuffer, sizeof(aBuffer))); } + virtual bool CreateFolder(const char *pFoldername, int Type) + { + if(Type < 0 || Type >= m_NumPaths) + return false; + + char aBuffer[MAX_PATH_LENGTH]; + return fs_makedir(GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer))); + } + static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments) { CStorage *p = new CStorage(); diff --git a/src/engine/storage.h b/src/engine/storage.h index c483c52d..d01a7dd0 100644 --- a/src/engine/storage.h +++ b/src/engine/storage.h @@ -16,6 +16,7 @@ public: virtual void ListDirectory(int Type, const char *pPath, FS_LISTDIR_CALLBACK pfnCallback, void *pUser) = 0; virtual IOHANDLE OpenFile(const char *pFilename, int Flags, int Type, char *pBuffer = 0, int BufferSize = 0) = 0; virtual bool RemoveFile(const char *pFilename, int Type) = 0; + virtual bool CreateFolder(const char *pFoldername, int Type) = 0; }; extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments); diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 1c6ad225..1cf367d4 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2293,6 +2293,7 @@ void CEditor::RenderFileDialog() // the buttons static int s_OkButton = 0; static int s_CancelButton = 0; + static int s_NewFolderButton = 0; CUIRect Button; ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button); @@ -2341,6 +2342,26 @@ void CEditor::RenderFileDialog() ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button); if(DoButton_Editor(&s_CancelButton, Localize("Cancel"), 0, &Button, 0, 0) || Input()->KeyPressed(KEY_ESCAPE)) m_Dialog = DIALOG_NONE; + + if(m_FileDialogStorageType == IStorage::TYPE_SAVE) + { + ButtonBar.VSplitLeft(40.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(70.0f, &Button, &ButtonBar); + if(DoButton_Editor(&s_NewFolderButton, Localize("New folder"), 0, &Button, 0, 0)) + { + if(*m_aFileDialogFileName) + { + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "%s/%s", m_pFileDialogPath, m_aFileDialogFileName); + Storage()->CreateFolder(aBuf, IStorage::TYPE_SAVE); + FilelistPopulate(IStorage::TYPE_SAVE); + if(m_FilesSelectedIndex >= 0 && !m_FileList[m_FilesSelectedIndex].m_IsDir) + str_copy(m_aFileDialogFileName, m_FileList[m_FilesSelectedIndex].m_aFilename, sizeof(m_aFileDialogFileName)); + else + m_aFileDialogFileName[0] = 0; + } + } + } } void CEditor::FilelistPopulate(int StorageType) |