Pārlūkot izejas kodu

Move applyStyle to scene editor

trethaller 7 gadi atpakaļ
vecāks
revīzija
e3a1c12198
3 mainītis faili ar 28 papildinājumiem un 17 dzēšanām
  1. 1 0
      hide/comp/IconTree.hx
  2. 15 5
      hide/comp/SceneEditor.hx
  3. 12 12
      hide/view/l3d/Level3D.hx

+ 1 - 0
hide/comp/IconTree.hx

@@ -88,6 +88,7 @@ class IconTree<T:{}> extends Component {
 	public function init() {
 		(element:Dynamic).jstree({
 			core : {
+				dblclick_toggle: false,
 				animation: 50,
 				themes: {
 					name: "default-dark",

+ 15 - 5
hide/comp/SceneEditor.hx

@@ -93,6 +93,7 @@ class SceneEditor {
 	var interactives : Map<PrefabElement, h3d.scene.Interactive>;
 	var ide : hide.Ide;
 	var event : hxd.WaitEvent;
+	var hideList : Array<PrefabElement> = [];
 
 	var undo(get, null):hide.ui.UndoHistory;
 	function get_undo() { return view.undo; }
@@ -114,7 +115,6 @@ class SceneEditor {
 		tree = new hide.comp.IconTree();
 		tree.async = false;
 		tree.autoOpenNodes = false;
-		tree.checkboxes = true;
 
 		var sceneEl = new Element('<div class="scene"></div>');
 		scene = new hide.comp.Scene(view.props, null, sceneEl);
@@ -322,7 +322,7 @@ class SceneEditor {
 				}, 50);
 			}
 		}
-		tree.applyStyle = updateTreeStyle;
+		tree.applyStyle = applyTreeStyle;
 		selectObjects([]);
 		refresh();
 	}
@@ -334,7 +334,7 @@ class SceneEditor {
 			for(elt in all) {
 				var el = tree.getElement(elt);
 				if(el == null) continue;
-				updateTreeStyle(elt, el);
+				applyTreeStyle(elt, el);
 			}
 			if(callb != null) callb();
 		});
@@ -364,6 +364,10 @@ class SceneEditor {
 		scene.init();
 		scene.engine.backgroundColor = bgcol;
 		refreshInteractives();
+
+		var all = sceneData.flatten(hxd.prefab.Prefab);
+		for(elt in all)
+			applySceneStyle(elt);
 		onRefresh();
 	}
 
@@ -650,11 +654,13 @@ class SceneEditor {
 
 		if(p != sceneData) {
 			var el = tree.getElement(p);
-			updateTreeStyle(p, el);
+			applyTreeStyle(p, el);
 		}
+
+		applySceneStyle(p);
 	}
 
-	function updateTreeStyle(p: PrefabElement, el: Element) {
+	public function applyTreeStyle(p: PrefabElement, el: Element) {
 		var obj3d  = p.to(Object3D);
 		el.toggleClass("disabled", !p.enabled);
 
@@ -676,6 +682,10 @@ class SceneEditor {
 		}
 	}
 
+	public function applySceneStyle(p: PrefabElement) {
+	
+	}
+
 	public function getContext(elt : PrefabElement) {
 		if(elt == null) return null;
 		return context.shared.contexts.get(elt);

+ 12 - 12
hide/view/l3d/Level3D.hx

@@ -114,9 +114,14 @@ private class Level3DSceneEditor extends hide.comp.SceneEditor {
 		selectObjects(all);
 	}
 
-	override function updateTreeStyle(p: PrefabElement, el: Element) {
-		super.updateTreeStyle(p, el);
-		parent.updateTreeStyle(p, el);
+	override function applyTreeStyle(p: PrefabElement, el: Element) {
+		super.applyTreeStyle(p, el);
+		parent.applyTreeStyle(p, el);
+	}
+
+	override function applySceneStyle(p:PrefabElement) {
+		super.applySceneStyle(p);
+		parent.applySceneStyle(p);
 	}
 
 	override function onPrefabChange(p: PrefabElement, ?pname: String) {
@@ -499,10 +504,6 @@ class Level3D extends FileView {
 	}
 
 	function onRefreshScene() {
-		var all = data.flatten(hxd.prefab.Prefab);
-		for(elt in all)
-			refreshSceneStyle(elt);
-
 		// Apply first render props
 		var settings = data.children.find(c -> c.name == "settings");
 		if(settings != null) {
@@ -555,7 +556,7 @@ class Level3D extends FileView {
 		var all = data.flatten(hxd.prefab.Prefab);
 		for(p in all) {
 			if(p.type == typeid || getCdbTypeId(p) == typeid) {
-				refreshSceneStyle(p);
+				sceneEditor.applySceneStyle(p);
 			}
 		}
 	}
@@ -588,8 +589,7 @@ class Level3D extends FileView {
 		initDone = true;
 	}
 
-
-	function updateTreeStyle(p: PrefabElement, el: Element) {
+	function applyTreeStyle(p: PrefabElement, el: Element) {
 		var styles = ide.currentProps.get("l3d.treeStyles");
 		var style: Dynamic = null;
 		var typeId = getCdbTypeId(p);
@@ -607,10 +607,10 @@ class Level3D extends FileView {
 	}
 
 	function onPrefabChange(p: PrefabElement, ?pname: String) {
-		refreshSceneStyle(p);
+		
 	}
 
-	function refreshSceneStyle(p: PrefabElement) {
+	function applySceneStyle(p: PrefabElement) {
 		var level3d = p.to(hide.prefab.l3d.Level3D);
 		if(level3d != null) {
 			updateGrid();