Explorar o código

minor fixes in inspectors

ncannasse %!s(int64=9) %!d(string=hai) anos
pai
achega
e63ba6fde0
Modificáronse 2 ficheiros con 27 adicións e 5 borrados
  1. 12 4
      hxd/net/PropInspector.hx
  2. 15 1
      hxd/net/SceneInspector.hx

+ 12 - 4
hxd/net/PropInspector.hx

@@ -214,6 +214,7 @@ class PropInspector extends cdb.jq.Client {
 		if( sameValue(oldV, newV) )
 			return;
 		history.push( { path : path, oldV : oldV, newV : newV } );
+		redoHistory = [];
 		onChange(path, oldV, newV);
 	}
 
@@ -350,12 +351,13 @@ class PropInspector extends cdb.jq.Client {
 					}
 				}
 			));
-			j.mousedown(function(e) {
+			jprop.mousedown(function(e) {
 				if( e.which == 3 ) {
+					if( jprop.find("input").length > 0 ) return;
 					var old = get();
 					var cur : Float = old;
 					j.addClass("active");
-					j.special("startDrag", [], function(v: { done:Bool, dx:Float, dy:Float } ) {
+					jprop.special("startDrag", [], function(v: { done:Bool, dx:Float, dy:Float } ) {
 						var delta = ( Math.max(Math.abs(old == 0 ? 1 : old),1e-3) / 200 ) * v.dx;
 						cur += delta;
 						cur = hxd.Math.fmt(cur);
@@ -381,12 +383,13 @@ class PropInspector extends cdb.jq.Client {
 					}
 				}
 			));
-			j.mousedown(function(e) {
+			jprop.mousedown(function(e) {
 				if( e.which == 3 ) {
+					if( jprop.find("input").length > 0 ) return;
 					var old = get();
 					var cur = old;
 					j.addClass("active");
-					j.special("startDrag", [], function(v: { done:Bool, dx:Float, dy:Float } ) {
+					jprop.special("startDrag", [], function(v: { done:Bool, dx:Float, dy:Float } ) {
 						var delta = ( Math.max(Math.abs(old == 0 ? 1 : old),1e-3) / 100 ) * v.dx;
 						cur += delta;
 						cur = hxd.Math.fmt(cur);
@@ -420,6 +423,7 @@ class PropInspector extends cdb.jq.Client {
 				));
 				jv.mousedown(function(e) {
 					if( e.which == 3 ) {
+						if( jv.find("input").length > 0 ) return;
 						var old = values[i];
 						var cur = old;
 						jv.addClass("active");
@@ -552,11 +556,15 @@ class PropInspector extends cdb.jq.Client {
 	}
 
 	function editValue( j : JQuery, get : Void -> String, set : String -> Void ) {
+
+		if( j.find("input").length > 0 ) return;
+
 		var input = J("<input>");
 		input.attr("value", get());
 		j.text("");
 		input.appendTo(j);
 		input.focus();
+		input.select();
 		input.blur(function(_) {
 			input.remove();
 			set(input.getValue());

+ 15 - 1
hxd/net/SceneInspector.hx

@@ -289,9 +289,16 @@ class SceneInspector {
 	}
 
 	function load() {
+		try {
 		hxd.File.browse(function(b) {
 			savedFile = b.fileName;
 			b.load(function(bytes) {
+
+				// reset to default
+				for( s in state.keys() )
+					inspect.setPathPropValue(s, state.get(s).original);
+				state = new Map();
+
 				var o : Dynamic = haxe.Json.parse(bytes.toString());
 				function browseRec( path : Array<String>, v : Dynamic ) {
 					switch( Type.typeof(v) ) {
@@ -315,6 +322,9 @@ class SceneInspector {
 			});
 
 		},{ defaultPath : savedFile, fileTypes : [ { name:"Scene Props", extensions:["js"] } ] } );
+		} catch( e : Dynamic ) {
+			// already open
+		}
 	}
 
 	function save() {
@@ -334,7 +344,11 @@ class SceneInspector {
 			Reflect.setField(o, path[0], state.get(s).current);
 		}
 		var js = haxe.Json.stringify(o, null, "\t");
-		hxd.File.saveAs(haxe.io.Bytes.ofString(js), { defaultPath : savedFile, saveFileName : function(name) savedFile = name } );
+		try {
+			hxd.File.saveAs(haxe.io.Bytes.ofString(js), { defaultPath : savedFile, saveFileName : function(name) savedFile = name } );
+		} catch( e : Dynamic ) {
+			// already open
+		}
 	}
 
 	public function addNode( name : String, icon : String, ?getProps : Void -> Array<Property>, ?parent : Node ) : Node {