diff --git a/armorforge/Sources/TabObjects.ts b/armorforge/Sources/TabObjects.ts
index c315fea7..6c8573dd 100644
--- a/armorforge/Sources/TabObjects.ts
+++ b/armorforge/Sources/TabObjects.ts
@@ -9,7 +9,7 @@ class TabObjects {
}
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Objects"))) {
ui.beginSticky();
ui.row([1 / 4]);
diff --git a/armorlab/Sources/RenderPathPaint.ts b/armorlab/Sources/RenderPathPaint.ts
index fb7a330a..6a6762e2 100644
--- a/armorlab/Sources/RenderPathPaint.ts
+++ b/armorlab/Sources/RenderPathPaint.ts
@@ -84,7 +84,7 @@ class RenderPathPaint {
path.bindTarget("texpaint_nor" + tid, "texpaint_nor");
path.bindTarget("texpaint_pack" + tid, "texpaint_pack");
path.drawMeshes("paint");
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
let texpaint_picker = path.renderTargets.get("texpaint_picker").image;
let texpaint_nor_picker = path.renderTargets.get("texpaint_nor_picker").image;
@@ -165,8 +165,8 @@ class RenderPathPaint {
return;
}
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let inpaint = nodes.nodesSelectedId.length > 0 && nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
if (!Base.uiEnabled || Base.isDragging || !inpaint) {
@@ -256,8 +256,8 @@ class RenderPathPaint {
static bindLayers = () => {
let image: Image = null;
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
if (nodes.nodesSelectedId.length > 0) {
let node = nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]);
let brushNode = ParserLogic.getLogicNode(node);
@@ -289,8 +289,8 @@ class RenderPathPaint {
path.bindTarget("texpaint_nor_empty", "texpaint_nor");
path.bindTarget("texpaint_pack_empty", "texpaint_pack");
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let node = nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]);
let inpaint = node.type == "InpaintNode";
if (inpaint) {
diff --git a/armorlab/Sources/UINodesExt.ts b/armorlab/Sources/UINodesExt.ts
index 61e58f34..b6b86d7c 100644
--- a/armorlab/Sources/UINodesExt.ts
+++ b/armorlab/Sources/UINodesExt.ts
@@ -4,7 +4,7 @@ class UINodesExt {
static lastVertices: DataView = null; // Before displacement
static drawButtons = (ew: f32, startY: f32) => {
- let ui = UINodes.inst.ui;
+ let ui = UINodes.ui;
if (ui.button(tr("Run"))) {
Console.progress(tr("Processing"));
@@ -84,7 +84,7 @@ class UINodesExt {
texpaint_pack.g4.drawIndexedVertices();
texpaint_pack.g4.end();
- if (UIHeader.inst.worktab.position == Space3D &&
+ if (UIHeader.worktab.position == Space3D &&
BrushOutputNode.inst.inputs[ChannelHeight].node.constructor != FloatNode) {
// Make copy of vertices before displacement
diff --git a/armorpaint/Sources/ImportFolder.ts b/armorpaint/Sources/ImportFolder.ts
index e26a89f7..dc34eef4 100644
--- a/armorpaint/Sources/ImportFolder.ts
+++ b/armorpaint/Sources/ImportFolder.ts
@@ -116,7 +116,7 @@ class ImportFolder {
MakeMaterial.parsePaintMaterial();
UtilRender.makeMaterialPreview();
- UIBase.inst.hwnds[1].redraws = 2;
+ UIBase.hwnds[1].redraws = 2;
History.newMaterial();
}
diff --git a/armorpaint/Sources/MakeMaterial.ts b/armorpaint/Sources/MakeMaterial.ts
index 1e4bc0a4..f685cb4d 100644
--- a/armorpaint/Sources/MakeMaterial.ts
+++ b/armorpaint/Sources/MakeMaterial.ts
@@ -9,7 +9,7 @@ class MakeMaterial {
static subsUsed = false;
static getMOut = (): bool => {
- for (let n of UINodes.inst.getCanvasMaterial().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
+ for (let n of UINodes.getCanvasMaterial().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
return false;
}
@@ -202,7 +202,7 @@ class MakeMaterial {
}
}
- let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.inst.getCanvasMaterial() });
+ let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.getCanvasMaterial() });
let tmcon: TMaterialContext = { name: "paint", bind_textures: [] };
let con = MakePaint.run(sdata, tmcon);
@@ -227,7 +227,7 @@ class MakeMaterial {
static bakeNodePreviews = () => {
Context.raw.nodePreviewsUsed = [];
if (Context.raw.nodePreviews == null) Context.raw.nodePreviews = new Map();
- MakeMaterial.traverseNodes(UINodes.inst.getCanvasMaterial().nodes, null, []);
+ MakeMaterial.traverseNodes(UINodes.getCanvasMaterial().nodes, null, []);
for (let key of Context.raw.nodePreviews.keys()) {
if (Context.raw.nodePreviewsUsed.indexOf(key) == -1) {
let image = Context.raw.nodePreviews.get(key);
@@ -267,7 +267,7 @@ class MakeMaterial {
}
ParserMaterial.blur_passthrough = true;
- UtilRender.makeNodePreview(UINodes.inst.getCanvasMaterial(), node, image, group, parents);
+ UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
ParserMaterial.blur_passthrough = false;
}
else if (node.type == "DIRECT_WARP") {
@@ -283,7 +283,7 @@ class MakeMaterial {
}
ParserMaterial.warp_passthrough = true;
- UtilRender.makeNodePreview(UINodes.inst.getCanvasMaterial(), node, image, group, parents);
+ UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
ParserMaterial.warp_passthrough = false;
}
else if (node.type == "BAKE_CURVATURE") {
@@ -302,10 +302,10 @@ class MakeMaterial {
RenderPathPaint.liveLayer = new SlotLayer("_live");
}
- let _space = UIHeader.inst.worktab.position;
+ let _space = UIHeader.worktab.position;
let _tool = Context.raw.tool;
let _bakeType = Context.raw.bakeType;
- UIHeader.inst.worktab.position = SpaceType.Space3D;
+ UIHeader.worktab.position = SpaceType.Space3D;
Context.raw.tool = WorkspaceTool.ToolBake;
Context.raw.bakeType = BakeType.BakeCurvature;
@@ -325,7 +325,7 @@ class MakeMaterial {
RenderPathPaint.useLiveLayer(false);
Context.raw.pdirty = 0;
- UIHeader.inst.worktab.position = _space;
+ UIHeader.worktab.position = _space;
Context.raw.tool = _tool;
Context.raw.bakeType = _bakeType;
MakeMaterial.parsePaintMaterial(false);
@@ -341,7 +341,7 @@ class MakeMaterial {
static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = null): { scon: ShaderContext, mcon: MaterialContext } => {
if (node.outputs.length == 0) return null;
- let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.inst.getCanvasMaterial() });
+ let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.getCanvasMaterial() });
let mcon_raw: TMaterialContext = { name: "mesh", bind_textures: [] };
let con = MakeNodePreview.run(sdata, mcon_raw, node, group, parents);
let compileError = false;
diff --git a/armorpaint/Sources/MakeMeshPreview.ts b/armorpaint/Sources/MakeMeshPreview.ts
index 8ec29e7f..e88b6937 100644
--- a/armorpaint/Sources/MakeMeshPreview.ts
+++ b/armorpaint/Sources/MakeMeshPreview.ts
@@ -52,7 +52,7 @@ class MakeMeshPreview {
ParserMaterial.sample_uv_scale = brushScale;
ParserMaterial.parse_height = MakeMaterial.heightUsed;
ParserMaterial.parse_height_as_channel = true;
- let sout = ParserMaterial.parse(UINodes.inst.getCanvasMaterial(), con_mesh, vert, frag, matcon);
+ let sout = ParserMaterial.parse(UINodes.getCanvasMaterial(), con_mesh, vert, frag, matcon);
ParserMaterial.parse_height = false;
ParserMaterial.parse_height_as_channel = false;
ParserMaterial.sample_keep_aspect = false;
diff --git a/armorpaint/Sources/MakePaint.ts b/armorpaint/Sources/MakePaint.ts
index 08897a59..dd8e7b6f 100644
--- a/armorpaint/Sources/MakePaint.ts
+++ b/armorpaint/Sources/MakePaint.ts
@@ -200,7 +200,7 @@ class MakePaint {
ParserMaterial.triplanar = uvType == UVType.UVTriplanar && !decal;
ParserMaterial.sample_keep_aspect = decal;
ParserMaterial.sample_uv_scale = 'brushScale';
- let sout = ParserMaterial.parse(UINodes.inst.getCanvasMaterial(), con_paint, vert, frag, matcon);
+ let sout = ParserMaterial.parse(UINodes.getCanvasMaterial(), con_paint, vert, frag, matcon);
ParserMaterial.parse_emission = false;
ParserMaterial.parse_subsurface = false;
ParserMaterial.parse_height_as_channel = false;
diff --git a/armorpaint/Sources/RenderPathPaint.ts b/armorpaint/Sources/RenderPathPaint.ts
index e5bacd73..d7561af1 100644
--- a/armorpaint/Sources/RenderPathPaint.ts
+++ b/armorpaint/Sources/RenderPathPaint.ts
@@ -141,7 +141,7 @@ class RenderPathPaint {
RenderPathPaint.path.clearTarget(0xff000000);
RenderPathPaint.path.bindTarget("gbuffer2", "gbuffer2");
RenderPathPaint.path.drawMeshes("paint");
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) {
if (Context.raw.pickPosNorTex) {
@@ -177,8 +177,8 @@ class RenderPathPaint {
RenderPathPaint.path.bindTarget("texpaint_pack" + tid, "texpaint_pack");
RenderPathPaint.path.drawMeshes("paint");
if (useLiveLayer) RenderPathPaint.useLiveLayer(false);
- UIHeader.inst.headerHandle.redraws = 2;
- UIBase.inst.hwnds[2].redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
+ UIBase.hwnds[2].redraws = 2;
let texpaint_picker = RenderPathPaint.path.renderTargets.get("texpaint_picker").image;
let texpaint_nor_picker = RenderPathPaint.path.renderTargets.get("texpaint_nor_picker").image;
@@ -434,7 +434,7 @@ class RenderPathPaint {
RenderPathPaint.liveLayerDrawn = 2;
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
let _x = Context.raw.paintVec.x;
let _y = Context.raw.paintVec.y;
if (Context.raw.brushLocked) {
@@ -745,7 +745,7 @@ class RenderPathPaint {
///if (krom_direct3d12 || krom_vulkan || krom_metal)
else if (isRaytracedBake) {
let dirty = RenderPathRaytraceBake.commands(MakeMaterial.parsePaintMaterial);
- if (dirty) UIHeader.inst.headerHandle.redraws = 2;
+ if (dirty) UIHeader.headerHandle.redraws = 2;
if (Config.raw.dilate == DilateType.DilateInstant) { // && Context.raw.pdirty == 1
RenderPathPaint.dilate(true, false);
}
@@ -807,9 +807,9 @@ class RenderPathPaint {
cam.buildProjection();
cam.buildMatrix();
- let tw = 0.95 * UIView2D.inst.panScale;
- let tx = UIView2D.inst.panX / UIView2D.inst.ww;
- let ty = UIView2D.inst.panY / App.h();
+ let tw = 0.95 * UIView2D.panScale;
+ let tx = UIView2D.panX / UIView2D.ww;
+ let ty = UIView2D.panY / App.h();
m.setIdentity();
m.scale(new Vec4(tw, tw, 1));
m.setLoc(new Vec4(tx, ty, 0));
@@ -817,7 +817,7 @@ class RenderPathPaint {
m2.getInverse(Scene.active.camera.VP);
m.multmat(m2);
- let tiled = UIView2D.inst.tiledShow;
+ let tiled = UIView2D.tiledShow;
if (tiled && Scene.active.getChild(".PlaneTiled") == null) {
// 3x3 planes
let posa = [32767,0,-32767,0,10922,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,10922,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,32767,0,-32767,0,10922,0,10922,0,10922,0,-10922,0,32767,0,-10922,0,10922,0,32767,0,10922,0,10922,0,32767,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,10922,0,-32767,0,-10922,0,32767,0,-10922,0,10922,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,-32767,0,-10922,0,-32767,0,-32767,0,10922,0,-32767,0,-10922,0,-10922,0,-10922,0,-32767,0,32767,0,-32767,0,32767,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,32767,0,-32767,0,32767,0,10922,0,10922,0,10922,0,32767,0,-10922,0,32767,0,32767,0,10922,0,32767,0,32767,0,10922,0,32767,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,10922,0,32767,0,-10922,0,32767,0,10922,0,10922,0,10922,0,-10922,0,-32767,0,-10922,0,-10922,0,-32767,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,-10922,0];
diff --git a/armorpaint/Sources/SlotLayer.ts b/armorpaint/Sources/SlotLayer.ts
index 2205b6e1..0595582b 100644
--- a/armorpaint/Sources/SlotLayer.ts
+++ b/armorpaint/Sources/SlotLayer.ts
@@ -401,7 +401,7 @@ class SlotLayer {
let _next = () => {
MakeMaterial.parsePaintMaterial();
Context.raw.layerPreviewDirty = true;
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
}
Base.notifyOnNextFrame(_next);
}
@@ -411,7 +411,7 @@ class SlotLayer {
this.fill_layer = null;
MakeMaterial.parsePaintMaterial();
Context.raw.layerPreviewDirty = true;
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
}
isVisible = (): bool => {
@@ -624,7 +624,7 @@ class SlotLayer {
Context.setLayer(this);
History.orderLayers(to);
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
array_remove(Project.layers, this);
Project.layers.splice(to, 0, this);
diff --git a/armorpaint/Sources/TabLayers.ts b/armorpaint/Sources/TabLayers.ts
index a580d027..32593334 100644
--- a/armorpaint/Sources/TabLayers.ts
+++ b/armorpaint/Sources/TabLayers.ts
@@ -11,7 +11,7 @@ class TabLayers {
}
static drawMini = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.setHoveredTabName(tr("Layers"));
let _ELEMENT_H = ui.t.ELEMENT_H;
@@ -34,7 +34,7 @@ class TabLayers {
}
static drawFull = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Layers"))) {
ui.beginSticky();
ui.row([1 / 4, 1 / 4, 1 / 2]);
@@ -52,9 +52,9 @@ class TabLayers {
}
static button2dView = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.button(tr("2D View"))) {
- UIBase.inst.show2DView(View2DType.View2DLayer);
+ UIBase.show2DView(View2DType.View2DLayer);
}
else if (ui.isHovered) ui.tooltip(tr("Show 2D View") + ` (${Config.keymap.toggle_2d_view})`);
}
@@ -69,9 +69,9 @@ class TabLayers {
}
static highlightOddLines = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H * 2;
- let fullH = ui._windowH - UIBase.inst.hwnds[0].scrollOffset;
+ let fullH = ui._windowH - UIBase.hwnds[0].scrollOffset;
for (let i = 0; i < Math.floor(fullH / step); ++i) {
if (i % 2 == 0) {
ui.fill(0, i * step, (ui._w / ui.SCALE() - 2), step, ui.t.WINDOW_BG_COL - 0x00040404);
@@ -80,7 +80,7 @@ class TabLayers {
}
static buttonNew = (text: string) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.button(text)) {
UIMenu.draw((ui: Zui) => {
let l = Context.raw.layer;
@@ -155,7 +155,7 @@ class TabLayers {
}
static comboFilter = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let ar = [tr("All")];
for (let p of Project.paintObjects) ar.push(p.name);
let atlases = Project.getUsedAtlases();
@@ -215,7 +215,7 @@ class TabLayers {
}
static drawLayerSlot = (l: SlotLayer, i: i32, mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (Context.raw.layerFilter > 0 &&
l.getObjectMask() > 0 &&
@@ -281,7 +281,7 @@ class TabLayers {
}
static drawLayerSlotMini = (l: SlotLayer, i: i32) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.row([1, 1]);
let uix = ui._x;
@@ -295,7 +295,7 @@ class TabLayers {
}
static drawLayerSlotFull = (l: SlotLayer, i: i32) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H;
@@ -508,12 +508,12 @@ class TabLayers {
static layerToggleVisible = (l: SlotLayer) => {
l.visible = !l.visible;
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
MakeMaterial.parseMeshMaterial();
}
static drawLayerHighlight = (l: SlotLayer, mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H;
// Separator line
@@ -531,7 +531,7 @@ class TabLayers {
}
static handleLayerIconState = (l: SlotLayer, i: i32, state: State, uix: f32, uiy: f32) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
///if is_paint
let texpaint_preview = l.texpaint_preview;
@@ -568,7 +568,7 @@ class TabLayers {
}
else if (state == State.Released) {
if (Time.time() - Context.raw.selectTime < 0.2) {
- UIBase.inst.show2DView(View2DType.View2DLayer);
+ UIBase.show2DView(View2DType.View2DLayer);
}
if (Time.time() - Context.raw.selectTime > 0.2) {
Context.raw.selectTime = Time.time();
@@ -578,7 +578,7 @@ class TabLayers {
}
static drawLayerIcon = (l: SlotLayer, i: i32, uix: f32, uiy: f32, mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let icons = Res.get("icons.k");
let iconH = (ui.ELEMENT_H() - (mini ? 2 : 3)) * 2;
@@ -631,7 +631,7 @@ class TabLayers {
}
// Draw layer numbers when selecting a layer via keyboard shortcut
- let isTyping = ui.isTyping || UIView2D.inst.ui.isTyping || UINodes.inst.ui.isTyping;
+ let isTyping = ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping;
if (!isTyping) {
if (i < 9 && Operator.shortcut(Config.keymap.select_layer, ShortcutType.ShortcutDown)) {
let number = String(i + 1) ;
diff --git a/armorpaint/Sources/nodes/BrushOutputNode.ts b/armorpaint/Sources/nodes/BrushOutputNode.ts
index 7cd66b35..5701e4ed 100644
--- a/armorpaint/Sources/nodes/BrushOutputNode.ts
+++ b/armorpaint/Sources/nodes/BrushOutputNode.ts
@@ -82,7 +82,7 @@ class BrushOutputNode extends LogicNode {
let right = 1.0;
if (Context.raw.paint2d) {
left = 1.0;
- right = (Context.raw.splitView ? 2.0 : 1.0) + UIView2D.inst.ww / Base.w();
+ right = (Context.raw.splitView ? 2.0 : 1.0) + UIView2D.ww / Base.w();
}
// First time init
@@ -105,7 +105,7 @@ class BrushOutputNode extends LogicNode {
!fillLayer &&
!groupLayer &&
(Context.raw.layer.isVisible() || Context.raw.paint2d) &&
- !UIBase.inst.ui.isHovered &&
+ !UIBase.ui.isHovered &&
!Base.isDragging &&
!Base.isResizing &&
!Base.isScrolling() &&
@@ -115,7 +115,7 @@ class BrushOutputNode extends LogicNode {
let down = Input.getMouse().down() || Input.getPen().down();
if (down && Context.raw.tool == WorkspaceTool.ToolColorId && Project.assets.length > 0) {
Context.raw.colorIdPicked = true;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
}
// Prevent painting the same spot
diff --git a/armorsculpt/Sources/ImportMesh.ts b/armorsculpt/Sources/ImportMesh.ts
index 005c9cfb..d1953949 100644
--- a/armorsculpt/Sources/ImportMesh.ts
+++ b/armorsculpt/Sources/ImportMesh.ts
@@ -63,7 +63,7 @@ class ImportMesh {
MakeMaterial.parsePaintMaterial();
MakeMaterial.parseMeshMaterial();
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
///if arm_physics
Context.raw.paintBody = null;
@@ -113,8 +113,8 @@ class ImportMesh {
Data.cachedMeshes.set(md.handle, md);
Context.raw.ddirty = 4;
- UIBase.inst.hwnds[TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabSidebar1].redraws = 2;
// Wait for addMesh calls to finish
App.notifyOnInit(finishImport);
@@ -169,7 +169,7 @@ class ImportMesh {
Data.cachedMeshes.set(md.handle, md);
Context.raw.ddirty = 4;
- UIBase.inst.hwnds[TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabSidebar0].redraws = 2;
});
}
diff --git a/armorsculpt/Sources/MakeMaterial.ts b/armorsculpt/Sources/MakeMaterial.ts
index 2fef4d1a..c6ae695e 100644
--- a/armorsculpt/Sources/MakeMaterial.ts
+++ b/armorsculpt/Sources/MakeMaterial.ts
@@ -9,7 +9,7 @@ class MakeMaterial {
static subsUsed = false;
static getMOut = (): bool => {
- for (let n of UINodes.inst.getCanvasMaterial().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
+ for (let n of UINodes.getCanvasMaterial().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
return false;
}
@@ -198,7 +198,7 @@ class MakeMaterial {
}
}
- let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.inst.getCanvasMaterial() });
+ let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.getCanvasMaterial() });
let mcon: TMaterialContext = { name: "paint", bind_textures: [] };
let con = MakeSculpt.run(sdata, mcon);
@@ -223,7 +223,7 @@ class MakeMaterial {
static bakeNodePreviews = () => {
Context.raw.nodePreviewsUsed = [];
if (Context.raw.nodePreviews == null) Context.raw.nodePreviews = [];
- traverseNodes(UINodes.inst.getCanvasMaterial().nodes, null, []);
+ traverseNodes(UINodes.getCanvasMaterial().nodes, null, []);
for (let key of Context.raw.nodePreviews.keys()) {
if (Context.raw.nodePreviewsUsed.indexOf(key) == -1) {
let image = Context.raw.nodePreviews.get(key);
@@ -263,7 +263,7 @@ class MakeMaterial {
}
ParserMaterial.blur_passthrough = true;
- UtilRender.makeNodePreview(UINodes.inst.getCanvasMaterial(), node, image, group, parents);
+ UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
ParserMaterial.blur_passthrough = false;
}
else if (node.type == "DIRECT_WARP") {
@@ -279,14 +279,14 @@ class MakeMaterial {
}
ParserMaterial.warp_passthrough = true;
- UtilRender.makeNodePreview(UINodes.inst.getCanvasMaterial(), node, image, group, parents);
+ UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
ParserMaterial.warp_passthrough = false;
}
}
static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = null): { scon: ShaderContext, mcon: MaterialContext } => {
if (node.outputs.length == 0) return null;
- let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.inst.getCanvasMaterial() });
+ let sdata = new NodeShaderData({ name: "Material", canvas: UINodes.getCanvasMaterial() });
let mcon_raw: TMaterialContext = { name: "mesh", bind_textures: [] };
let con = MakeNodePreview.run(sdata, mcon_raw, node, group, parents);
let compileError = false;
diff --git a/armorsculpt/Sources/MakeMeshPreview.ts b/armorsculpt/Sources/MakeMeshPreview.ts
index 6dfd9b45..bf8bb25e 100644
--- a/armorsculpt/Sources/MakeMeshPreview.ts
+++ b/armorsculpt/Sources/MakeMeshPreview.ts
@@ -53,7 +53,7 @@ class MakeMeshPreview {
ParserMaterial.sample_uv_scale = brushScale;
ParserMaterial.parse_height = MakeMaterial.heightUsed;
ParserMaterial.parse_height_as_channel = true;
- // let sout = ParserMaterial.parse(UINodes.inst.getCanvasMaterial(), con_mesh, vert, frag, matcon);
+ // let sout = ParserMaterial.parse(UINodes.getCanvasMaterial(), con_mesh, vert, frag, matcon);
ParserMaterial.parse_height = false;
ParserMaterial.parse_height_as_channel = false;
ParserMaterial.sample_keep_aspect = false;
diff --git a/armorsculpt/Sources/TabLayers.ts b/armorsculpt/Sources/TabLayers.ts
index 8a58ffb2..41a3a8ea 100644
--- a/armorsculpt/Sources/TabLayers.ts
+++ b/armorsculpt/Sources/TabLayers.ts
@@ -11,7 +11,7 @@ class TabLayers {
}
static drawMini = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.setHoveredTabName(tr("Layers"));
let _ELEMENT_H = ui.t.ELEMENT_H;
@@ -33,7 +33,7 @@ class TabLayers {
}
static drawFull = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Layers"))) {
ui.beginSticky();
ui.row([1 / 4, 3 / 4]);
@@ -59,9 +59,9 @@ class TabLayers {
}
static highlightOddLines = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H * 2;
- let fullH = ui._windowH - UIBase.inst.hwnds[0].scrollOffset;
+ let fullH = ui._windowH - UIBase.hwnds[0].scrollOffset;
for (let i = 0; i < Math.floor(fullH / step); ++i) {
if (i % 2 == 0) {
ui.fill(0, i * step, (ui._w / ui.SCALE() - 2), step, ui.t.WINDOW_BG_COL - 0x00040404);
@@ -70,7 +70,7 @@ class TabLayers {
}
static buttonNew = (text: string) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.button(text)) {
UIMenu.draw((ui: Zui) => {
let l = Context.raw.layer;
@@ -83,7 +83,7 @@ class TabLayers {
}
static comboFilter = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let ar = [tr("All")];
let filterHandle = Zui.handle("tablayers_0");
filterHandle.position = Context.raw.layerFilter;
@@ -121,7 +121,7 @@ class TabLayers {
}
static drawLayerSlot = (l: SlotLayer, i: i32, mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (Context.raw.layerFilter > 0 &&
l.getObjectMask() > 0 &&
@@ -187,7 +187,7 @@ class TabLayers {
}
static drawLayerSlotMini = (l: SlotLayer, i: i32) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.row([1, 1]);
let uix = ui._x;
@@ -200,7 +200,7 @@ class TabLayers {
}
static drawLayerSlotFull = (l: SlotLayer, i: i32) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H;
@@ -347,12 +347,12 @@ class TabLayers {
static layerToggleVisible = (l: SlotLayer) => {
l.visible = !l.visible;
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
MakeMaterial.parseMeshMaterial();
}
static drawLayerHighlight = (l: SlotLayer, mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let step = ui.t.ELEMENT_H;
// Separator line
diff --git a/armorsculpt/Sources/nodes/BrushOutputNode.ts b/armorsculpt/Sources/nodes/BrushOutputNode.ts
index 058e132f..70fe1bd6 100644
--- a/armorsculpt/Sources/nodes/BrushOutputNode.ts
+++ b/armorsculpt/Sources/nodes/BrushOutputNode.ts
@@ -76,7 +76,7 @@ class BrushOutputNode extends LogicNode {
let right = 1.0;
if (Context.raw.paint2d) {
left = 1.0;
- right = (Context.raw.splitView ? 2.0 : 1.0) + UIView2D.inst.ww / Base.w();
+ right = (Context.raw.splitView ? 2.0 : 1.0) + UIView2D.ww / Base.w();
}
// First time init
@@ -99,7 +99,7 @@ class BrushOutputNode extends LogicNode {
!fillLayer &&
!groupLayer &&
(Context.raw.layer.isVisible() || Context.raw.paint2d) &&
- !UIBase.inst.ui.isHovered &&
+ !UIBase.ui.isHovered &&
!Base.isDragging &&
!Base.isResizing &&
!Base.isScrolling() &&
diff --git a/base/Sources/Args.ts b/base/Sources/Args.ts
index d0a82d87..cf48bcac 100644
--- a/base/Sources/Args.ts
+++ b/base/Sources/Args.ts
@@ -89,7 +89,7 @@ class Args {
ImportAsset.run(Args.assetPath, -1, -1, false);
///if is_paint
if (Path.isTexture(Args.assetPath)) {
- UIBase.inst.show2DView(View2DType.View2DAsset);
+ UIBase.show2DView(View2DType.View2DAsset);
}
///end
}
diff --git a/base/Sources/Base.ts b/base/Sources/Base.ts
index 25622845..3745ecca 100644
--- a/base/Sources/Base.ts
+++ b/base/Sources/Base.ts
@@ -186,20 +186,20 @@ class Base {
///end
App.notifyOnUpdate(Base.update);
- App.notifyOnRender2D(UIView2D.inst.render);
- App.notifyOnUpdate(UIView2D.inst.update);
+ App.notifyOnRender2D(UIView2D.render);
+ App.notifyOnUpdate(UIView2D.update);
///if (is_paint || is_sculpt)
- App.notifyOnRender2D(UIBase.inst.renderCursor);
+ App.notifyOnRender2D(UIBase.renderCursor);
///end
- App.notifyOnUpdate(UINodes.inst.update);
- App.notifyOnRender2D(UINodes.inst.render);
- App.notifyOnUpdate(UIBase.inst.update);
- App.notifyOnRender2D(UIBase.inst.render);
- App.notifyOnUpdate(Camera.inst.update);
+ App.notifyOnUpdate(UINodes.update);
+ App.notifyOnRender2D(UINodes.render);
+ App.notifyOnUpdate(UIBase.update);
+ App.notifyOnRender2D(UIBase.render);
+ App.notifyOnUpdate(Camera.update);
App.notifyOnRender2D(Base.render);
///if (is_paint || is_sculpt)
- Base.appx = UIToolbar.inst.toolbarw;
+ Base.appx = UIToolbar.toolbarw;
///end
///if is_lab
Base.appx = 0;
@@ -236,34 +236,34 @@ class Base {
///if (is_paint || is_sculpt)
static w = (): i32 => {
// Drawing material preview
- if (UIBase.inst != null && Context.raw.materialPreview) {
+ if (UIBase != null && Context.raw.materialPreview) {
return UtilRender.materialPreviewSize;
}
// Drawing decal preview
- if (UIBase.inst != null && Context.raw.decalPreview) {
+ if (UIBase != null && Context.raw.decalPreview) {
return UtilRender.decalPreviewSize;
}
let res = 0;
- if (UINodes.inst == null || UIBase.inst == null) {
+ if (UINodes == null || UIBase == null) {
let sidebarw = Config.raw.layout == null ? UIBase.defaultSidebarW : Config.raw.layout[LayoutSize.LayoutSidebarW];
res = System.width - sidebarw - UIToolbar.defaultToolbarW;
}
- else if (UINodes.inst.show || UIView2D.inst.show) {
- res = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - Config.raw.layout[LayoutSize.LayoutNodesW] - UIToolbar.inst.toolbarw;
+ else if (UINodes.show || UIView2D.show) {
+ res = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - Config.raw.layout[LayoutSize.LayoutNodesW] - UIToolbar.toolbarw;
}
- else if (UIBase.inst.show) {
- res = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - UIToolbar.inst.toolbarw;
+ else if (UIBase.show) {
+ res = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - UIToolbar.toolbarw;
}
else { // Distract free
res = System.width;
}
- if (UIBase.inst != null && Context.raw.viewIndex > -1) {
+ if (UIBase != null && Context.raw.viewIndex > -1) {
res = Math.floor(res / 2);
}
if (Context.raw.paint2dView) {
- res = UIView2D.inst.ww;
+ res = UIView2D.ww;
}
return res > 0 ? res : 1; // App was minimized, force render path resize
@@ -271,18 +271,18 @@ class Base {
static h = (): i32 => {
// Drawing material preview
- if (UIBase.inst != null && Context.raw.materialPreview) {
+ if (UIBase != null && Context.raw.materialPreview) {
return UtilRender.materialPreviewSize;
}
// Drawing decal preview
- if (UIBase.inst != null && Context.raw.decalPreview) {
+ if (UIBase != null && Context.raw.decalPreview) {
return UtilRender.decalPreviewSize;
}
let res = System.height;
- if (UIBase.inst == null) {
+ if (UIBase == null) {
res -= UIHeader.defaultHeaderH * 2 + UIStatus.defaultStatusH;
///if (krom_android || krom_ios)
@@ -294,7 +294,7 @@ class Base {
res += UIHeader.headerh;
}
}
- else if (UIBase.inst != null && UIBase.inst.show && res > 0) {
+ else if (UIBase != null && UIBase.show && res > 0) {
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
res -= Math.floor(UIHeader.defaultHeaderH * 2 * Config.raw.window_scale) + statush;
@@ -310,10 +310,10 @@ class Base {
///if is_lab
static w = (): i32 => {
let res = 0;
- if (UINodes.inst == null) {
+ if (UINodes == null) {
res = System.width;
}
- else if (UINodes.inst.show || UIView2D.inst.show) {
+ else if (UINodes.show || UIView2D.show) {
res = System.width - Config.raw.layout[LayoutSize.LayoutNodesW];
}
else { // Distract free
@@ -325,10 +325,10 @@ class Base {
static h = (): i32 => {
let res = System.height;
- if (UIBase.inst == null) {
+ if (UIBase == null) {
res -= UIHeader.defaultHeaderH * 2 + UIStatus.defaultStatusH;
}
- else if (UIBase.inst != null && res > 0) {
+ else if (UIBase != null && res > 0) {
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
res -= Math.floor(UIHeader.defaultHeaderH * 2 * Config.raw.window_scale) + statush;
}
@@ -397,9 +397,9 @@ class Base {
Context.raw.ddirty = 2;
- if (UIBase.inst.show) {
+ if (UIBase.show) {
///if (is_paint || is_sculpt)
- Base.appx = UIToolbar.inst.toolbarw;
+ Base.appx = UIToolbar.toolbarw;
///end
///if is_lab
Base.appx = 0;
@@ -414,31 +414,31 @@ class Base {
Base.appy = 0;
}
- if (UINodes.inst.grid != null) {
- let _grid = UINodes.inst.grid;
+ if (UINodes.grid != null) {
+ let _grid = UINodes.grid;
let _next = () => {
_grid.unload();
}
Base.notifyOnNextFrame(_next);
- UINodes.inst.grid = null;
+ UINodes.grid = null;
}
Base.redrawUI();
}
static redrawUI = () => {
- UIHeader.inst.headerHandle.redraws = 2;
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
- UIMenubar.inst.menuHandle.redraws = 2;
- UIMenubar.inst.workspaceHandle.redraws = 2;
- UINodes.inst.hwnd.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+ UIMenubar.menuHandle.redraws = 2;
+ UIMenubar.workspaceHandle.redraws = 2;
+ UINodes.hwnd.redraws = 2;
UIBox.hwnd.redraws = 2;
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
if (Context.raw.ddirty < 0) Context.raw.ddirty = 0; // Redraw viewport
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
- UIToolbar.inst.toolbarHandle.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIToolbar.toolbarHandle.redraws = 2;
if (Context.raw.splitView) Context.raw.ddirty = 1;
///end
}
@@ -490,7 +490,7 @@ class Base {
if (mouse.released() && hasDrag) {
if (Base.dragAsset != null) {
if (Context.inNodes()) { // Create image texture
- UINodes.inst.acceptAssetDrag(Project.assets.indexOf(Base.dragAsset));
+ UINodes.acceptAssetDrag(Project.assets.indexOf(Base.dragAsset));
}
else if (Context.inViewport()) {
if (Base.dragAsset.file.toLowerCase().endsWith(".hdr")) {
@@ -507,7 +507,7 @@ class Base {
}
else if (Base.dragSwatch != null) {
if (Context.inNodes()) { // Create RGB node
- UINodes.inst.acceptSwatchDrag(Base.dragSwatch);
+ UINodes.acceptSwatchDrag(Base.dragSwatch);
}
else if (Context.inSwatches()) {
TabSwatches.acceptSwatchDrag(Base.dragSwatch);
@@ -559,7 +559,7 @@ class Base {
}
else if (Base.dragLayer != null) {
if (Context.inNodes()) {
- UINodes.inst.acceptLayerDrag(Project.layers.indexOf(Base.dragLayer));
+ UINodes.acceptLayerDrag(Project.layers.indexOf(Base.dragLayer));
}
else if (Context.inLayers() && Base.isDragging) {
Base.dragLayer.move(Context.raw.dragDestination);
@@ -589,7 +589,7 @@ class Base {
Base.isDragging ||
isPicker ||
decal ||
- UIView2D.inst.show ||
+ UIView2D.show ||
!Config.raw.brush_3d ||
Context.raw.frame < 3;
///end
@@ -612,7 +612,7 @@ class Base {
Base.createFillLayer(uvType, decalMat, Context.raw.dragDestination);
}
else if (Context.inNodes()) {
- UINodes.inst.acceptMaterialDrag(Project.materials.indexOf(Base.dragMaterial));
+ UINodes.acceptMaterialDrag(Project.materials.indexOf(Base.dragMaterial));
}
Base.dragMaterial = null;
}
@@ -661,7 +661,7 @@ class Base {
if (Base.dragFileIcon != null) return Base.dragFileIcon;
let icons = Res.get("icons.k");
Base.dragRect = Base.dragFile.indexOf(".") > 0 ? Res.tile50(icons, 3, 1) : Res.tile50(icons, 2, 1);
- Base.dragTint = UIBase.inst.ui.t.HIGHLIGHT_COL;
+ Base.dragTint = UIBase.ui.t.HIGHLIGHT_COL;
return icons;
}
@@ -674,7 +674,7 @@ class Base {
let folderClosed = Res.tile50(icons, 2, 1);
let folderOpen = Res.tile50(icons, 8, 1);
Base.dragRect = Base.dragLayer.show_panel ? folderOpen : folderClosed;
- Base.dragTint = UIBase.inst.ui.t.LABEL_COL - 0x00202020;
+ Base.dragTint = UIBase.ui.t.LABEL_COL - 0x00202020;
return icons;
}
if (Base.dragLayer != null && Base.dragLayer.isMask() && Base.dragLayer.fill_layer == null) {
@@ -695,7 +695,7 @@ class Base {
if (Context.raw.frame == 2) {
///if (is_paint || is_sculpt)
UtilRender.makeMaterialPreview();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
///end
MakeMaterial.parseMeshMaterial();
@@ -714,9 +714,9 @@ class Base {
// Default workspace
if (Config.raw.workspace != 0) {
- UIHeader.inst.worktab.position = Config.raw.workspace;
- UIMenubar.inst.workspaceHandle.redraws = 2;
- UIHeader.inst.worktab.changed = true;
+ UIHeader.worktab.position = Config.raw.workspace;
+ UIMenubar.workspaceHandle.redraws = 2;
+ UIHeader.worktab.changed = true;
}
// Default camera controls
@@ -750,7 +750,7 @@ class Base {
let img = Base.getDragImage();
///if (is_paint || is_sculpt)
- let scaleFactor = UIBase.inst.ui.SCALE();
+ let scaleFactor = UIBase.ui.SCALE();
///end
///if is_lab
let scaleFactor = Base.uiBox.SCALE();
@@ -872,7 +872,7 @@ class Base {
}
static getUIs = (): Zui[] => {
- return [Base.uiBox, Base.uiMenu, UIBase.inst.ui, UINodes.inst.ui, UIView2D.inst.ui];
+ return [Base.uiBox, Base.uiMenu, UIBase.ui, UINodes.ui, UIView2D.ui];
}
static isDecalLayer = (): bool => {
@@ -887,20 +887,18 @@ class Base {
}
static redrawStatus = () => {
- if (UIStatus.inst != null) {
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
- }
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
}
static redrawConsole = () => {
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
- if (UIStatus.inst != null && UIBase.inst != null && UIBase.inst.ui != null && statush > UIStatus.defaultStatusH * UIBase.inst.ui.SCALE()) {
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ if (UIBase != null && UIBase.ui != null && statush > UIStatus.defaultStatusH * UIBase.ui.SCALE()) {
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
}
}
static initLayout = () => {
- let show2d = (UINodes.inst != null && UINodes.inst.show) || (UIView2D.inst != null && UIView2D.inst.show);
+ let show2d = (UINodes != null && UINodes.show) || (UIView2D != null && UIView2D.show);
let raw = Config.raw;
raw.layout = [
@@ -2145,8 +2143,8 @@ class Base {
let texpaint_nor = BrushOutputNode.inst.texpaint_nor;
let texpaint_pack = BrushOutputNode.inst.texpaint_pack;
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
if (nodes.nodesSelectedId.length > 0) {
let node = nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]);
let brushNode = ParserLogic.getLogicNode(node);
diff --git a/base/Sources/BoxPreferences.ts b/base/Sources/BoxPreferences.ts
index 71788b14..60436202 100644
--- a/base/Sources/BoxPreferences.ts
+++ b/base/Sources/BoxPreferences.ts
@@ -25,7 +25,7 @@ class BoxPreferences {
let localeCode = BoxPreferences.locales[localeHandle.position];
Config.raw.locale = localeCode;
Translator.loadTranslations(localeCode);
- UIBase.inst.tagUIRedraw();
+ UIBase.tagUIRedraw();
}
let hscale = Zui.handle("boxpreferences_1", { value: Config.raw.window_scale });
@@ -61,7 +61,7 @@ class BoxPreferences {
ui.changed = false;
Config.raw.show_asset_names = ui.check(Zui.handle("boxpreferences_8", { selected: Config.raw.show_asset_names }), tr("Show Asset Names"));
if (ui.changed) {
- UIBase.inst.tagUIRedraw();
+ UIBase.tagUIRedraw();
}
///if !(krom_android || krom_ios)
@@ -71,7 +71,7 @@ class BoxPreferences {
Zui.touchScroll = Zui.touchHold = Zui.touchTooltip = Config.raw.touch_ui;
Config.loadTheme(Config.raw.theme);
BoxPreferences.setScale();
- UIBase.inst.tagUIRedraw();
+ UIBase.tagUIRedraw();
}
///end
@@ -676,19 +676,19 @@ plugin.drawUI = (ui) { =>
static setScale = () => {
let scale = Config.raw.window_scale;
- UIBase.inst.ui.setScale(scale);
+ UIBase.ui.setScale(scale);
UIHeader.headerh = Math.floor(UIHeader.defaultHeaderH * scale);
Config.raw.layout[LayoutSize.LayoutStatusH] = Math.floor(UIStatus.defaultStatusH * scale);
- UIMenubar.inst.menubarw = Math.floor(UIMenubar.defaultMenubarW * scale);
- UIBase.inst.setIconScale();
- UINodes.inst.ui.setScale(scale);
- UIView2D.inst.ui.setScale(scale);
+ UIMenubar.menubarw = Math.floor(UIMenubar.defaultMenubarW * scale);
+ UIBase.setIconScale();
+ UINodes.ui.setScale(scale);
+ UIView2D.ui.setScale(scale);
Base.uiBox.setScale(scale);
Base.uiMenu.setScale(scale);
Base.resize();
///if (is_paint || is_sculpt)
Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(UIBase.defaultSidebarW * scale);
- UIToolbar.inst.toolbarw = Math.floor(UIToolbar.defaultToolbarW * scale);
+ UIToolbar.toolbarw = Math.floor(UIToolbar.defaultToolbarW * scale);
///end
}
}
diff --git a/base/Sources/Camera.ts b/base/Sources/Camera.ts
index 7d2605fa..2760ac56 100644
--- a/base/Sources/Camera.ts
+++ b/base/Sources/Camera.ts
@@ -1,35 +1,28 @@
class Camera {
- static inst: Camera;
- origins: Vec4[];
- views: Mat4[];
- redraws = 0;
- first = true;
- dir = new Vec4();
- ease = 1.0;
- controlsDown = false;
+ static origins: Vec4[];
+ static views: Mat4[];
+ static redraws = 0;
+ static dir = new Vec4();
+ static ease = 1.0;
+ static controlsDown = false;
constructor() {
- Camera.inst = this;
+ Camera.reset();
}
- update = () => {
+ static update = () => {
let mouse = Input.getMouse();
let kb = Input.getKeyboard();
let camera = Scene.active.camera;
- if (this.first) {
- this.first = false;
- this.reset();
- }
-
if (mouse.viewX < 0 ||
mouse.viewX > App.w() ||
mouse.viewY < 0 ||
mouse.viewY > App.h()) {
- if (Config.raw.wrap_mouse && this.controlsDown) {
+ if (Config.raw.wrap_mouse && Camera.controlsDown) {
if (mouse.viewX < 0) {
mouse.x = mouse.lastX = App.x() + App.w();
Krom.setMousePosition(Math.floor(mouse.x), Math.floor(mouse.y));
@@ -64,7 +57,7 @@ class Camera {
(mouse.started("right") && !modif) ||
(mouse.started("middle") && !modif) ||
(mouse.wheelDelta != 0 && !modifKey)) {
- this.controlsDown = true;
+ Camera.controlsDown = true;
}
else if (!Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) &&
!Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown) &&
@@ -74,7 +67,7 @@ class Camera {
!(mouse.down("right") && !modif) &&
!(mouse.down("middle") && !modif) &&
(mouse.wheelDelta == 0 && !modifKey)) {
- this.controlsDown = false;
+ Camera.controlsDown = false;
}
if (Input.occupied ||
@@ -82,14 +75,14 @@ class Camera {
Base.isDragging ||
Base.isScrolling() ||
Base.isComboSelected() ||
- !this.controlsDown) {
+ !Camera.controlsDown) {
return;
}
let controls = Context.raw.cameraControls;
if (controls == CameraControls.ControlsOrbit && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse.down("right") && !modif && defaultKeymap))) {
- this.redraws = 2;
- let dist = this.distance();
+ Camera.redraws = 2;
+ let dist = Camera.distance();
camera.transform.move(camera.lookWorld(), dist);
camera.transform.rotate(Vec4.zAxis(), -mouse.movementX / 100 * Config.raw.camera_rotation_speed);
camera.transform.rotate(camera.rightWorld(), -mouse.movementY / 100 * Config.raw.camera_rotation_speed);
@@ -99,7 +92,7 @@ class Camera {
camera.transform.move(camera.lookWorld(), -dist);
}
else if (controls == CameraControls.ControlsRotate && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse.down("right") && !modif && defaultKeymap))) {
- this.redraws = 2;
+ Camera.redraws = 2;
let t = Context.mainObject().transform;
let up = t.up().normalize();
t.rotate(up, mouse.movementX / 100 * Config.raw.camera_rotation_speed);
@@ -112,19 +105,19 @@ class Camera {
}
if (controls == CameraControls.ControlsRotate || controls == CameraControls.ControlsOrbit) {
- this.panAction(modif, defaultKeymap);
+ Camera.panAction(modif, defaultKeymap);
if (Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown)) {
- this.redraws = 2;
+ Camera.redraws = 2;
let f = Camera.getZoomDelta() / 150;
- f *= this.getCameraZoomSpeed();
+ f *= Camera.getCameraZoomSpeed();
camera.transform.move(camera.look(), f);
}
if (mouse.wheelDelta != 0 && !modifKey) {
- this.redraws = 2;
+ Camera.redraws = 2;
let f = mouse.wheelDelta * (-0.1);
- f *= this.getCameraZoomSpeed();
+ f *= Camera.getCameraZoomSpeed();
camera.transform.move(camera.look(), f);
}
}
@@ -141,37 +134,37 @@ class Camera {
}
if (moveForward || moveBackward || strafeRight || strafeLeft || strafeUp || strafeDown) {
- this.ease += Time.delta * 15;
- if (this.ease > 1.0) this.ease = 1.0;
- this.dir.set(0, 0, 0);
- if (moveForward) this.dir.addf(camera.look().x, camera.look().y, camera.look().z);
- if (moveBackward) this.dir.addf(-camera.look().x, -camera.look().y, -camera.look().z);
- if (strafeRight) this.dir.addf(camera.right().x, camera.right().y, camera.right().z);
- if (strafeLeft) this.dir.addf(-camera.right().x, -camera.right().y, -camera.right().z);
- if (strafeUp) this.dir.addf(0, 0, 1);
- if (strafeDown) this.dir.addf(0, 0, -1);
+ Camera.ease += Time.delta * 15;
+ if (Camera.ease > 1.0) Camera.ease = 1.0;
+ Camera.dir.set(0, 0, 0);
+ if (moveForward) Camera.dir.addf(camera.look().x, camera.look().y, camera.look().z);
+ if (moveBackward) Camera.dir.addf(-camera.look().x, -camera.look().y, -camera.look().z);
+ if (strafeRight) Camera.dir.addf(camera.right().x, camera.right().y, camera.right().z);
+ if (strafeLeft) Camera.dir.addf(-camera.right().x, -camera.right().y, -camera.right().z);
+ if (strafeUp) Camera.dir.addf(0, 0, 1);
+ if (strafeDown) Camera.dir.addf(0, 0, -1);
}
else {
- this.ease -= Time.delta * 20.0 * this.ease;
- if (this.ease < 0.0) this.ease = 0.0;
+ Camera.ease -= Time.delta * 20.0 * Camera.ease;
+ if (Camera.ease < 0.0) Camera.ease = 0.0;
}
- let d = Time.delta * fast * this.ease * 2.0 * ((moveForward || moveBackward) ? Config.raw.camera_zoom_speed : Config.raw.camera_pan_speed);
+ let d = Time.delta * fast * Camera.ease * 2.0 * ((moveForward || moveBackward) ? Config.raw.camera_zoom_speed : Config.raw.camera_pan_speed);
if (d > 0.0) {
- camera.transform.move(this.dir, d);
+ camera.transform.move(Camera.dir, d);
if (Context.raw.cameraType == CameraType.CameraOrthographic) {
Viewport.updateCameraType(Context.raw.cameraType);
}
}
- this.redraws = 2;
+ Camera.redraws = 2;
camera.transform.rotate(Vec4.zAxis(), -mouse.movementX / 200 * Config.raw.camera_rotation_speed);
camera.transform.rotate(camera.right(), -mouse.movementY / 200 * Config.raw.camera_rotation_speed);
}
if (Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutDown)) {
- this.redraws = 2;
+ Camera.redraws = 2;
let light = Scene.active.lights[0];
Context.raw.lightAngle = (Context.raw.lightAngle + ((mouse.movementX / 100) % (2 * Math.PI) + 2 * Math.PI)) % (2 * Math.PI);
let m = Mat4.rotationZ(mouse.movementX / 100);
@@ -180,12 +173,12 @@ class Camera {
}
if (Operator.shortcut(Config.keymap.rotate_envmap, ShortcutType.ShortcutDown)) {
- this.redraws = 2;
+ Camera.redraws = 2;
Context.raw.envmapAngle -= mouse.movementX / 100;
}
- if (this.redraws > 0) {
- this.redraws--;
+ if (Camera.redraws > 0) {
+ Camera.redraws--;
Context.raw.ddirty = 2;
if (Context.raw.cameraType == CameraType.CameraOrthographic) {
@@ -194,45 +187,45 @@ class Camera {
}
}
- distance = (): f32 => {
+ static distance = (): f32 => {
let camera = Scene.active.camera;
- return Vec4.distance(this.origins[this.index()], camera.transform.loc);
+ return Vec4.distance(Camera.origins[Camera.index()], camera.transform.loc);
}
- index = (): i32 => {
+ static index = (): i32 => {
return Context.raw.viewIndexLast > 0 ? 1 : 0;
}
- getCameraZoomSpeed = (): f32 => {
+ static getCameraZoomSpeed = (): f32 => {
let sign = Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ||
Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ||
Config.raw.zoom_direction == ZoomDirection.ZoomVerticalAndHorizontalInverted ? -1 : 1;
return Config.raw.camera_zoom_speed * sign;
}
- reset = (viewIndex = -1) => {
+ static reset = (viewIndex = -1) => {
let camera = Scene.active.camera;
if (viewIndex == -1) {
- this.origins = [new Vec4(0, 0, 0), new Vec4(0, 0, 0)];
- this.views = [camera.transform.local.clone(), camera.transform.local.clone()];
+ Camera.origins = [new Vec4(0, 0, 0), new Vec4(0, 0, 0)];
+ Camera.views = [camera.transform.local.clone(), camera.transform.local.clone()];
}
else {
- this.origins[viewIndex] = new Vec4(0, 0, 0);
- this.views[viewIndex] = camera.transform.local.clone();
+ Camera.origins[viewIndex] = new Vec4(0, 0, 0);
+ Camera.views[viewIndex] = camera.transform.local.clone();
}
}
- panAction = (modif: bool, defaultKeymap: bool) => {
+ static panAction = (modif: bool, defaultKeymap: bool) => {
let camera = Scene.active.camera;
let mouse = Input.getMouse();
if (Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) || (mouse.down("middle") && !modif && defaultKeymap)) {
- this.redraws = 2;
+ Camera.redraws = 2;
let look = camera.transform.look().normalize().mult(mouse.movementY / 150 * Config.raw.camera_pan_speed);
let right = camera.transform.right().normalize().mult(-mouse.movementX / 150 * Config.raw.camera_pan_speed);
camera.transform.loc.add(look);
camera.transform.loc.add(right);
- this.origins[this.index()].add(look);
- this.origins[this.index()].add(right);
+ Camera.origins[Camera.index()].add(look);
+ Camera.origins[Camera.index()].add(right);
camera.buildMatrix();
}
}
diff --git a/base/Sources/Config.ts b/base/Sources/Config.ts
index c5636357..200c4b83 100644
--- a/base/Sources/Config.ts
+++ b/base/Sources/Config.ts
@@ -287,7 +287,7 @@ class Config {
Base.theme.FILL_WINDOW_BG = true;
if (tagRedraw) {
for (let ui of Base.getUIs()) ui.t = Base.theme;
- UIBase.inst.tagUIRedraw();
+ UIBase.tagUIRedraw();
}
if (Config.raw.touch_ui) {
// Enlarge elements
diff --git a/base/Sources/Context.ts b/base/Sources/Context.ts
index eecf7dca..f424eac2 100644
--- a/base/Sources/Context.ts
+++ b/base/Sources/Context.ts
@@ -24,10 +24,10 @@ class Context {
if (Project.materials.indexOf(m) == -1) return;
Context.raw.material = m;
MakeMaterial.parsePaintMaterial();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
- UIHeader.inst.headerHandle.redraws = 2;
- UINodes.inst.hwnd.redraws = 2;
- UINodes.inst.groupStack = [];
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
+ UINodes.hwnd.redraws = 2;
+ UINodes.groupStack = [];
let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
if (decal) {
@@ -47,8 +47,8 @@ class Context {
if (Project.brushes.indexOf(b) == -1) return;
Context.raw.brush = b;
MakeMaterial.parseBrush();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
- UINodes.inst.hwnd.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UINodes.hwnd.redraws = 2;
}
static selectFont = (i: i32) => {
@@ -61,8 +61,8 @@ class Context {
Context.raw.font = f;
UtilRender.makeTextPreview();
UtilRender.makeDecalPreview();
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
- UIView2D.inst.hwnd.redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+ UIView2D.hwnd.redraws = 2;
}
static selectLayer = (i: i32) => {
@@ -73,7 +73,7 @@ class Context {
static setLayer = (l: SlotLayer) => {
if (l == Context.raw.layer) return;
Context.raw.layer = l;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
let current = Graphics2.current;
if (current != null) current.end();
@@ -84,8 +84,8 @@ class Context {
if (current != null) current.begin(false);
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIView2D.inst.hwnd.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIView2D.hwnd.redraws = 2;
}
///end
@@ -100,8 +100,8 @@ class Context {
///if (is_paint || is_sculpt)
Context.initTool();
- UIHeader.inst.headerHandle.redraws = 2;
- UIToolbar.inst.toolbarHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
+ UIToolbar.toolbarHandle.redraws = 2;
///end
}
@@ -143,7 +143,7 @@ class Context {
static selectPaintObject = (o: MeshObject) => {
///if (is_paint || is_sculpt)
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
for (let p of Project.paintObjects) p.skip_context = "paint";
Context.raw.paintObject = o;
@@ -197,7 +197,7 @@ class Context {
///if (is_paint || is_sculpt)
let mouse = Input.getMouse();
let right = App.w();
- if (UIView2D.inst.show) right += UIView2D.inst.ww;
+ if (UIView2D.show) right += UIView2D.ww;
return mouse.viewX > 0 && mouse.viewX < right &&
mouse.viewY > 0 && mouse.viewY < App.h();
///end
@@ -208,35 +208,35 @@ class Context {
}
static inLayers = (): bool => {
- return UIBase.inst.ui.getHoveredTabName() == tr("Layers");
+ return UIBase.ui.getHoveredTabName() == tr("Layers");
}
static inMaterials = (): bool => {
- return UIBase.inst.ui.getHoveredTabName() == tr("Materials");
+ return UIBase.ui.getHoveredTabName() == tr("Materials");
}
///if (is_paint || is_sculpt)
static in2dView = (type = View2DType.View2DLayer): bool => {
let mouse = Input.getMouse();
- return UIView2D.inst.show && UIView2D.inst.type == type &&
- mouse.x > UIView2D.inst.wx && mouse.x < UIView2D.inst.wx + UIView2D.inst.ww &&
- mouse.y > UIView2D.inst.wy && mouse.y < UIView2D.inst.wy + UIView2D.inst.wh;
+ return UIView2D.show && UIView2D.type == type &&
+ mouse.x > UIView2D.wx && mouse.x < UIView2D.wx + UIView2D.ww &&
+ mouse.y > UIView2D.wy && mouse.y < UIView2D.wy + UIView2D.wh;
}
///end
static inNodes = (): bool => {
let mouse = Input.getMouse();
- return UINodes.inst.show &&
- mouse.x > UINodes.inst.wx && mouse.x < UINodes.inst.wx + UINodes.inst.ww &&
- mouse.y > UINodes.inst.wy && mouse.y < UINodes.inst.wy + UINodes.inst.wh;
+ return UINodes.show &&
+ mouse.x > UINodes.wx && mouse.x < UINodes.wx + UINodes.ww &&
+ mouse.y > UINodes.wy && mouse.y < UINodes.wy + UINodes.wh;
}
static inSwatches = (): bool => {
- return UIBase.inst.ui.getHoveredTabName() == tr("Swatches");
+ return UIBase.ui.getHoveredTabName() == tr("Swatches");
}
static inBrowser = (): bool => {
- return UIBase.inst.ui.getHoveredTabName() == tr("Browser");
+ return UIBase.ui.getHoveredTabName() == tr("Browser");
}
static getAreaType = (): AreaType => {
@@ -264,10 +264,10 @@ class Context {
}
RenderPath.active.commands = RenderPathForward.commands;
}
- let _workspace = UIHeader.inst.worktab.position;
- UIHeader.inst.worktab.position = 0;
+ let _workspace = UIHeader.worktab.position;
+ UIHeader.worktab.position = 0;
MakeMaterial.parseMeshMaterial();
- UIHeader.inst.worktab.position = _workspace;
+ UIHeader.worktab.position = _workspace;
}
static loadEnvmap = () => {
@@ -341,8 +341,8 @@ class Context {
Context.raw.lastPaintVecY = Context.raw.paintVec.y;
}
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let inpaint = nodes.nodesSelectedId.length > 0 && nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
// Paint bounds
diff --git a/base/Sources/ExportArm.ts b/base/Sources/ExportArm.ts
index 9391d221..4ea44947 100644
--- a/base/Sources/ExportArm.ts
+++ b/base/Sources/ExportArm.ts
@@ -108,7 +108,7 @@ class ExportArm {
envmap: Project.raw.envmap != null ? (sameDrive ? Path.toRelative(Project.filepath, Project.raw.envmap) : Project.raw.envmap) : null,
envmap_strength: Scene.active.world.probe.raw.strength,
camera_world: Scene.active.camera.transform.local.toFloat32Array(),
- camera_origin: ExportArm.vec3f32(Camera.inst.origins[0]),
+ camera_origin: ExportArm.vec3f32(Camera.origins[0]),
camera_fov: Scene.active.camera.data.raw.fov,
///if (is_paint || is_sculpt)
diff --git a/base/Sources/Geom.ts b/base/Sources/Geom.ts
new file mode 100644
index 00000000..884096a9
--- /dev/null
+++ b/base/Sources/Geom.ts
@@ -0,0 +1,139 @@
+
+class Geom {
+
+ static make_plane(sizeX = 1.0, sizeY = 1.0, vertsX = 2, vertsY = 2, uvScale = 1.0): TRawMesh {
+
+ let mesh: TRawMesh = {};
+ mesh.scalePos = 1.0;
+ mesh.scaleTex = 1.0;
+ mesh.name = "";
+ mesh.hasNext = false;
+
+ // Pack positions to (-1, 1) range
+ let halfX = sizeX / 2;
+ let halfY = sizeY / 2;
+ mesh.scalePos = Math.max(halfX, halfY);
+ let inv = (1 / mesh.scalePos) * 32767;
+
+ mesh.posa = new Int16Array(vertsX * vertsY * 4);
+ mesh.nora = new Int16Array(vertsX * vertsY * 2);
+ mesh.texa = new Int16Array(vertsX * vertsY * 2);
+ mesh.inda = new Uint32Array((vertsX - 1) * (vertsY - 1) * 6);
+ let stepX = sizeX / (vertsX - 1);
+ let stepY = sizeY / (vertsY - 1);
+ for (let i = 0; i < vertsX * vertsY; ++i) {
+ let x = (i % vertsX) * stepX - halfX;
+ let y = Math.floor(i / vertsX) * stepY - halfY;
+ mesh.posa[i * 4 ] = Math.floor(x * inv);
+ mesh.posa[i * 4 + 1] = Math.floor(y * inv);
+ mesh.posa[i * 4 + 2] = 0;
+ mesh.nora[i * 2 ] = 0;
+ mesh.nora[i * 2 + 1] = 0;
+ mesh.posa[i * 4 + 3] = 32767;
+ x = (i % vertsX) / (vertsX - 1);
+ y = 1.0 - Math.floor(i / vertsX) / (vertsY - 1);
+ mesh.texa[i * 2 ] = (Math.floor(x * 32767 * uvScale) - 1) % 32767;
+ mesh.texa[i * 2 + 1] = (Math.floor(y * 32767 * uvScale) - 1) % 32767;
+ }
+ for (let i = 0; i < (vertsX - 1) * (vertsY - 1); ++i) {
+ let x = i % (vertsX - 1);
+ let y = Math.floor(i / (vertsY - 1));
+ mesh.inda[i * 6 ] = y * vertsX + x;
+ mesh.inda[i * 6 + 1] = y * vertsX + x + 1;
+ mesh.inda[i * 6 + 2] = (y + 1) * vertsX + x;
+ mesh.inda[i * 6 + 3] = y * vertsX + x + 1;
+ mesh.inda[i * 6 + 4] = (y + 1) * vertsX + x + 1;
+ mesh.inda[i * 6 + 5] = (y + 1) * vertsX + x;
+ }
+
+ return mesh;
+ }
+
+ static make_uv_sphere(radius = 1.0, widthSegments = 32, heightSegments = 16, stretchUV = true, uvScale = 1.0): TRawMesh {
+
+ let mesh: TRawMesh = {};
+ mesh.scalePos = 1.0;
+ mesh.scaleTex = 1.0;
+ mesh.name = "";
+ mesh.hasNext = false;
+
+ // Pack positions to (-1, 1) range
+ mesh.scalePos = radius;
+ mesh.scaleTex = uvScale;
+ let inv = (1 / mesh.scalePos) * 32767;
+ let pi2 = Math.PI * 2;
+
+ let widthVerts = widthSegments + 1;
+ let heightVerts = heightSegments + 1;
+ mesh.posa = new Int16Array(widthVerts * heightVerts * 4);
+ mesh.nora = new Int16Array(widthVerts * heightVerts * 2);
+ mesh.texa = new Int16Array(widthVerts * heightVerts * 2);
+ mesh.inda = new Uint32Array(widthSegments * heightSegments * 6 - widthSegments * 6);
+
+ let nor = new Vec4();
+ let pos = 0;
+ for (let y = 0; y < heightVerts; ++y) {
+ let v = y / heightSegments;
+ let vFlip = 1.0 - v;
+ if (!stretchUV) vFlip /= 2;
+ let uOff = y == 0 ? 0.5 / widthSegments : y == heightSegments ? -0.5 / widthSegments : 0.0;
+ for (let x = 0; x < widthVerts; ++x) {
+ let u = x / widthSegments;
+ let uPI2 = u * pi2;
+ let vPI = v * Math.PI;
+ let vPIsin = Math.sin(vPI);
+ let vx = -radius * Math.cos(uPI2) * vPIsin;
+ let vy = radius * Math.sin(uPI2) * vPIsin;
+ let vz = -radius * Math.cos(vPI);
+ let i4 = pos * 4;
+ let i2 = pos * 2;
+ mesh.posa[i4 ] = Math.floor(vx * inv);
+ mesh.posa[i4 + 1] = Math.floor(vy * inv);
+ mesh.posa[i4 + 2] = Math.floor(vz * inv);
+ nor.set(vx, vy, vz).normalize();
+ mesh.posa[i4 + 3] = Math.floor(nor.z * 32767);
+ mesh.nora[i2 ] = Math.floor(nor.x * 32767);
+ mesh.nora[i2 + 1] = Math.floor(nor.y * 32767);
+ mesh.texa[i2 ] = (Math.floor((u + uOff) * 32767) - 1) % 32767;
+ mesh.texa[i2 + 1] = (Math.floor(vFlip * 32767) - 1) % 32767;
+ pos++;
+ }
+ }
+
+ pos = 0;
+ let heightSegments1 = heightSegments - 1;
+ for (let y = 0; y < heightSegments; ++y) {
+ for (let x = 0; x < widthSegments; ++x) {
+ let x1 = x + 1;
+ let y1 = y + 1;
+ let a = y * widthVerts + x1;
+ let b = y * widthVerts + x;
+ let c = y1 * widthVerts + x;
+ let d = y1 * widthVerts + x1;
+ if (y > 0) {
+ mesh.inda[pos++] = a;
+ mesh.inda[pos++] = b;
+ mesh.inda[pos++] = d;
+ }
+ if (y < heightSegments1) {
+ mesh.inda[pos++] = b;
+ mesh.inda[pos++] = c;
+ mesh.inda[pos++] = d;
+ }
+ }
+ }
+
+ return mesh;
+ }
+}
+
+type TRawMesh = {
+ posa?: Int16Array;
+ nora?: Int16Array;
+ texa?: Int16Array;
+ inda?: Uint32Array;
+ scalePos?: f32;
+ scaleTex?:f32;
+ name?: string;
+ hasNext?: bool;
+}
diff --git a/base/Sources/GeomPlane.ts b/base/Sources/GeomPlane.ts
deleted file mode 100644
index 880e6ce2..00000000
--- a/base/Sources/GeomPlane.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-
-class GeomPlane {
-
- posa: Int16Array = null;
- nora: Int16Array = null;
- texa: Int16Array = null;
- inda: Uint32Array = null;
- scalePos = 1.0;
- scaleTex = 1.0;
- name = "";
- hasNext = false;
-
- constructor(sizeX = 1.0, sizeY = 1.0, vertsX = 2, vertsY = 2, uvScale = 1.0) {
- // Pack positions to (-1, 1) range
- let halfX = sizeX / 2;
- let halfY = sizeY / 2;
- this.scalePos = Math.max(halfX, halfY);
- let inv = (1 / this.scalePos) * 32767;
-
- this.posa = new Int16Array(vertsX * vertsY * 4);
- this.nora = new Int16Array(vertsX * vertsY * 2);
- this.texa = new Int16Array(vertsX * vertsY * 2);
- this.inda = new Uint32Array((vertsX - 1) * (vertsY - 1) * 6);
- let stepX = sizeX / (vertsX - 1);
- let stepY = sizeY / (vertsY - 1);
- for (let i = 0; i < vertsX * vertsY; ++i) {
- let x = (i % vertsX) * stepX - halfX;
- let y = Math.floor(i / vertsX) * stepY - halfY;
- this.posa[i * 4 ] = Math.floor(x * inv);
- this.posa[i * 4 + 1] = Math.floor(y * inv);
- this.posa[i * 4 + 2] = 0;
- this.nora[i * 2 ] = 0;
- this.nora[i * 2 + 1] = 0;
- this.posa[i * 4 + 3] = 32767;
- x = (i % vertsX) / (vertsX - 1);
- y = 1.0 - Math.floor(i / vertsX) / (vertsY - 1);
- this.texa[i * 2 ] = (Math.floor(x * 32767 * uvScale) - 1) % 32767;
- this.texa[i * 2 + 1] = (Math.floor(y * 32767 * uvScale) - 1) % 32767;
- }
- for (let i = 0; i < (vertsX - 1) * (vertsY - 1); ++i) {
- let x = i % (vertsX - 1);
- let y = Math.floor(i / (vertsY - 1));
- this.inda[i * 6 ] = y * vertsX + x;
- this.inda[i * 6 + 1] = y * vertsX + x + 1;
- this.inda[i * 6 + 2] = (y + 1) * vertsX + x;
- this.inda[i * 6 + 3] = y * vertsX + x + 1;
- this.inda[i * 6 + 4] = (y + 1) * vertsX + x + 1;
- this.inda[i * 6 + 5] = (y + 1) * vertsX + x;
- }
- }
-}
diff --git a/base/Sources/GeomUVSphere.ts b/base/Sources/GeomUVSphere.ts
deleted file mode 100644
index 4626560a..00000000
--- a/base/Sources/GeomUVSphere.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-
-class GeomUVSphere {
-
- posa: Int16Array = null;
- nora: Int16Array = null;
- texa: Int16Array = null;
- inda: Uint32Array = null;
- scalePos = 1.0;
- scaleTex = 1.0;
- name = "";
- hasNext = false;
-
- constructor(radius = 1.0, widthSegments = 32, heightSegments = 16, stretchUV = true, uvScale = 1.0) {
- // Pack positions to (-1, 1) range
- this.scalePos = radius;
- this.scaleTex = uvScale;
- let inv = (1 / this.scalePos) * 32767;
- let pi2 = Math.PI * 2;
-
- let widthVerts = widthSegments + 1;
- let heightVerts = heightSegments + 1;
- this.posa = new Int16Array(widthVerts * heightVerts * 4);
- this.nora = new Int16Array(widthVerts * heightVerts * 2);
- this.texa = new Int16Array(widthVerts * heightVerts * 2);
- this.inda = new Uint32Array(widthSegments * heightSegments * 6 - widthSegments * 6);
-
- let nor = new Vec4();
- let pos = 0;
- for (let y = 0; y < heightVerts; ++y) {
- let v = y / heightSegments;
- let vFlip = 1.0 - v;
- if (!stretchUV) vFlip /= 2;
- let uOff = y == 0 ? 0.5 / widthSegments : y == heightSegments ? -0.5 / widthSegments : 0.0;
- for (let x = 0; x < widthVerts; ++x) {
- let u = x / widthSegments;
- let uPI2 = u * pi2;
- let vPI = v * Math.PI;
- let vPIsin = Math.sin(vPI);
- let vx = -radius * Math.cos(uPI2) * vPIsin;
- let vy = radius * Math.sin(uPI2) * vPIsin;
- let vz = -radius * Math.cos(vPI);
- let i4 = pos * 4;
- let i2 = pos * 2;
- this.posa[i4 ] = Math.floor(vx * inv);
- this.posa[i4 + 1] = Math.floor(vy * inv);
- this.posa[i4 + 2] = Math.floor(vz * inv);
- nor.set(vx, vy, vz).normalize();
- this.posa[i4 + 3] = Math.floor(nor.z * 32767);
- this.nora[i2 ] = Math.floor(nor.x * 32767);
- this.nora[i2 + 1] = Math.floor(nor.y * 32767);
- this.texa[i2 ] = (Math.floor((u + uOff) * 32767) - 1) % 32767;
- this.texa[i2 + 1] = (Math.floor(vFlip * 32767) - 1) % 32767;
- pos++;
- }
- }
-
- pos = 0;
- let heightSegments1 = heightSegments - 1;
- for (let y = 0; y < heightSegments; ++y) {
- for (let x = 0; x < widthSegments; ++x) {
- let x1 = x + 1;
- let y1 = y + 1;
- let a = y * widthVerts + x1;
- let b = y * widthVerts + x;
- let c = y1 * widthVerts + x;
- let d = y1 * widthVerts + x1;
- if (y > 0) {
- this.inda[pos++] = a;
- this.inda[pos++] = b;
- this.inda[pos++] = d;
- }
- if (y < heightSegments1) {
- this.inda[pos++] = b;
- this.inda[pos++] = c;
- this.inda[pos++] = d;
- }
- }
- }
- }
-}
diff --git a/base/Sources/History.ts b/base/Sources/History.ts
index 86a0e52b..3de2d074 100644
--- a/base/Sources/History.ts
+++ b/base/Sources/History.ts
@@ -193,9 +193,9 @@ class History {
Context.raw.material = new SlotMaterial(Project.materials[0].data);
Project.materials.splice(step.material, 0, Context.raw.material);
Context.raw.material.canvas = step.canvas;
- UINodes.inst.canvasChanged();
- UINodes.inst.getNodes().handle = new Handle();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.canvasChanged();
+ UINodes.getNodes().handle = new Handle();
+ UINodes.hwnd.redraws = 2;
}
else if (step.name == tr("Duplicate Material")) {
Context.raw.material = Project.materials[step.material];
@@ -217,15 +217,15 @@ class History {
Context.raw.ddirty = 2;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
- if (UIView2D.inst.show) {
- UIView2D.inst.hwnd.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ if (UIView2D.show) {
+ UIView2D.hwnd.redraws = 2;
}
if (Config.raw.touch_ui) {
// Refresh undo & redo buttons
- UIMenubar.inst.menuHandle.redraws = 2;
+ UIMenubar.menuHandle.redraws = 2;
}
///end
}
@@ -379,9 +379,9 @@ class History {
Context.raw.material = new SlotMaterial(Project.materials[0].data);
Project.materials.splice(step.material, 0, Context.raw.material);
Context.raw.material.canvas = step.canvas;
- UINodes.inst.canvasChanged();
- UINodes.inst.getNodes().handle = new Handle();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.canvasChanged();
+ UINodes.getNodes().handle = new Handle();
+ UINodes.hwnd.redraws = 2;
}
else if (step.name == tr("Delete Material")) {
Context.raw.material = Project.materials[step.material];
@@ -392,9 +392,9 @@ class History {
Context.raw.material = new SlotMaterial(Project.materials[0].data);
Project.materials.splice(step.material, 0, Context.raw.material);
Context.raw.material.canvas = step.canvas;
- UINodes.inst.canvasChanged();
- UINodes.inst.getNodes().handle = new Handle();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.canvasChanged();
+ UINodes.getNodes().handle = new Handle();
+ UINodes.hwnd.redraws = 2;
}
else { // Paint operation
let lay = History.undoLayers[History.undoI];
@@ -411,13 +411,13 @@ class History {
Context.raw.ddirty = 2;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
- if (UIView2D.inst.show) UIView2D.inst.hwnd.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ if (UIView2D.show) UIView2D.hwnd.redraws = 2;
if (Config.raw.touch_ui) {
// Refresh undo & redo buttons
- UIMenubar.inst.menuHandle.redraws = 2;
+ UIMenubar.menuHandle.redraws = 2;
}
///end
}
@@ -456,7 +456,7 @@ class History {
History.copyToUndo(Context.raw.layer.id, History.undoI, isMask);
History.pushUndo = false;
- History.push(tr(UIToolbar.inst.toolNames[Context.raw.tool]));
+ History.push(tr(UIToolbar.toolNames[Context.raw.tool]));
}
static newLayer = () => {
@@ -599,7 +599,7 @@ class History {
if (Config.raw.touch_ui) {
// Refresh undo & redo buttons
- UIMenubar.inst.menuHandle.redraws = 2;
+ UIMenubar.menuHandle.redraws = 2;
}
if (History.undos < Config.raw.undo_steps) History.undos++;
@@ -721,9 +721,9 @@ class History {
step.canvas = _canvas;
///end
- UINodes.inst.canvasChanged();
- UINodes.inst.getNodes().handle = new Handle();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.canvasChanged();
+ UINodes.getNodes().handle = new Handle();
+ UINodes.hwnd.redraws = 2;
}
}
diff --git a/base/Sources/ImportArm.ts b/base/Sources/ImportArm.ts
index 3152320c..9d63592f 100644
--- a/base/Sources/ImportArm.ts
+++ b/base/Sources/ImportArm.ts
@@ -83,9 +83,9 @@ class ImportArm {
Scene.active.camera.data.raw.fov = Project.raw.camera_fov;
Scene.active.camera.buildProjection();
let origin = Project.raw.camera_origin;
- Camera.inst.origins[0].x = origin[0];
- Camera.inst.origins[0].y = origin[1];
- Camera.inst.origins[0].z = origin[2];
+ Camera.origins[0].x = origin[0];
+ Camera.origins[0].y = origin[1];
+ Camera.origins[0].z = origin[2];
}
for (let file of project.assets) {
@@ -312,8 +312,8 @@ class ImportArm {
}
///end
- UINodes.inst.hwnd.redraws = 2;
- UINodes.inst.groupStack = [];
+ UINodes.hwnd.redraws = 2;
+ UINodes.groupStack = [];
Project.materialGroups = [];
if (project.material_groups != null) {
for (let g of project.material_groups) Project.materialGroups.push({ canvas: g, nodes: new Nodes() });
@@ -345,8 +345,8 @@ class ImportArm {
}
}
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
///end
///if is_lab
@@ -449,8 +449,8 @@ class ImportArm {
}
App.notifyOnInit(_init);
- UINodes.inst.groupStack = [];
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UINodes.groupStack = [];
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
Data.deleteBlob(path);
}
@@ -520,7 +520,7 @@ class ImportArm {
}
App.notifyOnInit(_init);
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
Data.deleteBlob(path);
}
///end
@@ -547,7 +547,7 @@ class ImportArm {
Project.raw.swatches.push(s);
}
}
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
Data.deleteBlob(path);
}
diff --git a/base/Sources/ImportAsset.ts b/base/Sources/ImportAsset.ts
index c1e7cb4d..5b608b63 100644
--- a/base/Sources/ImportAsset.ts
+++ b/base/Sources/ImportAsset.ts
@@ -30,9 +30,9 @@ class ImportAsset {
else if (Path.isTexture(path)) {
ImportTexture.run(path, hdrAsEnvmap);
// Place image node
- let x0 = UINodes.inst.wx;
- let x1 = UINodes.inst.wx + UINodes.inst.ww;
- if (UINodes.inst.show && dropX > x0 && dropX < x1) {
+ let x0 = UINodes.wx;
+ let x1 = UINodes.wx + UINodes.ww;
+ if (UINodes.show && dropX > x0 && dropX < x1) {
let assetIndex = 0;
for (let i = 0; i < Project.assets.length; ++i) {
if (Project.assets[i].file == path) {
@@ -40,14 +40,14 @@ class ImportAsset {
break;
}
}
- UINodes.inst.acceptAssetDrag(assetIndex);
- UINodes.inst.getNodes().nodesDrag = false;
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.acceptAssetDrag(assetIndex);
+ UINodes.getNodes().nodesDrag = false;
+ UINodes.hwnd.redraws = 2;
}
///if is_paint
if (Context.raw.tool == WorkspaceTool.ToolColorId && Project.assetNames.length == 1) {
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
Context.raw.ddirty = 2;
}
///end
diff --git a/base/Sources/ImportBlendMaterial.ts b/base/Sources/ImportBlendMaterial.ts
index b37c00bb..f96efd89 100644
--- a/base/Sources/ImportBlendMaterial.ts
+++ b/base/Sources/ImportBlendMaterial.ts
@@ -250,7 +250,7 @@ class ImportBlendMaterial {
}
App.notifyOnInit(_init);
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
Data.deleteBlob(path);
});
}
diff --git a/base/Sources/ImportFont.ts b/base/Sources/ImportFont.ts
index f0cfa1b6..3c6bfc99 100644
--- a/base/Sources/ImportFont.ts
+++ b/base/Sources/ImportFont.ts
@@ -30,7 +30,7 @@ class ImportFont {
}
App.notifyOnInit(_init);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
});
}
}
diff --git a/base/Sources/ImportMesh.ts b/base/Sources/ImportMesh.ts
index 929f7e0d..36af426b 100644
--- a/base/Sources/ImportMesh.ts
+++ b/base/Sources/ImportMesh.ts
@@ -90,7 +90,7 @@ class ImportMesh {
MakeMaterial.parseMeshMaterial();
///if (is_paint || is_sculpt)
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
///end
///if (krom_direct3d12 || krom_vulkan || krom_metal)
@@ -131,8 +131,8 @@ class ImportMesh {
Context.raw.ddirty = 4;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
UtilUV.uvmapCached = false;
UtilUV.trianglemapCached = false;
UtilUV.dilatemapCached = false;
@@ -208,7 +208,7 @@ class ImportMesh {
Context.raw.ddirty = 4;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
UtilUV.uvmapCached = false;
UtilUV.trianglemapCached = false;
UtilUV.dilatemapCached = false;
diff --git a/base/Sources/ImportTexture.ts b/base/Sources/ImportTexture.ts
index b27429b6..b51254c6 100644
--- a/base/Sources/ImportTexture.ts
+++ b/base/Sources/ImportTexture.ts
@@ -39,7 +39,7 @@ class ImportTexture {
if (Context.raw.texture == null) Context.raw.texture = asset;
Project.assetNames.push(name);
Project.assetMap.set(asset.id, image);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
Console.info(tr("Texture imported:") + " " + name);
// Set as envmap
diff --git a/base/Sources/Main.ts b/base/Sources/Main.ts
index cd40e82d..bcbe031c 100644
--- a/base/Sources/Main.ts
+++ b/base/Sources/Main.ts
@@ -1,7 +1,7 @@
class Main {
- // @:keep static snapshotHelper = globalThis.Krom = {};
+ // static snapshotHelper = globalThis.Krom = {};
static tasks: i32;
static main = () => {
@@ -28,7 +28,6 @@ class Main {
///end
}
- // @:keep
static kickstart = () => {
// Used to locate external application data folder
Krom.setApplicationName(Manifest.title);
diff --git a/base/Sources/NodesMaterial.ts b/base/Sources/NodesMaterial.ts
index dd372617..662d3ca8 100644
--- a/base/Sources/NodesMaterial.ts
+++ b/base/Sources/NodesMaterial.ts
@@ -2942,7 +2942,7 @@ class NodesMaterial {
}
if (ui.button(tr("Nodes"))) {
- UINodes.inst.groupStack.push(group);
+ UINodes.groupStack.push(group);
}
}
@@ -2959,7 +2959,7 @@ class NodesMaterial {
static addSocketButton = (ui: Zui, nodes: Nodes, node: TNode, sockets: TNodeSocket[]) => {
if (ui.button(tr("Add"))) {
UIMenu.draw((ui: Zui) => {
- let groupStack = UINodes.inst.groupStack;
+ let groupStack = UINodes.groupStack;
let c = groupStack[groupStack.length - 1].canvas;
if (UIMenu.menuButton(ui, tr("RGBA"))) {
sockets.push(NodesMaterial.createSocket(nodes, node, null, "RGBA", c));
@@ -2978,7 +2978,7 @@ class NodesMaterial {
}
static syncSockets = (node: TNode) => {
- let groupStack = UINodes.inst.groupStack;
+ let groupStack = UINodes.groupStack;
let c = groupStack[groupStack.length - 1].canvas;
for (let m of Project.materials) NodesMaterial.syncGroupSockets(m.canvas, c.name, node);
for (let g of Project.materialGroups) NodesMaterial.syncGroupSockets(g.canvas, c.name, node);
diff --git a/base/Sources/Project.ts b/base/Sources/Project.ts
index b6067475..38dbec40 100644
--- a/base/Sources/Project.ts
+++ b/base/Sources/Project.ts
@@ -162,8 +162,8 @@ class Project {
let raw: TMeshData = null;
if (Context.raw.projectType == ProjectModel.ModelSphere || Context.raw.projectType == ProjectModel.ModelTessellatedPlane) {
let mesh: any = Context.raw.projectType == ProjectModel.ModelSphere ?
- new GeomUVSphere(1, 512, 256) :
- new GeomPlane(1, 1, 512, 512);
+ Geom.make_uv_sphere(1, 512, 256) :
+ Geom.make_plane(1, 1, 512, 512);
mesh.name = "Tessellated";
raw = ImportMesh.rawMesh(mesh);
@@ -231,8 +231,8 @@ class Project {
Context.raw.material = Project.materials[0];
///end
- UINodes.inst.hwnd.redraws = 2;
- UINodes.inst.groupStack = [];
+ UINodes.hwnd.redraws = 2;
+ UINodes.groupStack = [];
Project.materialGroups = [];
///if (is_paint || is_sculpt)
@@ -265,8 +265,8 @@ class Project {
Context.raw.ddirty = 4;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
///end
if (resetLayers) {
@@ -350,7 +350,7 @@ class Project {
// Parse brush
MakeMaterial.parseBrush();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
let _init = () => {
UtilRender.makeBrushPreview();
}
@@ -536,7 +536,7 @@ class Project {
///if (is_paint || is_sculpt)
UtilRender.makeMaterialPreview();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
///end
}
Base.notifyOnNextFrame(_next);
diff --git a/base/Sources/RenderPathBase.ts b/base/Sources/RenderPathBase.ts
index 3eda4a6a..585e52ce 100644
--- a/base/Sources/RenderPathBase.ts
+++ b/base/Sources/RenderPathBase.ts
@@ -104,7 +104,7 @@ class RenderPathBase {
let cam = Scene.active.camera;
if (Context.raw.viewIndexLast > -1) {
// Save current viewport camera
- Camera.inst.views[Context.raw.viewIndexLast].setFrom(cam.transform.local);
+ Camera.views[Context.raw.viewIndexLast].setFrom(cam.transform.local);
}
let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
@@ -114,7 +114,7 @@ class RenderPathBase {
Context.raw.ddirty = 1;
}
- cam.transform.setMatrix(Camera.inst.views[Context.raw.viewIndex]);
+ cam.transform.setMatrix(Camera.views[Context.raw.viewIndex]);
cam.buildMatrix();
cam.buildProjection();
}
@@ -257,7 +257,7 @@ class RenderPathBase {
let cam = Scene.active.camera;
Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0;
- cam.transform.setMatrix(Camera.inst.views[Context.raw.viewIndex]);
+ cam.transform.setMatrix(Camera.views[Context.raw.viewIndex]);
cam.buildMatrix();
cam.buildProjection();
@@ -275,7 +275,7 @@ class RenderPathBase {
///end
Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0;
- cam.transform.setMatrix(Camera.inst.views[Context.raw.viewIndex]);
+ cam.transform.setMatrix(Camera.views[Context.raw.viewIndex]);
cam.buildMatrix();
cam.buildProjection();
}
diff --git a/base/Sources/TabBrowser.ts b/base/Sources/TabBrowser.ts
index d6ea8707..ab90744d 100644
--- a/base/Sources/TabBrowser.ts
+++ b/base/Sources/TabBrowser.ts
@@ -9,11 +9,11 @@ class TabBrowser {
static showDirectory = (directory: string) => {
TabBrowser.hpath.text = directory;
TabBrowser.hsearch.text = "";
- UIBase.inst.htabs[TabArea.TabStatus].position = 0;
+ UIBase.htabs[TabArea.TabStatus].position = 0;
}
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Browser")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
@@ -141,9 +141,9 @@ class TabBrowser {
if (assetIndex != -1) {
Context.raw.colorIdHandle.position = assetIndex;
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
if (Context.raw.tool == WorkspaceTool.ToolColorId) {
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
Context.raw.ddirty = 2;
}
}
diff --git a/base/Sources/TabBrushes.ts b/base/Sources/TabBrushes.ts
index c66ea20a..b5c0f937 100644
--- a/base/Sources/TabBrushes.ts
+++ b/base/Sources/TabBrushes.ts
@@ -4,7 +4,7 @@
class TabBrushes {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Brushes"))) {
ui.beginSticky();
ui.row([1 / 4, 1 / 4, 1 / 4]);
@@ -12,13 +12,13 @@ class TabBrushes {
Context.raw.brush = new SlotBrush();
Project.brushes.push(Context.raw.brush);
MakeMaterial.parseBrush();
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
}
if (ui.button(tr("Import"))) {
Project.importBrush();
}
if (ui.button(tr("Nodes"))) {
- UIBase.inst.showBrushNodes();
+ UIBase.showBrushNodes();
}
ui.endSticky();
ui.separator(3, false);
@@ -64,7 +64,7 @@ class TabBrushes {
let state = Project.brushes[i].previewReady ? ui.image(img) : ui.image(Res.get("icons.k"), -1, null, tile * 5, tile, tile, tile);
if (state == State.Started) {
if (Context.raw.brush != Project.brushes[i]) Context.selectBrush(i);
- if (Time.time() - Context.raw.selectTime < 0.25) UIBase.inst.showBrushNodes();
+ if (Time.time() - Context.raw.selectTime < 0.25) UIBase.showBrushNodes();
Context.raw.selectTime = Time.time();
// let mouse = Input.getMouse();
// App.dragOffX = -(mouse.x - uix - ui._windowX - 3);
@@ -144,7 +144,7 @@ class TabBrushes {
let i = Project.brushes.indexOf(b);
Context.selectBrush(i == Project.brushes.length - 1 ? i - 1 : i + 1);
Project.brushes.splice(i, 1);
- UIBase.inst.hwnds[1].redraws = 2;
+ UIBase.hwnds[1].redraws = 2;
}
}
diff --git a/base/Sources/TabConsole.ts b/base/Sources/TabConsole.ts
index 38072977..50771092 100644
--- a/base/Sources/TabConsole.ts
+++ b/base/Sources/TabConsole.ts
@@ -2,7 +2,7 @@
class TabConsole {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let title = Console.messageTimer > 0 ? Console.message + " " : tr("Console");
let color = Console.messageTimer > 0 ? Console.messageColor : -1;
diff --git a/base/Sources/TabFonts.ts b/base/Sources/TabFonts.ts
index e81b3383..5d26ac90 100644
--- a/base/Sources/TabFonts.ts
+++ b/base/Sources/TabFonts.ts
@@ -4,7 +4,7 @@
class TabFonts {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Fonts")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
@@ -20,12 +20,12 @@ class TabFonts {
if (ui.isHovered) ui.tooltip(tr("Import font file"));
if (ui.button(tr("2D View"))) {
- UIBase.inst.show2DView(View2DType.View2DFont);
+ UIBase.show2DView(View2DType.View2DFont);
}
ui.endSticky();
ui.separator(3, false);
- let statusw = System.width - UIToolbar.inst.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
+ let statusw = System.width - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
let slotw = Math.floor(51 * ui.SCALE());
let num = Math.floor(statusw / slotw);
@@ -64,11 +64,11 @@ class TabFonts {
let tile = ui.SCALE() > 1 ? 100 : 50;
let state = State.Idle;
if (Project.fonts[i].previewReady) {
- // ui.g.pipeline = UIView2D.inst.pipe; // L8
+ // ui.g.pipeline = UIView2D.pipe; // L8
// ///if krom_opengl
- // ui.currentWindow.texture.g4.setPipeline(UIView2D.inst.pipe);
+ // ui.currentWindow.texture.g4.setPipeline(UIView2D.pipe);
// ///end
- // ui.currentWindow.texture.g4.setInt(UIView2D.inst.channelLocation, 1);
+ // ui.currentWindow.texture.g4.setInt(UIView2D.channelLocation, 1);
state = ui.image(img);
// ui.g.pipeline = null;
}
@@ -83,7 +83,7 @@ class TabFonts {
}
App.notifyOnInit(_init);
}
- if (Time.time() - Context.raw.selectTime < 0.25) UIBase.inst.show2DView(View2DType.View2DFont);
+ if (Time.time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DFont);
Context.raw.selectTime = Time.time();
}
if (ui.isHovered && ui.inputReleasedR) {
@@ -143,7 +143,7 @@ class TabFonts {
Project.fonts.splice(i, 1);
}
App.notifyOnInit(_init);
- UIBase.inst.hwnds[2].redraws = 2;
+ UIBase.hwnds[2].redraws = 2;
}
}
diff --git a/base/Sources/TabHistory.ts b/base/Sources/TabHistory.ts
index 71953bb2..d778a29d 100644
--- a/base/Sources/TabHistory.ts
+++ b/base/Sources/TabHistory.ts
@@ -4,7 +4,7 @@
class TabHistory {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("History"))) {
for (let i = 0; i < History.steps.length; ++i) {
let active = History.steps.length - 1 - History.redos;
diff --git a/base/Sources/TabMaterials.ts b/base/Sources/TabMaterials.ts
index d4eeb869..33910863 100644
--- a/base/Sources/TabMaterials.ts
+++ b/base/Sources/TabMaterials.ts
@@ -9,7 +9,7 @@ class TabMaterials {
}
static drawMini = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.setHoveredTabName(tr("Materials"));
ui.beginSticky();
@@ -24,7 +24,7 @@ class TabMaterials {
}
static drawFull = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Materials"))) {
ui.beginSticky();
ui.row([1 / 4, 1 / 4, 1 / 4]);
@@ -42,15 +42,15 @@ class TabMaterials {
}
static buttonNodes = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.button(tr("Nodes"))) {
- UIBase.inst.showMaterialNodes();
+ UIBase.showMaterialNodes();
}
else if (ui.isHovered) ui.tooltip(tr("Show Node Editor") + ` (${Config.keymap.toggle_node_editor})`);
}
static drawSlots = (mini: bool) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let slotw = Math.floor(51 * ui.SCALE());
let num = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] / slotw);
@@ -106,7 +106,7 @@ class TabMaterials {
ui.image(Res.get("icons.k"), 0xffffffff, null, tile, tile, tile, tile);
// Draw material numbers when selecting a material via keyboard shortcut
- let isTyping = ui.isTyping || UIView2D.inst.ui.isTyping || UINodes.inst.ui.isTyping;
+ let isTyping = ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping;
if (!isTyping) {
if (i < 9 && Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) {
let number = String(i + 1);
@@ -138,7 +138,7 @@ class TabMaterials {
Base.dragMaterial = Context.raw.material;
// Double click to show nodes
if (Time.time() - Context.raw.selectTime < 0.25) {
- UIBase.inst.showMaterialNodes();
+ UIBase.showMaterialNodes();
Base.dragMaterial = null;
Base.isDragging = false;
}
@@ -264,7 +264,7 @@ class TabMaterials {
}
static buttonNew = (text: string) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.button(text)) {
ui.g.end();
Context.raw.material = new SlotMaterial(Project.materials[0].data);
@@ -276,9 +276,9 @@ class TabMaterials {
}
static updateMaterial = () => {
- UIHeader.inst.headerHandle.redraws = 2;
- UINodes.inst.hwnd.redraws = 2;
- UINodes.inst.groupStack = [];
+ UIHeader.headerHandle.redraws = 2;
+ UINodes.hwnd.redraws = 2;
+ UINodes.groupStack = [];
MakeMaterial.parsePaintMaterial();
UtilRender.makeMaterialPreview();
let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
@@ -328,7 +328,7 @@ class TabMaterials {
History.deleteMaterial();
Context.selectMaterial(i == Project.materials.length - 1 ? i - 1 : i + 1);
Project.materials.splice(i, 1);
- UIBase.inst.hwnds[1].redraws = 2;
+ UIBase.hwnds[1].redraws = 2;
for (let m of Project.materials) TabMaterials.updateMaterialPointers(m.canvas.nodes, i);
// for (let n of m.canvas.nodes) UINodes.onNodeRemove(n);
}
diff --git a/base/Sources/TabMeshes.ts b/base/Sources/TabMeshes.ts
index fb57ab0f..33980ff5 100644
--- a/base/Sources/TabMeshes.ts
+++ b/base/Sources/TabMeshes.ts
@@ -2,7 +2,7 @@
class TabMeshes {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Meshes")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
@@ -148,7 +148,7 @@ class TabMeshes {
let mo: MeshObject = null;
if (name == ".Plane" || name == ".Sphere") {
let res = Config.raw.rp_supersample > 1.0 ? 2048 : 1024;
- let mesh: any = name == ".Plane" ? new GeomPlane(1, 1, res, res) : new GeomUVSphere(1.0, res, Math.floor(res / 2), false, 2.0);
+ let mesh: any = name == ".Plane" ? Geom.make_plane(1, 1, res, res) : Geom.make_uv_sphere(1.0, res, Math.floor(res / 2), false, 2.0);
let raw = {
name: "Tessellated",
vertex_arrays: [
@@ -175,7 +175,7 @@ class TabMeshes {
Context.raw.ddirty = 2;
Context.raw.paintObject = mo;
Project.paintObjects[0] = mo;
- if (UIHeader.inst.worktab.position == SpaceType.Space3D) {
+ if (UIHeader.worktab.position == SpaceType.Space3D) {
Scene.active.meshes = [mo];
}
diff --git a/base/Sources/TabParticles.ts b/base/Sources/TabParticles.ts
index b2163d2c..85113ce5 100644
--- a/base/Sources/TabParticles.ts
+++ b/base/Sources/TabParticles.ts
@@ -4,7 +4,7 @@
class TabParticles {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Particles"))) {
ui.beginSticky();
ui.row([1 / 4, 1 / 4, 1 / 4]);
diff --git a/base/Sources/TabPlugins.ts b/base/Sources/TabPlugins.ts
index 205e5a5a..e5fa869e 100644
--- a/base/Sources/TabPlugins.ts
+++ b/base/Sources/TabPlugins.ts
@@ -2,7 +2,7 @@
class TabPlugins {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
if (ui.tab(htab, tr("Plugins"))) {
ui.beginSticky();
diff --git a/base/Sources/TabScript.ts b/base/Sources/TabScript.ts
index c5becb01..642025d0 100644
--- a/base/Sources/TabScript.ts
+++ b/base/Sources/TabScript.ts
@@ -5,7 +5,7 @@ class TabScript {
static textColoring: TTextColoring = null;
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Script")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
diff --git a/base/Sources/TabSwatches.ts b/base/Sources/TabSwatches.ts
index d6d8dec6..a8cef592 100644
--- a/base/Sources/TabSwatches.ts
+++ b/base/Sources/TabSwatches.ts
@@ -22,7 +22,7 @@ class TabSwatches {
static dragPosition: i32 = -1;
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Swatches")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
@@ -252,6 +252,6 @@ class TabSwatches {
let i = Project.raw.swatches.indexOf(swatch);
Context.setSwatch(Project.raw.swatches[i == Project.raw.swatches.length - 1 ? i - 1 : i + 1]);
Project.raw.swatches.splice(i, 1);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
}
}
diff --git a/base/Sources/TabTextures.ts b/base/Sources/TabTextures.ts
index 8aa6e383..dc62b62a 100644
--- a/base/Sources/TabTextures.ts
+++ b/base/Sources/TabTextures.ts
@@ -2,7 +2,7 @@
class TabTextures {
static draw = (htab: Handle) => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
if (ui.tab(htab, tr("Textures")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
@@ -18,19 +18,19 @@ class TabTextures {
if (ui.button(tr("Import"))) {
UIFiles.show(Path.textureFormats.join(","), false, true, (path: string) => {
ImportAsset.run(path, -1.0, -1.0, true, false);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
});
}
if (ui.isHovered) ui.tooltip(tr("Import texture file") + ` (${Config.keymap.file_import_assets})`);
- if (ui.button(tr("2D View"))) UIBase.inst.show2DView(View2DType.View2DAsset);
+ if (ui.button(tr("2D View"))) UIBase.show2DView(View2DType.View2DAsset);
ui.endSticky();
if (Project.assets.length > 0) {
///if (is_paint || is_sculpt)
- let statusw = System.width - UIToolbar.inst.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
+ let statusw = System.width - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
///end
///if is_lab
let statusw = System.width;
@@ -70,9 +70,9 @@ class TabTextures {
Base.dragAsset = asset;
Context.raw.texture = asset;
- if (Time.time() - Context.raw.selectTime < 0.25) UIBase.inst.show2DView(View2DType.View2DAsset);
+ if (Time.time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DAsset);
Context.raw.selectTime = Time.time();
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.hwnd.redraws = 2;
}
if (asset == Context.raw.texture) {
@@ -158,9 +158,9 @@ class TabTextures {
if (UIMenu.menuButton(ui, tr("Set as Color ID Map"))) {
Context.raw.colorIdHandle.position = i;
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
if (Context.raw.tool == WorkspaceTool.ToolColorId) {
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
Context.raw.ddirty = 2;
}
}
@@ -236,14 +236,14 @@ class TabTextures {
if (Project.assets.length > 1) {
Context.raw.texture = Project.assets[i == Project.assets.length - 1 ? i - 1 : i + 1];
}
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
///if is_paint
if (Context.raw.tool == WorkspaceTool.ToolColorId && i == Context.raw.colorIdHandle.position) {
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
Context.raw.ddirty = 2;
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
}
///end
@@ -256,7 +256,7 @@ class TabTextures {
///if (is_paint || is_sculpt)
UtilRender.makeMaterialPreview();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
///end
}
Base.notifyOnNextFrame(_next);
diff --git a/base/Sources/UIBase.ts b/base/Sources/UIBase.ts
index 2c81688a..7b23f34b 100644
--- a/base/Sources/UIBase.ts
+++ b/base/Sources/UIBase.ts
@@ -1,15 +1,34 @@
+///if is_paint
+///
+///end
+///if is_forge
+///
+///end
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+
class UIBase {
- static inst: UIBase;
- show = true;
- ui: Zui;
- borderStarted = 0;
- borderHandle_ptr: i32 = 0;
- action_paint_remap = "";
- operatorSearchOffset = 0;
- undoTapTime = 0.0;
- redoTapTime = 0.0;
+ static show = true;
+ static ui: Zui;
+ static borderStarted = 0;
+ static borderHandle_ptr: i32 = 0;
+ static action_paint_remap = "";
+ static operatorSearchOffset = 0;
+ static undoTapTime = 0.0;
+ static redoTapTime = 0.0;
static init_hwnds = (): Handle[] => {
///if is_paint
@@ -65,9 +84,9 @@ class UIBase {
///end
}
- hwnds = UIBase.init_hwnds();
- htabs = UIBase.init_htabs();
- hwndTabs = UIBase.init_hwnd_tabs();
+ static hwnds = UIBase.init_hwnds();
+ static htabs = UIBase.init_htabs();
+ static hwndTabs = UIBase.init_hwnd_tabs();
///if (is_paint || is_sculpt)
static defaultSidebarMiniW = 56;
@@ -77,17 +96,15 @@ class UIBase {
///else
static defaultSidebarW = UIBase.defaultSidebarFullW;
///end
- tabx = 0;
- hminimized = new Handle();
+ static tabx = 0;
+ static hminimized = new Handle();
static sidebarMiniW = UIBase.defaultSidebarMiniW;
///end
constructor() {
- UIBase.inst = this;
-
///if (is_paint || is_sculpt)
new UIToolbar();
- UIToolbar.inst.toolbarw = Math.floor(UIToolbar.defaultToolbarW * Config.raw.window_scale);
+ UIToolbar.toolbarw = Math.floor(UIToolbar.defaultToolbarW * Config.raw.window_scale);
Context.raw.textToolText = tr("Text");
///end
@@ -96,7 +113,7 @@ class UIBase {
new UIMenubar();
UIHeader.headerh = Math.floor(UIHeader.defaultHeaderH * Config.raw.window_scale);
- UIMenubar.inst.menubarw = Math.floor(UIMenubar.defaultMenubarW * Config.raw.window_scale);
+ UIMenubar.menubarw = Math.floor(UIMenubar.defaultMenubarW * Config.raw.window_scale);
///if (is_paint || is_sculpt)
if (Project.materials == null) {
@@ -184,11 +201,11 @@ class UIBase {
History.reset();
let scale = Config.raw.window_scale;
- this.ui = new Zui({ theme: Base.theme, font: Base.font, scaleFactor: scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient });
- Zui.onBorderHover = this.onBorderHover;
- Zui.onTextHover = this.onTextHover;
- Zui.onDeselectText = this.onDeselectText;
- Zui.onTabDrop = this.onTabDrop;
+ UIBase.ui = new Zui({ theme: Base.theme, font: Base.font, scaleFactor: scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient });
+ Zui.onBorderHover = UIBase.onBorderHover;
+ Zui.onTextHover = UIBase.onTextHover;
+ Zui.onDeselectText = UIBase.onDeselectText;
+ Zui.onTabDrop = UIBase.onTabDrop;
///if (is_paint || is_sculpt)
let resources = ["cursor.k", "icons.k"];
@@ -212,7 +229,7 @@ class UIBase {
Res.load(resources, () => {});
- if (this.ui.SCALE() > 1) this.setIconScale();
+ if (UIBase.ui.SCALE() > 1) UIBase.setIconScale();
Context.raw.paintObject = (Scene.active.getChild(".Cube") as MeshObject);
Project.paintObjects = [Context.raw.paintObject];
@@ -224,35 +241,35 @@ class UIBase {
Context.raw.projectObjects = [];
for (let m of Scene.active.meshes) Context.raw.projectObjects.push(m);
- Operator.register("view_top", this.view_top);
+ Operator.register("view_top", UIBase.view_top);
}
- update = () => {
- this.updateUI();
+ static update = () => {
+ UIBase.updateUI();
Operator.update();
for (let p of Plugin.plugins.values()) if (p.update != null) p.update();
if (!Base.uiEnabled) return;
- if (!UINodes.inst.ui.isTyping && !this.ui.isTyping) {
+ if (!UINodes.ui.isTyping && !UIBase.ui.isTyping) {
if (Operator.shortcut(Config.keymap.toggle_node_editor)) {
///if (is_paint || is_sculpt)
- UINodes.inst.canvasType == CanvasType.CanvasMaterial ? this.showMaterialNodes() : this.showBrushNodes();
+ UINodes.canvasType == CanvasType.CanvasMaterial ? UIBase.showMaterialNodes() : UIBase.showBrushNodes();
///end
///if is_lab
- this.showMaterialNodes();
+ UIBase.showMaterialNodes();
///end
}
else if (Operator.shortcut(Config.keymap.toggle_browser)) {
- this.toggleBrowser();
+ UIBase.toggleBrowser();
}
else if (Operator.shortcut(Config.keymap.toggle_2d_view)) {
///if (is_paint || is_sculpt)
- this.show2DView(View2DType.View2DLayer);
+ UIBase.show2DView(View2DType.View2DLayer);
///else
- this.show2DView(View2DType.View2DAsset);
+ UIBase.show2DView(View2DType.View2DAsset);
///end
}
}
@@ -291,8 +308,8 @@ class UIBase {
let kb = Input.getKeyboard();
if (kb.started(Config.keymap.view_distract_free) ||
- (kb.started("escape") && !this.show && !UIBox.show)) {
- this.toggleDistractFree();
+ (kb.started("escape") && !UIBase.show && !UIBox.show)) {
+ UIBase.toggleDistractFree();
}
///if krom_linux
@@ -338,7 +355,7 @@ class UIBase {
Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100;
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
}
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Context.raw.brushCanLock) {
Context.raw.brushCanLock = false;
@@ -356,7 +373,7 @@ class UIBase {
Context.raw.brushRadius = Math.max(0.01, Math.min(4.0, Context.raw.brushRadius));
Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100;
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Context.raw.brushCanLock) {
Context.raw.brushCanLock = false;
@@ -366,16 +383,16 @@ class UIBase {
}
///end
- let isTyping = this.ui.isTyping || UIView2D.inst.ui.isTyping || UINodes.inst.ui.isTyping;
+ let isTyping = UIBase.ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping;
///if (is_paint || is_sculpt)
if (!isTyping) {
if (Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) {
- this.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
for (let i = 1; i < 10; ++i) if (kb.started(i + "")) Context.selectMaterial(i - 1);
}
else if (Operator.shortcut(Config.keymap.select_layer, ShortcutType.ShortcutDown)) {
- this.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
for (let i = 1; i < 10; ++i) if (kb.started(i + "")) Context.selectLayer(i - 1);
}
}
@@ -422,40 +439,40 @@ class UIBase {
Context.raw.lockStartedY = mouse.y;
}
else if (Operator.shortcut(Config.keymap.brush_radius_decrease, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushRadius -= this.getRadiusIncrement();
+ Context.raw.brushRadius -= UIBase.getRadiusIncrement();
Context.raw.brushRadius = Math.max(Math.round(Context.raw.brushRadius * 100) / 100, 0.01);
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Operator.shortcut(Config.keymap.brush_radius_increase, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushRadius += this.getRadiusIncrement();
+ Context.raw.brushRadius += UIBase.getRadiusIncrement();
Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100;
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (decalMask) {
if (Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.brush_radius_decrease, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushDecalMaskRadius -= this.getRadiusIncrement();
+ Context.raw.brushDecalMaskRadius -= UIBase.getRadiusIncrement();
Context.raw.brushDecalMaskRadius = Math.max(Math.round(Context.raw.brushDecalMaskRadius * 100) / 100, 0.01);
Context.raw.brushDecalMaskRadiusHandle.value = Context.raw.brushDecalMaskRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.brush_radius_increase, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushDecalMaskRadius += this.getRadiusIncrement();
+ Context.raw.brushDecalMaskRadius += UIBase.getRadiusIncrement();
Context.raw.brushDecalMaskRadius = Math.round(Context.raw.brushDecalMaskRadius * 100) / 100;
Context.raw.brushDecalMaskRadiusHandle.value = Context.raw.brushDecalMaskRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
}
}
if (decalMask && (Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutStarted) || Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutReleased))) {
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
///end
///if is_lab
- if (UIHeader.inst.worktab.position == SpaceType.Space3D) {
+ if (UIHeader.worktab.position == SpaceType.Space3D) {
// Radius
if (Context.raw.tool == WorkspaceTool.ToolEraser ||
Context.raw.tool == WorkspaceTool.ToolClone ||
@@ -468,16 +485,16 @@ class UIBase {
Context.raw.lockStartedY = mouse.y;
}
else if (Operator.shortcut(Config.keymap.brush_radius_decrease, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushRadius -= this.getRadiusIncrement();
+ Context.raw.brushRadius -= UIBase.getRadiusIncrement();
Context.raw.brushRadius = Math.max(Math.round(Context.raw.brushRadius * 100) / 100, 0.01);
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
else if (Operator.shortcut(Config.keymap.brush_radius_increase, ShortcutType.ShortcutRepeat)) {
- Context.raw.brushRadius += this.getRadiusIncrement();
+ Context.raw.brushRadius += UIBase.getRadiusIncrement();
Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100;
Context.raw.brushRadiusHandle.value = Context.raw.brushRadius;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
}
}
}
@@ -575,7 +592,7 @@ class UIBase {
}
}
- if (Operator.shortcut(Config.keymap.operator_search)) this.operatorSearch();
+ if (Operator.shortcut(Config.keymap.operator_search)) UIBase.operatorSearch();
}
if (Context.raw.brushCanLock || Context.raw.brushLocked) {
@@ -612,9 +629,9 @@ class UIBase {
}
///if (is_paint || is_sculpt)
- if (this.borderHandle_ptr != 0) {
- if (this.borderHandle_ptr == UINodes.inst.hwnd.ptr || this.borderHandle_ptr == UIView2D.inst.hwnd.ptr) {
- if (this.borderStarted == BorderSide.SideLeft) {
+ if (UIBase.borderHandle_ptr != 0) {
+ if (UIBase.borderHandle_ptr == UINodes.hwnd.ptr || UIBase.borderHandle_ptr == UIView2D.hwnd.ptr) {
+ if (UIBase.borderStarted == BorderSide.SideLeft) {
Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(mouse.movementX);
if (Config.raw.layout[LayoutSize.LayoutNodesW] < 32) Config.raw.layout[LayoutSize.LayoutNodesW] = 32;
else if (Config.raw.layout[LayoutSize.LayoutNodesW] > System.width * 0.7) Config.raw.layout[LayoutSize.LayoutNodesW] = Math.floor(System.width * 0.7);
@@ -625,21 +642,21 @@ class UIBase {
else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95);
}
}
- else if (this.borderHandle_ptr == this.hwnds[TabArea.TabStatus].ptr) {
+ else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) {
let my = Math.floor(mouse.movementY);
if (Config.raw.layout[LayoutSize.LayoutStatusH] - my >= UIStatus.defaultStatusH * Config.raw.window_scale && Config.raw.layout[LayoutSize.LayoutStatusH] - my < System.height * 0.7) {
Config.raw.layout[LayoutSize.LayoutStatusH] -= my;
}
}
else {
- if (this.borderStarted == BorderSide.SideLeft) {
+ if (UIBase.borderStarted == BorderSide.SideLeft) {
Config.raw.layout[LayoutSize.LayoutSidebarW] -= Math.floor(mouse.movementX);
if (Config.raw.layout[LayoutSize.LayoutSidebarW] < UIBase.sidebarMiniW) Config.raw.layout[LayoutSize.LayoutSidebarW] = UIBase.sidebarMiniW;
else if (Config.raw.layout[LayoutSize.LayoutSidebarW] > System.width - UIBase.sidebarMiniW) Config.raw.layout[LayoutSize.LayoutSidebarW] = System.width - UIBase.sidebarMiniW;
}
else {
let my = Math.floor(mouse.movementY);
- if (this.borderHandle_ptr == this.hwnds[TabArea.TabSidebar1].ptr && this.borderStarted == BorderSide.SideTop) {
+ if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabSidebar1].ptr && UIBase.borderStarted == BorderSide.SideTop) {
if (Config.raw.layout[LayoutSize.LayoutSidebarH0] + my > 32 && Config.raw.layout[LayoutSize.LayoutSidebarH1] - my > 32) {
Config.raw.layout[LayoutSize.LayoutSidebarH0] += my;
Config.raw.layout[LayoutSize.LayoutSidebarH1] -= my;
@@ -651,9 +668,9 @@ class UIBase {
///end
///if is_lab
- if (this.borderHandle_ptr != 0) {
- if (this.borderHandle_ptr == UINodes.inst.hwnd.ptr || this.borderHandle_ptr == UIView2D.inst.hwnd.ptr) {
- if (this.borderStarted == BorderSide.SideLeft) {
+ if (UIBase.borderHandle_ptr != 0) {
+ if (UIBase.borderHandle_ptr == UINodes.hwnd.ptr || UIBase.borderHandle_ptr == UIView2D.hwnd.ptr) {
+ if (UIBase.borderStarted == BorderSide.SideLeft) {
Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(mouse.movementX);
if (Config.raw.layout[LayoutSize.LayoutNodesW] < 32) Config.raw.layout[LayoutSize.LayoutNodesW] = 32;
else if (Config.raw.layout[LayoutSize.LayoutNodesW] > System.width * 0.7) Config.raw.layout[LayoutSize.LayoutNodesW] = Math.floor(System.width * 0.7);
@@ -664,7 +681,7 @@ class UIBase {
else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95);
}
}
- else if (this.borderHandle_ptr == this.hwnds[TabArea.TabStatus].ptr) {
+ else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) {
let my = Math.floor(mouse.movementY);
if (Config.raw.layout[LayoutSize.LayoutStatusH] - my >= UIStatus.defaultStatusH * Config.raw.window_scale && Config.raw.layout[LayoutSize.LayoutStatusH] - my < System.height * 0.7) {
Config.raw.layout[LayoutSize.LayoutStatusH] -= my;
@@ -674,7 +691,7 @@ class UIBase {
///end
if (!mouse.down()) {
- this.borderHandle_ptr = 0;
+ UIBase.borderHandle_ptr = 0;
Base.isResizing = false;
}
@@ -740,8 +757,8 @@ class UIBase {
///end
}
- view_top = () => {
- let isTyping = this.ui.isTyping || UIView2D.inst.ui.isTyping || UINodes.inst.ui.isTyping;
+ static view_top = () => {
+ let isTyping = UIBase.ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping;
let mouse = Input.getMouse();
if (Context.inPaintArea() && !isTyping) {
@@ -751,7 +768,7 @@ class UIBase {
}
}
- operatorSearch = () => {
+ static operatorSearch = () => {
let kb = Input.getKeyboard();
let searchHandle = Zui.handle("uibase_1");
let first = true;
@@ -765,11 +782,11 @@ class UIBase {
ui.startTextEdit(searchHandle); // Focus search bar
}
- if (searchHandle.changed) this.operatorSearchOffset = 0;
+ if (searchHandle.changed) UIBase.operatorSearchOffset = 0;
if (ui.isKeyPressed) { // Move selection
- if (ui.key == KeyCode.Down && this.operatorSearchOffset < 6) this.operatorSearchOffset++;
- if (ui.key == KeyCode.Up && this.operatorSearchOffset > 0) this.operatorSearchOffset--;
+ if (ui.key == KeyCode.Down && UIBase.operatorSearchOffset < 6) UIBase.operatorSearchOffset++;
+ if (ui.key == KeyCode.Up && UIBase.operatorSearchOffset > 0) UIBase.operatorSearchOffset--;
}
let enter = kb.down("enter");
let count = 0;
@@ -777,8 +794,8 @@ class UIBase {
for (let n in Config.keymap) {
if (n.indexOf(search) >= 0) {
- ui.t.BUTTON_COL = count == this.operatorSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL;
- if (ui.button(n, Align.Left, Config.keymap[n]) || (enter && count == this.operatorSearchOffset)) {
+ ui.t.BUTTON_COL = count == UIBase.operatorSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL;
+ if (ui.button(n, Align.Left, Config.keymap[n]) || (enter && count == UIBase.operatorSearchOffset)) {
if (enter) {
ui.changed = true;
count = 6; // Trigger break
@@ -797,12 +814,12 @@ class UIBase {
}, 8, -1, -1);
}
- toggleDistractFree = () => {
- this.show = !this.show;
+ static toggleDistractFree = () => {
+ UIBase.show = !UIBase.show;
Base.resize();
}
- getRadiusIncrement = (): f32 => {
+ static getRadiusIncrement = (): f32 => {
return 0.1;
}
@@ -811,7 +828,7 @@ class UIBase {
}
///if (is_paint || is_sculpt)
- getBrushStencilRect = (): TRect => {
+ static getBrushStencilRect = (): TRect => {
let w = Math.floor(Context.raw.brushStencilImage.width * (Base.h() / Context.raw.brushStencilImage.height) * Context.raw.brushStencilScale);
let h = Math.floor(Base.h() * Context.raw.brushStencilScale);
let x = Math.floor(Base.x() + Context.raw.brushStencilX * Base.w());
@@ -820,14 +837,14 @@ class UIBase {
}
///end
- updateUI = () => {
+ static updateUI = () => {
if (Console.messageTimer > 0) {
Console.messageTimer -= Time.delta;
- if (Console.messageTimer <= 0) this.hwnds[TabArea.TabStatus].redraws = 2;
+ if (Console.messageTimer <= 0) UIBase.hwnds[TabArea.TabStatus].redraws = 2;
}
///if (is_paint || is_sculpt)
- UIBase.sidebarMiniW = Math.floor(UIBase.defaultSidebarMiniW * this.ui.SCALE());
+ UIBase.sidebarMiniW = Math.floor(UIBase.defaultSidebarMiniW * UIBase.ui.SCALE());
///end
if (!Base.uiEnabled) return;
@@ -839,7 +856,7 @@ class UIBase {
// Same mapping for paint and rotate (predefined in touch keymap)
if (Context.inViewport()) {
if (mouse.started() && Config.keymap.action_paint == Config.keymap.action_rotate) {
- this.action_paint_remap = Config.keymap.action_paint;
+ UIBase.action_paint_remap = Config.keymap.action_paint;
UtilRender.pickPosNorTex();
let isMesh = Math.abs(Context.raw.posXPicked) < 50 && Math.abs(Context.raw.posYPicked) < 50 && Math.abs(Context.raw.posZPicked) < 50;
///if krom_android
@@ -853,23 +870,23 @@ class UIBase {
// Pen painting only - rotate with touch, paint with pen
if ((isMesh && !penOnly) || isPen) {
Config.keymap.action_rotate = "";
- Config.keymap.action_paint = this.action_paint_remap;
+ Config.keymap.action_paint = UIBase.action_paint_remap;
}
// World sphere picked - disable paint
else {
Config.keymap.action_paint = "";
- Config.keymap.action_rotate = this.action_paint_remap;
+ Config.keymap.action_rotate = UIBase.action_paint_remap;
}
}
- else if (!mouse.down() && this.action_paint_remap != "") {
- Config.keymap.action_rotate = this.action_paint_remap;
- Config.keymap.action_paint = this.action_paint_remap;
- this.action_paint_remap = "";
+ else if (!mouse.down() && UIBase.action_paint_remap != "") {
+ Config.keymap.action_rotate = UIBase.action_paint_remap;
+ Config.keymap.action_paint = UIBase.action_paint_remap;
+ UIBase.action_paint_remap = "";
}
}
if (Context.raw.brushStencilImage != null && Operator.shortcut(Config.keymap.stencil_transform, ShortcutType.ShortcutDown)) {
- let r = this.getBrushStencilRect();
+ let r = UIBase.getBrushStencilRect();
if (mouse.started("left")) {
Context.raw.brushStencilScaling =
UIBase.hitRect(mouse.x, mouse.y, r.x - 8, r.y - 8, 16, 16) ||
@@ -971,7 +988,7 @@ class UIBase {
///if (is_paint || is_sculpt)
if (Context.raw.paint2d) {
mx -= App.w();
- ww = UIView2D.inst.ww;
+ ww = UIView2D.ww;
}
///end
@@ -1078,7 +1095,7 @@ class UIBase {
g2.pipeline = null;
g2.end();
}
- this.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
}
if (Context.raw.layerPreviewDirty && !Context.raw.layer.isGroup()) {
Context.raw.layerPreviewDirty = false;
@@ -1095,7 +1112,7 @@ class UIBase {
g2.drawScaledImage(source, 0, 0, target.width, target.height);
g2.pipeline = null;
g2.end();
- this.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
}
///end
@@ -1105,10 +1122,10 @@ class UIBase {
// Two-finger tap to undo, three-finger tap to redo
if (Context.inViewport() && Config.raw.touch_ui) {
- if (mouse.started("middle")) { this.redoTapTime = Time.time(); }
- else if (mouse.started("right")) { this.undoTapTime = Time.time(); }
- else if (mouse.released("middle") && Time.time() - this.redoTapTime < 0.1) { this.redoTapTime = this.undoTapTime = 0; redoPressed = true; }
- else if (mouse.released("right") && Time.time() - this.undoTapTime < 0.1) { this.redoTapTime = this.undoTapTime = 0; undoPressed = true; }
+ if (mouse.started("middle")) { UIBase.redoTapTime = Time.time(); }
+ else if (mouse.started("right")) { UIBase.undoTapTime = Time.time(); }
+ else if (mouse.released("middle") && Time.time() - UIBase.redoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; redoPressed = true; }
+ else if (mouse.released("right") && Time.time() - UIBase.undoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; undoPressed = true; }
}
if (undoPressed) History.undo();
@@ -1119,122 +1136,122 @@ class UIBase {
///end
}
- render = (g: Graphics2) => {
- if (!this.show && Config.raw.touch_ui) {
- this.ui.inputEnabled = true;
+ static render = (g: Graphics2) => {
+ if (!UIBase.show && Config.raw.touch_ui) {
+ UIBase.ui.inputEnabled = true;
g.end();
- this.ui.begin(g);
- if (this.ui.window(Zui.handle("uibase_2"), 0, 0, 150, Math.floor(this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET() + 1))) {
- if (this.ui.button(tr("Close"))) {
- this.toggleDistractFree();
+ UIBase.ui.begin(g);
+ if (UIBase.ui.window(Zui.handle("uibase_2"), 0, 0, 150, Math.floor(UIBase.ui.ELEMENT_H() + UIBase.ui.ELEMENT_OFFSET() + 1))) {
+ if (UIBase.ui.button(tr("Close"))) {
+ UIBase.toggleDistractFree();
}
}
- this.ui.end();
+ UIBase.ui.end();
g.begin(false);
}
- if (!this.show || System.width == 0 || System.height == 0) return;
+ if (!UIBase.show || System.width == 0 || System.height == 0) return;
- this.ui.inputEnabled = Base.uiEnabled;
+ UIBase.ui.inputEnabled = Base.uiEnabled;
// Remember last tab positions
- for (let i = 0; i < this.htabs.length; ++i) {
- if (this.htabs[i].changed) {
- Config.raw.layout_tabs[i] = this.htabs[i].position;
+ for (let i = 0; i < UIBase.htabs.length; ++i) {
+ if (UIBase.htabs[i].changed) {
+ Config.raw.layout_tabs[i] = UIBase.htabs[i].position;
Config.save();
}
}
// Set tab positions
- for (let i = 0; i < this.htabs.length; ++i) {
- this.htabs[i].position = Config.raw.layout_tabs[i];
+ for (let i = 0; i < UIBase.htabs.length; ++i) {
+ UIBase.htabs[i].position = Config.raw.layout_tabs[i];
}
g.end();
- this.ui.begin(g);
+ UIBase.ui.begin(g);
///if (is_paint || is_sculpt)
- UIToolbar.inst.renderUI(g);
+ UIToolbar.renderUI(g);
///end
- UIMenubar.inst.renderUI(g);
- UIHeader.inst.renderUI(g);
- UIStatus.inst.renderUI(g);
+ UIMenubar.renderUI(g);
+ UIHeader.renderUI(g);
+ UIStatus.renderUI(g);
///if (is_paint || is_sculpt)
- this.drawSidebar();
+ UIBase.drawSidebar();
///end
- this.ui.end();
+ UIBase.ui.end();
g.begin(false);
}
///if (is_paint || is_sculpt)
- drawSidebar = () => {
+ static drawSidebar = () => {
// Tabs
let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW;
- let expandButtonOffset = Config.raw.touch_ui ? Math.floor(this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET()) : 0;
- this.tabx = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW];
+ let expandButtonOffset = Config.raw.touch_ui ? Math.floor(UIBase.ui.ELEMENT_H() + UIBase.ui.ELEMENT_OFFSET()) : 0;
+ UIBase.tabx = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW];
- let _SCROLL_W = this.ui.t.SCROLL_W;
- if (mini) this.ui.t.SCROLL_W = this.ui.t.SCROLL_MINI_W;
+ let _SCROLL_W = UIBase.ui.t.SCROLL_W;
+ if (mini) UIBase.ui.t.SCROLL_W = UIBase.ui.t.SCROLL_MINI_W;
- if (this.ui.window(this.hwnds[TabArea.TabSidebar0], this.tabx, 0, Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH0])) {
- for (let i = 0; i < (mini ? 1 : this.hwndTabs[TabArea.TabSidebar0].length); ++i) this.hwndTabs[TabArea.TabSidebar0][i](this.htabs[TabArea.TabSidebar0]);
+ if (UIBase.ui.window(UIBase.hwnds[TabArea.TabSidebar0], UIBase.tabx, 0, Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH0])) {
+ for (let i = 0; i < (mini ? 1 : UIBase.hwndTabs[TabArea.TabSidebar0].length); ++i) UIBase.hwndTabs[TabArea.TabSidebar0][i](UIBase.htabs[TabArea.TabSidebar0]);
}
- if (this.ui.window(this.hwnds[TabArea.TabSidebar1], this.tabx, Config.raw.layout[LayoutSize.LayoutSidebarH0], Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH1] - expandButtonOffset)) {
- for (let i = 0; i < (mini ? 1 : this.hwndTabs[TabArea.TabSidebar1].length); ++i) this.hwndTabs[TabArea.TabSidebar1][i](this.htabs[TabArea.TabSidebar1]);
+ if (UIBase.ui.window(UIBase.hwnds[TabArea.TabSidebar1], UIBase.tabx, Config.raw.layout[LayoutSize.LayoutSidebarH0], Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH1] - expandButtonOffset)) {
+ for (let i = 0; i < (mini ? 1 : UIBase.hwndTabs[TabArea.TabSidebar1].length); ++i) UIBase.hwndTabs[TabArea.TabSidebar1][i](UIBase.htabs[TabArea.TabSidebar1]);
}
- this.ui.endWindow();
- this.ui.t.SCROLL_W = _SCROLL_W;
+ UIBase.ui.endWindow();
+ UIBase.ui.t.SCROLL_W = _SCROLL_W;
// Collapse / expand button for mini sidebar
if (Config.raw.touch_ui) {
let width = Config.raw.layout[LayoutSize.LayoutSidebarW];
- let height = Math.floor(this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET());
- if (this.ui.window(Zui.handle("uibase_3"), System.width - width, System.height - height, width, height + 1)) {
- this.ui._w = width;
- let _BUTTON_H = this.ui.t.BUTTON_H;
- let _BUTTON_COL = this.ui.t.BUTTON_COL;
- this.ui.t.BUTTON_H = this.ui.t.ELEMENT_H;
- this.ui.t.BUTTON_COL = this.ui.t.WINDOW_BG_COL;
- if (this.ui.button(mini ? "<<" : ">>")) {
+ let height = Math.floor(UIBase.ui.ELEMENT_H() + UIBase.ui.ELEMENT_OFFSET());
+ if (UIBase.ui.window(Zui.handle("uibase_3"), System.width - width, System.height - height, width, height + 1)) {
+ UIBase.ui._w = width;
+ let _BUTTON_H = UIBase.ui.t.BUTTON_H;
+ let _BUTTON_COL = UIBase.ui.t.BUTTON_COL;
+ UIBase.ui.t.BUTTON_H = UIBase.ui.t.ELEMENT_H;
+ UIBase.ui.t.BUTTON_COL = UIBase.ui.t.WINDOW_BG_COL;
+ if (UIBase.ui.button(mini ? "<<" : ">>")) {
Config.raw.layout[LayoutSize.LayoutSidebarW] = mini ? UIBase.defaultSidebarFullW : UIBase.defaultSidebarMiniW;
- Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] * this.ui.SCALE());
+ Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] * UIBase.ui.SCALE());
}
- this.ui.t.BUTTON_H = _BUTTON_H;
- this.ui.t.BUTTON_COL = _BUTTON_COL;
+ UIBase.ui.t.BUTTON_H = _BUTTON_H;
+ UIBase.ui.t.BUTTON_COL = _BUTTON_COL;
}
}
// Expand button
if (Config.raw.layout[LayoutSize.LayoutSidebarW] == 0) {
- let width = Math.floor(this.ui.font.width(this.ui.fontSize, "<<") + 25 * this.ui.SCALE());
- if (this.ui.window(this.hminimized, System.width - width, 0, width, Math.floor(this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET() + 1))) {
- this.ui._w = width;
- let _BUTTON_H = this.ui.t.BUTTON_H;
- let _BUTTON_COL = this.ui.t.BUTTON_COL;
- this.ui.t.BUTTON_H = this.ui.t.ELEMENT_H;
- this.ui.t.BUTTON_COL = this.ui.t.SEPARATOR_COL;
+ let width = Math.floor(UIBase.ui.font.width(UIBase.ui.fontSize, "<<") + 25 * UIBase.ui.SCALE());
+ if (UIBase.ui.window(UIBase.hminimized, System.width - width, 0, width, Math.floor(UIBase.ui.ELEMENT_H() + UIBase.ui.ELEMENT_OFFSET() + 1))) {
+ UIBase.ui._w = width;
+ let _BUTTON_H = UIBase.ui.t.BUTTON_H;
+ let _BUTTON_COL = UIBase.ui.t.BUTTON_COL;
+ UIBase.ui.t.BUTTON_H = UIBase.ui.t.ELEMENT_H;
+ UIBase.ui.t.BUTTON_COL = UIBase.ui.t.SEPARATOR_COL;
- if (this.ui.button("<<")) {
+ if (UIBase.ui.button("<<")) {
Config.raw.layout[LayoutSize.LayoutSidebarW] = Context.raw.maximizedSidebarWidth != 0 ? Context.raw.maximizedSidebarWidth : Math.floor(UIBase.defaultSidebarW * Config.raw.window_scale);
}
- this.ui.t.BUTTON_H = _BUTTON_H;
- this.ui.t.BUTTON_COL = _BUTTON_COL;
+ UIBase.ui.t.BUTTON_H = _BUTTON_H;
+ UIBase.ui.t.BUTTON_COL = _BUTTON_COL;
}
}
- else if (this.htabs[TabArea.TabSidebar0].changed && this.htabs[TabArea.TabSidebar0].position == Context.raw.lastHtab0Position) {
+ else if (UIBase.htabs[TabArea.TabSidebar0].changed && UIBase.htabs[TabArea.TabSidebar0].position == Context.raw.lastHtab0Position) {
if (Time.time() - Context.raw.selectTime < 0.25) {
Context.raw.maximizedSidebarWidth = Config.raw.layout[LayoutSize.LayoutSidebarW];
Config.raw.layout[LayoutSize.LayoutSidebarW] = 0;
}
Context.raw.selectTime = Time.time();
}
- Context.raw.lastHtab0Position = this.htabs[TabArea.TabSidebar0].position;
+ Context.raw.lastHtab0Position = UIBase.htabs[TabArea.TabSidebar0].position;
}
- renderCursor = (g: Graphics2) => {
+ static renderCursor = (g: Graphics2) => {
if (!Base.uiEnabled) return;
///if is_paint
@@ -1262,7 +1279,7 @@ class UIBase {
tool != WorkspaceTool.ToolPicker &&
tool != WorkspaceTool.ToolMaterial &&
tool != WorkspaceTool.ToolColorId) {
- let r = this.getBrushStencilRect();
+ let r = UIBase.getBrushStencilRect();
if (!Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown)) {
g.color = 0x88ffffff;
let angle = Context.raw.brushStencilAngle;
@@ -1309,7 +1326,7 @@ class UIBase {
}
let cursorImg = Res.get("cursor.k");
- let psize = Math.floor(cursorImg.width * (Context.raw.brushRadius * Context.raw.brushNodesRadius) * this.ui.SCALE());
+ let psize = Math.floor(cursorImg.width * (Context.raw.brushRadius * Context.raw.brushNodesRadius) * UIBase.ui.SCALE());
// Clone source cursor
let mouse = Input.getMouse();
@@ -1340,8 +1357,8 @@ class UIBase {
}
if (!Config.raw.brush_live) {
- let psizex = Math.floor(256 * this.ui.SCALE() * (Context.raw.brushRadius * Context.raw.brushNodesRadius * Context.raw.brushScaleX));
- let psizey = Math.floor(256 * this.ui.SCALE() * (Context.raw.brushRadius * Context.raw.brushNodesRadius));
+ let psizex = Math.floor(256 * UIBase.ui.SCALE() * (Context.raw.brushRadius * Context.raw.brushNodesRadius * Context.raw.brushScaleX));
+ let psizey = Math.floor(256 * UIBase.ui.SCALE() * (Context.raw.brushRadius * Context.raw.brushNodesRadius));
Context.raw.viewIndex = Context.raw.viewIndexLast;
let decalX = Base.x() + Context.raw.decalX * Base.w() - psizex / 2;
@@ -1371,10 +1388,10 @@ class UIBase {
(decalMask && !Config.raw.brush_3d) ||
(decalMask && Context.in2dView())) {
if (decalMask) {
- psize = Math.floor(cursorImg.width * (Context.raw.brushDecalMaskRadius * Context.raw.brushNodesRadius) * this.ui.SCALE());
+ psize = Math.floor(cursorImg.width * (Context.raw.brushDecalMaskRadius * Context.raw.brushNodesRadius) * UIBase.ui.SCALE());
}
if (Config.raw.brush_3d && Context.in2dView()) {
- psize = Math.floor(psize * UIView2D.inst.panScale);
+ psize = Math.floor(psize * UIView2D.panScale);
}
g.drawScaledImage(cursorImg, mx - psize / 2, my - psize / 2, psize, psize);
}
@@ -1400,49 +1417,49 @@ class UIBase {
}
///end
- showMaterialNodes = () => {
+ static showMaterialNodes = () => {
// Clear input state as ui receives input events even when not drawn
- UINodes.inst.ui.endInput();
+ UINodes.ui.endInput();
///if (is_paint || is_sculpt)
- UINodes.inst.show = !UINodes.inst.show || UINodes.inst.canvasType != CanvasType.CanvasMaterial;
- UINodes.inst.canvasType = CanvasType.CanvasMaterial;
+ UINodes.show = !UINodes.show || UINodes.canvasType != CanvasType.CanvasMaterial;
+ UINodes.canvasType = CanvasType.CanvasMaterial;
///end
///if is_lab
- UINodes.inst.show = !UINodes.inst.show;
+ UINodes.show = !UINodes.show;
///end
Base.resize();
}
///if (is_paint || is_sculpt)
- showBrushNodes = () => {
+ static showBrushNodes = () => {
// Clear input state as ui receives input events even when not drawn
- UINodes.inst.ui.endInput();
- UINodes.inst.show = !UINodes.inst.show || UINodes.inst.canvasType != CanvasType.CanvasBrush;
- UINodes.inst.canvasType = CanvasType.CanvasBrush;
+ UINodes.ui.endInput();
+ UINodes.show = !UINodes.show || UINodes.canvasType != CanvasType.CanvasBrush;
+ UINodes.canvasType = CanvasType.CanvasBrush;
Base.resize();
}
///end
- show2DView = (type: View2DType) => {
+ static show2DView = (type: View2DType) => {
// Clear input state as ui receives input events even when not drawn
- UIView2D.inst.ui.endInput();
- if (UIView2D.inst.type != type) UIView2D.inst.show = true;
- else UIView2D.inst.show = !UIView2D.inst.show;
- UIView2D.inst.type = type;
- UIView2D.inst.hwnd.redraws = 2;
+ UIView2D.ui.endInput();
+ if (UIView2D.type != type) UIView2D.show = true;
+ else UIView2D.show = !UIView2D.show;
+ UIView2D.type = type;
+ UIView2D.hwnd.redraws = 2;
Base.resize();
}
- toggleBrowser = () => {
+ static toggleBrowser = () => {
let minimized = Config.raw.layout[LayoutSize.LayoutStatusH] <= (UIStatus.defaultStatusH * Config.raw.window_scale);
Config.raw.layout[LayoutSize.LayoutStatusH] = minimized ? 240 : UIStatus.defaultStatusH;
Config.raw.layout[LayoutSize.LayoutStatusH] = Math.floor(Config.raw.layout[LayoutSize.LayoutStatusH] * Config.raw.window_scale);
}
- setIconScale = () => {
- if (this.ui.SCALE() > 1) {
+ static setIconScale = () => {
+ if (UIBase.ui.SCALE() > 1) {
Res.load(["icons2x.k"], () => {
Res.bundled.set("icons.k", Res.get("icons2x.k"));
});
@@ -1452,30 +1469,30 @@ class UIBase {
}
}
- onBorderHover = (handle_ptr: i32, side: i32) => {
+ static onBorderHover = (handle_ptr: i32, side: i32) => {
if (!Base.uiEnabled) return;
///if (is_paint || is_sculpt)
- if (handle_ptr != this.hwnds[TabArea.TabSidebar0].ptr &&
- handle_ptr != this.hwnds[TabArea.TabSidebar1].ptr &&
- handle_ptr != this.hwnds[TabArea.TabStatus].ptr &&
- handle_ptr != UINodes.inst.hwnd.ptr &&
- handle_ptr != UIView2D.inst.hwnd.ptr) return; // Scalable handles
- if (handle_ptr == UIView2D.inst.hwnd.ptr && side != BorderSide.SideLeft) return;
- if (handle_ptr == UINodes.inst.hwnd.ptr && side == BorderSide.SideTop && !UIView2D.inst.show) return;
- if (handle_ptr == this.hwnds[TabArea.TabSidebar0].ptr && side == BorderSide.SideTop) return;
+ if (handle_ptr != UIBase.hwnds[TabArea.TabSidebar0].ptr &&
+ handle_ptr != UIBase.hwnds[TabArea.TabSidebar1].ptr &&
+ handle_ptr != UIBase.hwnds[TabArea.TabStatus].ptr &&
+ handle_ptr != UINodes.hwnd.ptr &&
+ handle_ptr != UIView2D.hwnd.ptr) return; // Scalable handles
+ if (handle_ptr == UIView2D.hwnd.ptr && side != BorderSide.SideLeft) return;
+ if (handle_ptr == UINodes.hwnd.ptr && side == BorderSide.SideTop && !UIView2D.show) return;
+ if (handle_ptr == UIBase.hwnds[TabArea.TabSidebar0].ptr && side == BorderSide.SideTop) return;
///end
///if is_lab
- if (handle_ptr != this.hwnds[TabArea.TabStatus].ptr &&
- handle_ptr != UINodes.inst.hwnd.ptr &&
- handle_ptr != UIView2D.inst.hwnd.ptr) return; // Scalable handles
- if (handle_ptr == UIView2D.inst.hwnd.ptr && side != BorderSide.SideLeft) return;
- if (handle_ptr == UINodes.inst.hwnd.ptr && side == BorderSide.SideTop && !UIView2D.inst.show) return;
+ if (handle_ptr != UIBase.hwnds[TabArea.TabStatus].ptr &&
+ handle_ptr != UINodes.hwnd.ptr &&
+ handle_ptr != UIView2D.hwnd.ptr) return; // Scalable handles
+ if (handle_ptr == UIView2D.hwnd.ptr && side != BorderSide.SideLeft) return;
+ if (handle_ptr == UINodes.hwnd.ptr && side == BorderSide.SideTop && !UIView2D.show) return;
///end
- if (handle_ptr == UINodes.inst.hwnd.ptr && side != BorderSide.SideLeft && side != BorderSide.SideTop) return;
- if (handle_ptr == this.hwnds[TabArea.TabStatus].ptr && side != BorderSide.SideTop) return;
+ if (handle_ptr == UINodes.hwnd.ptr && side != BorderSide.SideLeft && side != BorderSide.SideTop) return;
+ if (handle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr && side != BorderSide.SideTop) return;
if (side == BorderSide.SideRight) return; // UI is snapped to the right side
side == BorderSide.SideLeft || side == BorderSide.SideRight ?
@@ -1483,47 +1500,47 @@ class UIBase {
Krom.setMouseCursor(4); // Vertical
if (Zui.current.inputStarted) {
- this.borderStarted = side;
- this.borderHandle_ptr = handle_ptr;
+ UIBase.borderStarted = side;
+ UIBase.borderHandle_ptr = handle_ptr;
Base.isResizing = true;
}
}
- onTextHover = () => {
+ static onTextHover = () => {
Krom.setMouseCursor(2); // I-cursor
}
- onDeselectText = () => {
+ static onDeselectText = () => {
///if krom_ios
Input.getKeyboard().upListener(KeyCode.Shift);
///end
}
- onTabDrop = (to_ptr: i32, toPosition: i32, from_ptr: i32, fromPosition: i32) => {
+ static onTabDrop = (to_ptr: i32, toPosition: i32, from_ptr: i32, fromPosition: i32) => {
let i = -1;
let j = -1;
- for (let k = 0; k < this.htabs.length; ++k) {
- if (this.htabs[k].ptr == to_ptr) i = k;
- if (this.htabs[k].ptr == from_ptr) j = k;
+ for (let k = 0; k < UIBase.htabs.length; ++k) {
+ if (UIBase.htabs[k].ptr == to_ptr) i = k;
+ if (UIBase.htabs[k].ptr == from_ptr) j = k;
}
if (i > -1 && j > -1) {
- let element = this.hwndTabs[j][fromPosition];
- this.hwndTabs[j].splice(fromPosition, 1);
- this.hwndTabs[i].splice(toPosition, 0, element);
- this.hwnds[i].redraws = 2;
- this.hwnds[j].redraws = 2;
+ let element = UIBase.hwndTabs[j][fromPosition];
+ UIBase.hwndTabs[j].splice(fromPosition, 1);
+ UIBase.hwndTabs[i].splice(toPosition, 0, element);
+ UIBase.hwnds[i].redraws = 2;
+ UIBase.hwnds[j].redraws = 2;
}
}
- tagUIRedraw = () => {
- UIHeader.inst.headerHandle.redraws = 2;
- this.hwnds[TabArea.TabStatus].redraws = 2;
- UIMenubar.inst.workspaceHandle.redraws = 2;
- UIMenubar.inst.menuHandle.redraws = 2;
+ static tagUIRedraw = () => {
+ UIHeader.headerHandle.redraws = 2;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+ UIMenubar.workspaceHandle.redraws = 2;
+ UIMenubar.menuHandle.redraws = 2;
///if (is_paint || is_sculpt)
- this.hwnds[TabArea.TabSidebar0].redraws = 2;
- this.hwnds[TabArea.TabSidebar1].redraws = 2;
- UIToolbar.inst.toolbarHandle.redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIToolbar.toolbarHandle.redraws = 2;
///end
}
}
diff --git a/base/Sources/UIFiles.ts b/base/Sources/UIFiles.ts
index 4044b167..cd1536bd 100644
--- a/base/Sources/UIFiles.ts
+++ b/base/Sources/UIFiles.ts
@@ -87,7 +87,7 @@ class UIFiles {
let file = Res.tile50(icons, 3, 1);
let isCloud = handle.text.startsWith("cloud");
- if (isCloud && File.cloud == null) File.initCloud(() => { UIBase.inst.hwnds[TabArea.TabStatus].redraws = 3; });
+ if (isCloud && File.cloud == null) File.initCloud(() => { UIBase.hwnds[TabArea.TabStatus].redraws = 3; });
if (isCloud && File.readDirectory("cloud", false).length == 0) return handle.text;
///if krom_ios
@@ -191,7 +191,7 @@ class UIFiles {
icon.g2.pipeline = null;
icon.g2.end();
UIFiles.iconMap.set(handle.text + Path.sep + f, icon);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 3;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 3;
});
});
}
@@ -292,7 +292,7 @@ class UIFiles {
icon.g2.pipeline = null;
icon.g2.end();
UIFiles.iconMap.set(shandle, icon);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 3;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 3;
Data.deleteImage(shandle); // The big image is not needed anymore
});
});
diff --git a/base/Sources/UIHeader.ts b/base/Sources/UIHeader.ts
index d6625c42..ac1a34ca 100644
--- a/base/Sources/UIHeader.ts
+++ b/base/Sources/UIHeader.ts
@@ -1,19 +1,16 @@
class UIHeader {
- static inst: UIHeader;
-
static defaultHeaderH = 28;
static headerh = UIHeader.defaultHeaderH;
- headerHandle = new Handle({ layout: Layout.Horizontal });
- worktab = new Handle();
+ static headerHandle = new Handle({ layout: Layout.Horizontal });
+ static worktab = new Handle();
constructor() {
- UIHeader.inst = this;
}
- renderUI = (g: Graphics2) => {
- let ui = UIBase.inst.ui;
+ static renderUI = (g: Graphics2) => {
+ let ui = UIBase.ui;
if (Config.raw.touch_ui) {
UIHeader.headerh = UIHeader.defaultHeaderH + 6;
}
@@ -24,22 +21,22 @@ class UIHeader {
if (Config.raw.layout[LayoutSize.LayoutHeader] == 0) return;
- let nodesw = (UINodes.inst.show || UIView2D.inst.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0;
+ let nodesw = (UINodes.show || UIView2D.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0;
///if is_lab
let ww = System.width - nodesw;
///else
- let ww = System.width - UIToolbar.inst.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW] - nodesw;
+ let ww = System.width - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW] - nodesw;
///end
- if (ui.window(this.headerHandle, App.x(), UIHeader.headerh, ww, UIHeader.headerh)) {
+ if (ui.window(UIHeader.headerHandle, App.x(), UIHeader.headerh, ww, UIHeader.headerh)) {
ui._y += 2;
- this.drawToolProperties(ui);
+ UIHeader.drawToolProperties(ui);
}
}
///if is_paint
- drawToolProperties = (ui: Zui) => {
+ static drawToolProperties = (ui: Zui) => {
if (Context.raw.tool == WorkspaceTool.ToolColorId) {
ui.text(tr("Picked Color"));
if (Context.raw.colorIdPicked) {
@@ -48,7 +45,7 @@ class UIHeader {
ui.enabled = Context.raw.colorIdPicked;
if (ui.button(tr("Clear"))) {
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
}
ui.enabled = true;
ui.text(tr("Color ID Map"));
@@ -57,7 +54,7 @@ class UIHeader {
if (Context.raw.colorIdHandle.changed) {
Context.raw.ddirty = 2;
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
}
ui.image(Project.getImage(Project.assets[cid]));
if (ui.isHovered) ui.tooltipImage(Project.getImage(Project.assets[cid]), 256);
@@ -73,8 +70,8 @@ class UIHeader {
}
Context.raw.ddirty = 2;
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
- UIBase.inst.hwnds[2].redraws = 2;
+ UIToolbar.toolbarHandle.redraws = 1;
+ UIBase.hwnds[2].redraws = 2;
});
}
ui.enabled = Context.raw.colorIdPicked;
@@ -93,8 +90,8 @@ class UIHeader {
m.texpaint.g4.drawIndexedVertices();
m.texpaint.g4.end();
Context.raw.colorIdPicked = false;
- UIToolbar.inst.toolbarHandle.redraws = 1;
- UIHeader.inst.headerHandle.redraws = 1;
+ UIToolbar.toolbarHandle.redraws = 1;
+ UIHeader.headerHandle.redraws = 1;
Context.raw.layerPreviewDirty = true;
Base.updateFillLayers();
}
@@ -144,7 +141,7 @@ class UIHeader {
let newSwatch = Project.cloneSwatch(Context.raw.pickedColor);
Context.setSwatch(newSwatch);
Project.raw.swatches.push(newSwatch);
- UIBase.inst.hwnds[2].redraws = 1;
+ UIBase.hwnds[2].redraws = 1;
}
if (ui.isHovered) ui.tooltip(tr("Add picked color to swatches"));
@@ -182,7 +179,7 @@ class UIHeader {
Base.notifyOnNextFrame(() => {
Context.raw.layerPreviewDirty = true;
});
- UIBase.inst.hwnds[0].redraws = 2;
+ UIBase.hwnds[0].redraws = 2;
History.pushUndo = true;
///if (krom_direct3d12 || krom_vulkan || krom_metal)
RenderPathRaytraceBake.currentSample = 0;
@@ -472,7 +469,7 @@ class UIHeader {
///end
///if is_sculpt
- drawToolProperties = (ui: Zui) => {
+ static drawToolProperties = (ui: Zui) => {
if (Context.raw.tool == WorkspaceTool.ToolBrush) {
Context.raw.brushRadius = ui.slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true);
if (ui.isHovered) ui.tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", new Map([["brush_radius", Config.keymap.brush_radius], ["brush_radius_decrease", Config.keymap.brush_radius_decrease], ["brush_radius_increase", Config.keymap.brush_radius_increase]])));
@@ -481,7 +478,7 @@ class UIHeader {
///end
///if is_lab
- drawToolProperties = (ui: Zui) => {
+ static drawToolProperties = (ui: Zui) => {
if (Context.raw.tool == WorkspaceTool.ToolPicker) {
}
@@ -490,8 +487,8 @@ class UIHeader {
Context.raw.tool == WorkspaceTool.ToolBlur ||
Context.raw.tool == WorkspaceTool.ToolSmudge) {
- let nodes = UINodes.inst.getNodes();
- let canvas = UINodes.inst.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let inpaint = nodes.nodesSelectedId.length > 0 && nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
if (inpaint) {
Context.raw.brushRadius = ui.slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true);
diff --git a/base/Sources/UIMenu.ts b/base/Sources/UIMenu.ts
index 9bba4eaa..9f646f48 100644
--- a/base/Sources/UIMenu.ts
+++ b/base/Sources/UIMenu.ts
@@ -107,8 +107,8 @@ class UIMenu {
}
else if (UIMenu.menuCategory == MenuCategory.MenuViewport) {
if (UIMenu.menuButton(ui, tr("Distract Free"), Config.keymap.view_distract_free)) {
- UIBase.inst.toggleDistractFree();
- UIBase.inst.ui.isHovered = false;
+ UIBase.toggleDistractFree();
+ UIBase.ui.isHovered = false;
}
///if !(krom_android || krom_ios)
diff --git a/base/Sources/UIMenubar.ts b/base/Sources/UIMenubar.ts
index 9b5de7f4..3141b5e3 100644
--- a/base/Sources/UIMenubar.ts
+++ b/base/Sources/UIMenubar.ts
@@ -1,11 +1,10 @@
class UIMenubar {
- static inst: UIMenubar;
static defaultMenubarW = 330;
- workspaceHandle = new Handle({ layout: Layout.Horizontal });
- menuHandle = new Handle({ layout: Layout.Horizontal });
- menubarw = UIMenubar.defaultMenubarW;
+ static workspaceHandle = new Handle({ layout: Layout.Horizontal });
+ static menuHandle = new Handle({ layout: Layout.Horizontal });
+ static menubarw = UIMenubar.defaultMenubarW;
///if is_lab
static _savedCamera: Mat4 = null;
@@ -13,20 +12,19 @@ class UIMenubar {
///end
constructor() {
- UIMenubar.inst = this;
}
- renderUI = (g: Graphics2) => {
- let ui = UIBase.inst.ui;
+ static renderUI = (g: Graphics2) => {
+ let ui = UIBase.ui;
///if (is_paint || is_sculpt)
- let panelx = App.x() - UIToolbar.inst.toolbarw;
+ let panelx = App.x() - UIToolbar.toolbarw;
///end
///if is_lab
let panelx = App.x();
///end
- if (ui.window(this.menuHandle, panelx, 0, this.menubarw, UIHeader.headerh)) {
+ if (ui.window(UIMenubar.menuHandle, panelx, 0, UIMenubar.menubarw, UIHeader.headerh)) {
ui._x += 1; // Prevent "File" button highlight on startup
ui.beginMenu();
@@ -34,7 +32,7 @@ class UIMenubar {
if (Config.raw.touch_ui) {
///if (is_paint || is_sculpt)
- ui._w = UIToolbar.inst.toolbarw;
+ ui._w = UIToolbar.toolbarw;
///end
///if is_lab
ui._w = 36;
@@ -56,13 +54,13 @@ class UIMenubar {
///end
let size = Math.floor(ui._w / ui.SCALE());
if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuViewport) ui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL);
- if (UIMenubar.iconButton(ui, 8, 2)) this.showMenu(ui, MenuCategory.MenuViewport);
+ if (UIMenubar.iconButton(ui, 8, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuViewport);
if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuMode) ui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL);
- if (UIMenubar.iconButton(ui, 9, 2)) this.showMenu(ui, MenuCategory.MenuMode);
+ if (UIMenubar.iconButton(ui, 9, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuMode);
if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuCamera) ui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL);
- if (UIMenubar.iconButton(ui, 10, 2)) this.showMenu(ui, MenuCategory.MenuCamera);
+ if (UIMenubar.iconButton(ui, 10, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuCamera);
if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuHelp) ui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL);
- if (UIMenubar.iconButton(ui, 11, 2)) this.showMenu(ui, MenuCategory.MenuHelp);
+ if (UIMenubar.iconButton(ui, 11, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuHelp);
ui.enabled = History.undos > 0;
if (UIMenubar.iconButton(ui, 6, 2)) History.undo();
ui.enabled = History.redos > 0;
@@ -73,49 +71,49 @@ class UIMenubar {
let categories = [tr("File"), tr("Edit"), tr("Viewport"), tr("Mode"), tr("Camera"), tr("Help")];
for (let i = 0; i < categories.length; ++i) {
if (ui.menuButton(categories[i]) || (UIMenu.show && UIMenu.menuCommands == null && ui.isHovered)) {
- this.showMenu(ui, i);
+ UIMenubar.showMenu(ui, i);
}
}
}
- if (this.menubarw < ui._x + 10) {
- this.menubarw = Math.floor(ui._x + 10);
+ if (UIMenubar.menubarw < ui._x + 10) {
+ UIMenubar.menubarw = Math.floor(ui._x + 10);
///if (is_paint || is_sculpt)
- UIToolbar.inst.toolbarHandle.redraws = 2;
+ UIToolbar.toolbarHandle.redraws = 2;
///end
}
ui.endMenu();
}
- let nodesw = (UINodes.inst.show || UIView2D.inst.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0;
+ let nodesw = (UINodes.show || UIView2D.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0;
///if (is_paint || is_sculpt)
- let ww = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - this.menubarw - nodesw;
- panelx = (App.x() - UIToolbar.inst.toolbarw) + this.menubarw;
+ let ww = System.width - Config.raw.layout[LayoutSize.LayoutSidebarW] - UIMenubar.menubarw - nodesw;
+ panelx = (App.x() - UIToolbar.toolbarw) + UIMenubar.menubarw;
///else
- let ww = System.width - this.menubarw - nodesw;
- panelx = (App.x()) + this.menubarw;
+ let ww = System.width - UIMenubar.menubarw - nodesw;
+ panelx = (App.x()) + UIMenubar.menubarw;
///end
- if (ui.window(this.workspaceHandle, panelx, 0, ww, UIHeader.headerh)) {
+ if (ui.window(UIMenubar.workspaceHandle, panelx, 0, ww, UIHeader.headerh)) {
if (!Config.raw.touch_ui) {
- ui.tab(UIHeader.inst.worktab, tr("3D View"));
+ ui.tab(UIHeader.worktab, tr("3D View"));
}
else {
ui.fill(0, 0, ui._windowW, ui._windowH + 4, ui.t.SEPARATOR_COL);
}
///if is_lab
- ui.tab(UIHeader.inst.worktab, tr("2D View"));
- if (UIHeader.inst.worktab.changed) {
+ ui.tab(UIHeader.worktab, tr("2D View"));
+ if (UIHeader.worktab.changed) {
Context.raw.ddirty = 2;
Context.raw.brushBlendDirty = true;
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
Context.mainObject().skip_context = null;
- if (UIHeader.inst.worktab.position == SpaceType.Space3D) {
+ if (UIHeader.worktab.position == SpaceType.Space3D) {
if (UIMenubar._savedCamera != null) {
Scene.active.camera.transform.setMatrix(UIMenubar._savedCamera);
UIMenubar._savedCamera = null;
@@ -124,7 +122,7 @@ class UIMenubar {
}
else { // Space2D
if (UIMenubar._plane == null) {
- let mesh: any = new GeomPlane(1, 1, 2, 2);
+ let mesh: any = Geom.make_plane(1, 1, 2, 2);
let raw = {
name: "2DView",
vertex_arrays: [
@@ -160,7 +158,7 @@ class UIMenubar {
}
}
- showMenu = (ui: Zui, category: i32) => {
+ static showMenu = (ui: Zui, category: i32) => {
UIMenu.show = true;
UIMenu.menuCommands = null;
UIMenu.menuCategory = category;
diff --git a/base/Sources/UINodes.ts b/base/Sources/UINodes.ts
index 0eb51c83..9794321e 100644
--- a/base/Sources/UINodes.ts
+++ b/base/Sources/UINodes.ts
@@ -1,76 +1,72 @@
class UINodes {
- static inst: UINodes;
-
///if (is_paint || is_sculpt)
- show = false;
+ static show = false;
///end
///if is_lab
- show = true;
+ static show = true;
///end
- wx: i32;
- wy: i32;
- ww: i32;
- wh: i32;
+ static wx: i32;
+ static wy: i32;
+ static ww: i32;
+ static wh: i32;
- ui: Zui;
- canvasType = CanvasType.CanvasMaterial;
- showMenu = false;
- showMenuFirst = true;
- hideMenu = false;
- menuCategory = 0;
- popupX = 0.0;
- popupY = 0.0;
+ static ui: Zui;
+ static canvasType = CanvasType.CanvasMaterial;
+ static showMenu = false;
+ static showMenuFirst = true;
+ static hideMenu = false;
+ static menuCategory = 0;
+ static popupX = 0.0;
+ static popupY = 0.0;
- uichangedLast = false;
- recompileMat = false; // Mat preview
- recompileMatFinal = false;
- nodeSearchSpawn: TNode = null;
- nodeSearchOffset = 0;
- lastCanvas: TNodeCanvas = null;
- lastNodeSelectedId = -1;
- releaseLink = false;
- isNodeMenuOperation = false;
+ static uichangedLast = false;
+ static recompileMat = false; // Mat preview
+ static recompileMatFinal = false;
+ static nodeSearchSpawn: TNode = null;
+ static nodeSearchOffset = 0;
+ static lastCanvas: TNodeCanvas = null;
+ static lastNodeSelectedId = -1;
+ static releaseLink = false;
+ static isNodeMenuOperation = false;
- grid: Image = null;
- hwnd = new Handle();
- groupStack: TNodeGroup[] = [];
- controlsDown = false;
+ static grid: Image = null;
+ static hwnd = new Handle();
+ static groupStack: TNodeGroup[] = [];
+ static controlsDown = false;
constructor() {
- UINodes.inst = this;
-
- Nodes.onLinkDrag = this.onLinkDrag;
- Nodes.onSocketReleased = this.onSocketReleased;
- Nodes.onCanvasReleased = this.onCanvasReleased;
- // Nodes.onNodeRemove = this.onNodeRemove;
- Nodes.onCanvasControl = this.onCanvasControl;
+ Nodes.onLinkDrag = UINodes.onLinkDrag;
+ Nodes.onSocketReleased = UINodes.onSocketReleased;
+ Nodes.onCanvasReleased = UINodes.onCanvasReleased;
+ // Nodes.onNodeRemove = UINodes.onNodeRemove;
+ Nodes.onCanvasControl = UINodes.onCanvasControl;
let scale = Config.raw.window_scale;
- this.ui = new Zui({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale });
- this.ui.scrollEnabled = false;
+ UINodes.ui = new Zui({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale });
+ UINodes.ui.scrollEnabled = false;
}
- onLinkDrag = (linkDragId: i32, isNewLink: bool) => {
+ static onLinkDrag = (linkDragId: i32, isNewLink: bool) => {
if (isNewLink) {
- let nodes = this.getNodes();
- let linkDrag = nodes.getLink(this.getCanvas(true).links, linkDragId);
- let node = nodes.getNode(this.getCanvas(true).nodes, linkDrag.from_id > -1 ? linkDrag.from_id : linkDrag.to_id);
- let linkX = this.ui._windowX + nodes.NODE_X(node);
- let linkY = this.ui._windowY + nodes.NODE_Y(node);
+ let nodes = UINodes.getNodes();
+ let linkDrag = nodes.getLink(UINodes.getCanvas(true).links, linkDragId);
+ let node = nodes.getNode(UINodes.getCanvas(true).nodes, linkDrag.from_id > -1 ? linkDrag.from_id : linkDrag.to_id);
+ let linkX = UINodes.ui._windowX + nodes.NODE_X(node);
+ let linkY = UINodes.ui._windowY + nodes.NODE_Y(node);
if (linkDrag.from_id > -1) {
linkX += nodes.NODE_W(node);
linkY += nodes.OUTPUT_Y(node.outputs, linkDrag.from_socket);
}
else {
- linkY += nodes.INPUT_Y(this.getCanvas(true), node.inputs, linkDrag.to_socket) + nodes.OUTPUTS_H(node.outputs) + nodes.BUTTONS_H(node);
+ linkY += nodes.INPUT_Y(UINodes.getCanvas(true), node.inputs, linkDrag.to_socket) + nodes.OUTPUTS_H(node.outputs) + nodes.BUTTONS_H(node);
}
let mouse = Input.getMouse();
if (Math.abs(mouse.x - linkX) > 5 || Math.abs(mouse.y - linkY) > 5) { // Link length
- this.nodeSearch(-1, -1, () => {
- let n = nodes.getNode(this.getCanvas(true).nodes, nodes.nodesSelectedId[0]);
+ UINodes.nodeSearch(-1, -1, () => {
+ let n = nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]);
if (linkDrag.to_id == -1 && n.inputs.length > 0) {
linkDrag.to_id = n.id;
let fromType = node.outputs[linkDrag.from_socket].type;
@@ -83,15 +79,15 @@ class UINodes {
break;
}
}
- this.getCanvas(true).links.push(linkDrag);
+ UINodes.getCanvas(true).links.push(linkDrag);
}
else if (linkDrag.from_id == -1 && n.outputs.length > 0) {
linkDrag.from_id = n.id;
linkDrag.from_socket = 0;
- this.getCanvas(true).links.push(linkDrag);
+ UINodes.getCanvas(true).links.push(linkDrag);
}
///if is_lab
- ParserLogic.parse(this.getCanvas(true));
+ ParserLogic.parse(UINodes.getCanvas(true));
Context.raw.rdirty = 5;
///end
});
@@ -106,12 +102,12 @@ class UINodes {
}
}
- onSocketReleased = (socket_id: i32) => {
- let nodes = this.getNodes();
- let canvas = this.getCanvas(true);
+ static onSocketReleased = (socket_id: i32) => {
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let socket = nodes.getSocket(canvas.nodes, socket_id);
let node = nodes.getNode(canvas.nodes, socket.node_id);
- if (this.ui.inputReleasedR) {
+ if (UINodes.ui.inputReleasedR) {
if (node.type == "GROUP_INPUT" || node.type == "GROUP_OUTPUT") {
Base.notifyOnNextFrame(() => {
UIMenu.draw((ui: Zui) => {
@@ -174,7 +170,7 @@ class UINodes {
socket.default_value = default_value;
UIBox.hide();
NodesMaterial.syncSockets(node);
- this.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
}
}
}, 400, 250);
@@ -199,7 +195,7 @@ class UINodes {
}, 2);
});
}
- else this.onCanvasReleased();
+ else UINodes.onCanvasReleased();
}
// Selecting which node socket to preview
else if (node.id == nodes.nodesSelectedId[0]) {
@@ -213,14 +209,14 @@ class UINodes {
}
}
- onCanvasReleased = () => {
- if (this.ui.inputReleasedR && Math.abs(this.ui.inputX - this.ui.inputStartedX) < 2 && Math.abs(this.ui.inputY - this.ui.inputStartedY) < 2) {
+ static onCanvasReleased = () => {
+ if (UINodes.ui.inputReleasedR && Math.abs(UINodes.ui.inputX - UINodes.ui.inputStartedX) < 2 && Math.abs(UINodes.ui.inputY - UINodes.ui.inputStartedY) < 2) {
// Node selection
- let nodes = this.getNodes();
- let canvas = this.getCanvas(true);
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
let selected: TNode = null;
for (let node of canvas.nodes) {
- if (this.ui.getInputInRect(this.ui._windowX + nodes.NODE_X(node), this.ui._windowY + nodes.NODE_Y(node), nodes.NODE_W(node), nodes.NODE_H(canvas, node))) {
+ if (UINodes.ui.getInputInRect(UINodes.ui._windowX + nodes.NODE_X(node), UINodes.ui._windowY + nodes.NODE_Y(node), nodes.NODE_W(node), nodes.NODE_H(canvas, node))) {
selected = node;
break;
}
@@ -231,7 +227,7 @@ class UINodes {
// Node context menu
if (!Nodes.socketReleased) {
let numberOfEntries = 5;
- if (this.canvasType == CanvasType.CanvasMaterial) ++numberOfEntries;
+ if (UINodes.canvasType == CanvasType.CanvasMaterial) ++numberOfEntries;
if (selected != null && selected.type == "RGB") ++numberOfEntries;
UIMenu.draw((uiMenu: Zui) => {
@@ -246,40 +242,40 @@ class UINodes {
uiMenu.enabled = !isProtected;
if (UIMenu.menuButton(uiMenu, tr("Cut"), "ctrl+x")) {
Base.notifyOnNextFrame(() => {
- this.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
Zui.isCopy = true;
Zui.isCut = true;
- this.isNodeMenuOperation = true;
+ UINodes.isNodeMenuOperation = true;
});
}
if (UIMenu.menuButton(uiMenu, tr("Copy"), "ctrl+c")) {
Base.notifyOnNextFrame(() => {
Zui.isCopy = true;
- this.isNodeMenuOperation = true;
+ UINodes.isNodeMenuOperation = true;
});
}
uiMenu.enabled = Nodes.clipboard != "";
if (UIMenu.menuButton(uiMenu, tr("Paste"), "ctrl+v")) {
Base.notifyOnNextFrame(() => {
- this.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
Zui.isPaste = true;
- this.isNodeMenuOperation = true;
+ UINodes.isNodeMenuOperation = true;
});
}
uiMenu.enabled = !isProtected;
if (UIMenu.menuButton(uiMenu, tr("Delete"), "delete")) {
Base.notifyOnNextFrame(() => {
- this.hwnd.redraws = 2;
- this.ui.isDeleteDown = true;
- this.isNodeMenuOperation = true;
+ UINodes.hwnd.redraws = 2;
+ UINodes.ui.isDeleteDown = true;
+ UINodes.isNodeMenuOperation = true;
});
}
if (UIMenu.menuButton(uiMenu, tr("Duplicate"))) {
Base.notifyOnNextFrame(() => {
- this.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
Zui.isCopy = true;
Zui.isPaste = true;
- this.isNodeMenuOperation = true;
+ UINodes.isNodeMenuOperation = true;
});
}
if (selected != null && selected.type == "RGB") {
@@ -288,14 +284,14 @@ class UINodes {
let newSwatch = Project.makeSwatch(color_from_floats(color[0], color[1], color[2], color[3]));
Context.setSwatch(newSwatch);
Project.raw.swatches.push(newSwatch);
- UIBase.inst.hwnds[TabArea.TabStatus].redraws = 1;
+ UIBase.hwnds[TabArea.TabStatus].redraws = 1;
}
}
- if (this.canvasType == CanvasType.CanvasMaterial) {
+ if (UINodes.canvasType == CanvasType.CanvasMaterial) {
UIMenu.menuSeparator(uiMenu);
if (UIMenu.menuButton(uiMenu, tr("2D View"))) {
- UIBase.inst.show2DView(View2DType.View2DNode);
+ UIBase.show2DView(View2DType.View2DNode);
}
}
@@ -304,14 +300,14 @@ class UINodes {
}
}
- if (this.ui.inputReleased) {
- let nodes = this.getNodes();
- let canvas = this.getCanvas(true);
+ if (UINodes.ui.inputReleased) {
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
for (let node of canvas.nodes) {
- if (this.ui.getInputInRect(this.ui._windowX + nodes.NODE_X(node), this.ui._windowY + nodes.NODE_Y(node), nodes.NODE_W(node), nodes.NODE_H(canvas, node))) {
+ if (UINodes.ui.getInputInRect(UINodes.ui._windowX + nodes.NODE_X(node), UINodes.ui._windowY + nodes.NODE_Y(node), nodes.NODE_W(node), nodes.NODE_H(canvas, node))) {
if (node.id == nodes.nodesSelectedId[0]) {
- UIView2D.inst.hwnd.redraws = 2;
- if (Time.time() - Context.raw.selectTime < 0.25) UIBase.inst.show2DView(View2DType.View2DNode);
+ UIView2D.hwnd.redraws = 2;
+ if (Time.time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DNode);
Context.raw.selectTime = Time.time();
}
break;
@@ -345,8 +341,8 @@ class UINodes {
// }
// }
- onCanvasControl = (): CanvasControl => {
- return UINodes.getCanvasControl(this.ui, UINodes.inst);
+ static onCanvasControl = (): CanvasControl => {
+ return UINodes.getCanvasControl(UINodes.ui, UINodes);
}
static getCanvasControl = (ui: Zui, parent: any): CanvasControl => {
@@ -408,11 +404,11 @@ class UINodes {
-(ui.inputDY - ui.inputDX);
}
- getCanvas = (groups = false): TNodeCanvas => {
+ static getCanvas = (groups = false): TNodeCanvas => {
///if (is_paint || is_sculpt)
- if (this.canvasType == CanvasType.CanvasMaterial) {
- if (groups && this.groupStack.length > 0) return this.groupStack[this.groupStack.length - 1].canvas;
- else return this.getCanvasMaterial();
+ if (UINodes.canvasType == CanvasType.CanvasMaterial) {
+ if (groups && UINodes.groupStack.length > 0) return UINodes.groupStack[UINodes.groupStack.length - 1].canvas;
+ else return UINodes.getCanvasMaterial();
}
else return Context.raw.brush.canvas;
///end
@@ -423,72 +419,72 @@ class UINodes {
}
///if (is_paint || is_sculpt)
- getCanvasMaterial = (): TNodeCanvas => {
+ static getCanvasMaterial = (): TNodeCanvas => {
return Context.raw.material.canvas;
}
///end
- getNodes = (): Nodes => {
+ static getNodes = (): Nodes => {
///if (is_paint || is_sculpt)
- if (this.canvasType == CanvasType.CanvasMaterial) {
- if (this.groupStack.length > 0) return this.groupStack[this.groupStack.length - 1].nodes;
+ if (UINodes.canvasType == CanvasType.CanvasMaterial) {
+ if (UINodes.groupStack.length > 0) return UINodes.groupStack[UINodes.groupStack.length - 1].nodes;
else return Context.raw.material.nodes;
}
else return Context.raw.brush.nodes;
///end
///if is_lab
- if (this.groupStack.length > 0) return this.groupStack[this.groupStack.length - 1].nodes;
+ if (UINodes.groupStack.length > 0) return UINodes.groupStack[UINodes.groupStack.length - 1].nodes;
else return Project.nodes;
///end
}
- update = () => {
- if (!this.show || !Base.uiEnabled) return;
+ static update = () => {
+ if (!UINodes.show || !Base.uiEnabled) return;
let mouse = Input.getMouse();
let kb = Input.getKeyboard();
///if (is_paint || is_sculpt)
- this.wx = Math.floor(App.w()) + UIToolbar.inst.toolbarw;
+ UINodes.wx = Math.floor(App.w()) + UIToolbar.toolbarw;
///end
///if is_lab
- this.wx = Math.floor(App.w());
+ UINodes.wx = Math.floor(App.w());
///end
- this.wy = UIHeader.headerh * 2;
+ UINodes.wy = UIHeader.headerh * 2;
- if (UIView2D.inst.show) {
- this.wy += App.h() - Config.raw.layout[LayoutSize.LayoutNodesH];
+ if (UIView2D.show) {
+ UINodes.wy += App.h() - Config.raw.layout[LayoutSize.LayoutNodesH];
}
let ww = Config.raw.layout[LayoutSize.LayoutNodesW];
- if (!UIBase.inst.show) {
+ if (!UIBase.show) {
///if (is_paint || is_sculpt)
- ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.inst.toolbarw;
- this.wx -= UIToolbar.inst.toolbarw;
+ ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.toolbarw;
+ UINodes.wx -= UIToolbar.toolbarw;
///end
- this.wy = 0;
+ UINodes.wy = 0;
}
let mx = mouse.x;
let my = mouse.y;
- if (mx < this.wx || mx > this.wx + ww || my < this.wy) return;
- if (this.ui.isTyping || !this.ui.inputEnabled) return;
+ if (mx < UINodes.wx || mx > UINodes.wx + ww || my < UINodes.wy) return;
+ if (UINodes.ui.isTyping || !UINodes.ui.inputEnabled) return;
- let nodes = this.getNodes();
- if (nodes.nodesSelectedId.length > 0 && this.ui.isKeyPressed) {
- if (this.ui.key == KeyCode.Left) for (let n of nodes.nodesSelectedId) nodes.getNode(this.getCanvas(true).nodes, n).x -= 1;
- else if (this.ui.key == KeyCode.Right) for (let n of nodes.nodesSelectedId) nodes.getNode(this.getCanvas(true).nodes, n).x += 1;
- if (this.ui.key == KeyCode.Up) for (let n of nodes.nodesSelectedId) nodes.getNode(this.getCanvas(true).nodes, n).y -= 1;
- else if (this.ui.key == KeyCode.Down) for (let n of nodes.nodesSelectedId) nodes.getNode(this.getCanvas(true).nodes, n).y += 1;
+ let nodes = UINodes.getNodes();
+ if (nodes.nodesSelectedId.length > 0 && UINodes.ui.isKeyPressed) {
+ if (UINodes.ui.key == KeyCode.Left) for (let n of nodes.nodesSelectedId) nodes.getNode(UINodes.getCanvas(true).nodes, n).x -= 1;
+ else if (UINodes.ui.key == KeyCode.Right) for (let n of nodes.nodesSelectedId) nodes.getNode(UINodes.getCanvas(true).nodes, n).x += 1;
+ if (UINodes.ui.key == KeyCode.Up) for (let n of nodes.nodesSelectedId) nodes.getNode(UINodes.getCanvas(true).nodes, n).y -= 1;
+ else if (UINodes.ui.key == KeyCode.Down) for (let n of nodes.nodesSelectedId) nodes.getNode(UINodes.getCanvas(true).nodes, n).y += 1;
}
// Node search popup
- if (Operator.shortcut(Config.keymap.node_search)) this.nodeSearch();
- if (this.nodeSearchSpawn != null) {
- this.ui.inputX = mouse.x; // Fix inputDX after popup removal
- this.ui.inputY = mouse.y;
- this.nodeSearchSpawn = null;
+ if (Operator.shortcut(Config.keymap.node_search)) UINodes.nodeSearch();
+ if (UINodes.nodeSearchSpawn != null) {
+ UINodes.ui.inputX = mouse.x; // Fix inputDX after popup removal
+ UINodes.ui.inputY = mouse.y;
+ UINodes.nodeSearchSpawn = null;
}
if (Operator.shortcut(Config.keymap.view_reset)) {
@@ -498,12 +494,12 @@ class UINodes {
}
}
- canvasChanged = () => {
- this.recompileMat = true;
- this.recompileMatFinal = true;
+ static canvasChanged = () => {
+ UINodes.recompileMat = true;
+ UINodes.recompileMatFinal = true;
}
- nodeSearch = (x = -1, y = -1, done: ()=>void = null) => {
+ static nodeSearch = (x = -1, y = -1, done: ()=>void = null) => {
let kb = Input.getKeyboard();
let searchHandle = Zui.handle("uinodes_9");
let first = true;
@@ -520,18 +516,18 @@ class UINodes {
ui.startTextEdit(searchHandle); // Focus search bar
}
- if (searchHandle.changed) this.nodeSearchOffset = 0;
+ if (searchHandle.changed) UINodes.nodeSearchOffset = 0;
if (ui.isKeyPressed) { // Move selection
- if (ui.key == KeyCode.Down && this.nodeSearchOffset < 6) this.nodeSearchOffset++;
- if (ui.key == KeyCode.Up && this.nodeSearchOffset > 0) this.nodeSearchOffset--;
+ if (ui.key == KeyCode.Down && UINodes.nodeSearchOffset < 6) UINodes.nodeSearchOffset++;
+ if (ui.key == KeyCode.Up && UINodes.nodeSearchOffset > 0) UINodes.nodeSearchOffset--;
}
let enter = kb.down("enter");
let count = 0;
let BUTTON_COL = ui.t.BUTTON_COL;
///if (is_paint || is_sculpt)
- let nodeList = this.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
+ let nodeList = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
///end
///if is_lab
let nodeList = NodesBrush.list;
@@ -540,21 +536,21 @@ class UINodes {
for (let list of nodeList) {
for (let n of list) {
if (tr(n.name).toLowerCase().indexOf(search) >= 0) {
- ui.t.BUTTON_COL = count == this.nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL;
- if (ui.button(tr(n.name), Align.Left) || (enter && count == this.nodeSearchOffset)) {
- this.pushUndo();
- let nodes = this.getNodes();
- let canvas = this.getCanvas(true);
- this.nodeSearchSpawn = UINodes.makeNode(n, nodes, canvas); // Spawn selected node
- canvas.nodes.push(this.nodeSearchSpawn);
- nodes.nodesSelectedId = [this.nodeSearchSpawn.id];
+ ui.t.BUTTON_COL = count == UINodes.nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL;
+ if (ui.button(tr(n.name), Align.Left) || (enter && count == UINodes.nodeSearchOffset)) {
+ UINodes.pushUndo();
+ let nodes = UINodes.getNodes();
+ let canvas = UINodes.getCanvas(true);
+ UINodes.nodeSearchSpawn = UINodes.makeNode(n, nodes, canvas); // Spawn selected node
+ canvas.nodes.push(UINodes.nodeSearchSpawn);
+ nodes.nodesSelectedId = [UINodes.nodeSearchSpawn.id];
nodes.nodesDrag = true;
///if is_lab
ParserLogic.parse(canvas);
///end
- this.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
if (enter) {
ui.changed = true;
count = 6; // Trigger break
@@ -574,71 +570,71 @@ class UINodes {
}, 8, x, y);
}
- getNodeX = (): i32 => {
+ static getNodeX = (): i32 => {
let mouse = Input.getMouse();
- return Math.floor((mouse.x - this.wx - this.getNodes().PAN_X()) / this.getNodes().SCALE());
+ return Math.floor((mouse.x - UINodes.wx - UINodes.getNodes().PAN_X()) / UINodes.getNodes().SCALE());
}
- getNodeY = (): i32 => {
+ static getNodeY = (): i32 => {
let mouse = Input.getMouse();
- return Math.floor((mouse.y - this.wy - this.getNodes().PAN_Y()) / this.getNodes().SCALE());
+ return Math.floor((mouse.y - UINodes.wy - UINodes.getNodes().PAN_Y()) / UINodes.getNodes().SCALE());
}
- drawGrid = () => {
+ static drawGrid = () => {
let ww = Config.raw.layout[LayoutSize.LayoutNodesW];
///if (is_paint || is_sculpt)
- if (!UIBase.inst.show) {
- ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.inst.toolbarw;
+ if (!UIBase.show) {
+ ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.toolbarw;
}
///end
let wh = App.h();
- let step = 100 * this.ui.SCALE();
+ let step = 100 * UINodes.ui.SCALE();
let w = Math.floor(ww + step * 3);
let h = Math.floor(wh + step * 3);
if (w < 1) w = 1;
if (h < 1) h = 1;
- this.grid = Image.createRenderTarget(w, h);
- this.grid.g2.begin(true, this.ui.t.SEPARATOR_COL);
+ UINodes.grid = Image.createRenderTarget(w, h);
+ UINodes.grid.g2.begin(true, UINodes.ui.t.SEPARATOR_COL);
- this.grid.g2.color = this.ui.t.SEPARATOR_COL - 0x00050505;
- step = 20 * this.ui.SCALE();
+ UINodes.grid.g2.color = UINodes.ui.t.SEPARATOR_COL - 0x00050505;
+ step = 20 * UINodes.ui.SCALE();
for (let i = 0; i < Math.floor(h / step) + 1; ++i) {
- this.grid.g2.drawLine(0, i * step, w, i * step);
+ UINodes.grid.g2.drawLine(0, i * step, w, i * step);
}
for (let i = 0; i < Math.floor(w / step) + 1; ++i) {
- this.grid.g2.drawLine(i * step, 0, i * step, h);
+ UINodes.grid.g2.drawLine(i * step, 0, i * step, h);
}
- this.grid.g2.color = this.ui.t.SEPARATOR_COL - 0x00090909;
- step = 100 * this.ui.SCALE();
+ UINodes.grid.g2.color = UINodes.ui.t.SEPARATOR_COL - 0x00090909;
+ step = 100 * UINodes.ui.SCALE();
for (let i = 0; i < Math.floor(h / step) + 1; ++i) {
- this.grid.g2.drawLine(0, i * step, w, i * step);
+ UINodes.grid.g2.drawLine(0, i * step, w, i * step);
}
for (let i = 0; i < Math.floor(w / step) + 1; ++i) {
- this.grid.g2.drawLine(i * step, 0, i * step, h);
+ UINodes.grid.g2.drawLine(i * step, 0, i * step, h);
}
- this.grid.g2.end();
+ UINodes.grid.g2.end();
}
- render = (g: Graphics2) => {
- if (this.recompileMat) {
+ static render = (g: Graphics2) => {
+ if (UINodes.recompileMat) {
///if (is_paint || is_sculpt)
- if (this.canvasType == CanvasType.CanvasBrush) {
+ if (UINodes.canvasType == CanvasType.CanvasBrush) {
MakeMaterial.parseBrush();
UtilRender.makeBrushPreview();
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
}
else {
Base.isFillMaterial() ? Base.updateFillLayers() : UtilRender.makeMaterialPreview();
- if (UIView2D.inst.show && UIView2D.inst.type == View2DType.View2DNode) {
- UIView2D.inst.hwnd.redraws = 2;
+ if (UIView2D.show && UIView2D.type == View2DType.View2DNode) {
+ UIView2D.hwnd.redraws = 2;
}
}
- UIBase.inst.hwnds[TabArea.TabSidebar1].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
if (Context.raw.splitView) Context.raw.ddirty = 2;
///end
@@ -646,13 +642,13 @@ class UINodes {
ParserLogic.parse(Project.canvas);
///end
- this.recompileMat = false;
+ UINodes.recompileMat = false;
}
- else if (this.recompileMatFinal) {
+ else if (UINodes.recompileMatFinal) {
///if (is_paint || is_sculpt)
MakeMaterial.parsePaintMaterial();
- if (this.canvasType == CanvasType.CanvasMaterial && Base.isFillMaterial()) {
+ if (UINodes.canvasType == CanvasType.CanvasMaterial && Base.isFillMaterial()) {
Base.updateFillLayers();
UtilRender.makeMaterialPreview();
}
@@ -660,109 +656,109 @@ class UINodes {
let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
if (decal) UtilRender.makeDecalPreview();
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
Context.raw.nodePreviewDirty = true;
///end
- this.recompileMatFinal = false;
+ UINodes.recompileMatFinal = false;
}
- let nodes = this.getNodes();
- if (nodes.nodesSelectedId.length > 0 && nodes.nodesSelectedId[0] != this.lastNodeSelectedId) {
- this.lastNodeSelectedId = nodes.nodesSelectedId[0];
+ let nodes = UINodes.getNodes();
+ if (nodes.nodesSelectedId.length > 0 && nodes.nodesSelectedId[0] != UINodes.lastNodeSelectedId) {
+ UINodes.lastNodeSelectedId = nodes.nodesSelectedId[0];
///if (is_paint || is_sculpt)
Context.raw.nodePreviewDirty = true;
///end
///if is_lab
Context.raw.ddirty = 2; // Show selected node texture in viewport
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
///end
Context.raw.nodePreviewSocket = 0;
}
// Remove dragged link when mouse is released out of the node viewport
- let c = this.getCanvas(true);
- if (this.releaseLink && nodes.linkDragId != -1) {
+ let c = UINodes.getCanvas(true);
+ if (UINodes.releaseLink && nodes.linkDragId != -1) {
array_remove(c.links, nodes.getLink(c.links, nodes.linkDragId));
nodes.linkDragId = -1;
}
- this.releaseLink = this.ui.inputReleased;
+ UINodes.releaseLink = UINodes.ui.inputReleased;
- if (!this.show || System.width == 0 || System.height == 0) return;
+ if (!UINodes.show || System.width == 0 || System.height == 0) return;
- this.ui.inputEnabled = Base.uiEnabled;
+ UINodes.ui.inputEnabled = Base.uiEnabled;
g.end();
- if (this.grid == null) this.drawGrid();
+ if (UINodes.grid == null) UINodes.drawGrid();
///if (is_paint || is_sculpt)
if (Config.raw.node_preview && Context.raw.nodePreviewDirty) {
- this.makeNodePreview();
+ UINodes.makeNodePreview();
}
///end
// Start with UI
- this.ui.begin(g);
+ UINodes.ui.begin(g);
// Make window
- this.ww = Config.raw.layout[LayoutSize.LayoutNodesW];
+ UINodes.ww = Config.raw.layout[LayoutSize.LayoutNodesW];
///if (is_paint || is_sculpt)
- this.wx = Math.floor(App.w()) + UIToolbar.inst.toolbarw;
+ UINodes.wx = Math.floor(App.w()) + UIToolbar.toolbarw;
///end
///if is_lab
- this.wx = Math.floor(App.w());
+ UINodes.wx = Math.floor(App.w());
///end
- this.wy = 0;
+ UINodes.wy = 0;
///if (is_paint || is_sculpt)
- if (!UIBase.inst.show) {
- this.ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.inst.toolbarw;
- this.wx -= UIToolbar.inst.toolbarw;
+ if (!UIBase.show) {
+ UINodes.ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.toolbarw;
+ UINodes.wx -= UIToolbar.toolbarw;
}
///end
- let ew = Math.floor(this.ui.ELEMENT_W() * 0.7);
- this.wh = App.h() + UIHeader.headerh;
- if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) this.wh += UIHeader.headerh;
+ let ew = Math.floor(UINodes.ui.ELEMENT_W() * 0.7);
+ UINodes.wh = App.h() + UIHeader.headerh;
+ if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) UINodes.wh += UIHeader.headerh;
- if (UIView2D.inst.show) {
- this.wh = Config.raw.layout[LayoutSize.LayoutNodesH];
- this.wy = App.h() - Config.raw.layout[LayoutSize.LayoutNodesH] + UIHeader.headerh;
- if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) this.wy += UIHeader.headerh;
- if (!UIBase.inst.show) {
- this.wy -= UIHeader.headerh * 2;
+ if (UIView2D.show) {
+ UINodes.wh = Config.raw.layout[LayoutSize.LayoutNodesH];
+ UINodes.wy = App.h() - Config.raw.layout[LayoutSize.LayoutNodesH] + UIHeader.headerh;
+ if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) UINodes.wy += UIHeader.headerh;
+ if (!UIBase.show) {
+ UINodes.wy -= UIHeader.headerh * 2;
}
}
- if (this.ui.window(this.hwnd, this.wx, this.wy, this.ww, this.wh)) {
+ if (UINodes.ui.window(UINodes.hwnd, UINodes.wx, UINodes.wy, UINodes.ww, UINodes.wh)) {
- this.ui.tab(Zui.handle("uinodes_10"), tr("Nodes"));
+ UINodes.ui.tab(Zui.handle("uinodes_10"), tr("Nodes"));
// Grid
- this.ui.g.color = 0xffffffff;
- let step = 100 * this.ui.SCALE();
- this.ui.g.drawImage(this.grid, (nodes.panX * nodes.SCALE()) % step - step, (nodes.panY * nodes.SCALE()) % step - step);
+ UINodes.ui.g.color = 0xffffffff;
+ let step = 100 * UINodes.ui.SCALE();
+ UINodes.ui.g.drawImage(UINodes.grid, (nodes.panX * nodes.SCALE()) % step - step, (nodes.panY * nodes.SCALE()) % step - step);
// Undo
- if (this.ui.inputStarted || this.ui.isKeyPressed) {
- this.lastCanvas = JSON.parse(JSON.stringify(this.getCanvas(true)));
+ if (UINodes.ui.inputStarted || UINodes.ui.isKeyPressed) {
+ UINodes.lastCanvas = JSON.parse(JSON.stringify(UINodes.getCanvas(true)));
}
// Nodes
- let _inputEnabled = this.ui.inputEnabled;
- this.ui.inputEnabled = _inputEnabled && !this.showMenu;
+ let _inputEnabled = UINodes.ui.inputEnabled;
+ UINodes.ui.inputEnabled = _inputEnabled && !UINodes.showMenu;
///if (is_paint || is_sculpt)
- this.ui.windowBorderRight = Config.raw.layout[LayoutSize.LayoutSidebarW];
+ UINodes.ui.windowBorderRight = Config.raw.layout[LayoutSize.LayoutSidebarW];
///end
- this.ui.windowBorderTop = UIHeader.headerh * 2;
- this.ui.windowBorderBottom = Config.raw.layout[LayoutSize.LayoutStatusH];
- nodes.nodeCanvas(this.ui, c);
- this.ui.inputEnabled = _inputEnabled;
+ UINodes.ui.windowBorderTop = UIHeader.headerh * 2;
+ UINodes.ui.windowBorderBottom = Config.raw.layout[LayoutSize.LayoutStatusH];
+ nodes.nodeCanvas(UINodes.ui, c);
+ UINodes.ui.inputEnabled = _inputEnabled;
if (nodes.colorPickerCallback != null) {
Context.raw.colorPickerPreviousTool = Context.raw.tool;
@@ -770,7 +766,7 @@ class UINodes {
let tmp = nodes.colorPickerCallback;
Context.raw.colorPickerCallback = (color: TSwatchColor) => {
tmp(color.base);
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
///if (is_paint || is_sculpt)
let material_live = Config.raw.material_live;
@@ -780,7 +776,7 @@ class UINodes {
///end
if (material_live) {
- UINodes.inst.canvasChanged();
+ UINodes.canvasChanged();
}
};
nodes.colorPickerCallback = null;
@@ -789,7 +785,7 @@ class UINodes {
// Remove nodes with unknown id for this canvas type
if (Zui.isPaste) {
///if (is_paint || is_sculpt)
- let nodeList = this.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
+ let nodeList = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
///end
///if is_lab
let nodeList = NodesBrush.list;
@@ -811,7 +807,7 @@ class UINodes {
}
if (found) break;
}
- if (canvasNode.type == "GROUP" && !this.canPlaceGroup(canvasNode.name)) {
+ if (canvasNode.type == "GROUP" && !UINodes.canPlaceGroup(canvasNode.name)) {
found = false;
}
if (!found) {
@@ -822,24 +818,24 @@ class UINodes {
}
}
- if (this.isNodeMenuOperation) {
- Zui.isCopy = Zui.isCut = Zui.isPaste = this.ui.isDeleteDown = false;
+ if (UINodes.isNodeMenuOperation) {
+ Zui.isCopy = Zui.isCut = Zui.isPaste = UINodes.ui.isDeleteDown = false;
}
// Recompile material on change
- if (this.ui.changed) {
+ if (UINodes.ui.changed) {
///if (is_paint || is_sculpt)
- this.recompileMat = (this.ui.inputDX != 0 || this.ui.inputDY != 0 || !this.uichangedLast) && Config.raw.material_live; // Instant preview
+ UINodes.recompileMat = (UINodes.ui.inputDX != 0 || UINodes.ui.inputDY != 0 || !UINodes.uichangedLast) && Config.raw.material_live; // Instant preview
///end
///if is_lab
- this.recompileMat = (this.ui.inputDX != 0 || this.ui.inputDY != 0 || !this.uichangedLast); // Instant preview
+ UINodes.recompileMat = (UINodes.ui.inputDX != 0 || UINodes.ui.inputDY != 0 || !UINodes.uichangedLast); // Instant preview
///end
}
- else if (this.uichangedLast) {
- this.canvasChanged();
- this.pushUndo(this.lastCanvas);
+ else if (UINodes.uichangedLast) {
+ UINodes.canvasChanged();
+ UINodes.pushUndo(UINodes.lastCanvas);
}
- this.uichangedLast = this.ui.changed;
+ UINodes.uichangedLast = UINodes.ui.changed;
// Node previews
if (Config.raw.node_preview && nodes.nodesSelectedId.length > 0) {
@@ -869,7 +865,7 @@ class UINodes {
else if (sel.type == "BrushOutputNode") {
img = Context.raw.brush.image;
}
- else if (this.canvasType == CanvasType.CanvasMaterial) {
+ else if (UINodes.canvasType == CanvasType.CanvasMaterial) {
img = Context.raw.nodePreview;
}
@@ -883,10 +879,10 @@ class UINodes {
///end
if (img != null) {
- let tw = 128 * this.ui.SCALE();
+ let tw = 128 * UINodes.ui.SCALE();
let th = tw * (img.height / img.width);
- let tx = this.ww - tw - 8 * this.ui.SCALE();
- let ty = this.wh - th - 8 * this.ui.SCALE();
+ let tx = UINodes.ww - tw - 8 * UINodes.ui.SCALE();
+ let ty = UINodes.wh - th - 8 * UINodes.ui.SCALE();
///if krom_opengl
let invertY = sel.type == "MATERIAL";
@@ -896,7 +892,7 @@ class UINodes {
///if (is_paint || is_sculpt)
if (singleChannel) {
- this.ui.g.pipeline = UIView2D.pipe;
+ UINodes.ui.g.pipeline = UIView2D.pipe;
///if krom_opengl
Krom.setPipeline(UIView2D.pipe.pipeline_);
///end
@@ -904,41 +900,41 @@ class UINodes {
}
///end
- this.ui.g.color = 0xffffffff;
+ UINodes.ui.g.color = 0xffffffff;
invertY ?
- this.ui.g.drawScaledImage(img, tx, ty + th, tw, -th) :
- this.ui.g.drawScaledImage(img, tx, ty, tw, th);
+ UINodes.ui.g.drawScaledImage(img, tx, ty + th, tw, -th) :
+ UINodes.ui.g.drawScaledImage(img, tx, ty, tw, th);
///if (is_paint || is_sculpt)
if (singleChannel) {
- this.ui.g.pipeline = null;
+ UINodes.ui.g.pipeline = null;
}
///end
}
}
// Menu
- this.ui.g.color = this.ui.t.SEPARATOR_COL;
- this.ui.g.fillRect(0, this.ui.ELEMENT_H(), this.ww, this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET() * 2);
- this.ui.g.color = 0xffffffff;
+ UINodes.ui.g.color = UINodes.ui.t.SEPARATOR_COL;
+ UINodes.ui.g.fillRect(0, UINodes.ui.ELEMENT_H(), UINodes.ww, UINodes.ui.ELEMENT_H() + UINodes.ui.ELEMENT_OFFSET() * 2);
+ UINodes.ui.g.color = 0xffffffff;
- let startY = this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET();
- this.ui._x = 0;
- this.ui._y = 2 + startY;
- this.ui._w = ew;
+ let startY = UINodes.ui.ELEMENT_H() + UINodes.ui.ELEMENT_OFFSET();
+ UINodes.ui._x = 0;
+ UINodes.ui._y = 2 + startY;
+ UINodes.ui._w = ew;
///if (is_paint || is_sculpt)
// Editable canvas name
let h = Zui.handle("uinodes_11");
h.text = c.name;
- this.ui._w = Math.floor(Math.min(this.ui.font.width(this.ui.fontSize, h.text) + 15 * this.ui.SCALE(), 100 * this.ui.SCALE()));
- let newName = this.ui.textInput(h, "");
- this.ui._x += this.ui._w + 3;
- this.ui._y = 2 + startY;
- this.ui._w = ew;
+ UINodes.ui._w = Math.floor(Math.min(UINodes.ui.font.width(UINodes.ui.fontSize, h.text) + 15 * UINodes.ui.SCALE(), 100 * UINodes.ui.SCALE()));
+ let newName = UINodes.ui.textInput(h, "");
+ UINodes.ui._x += UINodes.ui._w + 3;
+ UINodes.ui._y = 2 + startY;
+ UINodes.ui._w = ew;
if (h.changed) { // Check whether renaming is possible and update group links
- if (this.groupStack.length > 0) {
+ if (UINodes.groupStack.length > 0) {
let canRename = true;
for (let m of Project.materialGroups) {
if (m.canvas.name == newName) canRename = false; // Name already used
@@ -966,107 +962,107 @@ class UINodes {
///end
///if is_lab
- this.ui.windowBorderTop = 0;
+ UINodes.ui.windowBorderTop = 0;
UINodesExt.drawButtons(ew, startY);
///end
- let _BUTTON_COL = this.ui.t.BUTTON_COL;
- this.ui.t.BUTTON_COL = this.ui.t.SEPARATOR_COL;
+ let _BUTTON_COL = UINodes.ui.t.BUTTON_COL;
+ UINodes.ui.t.BUTTON_COL = UINodes.ui.t.SEPARATOR_COL;
///if (is_paint || is_sculpt)
- let cats = this.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.categories : NodesBrush.categories;
+ let cats = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.categories : NodesBrush.categories;
///end
///if is_lab
let cats = NodesBrush.categories;
///end
for (let i = 0; i < cats.length; ++i) {
- if ((this.ui.menuButton(tr(cats[i]))) || (this.ui.isHovered && this.showMenu)) {
- this.showMenu = true;
- this.menuCategory = i;
- this.popupX = this.wx + this.ui._x;
- this.popupY = this.wy + this.ui._y;
+ if ((UINodes.ui.menuButton(tr(cats[i]))) || (UINodes.ui.isHovered && UINodes.showMenu)) {
+ UINodes.showMenu = true;
+ UINodes.menuCategory = i;
+ UINodes.popupX = UINodes.wx + UINodes.ui._x;
+ UINodes.popupY = UINodes.wy + UINodes.ui._y;
if (Config.raw.touch_ui) {
- this.showMenuFirst = true;
+ UINodes.showMenuFirst = true;
let menuw = Math.floor(ew * 2.3);
- this.popupX -= menuw / 2;
- this.popupX += this.ui._w / 2;
+ UINodes.popupX -= menuw / 2;
+ UINodes.popupX += UINodes.ui._w / 2;
}
- UIMenu.menuCategoryW = this.ui._w;
- UIMenu.menuCategoryH = Math.floor(this.ui.MENUBAR_H());
+ UIMenu.menuCategoryW = UINodes.ui._w;
+ UIMenu.menuCategoryH = Math.floor(UINodes.ui.MENUBAR_H());
}
- this.ui._x += this.ui._w + 3;
- this.ui._y = 2 + startY;
+ UINodes.ui._x += UINodes.ui._w + 3;
+ UINodes.ui._y = 2 + startY;
}
if (Config.raw.touch_ui) {
- let _w = this.ui._w;
- this.ui._w = Math.floor(36 * this.ui.SCALE());
- this.ui._y = 4 * this.ui.SCALE() + startY;
- if (UIMenubar.iconButton(this.ui, 2, 3)) {
- this.nodeSearch(Math.floor(this.ui._windowX + this.ui._x), Math.floor(this.ui._windowY + this.ui._y));
+ let _w = UINodes.ui._w;
+ UINodes.ui._w = Math.floor(36 * UINodes.ui.SCALE());
+ UINodes.ui._y = 4 * UINodes.ui.SCALE() + startY;
+ if (UIMenubar.iconButton(UINodes.ui, 2, 3)) {
+ UINodes.nodeSearch(Math.floor(UINodes.ui._windowX + UINodes.ui._x), Math.floor(UINodes.ui._windowY + UINodes.ui._y));
}
- this.ui._w = _w;
+ UINodes.ui._w = _w;
}
else {
- if (this.ui.menuButton(tr("Search"))) {
- this.nodeSearch(Math.floor(this.ui._windowX + this.ui._x), Math.floor(this.ui._windowY + this.ui._y));
+ if (UINodes.ui.menuButton(tr("Search"))) {
+ UINodes.nodeSearch(Math.floor(UINodes.ui._windowX + UINodes.ui._x), Math.floor(UINodes.ui._windowY + UINodes.ui._y));
}
}
- if (this.ui.isHovered) {
- this.ui.tooltip(tr("Search for nodes") + ` (${Config.keymap.node_search})`);
+ if (UINodes.ui.isHovered) {
+ UINodes.ui.tooltip(tr("Search for nodes") + ` (${Config.keymap.node_search})`);
}
- this.ui._x += this.ui._w + 3;
- this.ui._y = 2 + startY;
+ UINodes.ui._x += UINodes.ui._w + 3;
+ UINodes.ui._y = 2 + startY;
- this.ui.t.BUTTON_COL = _BUTTON_COL;
+ UINodes.ui.t.BUTTON_COL = _BUTTON_COL;
// Close node group
- if (this.groupStack.length > 0 && this.ui.menuButton(tr("Close"))) {
- this.groupStack.pop();
+ if (UINodes.groupStack.length > 0 && UINodes.ui.menuButton(tr("Close"))) {
+ UINodes.groupStack.pop();
}
}
- this.ui.end(!this.showMenu);
+ UINodes.ui.end(!UINodes.showMenu);
g.begin(false);
- if (this.showMenu) {
+ if (UINodes.showMenu) {
///if (is_paint || is_sculpt)
- let list = this.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
+ let list = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list;
///end
///if is_lab
let list = NodesBrush.list;
///end
- let numNodes = list[this.menuCategory].length;
+ let numNodes = list[UINodes.menuCategory].length;
///if (is_paint || is_sculpt)
- let isGroupCategory = this.canvasType == CanvasType.CanvasMaterial && NodesMaterial.categories[this.menuCategory] == "Group";
+ let isGroupCategory = UINodes.canvasType == CanvasType.CanvasMaterial && NodesMaterial.categories[UINodes.menuCategory] == "Group";
///end
///if is_lab
- let isGroupCategory = NodesMaterial.categories[this.menuCategory] == "Group";
+ let isGroupCategory = NodesMaterial.categories[UINodes.menuCategory] == "Group";
///end
if (isGroupCategory) numNodes += Project.materialGroups.length;
- let py = this.popupY;
+ let py = UINodes.popupY;
let menuw = Math.floor(ew * 2.3);
- this.ui.beginRegion(g, Math.floor(this.popupX), Math.floor(py), menuw);
- let _BUTTON_COL = this.ui.t.BUTTON_COL;
- this.ui.t.BUTTON_COL = this.ui.t.SEPARATOR_COL;
- let _ELEMENT_OFFSET = this.ui.t.ELEMENT_OFFSET;
- this.ui.t.ELEMENT_OFFSET = 0;
- let _ELEMENT_H = this.ui.t.ELEMENT_H;
- this.ui.t.ELEMENT_H = Config.raw.touch_ui ? (28 + 2) : 28;
+ UINodes.ui.beginRegion(g, Math.floor(UINodes.popupX), Math.floor(py), menuw);
+ let _BUTTON_COL = UINodes.ui.t.BUTTON_COL;
+ UINodes.ui.t.BUTTON_COL = UINodes.ui.t.SEPARATOR_COL;
+ let _ELEMENT_OFFSET = UINodes.ui.t.ELEMENT_OFFSET;
+ UINodes.ui.t.ELEMENT_OFFSET = 0;
+ let _ELEMENT_H = UINodes.ui.t.ELEMENT_H;
+ UINodes.ui.t.ELEMENT_H = Config.raw.touch_ui ? (28 + 2) : 28;
- UIMenu.menuStart(this.ui);
+ UIMenu.menuStart(UINodes.ui);
- for (let n of list[this.menuCategory]) {
- if (UIMenu.menuButton(this.ui, tr(n.name))) {
- this.pushUndo();
- let canvas = this.getCanvas(true);
- let nodes = this.getNodes();
+ for (let n of list[UINodes.menuCategory]) {
+ if (UIMenu.menuButton(UINodes.ui, tr(n.name))) {
+ UINodes.pushUndo();
+ let canvas = UINodes.getCanvas(true);
+ let nodes = UINodes.getNodes();
let node = UINodes.makeNode(n, nodes, canvas);
canvas.nodes.push(node);
nodes.nodesSelectedId = [node.id];
@@ -1076,22 +1072,22 @@ class UINodes {
///end
}
// Next column
- if (this.ui._y - this.wy + this.ui.ELEMENT_H() / 2 > this.wh) {
- this.ui._x += menuw;
- this.ui._y = py;
+ if (UINodes.ui._y - UINodes.wy + UINodes.ui.ELEMENT_H() / 2 > UINodes.wh) {
+ UINodes.ui._x += menuw;
+ UINodes.ui._y = py;
}
}
if (isGroupCategory) {
for (let g of Project.materialGroups) {
- this.ui.fill(0, 1, this.ui._w / this.ui.SCALE(), this.ui.t.BUTTON_H + 2, this.ui.t.ACCENT_SELECT_COL);
- this.ui.fill(1, 1, this.ui._w / this.ui.SCALE() - 2, this.ui.t.BUTTON_H + 1, this.ui.t.SEPARATOR_COL);
- this.ui.enabled = this.canPlaceGroup(g.canvas.name);
- UIMenu.menuFill(this.ui);
- this.ui.row([5 / 6, 1 / 6]);
- if (this.ui.button(Config.buttonSpacing + g.canvas.name, Align.Left)) {
- this.pushUndo();
- let canvas = this.getCanvas(true);
- let nodes = this.getNodes();
+ UINodes.ui.fill(0, 1, UINodes.ui._w / UINodes.ui.SCALE(), UINodes.ui.t.BUTTON_H + 2, UINodes.ui.t.ACCENT_SELECT_COL);
+ UINodes.ui.fill(1, 1, UINodes.ui._w / UINodes.ui.SCALE() - 2, UINodes.ui.t.BUTTON_H + 1, UINodes.ui.t.SEPARATOR_COL);
+ UINodes.ui.enabled = UINodes.canPlaceGroup(g.canvas.name);
+ UIMenu.menuFill(UINodes.ui);
+ UINodes.ui.row([5 / 6, 1 / 6]);
+ if (UINodes.ui.button(Config.buttonSpacing + g.canvas.name, Align.Left)) {
+ UINodes.pushUndo();
+ let canvas = UINodes.getCanvas(true);
+ let nodes = UINodes.getNodes();
let node = UINodes.makeGroupNode(g.canvas, nodes, canvas);
canvas.nodes.push(node);
nodes.nodesSelectedId = [node.id];
@@ -1099,40 +1095,40 @@ class UINodes {
}
///if (is_paint || is_sculpt)
- this.ui.enabled = !Project.isMaterialGroupInUse(g);
- if (this.ui.button("x", Align.Center)) {
+ UINodes.ui.enabled = !Project.isMaterialGroupInUse(g);
+ if (UINodes.ui.button("x", Align.Center)) {
History.deleteMaterialGroup(g);
array_remove(Project.materialGroups, g);
}
///end
- this.ui.enabled = true;
+ UINodes.ui.enabled = true;
}
}
- this.hideMenu = this.ui.comboSelectedHandle_ptr == null && !this.showMenuFirst && (this.ui.changed || this.ui.inputReleased || this.ui.inputReleasedR || this.ui.isEscapeDown);
- this.showMenuFirst = false;
+ UINodes.hideMenu = UINodes.ui.comboSelectedHandle_ptr == null && !UINodes.showMenuFirst && (UINodes.ui.changed || UINodes.ui.inputReleased || UINodes.ui.inputReleasedR || UINodes.ui.isEscapeDown);
+ UINodes.showMenuFirst = false;
- this.ui.t.BUTTON_COL = _BUTTON_COL;
- this.ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET;
- this.ui.t.ELEMENT_H = _ELEMENT_H;
- this.ui.endRegion();
+ UINodes.ui.t.BUTTON_COL = _BUTTON_COL;
+ UINodes.ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET;
+ UINodes.ui.t.ELEMENT_H = _ELEMENT_H;
+ UINodes.ui.endRegion();
}
- if (this.hideMenu) {
- this.showMenu = false;
- this.showMenuFirst = true;
+ if (UINodes.hideMenu) {
+ UINodes.showMenu = false;
+ UINodes.showMenuFirst = true;
}
}
- containsNodeGroupRecursive = (group: TNodeGroup, groupName: string): bool => {
+ static containsNodeGroupRecursive = (group: TNodeGroup, groupName: string): bool => {
if (group.canvas.name == groupName) {
return true;
}
for (let n of group.canvas.nodes) {
if (n.type == "GROUP") {
let g = Project.getMaterialGroupByName(n.name);
- if (g != null && this.containsNodeGroupRecursive(g, groupName)) {
+ if (g != null && UINodes.containsNodeGroupRecursive(g, groupName)) {
return true;
}
}
@@ -1140,12 +1136,12 @@ class UINodes {
return false;
}
- canPlaceGroup = (groupName: string): bool => {
+ static canPlaceGroup = (groupName: string): bool => {
// Prevent Recursive node groups
// The group to place must not contain the current group or a group that contains the current group
- if (this.groupStack.length > 0) {
- for (let g of this.groupStack) {
- if (this.containsNodeGroupRecursive(Project.getMaterialGroupByName(groupName), g.canvas.name)) return false;
+ if (UINodes.groupStack.length > 0) {
+ for (let g of UINodes.groupStack) {
+ if (UINodes.containsNodeGroupRecursive(Project.getMaterialGroupByName(groupName), g.canvas.name)) return false;
}
}
// Group was deleted / renamed
@@ -1159,31 +1155,31 @@ class UINodes {
return true;
}
- pushUndo = (lastCanvas: TNodeCanvas = null) => {
- if (lastCanvas == null) lastCanvas = this.getCanvas(true);
- let canvasGroup = this.groupStack.length > 0 ? Project.materialGroups.indexOf(this.groupStack[this.groupStack.length - 1]) : null;
+ static pushUndo = (lastCanvas: TNodeCanvas = null) => {
+ if (lastCanvas == null) lastCanvas = UINodes.getCanvas(true);
+ let canvasGroup = UINodes.groupStack.length > 0 ? Project.materialGroups.indexOf(UINodes.groupStack[UINodes.groupStack.length - 1]) : null;
///if (is_paint || is_sculpt)
- UIBase.inst.hwnds[TabArea.TabSidebar0].redraws = 2;
- History.editNodes(lastCanvas, this.canvasType, canvasGroup);
+ UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+ History.editNodes(lastCanvas, UINodes.canvasType, canvasGroup);
///end
///if is_lab
History.editNodes(lastCanvas, canvasGroup);
///end
}
- acceptAssetDrag = (index: i32) => {
- this.pushUndo();
- let g = this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null;
+ static acceptAssetDrag = (index: i32) => {
+ UINodes.pushUndo();
+ let g = UINodes.groupStack.length > 0 ? UINodes.groupStack[UINodes.groupStack.length - 1] : null;
///if (is_paint || is_sculpt)
- let n = this.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.createNode("TEX_IMAGE", g) : NodesBrush.createNode("TEX_IMAGE");
+ let n = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.createNode("TEX_IMAGE", g) : NodesBrush.createNode("TEX_IMAGE");
///end
///if is_lab
let n = NodesBrush.createNode("ImageTextureNode");
///end
n.buttons[0].default_value = index;
- this.getNodes().nodesSelectedId = [n.id];
+ UINodes.getNodes().nodesSelectedId = [n.id];
///if is_lab
ParserLogic.parse(Project.canvas);
@@ -1191,28 +1187,28 @@ class UINodes {
}
///if (is_paint || is_sculpt)
- acceptLayerDrag = (index: i32) => {
- this.pushUndo();
+ static acceptLayerDrag = (index: i32) => {
+ UINodes.pushUndo();
if (Project.layers[index].isGroup()) return;
- let g = this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null;
+ let g = UINodes.groupStack.length > 0 ? UINodes.groupStack[UINodes.groupStack.length - 1] : null;
let n = NodesMaterial.createNode(Context.raw.layer.isMask() ? "LAYER_MASK" : "LAYER", g);
n.buttons[0].default_value = index;
- this.getNodes().nodesSelectedId = [n.id];
+ UINodes.getNodes().nodesSelectedId = [n.id];
}
- acceptMaterialDrag = (index: i32) => {
- this.pushUndo();
- let g = this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null;
+ static acceptMaterialDrag = (index: i32) => {
+ UINodes.pushUndo();
+ let g = UINodes.groupStack.length > 0 ? UINodes.groupStack[UINodes.groupStack.length - 1] : null;
let n = NodesMaterial.createNode("MATERIAL", g);
n.buttons[0].default_value = index;
- this.getNodes().nodesSelectedId = [n.id];
+ UINodes.getNodes().nodesSelectedId = [n.id];
}
///end
- acceptSwatchDrag = (swatch: TSwatchColor) => {
+ static acceptSwatchDrag = (swatch: TSwatchColor) => {
///if (is_paint || is_sculpt)
- this.pushUndo();
- let g = this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null;
+ UINodes.pushUndo();
+ let g = UINodes.groupStack.length > 0 ? UINodes.groupStack[UINodes.groupStack.length - 1] : null;
let n = NodesMaterial.createNode("RGB", g);
n.outputs[0].default_value = [
color_get_rb(swatch.base) / 255,
@@ -1220,15 +1216,15 @@ class UINodes {
color_get_bb(swatch.base) / 255,
color_get_ab(swatch.base) / 255
];
- this.getNodes().nodesSelectedId = [n.id];
+ UINodes.getNodes().nodesSelectedId = [n.id];
///end
}
static makeNode = (n: TNode, nodes: Nodes, canvas: TNodeCanvas): TNode => {
let node: TNode = JSON.parse(JSON.stringify(n));
node.id = nodes.getNodeId(canvas.nodes);
- node.x = UINodes.inst.getNodeX();
- node.y = UINodes.inst.getNodeY();
+ node.x = UINodes.getNodeX();
+ node.y = UINodes.getNodeY();
let count = 0;
for (let soc of node.inputs) {
soc.id = nodes.getSocketId(canvas.nodes) + count;
@@ -1248,8 +1244,8 @@ class UINodes {
let node: TNode = JSON.parse(JSON.stringify(n));
node.name = groupCanvas.name;
node.id = nodes.getNodeId(canvas.nodes);
- node.x = UINodes.inst.getNodeX();
- node.y = UINodes.inst.getNodeY();
+ node.x = UINodes.getNodeX();
+ node.y = UINodes.getNodeY();
let groupInput: TNode = null;
let groupOutput: TNode = null;
for (let g of Project.materialGroups) {
@@ -1273,7 +1269,7 @@ class UINodes {
}
///if (is_paint || is_sculpt)
- makeNodePreview = () => {
+ static makeNodePreview = () => {
let nodes = Context.raw.material.nodes;
if (nodes.nodesSelectedId.length == 0) return;
@@ -1293,7 +1289,7 @@ class UINodes {
}
Context.raw.nodePreviewDirty = false;
- UINodes.inst.hwnd.redraws = 2;
+ UINodes.hwnd.redraws = 2;
UtilRender.makeNodePreview(Context.raw.material.canvas, node, Context.raw.nodePreview);
}
///end
diff --git a/base/Sources/UIStatus.ts b/base/Sources/UIStatus.ts
index 0cf99c61..9dc75f8c 100644
--- a/base/Sources/UIStatus.ts
+++ b/base/Sources/UIStatus.ts
@@ -1,28 +1,26 @@
class UIStatus {
- static inst: UIStatus;
static defaultStatusH = 33;
constructor() {
- UIStatus.inst = this;
}
static get width(): i32 {
///if (is_paint || is_sculpt)
- return System.width - UIToolbar.inst.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
+ return System.width - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
///end
///if is_lab
return System.width;
///end
}
- renderUI = (g: Graphics2) => {
- let ui = UIBase.inst.ui;
+ static renderUI = (g: Graphics2) => {
+ let ui = UIBase.ui;
let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
- if (ui.window(UIBase.inst.hwnds[TabArea.TabStatus], App.x(), System.height - statush, UIStatus.width, statush)) {
+ if (ui.window(UIBase.hwnds[TabArea.TabStatus], App.x(), System.height - statush, UIStatus.width, statush)) {
ui._y += 2;
// Border
@@ -31,22 +29,22 @@ class UIStatus {
ui.g.fillRect(ui._windowW - 1, 0, 1, ui._windowH);
// Draw tabs
- for (let draw of UIBase.inst.hwndTabs[TabArea.TabStatus]) draw(UIBase.inst.htabs[TabArea.TabStatus]);
+ for (let draw of UIBase.hwndTabs[TabArea.TabStatus]) draw(UIBase.htabs[TabArea.TabStatus]);
let minimized = statush <= UIStatus.defaultStatusH * Config.raw.window_scale;
- if (UIBase.inst.htabs[TabArea.TabStatus].changed && (UIBase.inst.htabs[TabArea.TabStatus].position == Context.raw.lastStatusPosition || minimized)) {
- UIBase.inst.toggleBrowser();
+ if (UIBase.htabs[TabArea.TabStatus].changed && (UIBase.htabs[TabArea.TabStatus].position == Context.raw.lastStatusPosition || minimized)) {
+ UIBase.toggleBrowser();
}
- Context.raw.lastStatusPosition = UIBase.inst.htabs[TabArea.TabStatus].position;
+ Context.raw.lastStatusPosition = UIBase.htabs[TabArea.TabStatus].position;
}
}
static drawVersionTab = (htab: Handle) => {
// Version label
if (!Config.raw.touch_ui) {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
ui.enabled = false;
- ui.tab(UIBase.inst.htabs[TabArea.TabStatus], Manifest.version);
+ ui.tab(UIBase.htabs[TabArea.TabStatus], Manifest.version);
ui.enabled = true;
}
}
diff --git a/base/Sources/UIToolbar.ts b/base/Sources/UIToolbar.ts
index 7c580415..2176d11a 100644
--- a/base/Sources/UIToolbar.ts
+++ b/base/Sources/UIToolbar.ts
@@ -3,14 +3,13 @@
class UIToolbar {
- static inst: UIToolbar;
static defaultToolbarW = 36;
- toolbarHandle = new Handle();
- toolbarw = UIToolbar.defaultToolbarW;
- lastTool = 0;
+ static toolbarHandle = new Handle();
+ static toolbarw = UIToolbar.defaultToolbarW;
+ static lastTool = 0;
- toolNames = [
+ static toolNames = [
_tr("Brush"),
_tr("Eraser"),
_tr("Fill"),
@@ -28,21 +27,20 @@ class UIToolbar {
];
constructor() {
- UIToolbar.inst = this;
}
- renderUI = (g: Graphics2) => {
- let ui = UIBase.inst.ui;
+ static renderUI = (g: Graphics2) => {
+ let ui = UIBase.ui;
if (Config.raw.touch_ui) {
- this.toolbarw = UIToolbar.defaultToolbarW + 6;
+ UIToolbar.toolbarw = UIToolbar.defaultToolbarW + 6;
}
else {
- this.toolbarw = UIToolbar.defaultToolbarW;
+ UIToolbar.toolbarw = UIToolbar.defaultToolbarW;
}
- this.toolbarw = Math.floor(this.toolbarw * ui.SCALE());
+ UIToolbar.toolbarw = Math.floor(UIToolbar.toolbarw * ui.SCALE());
- if (ui.window(this.toolbarHandle, 0, UIHeader.headerh, this.toolbarw, System.height - UIHeader.headerh)) {
+ if (ui.window(UIToolbar.toolbarHandle, 0, UIHeader.headerh, UIToolbar.toolbarw, System.height - UIHeader.headerh)) {
ui._y -= 4 * ui.SCALE();
ui.imageScrollAlign = false;
@@ -73,7 +71,7 @@ class UIToolbar {
let fontHeight = ui.font.height(ui.fontSize);
ui.fontOffsetY = (ui.ELEMENT_H() - fontHeight) / 2;
let _w = ui._w;
- ui._w = this.toolbarw;
+ ui._w = UIToolbar.toolbarw;
if (ui.button(">>")) {
UIToolbar.toolPropertiesMenu();
@@ -118,10 +116,10 @@ class UIToolbar {
Context.selectTool(i);
}
else if (imageState == State.Released && Config.raw.layout[LayoutSize.LayoutHeader] == 0) {
- if (this.lastTool == i) {
+ if (UIToolbar.lastTool == i) {
UIToolbar.toolPropertiesMenu();
}
- this.lastTool = i;
+ UIToolbar.lastTool = i;
}
///if is_paint
@@ -130,7 +128,7 @@ class UIToolbar {
}
///end
- if (ui.isHovered) ui.tooltip(tr(this.toolNames[i]) + " " + keys[i]);
+ if (ui.isHovered) ui.tooltip(tr(UIToolbar.toolNames[i]) + " " + keys[i]);
ui._x -= 2;
ui._y += 2;
}
@@ -168,7 +166,7 @@ class UIToolbar {
}
static toolPropertiesMenu = () => {
- let ui = UIBase.inst.ui;
+ let ui = UIBase.ui;
let _x = ui._x;
let _y = ui._y;
let _w = ui._w;
@@ -176,7 +174,7 @@ class UIToolbar {
let startY = ui._y;
ui.changed = false;
- UIHeader.inst.drawToolProperties(ui);
+ UIHeader.drawToolProperties(ui);
if (ui.changed) {
UIMenu.keepOpen = true;
@@ -200,8 +198,8 @@ class UIToolbar {
}
static drawHighlight = () => {
- let ui = UIBase.inst.ui;
- let size = UIToolbar.inst.toolbarw - 4;
+ let ui = UIBase.ui;
+ let size = UIToolbar.toolbarw - 4;
ui.g.color = ui.t.HIGHLIGHT_COL;
ui.drawRect(ui.g, true, ui._x + -1, ui._y + 2, size + 2, size + 2);
}
diff --git a/base/Sources/UIView2D.ts b/base/Sources/UIView2D.ts
index 7e4ad026..410957c6 100644
--- a/base/Sources/UIView2D.ts
+++ b/base/Sources/UIView2D.ts
@@ -5,34 +5,31 @@ class UIView2D {
static pipe: PipelineState;
static channelLocation: ConstantLocation;
static textInputHover = false;
- uvmapShow = false;
- texType = PaintTex.TexBase;
- layerMode = View2DLayerMode.View2DSelected;
+ static uvmapShow = false;
+ static texType = PaintTex.TexBase;
+ static layerMode = View2DLayerMode.View2DSelected;
///end
///if (is_paint || is_sculpt)
- type = View2DType.View2DLayer;
+ static type = View2DType.View2DLayer;
///else
- type = View2DType.View2DAsset;
+ static type = View2DType.View2DAsset;
///end
- static inst: UIView2D;
- show = false;
- wx: i32;
- wy: i32;
- ww: i32;
- wh: i32;
- ui: Zui;
- hwnd = new Handle();
- panX = 0.0;
- panY = 0.0;
- panScale = 1.0;
- tiledShow = false;
- controlsDown = false;
+ static show = false;
+ static wx: i32;
+ static wy: i32;
+ static ww: i32;
+ static wh: i32;
+ static ui: Zui;
+ static hwnd = new Handle();
+ static panX = 0.0;
+ static panY = 0.0;
+ static panScale = 1.0;
+ static tiledShow = false;
+ static controlsDown = false;
constructor() {
- UIView2D.inst = this;
-
///if (is_paint || is_sculpt)
UIView2D.pipe = new PipelineState();
UIView2D.pipe.vertexShader = System.getShader("layer_view.vert");
@@ -50,42 +47,42 @@ class UIView2D {
///end
let scale = Config.raw.window_scale;
- this.ui = new Zui({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale });
- this.ui.scrollEnabled = false;
+ UIView2D.ui = new Zui({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale });
+ UIView2D.ui.scrollEnabled = false;
}
- render = (g: Graphics2) => {
+ static render = (g: Graphics2) => {
- this.ww = Config.raw.layout[LayoutSize.LayoutNodesW];
+ UIView2D.ww = Config.raw.layout[LayoutSize.LayoutNodesW];
///if (is_paint || is_sculpt)
- this.wx = Math.floor(App.w()) + UIToolbar.inst.toolbarw;
+ UIView2D.wx = Math.floor(App.w()) + UIToolbar.toolbarw;
///else
- this.wx = Math.floor(App.w());
+ UIView2D.wx = Math.floor(App.w());
///end
- this.wy = 0;
+ UIView2D.wy = 0;
///if (is_paint || is_sculpt)
- if (!UIBase.inst.show) {
- this.ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.inst.toolbarw;
- this.wx -= UIToolbar.inst.toolbarw;
+ if (!UIBase.show) {
+ UIView2D.ww += Config.raw.layout[LayoutSize.LayoutSidebarW] + UIToolbar.toolbarw;
+ UIView2D.wx -= UIToolbar.toolbarw;
}
///end
- if (!this.show) return;
+ if (!UIView2D.show) return;
if (System.width == 0 || System.height == 0) return;
- if (Context.raw.pdirty >= 0) this.hwnd.redraws = 2; // Paint was active
+ if (Context.raw.pdirty >= 0) UIView2D.hwnd.redraws = 2; // Paint was active
g.end();
// Cache grid
- if (UINodes.inst.grid == null) UINodes.inst.drawGrid();
+ if (UINodes.grid == null) UINodes.drawGrid();
// Ensure UV map is drawn
///if (is_paint || is_sculpt)
- if (this.uvmapShow) UtilUV.cacheUVMap();
+ if (UIView2D.uvmapShow) UtilUV.cacheUVMap();
///end
// Ensure font image is drawn
@@ -93,24 +90,24 @@ class UIView2D {
if (Context.raw.font.image == null) UtilRender.makeFontPreview();
///end
- this.ui.begin(g);
+ UIView2D.ui.begin(g);
let headerh = Config.raw.layout[LayoutSize.LayoutHeader] == 1 ? UIHeader.headerh * 2 : UIHeader.headerh;
let apph = System.height - Config.raw.layout[LayoutSize.LayoutStatusH] + headerh;
- this.wh = System.height - Config.raw.layout[LayoutSize.LayoutStatusH];
+ UIView2D.wh = System.height - Config.raw.layout[LayoutSize.LayoutStatusH];
- if (UINodes.inst.show) {
- this.wh -= Config.raw.layout[LayoutSize.LayoutNodesH];
- if (Config.raw.touch_ui) this.wh += UIHeader.headerh;
+ if (UINodes.show) {
+ UIView2D.wh -= Config.raw.layout[LayoutSize.LayoutNodesH];
+ if (Config.raw.touch_ui) UIView2D.wh += UIHeader.headerh;
}
- if (this.ui.window(this.hwnd, this.wx, this.wy, this.ww, this.wh)) {
+ if (UIView2D.ui.window(UIView2D.hwnd, UIView2D.wx, UIView2D.wy, UIView2D.ww, UIView2D.wh)) {
- this.ui.tab(Zui.handle("uiview2d_0"), tr("2D View"));
+ UIView2D.ui.tab(Zui.handle("uiview2d_0"), tr("2D View"));
// Grid
- this.ui.g.color = 0xffffffff;
- this.ui.g.drawImage(UINodes.inst.grid, (this.panX * this.panScale) % 100 - 100, (this.panY * this.panScale) % 100 - 100);
+ UIView2D.ui.g.color = 0xffffffff;
+ UIView2D.ui.g.drawImage(UINodes.grid, (UIView2D.panX * UIView2D.panScale) % 100 - 100, (UIView2D.panY * UIView2D.panScale) % 100 - 100);
// Texture
let tex: Image = null;
@@ -120,23 +117,23 @@ class UIView2D {
let channel = 0;
///end
- let tw = this.ww * 0.95 * this.panScale;
- let tx = this.ww / 2 - tw / 2 + this.panX;
- let ty = apph / 2 - tw / 2 + this.panY;
+ let tw = UIView2D.ww * 0.95 * UIView2D.panScale;
+ let tx = UIView2D.ww / 2 - tw / 2 + UIView2D.panX;
+ let ty = apph / 2 - tw / 2 + UIView2D.panY;
- if (this.type == View2DType.View2DAsset) {
+ if (UIView2D.type == View2DType.View2DAsset) {
tex = Project.getImage(Context.raw.texture);
}
- else if (this.type == View2DType.View2DNode) {
+ else if (UIView2D.type == View2DType.View2DNode) {
///if (is_paint || is_sculpt)
tex = Context.raw.nodePreview;
///else
- let nodes = UINodes.inst.getNodes();
+ let nodes = UINodes.getNodes();
if (nodes.nodesSelectedId.length > 0) {
- let sel = nodes.getNode(UINodes.inst.getCanvas(true).nodes, nodes.nodesSelectedId[0]);
+ let sel = nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]);
let brushNode = ParserLogic.getLogicNode(sel);
if (brushNode != null) {
tex = brushNode.getCachedImage();
@@ -146,14 +143,14 @@ class UIView2D {
///end
}
///if is_paint
- else if (this.type == View2DType.View2DLayer) {
+ else if (UIView2D.type == View2DType.View2DLayer) {
let layer = l;
if (Config.raw.brush_live && RenderPathPaint.liveLayerDrawn > 0) {
layer = RenderPathPaint.liveLayer;
}
- if (this.layerMode == View2DLayerMode.View2DVisible) {
+ if (UIView2D.layerMode == View2DLayerMode.View2DVisible) {
let current = Graphics2.current;
if (current != null) current.end();
layer = Base.flatten();
@@ -168,22 +165,22 @@ class UIView2D {
tex =
Context.raw.layer.isMask() ? layer.texpaint :
- this.texType == PaintTex.TexBase ? layer.texpaint :
- this.texType == PaintTex.TexOpacity ? layer.texpaint :
- this.texType == PaintTex.TexNormal ? layer.texpaint_nor :
+ UIView2D.texType == PaintTex.TexBase ? layer.texpaint :
+ UIView2D.texType == PaintTex.TexOpacity ? layer.texpaint :
+ UIView2D.texType == PaintTex.TexNormal ? layer.texpaint_nor :
layer.texpaint_pack;
channel =
Context.raw.layer.isMask() ? 1 :
- this.texType == PaintTex.TexOcclusion ? 1 :
- this.texType == PaintTex.TexRoughness ? 2 :
- this.texType == PaintTex.TexMetallic ? 3 :
- this.texType == PaintTex.TexOpacity ? 4 :
- this.texType == PaintTex.TexHeight ? 4 :
- this.texType == PaintTex.TexNormal ? 5 :
+ UIView2D.texType == PaintTex.TexOcclusion ? 1 :
+ UIView2D.texType == PaintTex.TexRoughness ? 2 :
+ UIView2D.texType == PaintTex.TexMetallic ? 3 :
+ UIView2D.texType == PaintTex.TexOpacity ? 4 :
+ UIView2D.texType == PaintTex.TexHeight ? 4 :
+ UIView2D.texType == PaintTex.TexNormal ? 5 :
0;
}
- else if (this.type == View2DType.View2DFont) {
+ else if (UIView2D.type == View2DType.View2DFont) {
tex = Context.raw.font.image;
}
///end
@@ -191,15 +188,15 @@ class UIView2D {
let th = tw;
if (tex != null) {
th = tw * (tex.height / tex.width);
- ty = apph / 2 - th / 2 + this.panY;
+ ty = apph / 2 - th / 2 + UIView2D.panY;
///if (is_paint || is_sculpt)
- if (this.type == View2DType.View2DLayer) {
+ if (UIView2D.type == View2DType.View2DLayer) {
///if (!krom_opengl)
- this.ui.g.pipeline = UIView2D.pipe;
+ UIView2D.ui.g.pipeline = UIView2D.pipe;
///end
if (!Context.raw.textureFilter) {
- this.ui.g.imageScaleQuality = ImageScaleQuality.Low;
+ UIView2D.ui.g.imageScaleQuality = ImageScaleQuality.Low;
}
///if krom_opengl
Krom.setPipeline(UIView2D.pipe.pipeline_);
@@ -208,31 +205,31 @@ class UIView2D {
}
///end
- this.ui.g.drawScaledImage(tex, tx, ty, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx, ty, tw, th);
- if (this.tiledShow) {
- this.ui.g.drawScaledImage(tex, tx - tw, ty, tw, th);
- this.ui.g.drawScaledImage(tex, tx - tw, ty - th, tw, th);
- this.ui.g.drawScaledImage(tex, tx - tw, ty + th, tw, th);
- this.ui.g.drawScaledImage(tex, tx + tw, ty, tw, th);
- this.ui.g.drawScaledImage(tex, tx + tw, ty - th, tw, th);
- this.ui.g.drawScaledImage(tex, tx + tw, ty + th, tw, th);
- this.ui.g.drawScaledImage(tex, tx, ty - th, tw, th);
- this.ui.g.drawScaledImage(tex, tx, ty + th, tw, th);
+ if (UIView2D.tiledShow) {
+ UIView2D.ui.g.drawScaledImage(tex, tx - tw, ty, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx - tw, ty - th, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx - tw, ty + th, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx + tw, ty, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx + tw, ty - th, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx + tw, ty + th, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx, ty - th, tw, th);
+ UIView2D.ui.g.drawScaledImage(tex, tx, ty + th, tw, th);
}
///if (is_paint || is_sculpt)
- if (this.type == View2DType.View2DLayer) {
- this.ui.g.pipeline = null;
+ if (UIView2D.type == View2DType.View2DLayer) {
+ UIView2D.ui.g.pipeline = null;
if (!Context.raw.textureFilter) {
- this.ui.g.imageScaleQuality = ImageScaleQuality.High;
+ UIView2D.ui.g.imageScaleQuality = ImageScaleQuality.High;
}
}
// Texture and node preview color picking
- if ((Context.in2dView(View2DType.View2DAsset) || Context.in2dView(View2DType.View2DNode)) && Context.raw.tool == WorkspaceTool.ToolPicker && this.ui.inputDown) {
- let x = this.ui.inputX - tx - this.wx;
- let y = this.ui.inputY - ty - this.wy;
+ if ((Context.in2dView(View2DType.View2DAsset) || Context.in2dView(View2DType.View2DNode)) && Context.raw.tool == WorkspaceTool.ToolPicker && UIView2D.ui.inputDown) {
+ let x = UIView2D.ui.inputX - tx - UIView2D.wx;
+ let y = UIView2D.ui.inputY - ty - UIView2D.wy;
Base.notifyOnNextFrame(() => {
let path = RenderPath.active;
let texpaint_picker = path.renderTargets.get("texpaint_picker").image;
@@ -254,7 +251,7 @@ class UIView2D {
Context.raw.pickedColor.base = color_set_rb(Context.raw.pickedColor.base, a.getUint8(i0));
Context.raw.pickedColor.base = color_set_gb(Context.raw.pickedColor.base, a.getUint8(i1));
Context.raw.pickedColor.base = color_set_bb(Context.raw.pickedColor.base, a.getUint8(i2));
- UIHeader.inst.headerHandle.redraws = 2;
+ UIHeader.headerHandle.redraws = 2;
});
}
///end
@@ -262,85 +259,85 @@ class UIView2D {
///if (is_paint || is_sculpt)
// UV map
- if (this.type == View2DType.View2DLayer && this.uvmapShow) {
- this.ui.g.drawScaledImage(UtilUV.uvmap, tx, ty, tw, th);
+ if (UIView2D.type == View2DType.View2DLayer && UIView2D.uvmapShow) {
+ UIView2D.ui.g.drawScaledImage(UtilUV.uvmap, tx, ty, tw, th);
}
///end
// Menu
- let ew = Math.floor(this.ui.ELEMENT_W());
- this.ui.g.color = this.ui.t.SEPARATOR_COL;
- this.ui.g.fillRect(0, this.ui.ELEMENT_H(), this.ww, this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET() * 2);
- this.ui.g.color = 0xffffffff;
+ let ew = Math.floor(UIView2D.ui.ELEMENT_W());
+ UIView2D.ui.g.color = UIView2D.ui.t.SEPARATOR_COL;
+ UIView2D.ui.g.fillRect(0, UIView2D.ui.ELEMENT_H(), UIView2D.ww, UIView2D.ui.ELEMENT_H() + UIView2D.ui.ELEMENT_OFFSET() * 2);
+ UIView2D.ui.g.color = 0xffffffff;
- let startY = this.ui.ELEMENT_H() + this.ui.ELEMENT_OFFSET();
- this.ui._x = 2;
- this.ui._y = 2 + startY;
- this.ui._w = ew;
+ let startY = UIView2D.ui.ELEMENT_H() + UIView2D.ui.ELEMENT_OFFSET();
+ UIView2D.ui._x = 2;
+ UIView2D.ui._y = 2 + startY;
+ UIView2D.ui._w = ew;
// Editable layer name
let h = Zui.handle("uiview2d_1");
///if (is_paint || is_sculpt)
- let text = this.type == View2DType.View2DNode ? Context.raw.nodePreviewName : h.text;
+ let text = UIView2D.type == View2DType.View2DNode ? Context.raw.nodePreviewName : h.text;
///else
let text = h.text;
///end
- this.ui._w = Math.floor(Math.min(this.ui.font.width(this.ui.fontSize, text) + 15 * this.ui.SCALE(), 100 * this.ui.SCALE()));
+ UIView2D.ui._w = Math.floor(Math.min(UIView2D.ui.font.width(UIView2D.ui.fontSize, text) + 15 * UIView2D.ui.SCALE(), 100 * UIView2D.ui.SCALE()));
- if (this.type == View2DType.View2DAsset) {
+ if (UIView2D.type == View2DType.View2DAsset) {
let asset = Context.raw.texture;
if (asset != null) {
let assetNames = Project.assetNames;
let i = assetNames.indexOf(asset.name);
h.text = asset.name;
- asset.name = this.ui.textInput(h, "");
+ asset.name = UIView2D.ui.textInput(h, "");
assetNames[i] = asset.name;
}
}
- else if (this.type == View2DType.View2DNode) {
+ else if (UIView2D.type == View2DType.View2DNode) {
///if (is_paint || is_sculpt)
- this.ui.text(Context.raw.nodePreviewName);
+ UIView2D.ui.text(Context.raw.nodePreviewName);
///else
- let nodes = UINodes.inst.getNodes();
+ let nodes = UINodes.getNodes();
if (nodes.nodesSelectedId.length > 0) {
- this.ui.text(nodes.getNode(UINodes.inst.getCanvas(true).nodes, nodes.nodesSelectedId[0]).name);
+ UIView2D.ui.text(nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]).name);
}
///end
}
///if (is_paint || is_sculpt)
- else if (this.type == View2DType.View2DLayer) {
+ else if (UIView2D.type == View2DType.View2DLayer) {
h.text = l.name;
- l.name = this.ui.textInput(h, "");
- UIView2D.textInputHover = this.ui.isHovered;
+ l.name = UIView2D.ui.textInput(h, "");
+ UIView2D.textInputHover = UIView2D.ui.isHovered;
}
- else if (this.type == View2DType.View2DFont) {
+ else if (UIView2D.type == View2DType.View2DFont) {
h.text = Context.raw.font.name;
- Context.raw.font.name = this.ui.textInput(h, "");
+ Context.raw.font.name = UIView2D.ui.textInput(h, "");
}
///end
- if (h.changed) UIBase.inst.hwnds[0].redraws = 2;
- this.ui._x += this.ui._w + 3;
- this.ui._y = 2 + startY;
- this.ui._w = ew;
+ if (h.changed) UIBase.hwnds[0].redraws = 2;
+ UIView2D.ui._x += UIView2D.ui._w + 3;
+ UIView2D.ui._y = 2 + startY;
+ UIView2D.ui._w = ew;
///if (is_paint || is_sculpt)
- if (this.type == View2DType.View2DLayer) {
- this.layerMode = this.ui.combo(Zui.handle("uiview2d_2", { position: this.layerMode }), [
+ if (UIView2D.type == View2DType.View2DLayer) {
+ UIView2D.layerMode = UIView2D.ui.combo(Zui.handle("uiview2d_2", { position: UIView2D.layerMode }), [
tr("Visible"),
tr("Selected"),
], tr("Layers"));
- this.ui._x += ew + 3;
- this.ui._y = 2 + startY;
+ UIView2D.ui._x += ew + 3;
+ UIView2D.ui._y = 2 + startY;
if (!Context.raw.layer.isMask()) {
- this.texType = this.ui.combo(Zui.handle("uiview2d_3", { position: this.texType }), [
+ UIView2D.texType = UIView2D.ui.combo(Zui.handle("uiview2d_3", { position: UIView2D.texType }), [
tr("Base Color"),
tr("Normal Map"),
tr("Occlusion"),
@@ -349,77 +346,77 @@ class UIView2D {
tr("Opacity"),
tr("Height"),
], tr("Texture"));
- this.ui._x += ew + 3;
- this.ui._y = 2 + startY;
+ UIView2D.ui._x += ew + 3;
+ UIView2D.ui._y = 2 + startY;
}
- this.ui._w = Math.floor(ew * 0.7 + 3);
- this.uvmapShow = this.ui.check(Zui.handle("uiview2d_4", { selected: this.uvmapShow }), tr("UV Map"));
- this.ui._x += ew * 0.7 + 3;
- this.ui._y = 2 + startY;
+ UIView2D.ui._w = Math.floor(ew * 0.7 + 3);
+ UIView2D.uvmapShow = UIView2D.ui.check(Zui.handle("uiview2d_4", { selected: UIView2D.uvmapShow }), tr("UV Map"));
+ UIView2D.ui._x += ew * 0.7 + 3;
+ UIView2D.ui._y = 2 + startY;
}
///end
- this.tiledShow = this.ui.check(Zui.handle("uiview2d_5", { selected: this.tiledShow }), tr("Tiled"));
- this.ui._x += ew * 0.7 + 3;
- this.ui._y = 2 + startY;
+ UIView2D.tiledShow = UIView2D.ui.check(Zui.handle("uiview2d_5", { selected: UIView2D.tiledShow }), tr("Tiled"));
+ UIView2D.ui._x += ew * 0.7 + 3;
+ UIView2D.ui._y = 2 + startY;
- if (this.type == View2DType.View2DAsset && tex != null) { // Texture resolution
- this.ui.text(tex.width + "x" + tex.height);
+ if (UIView2D.type == View2DType.View2DAsset && tex != null) { // Texture resolution
+ UIView2D.ui.text(tex.width + "x" + tex.height);
}
// Picked position
///if (is_paint || is_sculpt)
- if (Context.raw.tool == WorkspaceTool.ToolPicker && (this.type == View2DType.View2DLayer || this.type == View2DType.View2DAsset)) {
+ if (Context.raw.tool == WorkspaceTool.ToolPicker && (UIView2D.type == View2DType.View2DLayer || UIView2D.type == View2DType.View2DAsset)) {
let cursorImg = Res.get("cursor.k");
- let hsize = 16 * this.ui.SCALE();
+ let hsize = 16 * UIView2D.ui.SCALE();
let size = hsize * 2;
- this.ui.g.drawScaledImage(cursorImg, tx + tw * Context.raw.uvxPicked - hsize, ty + th * Context.raw.uvyPicked - hsize, size, size);
+ UIView2D.ui.g.drawScaledImage(cursorImg, tx + tw * Context.raw.uvxPicked - hsize, ty + th * Context.raw.uvyPicked - hsize, size, size);
}
///end
}
- this.ui.end();
+ UIView2D.ui.end();
g.begin(false);
}
- update = () => {
+ static update = () => {
let mouse = Input.getMouse();
let kb = Input.getKeyboard();
- let headerh = this.ui.ELEMENT_H() * 1.4;
+ let headerh = UIView2D.ui.ELEMENT_H() * 1.4;
///if (is_paint || is_sculpt)
Context.raw.paint2d = false;
///end
if (!Base.uiEnabled ||
- !this.show ||
- mouse.x < this.wx ||
- mouse.x > this.wx + this.ww ||
- mouse.y < this.wy + headerh ||
- mouse.y > this.wy + this.wh) {
- if (UIView2D.inst.controlsDown) {
- UINodes.getCanvasControl(this.ui, UIView2D.inst);
+ !UIView2D.show ||
+ mouse.x < UIView2D.wx ||
+ mouse.x > UIView2D.wx + UIView2D.ww ||
+ mouse.y < UIView2D.wy + headerh ||
+ mouse.y > UIView2D.wy + UIView2D.wh) {
+ if (UIView2D.controlsDown) {
+ UINodes.getCanvasControl(UIView2D.ui, UIView2D);
}
return;
}
- let control = UINodes.getCanvasControl(this.ui, UIView2D.inst);
- this.panX += control.panX;
- this.panY += control.panY;
+ let control = UINodes.getCanvasControl(UIView2D.ui, UIView2D);
+ UIView2D.panX += control.panX;
+ UIView2D.panY += control.panY;
if (control.zoom != 0) {
- let _panX = this.panX / this.panScale;
- let _panY = this.panY / this.panScale;
- this.panScale += control.zoom;
- if (this.panScale < 0.1) this.panScale = 0.1;
- if (this.panScale > 6.0) this.panScale = 6.0;
- this.panX = _panX * this.panScale;
- this.panY = _panY * this.panScale;
+ let _panX = UIView2D.panX / UIView2D.panScale;
+ let _panY = UIView2D.panY / UIView2D.panScale;
+ UIView2D.panScale += control.zoom;
+ if (UIView2D.panScale < 0.1) UIView2D.panScale = 0.1;
+ if (UIView2D.panScale > 6.0) UIView2D.panScale = 6.0;
+ UIView2D.panX = _panX * UIView2D.panScale;
+ UIView2D.panY = _panY * UIView2D.panScale;
if (Zui.touchScroll) {
// Zoom to finger location
- this.panX -= (this.ui.inputX - this.ui._windowX - this.ui._windowW / 2) * control.zoom;
- this.panY -= (this.ui.inputY - this.ui._windowY - this.ui._windowH / 2) * control.zoom;
+ UIView2D.panX -= (UIView2D.ui.inputX - UIView2D.ui._windowX - UIView2D.ui._windowW / 2) * control.zoom;
+ UIView2D.panY -= (UIView2D.ui.inputY - UIView2D.ui._windowY - UIView2D.ui._windowH / 2) * control.zoom;
}
}
@@ -428,7 +425,7 @@ class UIView2D {
let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown);
let setCloneSource = Context.raw.tool == WorkspaceTool.ToolClone && Operator.shortcut(Config.keymap.set_clone_source + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown);
- if (this.type == View2DType.View2DLayer &&
+ if (UIView2D.type == View2DType.View2DLayer &&
!UIView2D.textInputHover &&
(Operator.shortcut(Config.keymap.action_paint, ShortcutType.ShortcutDown) ||
Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) ||
@@ -439,29 +436,29 @@ class UIView2D {
}
///end
- if (this.ui.isTyping) return;
+ if (UIView2D.ui.isTyping) return;
- if (kb.started("left")) this.panX -= 5;
- else if (kb.started("right")) this.panX += 5;
- if (kb.started("up")) this.panY -= 5;
- else if (kb.started("down")) this.panY += 5;
+ if (kb.started("left")) UIView2D.panX -= 5;
+ else if (kb.started("right")) UIView2D.panX += 5;
+ if (kb.started("up")) UIView2D.panY -= 5;
+ else if (kb.started("down")) UIView2D.panY += 5;
// Limit panning to keep texture in viewport
let border = 32;
- let tw = this.ww * 0.95 * this.panScale;
- let tx = this.ww / 2 - tw / 2 + this.panX;
+ let tw = UIView2D.ww * 0.95 * UIView2D.panScale;
+ let tx = UIView2D.ww / 2 - tw / 2 + UIView2D.panX;
let hh = App.h();
- let ty = hh / 2 - tw / 2 + this.panY;
+ let ty = hh / 2 - tw / 2 + UIView2D.panY;
- if (tx + border > this.ww) this.panX = this.ww / 2 + tw / 2 - border;
- else if (tx - border < -tw) this.panX = -tw / 2 - this.ww / 2 + border;
- if (ty + border > hh) this.panY = hh / 2 + tw / 2 - border;
- else if (ty - border < -tw) this.panY = -tw / 2 - hh / 2 + border;
+ if (tx + border > UIView2D.ww) UIView2D.panX = UIView2D.ww / 2 + tw / 2 - border;
+ else if (tx - border < -tw) UIView2D.panX = -tw / 2 - UIView2D.ww / 2 + border;
+ if (ty + border > hh) UIView2D.panY = hh / 2 + tw / 2 - border;
+ else if (ty - border < -tw) UIView2D.panY = -tw / 2 - hh / 2 + border;
if (Operator.shortcut(Config.keymap.view_reset)) {
- this.panX = 0.0;
- this.panY = 0.0;
- this.panScale = 1.0;
+ UIView2D.panX = 0.0;
+ UIView2D.panY = 0.0;
+ UIView2D.panScale = 1.0;
}
}
}
diff --git a/base/Sources/UniformsExt.ts b/base/Sources/UniformsExt.ts
index 0c3b6ed5..0408c15b 100644
--- a/base/Sources/UniformsExt.ts
+++ b/base/Sources/UniformsExt.ts
@@ -26,7 +26,7 @@ class UniformsExt {
let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown);
let brushDecalMaskRadius = Context.raw.brushDecalMaskRadius;
if (Config.raw.brush_3d) {
- brushDecalMaskRadius *= Context.raw.paint2d ? 0.55 * UIView2D.inst.panScale : 2.0;
+ brushDecalMaskRadius *= Context.raw.paint2d ? 0.55 * UIView2D.panScale : 2.0;
}
let radius = decalMask ? brushDecalMaskRadius : Context.raw.brushRadius;
let val = (radius * Context.raw.brushNodesRadius) / 15.0;
@@ -37,7 +37,7 @@ class UniformsExt {
let scale2d = (900 / Base.h()) * Config.raw.window_scale;
if (Config.raw.brush_3d && !decal) {
- val *= Context.raw.paint2d ? 0.55 * scale2d * UIView2D.inst.panScale : 2;
+ val *= Context.raw.paint2d ? 0.55 * scale2d * UIView2D.panScale : 2;
}
else {
val *= scale2d; // Projection ratio
@@ -92,7 +92,7 @@ class UniformsExt {
}
if (Config.raw.brush_3d) {
if (Context.raw.paint2d) {
- val *= 1.0 / UIView2D.inst.panScale;
+ val *= 1.0 / UIView2D.panScale;
}
else {
val *= val;
@@ -260,7 +260,7 @@ class UniformsExt {
static vec2d = (x: f32) => {
// Transform from 3d viewport coord to 2d view coord
Context.raw.paint2dView = false;
- let res = (x * Base.w() - Base.w()) / UIView2D.inst.ww;
+ let res = (x * Base.w() - Base.w()) / UIView2D.ww;
Context.raw.paint2dView = true;
return res;
}
diff --git a/base/Sources/Viewport.ts b/base/Sources/Viewport.ts
index e8168813..33d8e17d 100644
--- a/base/Sources/Viewport.ts
+++ b/base/Sources/Viewport.ts
@@ -30,7 +30,7 @@ class Viewport {
cam.data.raw.ortho = null;
cam.buildProjection();
Context.raw.ddirty = 2;
- Camera.inst.reset();
+ Camera.reset();
Context.mainObject().transform.reset();
break;
}
@@ -47,12 +47,12 @@ class Viewport {
cam.transform.buildMatrix();
cam.buildProjection();
Context.raw.ddirty = 2;
- Camera.inst.reset(Context.raw.viewIndexLast);
+ Camera.reset(Context.raw.viewIndexLast);
}
static orbit = (x: f32, y: f32) => {
let cam = Scene.active.camera;
- let dist = Camera.inst.distance();
+ let dist = Camera.distance();
cam.transform.move(cam.lookWorld(), dist);
cam.transform.rotate(new Vec4(0, 0, 1), x);
cam.transform.rotate(cam.rightWorld(), y);