Browse Source

Merge remote-tracking branch 'upstream/master'

Conflicts:
	Source/AtomicJS/Javascript/JSAPI.cpp
Matt Benic 10 years ago
parent
commit
cd6a54d36f
86 changed files with 579 additions and 778 deletions
  1. 17 7
      AUTHORS.md
  2. 38 0
      CONTRIBUTING.md
  3. 19 0
      CONTRIBUTION_LICENSE.md
  4. 1 2
      Resources/EditorData/AtomicEditor/editor/ui/welcomeframe.tb.txt
  5. 5 7
      Script/AtomicEditor/editor/Editor.ts
  6. 124 0
      Script/AtomicEditor/editor/Preferences.ts
  7. 0 49
      Script/AtomicEditor/tsconfig.json
  8. 14 7
      Script/AtomicEditor/ui/EditorStrings.ts
  9. 1 1
      Script/AtomicEditor/ui/HierarchyFrame.ts
  10. 2 4
      Script/AtomicEditor/ui/ProjectFrame.ts
  11. 5 0
      Script/AtomicEditor/ui/ProjectFrameMenu.ts
  12. 42 29
      Script/AtomicEditor/ui/WelcomeFrame.ts
  13. 1 1
      Script/AtomicEditor/ui/inspector/ModelInspector.ts
  14. 2 1
      Script/Packages/Atomic/IO.json
  15. 1 1
      Script/Packages/Editor/Editor.json
  16. 44 101
      Script/TypeScript/Atomic.d.ts
  17. 0 27
      Script/TypeScript/Editor.d.ts
  18. 5 8
      Script/TypeScript/ToolCore.d.ts
  19. 2 0
      Source/Atomic/Atomic2D/Animation2D.h
  20. 7 0
      Source/Atomic/Atomic2D/TileMapDefs2D.h
  21. 8 0
      Source/Atomic/Atomic2D/TmxFile2D.h
  22. 2 0
      Source/Atomic/Atomic3D/AnimationState.h
  23. 2 0
      Source/Atomic/Audio/SoundStream.h
  24. 17 0
      Source/Atomic/Container/RefCounted.h
  25. 2 0
      Source/Atomic/Core/Attribute.h
  26. 2 0
      Source/Atomic/Core/Context.h
  27. 5 0
      Source/Atomic/Core/Object.h
  28. 2 0
      Source/Atomic/Core/WorkQueue.cpp
  29. 2 0
      Source/Atomic/Core/WorkQueue.h
  30. 2 0
      Source/Atomic/Graphics/Direct3D11/D3D11RenderSurface.h
  31. 2 0
      Source/Atomic/Graphics/Direct3D11/D3D11ShaderProgram.h
  32. 2 0
      Source/Atomic/Graphics/Direct3D11/D3D11ShaderVariation.h
  33. 2 0
      Source/Atomic/Graphics/Direct3D11/D3D11VertexDeclaration.h
  34. 2 0
      Source/Atomic/Graphics/Direct3D9/D3D9RenderSurface.h
  35. 2 0
      Source/Atomic/Graphics/Direct3D9/D3D9ShaderProgram.h
  36. 2 0
      Source/Atomic/Graphics/Direct3D9/D3D9ShaderVariation.h
  37. 2 0
      Source/Atomic/Graphics/Direct3D9/D3D9VertexDeclaration.h
  38. 2 0
      Source/Atomic/Graphics/Material.h
  39. 2 0
      Source/Atomic/Graphics/OpenGL/OGLRenderSurface.h
  40. 2 0
      Source/Atomic/Graphics/OpenGL/OGLShaderProgram.h
  41. 2 0
      Source/Atomic/Graphics/OpenGL/OGLShaderVariation.h
  42. 2 0
      Source/Atomic/Graphics/RenderPath.h
  43. 2 0
      Source/Atomic/Graphics/Technique.h
  44. 3 0
      Source/Atomic/IO/FileSystem.h
  45. 2 0
      Source/Atomic/Network/HttpRequest.h
  46. 7 0
      Source/Atomic/Physics/CollisionShape.h
  47. 2 0
      Source/Atomic/Resource/BackgroundLoader.h
  48. 2 0
      Source/Atomic/Scene/ValueAnimationInfo.h
  49. 10 0
      Source/Atomic/UI/UIButton.cpp
  50. 2 0
      Source/Atomic/UI/UIPreferredSize.h
  51. 0 3
      Source/AtomicEditor/Application/AEEditorApp.cpp
  52. 0 2
      Source/AtomicEditor/Application/AEEditorApp.h
  53. 0 2
      Source/AtomicEditor/Application/AEEditorCommon.h
  54. 0 285
      Source/AtomicEditor/Application/AEPreferences.cpp
  55. 0 68
      Source/AtomicEditor/Application/AEPreferences.h
  56. 0 8
      Source/AtomicEditor/EditorMode/AEEditorMode.cpp
  57. 0 6
      Source/AtomicEditor/EditorMode/AEEditorMode.h
  58. 0 5
      Source/AtomicEditor/Javascript/AEEditorJS.cpp
  59. 33 46
      Source/AtomicJS/Javascript/JSAPI.cpp
  60. 1 2
      Source/AtomicJS/Javascript/JSAPI.h
  61. 5 6
      Source/AtomicJS/Javascript/JSVM.cpp
  62. 14 18
      Source/AtomicJS/Javascript/JSVM.h
  63. 0 4
      Source/AtomicPlayerJS/AtomicPlayerJS.cpp
  64. 14 2
      Source/ToolCore/Assets/Asset.cpp
  65. 12 0
      Source/ToolCore/Assets/Asset.h
  66. 30 8
      Source/ToolCore/Assets/AssetDatabase.cpp
  67. 4 2
      Source/ToolCore/Assets/AssetImporter.h
  68. 1 7
      Source/ToolCore/Assets/AudioImporter.cpp
  69. 2 2
      Source/ToolCore/Assets/AudioImporter.h
  70. 1 7
      Source/ToolCore/Assets/FolderImporter.cpp
  71. 2 2
      Source/ToolCore/Assets/FolderImporter.h
  72. 1 1
      Source/ToolCore/Assets/JavascriptImporter.cpp
  73. 2 2
      Source/ToolCore/Assets/JavascriptImporter.h
  74. 2 2
      Source/ToolCore/Assets/MaterialImporter.cpp
  75. 2 2
      Source/ToolCore/Assets/MaterialImporter.h
  76. 2 8
      Source/ToolCore/Assets/ModelImporter.cpp
  77. 2 2
      Source/ToolCore/Assets/ModelImporter.h
  78. 1 1
      Source/ToolCore/Assets/PrefabImporter.cpp
  79. 2 1
      Source/ToolCore/Assets/PrefabImporter.h
  80. 1 7
      Source/ToolCore/Assets/SceneImporter.cpp
  81. 2 2
      Source/ToolCore/Assets/SceneImporter.h
  82. 4 8
      Source/ToolCore/Assets/TextureImporter.cpp
  83. 2 2
      Source/ToolCore/Assets/TextureImporter.h
  84. 1 5
      Source/ToolCore/JSBind/JSBModuleWriter.cpp
  85. 8 2
      Source/ToolCore/JSBind/JSBPackageWriter.cpp
  86. 0 3
      Source/ToolCoreJS/ToolCoreJS.cpp

+ 17 - 7
Credits.md → AUTHORS.md

@@ -1,16 +1,26 @@
-## Atomic Game Engine
+## Atomic Game Engine
 ------------------
 
-Please see [LICENSE.md](https://github.com/AtomicGameEngine/AtomicGameEngine/blob/master/LICENSE.md) for the **Atomic Game Engine Source Code EULA**
+#### THUNDERBEAST GAMES LLC:
 
-Credits:
+- Josh Engebretson (Technical Director)
+
+### Contributors:
+
+- marynate (https://github.com/marynate)
+
+- rsredsq (https://github.com/rsredsq)
 
-Josh Engebretson (Technical Director, THUNDERBEAST GAMES LLC)
 
-#### Urho3D - Website & Credits
+### Contribution Copyright and Licensing
+
+Atomic Game Engine contribution copyrights are held by their authors.  Each author has a copyright to their contribution, and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.
+
 --------------------------
 
-The Atomic Game Engine started as a fork of the Urho3D project in November 2014
+##### Urho3D - Website & Credits
+
+The Atomic Game Engine began as a fork of the Urho3D project in November 2014
 
 Website:
 
@@ -123,4 +133,4 @@ Jack and mushroom models from the realXtend project. (http://www.realxtend.org)
 Ninja model and terrain, water, smoke, flare and status bar textures from OGRE.
 BlueHighway font from Larabie Fonts.
 Anonymous Pro font by Mark Simonson.
-NinjaSnowWar sounds by Veli-Pekka Tätilä.
+NinjaSnowWar sounds by Veli-Pekka Tätilä.

+ 38 - 0
CONTRIBUTING.md

@@ -0,0 +1,38 @@
+Contributing to the Atomic Game Engine
+=======================
+
+Contribution Copyrights and Licensing
+------------------------
+
+Atomic Game Engine contribution copyrights are held by their authors.  Each author has a copyright to their contribution, and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`
+
+To make a code contribution to the Atomic Game Engine
+--------------------------------------
+
+* Fork the Atomic Game Engine Github repository and make your changes.  Use a well named topic branch for the changes, preferably with uppercase and dashes, use your initials at the beginning of the branch name e.g. `JME-EDITOR-FIXES`.  Fork off the `master` branch.  Avoid forking from repository work branches as they may get rebased.
+
+* Test your changes as thoroughly as possible.
+
+* Ensure your code follows the general code style of the engine and scripts.  There needs to be an explicit style guide, in the meantime try to follow the general style in the code base.  Check that your diff looks as clean and minimal as possible.
+
+* Add yourself to the end of the "Contributors" list in `AUTHORS.md` if you're not already on the list.  `By doing this you confirm that`:
+
+  - **You own the rights to the contribution**, or have the legal right to
+    license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md` on behalf of the copyright owner(s).
+
+  - You, or the copyright owner(s), agree to **irrevocably license the contribution** under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`
+
+  - Please include a link to your GitHub profile to allow your contribution to be identified accurately.
+
+* Create a pull request in Github.  For now, the "base branch" should be
+  "master", i.e. the pull requests are merged directly to the master branch.
+  In the description:
+
+  - Summarize the change and the motivation for the change.
+
+To report bugs or request features
+----------------------------------
+
+Use GitHub issues to report bugs or request features:
+
+* Please include a compilation or execution log to help diagnosis.

+ 19 - 0
CONTRIBUTION_LICENSE.md

@@ -0,0 +1,19 @@
+===============
+Atomic Game Engine Contribution License
+===============
+
+(http://opensource.org/licenses/MIT)
+
+Copyright (c) 2014-2015 by Atomic Game Engine Contributors (see AUTHORS.md)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 1 - 2
Resources/EditorData/AtomicEditor/editor/ui/welcomeframe.tb.txt

@@ -7,9 +7,8 @@ TBLayout: distribution: gravity, size: available, axis: y, id: welcomelayout, po
 					text Open Project
 				TBButton: id: new project
 					text New Project
-			TBLayout: distribution: gravity, axis: y, position: left
+			TBLayout: distribution: gravity, axis: y, position: left, id: recentprojects
 				TBEditField: text: "<color #76D6FF>Recent Projects:</color>", styling: 1, readonly: 1, adapt-to-content: 1, skin: 0
-				TBSelectList: gravity: all, id: recentprojects
 	TBLayout: distribution: gravity, size: available
 		TBLayout: distribution: gravity, axis: y, position: left
 			TBEditField: text: "<color #76D6FF>Welcome:</color>", styling: 1, readonly: 1, adapt-to-content: 1, skin: 0

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

@@ -5,6 +5,7 @@ import AssetImport = require("../assets/AssetImport");
 import PlayMode = require("../ui/playmode/PlayMode");
 import EditorLicense = require("./EditorLicense");
 import EditorEvents = require("./EditorEvents");
+import Preferences = require("./Preferences");
 
 class Editor extends Atomic.ScriptObject {
 
@@ -26,6 +27,8 @@ class Editor extends Atomic.ScriptObject {
 
         this.editorLicense = new EditorLicense();
 
+        Preferences.getInstance().read();
+
         EditorUI.initialize();
 
         this.playMode = new PlayMode();
@@ -41,14 +44,10 @@ class Editor extends Atomic.ScriptObject {
         this.subscribeToEvent("ExitRequested", (data) => this.handleExitRequested(data));
 
         this.subscribeToEvent("ProjectLoaded", (data) => {
-
-            Atomic.editorMode.preferences.registerRecentProject(data.projectPath);
-
+            Preferences.getInstance().registerRecentProject(data.projectPath);
         })
 
         this.parseArguments();
-
-
     }
 
     handleEditorLoadProject(event: EditorEvents.LoadProjectEvent): boolean {
@@ -69,7 +68,6 @@ class Editor extends Atomic.ScriptObject {
     }
 
     handleEditorCloseProject(event) {
-
         var system = ToolCore.getToolSystem();
 
         if (system.project) {
@@ -110,7 +108,7 @@ class Editor extends Atomic.ScriptObject {
 
     // event handling
     handleExitRequested(data) {
-
+        Preferences.getInstance().write();
         EditorUI.shutdown();
 
     }

+ 124 - 0
Script/AtomicEditor/editor/Preferences.ts

@@ -0,0 +1,124 @@
+
+class Preferences {
+
+    private static Ctor = (() => {
+        new Preferences();
+    })();
+
+    private fileSystem: Atomic.FileSystem;
+
+    private static instance: Preferences;
+    private _prefs: PreferencesFormat;
+
+    constructor() {
+        this.fileSystem = Atomic.getFileSystem();
+        Preferences.instance = this;
+    }
+
+    registerRecentProject(path: string): void {
+        var index = this._prefs.recentProjects.indexOf(path);
+        if (index >= 0) {
+            this._prefs.recentProjects.splice(index, 1);
+        }
+        this._prefs.recentProjects.unshift(path);
+        this.updateRecentProjects();
+    }
+
+    unRegisterRecentProject(path: string): void {
+        var index = this._prefs.recentProjects.indexOf(path);
+        if (index >= 0) {
+            this._prefs.recentProjects.splice(index, 1);
+        }
+        this.updateRecentProjects();
+    }
+
+    updateRecentProjects(): void {
+        for (var i in this._prefs.recentProjects) {
+            var path = this._prefs.recentProjects[i];
+            if (!this.fileSystem.exists(path)) {
+                this._prefs.recentProjects.splice(i, 1);
+            }
+        }
+    }
+
+    deleteRecentProjects(): void {
+        this._prefs.recentProjects.length = 0;
+    }
+
+    getPreferencesFullPath(): string {
+        var filePath = this.fileSystem.getAppPreferencesDir("AtomicEditor", "Preferences");
+        filePath += "prefs.json";
+        return filePath;
+    }
+
+    read(): void {
+        var filePath = this.getPreferencesFullPath();
+        var jsonFile = new Atomic.File(filePath, Atomic.FILE_READ);
+        if (!jsonFile.isOpen()) return;
+        var prefs = <PreferencesFormat> JSON.parse(jsonFile.readText());
+        if (prefs) {
+            if(!prefs.recentProjects) prefs.recentProjects = [""];
+            this._prefs = prefs;
+        }
+    }
+
+    write(): void {
+        var filePath = this.getPreferencesFullPath();
+        var jsonFile = new Atomic.File(filePath, Atomic.FILE_WRITE);
+        if (!jsonFile.isOpen()) return;
+        var graphics = Atomic.getGraphics();
+        var pos, width, height;
+        if (graphics && !graphics.getFullscreen()) {
+            pos = graphics.getWindowPosition();
+            width = graphics.getWidth();
+            height = graphics.getHeight();
+        }
+        this._prefs.window = { x: pos[0], y: pos[1], width: width, height: height };
+        jsonFile.writeString(JSON.stringify(this._prefs, null, 2));
+    }
+
+    get recentProjects(): [string] {
+        return this._prefs.recentProjects;
+    }
+
+    get androidSDKPath(): string {
+        return Atomic.addTrailingSlash(this._prefs.androidSDKPath);
+    }
+
+    set androidSDKPath(path: string) {
+        this._prefs.androidSDKPath = path;
+        this.write()
+    }
+
+    get jdkRootPath(): string {
+        return Atomic.addTrailingSlash(this._prefs.jdkRootPath);
+    }
+
+    set jdkRootPath(path: string) {
+        this._prefs.jdkRootPath = path;
+        this.write();
+    }
+
+    get antPath(): string {
+        return Atomic.addTrailingSlash(this._prefs.antPath);
+    }
+
+    set antPath(path: string) {
+        this._prefs.antPath = path;
+        this.write();
+    }
+
+    static getInstance(): Preferences {
+        return Preferences.instance;
+    }
+}
+
+class PreferencesFormat {
+    recentProjects: [string];
+    androidSDKPath: string;
+    jdkRootPath: string;
+    antPath: string;
+    window: { x: number, y: number, width: number, height: number };
+}
+
+export = Preferences;

+ 0 - 49
Script/AtomicEditor/tsconfig.json

@@ -9,54 +9,5 @@
     },
     "filesGlob": [
         "./**/*.ts"
-    ],
-    "files": [
-        "./assets/AssetImport.ts",
-        "./editor/Editor.ts",
-        "./editor/EditorEvents.ts",
-        "./editor/EditorLicense.ts",
-        "./main.ts",
-        "./resources/ResourceOps.ts",
-        "./ui/EditorStrings.ts",
-        "./ui/EditorUI.ts",
-        "./ui/HierarchyFrame.ts",
-        "./ui/HierarchyFrameMenu.ts",
-        "./ui/MainFrame.ts",
-        "./ui/MainFrameMenu.ts",
-        "./ui/MainToolbar.ts",
-        "./ui/ProjectFrame.ts",
-        "./ui/ProjectFrameMenu.ts",
-        "./ui/ResourceFrame.ts",
-        "./ui/ScriptWidget.ts",
-        "./ui/Shortcuts.ts",
-        "./ui/UIEvents.ts",
-        "./ui/WelcomeFrame.ts",
-        "./ui/inspector/ArrayEditWidget.ts",
-        "./ui/inspector/ComponentInspector.ts",
-        "./ui/inspector/CreateComponentButton.ts",
-        "./ui/inspector/DataBinding.ts",
-        "./ui/inspector/InspectorFrame.ts",
-        "./ui/inspector/InspectorUtils.ts",
-        "./ui/inspector/InspectorWidget.ts",
-        "./ui/inspector/MaterialInspector.ts",
-        "./ui/inspector/ModelInspector.ts",
-        "./ui/inspector/NodeInspector.ts",
-        "./ui/inspector/TextureSelector.ts",
-        "./ui/license/ActivationSuccessWindow.ts",
-        "./ui/license/ActivationWindow.ts",
-        "./ui/license/EULAWindow.ts",
-        "./ui/license/ManageLicense.ts",
-        "./ui/menus/MenuItemSources.ts",
-        "./ui/modal/About.ts",
-        "./ui/modal/CreateProject.ts",
-        "./ui/modal/MessageModal.ts",
-        "./ui/modal/ModalOps.ts",
-        "./ui/modal/ModalWindow.ts",
-        "./ui/modal/NewProject.ts",
-        "./ui/modal/ProgressModal.ts",
-        "./ui/modal/ResourceSelection.ts",
-        "./ui/modal/UIResourceOps.ts",
-        "./ui/playmode/PlayMode.ts",
-        "./ui/playmode/PlayerOutput.ts"
     ]
 }

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

@@ -33,15 +33,22 @@ export class EditorString {
 
         var lookup = EditorString.lookup;
 
-        var shortcutKey = "⌘";
+        var lookup = EditorString.lookup;
 
-        lookup[StringID.RevealInFinder] = "Reveal in Finder";
+        var shortcutKey;
+        if (Atomic.platform == "MacOSX") {
+            shortcutKey = "⌘";
+        } else { // Windows and Linux
+            shortcutKey = "CTRL + "
+        }
 
-        // Mac
-        lookup[StringID.ShortcutRedo] = "⇧⌘Z";
-        lookup[StringID.ShortcutFindNext] = "⌘G";
-        lookup[StringID.ShortcutFindPrev] = "⇧⌘G";
-        lookup[StringID.ShortcutBuildSettings] = "⇧⌘B";
+        lookup[StringID.RevealInFinder] = "Reveal in Finder";
+        
+        // Mac, Windows and Linux
+        lookup[StringID.ShortcutRedo] = "⇧" + shortcutKey + "Z";
+        lookup[StringID.ShortcutFindNext] = shortcutKey + "G";
+        lookup[StringID.ShortcutFindPrev] = "⇧" + shortcutKey + "G";
+        lookup[StringID.ShortcutBuildSettings] = "⇧" + shortcutKey + "B";
 
         // General
         lookup[StringID.ShortcutUndo] = shortcutKey + "Z";

+ 1 - 1
Script/AtomicEditor/ui/HierarchyFrame.ts

@@ -236,7 +236,7 @@ class HierarchyFrame extends Atomic.UIWidget {
 
             // create
             if (id == "menu create") {
-
+                if (!ToolCore.toolSystem.project) return;  
                 var src = MenuItemSources.getMenuItemSource("hierarchy create items");
                 var menu = new Atomic.UIMenuWindow(data.target, "create popup");
                 menu.show(src);

+ 2 - 4
Script/AtomicEditor/ui/ProjectFrame.ts

@@ -136,10 +136,10 @@ class ProjectFrame extends ScriptWidget {
 
             if (this.menu.handlePopupMenu(data.target, data.refid))
                 return true;
-
+            
             // create
             if (id == "menu create") {
-
+                if (!ToolCore.toolSystem.project) return;  
                 var src = MenuItemSources.getMenuItemSource("project create items");
                 var menu = new Atomic.UIMenuWindow(data.target, "create popup");
                 menu.show(src);
@@ -147,8 +147,6 @@ class ProjectFrame extends ScriptWidget {
 
             }
 
-            var system = ToolCore.getToolSystem();
-            var project = system.project;
             var db = ToolCore.getAssetDatabase();
             var fs = Atomic.getFileSystem();
 

+ 5 - 0
Script/AtomicEditor/ui/ProjectFrameMenu.ts

@@ -63,6 +63,11 @@ class ProjectFrameMenus extends Atomic.ScriptObject {
                 return true;
             }
 
+            if (refid == "reveal_folder") {
+                var utils = new Editor.FileUtils();
+                utils.revealInFinder(path);
+                return true;
+            }
         }
 
     }

+ 42 - 29
Script/AtomicEditor/ui/WelcomeFrame.ts

@@ -2,6 +2,7 @@
 import EditorEvents = require("../editor/EditorEvents");
 import EditorUI = require("./EditorUI");
 import ScriptWidget = require("./ScriptWidget");
+import Preferences = require("../editor/Preferences");
 
 class WelcomeFrame extends ScriptWidget {
 
@@ -11,38 +12,37 @@ class WelcomeFrame extends ScriptWidget {
 
         this.load("AtomicEditor/editor/ui/welcomeframe.tb.txt");
 
-        this.recentProjects = <Atomic.UISelectList> this.getWidget("recentprojects");
-        this.recentSource = new Atomic.UISelectItemSource();
+        var recentProjects = <Atomic.UILayout> this.getWidget("recentprojects");
         this.gravity = Atomic.UI_GRAVITY_ALL;
 
+        this.recentList = new Atomic.UIListView();
+        this.recentList.rootList.id = "recentList";
+
+        recentProjects.addChild(this.recentList);
+
         var container = <Atomic.UILayout> parent.getWidget("resourceviewcontainer");
 
         container.addChild(this);
 
         this.updateRecentProjects();
 
+        this.subscribeToEvent(EditorEvents.CloseProject, () => {
+            this.updateRecentProjects();
+        });
+        
     }
 
     handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
+        if (ev.type == Atomic.UI_EVENT_TYPE_RIGHT_POINTER_UP) {
+            if (ev.target.id == "recentList") {
+                this.openFrameMenu(ev.x, ev.y);
+            }
+        }
 
         if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
 
             var id = ev.target.id;
 
-            if (id == "recentprojects") {
-
-                var itemID = Number(this.recentProjects.selectedItemID);
-
-                if (itemID >= 0 && itemID < this.recent.length) {
-
-                    this.sendEvent(EditorEvents.LoadProject, { path: this.recent[itemID] });
-
-                }
-
-                return true;
-
-            }
-
             if (id == "open project") {
 
                 var utils = new Editor.FileUtils();
@@ -64,32 +64,45 @@ class WelcomeFrame extends ScriptWidget {
 
             }
 
-        }
+            if (id == "recentList") {
+                var path: string = this.recent[this.recentList.getSelectedItemID()];
+                this.sendEvent(EditorEvents.LoadProject, { path: path });
+            }
 
+            if (id == "recentProjectsContextMenu") {
+                var prefs = Preferences.getInstance();
+                if (ev.refid == "clear recent projects") {
+                    prefs.deleteRecentProjects();
+                    this.updateRecentProjects();
+                }
+            }
+        }
     }
 
     updateRecentProjects() {
 
-        this.recentSource.clear();
-
-        // prune any that don't exist
-        Atomic.editorMode.preferences.updateRecentFiles();
-
-        this.recent = Atomic.editorMode.preferences.recentProjects;
+        this.recentList.deleteAllItems();
+        
+        var prefs = Preferences.getInstance();
+        prefs.updateRecentProjects();
+        
+        this.recent = prefs.recentProjects;
 
         for (var i in this.recent) {
-
-            this.recentSource.addItem(new Atomic.UISelectItem(this.recent[i], i))
-
+            this.recentList.addRootItem(this.recent[i], "Folder.icon", i);
         }
 
-        this.recentProjects.source = this.recentSource;
+    }
 
+    private openFrameMenu(x: number, y: number) {
+        var menu = new Atomic.UIMenuWindow(this, "recentProjectsContextMenu");
+        var menuButtons = new Atomic.UISelectItemSource();
+        menuButtons.addItem(new Atomic.UISelectItem("Clear Recent Projects", "clear recent projects"));
+        menu.show(menuButtons, x, y);
     }
 
     recent: string[] = [];
-    recentProjects: Atomic.UISelectList;
-    recentSource: Atomic.UISelectItemSource;
+    recentList: Atomic.UIListView;
 
 }
 

+ 1 - 1
Script/AtomicEditor/ui/inspector/ModelInspector.ts

@@ -46,7 +46,7 @@ class ModelInspector extends InspectorWidget {
 
         }
 
-        this.importer.import(this.asset.guid);
+        this.asset.import();
         this.asset.save();
 
     }

+ 2 - 1
Script/Packages/Atomic/IO.json

@@ -9,7 +9,8 @@
 	},
 	"typescript_decl" : {
 		"File" : [
-			"readText():string;"
+			"readText():string;",
+            "writeString(text:string):void;"
 		],
 		"FileSystem" : [
 			"scanDir(pathName:string, filter:string, flags:number, recursive:boolean);"

+ 1 - 1
Script/Packages/Editor/Editor.json

@@ -3,5 +3,5 @@
 	"sources" : ["Source/AtomicEditor/Application", "Source/AtomicEditor/Utils",
 							"Source/AtomicEditor/EditorMode", "Source/AtomicEditor/PlayerMode",
 							 "Source/AtomicEditor/Editors", "Source/AtomicEditor/Editors/SceneEditor3D"],
-	"classes" : ["EditorMode", "PlayerMode", "FileUtils", "AEPreferences", "ResourceEditor", "JSResourceEditor", "SceneEditor3D", "SceneView3D"]
+	"classes" : ["EditorMode", "PlayerMode", "FileUtils", "ResourceEditor", "JSResourceEditor", "SceneEditor3D", "SceneView3D"]
 }

+ 44 - 101
Script/TypeScript/Atomic.d.ts

@@ -890,7 +890,6 @@ declare module Atomic {
    export var SHADOW_MIN_PIXELS: number;
    export var INSTANCING_BUFFER_DEFAULT_SIZE: number;
    export var MAX_VIEWPORT_TEXTURES: number;
-   export var NUM_SCREEN_BUFFERS: number;
    export var MAX_TEXTURE_QUALITY_LEVELS: number;
 
 
@@ -3125,13 +3124,11 @@ declare module Atomic {
 
    export class Graphics extends AObject {
 
-      windowIcon: Image;
       windowTitle: string;
+      windowIcon: Image;
       srgb: boolean;
       flushGPU: boolean;
-      forceGL2: boolean;
       orientations: string;
-      textureForUpdate: Texture;
       defaultTextureFilterMode: TextureFilterMode;
       textureAnisotropy: number;
       viewport: IntRect;
@@ -3147,8 +3144,8 @@ declare module Atomic {
       height: number;
       multiSample: number;
       fullscreen: boolean;
-      borderless: boolean;
       resizable: boolean;
+      borderless: boolean;
       vSync: boolean;
       tripleBuffer: boolean;
       numPrimitives: number;
@@ -3159,7 +3156,6 @@ declare module Atomic {
       instancingSupport: boolean;
       lightPrepassSupport: boolean;
       deferredSupport: boolean;
-      anisotropySupport: boolean;
       hardwareShadowSupport: boolean;
       readableDepthSupport: boolean;
       sRGBSupport: boolean;
@@ -3168,7 +3164,6 @@ declare module Atomic {
       vertexShader: ShaderVariation;
       pixelShader: ShaderVariation;
       depthStencil: RenderSurface;
-      depthTexture: Texture2D;
       depthConstantBias: number;
       depthSlopeScaledBias: number;
       stencilTest: boolean;
@@ -3183,8 +3178,6 @@ declare module Atomic {
       stencilWriteMask: number;
       useClipPlane: boolean;
       renderTargetDimensions: IntVector2;
-      vbo: number;
-      ubo: number;
       alphaFormat: number;
       luminanceFormat: number;
       luminanceAlphaFormat: number;
@@ -3203,15 +3196,14 @@ declare module Atomic {
       readableDepthFormat: number;
       pixelUVOffset: Vector2;
       maxBones: number;
-      gL3Support: boolean;
 
       // Construct.
       constructor();
 
-      // Set window icon.
-      setWindowIcon(windowIcon: Image): void;
       // Set window title.
       setWindowTitle(windowTitle: string): void;
+      // Set window icon.
+      setWindowIcon(windowIcon: Image): void;
       // Set window size.
       setWindowSize(width: number, height: number): void;
       // Center window.
@@ -3220,10 +3212,8 @@ declare module Atomic {
       raiseWindow(): void;
       // Set whether the main window uses sRGB conversion on write.
       setSRGB(enable: boolean): void;
-      // Set whether to flush the GPU command buffer to prevent multiple frames being queued and uneven frame timesteps. Not yet implemented on OpenGL.
+      // Set whether to flush the GPU command buffer to prevent multiple frames being queued and uneven frame timesteps. Default off, may decrease performance if enabled.
       setFlushGPU(enable: boolean): void;
-      // Set forced use of OpenGL 2 even if OpenGL 3 is available. Must be called before setting the screen mode for the first time. Default false.
-      setForceGL2(enable: boolean): void;
       // Set allowed screen orientations as a space-separated list of "LandscapeLeft", "LandscapeRight", "Portrait" and "PortraitUpsideDown". Affects currently only iOS platform.
       setOrientations(orientations: string): void;
       // Toggle between full screen and windowed mode. Return true if successful.
@@ -3240,7 +3230,7 @@ declare module Atomic {
       clear(flags: number, color?: Color, depth?: number, stencil?: number): void;
       // Resolve multisampled backbuffer to a texture rendertarget. The texture's size should match the viewport size.
       resolveToTexture(destination: Texture2D, viewport: IntRect): boolean;
-      // Draw indexed, instanced geometry.
+      // Draw indexed, instanced geometry. An instancing vertex buffer must be set.
       drawInstanced(type: PrimitiveType, indexStart: number, indexCount: number, minVertex: number, vertexCount: number, instanceCount: number): void;
       // Set shaders.
       setShaders(vs: ShaderVariation, ps: ShaderVariation): void;
@@ -3256,14 +3246,10 @@ declare module Atomic {
       clearTransformSources(): void;
       // Set texture.
       setTexture(index: number, texture: Texture): void;
-      // Bind texture unit 0 for update. Called by Texture.
-      setTextureForUpdate(texture: Texture): void;
       // Set default texture filtering mode.
       setDefaultTextureFilterMode(mode: TextureFilterMode): void;
       // Set texture anisotropy.
       setTextureAnisotropy(level: number): void;
-      // Dirty texture parameters of all textures (when global settings change.)
-      setTextureParametersDirty(): void;
       // Reset all rendertargets, depth-stencil surface and viewport.
       resetRenderTargets(): void;
       // Reset specific rendertarget.
@@ -3308,43 +3294,39 @@ declare module Atomic {
       getMultiSample(): number;
       // Return whether window is fullscreen.
       getFullscreen(): boolean;
-      // Return whether window is borderless.
-      getBorderless(): boolean;
       // Return whether window is resizable.
       getResizable(): boolean;
+      // Return whether window is borderless.
+      getBorderless(): boolean;
       // Return whether vertical sync is on.
       getVSync(): boolean;
       // Return whether triple buffering is enabled.
       getTripleBuffer(): boolean;
       // Return whether the main window is using sRGB conversion on write.
       getSRGB(): boolean;
-      // Return whether the GPU command buffer is flushed each frame. Not yet implemented on OpenGL.
+      // Return whether the GPU command buffer is flushed each frame.
       getFlushGPU(): boolean;
-      // Return whether OpenGL 2 use is forced.
-      getForceGL2(): boolean;
       // Return allowed screen orientations.
       getOrientations(): string;
-      // Return whether device is lost, and can not yet render.
+      // Return whether Direct3D device is lost, and can not yet render. This happens during fullscreen resolution switching.
       isDeviceLost(): boolean;
       // Return number of primitives drawn this frame.
       getNumPrimitives(): number;
       // Return number of batches drawn this frame.
       getNumBatches(): number;
-      // Return dummy color texture format for shadow maps. 0 if not needed, may be nonzero on OS X to work around an Intel driver issue.
+      // Return dummy color texture format for shadow maps. Is "NULL" (consume no video memory) if supported.
       getDummyColorFormat(): number;
       // Return shadow map depth texture format, or 0 if not supported.
       getShadowMapFormat(): number;
       // Return 24-bit shadow map depth texture format, or 0 if not supported.
       getHiresShadowMapFormat(): number;
-      // Return whether hardware instancing is supported.
+      // Return whether hardware instancing is supported..
       getInstancingSupport(): boolean;
       // Return whether light pre-pass rendering is supported.
       getLightPrepassSupport(): boolean;
       // Return whether deferred rendering is supported.
       getDeferredSupport(): boolean;
-      // Return whether anisotropic texture filtering is supported.
-      getAnisotropySupport(): boolean;
-      // Return whether shadow map depth compare is done in hardware. Always true on OpenGL.
+      // Return whether shadow map depth compare is done in hardware.
       getHardwareShadowSupport(): boolean;
       // Return whether a readable hardware depth format is available.
       getReadableDepthSupport(): boolean;
@@ -3356,24 +3338,22 @@ declare module Atomic {
       getDesktopResolution(): IntVector2;
       // Return a shader variation by name and defines.
       getShader(type: ShaderType, name: string, defines?: string): ShaderVariation;
-      // Return vertex shader.
+      // Return current vertex shader.
       getVertexShader(): ShaderVariation;
-      // Return pixel shader.
+      // Return current pixel shader.
       getPixelShader(): ShaderVariation;
       // Return texture unit index by name.
       getTextureUnit(name: string): TextureUnit;
       // Return texture unit name by index.
       getTextureUnitName(unit: TextureUnit): string;
-      // Return texture by texture unit index.
+      // Return current texture by texture unit index.
       getTexture(index: number): Texture;
       // Return default texture filtering mode.
       getDefaultTextureFilterMode(): TextureFilterMode;
-      // Return rendertarget by index.
+      // Return current rendertarget by index.
       getRenderTarget(index: number): RenderSurface;
-      // Return depth-stencil surface.
+      // Return current depth-stencil surface.
       getDepthStencil(): RenderSurface;
-      // Return readable depth-stencil texture. Not created automatically on OpenGL.
-      getDepthTexture(): Texture2D;
       // Return the viewport coordinates.
       getViewport(): IntRect;
       // Return texture anisotropy.
@@ -3422,26 +3402,14 @@ declare module Atomic {
       windowResized(): void;
       // Window was moved through user interaction. Called by Input subsystem.
       windowMoved(): void;
-      // Clean up too large scratch buffers.
-      cleanupScratchBuffers(): void;
-      // Clean up a render surface from all FBOs.
-      cleanupRenderSurface(surface: RenderSurface): void;
-      // Clean up shader programs when a shader variation is released or destroyed.
-      cleanupShaderPrograms(variation: ShaderVariation): void;
-      // Release/clear GPU objects and optionally close the window.
-      release(clearGPUObjects: boolean, closeWindow: boolean): void;
-      // Restore GPU objects and reinitialize state. Requires an open window.
-      restore(): void;
       // Maximize the Window.
       maximize(): void;
       // Minimize the Window.
       minimize(): void;
-      // Mark the FBO needing an update.
-      markFBODirty(): void;
-      // Bind a VBO, avoiding redundant operation.
-      setVBO(object: number): void;
-      // Bind a UBO, avoiding redundant operation.
-      setUBO(object: number): void;
+      // Clean up too large scratch buffers.
+      cleanupScratchBuffers(): void;
+      // Clean up shader programs when a shader variation is released or destroyed.
+      cleanupShaderPrograms(variation: ShaderVariation): void;
       // Return the API-specific alpha texture format.
       getAlphaFormat(): number;
       // Return the API-specific luminance texture format.
@@ -3478,8 +3446,6 @@ declare module Atomic {
       getPixelUVOffset(): Vector2;
       // Return maximum number of supported bones for skinning.
       getMaxBones(): number;
-      // Return whether is using an OpenGL 3 context.
-      getGL3Support(): boolean;
 
    }
 
@@ -3490,11 +3456,9 @@ declare module Atomic {
       linkedRenderTarget: RenderSurface;
       linkedDepthStencil: RenderSurface;
       parentTexture: Texture;
-      renderBuffer: number;
       width: number;
       height: number;
       usage: TextureUsage;
-      target: number;
 
       // Construct with parent texture.
       constructor(parentTexture: Texture);
@@ -3511,16 +3475,10 @@ declare module Atomic {
       setLinkedDepthStencil(depthStencil: RenderSurface): void;
       // Queue manual update of the viewport(s).
       queueUpdate(): void;
-      // Create a renderbuffer. Return true if successful.
-      createRenderBuffer(width: number, height: number, format: number): boolean;
-      // Handle device loss.
-      onDeviceLost(): void;
-      // Release renderbuffer if any.
+      // Release surface.
       release(): void;
       // Return parent texture.
       getParentTexture(): Texture;
-      // Return renderbuffer if created.
-      getRenderBuffer(): number;
       // Return width.
       getWidth(): number;
       // Return height.
@@ -3533,14 +3491,10 @@ declare module Atomic {
       getViewport(index: number): Viewport;
       // Return viewport update mode.
       getUpdateMode(): RenderSurfaceUpdateMode;
-      // Return linked color buffer.
+      // Return linked color rendertarget.
       getLinkedRenderTarget(): RenderSurface;
-      // Return linked depth buffer.
+      // Return linked depth-stencil surface.
       getLinkedDepthStencil(): RenderSurface;
-      // Set surface's OpenGL target.
-      setTarget(target: number): void;
-      // Return surface's OpenGL target.
-      getTarget(): number;
       // Clear update flag. Called by Renderer.
       wasUpdated(): void;
 
@@ -3558,8 +3512,6 @@ declare module Atomic {
       // Construct.
       constructor(owner: Shader, type: ShaderType);
 
-      // Mark the GPU resource destroyed on context destruction.
-      onDeviceLost(): void;
       // Release the shader.
       release(): void;
       // Compile the shader. Return true if successful.
@@ -3572,7 +3524,7 @@ declare module Atomic {
       getOwner(): Shader;
       // Return shader type.
       getShaderType(): ShaderType;
-      // Return name.
+      // Return shader name.
       getName(): string;
       // Return defines.
       getDefines(): string;
@@ -3580,6 +3532,10 @@ declare module Atomic {
       getFullName(): string;
       // Return compile error/warning string.
       getCompilerOutput(): string;
+      // Return whether uses a parameter.
+      hasParameter(param: string): boolean;
+      // Return whether uses a texture unit (only for pixel shaders.)
+      hasTextureUnit(unit: TextureUnit): boolean;
 
    }
 
@@ -3591,13 +3547,11 @@ declare module Atomic {
       borderColor: Color;
       srgb: boolean;
       backupTexture: Texture;
-      target: number;
       format: number;
       levels: number;
       width: number;
       height: number;
       depth: number;
-      parametersDirty: boolean;
       usage: TextureUsage;
       components: number;
       parameters: XMLFile;
@@ -3611,7 +3565,7 @@ declare module Atomic {
       setFilterMode(filter: TextureFilterMode): void;
       // Set addressing mode by texture coordinate.
       setAddressMode(coord: TextureCoordinate, address: TextureAddressMode): void;
-      // Set shadow compare mode.
+      // Set shadow compare mode. No-op on D3D9.
       setShadowCompare(enable: boolean): void;
       // Set border color for border addressing mode.
       setBorderColor(color: Color): void;
@@ -3621,12 +3575,6 @@ declare module Atomic {
       setBackupTexture(texture: Texture): void;
       // Set mip levels to skip on a quality setting when loading. Ensures higher quality levels do not skip more.
       setMipsToSkip(quality: number, mips: number): void;
-      // Dirty the parameters.
-      setParametersDirty(): void;
-      // Update changed parameters to OpenGL. Called by Graphics when binding the texture.
-      updateParameters(): void;
-      // Return texture's OpenGL target.
-      getTarget(): number;
       // Return texture format.
       getFormat(): number;
       // Return whether the texture format is compressed.
@@ -3639,13 +3587,11 @@ declare module Atomic {
       getHeight(): number;
       // Return height.
       getDepth(): number;
-      // Return whether parameters are dirty.
-      getParametersDirty(): boolean;
       // Return filtering mode.
       getFilterMode(): TextureFilterMode;
       // Return addressing mode by texture coordinate.
       getAddressMode(coord: TextureCoordinate): TextureAddressMode;
-      // Return whether shadow compare is enabled.
+      // Return whether shadow compare is enabled. Always false on D3D9.
       getShadowCompare(): boolean;
       // Return border color.
       getBorderColor(): Color;
@@ -3667,14 +3613,8 @@ declare module Atomic {
       getRowDataSize(width: number): number;
       // Return number of image components required to receive pixel data from GetData(), or 0 for compressed images.
       getComponents(): number;
-      // Return the non-internal texture format corresponding to an OpenGL internal format.
-      getExternalFormat(format: number): number;
-      // Return the data type corresponding to an OpenGL internal format.
-      getDataType(format: number): number;
       // Set additional parameters from an XML file.
       setParameters(xml: XMLFile): void;
-      // Return the corresponding SRGB texture format if supported. If not supported, return format unchanged.
-      getSRGBFormat(format: number): number;
 
    }
 
@@ -3687,11 +3627,11 @@ declare module Atomic {
 
       // Finish resource loading. Always called from the main thread. Return true if successful.
       endLoad(): boolean;
-      // Mark the GPU resource destroyed on context destruction.
+      // Release default pool resources.
       onDeviceLost(): void;
-      // Recreate the GPU resource and restore data if applicable.
+      // Recreate default pool resources.
       onDeviceReset(): void;
-      // Release the texture.
+      // Release texture.
       release(): void;
       // Set size, format and usage. Zero size will follow application window size. Return true if successful.
       setSize(width: number, height: number, format: number, usage?: TextureUsage): boolean;
@@ -3709,11 +3649,11 @@ declare module Atomic {
 
       // Finish resource loading. Always called from the main thread. Return true if successful.
       endLoad(): boolean;
-      // Mark the GPU resource destroyed on context destruction.
+      // Release default pool resources.
       onDeviceLost(): void;
-      // Recreate the GPU resource and restore data if applicable.
+      // Recreate default pool resources.
       onDeviceReset(): void;
-      // Release the texture.
+      // Release texture.
       release(): void;
       // Set size, format and usage. Zero size will follow application window size. Return true if successful.
       setSize(width: number, height: number, depth: number, format: number, usage?: TextureUsage): boolean;
@@ -3729,11 +3669,11 @@ declare module Atomic {
 
       // Finish resource loading. Always called from the main thread. Return true if successful.
       endLoad(): boolean;
-      // Mark the GPU resource destroyed on context destruction.
+      // Release default pool resources.
       onDeviceLost(): void;
-      // Recreate the GPU resource and restore data if applicable.
+      // ReCreate default pool resources.
       onDeviceReset(): void;
-      // Release the texture.
+      // Release texture.
       release(): void;
       // Set size, format and usage. Return true if successful.
       setSize(size: number, format: number, usage?: TextureUsage): boolean;
@@ -7857,6 +7797,7 @@ declare module Atomic {
       // Unlike FileSystem.Copy this copy works when the source file is in a package file
       copy(srcFile: File): boolean;
       readText():string;
+      writeString(text:string):void;
 
    }
 
@@ -7924,6 +7865,8 @@ declare module Atomic {
       createDirs(root: string, subdirectory: string): boolean;
       // Copy a directory, directoryOut must not exist
       copyDir(directoryIn: string, directoryOut: string): boolean;
+      // Check if a file or directory exists at the specified path
+      exists(pathName: string): boolean;
       createDirsRecursive(directoryIn: string, directoryOut: string): boolean;
       scanDir(pathName:string, filter:string, flags:number, recursive:boolean);
 

+ 0 - 27
Script/TypeScript/Editor.d.ts

@@ -35,30 +35,6 @@ declare module Editor {
 //----------------------------------------------------
 
 
-   export class AEPreferences extends Atomic.AObject {
-
-      recentProjects: string[];
-      androidSDKPath: string;
-      antPath: string;
-      jDKRootPath: string;
-
-      // Construct.
-      constructor();
-
-      registerRecentProject(fullpath: string): void;
-      getRecentProjects(): string[];
-      setAndroidSDKPath(path: string): void;
-      setAntPath(path: string): void;
-      setJDKRootPath(path: string): void;
-      getAndroidSDKPath(): string;
-      getJDKRootPath(): string;
-      getAntPath(): string;
-      read(): void;
-      write(): void;
-      updateRecentFiles(write?: boolean): void;
-
-   }
-
    export class FileUtils extends Atomic.AObject {
 
       // Construct.
@@ -73,13 +49,10 @@ declare module Editor {
 
    export class EditorMode extends Atomic.AObject {
 
-      preferences: AEPreferences;
-
       // Construct.
       constructor();
 
       playProject(): boolean;
-      getPreferences(): AEPreferences;
 
    }
 

+ 5 - 8
Script/TypeScript/ToolCore.d.ts

@@ -249,6 +249,7 @@ declare module ToolCore {
       importer: AssetImporter;
       parent: Asset;
       dirty: boolean;
+      fileTimestamp: number;
       dotAssetFilename: string;
 
       // Construct.
@@ -270,6 +271,10 @@ declare module ToolCore {
       getParent(): Asset;
       setDirty(dirty: boolean): void;
       isDirty(): boolean;
+      // Get the last timestamp as seen by the AssetDatabase
+      getFileTimestamp(): number;
+      // Sets the time stamp to the asset files current time
+      updateFileTimestamp(): void;
       getDotAssetFilename(): string;
       isFolder(): boolean;
       load(): boolean;
@@ -306,8 +311,6 @@ declare module ToolCore {
       constructor(asset: Asset);
 
       setDefaults(): void;
-      // Imports to cached data
-      import(guid: string): boolean;
       preload(): boolean;
       getAsset(): Asset;
       requiresCacheFile(): boolean;
@@ -320,7 +323,6 @@ declare module ToolCore {
       constructor(asset: Asset);
 
       setDefaults(): void;
-      import(guid: string): boolean;
 
    }
 
@@ -331,7 +333,6 @@ declare module ToolCore {
 
       setDefaults(): void;
       isComponentFile(): boolean;
-      import(guid: string): boolean;
 
    }
 
@@ -341,7 +342,6 @@ declare module ToolCore {
       constructor(asset: Asset);
 
       setDefaults(): void;
-      import(guid: string): boolean;
       saveMaterial(): void;
 
    }
@@ -380,7 +380,6 @@ declare module ToolCore {
       getAnimationCount(): number;
       setAnimationCount(count: number): void;
       getAnimationInfo(index: number): AnimationImportInfo;
-      import(guid: string): boolean;
 
    }
 
@@ -390,7 +389,6 @@ declare module ToolCore {
       constructor(asset: Asset);
 
       setDefaults(): void;
-      import(guid: string): boolean;
       preload(): boolean;
 
    }
@@ -401,7 +399,6 @@ declare module ToolCore {
       constructor(asset: Asset);
 
       setDefaults(): void;
-      import(guid: string): boolean;
 
    }
 

+ 2 - 0
Source/Atomic/Atomic2D/Animation2D.h

@@ -101,6 +101,8 @@ struct AnimationTrack2D
 /// 2D Animation.
 class ATOMIC_API Animation2D : public RefCounted
 {
+    REFCOUNTED(Animation2D)
+
 public:
     /// Construct.
     Animation2D(AnimationSet2D* animationSet);

+ 7 - 0
Source/Atomic/Atomic2D/TileMapDefs2D.h

@@ -103,6 +103,9 @@ enum TileMapObjectType2D
 /// Property set.
 class ATOMIC_API PropertySet2D : public RefCounted
 {
+
+    REFCOUNTED(PropertySet2D)
+
 public:
     PropertySet2D();
     virtual ~PropertySet2D();
@@ -122,6 +125,8 @@ protected:
 /// Tile define.
 class ATOMIC_API Tile2D : public RefCounted
 {
+    REFCOUNTED(Tile2D)
+
 public:
     /// Construct.
     Tile2D();
@@ -157,6 +162,8 @@ private:
 /// Tile map object.
 class ATOMIC_API TileMapObject2D : public RefCounted
 {
+    REFCOUNTED(TileMapObject2D)
+
 public:
     TileMapObject2D();
 

+ 8 - 0
Source/Atomic/Atomic2D/TmxFile2D.h

@@ -37,6 +37,8 @@ class XMLFile;
 /// Tmx layer.
 class TmxLayer2D : public RefCounted
 {
+    REFCOUNTED(TmxLayer2D)
+
 public:
     TmxLayer2D(TmxFile2D* tmxFile, TileMapLayerType2D type);
     virtual ~TmxLayer2D();
@@ -90,6 +92,8 @@ protected:
 /// Tmx tile layer.
 class TmxTileLayer2D : public TmxLayer2D
 {
+    REFCOUNTED(TmxTileLayer2D)
+
 public:
     TmxTileLayer2D(TmxFile2D* tmxFile);
 
@@ -106,6 +110,8 @@ protected:
 /// Tmx image layer.
 class TmxObjectGroup2D : public TmxLayer2D
 {
+    REFCOUNTED(TmxObjectGroup2D)
+
 public:
     TmxObjectGroup2D(TmxFile2D* tmxFile);
 
@@ -126,6 +132,8 @@ private:
 /// Tmx image layer.
 class TmxImageLayer2D : public TmxLayer2D
 {
+    REFCOUNTED(TmxImageLayer2D)
+
 public:
     TmxImageLayer2D(TmxFile2D* tmxFile);
 

+ 2 - 0
Source/Atomic/Atomic3D/AnimationState.h

@@ -59,6 +59,8 @@ struct AnimationStateTrack
 /// %Animation instance.
 class ATOMIC_API AnimationState : public RefCounted
 {
+    REFCOUNTED(AnimationState)
+
 public:
     /// Construct with animated model and animation pointers.
     AnimationState(AnimatedModel* model, Animation* animation);

+ 2 - 0
Source/Atomic/Audio/SoundStream.h

@@ -30,6 +30,8 @@ namespace Atomic
 /// Base class for sound streams.
 class ATOMIC_API SoundStream : public RefCounted
 {
+    REFCOUNTED(SoundStream)
+
 public:
     /// Construct.
     SoundStream();

+ 17 - 0
Source/Atomic/Container/RefCounted.h

@@ -25,6 +25,18 @@
 namespace Atomic
 {
 
+// ATOMIC BEGIN
+
+typedef const void* ClassID;
+
+/// Macro to be included in RefCounted derived classes for efficient RTTI
+#define REFCOUNTED(typeName) \
+    public: \
+        virtual ClassID GetClassID() const { return GetClassIDStatic(); } \
+        static ClassID GetClassIDStatic() { static const int typeID = 0; return (ClassID) &typeID; }
+
+// ATOMIC END
+
 /// Reference count structure.
 struct RefCount
 {
@@ -70,10 +82,15 @@ public:
     /// Return pointer to the reference count structure.
     RefCount* RefCountPtr() { return refCount_; }
 
+    // ATOMIC BEGIN
     virtual bool IsObject() const { return false; }
 
+    virtual ClassID GetClassID() const  = 0;
+    static ClassID GetClassIDStatic() { static const int typeID = 0; return (ClassID) &typeID; }
+
     inline void* JSGetHeapPtr() const { return jsHeapPtr_; }
     inline void  JSSetHeapPtr(void* heapptr) { jsHeapPtr_ = heapptr; }
+    // ATOMIC END
 
 private:
     /// Prevent copy construction.

+ 2 - 0
Source/Atomic/Core/Attribute.h

@@ -52,6 +52,8 @@ class Serializable;
 /// Abstract base class for invoking attribute accessors.
 class ATOMIC_API AttributeAccessor : public RefCounted
 {
+    REFCOUNTED(AttributeAccessor)
+
 public:
     /// Get the attribute.
     virtual void Get(const Serializable* ptr, Variant& dest) const = 0;

+ 2 - 0
Source/Atomic/Core/Context.h

@@ -46,6 +46,8 @@ class ATOMIC_API Context : public RefCounted
 {
     friend class Object;
 
+    REFCOUNTED(Context)
+
 public:
     /// Construct.
     Context();

+ 5 - 0
Source/Atomic/Core/Object.h

@@ -40,6 +40,8 @@ class EventHandler;
         virtual const Atomic::String& GetTypeName() const { return GetTypeNameStatic(); } \
         static Atomic::StringHash GetTypeStatic() { static const Atomic::StringHash typeStatic(#typeName); return typeStatic; } \
         static const Atomic::String& GetTypeNameStatic() { static const Atomic::String typeNameStatic(#typeName); return typeNameStatic; } \
+        virtual ClassID GetClassID() const { return GetClassIDStatic(); } \
+        static ClassID GetClassIDStatic() { static const int typeID = 0; return (ClassID) &typeID; }
 
 #define BASEOBJECT(typeName) \
     public: \
@@ -111,6 +113,7 @@ public:
     const String& GetCategory() const;
 
     virtual bool IsObject() const { return true; }
+    static ClassID GetClassIDStatic() { static const int typeID = 0; return (ClassID) &typeID; }
     static const Atomic::String& GetTypeNameStatic() { static const Atomic::String typeNameStatic("Object"); return typeNameStatic; }
     
 protected:
@@ -136,6 +139,8 @@ template <class T> T* Object::GetSubsystem() const { return static_cast<T*>(GetS
 /// Base class for object factories.
 class ATOMIC_API ObjectFactory : public RefCounted
 {
+    REFCOUNTED(ObjectFactory)
+
 public:
     /// Construct.
     ObjectFactory(Context* context) :

+ 2 - 0
Source/Atomic/Core/WorkQueue.cpp

@@ -34,6 +34,8 @@ namespace Atomic
 /// Worker thread managed by the work queue.
 class WorkerThread : public Thread, public RefCounted
 {
+    REFCOUNTED(WorkerThread)
+
 public:
     /// Construct.
     WorkerThread(WorkQueue* owner, unsigned index) :

+ 2 - 0
Source/Atomic/Core/WorkQueue.h

@@ -40,6 +40,8 @@ class WorkerThread;
 /// Work queue item.
 struct WorkItem : public RefCounted
 {
+    REFCOUNTED(WorkItem)
+
     friend class WorkQueue;
 
 public:

+ 2 - 0
Source/Atomic/Graphics/Direct3D11/D3D11RenderSurface.h

@@ -36,6 +36,8 @@ class ATOMIC_API RenderSurface : public RefCounted
     friend class Texture2D;
     friend class TextureCube;
 
+    REFCOUNTED(RenderSurface)
+
 public:
     /// Construct with parent texture.
     RenderSurface(Texture* parentTexture);

+ 2 - 0
Source/Atomic/Graphics/Direct3D11/D3D11ShaderProgram.h

@@ -33,6 +33,8 @@ namespace Atomic
 /// Combined information for specific vertex and pixel shaders.
 class ATOMIC_API ShaderProgram : public RefCounted
 {
+    REFCOUNTED(ShaderProgram)
+
 public:
     /// Construct.
     ShaderProgram(Graphics* graphics, ShaderVariation* vertexShader, ShaderVariation* pixelShader)

+ 2 - 0
Source/Atomic/Graphics/Direct3D11/D3D11ShaderVariation.h

@@ -75,6 +75,8 @@ struct ShaderParameter
 /// Vertex or pixel shader on the GPU.
 class ATOMIC_API ShaderVariation : public RefCounted, public GPUObject
 {
+    REFCOUNTED(ShaderVariation)
+
 public:
     /// Construct.
     ShaderVariation(Shader* owner, ShaderType type);

+ 2 - 0
Source/Atomic/Graphics/Direct3D11/D3D11VertexDeclaration.h

@@ -36,6 +36,8 @@ class VertexBuffer;
 /// Vertex declaration.
 class ATOMIC_API VertexDeclaration : public RefCounted
 {
+    REFCOUNTED(VertexDeclaration)
+
 public:
     /// Construct with vertex buffers and element masks to base declaration on.
     VertexDeclaration(Graphics* graphics, ShaderVariation* vertexShader, VertexBuffer** buffers, unsigned* elementMasks);

+ 2 - 0
Source/Atomic/Graphics/Direct3D9/D3D9RenderSurface.h

@@ -35,6 +35,8 @@ class ATOMIC_API RenderSurface : public RefCounted
 {
     friend class Texture2D;
     friend class TextureCube;
+    
+    REFCOUNTED(RenderSurface)
 
 public:
     /// Construct with parent texture.

+ 2 - 0
Source/Atomic/Graphics/Direct3D9/D3D9ShaderProgram.h

@@ -31,6 +31,8 @@ namespace Atomic
 /// Combined information for specific vertex and pixel shaders.
 class ShaderProgram : public RefCounted
 {
+    REFCOUNTED(ShaderProgram)
+
 public:
     /// Construct.
     ShaderProgram(ShaderVariation* vertexShader, ShaderVariation* pixelShader)

+ 2 - 0
Source/Atomic/Graphics/Direct3D9/D3D9ShaderVariation.h

@@ -66,6 +66,8 @@ struct ShaderParameter
 /// Vertex or pixel shader on the GPU.
 class ATOMIC_API ShaderVariation : public RefCounted, public GPUObject
 {
+    REFCOUNTED(ShaderVariation)
+
 public:
     /// Construct.
     ShaderVariation(Shader* owner, ShaderType type);

+ 2 - 0
Source/Atomic/Graphics/Direct3D9/D3D9VertexDeclaration.h

@@ -48,6 +48,8 @@ struct VertexDeclarationElement
 /// Vertex declaration.
 class ATOMIC_API VertexDeclaration : public RefCounted
 {
+    REFCOUNTED(VertexDeclaration)
+
 public:
     /// Construct with vertex element mask.
     VertexDeclaration(Graphics* graphics, unsigned elementMask);

+ 2 - 0
Source/Atomic/Graphics/Material.h

@@ -70,6 +70,8 @@ struct TechniqueEntry
 /// Material's shader parameter animation instance.
 class ShaderParameterAnimationInfo : public ValueAnimationInfo
 {
+    REFCOUNTED(ShaderParameterAnimationInfo)
+
 public:
     /// Construct.
     ShaderParameterAnimationInfo

+ 2 - 0
Source/Atomic/Graphics/OpenGL/OGLRenderSurface.h

@@ -38,6 +38,8 @@ class ATOMIC_API RenderSurface : public RefCounted
     friend class Texture2D;
     friend class TextureCube;
 
+    REFCOUNTED(RenderSurface)
+
 public:
     /// Construct with parent texture.
     RenderSurface(Texture* parentTexture);

+ 2 - 0
Source/Atomic/Graphics/OpenGL/OGLShaderProgram.h

@@ -54,6 +54,8 @@ struct ShaderParameter
 /// Linked shader program on the GPU.
 class ATOMIC_API ShaderProgram : public RefCounted, public GPUObject
 {
+    REFCOUNTED(ShaderProgam)
+
 public:
     /// Construct.
     ShaderProgram(Graphics* graphics, ShaderVariation* vertexShader, ShaderVariation* pixelShader);

+ 2 - 0
Source/Atomic/Graphics/OpenGL/OGLShaderVariation.h

@@ -36,6 +36,8 @@ class ShaderProgram;
 /// Vertex or pixel shader on the GPU.
 class ATOMIC_API ShaderVariation : public RefCounted, public GPUObject
 {
+    REFCOUNTED(ShaderVariation)
+
 public:
     /// Construct.
     ShaderVariation(Shader* owner, ShaderType type);

+ 2 - 0
Source/Atomic/Graphics/RenderPath.h

@@ -204,6 +204,8 @@ struct RenderPathCommand
 /// Rendering path definition.
 class ATOMIC_API RenderPath : public RefCounted
 {
+    REFCOUNTED(RenderPath)
+
 public:
     /// Construct.
     RenderPath();

+ 2 - 0
Source/Atomic/Graphics/Technique.h

@@ -41,6 +41,8 @@ enum PassLightingMode
 /// %Material rendering pass, which defines shaders and render state.
 class ATOMIC_API Pass : public RefCounted
 {
+    REFCOUNTED(Pass)
+
 public:
     /// Construct.
     Pass(const String& passName);

+ 3 - 0
Source/Atomic/IO/FileSystem.h

@@ -110,6 +110,9 @@ public:
     /// Copy a directory, directoryOut must not exist
     bool CopyDir(const String& directoryIn, const String& directoryOut);
 
+	/// Check if a file or directory exists at the specified path
+    bool Exists(const String& pathName) const { return FileExists(pathName) || DirExists(pathName); }
+
     bool CreateDirsRecursive(const String& directoryIn, const String& directoryOut);
     
 private:

+ 2 - 0
Source/Atomic/Network/HttpRequest.h

@@ -43,6 +43,8 @@ enum HttpRequestState
 /// An HTTP connection with response data stream.
 class HttpRequest : public RefCounted, public Deserializer, public Thread
 {
+    REFCOUNTED(HttpRequest)
+
 public:
     /// Construct with parameters.
     HttpRequest(const String& url, const String& verb, const Vector<String>& headers, const String& postData);

+ 7 - 0
Source/Atomic/Physics/CollisionShape.h

@@ -62,11 +62,14 @@ enum ShapeType
 /// Base class for collision shape geometry data.
 struct CollisionGeometryData : public RefCounted
 {
+    REFCOUNTED(CollisionGeometryData)
 };
 
 /// Triangle mesh geometry data.
 struct TriangleMeshData : public CollisionGeometryData
 {
+    REFCOUNTED(TriangleMeshData)
+
     /// Construct from a model.
     TriangleMeshData(Model* model, unsigned lodLevel);
     /// Construct from a custom geometry.
@@ -85,6 +88,8 @@ struct TriangleMeshData : public CollisionGeometryData
 /// Convex hull geometry data.
 struct ConvexData : public CollisionGeometryData
 {
+    REFCOUNTED(ConvexData)
+
     /// Construct from a model.
     ConvexData(Model* model, unsigned lodLevel);
     /// Construct from a custom geometry.
@@ -108,6 +113,8 @@ struct ConvexData : public CollisionGeometryData
 /// Heightfield geometry data.
 struct HeightfieldData : public CollisionGeometryData
 {
+    REFCOUNTED(HeightfieldData)
+
     /// Construct from a terrain.
     HeightfieldData(Terrain* terrain, unsigned lodLevel);
     /// Destruct. Free geometry data.

+ 2 - 0
Source/Atomic/Resource/BackgroundLoader.h

@@ -52,6 +52,8 @@ struct BackgroundLoadItem
 /// Background loader of resources. Owned by the ResourceCache.
 class BackgroundLoader : public RefCounted, public Thread
 {
+    REFCOUNTED(BackgroundLoader);
+
 public:
     /// Construct.
     BackgroundLoader(ResourceCache* owner);

+ 2 - 0
Source/Atomic/Scene/ValueAnimationInfo.h

@@ -35,6 +35,8 @@ struct VAnimEventFrame;
 /// Base class for a value animation instance, which includes animation runtime information and updates the target object's value automatically.
 class ValueAnimationInfo : public RefCounted
 {
+    REFCOUNTED(ValueAnimationInfo)
+
 public:
     /// Construct without target object.
     ValueAnimationInfo(ValueAnimation* animation, WrapMode wrapMode, float speed);

+ 10 - 0
Source/Atomic/UI/UIButton.cpp

@@ -3,6 +3,7 @@
 #include <TurboBadger/tb_widgets_common.h>
 
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/FileSystem.h>
 
 #include "UIEvents.h"
 #include "UI.h"
@@ -38,6 +39,15 @@ void UIButton::SetSqueezable(bool value)
 
 bool UIButton::OnEvent(const tb::TBWidgetEvent &ev)
 {
+    if (ev.type == EVENT_TYPE_CLICK) 
+	{
+        String text = GetText();
+        if (text.StartsWith("http://") || text.StartsWith("https://")) 
+		{
+            FileSystem* fileSystem = GetSubsystem<FileSystem>();
+            fileSystem->SystemOpen(text);
+        }
+    }
     return UIWidget::OnEvent(ev);
 }
 

+ 2 - 0
Source/Atomic/UI/UIPreferredSize.h

@@ -28,6 +28,8 @@ class UIPreferredSize : public RefCounted
 {
     friend class UIWidget;
 
+    REFCOUNTED(UIPreferredSize)
+
 public:
 
     UIPreferredSize(int w = 0, int h = 0);

+ 0 - 3
Source/AtomicEditor/Application/AEEditorApp.cpp

@@ -22,7 +22,6 @@
 #include "../EditorMode/AEEditorMode.h"
 
 #include "AEEditorApp.h"
-#include "AEPreferences.h"
 
 using namespace ToolCore;
 
@@ -90,8 +89,6 @@ void AEEditorApp::Setup()
 {
     context_->SetEditorContext(true);
 
-    context_->RegisterSubsystem(new AEPreferences(context_));
-
     ToolEnvironment* env = new ToolEnvironment(context_);
     context_->RegisterSubsystem(env);
 

+ 0 - 2
Source/AtomicEditor/Application/AEEditorApp.h

@@ -13,8 +13,6 @@ namespace Atomic
 namespace AtomicEditor
 {
 
-class AEPreferences;
-
 class AEEditorApp : public AEEditorCommon
 {
     OBJECT(AEEditorApp);

+ 0 - 2
Source/AtomicEditor/Application/AEEditorCommon.h

@@ -13,8 +13,6 @@ namespace Atomic
 namespace AtomicEditor
 {
 
-class AEPreferences;
-
 class AEEditorCommon : public Application
 {
     OBJECT(AEEditorCommon);

+ 0 - 285
Source/AtomicEditor/Application/AEPreferences.cpp

@@ -1,285 +0,0 @@
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
-// Please see LICENSE.md in repository root for license information
-// https://github.com/AtomicGameEngine/AtomicGameEngine
-
-#include <rapidjson/document.h>
-#include "rapidjson/prettywriter.h"
-#include "rapidjson/filestream.h"
-
-#include <Atomic/Core/Context.h>
-#include <Atomic/IO/FileSystem.h>
-#include <Atomic/IO/Log.h>
-#include <Atomic/IO/File.h>
-#include <Atomic/Graphics/Graphics.h>
-
-#include "../EditorMode/AEEditorEvents.h"
-#include "AEPreferences.h"
-
-using namespace rapidjson;
-
-namespace AtomicEditor
-{
-
-AEPreferences::AEPreferences(Context* context) :
-    Object(context)
-{
-    context->RegisterSubsystem(this);
-
-    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(AEPreferences, HandleEditorShutdown));
-
-    Read();
-}
-
-AEPreferences::~AEPreferences()
-{
-
-}
-
-String AEPreferences::GetPreferencesFullPath()
-{
-    FileSystem* fs = GetSubsystem<FileSystem>();
-    String filepath = fs->GetAppPreferencesDir("AtomicEditor", "Preferences");
-    filepath += "prefs.json";
-    return filepath;
-}
-
-void AEPreferences::Clear()
-{
-    recentProjects_.Clear();
-}
-
-void AEPreferences::Read()
-{
-    rapidjson::Document document;
-
-    String filepath = GetPreferencesFullPath();
-
-    File jsonFile(context_, filepath);
-
-    if (!jsonFile.IsOpen())
-        return;
-
-    String json;
-    jsonFile.ReadText(json);
-
-    if (!json.Length())
-        return;
-
-    if (document.Parse<0>(json.CString()).HasParseError())
-    {
-        LOGERRORF("Could not parse JSON data from %s", filepath.CString());
-        return;
-    }
-
-    Clear();
-
-    const Value::Member* recent_files = document.FindMember("recent_files");
-    if (recent_files && recent_files->value.IsArray())
-    {
-        for (Value::ConstValueIterator itr = recent_files->value.Begin(); itr != recent_files->value.End(); itr++)
-        {
-             if (!(*itr).IsString())
-                 continue;
-
-            String path(itr->GetString());
-            recentProjects_.Push(path.CString());
-        }
-    }
-
-    const Value::Member* android_sdk_path = document.FindMember("android_sdk_path");
-    if (android_sdk_path && android_sdk_path->value.IsString())
-        androidSDKPath_ = android_sdk_path->value.GetString();
-
-    const Value::Member* jdk_root_path = document.FindMember("jdk_root_path");
-    if (jdk_root_path && jdk_root_path->value.IsString())
-        jdkRootPath_ = jdk_root_path->value.GetString();
-
-    const Value::Member* ant_path = document.FindMember("ant_path");
-    if (ant_path && ant_path->value.IsString())
-        antPath_ = ant_path->value.GetString();
-
-    UpdateRecentFiles(false);
-
-}
-
-void AEPreferences::Write()
-{
-    String filepath = GetPreferencesFullPath();
-
-    FILE* file = fopen(filepath.CString(), "w");
-
-    if (!file)
-        return;
-
-    Graphics* graphics = GetSubsystem<Graphics>();
-
-    IntVector2 pos(-1, -1);
-
-    int width = -1;
-    int height = -1;
-
-    if (graphics && !graphics->GetFullscreen())
-    {
-        pos = graphics->GetWindowPosition();
-        width = graphics->GetWidth();
-        height = graphics->GetHeight();
-    }
-
-    rapidjson::FileStream s(file);
-    rapidjson::PrettyWriter<rapidjson::FileStream> writer(s);
-
-    writer.StartObject();
-
-    // recent files
-    writer.String("recent_files");
-    writer.StartArray();
-    for (unsigned i = 0; i < recentProjects_.Size(); i++)
-        writer.String(recentProjects_[i].CString());
-    writer.EndArray();
-
-    writer.String("android_sdk_path");
-    writer.String(androidSDKPath_.CString());
-
-    writer.String("jdk_root_path");
-    writer.String(jdkRootPath_.CString());
-
-    writer.String("ant_path");
-    writer.String(antPath_.CString());
-
-    writer.String("window_pos_x");
-    writer.Int(pos.x_);
-    writer.String("window_pos_y");
-    writer.Int(pos.y_);
-    writer.String("window_width");
-    writer.Int(width);
-    writer.String("window_height");
-    writer.Int(height);
-
-    writer.EndObject();
-
-    fclose(file);
-
-}
-
-void AEPreferences::UpdateRecentFiles(bool write)
-{
-    FileSystem* fileSystem = GetSubsystem<FileSystem>();
-    Vector<String> recentProjects;
-
-    for (unsigned i = 0; i < recentProjects_.Size(); i++)
-    {
-        String path = recentProjects_[i];
-
-        if (!fileSystem->FileExists(path))
-            continue;
-
-
-        recentProjects.Push(path);
-
-        if (recentProjects.Size() == 10)
-            break;
-    }
-
-    recentProjects_ = recentProjects;
-
-    if (write)
-        Write();
-}
-
-void AEPreferences::RegisterRecentProject(const String& fullpath)
-{
-    if (recentProjects_.Contains(fullpath))
-    {
-        recentProjects_.Remove(fullpath);
-    }
-
-    recentProjects_.Insert(0, fullpath);
-
-
-    UpdateRecentFiles();
-
-}
-
-bool AEPreferences::ReadStartupPrefs(Context *context, StartupPreferences& prefs)
-{
-
-    FileSystem* fileSystem = context->GetSubsystem<FileSystem>();
-    String filepath = fileSystem->GetAppPreferencesDir("AtomicEditor", "Preferences");
-    filepath += "prefs.json";
-
-    if (!fileSystem->FileExists(filepath))
-        return false;
-
-    SharedPtr<File> file(new File(context, filepath, FILE_READ));
-
-    if (!file->IsOpen())
-        return false;
-
-    String json;
-    file->ReadText(json);
-
-    if (!json.Length())
-        return false;
-
-    rapidjson::Document document;
-
-    if (document.Parse<0>(json.CString()).HasParseError())
-    {
-        return false;
-    }
-
-    bool success = true;
-
-    const Value::Member* imember = document.FindMember("window_pos_x");
-    if (imember && imember->value.IsInt())
-    {
-        prefs.windowPos.x_ = imember->value.GetInt();
-    }
-    else
-    {
-        success = false;
-    }
-
-    imember = document.FindMember("window_pos_y");
-    if (imember && imember->value.IsInt())
-    {
-        prefs.windowPos.y_ = imember->value.GetInt();
-    }
-    else
-    {
-        success = false;
-    }
-
-    imember = document.FindMember("window_width");
-    if (imember && imember->value.IsInt())
-    {
-        prefs.windowWidth = imember->value.GetInt();
-    }
-    else
-    {
-        success = false;
-    }
-
-    imember = document.FindMember("window_height");
-    if (imember && imember->value.IsInt())
-    {
-        prefs.windowHeight = imember->value.GetInt();
-    }
-    else
-    {
-        success = false;
-    }
-
-    if (prefs.windowHeight < 128 || prefs.windowWidth < 128)
-        return false;
-
-    return success;
-
-}
-
-void AEPreferences::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
-{
-    context_->RemoveSubsystem(GetType());
-}
-
-}

+ 0 - 68
Source/AtomicEditor/Application/AEPreferences.h

@@ -1,68 +0,0 @@
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
-// Please see LICENSE.md in repository root for license information
-// https://github.com/AtomicGameEngine/AtomicGameEngine
-
-#pragma once
-
-#include <Atomic/Core/Object.h>
-#include <Atomic/IO/FileSystem.h>
-
-using namespace Atomic;
-
-namespace AtomicEditor
-{
-
-class AEPreferences : public Object
-{
-
-    OBJECT(AEPreferences);
-
-public:
-
-    struct StartupPreferences
-    {
-        IntVector2 windowPos;
-        int windowWidth;
-        int windowHeight;
-    };
-
-    /// Construct.
-    AEPreferences(Context* context);
-    /// Destruct.
-    ~AEPreferences();
-
-    void RegisterRecentProject(const String& fullpath);
-    const Vector<String>& GetRecentProjects() { return recentProjects_; }
-
-    void SetAndroidSDKPath(const String& path) { androidSDKPath_ = path; Write(); }
-    void SetAntPath(const String& path) { antPath_ = path; Write(); }
-    void SetJDKRootPath(const String& path) { jdkRootPath_ = path; Write(); }
-
-    String GetAndroidSDKPath() { return AddTrailingSlash(androidSDKPath_); }
-    String GetJDKRootPath() { return AddTrailingSlash(jdkRootPath_); }
-    String GetAntPath() { return AddTrailingSlash(antPath_); }
-
-    void Read();
-    void Write();
-
-    static bool ReadStartupPrefs(Context* context, StartupPreferences& prefs);
-
-    void UpdateRecentFiles(bool write = true);
-
-private:
-
-     void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
-
-    void Clear();
-    String GetPreferencesFullPath();
-
-    String androidSDKPath_;
-    String jdkRootPath_;
-    String antPath_;
-
-    String lastProjectFullPath_;
-    Vector<String> recentProjects_;    
-};
-
-
-}

+ 0 - 8
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -11,8 +11,6 @@
 
 #include <AtomicJS/Javascript/JSIPCEvents.h>
 
-#include "../Application/AEPreferences.h"
-
 #include "AEEditorMode.h"
 
 using namespace ToolCore;
@@ -31,12 +29,6 @@ EditorMode::~EditorMode()
 
 }
 
-AEPreferences* EditorMode::GetPreferences()
-{
-    return GetSubsystem<AEPreferences>();
-
-}
-
 void EditorMode::HandleIPCWorkerStarted(StringHash eventType, VariantMap& eventData)
 {
     VariantMap startupData;

+ 0 - 6
Source/AtomicEditor/EditorMode/AEEditorMode.h

@@ -15,8 +15,6 @@ using namespace Atomic;
 namespace AtomicEditor
 {
 
-class AEPreferences;
-
 /// EditorMode subsystem
 class EditorMode : public Object
 {
@@ -30,10 +28,6 @@ public:
 
     bool PlayProject();
 
-
-    AEPreferences* GetPreferences();
-
-
 private:
 
     void HandleIPCWorkerStarted(StringHash eventType, VariantMap& eventData);

+ 0 - 5
Source/AtomicEditor/Javascript/AEEditorJS.cpp

@@ -1,8 +1,6 @@
 
 #include <AtomicJS/Javascript/JSVM.h>
 
-#include "../Application/AEPreferences.h"
-
 #include "../EditorMode/AEEditorMode.h"
 
 using namespace Atomic;
@@ -19,9 +17,6 @@ void jsapi_init_editor(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
 
-    duk_push_object(ctx);
-    duk_put_global_string(ctx, "Editor");
-
     jsb_package_editor_init(vm);
 
     duk_get_global_string(ctx, "Atomic");

+ 33 - 46
Source/AtomicJS/Javascript/JSAPI.cpp

@@ -58,28 +58,28 @@ void js_class_declare_internal(JSVM* vm, void* uniqueClassID, const char* packag
 {
     duk_context* ctx = vm->GetJSContext();
 
-    // stash a lookup from the uniqueID to the package name
-    // (NULL) == non-object, so core "Atomic" package
+    // uniqueClassID must be non-null
+    assert(uniqueClassID);
 
-    if (uniqueClassID)
-    {
-        duk_push_heap_stash(ctx);
-        duk_push_pointer(ctx, uniqueClassID);
-        duk_push_string(ctx, package);
-        duk_put_prop(ctx, -3);
-        duk_pop(ctx);
-    }
-    
-    if (!duk_get_global_string(ctx, package))
-    {
-        // Failure leaves undefined on the stack
-        duk_pop(ctx);
-        // Create a new namespace object for the package
-        duk_push_object(ctx);
-        duk_put_global_string(ctx, package);
-        duk_get_global_string(ctx, package);
-    }
+    // stash a lookup from the uniqueID to the package and class name
+
+    duk_push_heap_stash(ctx);
+    duk_push_pointer(ctx, uniqueClassID);
 
+    duk_push_object(ctx);
+    duk_push_string(ctx, package);
+    duk_put_prop_index(ctx, -2, 0);
+    duk_push_string(ctx, classname);
+    duk_put_prop_index(ctx, -2, 1);
+
+    // store class object into uniqueClassID key
+    duk_put_prop(ctx, -3);
+
+    // pop heap stash
+    duk_pop(ctx);
+
+    // store the constructor
+    duk_get_global_string(ctx, package);
     duk_push_c_function(ctx, constructor, DUK_VARARGS);
     duk_put_prop_string(ctx, -2, classname);
     duk_pop(ctx);
@@ -376,15 +376,11 @@ void js_push_variant(duk_context *ctx, const Variant& v)
 {
     VariantType type = v.GetType();
     RefCounted* ref;
-    Object* object;
     Vector2 vector2 = Vector2::ZERO;
     Vector3 vector3 = Vector3::ZERO;
     Vector4 vector4 = Vector4::ZERO;
     Color color = Color::BLACK;
 
-    void* uniqueClassID = NULL;
-    const char* package = NULL;
-
     switch (type)
     {
     case VAR_NONE:
@@ -398,38 +394,29 @@ void js_push_variant(duk_context *ctx, const Variant& v)
 
         ref = v.GetPtr();
 
-        if (!ref || !ref->IsObject() || !ref->Refs())
+        // if we're null or don't have any refs, return null
+        if (!ref || !ref->Refs())
         {
             duk_push_null(ctx);
             break;
         }
 
-        object = (Object*) ref;
-
-
         // check that class is supported
-        uniqueClassID = (void *) object->GetTypeName().CString();
         duk_push_heap_stash(ctx);
-        duk_push_pointer(ctx, uniqueClassID);
+        duk_push_pointer(ctx, (void*) ref->GetClassID());
         duk_get_prop(ctx, -2);
-        package = duk_to_string(ctx, -1);
-        duk_pop_2(ctx);
-
-        // check that class is supported
-        duk_get_global_string(ctx, package);
-
-        // will not handle renamed classes!
-        duk_get_prop_string(ctx, -1, object->GetTypeName().CString());
-
-        if (!duk_is_function(ctx, -1))
-            object = NULL;
-
-        duk_pop_n(ctx, 2);
 
-        if (object)
-            js_push_class_object_instance(ctx, object);
-        else
+        if (!duk_is_object(ctx, -1))
+        {
+            duk_pop_2(ctx);
             duk_push_undefined(ctx);
+        }
+        else
+        {
+            duk_pop_2(ctx);
+            js_push_class_object_instance(ctx, ref);
+        }
+
         break;
 
     case VAR_BOOL:

+ 1 - 2
Source/AtomicJS/Javascript/JSAPI.h

@@ -28,8 +28,7 @@ void js_class_declare_internal(JSVM* vm, void* uniqueClassID, const char* packag
 template<typename T>
 void js_class_declare(JSVM* vm, const char* package, const char* classname, duk_c_function constructor)
 {
-    void* uniqueID = (void*) T::GetTypeNameStatic().CString();
-    js_class_declare_internal(vm, uniqueID, package, classname, constructor);
+    js_class_declare_internal(vm, (void*) T::GetClassIDStatic(), package, classname, constructor);
 }
 
 void js_constructor_basecall(duk_context* ctx, const char* package, const char* baseclass);

+ 5 - 6
Source/AtomicJS/Javascript/JSVM.cpp

@@ -57,12 +57,12 @@ void JSVM::InitJSContext()
 {
     ctx_ = duk_create_heap_default();
 
-    // create root Atomic Object
-    duk_push_global_object(ctx_);
-    duk_push_object(ctx_);
+    jsapi_init_atomic(this);
+
+    // register whether we are in the editor
+    duk_get_global_string(ctx_, "Atomic");
     duk_push_boolean(ctx_, context_->GetEditorContext() ? 1 : 0);
     duk_put_prop_string(ctx_, -2, "editor");
-    duk_put_prop_string(ctx_, -2, "Atomic");
     duk_pop(ctx_);
 
     duk_push_global_stash(ctx_);
@@ -71,8 +71,7 @@ void JSVM::InitJSContext()
     duk_pop(ctx_);
 
     js_init_require(this);
-    js_init_jsplugin(this);
-    jsapi_init_atomic(this);
+    js_init_jsplugin(this);    
 
     ui_ = new JSUI(context_);
 

+ 14 - 18
Source/AtomicJS/Javascript/JSVM.h

@@ -225,26 +225,22 @@ inline bool js_push_class_object_instance(duk_context* ctx, const RefCounted *in
         return true;
     }
 
-    // will not handle renamed classes
-    if (instance->IsObject())
-    {
-        Object *obj = (Object*) instance;
+    duk_push_heap_stash(ctx);
+    duk_push_pointer(ctx, (void*) instance->GetClassID());
+    duk_get_prop(ctx, -2);
 
-        void* uniqueClassID = (void *) obj->GetTypeName().CString();
-        duk_push_heap_stash(ctx);
-        duk_push_pointer(ctx, uniqueClassID);
-        duk_get_prop(ctx, -2);
-        const char* package = duk_require_string(ctx, -1);
-        duk_pop_2(ctx);
+    // if this is tripped, means the class hasn't been registered and shouldn't be trying to push it
+    assert(duk_is_object(ctx, -1));
 
-        duk_get_global_string(ctx, package);
-        duk_get_prop_string(ctx, -1, ((Object*)instance)->GetTypeName().CString());
-    }
-    else
-    {
-        duk_get_global_string(ctx, "Atomic");
-        duk_get_prop_string(ctx, -1, classname);
-    }
+    duk_get_prop_index(ctx, -1, 0);
+    const char* package = duk_require_string(ctx, -1);
+    duk_get_prop_index(ctx, -2, 1);
+    const char* jclassname = duk_require_string(ctx, -1);
+
+    duk_set_top(ctx, top);
+
+    duk_get_global_string(ctx, package);
+    duk_get_prop_string(ctx, -1, jclassname);
 
     duk_push_pointer(ctx, (void*) instance);
     duk_new(ctx, 1);

+ 0 - 4
Source/AtomicPlayerJS/AtomicPlayerJS.cpp

@@ -19,10 +19,6 @@ void jsapi_init_atomicplayer(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
 
-    // setup the global AtomicPlayer object
-    duk_push_object(ctx);
-    duk_put_global_string(ctx, "AtomicPlayer");
-
     jsb_package_atomicplayer_init(vm);
 
     duk_get_global_string(ctx, "Atomic");

+ 14 - 2
Source/ToolCore/Assets/Asset.cpp

@@ -25,7 +25,8 @@ namespace ToolCore
 Asset::Asset(Context* context) :
     Object(context),
     dirty_(false),
-    isFolder_(false)
+    isFolder_(false),
+    fileTimestamp_(0xffffffff)
 {
 
 }
@@ -35,6 +36,16 @@ Asset::~Asset()
 
 }
 
+void Asset::UpdateFileTimestamp()
+{
+    FileSystem* fs = GetSubsystem<FileSystem>();
+
+    if (fs->FileExists(path_))
+    {
+        fileTimestamp_ = fs->GetLastModifiedTime(path_);
+    }
+}
+
 Asset* Asset::GetParent()
 {
     AssetDatabase* db = GetSubsystem<AssetDatabase>();
@@ -90,10 +101,11 @@ bool Asset::CheckCacheFile()
 
 bool Asset::Import()
 {
+
     if (importer_.Null())
         return true;
 
-    return importer_->Import(guid_);
+    return importer_->Import();
 }
 
 bool Asset::Preload()

+ 12 - 0
Source/ToolCore/Assets/Asset.h

@@ -48,6 +48,12 @@ public:
     void SetDirty(bool dirty) { dirty_ = dirty; }
     bool IsDirty() const { return dirty_; }
 
+    /// Get the last timestamp as seen by the AssetDatabase
+    unsigned GetFileTimestamp() { return fileTimestamp_; }
+
+    /// Sets the time stamp to the asset files current time
+    void UpdateFileTimestamp();
+
     // get the .asset filename
     String GetDotAssetFilename();
 
@@ -74,6 +80,12 @@ private:
     bool dirty_;
     bool isFolder_;
 
+    // the current timestamp of the asset as seen by the asset database
+    // used to catch when the asset needs to be marked dirty when notified
+    // that the file has changed (the resource system will send a changed file
+    // event when the resource is first added)
+    unsigned fileTimestamp_;
+
     SharedPtr<JSONFile> json_;
     SharedPtr<AssetImporter> importer_;
 };

+ 30 - 8
Source/ToolCore/Assets/AssetDatabase.cpp

@@ -22,8 +22,7 @@ namespace ToolCore
 AssetDatabase::AssetDatabase(Context* context) : Object(context)
 {
     SubscribeToEvent(E_PROJECTLOADED, HANDLER(AssetDatabase, HandleProjectLoaded));
-    SubscribeToEvent(E_PROJECTUNLOADED, HANDLER(AssetDatabase, HandleProjectUnloaded));
-    SubscribeToEvent(E_FILECHANGED, HANDLER(AssetDatabase, HandleFileChanged));
+    SubscribeToEvent(E_PROJECTUNLOADED, HANDLER(AssetDatabase, HandleProjectUnloaded));    
 }
 
 AssetDatabase::~AssetDatabase()
@@ -141,6 +140,13 @@ Asset* AssetDatabase::GetAssetByPath(const String& path)
 
 void AssetDatabase::PruneOrphanedDotAssetFiles()
 {
+
+    if (project_.Null())
+    {
+        LOGDEBUG("AssetDatabase::PruneOrphanedDotAssetFiles - called without project loaded");
+        return;
+    }
+
     FileSystem* fs = GetSubsystem<FileSystem>();
 
     const String& resourcePath = project_->GetResourcePath();
@@ -189,6 +195,9 @@ void AssetDatabase::AddAsset(SharedPtr<Asset>& asset)
 
     assets_.Push(asset);
 
+    // set to the current timestamp
+    asset->UpdateFileTimestamp();
+
     VariantMap eventData;
     eventData[ResourceAdded::P_GUID] = asset->GetGUID();
     SendEvent(E_RESOURCEADDED, eventData);
@@ -241,6 +250,7 @@ bool AssetDatabase::ImportDirtyAssets()
         assets[i]->Import();
         assets[i]->Save();
         assets[i]->dirty_ = false;
+        assets[i]->UpdateFileTimestamp();
     }
 
     return assets.Size() != 0;
@@ -409,6 +419,8 @@ void AssetDatabase::HandleProjectLoaded(StringHash eventType, VariantMap& eventD
     cache->AddResourceDir(GetCachePath());
 
     Scan();
+
+    SubscribeToEvent(E_FILECHANGED, HANDLER(AssetDatabase, HandleFileChanged));
 }
 
 void AssetDatabase::HandleProjectUnloaded(StringHash eventType, VariantMap& eventData)
@@ -418,6 +430,8 @@ void AssetDatabase::HandleProjectUnloaded(StringHash eventType, VariantMap& even
     assets_.Clear();
     usedGUID_.Clear();
     project_ = 0;
+
+    UnsubscribeFromEvent(E_FILECHANGED);
 }
 
 void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventData)
@@ -431,6 +445,14 @@ void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventDat
 
     SplitPath(fullPath, pathName, fileName, ext);
 
+    // ignore changes in the Cache resource dir
+    if (fullPath == GetCachePath() || pathName.StartsWith(GetCachePath()))
+        return;
+
+    // don't care about directories and asset file changes
+    if (fs->DirExists(fullPath) || ext == ".asset")
+        return;
+
     Asset* asset = GetAssetByPath(fullPath);
 
     if (!asset && fs->FileExists(fullPath))
@@ -441,19 +463,19 @@ void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventDat
 
     if (asset)
     {
-        if(!fs->FileExists(fullPath))
+        if(!fs->Exists(fullPath))
         {
             DeleteAsset(asset);
         }
         else
         {
-            asset->SetDirty(true);
-            Scan();
+            if (asset->GetFileTimestamp() != fs->GetLastModifiedTime(asset->GetPath()))
+            {
+                asset->SetDirty(true);
+                Scan();
+            }
         }
-
     }
-
-
 }
 
 

+ 4 - 2
Source/ToolCore/Assets/AssetImporter.h

@@ -14,6 +14,8 @@ class Asset;
 /// deals with .asset files
 class AssetImporter : public Object
 {
+    friend class Asset;
+
     OBJECT(AssetImporter);
 
 public:
@@ -28,8 +30,6 @@ public:
 
     virtual void SetDefaults();
 
-    /// Imports to cached data
-    virtual bool Import(const String& guid) = 0;
     virtual bool Preload() { return true; }
 
     Asset* GetAsset() { return asset_; }
@@ -38,6 +38,8 @@ public:
 
 protected:
 
+    virtual bool Import() { return true; }
+
     WeakPtr<Asset> asset_;
     JSONValue jsonRoot_;   
     bool requiresCacheFile_;

+ 1 - 7
Source/ToolCore/Assets/AudioImporter.cpp

@@ -24,14 +24,8 @@ void AudioImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool AudioImporter::Import(const String& guid)
+bool AudioImporter::Import()
 {
-    AssetDatabase* db = GetSubsystem<AssetDatabase>();
-    Asset* asset = db->GetAssetByGUID(guid);
-
-    if (!asset)
-        return false;
-
     return true;
 }
 

+ 2 - 2
Source/ToolCore/Assets/AudioImporter.h

@@ -17,10 +17,10 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 1 - 7
Source/ToolCore/Assets/FolderImporter.cpp

@@ -21,14 +21,8 @@ void FolderImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool FolderImporter::Import(const String& guid)
+bool FolderImporter::Import()
 {
-    AssetDatabase* db = GetSubsystem<AssetDatabase>();
-    Asset* asset = db->GetAssetByGUID(guid);
-
-    if (!asset)
-        return false;
-
     return true;
 }
 

+ 2 - 2
Source/ToolCore/Assets/FolderImporter.h

@@ -17,10 +17,10 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 1 - 1
Source/ToolCore/Assets/JavascriptImporter.cpp

@@ -27,7 +27,7 @@ void JavascriptImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool JavascriptImporter::Import(const String& guid)
+bool JavascriptImporter::Import()
 {
     isComponentFile_ = false;
 

+ 2 - 2
Source/ToolCore/Assets/JavascriptImporter.h

@@ -19,10 +19,10 @@ public:
 
     bool IsComponentFile() { return isComponentFile_; }
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     bool isComponentFile_;
 
     virtual bool LoadSettingsInternal();

+ 2 - 2
Source/ToolCore/Assets/MaterialImporter.cpp

@@ -12,7 +12,7 @@ namespace ToolCore
 
 MaterialImporter::MaterialImporter(Context* context, Asset* asset) : AssetImporter(context, asset)
 {
-
+    requiresCacheFile_ = false;
 }
 
 MaterialImporter::~MaterialImporter()
@@ -25,7 +25,7 @@ void MaterialImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool MaterialImporter::Import(const String& guid)
+bool MaterialImporter::Import()
 {
     return true;
 }

+ 2 - 2
Source/ToolCore/Assets/MaterialImporter.h

@@ -17,12 +17,12 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
-
     void SaveMaterial();
 
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 2 - 8
Source/ToolCore/Assets/ModelImporter.cpp

@@ -180,15 +180,9 @@ bool ModelImporter::ImportAnimations()
     return true;
 }
 
-bool ModelImporter::Import(const String& guid)
+bool ModelImporter::Import()
 {
-    AssetDatabase* db = GetSubsystem<AssetDatabase>();
-    Asset* asset = db->GetAssetByGUID(guid);
-
-    if (!asset)
-        return false;
-
-    String modelAssetFilename = asset->GetPath();
+    String modelAssetFilename = asset_->GetPath();
 
     importNode_ = new Node(context_);
 

+ 2 - 2
Source/ToolCore/Assets/ModelImporter.h

@@ -65,10 +65,10 @@ public:
 
     AnimationImportInfo* GetAnimationInfo(unsigned index) { return animationInfo_[index]; }
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     bool ImportModel();
     bool ImportAnimations();
     bool ImportAnimation(const String &filename, const String& name, float startTime=-1.0f, float endTime=-1.0f);

+ 1 - 1
Source/ToolCore/Assets/PrefabImporter.cpp

@@ -74,7 +74,7 @@ void PrefabImporter::HandlePrefabSave(StringHash eventType, VariantMap& eventDat
 
 }
 
-bool PrefabImporter::Import(const String& guid)
+bool PrefabImporter::Import()
 {
     FileSystem* fs = GetSubsystem<FileSystem>();
 

+ 2 - 1
Source/ToolCore/Assets/PrefabImporter.h

@@ -22,11 +22,12 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
     virtual bool Preload();
 
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 1 - 7
Source/ToolCore/Assets/SceneImporter.cpp

@@ -21,14 +21,8 @@ void SceneImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool SceneImporter::Import(const String& guid)
+bool SceneImporter::Import()
 {
-    AssetDatabase* db = GetSubsystem<AssetDatabase>();
-    Asset* asset = db->GetAssetByGUID(guid);
-
-    if (!asset)
-        return false;
-
     return true;
 }
 

+ 2 - 2
Source/ToolCore/Assets/SceneImporter.h

@@ -17,10 +17,10 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 4 - 8
Source/ToolCore/Assets/TextureImporter.cpp

@@ -24,16 +24,12 @@ void TextureImporter::SetDefaults()
     AssetImporter::SetDefaults();
 }
 
-bool TextureImporter::Import(const String& guid)
+bool TextureImporter::Import()
 {
     AssetDatabase* db = GetSubsystem<AssetDatabase>();
-    Asset* asset = db->GetAssetByGUID(guid);
-
-    if (!asset)
-        return false;
 
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SharedPtr<Image> image = cache->GetTempResource<Image>(asset->GetPath());
+    SharedPtr<Image> image = cache->GetTempResource<Image>(asset_->GetPath());
 
     if (image.Null())
         return false;
@@ -45,10 +41,10 @@ bool TextureImporter::Import(const String& guid)
 
     // not sure entirely what we want to do here, though if the cache file doesn't exist
     // will reimport
-    image->SavePNG(cachePath + asset->GetGUID());
+    image->SavePNG(cachePath + asset_->GetGUID());
 
     // save thumbnail
-    image->SavePNG(cachePath + asset->GetGUID() + "_thumbnail.png");
+    image->SavePNG(cachePath + asset_->GetGUID() + "_thumbnail.png");
 
     return true;
 }

+ 2 - 2
Source/ToolCore/Assets/TextureImporter.h

@@ -17,10 +17,10 @@ public:
 
     virtual void SetDefaults();
 
-    bool Import(const String& guid);
-
 protected:
 
+    bool Import();
+
     virtual bool LoadSettingsInternal();
     virtual bool SaveSettingsInternal();
 

+ 1 - 5
Source/ToolCore/JSBind/JSBModuleWriter.cpp

@@ -52,11 +52,7 @@ void JSBModuleWriter::WriteClassDeclaration(String& source)
         if (klass->IsNumberArray())
             continue;
 
-        if (klass->IsObject())
-            source.AppendWithFormat("   js_class_declare<%s>(vm, \"%s\", \"%s\", jsb_constructor_%s);\n", klass->GetNativeName().CString(), packageName.CString(), klass->GetName().CString(), klass->GetName().CString());
-        else
-            source.AppendWithFormat("   js_class_declare_internal(vm, NULL, \"%s\", \"%s\", jsb_constructor_%s);\n", packageName.CString(), klass->GetName().CString(), klass->GetName().CString());
-
+        source.AppendWithFormat("   js_class_declare<%s>(vm, \"%s\", \"%s\", jsb_constructor_%s);\n", klass->GetNativeName().CString(), packageName.CString(), klass->GetName().CString(), klass->GetName().CString());
 
         if (klass->HasProperties())
         {

+ 8 - 2
Source/ToolCore/JSBind/JSBPackageWriter.cpp

@@ -103,15 +103,21 @@ void JSBPackageWriter::GenerateSource(String& sourceOut)
 
     source.AppendWithFormat("\n\nstatic void jsb_package_%s_preinit(JSVM* vm)\n{", packageLower.CString());
 
+
+    source.Append("\n    // Create the global package object\n");
+    source.Append("    duk_context* ctx = vm->GetJSContext();\n");
+    source.Append("    duk_push_object(ctx);\n");
+    source.AppendWithFormat("    duk_put_global_string(ctx, \"%s\");\n", package_->GetName().CString());
+
     for (unsigned i = 0; i < package_->modules_.Size(); i++)
     {
         JSBModule* module = package_->modules_.At(i);
 
-        String moduleLower = module->GetName().ToLower();
-
         if (module->Requires("3D"))
             source += "\n#ifdef ATOMIC_3D";
 
+        String moduleLower = module->GetName().ToLower();
+
         source.AppendWithFormat("\n   jsb_package_%s_preinit_%s(vm);", packageLower.CString(), moduleLower.CString());
 
         if (module->Requires("3D"))

+ 0 - 3
Source/ToolCoreJS/ToolCoreJS.cpp

@@ -103,9 +103,6 @@ void jsapi_init_toolcore(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
 
-    duk_push_object(ctx);
-    duk_put_global_string(ctx, "ToolCore");
-
     jsb_package_toolcore_init(vm);
 
     duk_get_global_string(ctx, "ToolCore");