Improve init

This commit is contained in:
luboslenco
2019-05-18 19:06:45 +02:00
parent 7797ccad76
commit bd97a4c5ac
3 changed files with 33 additions and 16 deletions
+13 -2
View File
@@ -143,8 +143,17 @@ class App extends iron.Trait {
iron.App.notifyOnRender2D(render);
appx = C.ui_layout == 0 ? UITrait.inst.toolbarw : UITrait.inst.windowW + UITrait.inst.toolbarw;
appy = UITrait.inst.headerh * 2;
var cam = iron.Scene.active.camera;
cam.data.raw.fov = Std.int(cam.data.raw.fov * 100) / 100;
cam.buildProjection();
if (fileArg != "") {
Importer.importFile(fileArg);
if (Format.checkMeshFormat(fileArg)) {
UITrait.inst.toggleDistractFree();
}
else if (Format.checkTextureFormat(fileArg)) {
UITrait.inst.show2DView(1);
}
}
});
});
@@ -181,6 +190,7 @@ class App extends iron.Trait {
var res = 0;
if (UINodes.inst == null || UITrait.inst == null) {
res = kha.System.windowWidth() - UITrait.defaultWindowW;
res -= UITrait.defaultToolbarW;
}
else if (UINodes.inst.show || UIView2D.inst.show) {
res = Std.int((kha.System.windowWidth() - UITrait.inst.windowW) / 2);
@@ -193,7 +203,7 @@ class App extends iron.Trait {
else {
res = kha.System.windowWidth();
}
return res > 0 ? res : 1; // App was minimized, force render path resize
}
@@ -206,8 +216,9 @@ class App extends iron.Trait {
var res = 0;
res = kha.System.windowHeight();
if (UITrait.inst == null) res -= UITrait.defaultHeaderH * 3;
if (UITrait.inst != null && UITrait.inst.show && res > 0) res -= UITrait.inst.headerh * 3;
return res > 0 ? res : 1; // App was minimized, force render path resize
}
+1 -2
View File
@@ -89,8 +89,7 @@ class UIMenu {
if (ui.button("Orbit Opposite", Left, "9")) { ViewportUtil.orbit(Math.PI, 0); }
ui.fill(0, 0, sepw, 1, ui.t.ACCENT_SELECT_COL);
if (ui.button("Distract Free", Left, "F11")) {
UITrait.inst.show = !UITrait.inst.show;
arm.App.resize();
UITrait.inst.toggleDistractFree();
UITrait.inst.ui.isHovered = false;
}
+19 -12
View File
@@ -30,6 +30,8 @@ class UITrait extends iron.Trait {
public static var inst:UITrait;
public static var defaultWindowW = 280;
public static var defaultToolbarW = 54;
public static var defaultHeaderH = 24;
public static var penPressureRadius = true;
public static var penPressureOpacity = false;
@@ -267,8 +269,8 @@ class UITrait extends iron.Trait {
systemId = kha.System.systemId;
windowW = Std.int(defaultWindowW * App.C.window_scale);
toolbarw = Std.int(54 * App.C.window_scale);
headerh = Std.int(24 * App.C.window_scale);
toolbarw = Std.int(defaultToolbarW * App.C.window_scale);
headerh = Std.int(defaultHeaderH * App.C.window_scale);
menubarw = Std.int(215 * App.C.window_scale);
Uniforms.init();
@@ -496,8 +498,7 @@ class UITrait extends iron.Trait {
if (kb.started("f11") ||
(kb.started("escape") && !show && !arm.App.showFiles && !arm.App.showBox)) {
show = !show;
arm.App.resize();
toggleDistractFree();
}
var mouse = iron.system.Input.getMouse();
@@ -616,6 +617,11 @@ class UITrait extends iron.Trait {
}
}
public function toggleDistractFree() {
show = !show;
arm.App.resize();
}
function selectMaterial(i:Int) {
if (materials.length <= i) return;
setMaterial(materials[i]);
@@ -632,6 +638,7 @@ class UITrait extends iron.Trait {
if (current != null) current.end();
var decal = selectedTool == ToolDecal || selectedTool == ToolText;
if (decal) RenderUtil.makeDecalPreview();
if (worktab.position == 2) MaterialParser.parseMeshPreviewMaterial();
if (current != null) current.begin(false);
}
@@ -921,7 +928,7 @@ class UITrait extends iron.Trait {
// function showParticleNodes() {}
function show2DView(type = 0) {
public function show2DView(type = 0) {
// Clear input state as ui receives input events even when not drawn
@:privateAccess UIView2D.inst.ui.endInput();
if (UIView2D.inst.type != type) UIView2D.inst.show = true;
@@ -1911,8 +1918,8 @@ class UITrait extends iron.Trait {
UINodes.inst.ui.setScale(hscale.value);
UIView2D.inst.ui.setScale(hscale.value);
windowW = Std.int(defaultWindowW * App.C.window_scale);
toolbarw = Std.int(54 * App.C.window_scale);
headerh = Std.int(24 * App.C.window_scale);
toolbarw = Std.int(defaultToolbarW * App.C.window_scale);
headerh = Std.int(defaultHeaderH * App.C.window_scale);
menubarw = Std.int(215 * App.C.window_scale);
arm.App.resize();
armory.data.Config.save();
@@ -2043,11 +2050,6 @@ class UITrait extends iron.Trait {
ui.g.begin(false);
}
if (ui.button("Nodes")) {
showMaterialNodes();
}
else if (ui.isHovered) ui.tooltip("Show Node Editor (TAB)");
if (ui.button("Import")) {
arm.App.showFiles = true;
@:privateAccess Ext.lastPath = ""; // Refresh
@@ -2062,6 +2064,11 @@ class UITrait extends iron.Trait {
}
}
if (ui.button("Nodes")) {
showMaterialNodes();
}
else if (ui.isHovered) ui.tooltip("Show Node Editor (TAB)");
for (row in 0...Std.int(Math.ceil(materials.length / 5))) {
ui.row([1/5,1/5,1/5,1/5,1/5]);