Browse Source

967 NFD file dialogs no longer remember the last path chosen for common operations

JimMarlowe 9 years ago
parent
commit
2d5f3110e6
1 changed files with 19 additions and 25 deletions
  1. 19 25
      Source/AtomicEditor/Utils/FileUtils.cpp

+ 19 - 25
Source/AtomicEditor/Utils/FileUtils.cpp

@@ -45,11 +45,15 @@ FileUtils::~FileUtils()
 String FileUtils::OpenProjectFileDialog()
 String FileUtils::OpenProjectFileDialog()
 {
 {
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
-    
-    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
+
+    String upath;
+
+#ifdef ATOMIC_PLATFORM_LINUX
+    upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
+#endif
 
 
     nfdresult_t result = NFD_OpenDialog( "atomic",
     nfdresult_t result = NFD_OpenDialog( "atomic",
-                                GetNativePath(upath).CString(),
+                                upath.Length() ? GetNativePath(upath).CString() : "",
                                 &outPath);
                                 &outPath);
 
 
     String fullpath;
     String fullpath;
@@ -86,10 +90,14 @@ String FileUtils::NewProjectFileDialog()
 
 
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
 
 
-    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
+    String upath;
+    
+#ifdef ATOMIC_PLATFORM_LINUX
+    upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
+#endif
 
 
     nfdresult_t result = NFD_ChooseDirectory( "Please choose the root folder for your project",
     nfdresult_t result = NFD_ChooseDirectory( "Please choose the root folder for your project",
-                                GetNativePath(upath).CString(),
+                                upath.Length() ? GetNativePath(upath).CString() : "",
                                 &outPath);
                                 &outPath);
 
 
 
 
@@ -113,11 +121,8 @@ String FileUtils::GetBuildPath(const String& defaultPath)
 
 
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
     
     
-    String ppath = GetSubsystem<FileSystem>()->GetProgramDir();
-    if ( defaultPath.Length() > 0) ppath = defaultPath;
-
     nfdresult_t result = NFD_ChooseDirectory( "Please choose the build folder",
     nfdresult_t result = NFD_ChooseDirectory( "Please choose the build folder",
-                                GetNativePath(ppath).CString(),
+                                defaultPath.Length() ? GetNativePath(defaultPath).CString() : "",
                                 &outPath);
                                 &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
@@ -146,11 +151,8 @@ String FileUtils::GetAntPath(const String& defaultPath)
     String msg = "Please select the folder which contains the ant executable";
     String msg = "Please select the folder which contains the ant executable";
 #endif
 #endif
 
 
-    String ppath = GetSubsystem<FileSystem>()->GetProgramDir();
-    if ( defaultPath.Length() > 0) ppath = defaultPath;
-
     nfdresult_t result = NFD_ChooseDirectory(msg.CString(),
     nfdresult_t result = NFD_ChooseDirectory(msg.CString(),
-                        GetNativePath(ppath).CString(),
+                        defaultPath.Length() ? GetNativePath(defaultPath).CString() : "",
                         &outPath);
                         &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
@@ -170,10 +172,8 @@ String FileUtils::GetMobileProvisionPath()
 {
 {
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
 
 
-    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
-
     nfdresult_t result = NFD_OpenDialog( "mobileprovision",
     nfdresult_t result = NFD_OpenDialog( "mobileprovision",
-                                GetNativePath(upath).CString(),
+                                "",
                                 &outPath);
                                 &outPath);
 
 
     String fullpath;
     String fullpath;
@@ -208,12 +208,9 @@ String FileUtils::FindPath(const String& title, const String& defaultPath)
     String resultPath;
     String resultPath;
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
 
 
-    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
-    if ( defaultPath.Length() > 0) upath = defaultPath;
-
     nfdresult_t result = NFD_ChooseDirectory(title.CString(),
     nfdresult_t result = NFD_ChooseDirectory(title.CString(),
-                        GetNativePath(upath).CString(),
-                        &outPath);
+                       defaultPath.Length() ? GetNativePath(defaultPath).CString() : "",
+                       &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
     {
     {
@@ -233,11 +230,8 @@ String FileUtils::FindFile (const String& filterlist, const String& defaultPath)
     String fullpath;
     String fullpath;
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
 
 
-    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
-    if ( defaultPath.Length() > 0) upath = defaultPath;
-
     nfdresult_t result = NFD_OpenDialog( filterlist.CString(),
     nfdresult_t result = NFD_OpenDialog( filterlist.CString(),
-        GetNativePath(upath).CString(),
+        defaultPath.Length() ? GetNativePath(defaultPath).CString() : "",
         &outPath);
         &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)