Skip to content

Commit 6ef93b6

Browse files
committed
HideHL/Texture: add mip maps selector
1 parent 14f6d8c commit 6ef93b6

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

hide_hl/hide/view/Texture.hx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,22 @@ class Texture extends HuiView<{path: String}> {
399399
zoomInputBox.dom.addClass("group");
400400
widgets.push(zoomInputBox);
401401

402+
var mipSel = new HuiSelect();
403+
mipSel.dom.setId("mip-sel");
404+
if (shader.compressedTex.mipLevels > 0) {
405+
var h = shader.compressedTex.height;
406+
var w = shader.compressedTex.width;
407+
mipSel.items = [ for (idx in 0...shader.compressedTex.mipLevels) { label: 'Mip $idx - ${w / (hxd.Math.pow(2, idx))}x${h / (hxd.Math.pow(2, idx))}', value: idx}];
408+
mipSel.value = 0;
409+
}
410+
else {
411+
mipSel.visible = false;
412+
}
413+
mipSel.onValueChanged = () -> {
414+
shader.mipLod = mipSel.value;
415+
}
416+
widgets.push(mipSel);
417+
402418
new HuiIcon("question_mark", helpBtn);
403419
widgets.push(helpBtn);
404420

@@ -487,6 +503,14 @@ class Texture extends HuiView<{path: String}> {
487503
alphaInput.disabled = !params.alpha;
488504
alphaInput.text = '${params.alphaThreshold}';
489505

506+
var h = shader.compressedTex.height;
507+
var w = shader.compressedTex.width;
508+
var mipSel = Std.downcast(toolbar.getWidget("mip-sel"), HuiSelect);
509+
if (mipSel != null) {
510+
mipSel.items = [ for (idx in 0...shader.compressedTex.mipLevels) { label: 'Mip $idx - ${w / (hxd.Math.pow(2, idx))}x${h / (hxd.Math.pow(2, idx))}', value: idx}];
511+
mipSel.value = 0;
512+
}
513+
490514
var texMaxSize = getTextureMaxSize();
491515
size.text = '${params.size}';
492516
maxSizeEl.text = '/ ${texMaxSize} px';

hide_hl/res/ui/style/hui-toolbar.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ hui-toolbar {
2929
}
3030
}
3131

32+
hui-select {
33+
min-height: 26;
34+
width: 150;
35+
fill-width: false;
36+
background-type: hui;
37+
> hui-background {
38+
border-radius: @base-corner-radius !important;
39+
}
40+
}
41+
3242
>hui-element {
3343
margin-right: 5px;
3444
}

0 commit comments

Comments
 (0)