Browse Source

Editor shutdown improvements

Josh Engebretson 10 years ago
parent
commit
cce9f164a8

+ 7 - 1
Script/AtomicEditor/editor/Editor.ts

@@ -32,6 +32,7 @@ class Editor extends Atomic.ScriptObject {
 
 
         this.subscribeToEvent(EditorEvents.LoadProject, (data) => this.handleEditorLoadProject(data));
         this.subscribeToEvent(EditorEvents.LoadProject, (data) => this.handleEditorLoadProject(data));
         this.subscribeToEvent(EditorEvents.Quit, (data) => this.handleEditorEventQuit(data));
         this.subscribeToEvent(EditorEvents.Quit, (data) => this.handleEditorEventQuit(data));
+        this.subscribeToEvent("ExitRequested", (data) => this.handleExitRequested(data));
 
 
         this.parseArguments();
         this.parseArguments();
 
 
@@ -76,10 +77,15 @@ class Editor extends Atomic.ScriptObject {
     }
     }
 
 
     // event handling
     // event handling
+    handleExitRequested(data) {
+
+      EditorUI.shutdown();
+
+    }
 
 
     handleEditorEventQuit(data) {
     handleEditorEventQuit(data) {
 
 
-      Atomic.getEngine().exit();
+      this.sendEvent("ExitRequested");
 
 
     }
     }
 
 

+ 9 - 0
Script/AtomicEditor/ui/EditorUI.ts

@@ -24,6 +24,15 @@ export function initialize() {
   editorUI = new EditorUI();
   editorUI = new EditorUI();
 }
 }
 
 
+export function shutdown() {
+
+  editorUI.mainframe.shutdown();
+  var view = editorUI.view;
+  view.deleteAllChildren();
+  view.parent.removeChild(view);
+
+}
+
 export function showModalError(windowText:string, message:string) {
 export function showModalError(windowText:string, message:string) {
   editorUI.showModalError(windowText, message);
   editorUI.showModalError(windowText, message);
 }
 }

+ 14 - 7
Script/AtomicEditor/ui/MainFrame.ts

@@ -41,7 +41,7 @@ class MainFrame extends ScriptWidget {
         this.subscribeToEvent(UIEvents.ResourceEditorChanged, (data) => this.handleResourceEditorChanged(data));
         this.subscribeToEvent(UIEvents.ResourceEditorChanged, (data) => this.handleResourceEditorChanged(data));
 
 
         this.subscribeToEvent("ProjectLoaded", (data) => {
         this.subscribeToEvent("ProjectLoaded", (data) => {
-          this.showWelcomeFrame(false);
+            this.showWelcomeFrame(false);
         });
         });
 
 
         this.showWelcomeFrame(true);
         this.showWelcomeFrame(true);
@@ -64,14 +64,14 @@ class MainFrame extends ScriptWidget {
     showWelcomeFrame(show: boolean) {
     showWelcomeFrame(show: boolean) {
 
 
         if (show) {
         if (show) {
-          this.showInspectorFrame(false);
-          this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
-          this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
+            this.showInspectorFrame(false);
+            this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
+            this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
         }
         }
         else {
         else {
-          this.showInspectorFrame(true);
-          this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
-          this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
+            this.showInspectorFrame(true);
+            this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
+            this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
         }
         }
 
 
     }
     }
@@ -111,6 +111,13 @@ class MainFrame extends ScriptWidget {
 
 
     }
     }
 
 
+    shutdown() {
+
+        this.resourceframe.shutdown();
+        this.deleteAllChildren();
+
+    }
+
     handleResourceEditorChanged(data): void {
     handleResourceEditorChanged(data): void {
 
 
         var editor = <Editor.ResourceEditor> data.editor;
         var editor = <Editor.ResourceEditor> data.editor;

+ 11 - 0
Script/AtomicEditor/ui/ResourceFrame.ts

@@ -188,6 +188,17 @@ class ResourceFrame extends ScriptWidget {
 
 
     }
     }
 
 
+    shutdown() {
+
+        // on exit close all open editors
+        for (var path in this.editors) {
+
+            this.sendEvent(EditorEvents.CloseResource, { editor: this.editors[path], navigateToAvailableResource: false });
+
+        }
+
+    }
+
     constructor(parent: Atomic.UIWidget) {
     constructor(parent: Atomic.UIWidget) {
 
 
         super();
         super();