Browse Source

Android deployment from Windows

JoshEngebretson 10 years ago
parent
commit
7cd717f009

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

@@ -15,19 +15,28 @@ class AndroidSettingsWidget extends Atomic.UIWidget {
         this.productNameEdit = <Atomic.UIEditField>this.getWidget("product_name");
         this.productNameEdit = <Atomic.UIEditField>this.getWidget("product_name");
         this.companyNameEdit = <Atomic.UIEditField>this.getWidget("company_name");
         this.companyNameEdit = <Atomic.UIEditField>this.getWidget("company_name");
 
 
-        this.jdkRootText = <Atomic.UITextField>this.getWidget("jdk_root_text");
+
         this.jdkRootChooseButton = <Atomic.UIButton>this.getWidget("choose_jdk_root");
         this.jdkRootChooseButton = <Atomic.UIButton>this.getWidget("choose_jdk_root");
         this.jdkRootEdit = <Atomic.UIEditField>this.getWidget("jdk_root");
         this.jdkRootEdit = <Atomic.UIEditField>this.getWidget("jdk_root");
 
 
-        this.antPathEdit = <Atomic.UIEditField>this.getWidget("ant_path");
+        var jdkRootText = <Atomic.UITextField>this.getWidget("jdk_root_text");
+        var antPathText = <Atomic.UITextField>this.getWidget("ant_path_text");
+
+        if (Atomic.platform == "Windows") {
 
 
-        if (Atomic.platform == "MacOSX") {
+            jdkRootText.text = "JDK Root: (Ex. C:\\Program Files\\Java\\jdk1.8.0_31)";
+            antPathText.text = "Ant Path: (The folder that contains ant.bat)";
 
 
-            this.jdkRootText.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
+        } else {
+
+            jdkRootText.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
             this.jdkRootChooseButton.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
             this.jdkRootChooseButton.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
             this.jdkRootEdit.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
             this.jdkRootEdit.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
+
         }
         }
 
 
+        this.antPathEdit = <Atomic.UIEditField>this.getWidget("ant_path");
+
         this.refreshWidgets();
         this.refreshWidgets();
 
 
         this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
         this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
@@ -57,6 +66,44 @@ class AndroidSettingsWidget extends Atomic.UIWidget {
 
 
                 return true;
                 return true;
 
 
+            } else if (ev.target.id == "choose_ant_path") {
+
+                var fileUtils = new Editor.FileUtils();
+                var path = fileUtils.getAntPath("");
+
+                if (path.length) {
+
+                    var toolPrefs = ToolCore.toolEnvironment.toolPrefs;
+                    if (toolPrefs.antPath != path) {
+                        toolPrefs.antPath = path;
+                        toolPrefs.save();
+                    }
+
+                    this.refreshWidgets();
+
+                }
+
+                return true;
+
+            }  else if (ev.target.id == "choose_jdk_root") {
+
+                var fileUtils = new Editor.FileUtils();
+                var path = fileUtils.getJDKRootPath("");
+
+                if (path.length) {
+
+                    var toolPrefs = ToolCore.toolEnvironment.toolPrefs;
+                    if (toolPrefs.jDKRootPath != path) {
+                        toolPrefs.jDKRootPath = path;
+                        toolPrefs.save();
+                    }
+
+                    this.refreshWidgets();
+
+                }
+
+                return true;
+
             } else if (ev.target.id == "refresh_sdk_targets") {
             } else if (ev.target.id == "refresh_sdk_targets") {
 
 
                 this.refreshAndroidTargets();
                 this.refreshAndroidTargets();
@@ -134,7 +181,6 @@ class AndroidSettingsWidget extends Atomic.UIWidget {
     sdkTargetSource: Atomic.UISelectItemSource = new Atomic.UISelectItemSource();
     sdkTargetSource: Atomic.UISelectItemSource = new Atomic.UISelectItemSource();
     sdkTargetSelect: Atomic.UISelectDropdown;
     sdkTargetSelect: Atomic.UISelectDropdown;
 
 
-    jdkRootText: Atomic.UITextField;
     jdkRootChooseButton: Atomic.UIButton;
     jdkRootChooseButton: Atomic.UIButton;
     jdkRootEdit: Atomic.UIEditField;
     jdkRootEdit: Atomic.UIEditField;
 
 

+ 53 - 0
Source/AtomicEditor/Utils/FileUtils.cpp

@@ -130,6 +130,59 @@ String FileUtils::GetAndroidSDKPath(const String& defaultPath)
 
 
 }
 }
 
 
+String FileUtils::GetAntPath(const String& defaultPath)
+{
+    String antPath;
+
+    nfdchar_t *outPath = NULL;
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    String msg = "Please select the folder which contains ant.bat";
+#else
+    String msg = "Please select the folder which contains the ant executable";
+#endif
+
+    nfdresult_t result = NFD_ChooseDirectory(msg.CString(),
+        defaultPath.Length() ? defaultPath.CString() : NULL,
+        &outPath);
+
+    if (outPath && result == NFD_OKAY)
+    {
+        antPath = outPath;
+    }
+
+    if (outPath)
+        free(outPath);
+
+    GetSubsystem<Graphics>()->RaiseWindow();
+
+    return GetInternalPath(antPath);
+}
+
+String FileUtils::GetJDKRootPath(const String& defaultPath)
+{
+    String jdkPath;
+
+    nfdchar_t *outPath = NULL;
+
+    nfdresult_t result = NFD_ChooseDirectory("Please choose the root folder of your JDK",
+        defaultPath.Length() ? defaultPath.CString() : NULL,
+        &outPath);
+
+    if (outPath && result == NFD_OKAY)
+    {
+        jdkPath = outPath;
+    }
+
+    if (outPath)
+        free(outPath);
+
+    GetSubsystem<Graphics>()->RaiseWindow();
+
+    return GetInternalPath(jdkPath);
+
+}
+
 String FileUtils::GetMobileProvisionPath()
 String FileUtils::GetMobileProvisionPath()
 {
 {
     nfdchar_t *outPath = NULL;
     nfdchar_t *outPath = NULL;

+ 2 - 0
Source/AtomicEditor/Utils/FileUtils.h

@@ -23,6 +23,8 @@ public:
 
 
     String GetMobileProvisionPath();
     String GetMobileProvisionPath();
     String GetAndroidSDKPath(const String& defaultPath);
     String GetAndroidSDKPath(const String& defaultPath);
+    String GetAntPath(const String& defaultPath);
+    String GetJDKRootPath(const String& defaultPath);
     String OpenProjectFileDialog();
     String OpenProjectFileDialog();
     String NewProjectFileDialog();
     String NewProjectFileDialog();
     String GetBuildPath(const String& defaultPath);
     String GetBuildPath(const String& defaultPath);

+ 5 - 3
Source/ToolCore/ToolEnvironment.cpp

@@ -36,14 +36,14 @@ bool ToolEnvironment::InitFromPackage()
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
 	editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor.exe";
 	editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor.exe";
     String resourcesDir = fileSystem->GetProgramDir() + "Resources/";
     String resourcesDir = fileSystem->GetProgramDir() + "Resources/";
-    //TODO: move this to deployment stuff
-    playerBinary_ = resourcesDir + "ToolData/Deployment/Windows/x86/AtomicPlayer.exe";
 #else
 #else
     editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor";
     editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor";
     String resourcesDir = GetPath(RemoveTrailingSlash(fileSystem->GetProgramDir())) + "Resources/";
     String resourcesDir = GetPath(RemoveTrailingSlash(fileSystem->GetProgramDir())) + "Resources/";
+#endif
+
     //TODO: move this to deployment stuff
     //TODO: move this to deployment stuff
     playerAppFolder_ = resourcesDir + "ToolData/Deployment/MacOS/AtomicPlayer.app/";
     playerAppFolder_ = resourcesDir + "ToolData/Deployment/MacOS/AtomicPlayer.app/";
-#endif
+    playerBinary_ = resourcesDir + "ToolData/Deployment/Windows/x86/AtomicPlayer.exe";
 
 
     resourceCoreDataDir_ = resourcesDir + "CoreData";
     resourceCoreDataDir_ = resourcesDir + "CoreData";
     resourcePlayerDataDir_ = resourcesDir + "PlayerData";
     resourcePlayerDataDir_ = resourcesDir + "PlayerData";
@@ -149,6 +149,8 @@ void ToolEnvironment::SetRootBuildDir(const String& buildDir, bool setBinaryPath
         editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/Release/AtomicEditor.exe";
         editorBinary_ = rootBuildDir_ + "Source/AtomicEditor/Release/AtomicEditor.exe";
 #endif
 #endif
 
 
+        playerAppFolder_ = rootSourceDir_ + "Data/AtomicEditor/Deployment/MacOS/AtomicPlayer.app";
+
 #elif ATOMIC_PLATFORM_OSX
 #elif ATOMIC_PLATFORM_OSX
 
 
 #ifdef ATOMIC_XCODE
 #ifdef ATOMIC_XCODE