Skip to content

Commit

Permalink
MaterialSelector: add blend mode selection
Browse files Browse the repository at this point in the history
LeoVgr committed Jan 20, 2025
1 parent 8a933b9 commit 3533b01
Showing 3 changed files with 85 additions and 2 deletions.
22 changes: 22 additions & 0 deletions bin/style.css
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 0 deletions bin/style.less
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
39 changes: 37 additions & 2 deletions hrt/prefab/MaterialSelector.hx
Original file line number Diff line number Diff line change
@@ -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('

0 comments on commit 3533b01

Please sign in to comment.