Browse Source

- Created individual XML and Shader Resource editor types
- Code Review cleanup

JohnnyWahib 9 years ago
parent
commit
d8fd9cd44a

+ 4 - 0
Script/AtomicEditor/ui/ResourceEditorProvider.ts

@@ -26,6 +26,8 @@ import Scene3dResourceEditorBuilder from "./resourceEditors/Scene3dResourceEdito
 import TextFileResourceEditorBuilder from "./resourceEditors/TextFileResourceEditorBuilder";
 import TurboBadgerResourceEditorBuilder from "./resourceEditors/TurboBadgerResourceEditorBuilder";
 import TypescriptResourceEditorBuilder from "./resourceEditors/TypescriptResourceEditorBuilder";
+import XMLResourceEditorBuilder from "./resourceEditors/XMLResourceEditorBuilder";
+import ShaderResourceEditorBuilder from "./resourceEditors/ShaderResourceEditorBuilder";
 
 export default class ResourceEditorProvider {
     private standardEditorRegistry: Editor.Extensions.ResourceEditorBuilder[] = [];
@@ -88,6 +90,8 @@ export default class ResourceEditorProvider {
         this.registerStandardEditor(new JsonResourceEditorBuilder());
         this.registerStandardEditor(new TypescriptResourceEditorBuilder());
         this.registerStandardEditor(new Scene3dResourceEditorBuilder());
+        this.registerStandardEditor(new XMLResourceEditorBuilder());
+        this.registerStandardEditor(new ShaderResourceEditorBuilder());
 
         // this overrides the test resource editor so need to put it in the custom bucket
         this.registerCustomEditor(new TurboBadgerResourceEditorBuilder());

+ 2 - 2
Script/AtomicEditor/ui/frames/inspector/MaterialInspector.ts

@@ -425,7 +425,7 @@ class MaterialInspector extends ScriptWidget {
         var resourcePath = ToolCore.toolSystem.project.getResourcePath();
         var TechniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
 
-        for (var i in TechniqueAssets) {
+        for (var i = 0; i < TechniqueAssets.length; i++) {
 
             var asset = TechniqueAssets[i];
 
@@ -453,7 +453,7 @@ class MaterialInspector extends ScriptWidget {
 
         var techniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
 
-        for (var i in techniqueAssets) {
+        for (var i = 0; i < techniqueAssets.length; i++) {
 
             var asset = techniqueAssets[i];
 

+ 35 - 0
Script/AtomicEditor/ui/resourceEditors/ShaderResourceEditorBuilder.ts

@@ -0,0 +1,35 @@
+//
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
+//
+// 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.
+//
+
+import {AbstractTextResourceEditorBuilder} from "./AbstractTextResourceEditorBuilder";
+
+export default class ShaderResourceEditorBuilder extends AbstractTextResourceEditorBuilder {
+
+    constructor() {
+        super();
+    }
+
+    canHandleResource(resourcePath: string) : boolean {
+        var ext = Atomic.getExtension(resourcePath).toLowerCase();
+        return ext == ".hlsl" || ext == ".glsl";
+    }
+}

+ 1 - 1
Script/AtomicEditor/ui/resourceEditors/TextFileResourceEditorBuilder.ts

@@ -30,6 +30,6 @@ export default class TextResourceEditorBuilder extends AbstractTextResourceEdito
 
     canHandleResource(resourcePath: string) : boolean {
         var ext = Atomic.getExtension(resourcePath).toLowerCase();
-        return ext == ".txt" || ext == ".hlsl" || ext == ".xml";
+        return ext == ".txt";
     }
 }

+ 35 - 0
Script/AtomicEditor/ui/resourceEditors/XMLResourceEditorBuilder.ts

@@ -0,0 +1,35 @@
+//
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
+//
+// 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.
+//
+
+import {AbstractTextResourceEditorBuilder} from "./AbstractTextResourceEditorBuilder";
+
+export default class XMLResourceEditorBuilder extends AbstractTextResourceEditorBuilder {
+
+    constructor() {
+        super();
+    }
+
+    canHandleResource(resourcePath: string) : boolean {
+        var ext = Atomic.getExtension(resourcePath).toLowerCase();
+        return ext == ".xml";
+    }
+}

+ 2 - 0
Script/tsconfig.json

@@ -102,6 +102,8 @@
         "./AtomicEditor/ui/resourceEditors/TextFileResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/TurboBadgerResourceEditorBuilder.ts",
         "./AtomicEditor/ui/resourceEditors/TypescriptResourceEditorBuilder.ts",
+        "./AtomicEditor/ui/resourceEditors/XMLResourceEditorBuilder.ts",
+        "./AtomicEditor/ui/resourceEditors/ShaderResourceEditorBuilder.ts",
         "./AtomicEditor/ui/ScriptWidget.ts",
         "./AtomicEditor/ui/Shortcuts.ts",
         "./AtomicEditor/ui/UIEvents.ts",