From bafd22ebe7e249e05ba4b64266196935abcc5c66 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 13:14:02 +0100 Subject: show path in the editor file dialog. Closes #786 --- src/engine/shared/storage.cpp | 12 ++++++++++++ src/engine/storage.h | 1 + src/game/editor/editor.cpp | 13 ++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index d6f83dc8..c1888188 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -377,6 +377,18 @@ public: return !fs_makedir(GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer))); } + virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) + { + if(Type < 0 || Type >= m_NumPaths) + { + if(BufferSize > 0) + pBuffer[0] = 0; + return; + } + + GetPath(Type, pDir, pBuffer, BufferSize); + } + 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 1fd48f6a..bcfb9ce2 100644 --- a/src/engine/storage.h +++ b/src/engine/storage.h @@ -21,6 +21,7 @@ public: virtual bool RemoveFile(const char *pFilename, int Type) = 0; virtual bool RenameFile(const char* pOldFilename, const char* pNewFilename, int Type) = 0; virtual bool CreateFolder(const char *pFoldername, int Type) = 0; + virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) = 0; }; extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments); diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 6b0a401c..a5a9392a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2781,11 +2781,13 @@ void CEditor::RenderFileDialog() RenderTools()->DrawUIRect(&View, vec4(0,0,0,0.75f), CUI::CORNER_ALL, 5.0f); View.Margin(10.0f, &View); - CUIRect Title, FileBox, FileBoxLabel, ButtonBar, Scroll; + CUIRect Title, FileBox, FileBoxLabel, ButtonBar, Scroll, PathBox; View.HSplitTop(18.0f, &Title, &View); View.HSplitTop(5.0f, 0, &View); // some spacing View.HSplitBottom(14.0f, &View, &ButtonBar); View.HSplitBottom(10.0f, &View, 0); // some spacing + View.HSplitBottom(14.0f, &View, &PathBox); + View.HSplitBottom(5.0f, &View, 0); // some spacing View.HSplitBottom(14.0f, &View, &FileBox); FileBox.VSplitLeft(55.0f, &FileBoxLabel, &FileBox); View.HSplitBottom(10.0f, &View, 0); // some spacing @@ -2796,6 +2798,15 @@ void CEditor::RenderFileDialog() Title.VMargin(10.0f, &Title); UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, -1, -1); + // pathbox + char aPath[128], aBuf[128]; + if(m_FilesSelectedIndex != -1) + Storage()->GetCompletePath(m_FileList[m_FilesSelectedIndex].m_StorageType, m_pFileDialogPath, aPath, sizeof(aPath)); + else + aPath[0] = 0; + str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath); + UI()->DoLabel(&PathBox, aBuf, 10.0f, -1, -1); + // filebox if(m_FileDialogStorageType == IStorage::TYPE_SAVE) { -- cgit 1.4.1