瀏覽代碼

hide.ui.Ide -> hide.Ide

Nicolas Cannasse 7 年之前
父節點
當前提交
f780c3ed98

+ 19 - 4
.vscode/tasks.json

@@ -1,7 +1,22 @@
 {
     "version": "2.0.0",
-    "command": "haxe",
-    "args": ["hide.hxml","-cmd","bin\\hide.cmd"],
-    "problemMatcher": "$haxe",
-    "showOutput": "never"
+    "tasks": [
+        {
+            "label": "Compile & Run",
+            "command": "haxe",
+            "args": [
+                "hide.hxml",
+                "-cmd",
+                "bin\\hide.cmd"
+            ],
+            "problemMatcher": "$haxe",
+            "group": {
+                "kind": "build",
+                "isDefault": true
+            },
+            "presentation": {
+                "reveal": "never"
+            }
+        }
+    ],
 }

+ 1 - 2
hide.hxml

@@ -5,9 +5,8 @@
 -lib castle
 -cp libs
 -js bin/hide.js
--main hide.ui.Ide
+-main hide.Ide
 -D hscriptPos
--D old-error-format
 -D multidriver
 -D editor
 -dce no

+ 10 - 9
hide/ui/Ide.hx → hide/Ide.hx

@@ -1,4 +1,5 @@
-package hide.ui;
+package hide;
+import hide.ui.Props;
 
 class Ide {
 
@@ -26,7 +27,7 @@ class Ide {
 		user : Props,
 		current : Props,
 	};
-	var ideProps(get, never) : Props.HideProps;
+	var ideProps(get, never) : hide.ui.Props.HideProps;
 
 	var window : nw.Window;
 	var layout : golden.Layout;
@@ -34,7 +35,7 @@ class Ide {
 	var currentLayout : { name : String, state : Dynamic };
 	var maximized : Bool;
 	var updates : Array<Void->Void> = [];
-	var views : Array<View<Dynamic>> = [];
+	var views : Array<hide.ui.View<Dynamic>> = [];
 
 	var renderers : Array<h3d.mat.MaterialSetup>;
 
@@ -75,7 +76,7 @@ class Ide {
 			window.close(true);
 		});
 		window.on('blur', hxd.Key.initialize);
-		
+
 		// handle commandline parameters
 		nw.App.on("open", function(cmd) {
 			~/"([^"]+)"/g.map(cmd, function(r) {
@@ -215,7 +216,7 @@ class Ide {
 			content: state.state,
 		};
 		var comps = new Map();
-		for( vcl in View.viewClasses )
+		for( vcl in hide.ui.View.viewClasses )
 			comps.set(vcl.name, true);
 		function checkRec(i:golden.Config.ItemConfig) {
 			if( i.componentName != null && !comps.exists(i.componentName) ) {
@@ -228,7 +229,7 @@ class Ide {
 
 		layout = new golden.Layout(config);
 
-		for( vcl in View.viewClasses )
+		for( vcl in hide.ui.View.viewClasses )
 			layout.registerComponent(vcl.name,function(cont,state) {
 				var view = Type.createInstance(vcl.cl,[state]);
 				view.setContainer(cont);
@@ -525,7 +526,7 @@ class Ide {
 			props.global.save();
 		});
 
-		window.menu = new Menu(menu).root;
+		window.menu = new hide.ui.Menu(menu).root;
 	}
 
 	public function openFile( file : String, ?onCreate ) {
@@ -542,10 +543,10 @@ class Ide {
 		open(ext.component, { path : path }, onCreate);
 	}
 
-	public function open( component : String, state : Dynamic, ?onCreate : View<Dynamic> -> Void ) {
+	public function open( component : String, state : Dynamic, ?onCreate : hide.ui.View<Dynamic> -> Void ) {
 		if( state == null ) state = {};
 
-		var c = View.viewClasses.get(component);
+		var c = hide.ui.View.viewClasses.get(component);
 		if( c == null )
 			throw "Unknown component " + component;
 

+ 2 - 2
hide/comp/Component.hx

@@ -2,13 +2,13 @@ package hide.comp;
 
 class Component {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	public var name(get, never) : String;
 	public var root : Element;
 	public var saveDisplayKey : String;
 
 	public function new(root) {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 		this.root = root;
 	}
 

+ 1 - 1
hide/comp/ContextMenu.hx

@@ -13,7 +13,7 @@ class ContextMenu {
 
 	public function new( config : Array<ContextMenuItem> ) {
 		var menu = makeMenu(config);
-		var ide = hide.ui.Ide.inst;
+		var ide = hide.Ide.inst;
 		menu.popup(ide.mouseX, ide.mouseY);
 	}
 

+ 2 - 2
hide/comp/Scene.hx

@@ -3,13 +3,13 @@ package hide.comp;
 @:access(hide.comp.Scene)
 class SceneLoader extends hxd.fmt.hsd.Serializer {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	var hsdPath : String;
 	var projectPath : String;
 	var scene : Scene;
 
 	public function new(hsdPath, scene) {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 		super();
 		this.hsdPath = hsdPath;
 		this.scene = scene;

+ 2 - 2
hide/prefab/EditContext.hx

@@ -6,12 +6,12 @@ class EditContext {
 
 	#if editor
 	public var prefabPath : String;
-	public var ide(get,never) : hide.ui.Ide;
+	public var ide(get,never) : hide.Ide;
 	public var scene : hide.comp.Scene;
 	public var view : hide.view.FileView;
 	public var cleanups : Array<Void->Void>;
 	public var properties : hide.comp.PropsEditor;
-	function get_ide() return hide.ui.Ide.inst;
+	function get_ide() return hide.Ide.inst;
 	public function onChange(p : Prefab, propName : String) { }
 	#end
 

+ 4 - 4
hide/prefab/l3d/Instance.hx

@@ -26,7 +26,7 @@ class Instance extends Object3D {
 		var ctx = super.makeInstance(ctx);
 		var parentLayer = getParent(Layer);
 		if(parentLayer != null) {
-			var sheet = parentLayer.getCdbModel();			
+			var sheet = parentLayer.getCdbModel();
 			if(sheet != null) {
 				var refCol = findRefColumn(sheet);
 				if(refCol != null) {
@@ -104,7 +104,7 @@ class Instance extends Object3D {
 	public static function findRefColumn(sheet : cdb.Sheet) {
 		for(col in sheet.columns) {
 			switch(col.type) {
-				case TRef(sheet): 
+				case TRef(sheet):
 					return {col: col, sheet: sheet};
 				default:
 			}
@@ -121,7 +121,7 @@ class Instance extends Object3D {
 		if(path == null)
 			return null;
 		try {
-			var model = hxd.Res.load(path).toModel();
+			var model = hxd.res.Loader.currentInstance.load(path).toModel();
 			return model;
 		} catch( e : hxd.res.NotFound ) {}
 		return null;
@@ -174,7 +174,7 @@ class Instance extends Object3D {
 	static function makeTile(p:cdb.Types.TilePos) : h2d.Tile {
 		var w = (p.width == null ? 1 : p.width) * p.size;
 		var h = (p.height == null ? 1 : p.height) * p.size;
-		return hxd.Res.load(p.file).toTile().sub(p.x * p.size, p.y * p.size, w, h);
+		return hxd.res.Loader.currentInstance.load(p.file).toTile().sub(p.x * p.size, p.y * p.size, w, h);
 	}
 
 	static var _ = Library.register("instance", Instance);

+ 3 - 3
hide/prefab/l3d/Layer.hx

@@ -22,11 +22,11 @@ class Layer extends Object3D {
 	}
 
 	public function getLevelSheet() {
-		var ide = hide.ui.Ide.inst;
+		var ide = hide.Ide.inst;
 		return ide.database.getSheet(ide.currentProps.get("l3d.cdbLevel", "level"));
 	}
 	#end
-	
+
 	override function save() {
 		var obj : Dynamic = super.save();
 		obj.locked = locked;
@@ -76,7 +76,7 @@ class Layer extends Object3D {
 		}
 		#end
 	}
-	
+
 	override function getHideProps() {
 		return { icon : "file", name : "Layer", fileSource : null };
 	}

+ 2 - 2
hide/tools/FileWatcher.hx

@@ -2,11 +2,11 @@ package hide.tools;
 
 class FileWatcher {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	var watches : Map<String,{ events : Array<{path:String,fun:Void->Void,checkDel:Bool}>, w : js.node.fs.FSWatcher, changed : Bool, isDir : Bool }> = new Map();
 
 	public function new() {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 	}
 
 	public function register( path : String, updateFun, ?checkDelete : Bool ) {

+ 3 - 3
hide/tools/Interp.hx

@@ -5,10 +5,10 @@ import h3d.anim.SmoothTarget;
 
 class Interp extends hscript.Interp {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 
 	public function new() {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 		super();
 		// share some classes
 		variables.set("hxd", { Res : new ResourceLoader([]) });
@@ -84,7 +84,7 @@ class ResourceLoader {
 	}
 
 	function resolvePath() {
-		var ide = hide.ui.Ide.inst;
+		var ide = hide.Ide.inst;
 		var dir = __path.copy();
 		var name = dir.pop();
 		var dir = dir.join("/");

+ 3 - 3
hide/tools/MaterialScript.hx

@@ -19,7 +19,7 @@ class RendererScript extends h3d.scene.Renderer {
 			callb();
 		} catch( e : hscript.Expr.Error ) {
 			hasError = true;
-			hide.ui.Ide.inst.error(hscript.Printer.errorToString(e));
+			hide.Ide.inst.error(hscript.Printer.errorToString(e));
 		}
 	}
 
@@ -56,12 +56,12 @@ class Properties extends hxd.impl.Properties {
 
 class MaterialScript extends h3d.mat.MaterialScript {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	public var renderer : Properties;
 
 	public function new() {
 		super(); // name will be set by script itself
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 	}
 
 	function loadModule( path : String ) : Dynamic {

+ 2 - 2
hide/tools/ShaderLoader.hx

@@ -10,12 +10,12 @@ typedef CachedShader = {
 
 class ShaderLoader {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	var shaderPath : Array<String>;
 	var shaderCache = new Map<String, CachedShader>();
 
 	public function new() {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 		shaderPath = ide.currentProps.get("haxe.classPath");
 	}
 

+ 2 - 2
hide/tools/TypesCache.hx

@@ -23,7 +23,7 @@ typedef TypeFile = {
 
 class TypesCache {
 
-	var ide : hide.ui.Ide;
+	var ide : hide.Ide;
 	var needRebuild = true;
 	var types : Array<TypeModel> = [];
 	var htype : Map<String, TypeModel> = new Map();
@@ -31,7 +31,7 @@ class TypesCache {
 	var watchers = [];
 
 	public function new() {
-		ide = hide.ui.Ide.inst;
+		ide = hide.Ide.inst;
 	}
 
 	public function getModels() {

+ 2 - 2
hide/ui/Props.hx

@@ -82,7 +82,7 @@ class Props {
 	public function get( key : String, ?defaultVal : Dynamic ) : Dynamic {
 		var val = Reflect.field(current,key);
 		if(val != null) return val;
-		return defaultVal; 
+		return defaultVal;
 	}
 
 	public static function loadForProject( projectPath : String, resourcePath : String ) {
@@ -120,7 +120,7 @@ class Props {
 		};
 	}
 
-	public static function loadForFile( ide : hide.ui.Ide, path : String ) {
+	public static function loadForFile( ide : hide.Ide, path : String ) {
 		var parts = path.split("/");
 		var propFiles = [];
 		var first = true, allowSave = false;

+ 1 - 1
hide/ui/View.hx

@@ -9,7 +9,7 @@ enum DisplayPosition {
 
 typedef ViewOptions = { ?position : DisplayPosition, ?width : Int }
 
-@:keepSub @:allow(hide.ui.Ide)
+@:keepSub @:allow(hide.Ide)
 class View<T> extends hide.comp.Component {
 
 	var container : golden.Container;

+ 3 - 3
hide/view/l3d/Gizmo.hx

@@ -42,7 +42,7 @@ class Gizmo extends h3d.scene.Object {
 	public function new(scene: hide.comp.Scene) {
 		super(scene.s3d);
 		this.scene = scene;
-		var path = hide.ui.Ide.inst.appPath + "/res/gizmo.hmd";
+		var path = hide.Ide.inst.appPath + "/res/gizmo.hmd";
 		var data = sys.io.File.getBytes(path);
 		var hmd = hxd.res.Any.fromBytes(path, data).toModel().toHmd();
 		gizmo = hmd.makeObject();
@@ -122,7 +122,7 @@ class Gizmo extends h3d.scene.Object {
 			var curPt = getDragPoint(dragPlane);
 			var delta = curPt.sub(startDragPt);
 			var translate = new h3d.Vector(0,0,0);
-			var quat = new h3d.Quat();			
+			var quat = new h3d.Quat();
 			var speedFactor = K.isDown(K.SHIFT) ? 0.1 : 1.0;
 			delta.scale(speedFactor);
 
@@ -139,7 +139,7 @@ class Gizmo extends h3d.scene.Object {
 				if(mode == MoveX || mode == MoveXY || mode == MoveZX) translate.x = snap(delta.x);
 				if(mode == MoveY || mode == MoveYZ || mode == MoveXY) translate.y = snap(delta.y);
 				if(mode == MoveZ || mode == MoveZX || mode == MoveYZ) translate.z = snap(delta.z);
-			
+
 				x = (startPos.x + translate.x);
 				y = (startPos.y + translate.y);
 				z = (startPos.z + translate.z);