Kaynağa Gözat

AtomicNET iOS project creation

Josh Engebretson 9 yıl önce
ebeveyn
işleme
c4ea41d755

+ 24 - 0
Data/AtomicEditor/AtomicNET/ProjectTemplate/Platforms/iOS/AppUIDelegate.cs

@@ -0,0 +1,24 @@
+using Foundation;
+using UIKit;
+using System.Threading.Tasks;
+
+using AtomicEngine;
+
+namespace AtomicPlayer
+{
+	[Register("AppUIDelegate")]
+	public partial class AppUIDelegate : UIApplicationDelegate
+	{
+		public override bool FinishedLaunching(UIApplication app, NSDictionary options)
+		{
+			LaunchGame();
+			return true;
+		}
+
+		async void LaunchGame()
+		{
+			await Task.Yield();
+			Application.Run<AtomicMain>(new string[0]);
+		}
+	}
+}

+ 6 - 0
Data/AtomicEditor/AtomicNET/ProjectTemplate/Platforms/iOS/Entitlements.plist

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+	<dict>
+	</dict>
+</plist>

+ 38 - 0
Data/AtomicEditor/AtomicNET/ProjectTemplate/Platforms/iOS/Info.plist

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleIdentifier</key>
+	<string>$$APPLICATION_ID$$</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleVersion</key>
+	<string>1.0</string>
+	<key>UIDeviceFamily</key>
+	<array>
+		<integer>1</integer>
+		<integer>2</integer>
+	</array>
+	<key>UISupportedInterfaceOrientations</key>
+	<array>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+	<key>UISupportedInterfaceOrientations~ipad</key>
+	<array>
+		<string>UIInterfaceOrientationLandscape</string>
+	</array>
+	<key>MinimumOSVersion</key>
+	<string>9.3</string>
+	<key>CFBundleIconFiles</key>
+	<array>
+		<string>Data/Icon</string>
+	</array>
+	<key>UIStatusBarHidden</key>
+	<true/>
+	<key>CFBundleName</key>
+	<string>$$APPLICATION_NAME$$</string>
+	<key>UIRequiresFullScreen</key>
+	<true/>
+</dict>
+</plist>

+ 13 - 0
Data/AtomicEditor/AtomicNET/ProjectTemplate/Platforms/iOS/Main.cs

@@ -0,0 +1,13 @@
+using UIKit;
+
+namespace AtomicPlayer
+{
+	public class AtomicApp
+	{
+		// This is the main entry point of the application.
+		static void Main(string[] args)
+		{
+			UIApplication.Main(args, null, "AppUIDelegate");
+		}
+	}
+}

+ 36 - 0
Data/AtomicEditor/AtomicNET/ProjectTemplate/Platforms/iOS/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("$$APPLICATION_NAME$$")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("$$APPLICATION_NAME$$")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3a72e714-15ce-4707-ba90-e389fb7c9b2c")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

BIN
Resources/EditorData/AtomicEditor/editor/images/Desktop128.png


+ 75 - 5
Script/AtomicEditor/resources/ProjectTemplates.ts

@@ -117,6 +117,7 @@ export function GetNewFileTemplateDefinitions(fileTemplateType: string) : Editor
 
 export interface AtomicNETProjectInfo {
     name: string;
+    appID: string;
     platforms: string[];
     projectFolder: string;
 }
@@ -141,6 +142,7 @@ function processAtomicNETTemplate(filename:string, templateFilename:string) : bo
     let text = file.readText();
 
     text = text.split("$$APPLICATION_NAME$$").join(atomicNETProjectInfo.name);
+    text = text.split("$$APPLICATION_ID$$").join(atomicNETProjectInfo.appID);
 
     let fileOut = new Atomic.File(filename, Atomic.FILE_WRITE);
 
@@ -152,7 +154,7 @@ function processAtomicNETTemplate(filename:string, templateFilename:string) : bo
     fileOut.writeString(text);
 
     file.close();
-    
+
     return true;
 }
 
@@ -161,7 +163,7 @@ function processAtomicNETTemplate(filename:string, templateFilename:string) : bo
  * @return {boolean}
  */
 function generateAtomicNETAndroidProject():boolean {
-    
+
     let env = ToolCore.toolEnvironment;
     let utils = new Editor.FileUtils();
     let templateFolder = env.toolDataDir + "AtomicNET/ProjectTemplate/";
@@ -179,7 +181,7 @@ function generateAtomicNETAndroidProject():boolean {
 
             if (!utils.createDirs(folder))
                 return false;
-        }        
+        }
 
     }
 
@@ -210,16 +212,75 @@ function generateAtomicNETAndroidProject():boolean {
         }
 
     }
-                 
+
     return true;
 }
 
+/**
+ * Generates the iOS portion of an AtomicNET project
+ * @return {boolean}
+ */
+function generateAtomicNETIOSProject():boolean {
+
+    let env = ToolCore.toolEnvironment;
+    let utils = new Editor.FileUtils();
+    let templateFolder = env.toolDataDir + "AtomicNET/ProjectTemplate/";
+    let iosFolder = Atomic.addTrailingSlash(atomicNETProjectInfo.projectFolder) + "Project/AtomicNET/Platforms/iOS/";
+
+    let fileSystem = Atomic.fileSystem;
+
+    // Create necessary folders
+    let folders = ["Properties", "Resources"];
+    for (var i = 0; i < folders.length; i++) {
+
+        let folder = iosFolder + folders[i];
+
+        if (!fileSystem.dirExists(folder)) {
+
+            if (!utils.createDirs(folder))
+                return false;
+        }
+
+    }
+
+    let textFiles = [".cs", ".plist"];
+
+    let files = ["Main.cs", "AppUIDelegate.cs", "Entitlements.plist", "Info.plist",
+                 "Properties/AssemblyInfo.cs"];
+
+    for (var i = 0; i < files.length; i++) {
+
+        let templateName = templateFolder + "Platforms/iOS/" + files[i];
+        let filename = iosFolder + files[i];
+
+        if (textFiles.indexOf(Atomic.getExtension(templateName)) == -1) {
+
+            if (!fileSystem.copy(templateName, filename)) {
+
+                console.log("Failed to copy: ", templateName, " to ",  filename);
+                return false;
+            }
+
+        } else {
+
+            if (!processAtomicNETTemplate(filename, templateName)) {
+                return false;
+            }
+
+        }
+
+    }
+
+    return true;
+}
+
+
 /**
  * Generates the Desktop portion of an AtomicNET project
  * @return {boolean}
  */
 function generateAtomicNETDesktopProject():boolean {
-    
+
     let env = ToolCore.toolEnvironment;
     let utils = new Editor.FileUtils();
     let templateFolder = env.toolDataDir + "AtomicNET/ProjectTemplate/";
@@ -275,5 +336,14 @@ export function generateAtomicNETProject(projectInfo:AtomicNETProjectInfo):boole
 
     }
 
+    if (projectInfo.platforms.indexOf("ios") != -1) {
+
+        if (!generateAtomicNETIOSProject()) {
+            return false;
+        }
+
+    }
+
+
     return true;
 }

+ 10 - 9
Script/AtomicEditor/ui/modal/CreateProject.ts

@@ -88,8 +88,8 @@ class CreateProject extends ModalWindow {
         var size = 92;
 
         var button = new Atomic.UIButton();
-        button.id = id;     
-        button.toggleMode = true;   
+        button.id = id;
+        button.toggleMode = true;
 
         button.onClick = () => {
 
@@ -117,8 +117,8 @@ class CreateProject extends ModalWindow {
             greenplus.visibility = Atomic.UI_WIDGET_VISIBILITY_INVISIBLE;
             button.addChild(greenplus);
             button["greenPlus"] = greenplus;
-        }   
-        
+        }
+
         platformcontainer.addChild(button);
 
         return button;
@@ -224,7 +224,7 @@ class CreateProject extends ModalWindow {
                 if (this.androidButton.value == 1) {
                     platforms.push("android");
                 }
-                
+
                 if (this.iosButton.value == 1) {
                     platforms.push("ios");
                 }
@@ -245,6 +245,7 @@ class CreateProject extends ModalWindow {
                 if (atomicNET) {
                     if (!ProjectTemplates.generateAtomicNETProject({
                         name: name,
+                        appID : this.appIDField.text,
                         platforms : platforms,
                         projectFolder : folder
                     })) {
@@ -288,8 +289,8 @@ class CreateProject extends ModalWindow {
             this.html5Button.enable();
             this.html5Button["greenPlus"].visibility = this.html5Button.value == 1 ? Atomic.UI_WIDGET_VISIBILITY_VISIBLE : Atomic.UI_WIDGET_VISIBILITY_INVISIBLE;
 
-        }                
-        
+        }
+
     }
 
     handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
@@ -326,7 +327,7 @@ class CreateProject extends ModalWindow {
             }
 
             if (ev.target.id == "desktop") {
-                
+
                 // desktop is always selected
                 this.desktopButton.value = 1;
 
@@ -352,7 +353,7 @@ class CreateProject extends ModalWindow {
         this.projectLanguageField.source = this.projectLanguageFieldSource;
         this.projectLanguageField.value = 0;
     }
-    
+
     projectPathField: Atomic.UIEditField;
     projectNameField: Atomic.UIEditField;
     appIDField: Atomic.UIEditField;