Files
armorpaint/Sources/arm/ui/BoxPreferences.hx
T

218 lines
7.8 KiB
Haxe
Raw Normal View History

2019-06-20 16:50:57 +02:00
package arm.ui;
import zui.Id;
2019-10-16 17:29:48 +02:00
import zui.Zui;
2019-06-20 16:50:57 +02:00
import iron.data.Data;
import arm.nodes.MaterialParser;
import arm.data.LayerSlot;
2019-10-16 23:02:57 +02:00
class BoxPreferences {
2019-06-20 16:50:57 +02:00
@:access(zui.Zui)
2019-10-16 23:02:57 +02:00
public static function show() {
UIBox.showCustom(function(ui:Zui) {
var _w = ui._w;
ui._w = Std.int(_w / 2);
var htab = Id.handle();
if (ui.tab(htab, "Interface")) {
2019-10-16 17:29:48 +02:00
2019-06-23 15:50:07 +02:00
var hscale = Id.handle({value: Config.raw.window_scale});
2019-06-20 16:50:57 +02:00
ui.slider(hscale, "UI Scale", 0.5, 4.0, true);
if (!hscale.changed && UITrait.inst.hscaleWasChanged) {
if (hscale.value == null || Math.isNaN(hscale.value)) hscale.value = 1.0;
2019-06-23 15:50:07 +02:00
Config.raw.window_scale = hscale.value;
2019-06-22 00:25:38 +02:00
Config.save();
2019-10-17 10:58:29 +02:00
setScale();
2019-06-20 16:50:57 +02:00
}
UITrait.inst.hscaleWasChanged = hscale.changed;
var themeHandle = Id.handle({position: 0});
var themes = ["Dark", "Light"];
ui.combo(themeHandle, themes, "Theme", true);
if (themeHandle.changed) {
var theme = themes[themeHandle.position].toLowerCase();
if (theme == "dark") { // Built-in default
App.theme = zui.Themes.dark;
}
else {
Data.getBlob("themes/theme_" + theme + ".arm", function(b:kha.Blob) {
App.theme = haxe.Json.parse(b.toString());
});
}
ui.t = App.theme;
2019-10-18 11:53:49 +02:00
UITrait.inst.ui.t = App.theme;
// UINodes.inst.ui.t = App.theme;
2019-06-20 16:50:57 +02:00
UITrait.inst.headerHandle.redraws = 2;
UITrait.inst.toolbarHandle.redraws = 2;
UITrait.inst.statusHandle.redraws = 2;
UITrait.inst.workspaceHandle.redraws = 2;
UITrait.inst.menuHandle.redraws = 2;
UITrait.inst.hwnd.redraws = 2;
UITrait.inst.hwnd1.redraws = 2;
UITrait.inst.hwnd2.redraws = 2;
}
2019-09-02 19:36:43 +02:00
// ui.text("Node Editor");
// var gridSnap = ui.check(Id.handle({selected: false}), "Grid Snap");
2019-06-20 16:50:57 +02:00
2019-10-16 23:02:57 +02:00
ui.endElement();
ui.row([1/2]);
2019-10-17 22:00:59 +02:00
if (ui.button("Restore")) {
2019-10-16 23:02:57 +02:00
// UIMenu.draw(function(ui:Zui) {
// ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 2, ui.t.SEPARATOR_COL);
// ui.text("Restore defaults?", Right);
// if (ui.button("Confirm", Left)) {
Config.restore();
2019-10-17 10:58:29 +02:00
setScale();
2019-10-16 23:02:57 +02:00
// }
// });
}
}
if (ui.tab(htab, "Usage")) {
2019-06-23 15:50:07 +02:00
UITrait.inst.undoHandle = Id.handle({value: Config.raw.undo_steps});
2019-06-24 22:35:17 +02:00
Config.raw.undo_steps = Std.int(ui.slider(UITrait.inst.undoHandle, "Undo Steps", 2, 64, false, 1));
2019-06-20 16:50:57 +02:00
if (UITrait.inst.undoHandle.changed) {
ui.g.end();
2019-06-23 15:50:07 +02:00
while (History.undoLayers.length < Config.raw.undo_steps) {
2019-06-23 14:50:41 +02:00
var l = new LayerSlot("_undo" + History.undoLayers.length);
2019-06-20 16:50:57 +02:00
l.createMask(0, false);
2019-06-23 14:50:41 +02:00
History.undoLayers.push(l);
2019-06-20 16:50:57 +02:00
}
2019-06-23 15:50:07 +02:00
while (History.undoLayers.length > Config.raw.undo_steps) {
2019-06-23 14:50:41 +02:00
var l = History.undoLayers.pop();
2019-06-20 16:50:57 +02:00
l.unload();
}
History.reset();
ui.g.begin(false);
2019-06-22 00:25:38 +02:00
Config.save();
2019-06-20 16:50:57 +02:00
}
2019-08-07 15:50:03 +02:00
UITrait.inst.brushBias = ui.slider(Id.handle({value: UITrait.inst.brushBias}), "Paint Bleed", 0.0, 2.0, true);
2019-07-11 16:10:30 +02:00
if (ui.isHovered) ui.tooltip("Stretch brush strokes on the uv map to prevent seams");
2019-06-20 16:50:57 +02:00
var brush3dHandle = Id.handle({selected: UITrait.inst.brush3d});
UITrait.inst.brush3d = ui.check(brush3dHandle, "3D Cursor");
if (brush3dHandle.changed) MaterialParser.parsePaintMaterial();
ui.enabled = UITrait.inst.brush3d;
var brushDepthRejectHandle = Id.handle({selected: UITrait.inst.brushDepthReject});
UITrait.inst.brushDepthReject = ui.check(brushDepthRejectHandle, "Depth Reject");
if (brushDepthRejectHandle.changed) MaterialParser.parsePaintMaterial();
ui.row([1/2,1/2]);
var brushAngleRejectHandle = Id.handle({selected: UITrait.inst.brushAngleReject});
UITrait.inst.brushAngleReject = ui.check(brushAngleRejectHandle, "Angle Reject");
if (brushAngleRejectHandle.changed) MaterialParser.parsePaintMaterial();
if (!UITrait.inst.brushAngleReject) ui.enabled = false;
var angleDotHandle = Id.handle({value: UITrait.inst.brushAngleRejectDot});
UITrait.inst.brushAngleRejectDot = ui.slider(angleDotHandle, "Angle", 0.0, 1.0, true);
if (angleDotHandle.changed) {
MaterialParser.parsePaintMaterial();
}
ui.enabled = true;
}
2019-10-16 23:02:57 +02:00
if (ui.tab(htab, "Pen")) {
2019-06-20 16:50:57 +02:00
UITrait.penPressureRadius = ui.check(Id.handle({selected: UITrait.penPressureRadius}), "Brush Radius");
UITrait.penPressureOpacity = ui.check(Id.handle({selected: UITrait.penPressureOpacity}), "Brush Opacity");
UITrait.penPressureHardness = ui.check(Id.handle({selected: UITrait.penPressureHardness}), "Brush Hardness");
}
2019-06-23 15:50:07 +02:00
UITrait.inst.hssgi = Id.handle({selected: Config.raw.rp_ssgi});
UITrait.inst.hssr = Id.handle({selected: Config.raw.rp_ssr});
UITrait.inst.hbloom = Id.handle({selected: Config.raw.rp_bloom});
UITrait.inst.hsupersample = Id.handle({position: Config.getSuperSampleQuality(Config.raw.rp_supersample)});
UITrait.inst.hvxao = Id.handle({selected: Config.raw.rp_gi});
2019-10-16 23:02:57 +02:00
if (ui.tab(htab, "Viewport")) {
ui.combo(UITrait.inst.hsupersample, ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"], "Super Sample", true);
if (UITrait.inst.hsupersample.changed) Config.applyConfig();
2019-06-23 15:50:07 +02:00
var vsyncHandle = Id.handle({selected: Config.raw.window_vsync});
Config.raw.window_vsync = ui.check(vsyncHandle, "VSync");
2019-06-22 00:25:38 +02:00
if (vsyncHandle.changed) Config.save();
2019-10-05 11:04:20 +02:00
var cullHandle = Id.handle({selected: Config.raw.rp_culling});
Config.raw.rp_culling = ui.check(cullHandle, "Cull Backfaces");
2019-08-06 17:37:44 +02:00
if (cullHandle.changed) {
2019-10-05 11:04:20 +02:00
Config.save();
2019-08-06 17:37:44 +02:00
MaterialParser.parseMeshMaterial();
}
var filterHandle = Id.handle({selected: UITrait.inst.textureFilter});
UITrait.inst.textureFilter = ui.check(filterHandle, "Filter Textures");
if (filterHandle.changed) {
MaterialParser.parseMeshMaterial();
}
2019-10-16 23:02:57 +02:00
#if (!kha_direct3d12)
2019-06-20 16:50:57 +02:00
ui.check(UITrait.inst.hvxao, "Voxel AO");
if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows");
2019-10-03 21:19:02 +02:00
#end
2019-08-25 21:21:56 +02:00
if (UITrait.inst.hvxao.changed) {
Config.applyConfig();
#if arm_creator
MaterialParser.parseMeshMaterial();
#end
}
2019-06-20 16:50:57 +02:00
ui.check(UITrait.inst.hssgi, "SSAO");
if (UITrait.inst.hssgi.changed) Config.applyConfig();
ui.check(UITrait.inst.hbloom, "Bloom");
if (UITrait.inst.hbloom.changed) Config.applyConfig();
ui.check(UITrait.inst.hssr, "SSR");
if (UITrait.inst.hssr.changed) Config.applyConfig();
2019-08-25 21:21:56 +02:00
#if arm_creator
var h = Id.handle({value: UITrait.inst.vxaoExt});
UITrait.inst.vxaoExt = ui.slider(h, "VXAO Ext", 1.0, 10.0);
if (h.changed) {
Context.ddirty = 2;
MaterialParser.parseMeshMaterial();
}
#end
2019-06-20 16:50:57 +02:00
}
2019-10-16 23:02:57 +02:00
if (ui.tab(htab, "Keymap")) {
2019-06-27 13:35:58 +02:00
var presetHandle = Id.handle();
ui.combo(presetHandle, ["Default", "Blender"], "Preset", true);
if (presetHandle.changed) {
var preset = presetHandle.position;
var keymap = Config.keymap;
if (preset == 0) {
keymap.action_rotate = "alt+left";
keymap.action_pan = "alt+middle";
keymap.action_zoom = "alt+right";
}
else if (preset == 1) {
keymap.action_rotate = "middle";
keymap.action_pan = "shift+middle";
keymap.action_zoom = "ctrl+middle";
}
2019-06-29 22:29:39 +02:00
Config.applyConfig();
2019-06-27 13:35:58 +02:00
}
ui.separator(8, false);
2019-06-20 16:50:57 +02:00
var i = 0;
ui.changed = false;
2019-06-27 13:35:58 +02:00
for (key in Reflect.fields(Config.keymap)) {
var h = Id.handle().nest(i++);
h.text = Reflect.field(Config.keymap, key);
var text = ui.textInput(h, key, Left);
Reflect.setField(Config.keymap, key, text);
2019-06-20 16:50:57 +02:00
}
if (ui.changed) Config.applyConfig();
}
2019-08-25 21:21:56 +02:00
2019-10-16 23:02:57 +02:00
ui._w = _w;
2019-10-17 10:58:29 +02:00
}, 400, 270);
}
static function setScale() {
var scale = Config.raw.window_scale;
UITrait.inst.ui.setScale(scale);
UITrait.inst.windowW = Std.int(UITrait.defaultWindowW * scale);
UITrait.inst.toolbarw = Std.int(UITrait.defaultToolbarW * scale);
UITrait.inst.headerh = Std.int(UITrait.defaultHeaderH * scale);
UITrait.inst.menubarw = Std.int(215 * scale);
UITrait.inst.setIconScale();
UINodes.inst.ui.setScale(scale);
UIView2D.inst.ui.setScale(scale);
App.uibox.setScale(scale);
App.resize();
2019-08-25 21:21:56 +02:00
}
2019-06-20 16:50:57 +02:00
}