Josh Engebretson 10 years ago
parent
commit
ac6b8f30eb

+ 49 - 10
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/AtomicWork.d.ts

@@ -2,20 +2,59 @@
 /// <reference path="/Users/josh/Dev/thunderbeast/AtomicGameEngine/Bin/ToolCore.d.ts" />
 /// <reference path="/Users/josh/Dev/thunderbeast/AtomicGameEngine/Bin/ToolCore.d.ts" />
 /// <reference path="/Users/josh/Dev/thunderbeast/AtomicGameEngine/Bin/Editor.d.ts" />
 /// <reference path="/Users/josh/Dev/thunderbeast/AtomicGameEngine/Bin/Editor.d.ts" />
 
 
-declare module Atomic
-{
-	export function getArguments() : Array<string>;
+declare module Atomic {
 
 
-	export function getInput() : Input;
-	export function getGraphics() : Graphics;
-	export function getFileSystem(): FileSystem;
+    /*
+        export enum UIWidgetEventType {
 
 
+            EVENT_TYPE_CLICK,
+            EVENT_TYPE_LONG_CLICK,
+        EVENT_TYPE_POINTER_DOWN,
+        EVENT_TYPE_POINTER_UP,
+        EVENT_TYPE_POINTER_MOVE,
+        EVENT_TYPE_RIGHT_POINTER_DOWN,
+        EVENT_TYPE_RIGHT_POINTER_UP,
+        EVENT_TYPE_WHEEL,
+        EVENT_TYPE_CHANGED,
+        EVENT_TYPE_KEY_DOWN,
+        EVENT_TYPE_KEY_UP,
+        EVENT_TYPE_SHORTCUT,
+        EVENT_TYPE_CONTEXT_MENU,
+        EVENT_TYPE_FILE_DROP,
+        EVENT_TYPE_TAB_CHANGED,
+        EVENT_TYPE_CUSTOM
+        }
+    */
+    export interface UIWidgetEvent {
 
 
+        handler: UIWidget;
+        target: UIWidget;
+        type: number; /*UIWidgetEventType*/
+        x: number;
+        y: number;
+        deltax: number;
+        deltay: number;
+        count: number;
+        key: number;
+        specialkey: number;
+        modifierkeys: number;
+        refid: string;
+        touch: boolean;
+    }
+
+    export function getArguments(): Array<string>;
+    export function getEngine(): Engine;
+    export function getInput(): Input;
+    export function getGraphics(): Graphics;
+    export function getFileSystem(): FileSystem;
+
+    export function getParentPath(path: string): string;
+    export function addTrailingSlash(path: string): string;
+		export function getExtension(path: string): string;
 
 
 }
 }
 
 
-declare module ToolCore
-{
-	export function getToolEnvironment() : ToolEnvironment;
-	export function getToolSystem() : ToolSystem;
+declare module ToolCore {
+    export function getToolEnvironment(): ToolEnvironment;
+    export function getToolSystem(): ToolSystem;
 }
 }

+ 1 - 2
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/tsconfig.json

@@ -22,7 +22,6 @@
         "./ui/ScriptWidget.ts",
         "./ui/ScriptWidget.ts",
         "./ui/UIEvents.ts",
         "./ui/UIEvents.ts",
         "./ui/modal/MessageModal.ts",
         "./ui/modal/MessageModal.ts",
-        "./ui/modal/ModalOps.ts",
-        "./ui/ui.ts"
+        "./ui/modal/ModalOps.ts"
     ]
     ]
 }
 }

+ 6 - 8
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/MainFrame.ts

@@ -43,13 +43,11 @@ class MainFrame extends ScriptWidget {
 
 
         if (show) {
         if (show) {
 
 
-            print("Showing Inspector");
             this.inspectorlayout.visibility = UI.VISIBILITY_VISIBLE;
             this.inspectorlayout.visibility = UI.VISIBILITY_VISIBLE;
             this.inspectorframe.visibility = UI.VISIBILITY_VISIBLE;
             this.inspectorframe.visibility = UI.VISIBILITY_VISIBLE;
 
 
         } else {
         } else {
 
 
-            print("Hiding Inspector");
             this.inspectorframe.visibility = UI.VISIBILITY_GONE;
             this.inspectorframe.visibility = UI.VISIBILITY_GONE;
             this.inspectorlayout.visibility = UI.VISIBILITY_GONE;
             this.inspectorlayout.visibility = UI.VISIBILITY_GONE;
 
 
@@ -103,17 +101,17 @@ class MainFrame extends ScriptWidget {
 
 
     handleResourceEditorChanged(data) {
     handleResourceEditorChanged(data) {
 
 
-      var editor = <Editor.ResourceEditor> data.editor;
+        var editor = <Editor.ResourceEditor> data.editor;
 
 
-      if (editor) {
+        if (editor) {
 
 
-        this.showInspectorFrame(editor.requiresInspector());
+            this.showInspectorFrame(editor.requiresInspector());
 
 
-      } else {
+        } else {
 
 
-        this.showInspectorFrame(false);
+            this.showInspectorFrame(false);
 
 
-      }
+        }
 
 
 
 
     }
     }

+ 18 - 22
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/ResourceFrame.ts

@@ -5,8 +5,8 @@ var UI = Atomic.UI;
 
 
 // the root content of editor widgets (rootContentWidget property) are extended with an editor field
 // the root content of editor widgets (rootContentWidget property) are extended with an editor field
 // so we can access the editor they belong to from the widget itself
 // so we can access the editor they belong to from the widget itself
-interface EditorRootContentWidget extends Atomic.UIWidget{
-  editor: Editor.ResourceEditor;
+interface EditorRootContentWidget extends Atomic.UIWidget {
+    editor: Editor.ResourceEditor;
 }
 }
 
 
 class ResourceFrame extends ScriptWidget {
 class ResourceFrame extends ScriptWidget {
@@ -45,19 +45,19 @@ class ResourceFrame extends ScriptWidget {
 
 
         if (ext == ".js") {
         if (ext == ".js") {
 
 
-           editor = new Editor.JSResourceEditor(path, this.tabcontainer);
+            editor = new Editor.JSResourceEditor(path, this.tabcontainer);
 
 
         } else if (ext == ".scene") {
         } else if (ext == ".scene") {
 
 
-           editor = new Editor.SceneEditor3D(path, this.tabcontainer);
+            editor = new Editor.SceneEditor3D(path, this.tabcontainer);
 
 
         }
         }
 
 
         if (editor) {
         if (editor) {
 
 
-            // add __editor which lets us lookup the editor via the rootContentWidget
-            // could this be formalized with an interface?
+            // cast and add editor lookup on widget itself
             (<EditorRootContentWidget> editor.rootContentWidget).editor = editor;
             (<EditorRootContentWidget> editor.rootContentWidget).editor = editor;
+
             this.editors[path] = editor;
             this.editors[path] = editor;
             this.tabcontainer.currentPage = this.tabcontainer.numPages - 1;
             this.tabcontainer.currentPage = this.tabcontainer.numPages - 1;
             editor.setFocus();
             editor.setFocus();
@@ -133,34 +133,30 @@ class ResourceFrame extends ScriptWidget {
 
 
     handleResourceEditorChanged(data) {
     handleResourceEditorChanged(data) {
 
 
-      var editor = <Editor.ResourceEditor> data.editor;
-      this.currentResourceEditor = editor;
+        var editor = <Editor.ResourceEditor> data.editor;
+        this.currentResourceEditor = editor;
 
 
     }
     }
 
 
-    handleWidgetEvent(data) {
+    handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
 
 
-      // ok, first thing is to fix up this widget <-> editor mess
+        if (ev.type == Atomic.UI.EVENT_TYPE_TAB_CHANGED && ev.target == this.tabcontainer) {
+            var w = <EditorRootContentWidget> this.tabcontainer.currentPageWidget;
 
 
-      if (data.type == Atomic.UI.EVENT_TYPE_TAB_CHANGED && data.target == this.tabcontainer)
-      {
-        var w = <EditorRootContentWidget> this.tabcontainer.currentPageWidget;
+            if (w && w.editor) {
 
 
-        if (w && w.editor) {
+                if (this.currentResourceEditor != w.editor) {
 
 
-          if (this.currentResourceEditor != w.editor) {
+                    this.sendEvent(UIEvents.ResourceEditorChanged, { editor: w.editor });
 
 
-            this.sendEvent(UIEvents.ResourceEditorChanged, { editor: w.editor});
+                }
 
 
-          }
+            }
 
 
         }
         }
 
 
-
-      }
-
-      // bubble
-      return false;
+        // bubble
+        return false;
 
 
     }
     }
 
 

+ 3 - 4
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/ScriptWidget.ts

@@ -20,12 +20,11 @@ class ScriptWidget extends Atomic.UIWidget {
 
 
     }
     }
 
 
+    handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
 
 
-    handleWidgetEvent(data): boolean {
+        if (ev.type == Atomic.UI.EVENT_TYPE_CLICK) {
 
 
-        if (data.type == Atomic.UI.EVENT_TYPE_CLICK) {
-
-            return this.onEventClick(data.target, data.refid);
+            return this.onEventClick(ev.target, ev.refid);
 
 
         }
         }