Move viewport color to theme
This commit is contained in:
@@ -22,6 +22,7 @@ class BoxPreferences {
|
||||
public static var presetHandle: Handle;
|
||||
static var locales: Array<String> = null;
|
||||
static var themes: Array<String> = null;
|
||||
static var worldColor = kha.Color.fromValue(0xff030303);
|
||||
|
||||
@:access(zui.Zui)
|
||||
public static function show() {
|
||||
@@ -140,10 +141,44 @@ class BoxPreferences {
|
||||
var i = 0;
|
||||
var theme = arm.App.theme;
|
||||
var hlist = Id.handle();
|
||||
|
||||
// Viewport color
|
||||
var h = hlist.nest(i++, { color: worldColor });
|
||||
ui.row([1 / 8, 7 / 8]);
|
||||
ui.text("", 0, h.color);
|
||||
if (ui.isHovered && ui.inputReleased) {
|
||||
UIMenu.draw(function(ui) {
|
||||
ui.fill(0, 0, ui._w / ui.ops.scaleFactor, ui.t.ELEMENT_H * 6, ui.t.SEPARATOR_COL);
|
||||
ui.changed = false;
|
||||
zui.Ext.colorWheel(ui, h, false, null, false, false);
|
||||
if (ui.changed) UIMenu.keepOpen = true;
|
||||
}, 3);
|
||||
}
|
||||
var val = untyped h.color;
|
||||
if (val < 0) val += untyped 4294967296;
|
||||
h.text = untyped val.toString(16);
|
||||
ui.textInput(h, "VIEWPORT_COL");
|
||||
h.color = untyped parseInt(h.text, 16);
|
||||
|
||||
if (worldColor != h.color) {
|
||||
worldColor = h.color;
|
||||
var b = Bytes.alloc(4);
|
||||
b.set(0, worldColor.Rb);
|
||||
b.set(1, worldColor.Gb);
|
||||
b.set(2, worldColor.Bb);
|
||||
b.set(3, 255);
|
||||
Context.emptyEnvmap = kha.Image.fromBytes(b, 1, 1);
|
||||
Context.ddirty = 2;
|
||||
if (!Context.showEnvmap) {
|
||||
iron.Scene.active.world.envmap = Context.emptyEnvmap;
|
||||
}
|
||||
}
|
||||
|
||||
// Theme fields
|
||||
for (key in Reflect.fields(theme)) {
|
||||
if (key == "NAME") continue;
|
||||
|
||||
var h = hlist.nest(i);
|
||||
var h = hlist.nest(i++);
|
||||
var val: Int = untyped theme[key];
|
||||
var isHex = key.endsWith("_COL");
|
||||
if (isHex && val < 0) val += untyped 4294967296;
|
||||
@@ -168,9 +203,7 @@ class BoxPreferences {
|
||||
else if (res == "false") untyped theme[key] = false;
|
||||
else if (isHex) untyped theme[key] = parseInt(h.text, 16);
|
||||
else untyped theme[key] = parseInt(h.text);
|
||||
i++;
|
||||
}
|
||||
ui.enabled = true;
|
||||
}
|
||||
|
||||
if (ui.tab(htab, tr("Usage"), true)) {
|
||||
|
||||
@@ -33,7 +33,6 @@ class UIMenu {
|
||||
static var changeStarted = false;
|
||||
static var showMenuFirst = true;
|
||||
static var hideMenu = false;
|
||||
static var viewportColorHandle = Id.handle({selected: false});
|
||||
static var envmapLoaded = false;
|
||||
|
||||
@:access(zui.Zui)
|
||||
@@ -55,7 +54,6 @@ class UIMenu {
|
||||
}
|
||||
else {
|
||||
var menuItems = [14, 3, 14, #if kha_direct3d12 13 #else 12 #end, 17, 5];
|
||||
if (viewportColorHandle.selected) menuItems[2] += 6;
|
||||
var sepw = menuW / ui.SCALE();
|
||||
g.color = ui.t.SEPARATOR_COL;
|
||||
g.fillRect(menuX, menuY, menuW, 28 * menuItems[menuCategory] * ui.SCALE());
|
||||
@@ -202,32 +200,8 @@ class UIMenu {
|
||||
Context.ddirty = 2;
|
||||
}
|
||||
|
||||
if (Context.showEnvmap) {
|
||||
Context.showEnvmapBlur = ui.check(Context.showEnvmapBlurHandle, " " + tr("Blurred"));
|
||||
if (Context.showEnvmapBlurHandle.changed) Context.ddirty = 2;
|
||||
}
|
||||
else {
|
||||
if (ui.panel(viewportColorHandle, " " + tr("Viewport Color"), false, false, false)) {
|
||||
var hwheel = Id.handle({color: 0xff030303});
|
||||
var worldColor: kha.Color = Ext.colorWheel(ui, hwheel);
|
||||
if (hwheel.changed) {
|
||||
// var b = Context.emptyEnvmap.lock(); // No lock for d3d11
|
||||
// b.set(0, worldColor.Rb);
|
||||
// b.set(1, worldColor.Gb);
|
||||
// b.set(2, worldColor.Bb);
|
||||
// Context.emptyEnvmap.unlock();
|
||||
// Context.emptyEnvmap.unload(); //
|
||||
var b = Bytes.alloc(4);
|
||||
b.set(0, worldColor.Rb);
|
||||
b.set(1, worldColor.Gb);
|
||||
b.set(2, worldColor.Bb);
|
||||
b.set(3, 255);
|
||||
Context.emptyEnvmap = Image.fromBytes(b, 1, 1);
|
||||
Context.ddirty = 2;
|
||||
if (ui.inputStarted) changeStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Context.showEnvmapBlur = ui.check(Context.showEnvmapBlurHandle, " " + tr("Blur Envmap"));
|
||||
if (Context.showEnvmapBlurHandle.changed) Context.ddirty = 2;
|
||||
|
||||
if (Context.showEnvmap) {
|
||||
Scene.active.world.envmap = Context.showEnvmapBlur ? Scene.active.world.probe.radianceMipmaps[0] : Context.savedEnvmap;
|
||||
|
||||
Reference in New Issue
Block a user