Browse Source

[model] Added project setting to hightlight materials that have unset mat libs

Clément Espeute 2 days ago
parent
commit
96c4c2855f
3 changed files with 18 additions and 0 deletions
  1. 3 0
      bin/style.css
  2. 4 0
      bin/style.less
  3. 11 0
      hide/view/Model.hx

+ 3 - 0
bin/style.css

@@ -5525,3 +5525,6 @@ fancy-gallery-item.details .icon-placement {
   margin-left: 0.2em;
   font-size: 0.8em;
 }
+.model-view-mat-not-set {
+  color: #ee6666 !important;
+}

+ 4 - 0
bin/style.less

@@ -6618,4 +6618,8 @@ fancy-gallery-item {
 		margin-left: 0.2em;
 		font-size: 0.8em;
 	}
+}
+
+.model-view-mat-not-set {
+	color: #ee6666 !important;
 }

+ 11 - 0
hide/view/Model.hx

@@ -1054,6 +1054,7 @@ class Model extends FileView {
 			}
 			h3d.mat.MaterialSetup.current.saveMaterialProps(m, defaultProps);
 			Ide.inst.quickMessage('Properties for mat (${m.name}) had been saved');
+			tree.queueRefresh(RegenHeader);
 		};
 		saveButton.click(saveCallback);
 		properties.add(matLibrary, m);
@@ -1700,6 +1701,16 @@ class Model extends FileView {
 		tree.rebuildTree();
 		tree.openItem(obj, true);
 
+		tree.applyStyle = (item: Dynamic, elt : js.html.Element) -> {
+			if (hide.Ide.inst.currentConfig.get("highlightUnsetMats") ?? false) {
+				var mat = Std.downcast(item, h3d.mat.Material);
+				if (mat != null) {
+					var props : Dynamic =  h3d.mat.MaterialSetup.current.loadMaterialProps(mat);
+					elt.classList.toggle("model-view-mat-not-set", props == null || props.__ref == null);
+				}
+			}
+		}
+
 		tools.clear();
 		var anims = scene.listAnims(getPath());