فهرست منبع

Welcome frame more or less operational

Josh Engebretson 10 سال پیش
والد
کامیت
92dc2ea951

+ 23 - 1
Script/AtomicEditor/ui/WelcomeFrame.ts

@@ -1,5 +1,6 @@
 
 import EditorEvents = require("../editor/EditorEvents");
+import EditorUI = require("./EditorUI");
 import ScriptWidget = require("./ScriptWidget");
 
 class WelcomeFrame extends ScriptWidget {
@@ -16,7 +17,7 @@ class WelcomeFrame extends ScriptWidget {
 
         this.subscribeToEvent("ProjectLoaded", (data) => {
 
-          Editor.getPreferences().registerRecentProject(data.ProjectPath);
+            Editor.getPreferences().registerRecentProject(data.ProjectPath);
 
         })
 
@@ -48,6 +49,27 @@ class WelcomeFrame extends ScriptWidget {
 
             }
 
+            if (id == "open project") {
+
+                var utils = new Editor.FileUtils();
+                var path = utils.openProjectFileDialog();
+                if (path) {
+
+                    this.sendEvent(EditorEvents.LoadProject, { path: path });
+
+                }
+
+                return true;
+            }
+
+            if (id == "new project") {
+
+                var mo = EditorUI.getModelOps();
+                mo.showNewProject();
+                return true;
+
+            }
+
         }
 
     }

+ 1 - 1
Script/TypeScript/Editor.d.ts

@@ -55,7 +55,7 @@ declare module Editor {
       constructor();
 
       createDirs(folder: string): boolean;
-      openProjectFileDialog(): void;
+      openProjectFileDialog(): string;
       newProjectFileDialog(): string;
       revealInFinder(fullpath: string): void;
 

+ 6 - 4
Source/AtomicEditorWork/Utils/FileUtils.cpp

@@ -23,7 +23,7 @@ FileUtils::~FileUtils()
 {
 }
 
-void FileUtils::OpenProjectFileDialog()
+String FileUtils::OpenProjectFileDialog()
 {
     nfdchar_t *outPath = NULL;
 
@@ -31,11 +31,11 @@ void FileUtils::OpenProjectFileDialog()
                                 NULL,
                                 &outPath);
 
+    String fullpath;
+
     if (outPath && result == NFD_OKAY)
     {
-        String fullpath = outPath;
-        //Editor* editor = GetSubsystem<Editor>();
-        //editor->LoadProject(fullpath);
+        fullpath = outPath;
     }
 
     GetSubsystem<Graphics>()->RaiseWindow();
@@ -43,6 +43,8 @@ void FileUtils::OpenProjectFileDialog()
     if (outPath)
         free(outPath);
 
+    return fullpath;
+
 }
 
 bool FileUtils::CreateDirs(const String& folder)

+ 1 - 1
Source/AtomicEditorWork/Utils/FileUtils.h

@@ -21,7 +21,7 @@ public:
 
     bool CreateDirs(const String& folder);
 
-    void OpenProjectFileDialog();
+    String OpenProjectFileDialog();
     String NewProjectFileDialog();
     void RevealInFinder(const String& fullpath);