Selaa lähdekoodia

MaterialSelector: add blend mode selection

lviguier 8 kuukautta sitten
vanhempi
commit
3533b015e8
3 muutettua tiedostoa jossa 85 lisäystä ja 2 poistoa
  1. 22 0
      bin/style.css
  2. 26 0
      bin/style.less
  3. 37 2
      hrt/prefab/MaterialSelector.hx

+ 22 - 0
bin/style.css

@@ -4548,3 +4548,25 @@ blend-space-2d-root properties-container .hide-properties dl > div .hide-range i
 .anim-list > ul > li:hover {
   background-color: var(--hover-highlight);
 }
+.blend-selector-container {
+  width: 100%;
+}
+.blend-selector-container .blend-mode-selector {
+  overflow-y: scroll;
+  overflow-x: hidden;
+  background: #303030;
+  max-height: 150px;
+  padding: 3px;
+  margin: 5px;
+  border-radius: 3px;
+}
+.blend-selector-container .blend-mode-selector .blend-mode {
+  margin-top: 1px;
+  width: 100%;
+  padding: 5px;
+  border-radius: 3px;
+  background: #545454;
+}
+.blend-selector-container .blend-mode-selector .blend-mode input {
+  margin-right: 5px;
+}

+ 26 - 0
bin/style.less

@@ -5394,4 +5394,30 @@ blend-space-2d-root {
 			border-radius: var(--basic-border-radius);
 		}
 	}
+}
+
+.blend-selector-container {
+	width: 100%;
+
+	.blend-mode-selector {
+		overflow-y: scroll;
+		overflow-x: hidden;
+		background: @color-menu-bg-highlight;
+		max-height: 150px;
+		padding: 3px;
+		margin: 5px;
+		border-radius: 3px;
+
+		.blend-mode {
+			margin-top: 1px;
+			width: 100%;
+			padding: 5px;
+			border-radius: 3px;
+			background: @color-tool-bg;
+
+			input {
+				margin-right: 5px;
+			}
+		}
+	}
 }

+ 37 - 2
hrt/prefab/MaterialSelector.hx

@@ -14,6 +14,7 @@ class MaterialSelector extends hrt.prefab.Prefab {
 	@:s public var selections : Array<MaterialSelection> = [{
 		passName : "all",
 	}];
+	@:s public var blendModesSelected : Array<String> = [];
 	public var filterObj : h3d.scene.Object -> Bool;
 
 	public function getPasses(local3d: h3d.scene.Object = null) : Array<SelectedPass> {
@@ -38,6 +39,12 @@ class MaterialSelector extends hrt.prefab.Prefab {
 		var selectionSorted = selections.copy();
 		selectionSorted.sort((s1, s2) -> s1.passName == "all" ? return 1 : -1);
 		for ( m in mats ) {
+			if (blendModesSelected.length > 0) {
+				if (blendModesSelected.contains(m.blendMode.getName()))
+					passes.push({pass : m.mainPass, all : true});
+				continue;
+			}
+
 			for ( selection in selections ) {
 				if ( selection.passName == "all" ) {
 					passes.push({pass : m.mainPass, all : true});
@@ -67,15 +74,43 @@ class MaterialSelector extends hrt.prefab.Prefab {
 		super.edit(ctx);
 
 		var e1 = new hide.Element('
-			<div class="group" name="Selections">
+			<div class="group" name="Material selector">
+				<div class="blend-selector-container"></div>
 				<ul id="selections"></ul>
 			</div>
 		');
-		ctx.properties.add(e1, function(propName) {
+		ctx.properties.add(e1, this, function(propName) {
 			ctx.onChange(this, propName);
 			ctx.rebuildPrefab(this);
 		});
 
+		var blendModeSelector = new hide.Element('<div class="blend-mode-selector">
+		</div>');
+		for (b in Type.allEnums(h3d.mat.BlendMode)) {
+			var el = new hide.Element('<div class="blend-mode">
+				<input type="checkbox" ${blendModesSelected != null && blendModesSelected.contains(b.getName()) ? 'checked' : ''}/>
+				<label>$b</label>
+			</div>').appendTo(blendModeSelector);
+
+			var cb = el.find("input");
+			cb.change(function(e) {
+				var newVal = cb.prop('checked');
+				function exec(undo : Bool) {
+					var val = undo ? !newVal : newVal;
+					cb.prop('checked', val);
+					if (val)
+						blendModesSelected.push(b.getName());
+					else
+						blendModesSelected.remove(b.getName());
+				}
+
+				exec(false);
+				ctx.properties.undo.change(Custom(exec));
+			});
+		}
+
+		blendModeSelector.appendTo(e1.find(".blend-selector-container"));
+
 		var list = e1.find("ul#selections");
 		for ( s in selections ) {
 			var es = new hide.Element('