Browse Source

fixed information display and 2d camera on by default.

Nicolas Cannasse 5 years ago
parent
commit
0e17a7c087

+ 3 - 2
hide/comp/SceneEditor.hx

@@ -125,7 +125,7 @@ class SceneEditor {
 	public var snapToGround = false;
 	public var localTransform = true;
 	public var cameraController : h3d.scene.CameraController;
-	public var cameraController2D : CameraController2D;
+	public var cameraController2D : hide.view.l3d.CameraController2D;
 	public var editorDisplay(default,set) : Bool;
 	public var camera2D(default,set) : Bool = false;
 
@@ -314,7 +314,7 @@ class SceneEditor {
 	}
 
 	function makeCamController2D() {
-		return new CameraController2D(context.shared.root2d);
+		return new hide.view.l3d.CameraController2D(context.shared.root2d);
 	}
 
 	function focusSelection() {
@@ -567,6 +567,7 @@ class SceneEditor {
 		tree.applyStyle = function(p, el) applyTreeStyle(p, el);
 		selectObjects([]);
 		refresh();
+		this.camera2D = camera2D;
 	}
 
 	public function refresh( ?mode: RefreshMode, ?callb: Void->Void) {

+ 7 - 2
hide/comp/Toolbar.hx

@@ -4,6 +4,7 @@ typedef ToolToggle = {
 	var element : Element;
 	function toggle( v : Bool ) : Void;
 	function isDown(): Bool;
+	function rightClick( v : Void -> Void ) : Void;
 }
 
 typedef ToolSelect<T> = {
@@ -36,7 +37,7 @@ class Toolbar extends Component {
 			this.saveDisplayState("toggle:" + icon, e.hasClass("toggled"));
 			if( onToggle != null ) onToggle(e.hasClass("toggled"));
 		}
-		e.click(function(_) tog());
+		e.click(function(e) if( e.button == 0 ) tog());
 		e.appendTo(element);
 		if( defValue ) e.addClass("toggled");
 		var def = getDisplayState("toggle:" + icon);
@@ -45,7 +46,11 @@ class Toolbar extends Component {
 		return {
 			element : e,
 			toggle : function(b) tog(),
-			isDown: function() return e.hasClass("toggled") };
+			isDown: function() return e.hasClass("toggled"),
+			rightClick : function(f) {
+				e.contextmenu(function(e) { f(); e.preventDefault(); });
+			}
+		};
 	}
 
 	public function addColor( label : String, onChange : Int -> Void, ?alpha : Bool, ?defValue = 0 ) {

+ 1 - 1
hide/comp/CameraController2D.hx → hide/view/l3d/CameraController2D.hx

@@ -1,4 +1,4 @@
-package hide.comp;
+package hide.view.l3d;
 
 class CameraController2D extends h2d.Object {
 

+ 34 - 19
hide/view/l3d/Level3D.hx

@@ -407,21 +407,40 @@ class Level3D extends FileView {
 		keys.register("sceneeditor.toggleGrid", () -> gridToggle.toggle(!gridToggle.isDown()));
 		tools.addButton("sun-o", "Bake Lights", () -> bakeLights());
 		tools.addButton("map", "Bake Volumetric Lightmaps", () -> { bakeLights(); bakeVolumetricLightmaps(); });
-		tools.addButton("info-circle", "Scene information", () -> {
-			var memStats = scene.engine.mem.stats();
-			var texs = @:privateAccess scene.engine.mem.textures;
-			var list = [for(t in texs) {
-				n: '${t.width}x${t.height}  ${t.format}  ${t.name}',
-				size: t.width * t.height
-			}];
-			list.sort((a, b) -> Reflect.compare(b.size, a.size));
-			var content = new Element('<div tabindex="1" class="overlay-info"><h2>Scene info</h2><pre></pre></div>');
-			new Element(element[0].ownerDocument.body).append(content);
-			var pre = content.find("pre");
-			pre.text([for(l in list) l.n].join("\n"));
-			content.blur(function(_) {
-				content.remove();
-			});
+
+
+		statusText = new h2d.Text(hxd.res.DefaultFont.get(), scene.s2d);
+		statusText.setPosition(5, 5);
+		statusText.visible = false;
+		var texContent : Element = null;
+		tools.addToggle("info-circle", "Scene information", function(b) statusText.visible = b).rightClick(function() {
+			if( texContent != null ) {
+				texContent.remove();
+				texContent = null;
+			}
+			new hide.comp.ContextMenu([
+				{
+					label : "Show Texture Details",
+					click : function() {
+						var memStats = scene.engine.mem.stats();
+						var texs = @:privateAccess scene.engine.mem.textures;
+						var list = [for(t in texs) {
+							n: '${t.width}x${t.height}  ${t.format}  ${t.name}',
+							size: t.width * t.height
+						}];
+						list.sort((a, b) -> Reflect.compare(b.size, a.size));
+						var content = new Element('<div tabindex="1" class="overlay-info"><h2>Scene info</h2><pre></pre></div>');
+						new Element(element[0].ownerDocument.body).append(content);
+						var pre = content.find("pre");
+						pre.text([for(l in list) l.n].join("\n"));
+						texContent = content;
+						content.blur(function(_) {
+							content.remove();
+							texContent = null;
+						});
+					}
+				}
+			]);
 		});
 
 		tools.addColor("Background color", function(v) {
@@ -429,10 +448,6 @@ class Level3D extends FileView {
 			updateGrid();
 		}, scene.engine.backgroundColor);
 
-		statusText = new h2d.Text(hxd.res.DefaultFont.get(), scene.s2d);
-		statusText.setPosition(5, 5);
-		statusText.visible = tools.getDisplayState("");
-
 		posToolTip = new h2d.Text(hxd.res.DefaultFont.get(), scene.s2d);
 		posToolTip.dropShadow = { dx : 1, dy : 1, color : 0, alpha : 0.5 };
 

+ 0 - 1
hrt/prefab/fx2d/Bitmap.hx

@@ -82,7 +82,6 @@ class Bitmap extends Object2D {
 			return null;
 		var bmp = cast(local2d, h2d.Bitmap);
 		var int = new h2d.Interactive(bmp.tile.width, bmp.tile.height);
-		int.backgroundColor = 0x80FF0000;
 		bmp.addChildAt(int, 0);
 		int.propagateEvents = true;
 		int.x = bmp.tile.dx;