Kaynağa Gözat

Generate TypeScript project files for external editors

Kobus vd walt 9 yıl önce
ebeveyn
işleme
d292d47058

+ 2 - 0
AUTHORS.md

@@ -35,6 +35,8 @@
 
 - Tarik Belabbas (https://github.com/Tarik-B)
 
+- Kobus vd Walt (https://github.com/Kobusvdwalt)
+
 ### Contribution Copyright and Licensing
 
 Atomic Game Engine contribution copyrights are held by their authors.  Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.  Please see `CONTRIBUTING.md` for more details.

+ 40 - 0
Script/AtomicEditor/hostExtensions/languageExtensions/TypscriptLanguageExtension.ts

@@ -165,6 +165,7 @@ export default class TypescriptLanguageExtension implements Editor.HostExtension
             this.compileOnSaveMenuItem = new Atomic.UIMenuItem(`Compile on Save: ${isCompileOnSave ? "On" : "Off"}`, `${this.name}.compileonsave`);
             menu.addItem(this.compileOnSaveMenuItem);
             menu.addItem(new Atomic.UIMenuItem("Compile Project", `${this.name}.compileproject`));
+            menu.addItem(new Atomic.UIMenuItem("Generate External Editor Project", `${this.name}.generateexternalproject`));
             this.menuCreated = true;
         }
     }
@@ -316,6 +317,9 @@ export default class TypescriptLanguageExtension implements Editor.HostExtension
                 case "compileproject":
                     this.doFullCompile();
                     return true;
+                case "generateexternalproject":
+                    this.generateExternalProject();
+                    return true;
             }
         }
     }
@@ -337,6 +341,42 @@ export default class TypescriptLanguageExtension implements Editor.HostExtension
         WebView.WebBrowserHost.setGlobalStringProperty("TypeScriptLanguageExtension", "tsConfig", JSON.stringify(tsConfig));
     }
 
+    generateExternalProject ()
+    {
+      var projectPath : string = ToolCore.toolSystem.project.projectPath;
+
+      // Create TypeScript folder in project root
+      var tsPath : string = projectPath + "TypeScript/";
+      Atomic.getFileSystem().createDir(tsPath);
+
+      // Copy the Atomic.d.ts definition file to the TypeScript folder
+      var toolDataDir : string = ToolCore.toolEnvironment.toolDataDir;
+      Atomic.getFileSystem().copy(toolDataDir + "/TypeScriptSupport/Atomic.d.ts", tsPath + "Atomic.d.ts");
+
+      // Generate a tsconfig.json file
+      var config = new Atomic.File(projectPath + "tsconfig.json", Atomic.FILE_WRITE);
+      config.writeString
+(`
+{
+    "compilerOptions": {
+        "noEmitOnError": true,
+        "noImplicitAny": false,
+        "target": "ES5",
+        "module": "commonjs",
+        "outDir": "./Resources",
+        "rootDir": "./Resources",
+        "declaration": false,
+        "inlineSourceMap": false,
+        "removeComments": false,
+        "allowJs": true,
+        "noLib": true,
+        "allowNonTsExtensions": true,
+    }
+}
+`);
+
+      config.close();
+    }
     /**
      * Perform a full compile of the TypeScript
      */

+ 1 - 8
Script/tsconfig.json

@@ -109,15 +109,8 @@
         "./AtomicEditor/ui/ScriptWidget.ts",
         "./AtomicEditor/ui/Shortcuts.ts",
         "./AtomicEditor/ui/UIEvents.ts",
-        "./TypeScript/Atomic.d.ts",
-        "./TypeScript/AtomicApp.d.ts",
-        "./TypeScript/AtomicNETScript.d.ts",
-        "./TypeScript/AtomicPlayer.d.ts",
         "./TypeScript/AtomicWork.d.ts",
         "./TypeScript/duktape.d.ts",
-        "./TypeScript/Editor.d.ts",
-        "./TypeScript/EditorWork.d.ts",
-        "./TypeScript/ToolCore.d.ts",
-        "./TypeScript/WebView.d.ts"
+        "./TypeScript/EditorWork.d.ts"
     ]
 }