2
0
ncannasse 9 жил өмнө
parent
commit
5f9582c630

+ 3 - 7
hxd/inspect/Node.hx

@@ -49,15 +49,11 @@ class Node {
 		return parent.getFullPath() + "." + n;
 	}
 
-	function dispose() {
-		if( j != null ) j.dispose();
-	}
-
-	public function remove() {
+	public function dispose() {
 		parent = null;
-		dispose();
+		if( j != null ) j.dispose();
 		for( c in childs )
-			c.remove();
+			c.dispose();
 	}
 
 	function set_name(v) {

+ 4 - 0
hxd/inspect/Panel.hx

@@ -38,6 +38,7 @@ class Panel extends Node {
 		panel.bind("paneldock", function(e) {
 			if( e.target == null ) {
 				visible = false;
+				onClose();
 				return;
 			}
 		});
@@ -45,6 +46,9 @@ class Panel extends Node {
 		j.appendTo(panel);
 	}
 
+	public dynamic function onClose() {
+	}
+
 	override function dispose() {
 		undock();
 		super.dispose();

+ 23 - 11
hxd/inspect/PropManager.hx

@@ -11,7 +11,7 @@ class PropManager extends cdb.jq.Client {
 	public var connected(default,null) = false;
 
 	var sock : hxd.net.Socket;
-	var flushWait = false;
+	var pendingMessages : Array<cdb.jq.Message>;
 
 	var refreshProps : Void -> Void;
 	var history : Array<History>;
@@ -76,17 +76,23 @@ class PropManager extends cdb.jq.Client {
 		});
 	}
 
-	override function sendBytes( msg : haxe.io.Bytes ) {
-		if( !flushWait ) {
-			flushWait = true;
-			sock.out.wait();
-			haxe.Timer.delay(function() {
-				flushWait = false;
-				sock.out.flush();
-			},0);
+	function flushMessages() {
+		if( pendingMessages == null ) return;
+		var msg = pendingMessages.length == 1 ? pendingMessages[0] : cdb.jq.Message.Group(pendingMessages);
+		pendingMessages = null;
+		var data = cdb.BinSerializer.serialize(msg);
+		sock.out.wait();
+		sock.out.writeInt32(data.length);
+		sock.out.write(data);
+		sock.out.flush();
+	}
+
+	override function send( msg : cdb.jq.Message ) {
+		if( pendingMessages == null ) {
+			pendingMessages = [];
+			haxe.Timer.delay(flushMessages,0);
 		}
-		sock.out.writeInt32(msg.length);
-		sock.out.write(msg);
+		pendingMessages.push(msg);
 	}
 
 	public dynamic function onConnected(b:Bool) {
@@ -528,8 +534,12 @@ class PropManager extends cdb.jq.Client {
 				if( !alpha ) cur &= 0xFFFFFF;
 				jprop.html('<div class="color" style="background:#${StringTools.hex(cur&0xFFFFFF,6)}"></div>');
 			}
+			var delay = false;
 			jprop.click(function(_) {
+				if( delay ) return;
 				jprop.special("colorPick", [get().toColor(), alpha], function(c) {
+					delay = true;
+					haxe.Timer.delay(function() delay = false, 200);
 					var color = h3d.Vector.fromColor(c.color);
 					if( c.done ) {
 						if( !alpha ) c.color &= 0xFFFFFF;
@@ -555,6 +565,8 @@ class PropManager extends cdb.jq.Client {
 						jprop.html(StringTools.htmlEscape("" + t) + " <button>View</button>");
 						jprop.find("button").click(function(_) {
 							var p = new Panel(null, "" + t);
+							p.show();
+							p.onClose = p.dispose;
 							p.j.html("Loading...");
 							haxe.Timer.delay(function() {
 								var bmp = t.capturePixels();

+ 1 - 1
hxd/inspect/ResPanel.hx

@@ -34,7 +34,7 @@ class ResPanel extends Panel {
 		for( e in subs )
 			syncRec(e, this);
 		while( files.length > filePos )
-			files.pop().remove();
+			files.pop().dispose();
 	}
 
 	override function initContent() {

+ 3 - 3
hxd/inspect/ScenePanel.hx

@@ -104,7 +104,7 @@ class ScenePanel extends Panel {
 		scenePosition = 0;
 		syncRec(scene, this);
 		while( sceneObjects.length > scenePosition )
-			sceneObjects.pop().remove();
+			sceneObjects.pop().dispose();
 	}
 
 	@:access(hxd.inspect.TreeNode)
@@ -149,10 +149,10 @@ class ScenePanel extends Panel {
 			for( c in o )
 				syncRec(c, so);
 		} else if( so.jchild != null ) {
+			for( o in so.childs )
+				o.dispose();
 			so.jchild.remove();
 			so.jchild = null;
-			for( o in so.childs )
-				o.remove();
 			if( so.openIcon == "circle-o" ) {
 				so.openIcon = null;
 				so.icon = "circle-o";