Browse Source

UI914 Better and remembered default paths

JimMarlowe 9 years ago
parent
commit
e976f341fd

+ 10 - 5
Script/AtomicEditor/ui/modal/build/platforms/AndroidSettingsWidget.ts

@@ -75,7 +75,8 @@ class AndroidSettingsWidget extends Atomic.UIWidget implements BuildSettingsWind
             if (ev.target.id == "choose_sdk_path") {
             if (ev.target.id == "choose_sdk_path") {
 
 
                 var fileUtils = new Editor.FileUtils();
                 var fileUtils = new Editor.FileUtils();
-                var path = fileUtils.findPath("Please choose the root folder of your Android SDK" , "");
+                var currsdk = this.sdkPathEdit.text;
+                var path = fileUtils.findPath("Please choose the root folder of your Android SDK" , currsdk );
                 if ( path.length > 0 )
                 if ( path.length > 0 )
                     this.sdkPathEdit.text = path;
                     this.sdkPathEdit.text = path;
 
 
@@ -84,7 +85,8 @@ class AndroidSettingsWidget extends Atomic.UIWidget implements BuildSettingsWind
             } else if (ev.target.id == "choose_ant_path") {
             } else if (ev.target.id == "choose_ant_path") {
 
 
                 var fileUtils = new Editor.FileUtils();
                 var fileUtils = new Editor.FileUtils();
-                var path = fileUtils.getAntPath("");
+                var currant = this.antPathEdit.text;
+                var path = fileUtils.getAntPath(currant);
                 if ( path.length > 0 )
                 if ( path.length > 0 )
                     this.antPathEdit.text = path;
                     this.antPathEdit.text = path;
 
 
@@ -93,7 +95,8 @@ class AndroidSettingsWidget extends Atomic.UIWidget implements BuildSettingsWind
             }  else if (ev.target.id == "choose_jdk_root") {
             }  else if (ev.target.id == "choose_jdk_root") {
 
 
                 var fileUtils = new Editor.FileUtils();
                 var fileUtils = new Editor.FileUtils();
-                var path = fileUtils.findPath("Please choose the root folder of your JDK" , "");
+                var currjdk = this.jdkRootEdit.text;
+                var path = fileUtils.findPath("Please choose the root folder of your JDK" , currjdk );
                 if ( path.length > 0 )
                 if ( path.length > 0 )
                     this.jdkRootEdit.text = path;
                     this.jdkRootEdit.text = path;
 
 
@@ -105,14 +108,16 @@ class AndroidSettingsWidget extends Atomic.UIWidget implements BuildSettingsWind
 
 
             }  else if (ev.target.id == "choose_and_auth") {
             }  else if (ev.target.id == "choose_and_auth") {
                 var fileUtils = new Editor.FileUtils();
                 var fileUtils = new Editor.FileUtils();
-                var path = fileUtils.findPath( "Please choose the folder of your ant.properties", "");
+                var currauth = this.releaseNameEdit.text;
+                var path = fileUtils.findPath( "Please choose the folder of your ant.properties", currauth );
                 if ( path.length > 0 )
                 if ( path.length > 0 )
                     this.releaseNameEdit.text = path;
                     this.releaseNameEdit.text = path;
                 return true;
                 return true;
 
 
             }  else if (ev.target.id == "choose_icon") {
             }  else if (ev.target.id == "choose_icon") {
                 var fileUtils = new Editor.FileUtils();
                 var fileUtils = new Editor.FileUtils();
-                var path = fileUtils.findPath("Please choose the folder with drawable folders" , "");
+                var curricon = this.iconNameEdit.text;
+                var path = fileUtils.findPath("Please choose the folder with drawable folders" , curricon);
                 if ( path.length > 0 ) {
                 if ( path.length > 0 ) {
                     this.iconNameEdit.text = path;
                     this.iconNameEdit.text = path;
                     this.updateIconButton();
                     this.updateIconButton();

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

@@ -45,9 +45,11 @@ FileUtils::~FileUtils()
 String FileUtils::OpenProjectFileDialog()
 String FileUtils::OpenProjectFileDialog()
 {
 {
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
+    
+    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
 
 
     nfdresult_t result = NFD_OpenDialog( "atomic",
     nfdresult_t result = NFD_OpenDialog( "atomic",
-                                NULL,
+                                upath.CString(),
                                 &outPath);
                                 &outPath);
 
 
     String fullpath;
     String fullpath;
@@ -84,8 +86,10 @@ String FileUtils::NewProjectFileDialog()
 
 
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;
 
 
+    String upath = GetSubsystem<FileSystem>()->GetUserDocumentsDir();
+
     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",
-                                NULL,
+                                upath.CString(),
                                 &outPath);
                                 &outPath);
 
 
 
 
@@ -108,9 +112,12 @@ String FileUtils::GetBuildPath(const String& defaultPath)
     String buildPath;
     String buildPath;
 
 
     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",
-                                defaultPath.Length() ? defaultPath.CString() : NULL,
+                               ppath.CString(),
                                 &outPath);
                                 &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
@@ -139,8 +146,11 @@ 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(),
-        defaultPath.Length() ? defaultPath.CString() : NULL,
+        ppath.CString(),
         &outPath);
         &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
@@ -160,8 +170,10 @@ 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",
-                                NULL,
+                                upath.CString(),
                                 &outPath);
                                 &outPath);
 
 
     String fullpath;
     String fullpath;
@@ -196,8 +208,11 @@ 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(),
-        defaultPath.Length() ? defaultPath.CString() : NULL,
+        upath.CString(),
         &outPath);
         &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)
@@ -218,8 +233,11 @@ 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(),
-        defaultPath.Length() ? defaultPath.CString() : NULL,
+        upath.CString(),
         &outPath);
         &outPath);
 
 
     if (outPath && result == NFD_OKAY)
     if (outPath && result == NFD_OKAY)