diff --git a/armorforge/Sources/TabObjects.ts b/armorforge/Sources/TabObjects.ts index 9bce3ee12..d02f2edce 100644 --- a/armorforge/Sources/TabObjects.ts +++ b/armorforge/Sources/TabObjects.ts @@ -8,71 +8,71 @@ class TabObjects { return Math.round(f) / Math.pow(10, precision); } - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Objects"))) { - Zui.beginSticky(); - Zui.row([1 / 4]); - if (Zui.button("Import")) { + if (zui_tab(htab, tr("Objects"))) { + zui_begin_sticky(); + zui_row([1 / 4]); + if (zui_button("Import")) { Project.importMesh(false, () => { - BaseObject.setParent(Project.paintObjects.pop().base, null); + object_set_parent(Project.paintObjects.pop().base, null); }); } - Zui.endSticky(); + zui_end_sticky(); - if (Zui.panel(Zui.handle("tabobjects_0", {selected: true}), "Outliner")) { + if (zui_panel(zui_handle("tabobjects_0", {selected: true}), "Outliner")) { // ui.indent(); - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); let listX = ui._x; let listW = ui._w; let lineCounter = 0; - let drawList = (listHandle: HandleRaw, currentObject: TBaseObject) => { + let drawList = (listHandle: zui_handle_t, currentObject: object_t) => { if (currentObject.name.charAt(0) == ".") return; // Hidden let b = false; // Highlight every other line if (lineCounter % 2 == 0) { ui.g.color = ui.t.SEPARATOR_COL; - g2_fill_rect(0, ui._y, ui._windowW, Zui.ELEMENT_H(ui)); + g2_fill_rect(0, ui._y, ui._window_w, zui_ELEMENT_H(ui)); ui.g.color = 0xffffffff; } // Highlight selected line if (currentObject == Context.raw.selectedObject) { ui.g.color = 0xff205d9c; - g2_fill_rect(0, ui._y, ui._windowW, Zui.ELEMENT_H(ui)); + g2_fill_rect(0, ui._y, ui._window_w, zui_ELEMENT_H(ui)); ui.g.color = 0xffffffff; } if (currentObject.children.length > 0) { - Zui.row([1 / 13, 12 / 13]); - b = Zui.panel(Zui.nest(listHandle, lineCounter, {selected: true}), "", true, false, false); - Zui.text(currentObject.name); + zui_row([1 / 13, 12 / 13]); + b = zui_panel(zui_nest(listHandle, lineCounter, {selected: true}), "", true, false, false); + zui_text(currentObject.name); } else { ui._x += 18; // Sign offset // Draw line that shows parent relations ui.g.color = ui.t.ACCENT_COL; - g2_draw_line(ui._x - 10, ui._y + Zui.ELEMENT_H(ui) / 2, ui._x, ui._y + Zui.ELEMENT_H(ui) / 2); + g2_draw_line(ui._x - 10, ui._y + zui_ELEMENT_H(ui) / 2, ui._x, ui._y + zui_ELEMENT_H(ui) / 2); ui.g.color = 0xffffffff; - Zui.text(currentObject.name); + zui_text(currentObject.name); ui._x -= 18; } lineCounter++; // Undo applied offset for row drawing caused by endElement() in Zui.hx - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); - if (ui.isReleased) { + if (ui.is_released) { Context.raw.selectedObject = currentObject; } - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, "Assign Material")) { TabObjects.materialId++; @@ -95,8 +95,8 @@ class TabObjects { } } - Data.getMaterial("Scene", "TempMaterial" + TabObjects.materialId, (md: material_data_t) => { - let mo: TMeshObject = currentObject.ext; + data_get_material("Scene", "TempMaterial" + TabObjects.materialId, (md: material_data_t) => { + let mo: mesh_object_t = currentObject.ext; mo.materials = [md]; MakeMaterial.parseMeshPreviewMaterial(md); }); @@ -114,24 +114,24 @@ class TabObjects { // Draw line that shows parent relations ui.g.color = ui.t.ACCENT_COL; - g2_draw_line(ui._x + 14, currentY, ui._x + 14, ui._y - Zui.ELEMENT_H(ui) / 2); + g2_draw_line(ui._x + 14, currentY, ui._x + 14, ui._y - zui_ELEMENT_H(ui) / 2); ui.g.color = 0xffffffff; } } for (let c of _scene_root.children) { - drawList(Zui.handle("tabobjects_1"), c); + drawList(zui_handle("tabobjects_1"), c); } // ui.unindent(); } - if (Zui.panel(Zui.handle("tabobjects_2", {selected: true}), 'Properties')) { + if (zui_panel(zui_handle("tabobjects_2", {selected: true}), 'Properties')) { // ui.indent(); if (Context.raw.selectedObject != null) { - let h = Zui.handle("tabobjects_3"); + let h = zui_handle("tabobjects_3"); h.selected = Context.raw.selectedObject.visible; - Context.raw.selectedObject.visible = Zui.check(h, "Visible"); + Context.raw.selectedObject.visible = zui_check(h, "Visible"); let t = Context.raw.selectedObject.transform; let localPos = t.loc; @@ -142,41 +142,41 @@ class TabObjects { vec4_mult(rot, 180 / 3.141592); let f = 0.0; - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.text("Loc"); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_text("Loc"); - h = Zui.handle("tabobjects_4"); + h = zui_handle("tabobjects_4"); h.text = TabObjects.roundfp(localPos.x) + ""; - f = parseFloat(Zui.textInput(h, "X")); + f = parseFloat(zui_text_input(h, "X")); if (h.changed) localPos.x = f; - h = Zui.handle("tabobjects_5"); + h = zui_handle("tabobjects_5"); h.text = TabObjects.roundfp(localPos.y) + ""; - f = parseFloat(Zui.textInput(h, "Y")); + f = parseFloat(zui_text_input(h, "Y")); if (h.changed) localPos.y = f; - h = Zui.handle("tabobjects_6"); + h = zui_handle("tabobjects_6"); h.text = TabObjects.roundfp(localPos.z) + ""; - f = parseFloat(Zui.textInput(h, "Z")); + f = parseFloat(zui_text_input(h, "Z")); if (h.changed) localPos.z = f; - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.text("Rotation"); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_text("Rotation"); - h = Zui.handle("tabobjects_7"); + h = zui_handle("tabobjects_7"); h.text = TabObjects.roundfp(rot.x) + ""; - f = parseFloat(Zui.textInput(h, "X")); + f = parseFloat(zui_text_input(h, "X")); let changed = false; if (h.changed) { changed = true; rot.x = f; } - h = Zui.handle("tabobjects_8"); + h = zui_handle("tabobjects_8"); h.text = TabObjects.roundfp(rot.y) + ""; - f = parseFloat(Zui.textInput(h, "Y")); + f = parseFloat(zui_text_input(h, "Y")); if (h.changed) { changed = true; rot.y = f; } - h = Zui.handle("tabobjects_9"); + h = zui_handle("tabobjects_9"); h.text = TabObjects.roundfp(rot.z) + ""; - f = parseFloat(Zui.textInput(h, "Z")); + f = parseFloat(zui_text_input(h, "Z")); if (h.changed) { changed = true; rot.z = f; } if (changed && Context.raw.selectedObject.name != "Scene") { @@ -188,61 +188,61 @@ class TabObjects { // ///end } - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.text("Scale"); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_text("Scale"); - h = Zui.handle("tabobjects_10"); + h = zui_handle("tabobjects_10"); h.text = TabObjects.roundfp(scale.x) + ""; - f = parseFloat(Zui.textInput(h, "X")); + f = parseFloat(zui_text_input(h, "X")); if (h.changed) scale.x = f; - h = Zui.handle("tabobjects_11"); + h = zui_handle("tabobjects_11"); h.text = TabObjects.roundfp(scale.y) + ""; - f = parseFloat(Zui.textInput(h, "Y")); + f = parseFloat(zui_text_input(h, "Y")); if (h.changed) scale.y = f; - h = Zui.handle("tabobjects_12"); + h = zui_handle("tabobjects_12"); h.text = TabObjects.roundfp(scale.z) + ""; - f = parseFloat(Zui.textInput(h, "Z")); + f = parseFloat(zui_text_input(h, "Z")); if (h.changed) scale.z = f; - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.text("Dimensions"); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_text("Dimensions"); - h = Zui.handle("tabobjects_13"); + h = zui_handle("tabobjects_13"); h.text = TabObjects.roundfp(dim.x) + ""; - f = parseFloat(Zui.textInput(h, "X")); + f = parseFloat(zui_text_input(h, "X")); if (h.changed) dim.x = f; - h = Zui.handle("tabobjects_14"); + h = zui_handle("tabobjects_14"); h.text = TabObjects.roundfp(dim.y) + ""; - f = parseFloat(Zui.textInput(h, "Y")); + f = parseFloat(zui_text_input(h, "Y")); if (h.changed) dim.y = f; - h = Zui.handle("tabobjects_15"); + h = zui_handle("tabobjects_15"); h.text = TabObjects.roundfp(dim.z) + ""; - f = parseFloat(Zui.textInput(h, "Z")); + f = parseFloat(zui_text_input(h, "Z")); if (h.changed) dim.z = f; Context.raw.selectedObject.transform.dirty = true; if (Context.raw.selectedObject.name == "Scene") { let p = scene_world; - p.strength = Zui.slider(Zui.handle("tabobjects_16", {value: p.strength}), "Environment", 0.0, 5.0, true); + p.strength = zui_slider(zui_handle("tabobjects_16", {value: p.strength}), "Environment", 0.0, 5.0, true); } - else if (Context.raw.selectedObject.ext.constructor == TLightObject) { + else if (Context.raw.selectedObject.ext.constructor == light_object_t) { let light = Context.raw.selectedObject.ext; - let lightHandle = Zui.handle("tabobjects_17"); + let lightHandle = zui_handle("tabobjects_17"); lightHandle.value = light.data.strength / 10; - light.data.strength = Zui.slider(lightHandle, "Strength", 0.0, 5.0, true) * 10; + light.data.strength = zui_slider(lightHandle, "Strength", 0.0, 5.0, true) * 10; } - else if (Context.raw.selectedObject.ext.constructor == TCameraObject) { + else if (Context.raw.selectedObject.ext.constructor == camera_object_t) { let cam = Context.raw.selectedObject.ext; - let fovHandle = Zui.handle("tabobjects_18"); + let fovHandle = zui_handle("tabobjects_18"); fovHandle.value = Math.floor(cam.data.fov * 100) / 100; - cam.data.fov = Zui.slider(fovHandle, "FoV", 0.3, 2.0, true); + cam.data.fov = zui_slider(fovHandle, "FoV", 0.3, 2.0, true); if (fovHandle.changed) { - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); } } } diff --git a/armorlab/Sources/MakeMaterial.ts b/armorlab/Sources/MakeMaterial.ts index b309bfd68..28f857a09 100644 --- a/armorlab/Sources/MakeMaterial.ts +++ b/armorlab/Sources/MakeMaterial.ts @@ -93,7 +93,7 @@ class MakeMaterial { scon2._override_context = {}; scon2._override_context.addressing = "repeat"; let mcon3: material_context_t; - MaterialContext.create(mcon2, (_mcon: material_context_t) => { mcon3 = _mcon; }); + material_context_create(mcon2, (_mcon: material_context_t) => { mcon3 = _mcon; }); m._shader.contexts.push(scon2); m._shader._contexts.push(scon2); diff --git a/armorlab/Sources/MakePaint.ts b/armorlab/Sources/MakePaint.ts index 4770d3632..16a9d34ab 100644 --- a/armorlab/Sources/MakePaint.ts +++ b/armorlab/Sources/MakePaint.ts @@ -18,7 +18,7 @@ class MakePaint { con_paint.data.color_writes_green = [true, true, true, true]; con_paint.data.color_writes_blue = [true, true, true, true]; con_paint.data.color_writes_alpha = [true, true, true, true]; - con_paint.allow_vcols = MeshData.getVArray(Context.raw.paintObject.data, "col") != null; + con_paint.allow_vcols = mesh_data_get_vertex_array(Context.raw.paintObject.data, "col") != null; let vert = NodeShaderContext.make_vert(con_paint); let frag = NodeShaderContext.make_frag(con_paint); diff --git a/armorlab/Sources/NodesBrush.ts b/armorlab/Sources/NodesBrush.ts index 7d2791996..bcad35384 100644 --- a/armorlab/Sources/NodesBrush.ts +++ b/armorlab/Sources/NodesBrush.ts @@ -11,7 +11,7 @@ class NodesBrush { static categories = [_tr("Input"), _tr("Model")]; - static list: TNode[][] = [ + static list: zui_node_t[][] = [ [ // Input ImageTextureNode.def, RGBNode.def, @@ -26,7 +26,7 @@ class NodesBrush { ] ]; - static createNode = (nodeType: string): TNode => { + static createNode = (nodeType: string): zui_node_t => { for (let c of NodesBrush.list) { for (let n of c) { if (n.type == nodeType) { diff --git a/armorlab/Sources/RenderPathPaint.ts b/armorlab/Sources/RenderPathPaint.ts index 4a421c7af..7bcbdc5ef 100644 --- a/armorlab/Sources/RenderPathPaint.ts +++ b/armorlab/Sources/RenderPathPaint.ts @@ -165,7 +165,7 @@ class RenderPathPaint { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); - let inpaint = nodes.nodesSelectedId.length > 0 && Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; + let inpaint = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; if (!Base.uiEnabled || Base.isDragging || !inpaint) { return; @@ -174,8 +174,8 @@ class RenderPathPaint { let mx = Context.raw.paintVec.x; let my = 1.0 - Context.raw.paintVec.y; if (Context.raw.brushLocked) { - mx = (Context.raw.lockStartedX - App.x()) / App.w(); - my = 1.0 - (Context.raw.lockStartedY - App.y()) / App.h(); + mx = (Context.raw.lockStartedX - app_x()) / app_w(); + my = 1.0 - (Context.raw.lockStartedY - app_y()) / app_h(); } let radius = Context.raw.brushRadius; RenderPathPaint.drawCursor(mx, my, radius / 3.4); @@ -195,15 +195,15 @@ class RenderPathPaint { g4_set_float2(Base.cursorMouse, mx, my); g4_set_float2(Base.cursorTexStep, 1 / gbuffer0.width, 1 / gbuffer0.height); g4_set_float(Base.cursorRadius, radius); - let right = vec4_normalize(CameraObject.rightWorld(scene_camera)); + let right = vec4_normalize(camera_object_right_world(scene_camera)); g4_set_float3(Base.cursorCameraRight, right.x, right.y, right.z); g4_set_float3(Base.cursorTint, tintR, tintG, tintB); - g4_set_mat(Base.cursorVP, scene_camera.VP); + g4_set_mat(Base.cursorVP, scene_camera.vp); let helpMat = mat4_identity(); - mat4_get_inv(helpMat, scene_camera.VP); + mat4_get_inv(helpMat, scene_camera.vp); g4_set_mat(Base.cursorInvVP, helpMat); ///if (krom_metal || krom_vulkan) - g4_set_vertex_buffer(MeshData.get(geom, [{name: "tex", data: "short2norm"}])); + g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}])); ///else g4_set_vertex_buffer(geom._vertexBuffer); ///end @@ -255,7 +255,7 @@ class RenderPathPaint { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); if (nodes.nodesSelectedId.length > 0) { - let node = Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]); + let node = zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]); let brushNode = ParserLogic.getLogicNode(node); if (brushNode != null) { image = brushNode.getCachedImage(); @@ -285,7 +285,7 @@ class RenderPathPaint { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); - let node = Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]); + let node = zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]); let inpaint = node.type == "InpaintNode"; if (inpaint) { let brushNode = ParserLogic.getLogicNode(node); diff --git a/armorlab/Sources/UINodesExt.ts b/armorlab/Sources/UINodesExt.ts index da3683a5f..53aabf914 100644 --- a/armorlab/Sources/UINodesExt.ts +++ b/armorlab/Sources/UINodesExt.ts @@ -5,13 +5,13 @@ class UINodesExt { static drawButtons = (ew: f32, startY: f32) => { let ui = UINodes.ui; - if (Zui.button(tr("Run"))) { + if (zui_button(tr("Run"))) { Console.progress(tr("Processing")); let delayIdleSleep = (_: any) => { Krom.delayIdleSleep(); } - App.notifyOnRender2D(delayIdleSleep); + app_notify_on_render_2d(delayIdleSleep); let tasks = 1; @@ -20,7 +20,7 @@ class UINodesExt { if (tasks == 0) { Console.progress(null); Context.raw.ddirty = 2; - App.removeRender2D(delayIdleSleep); + app_remove_render_2d(delayIdleSleep); ///if (krom_direct3d12 || krom_vulkan || krom_metal) RenderPathRaytrace.ready = false; @@ -55,7 +55,7 @@ class UINodesExt { if (Base.pipeCopy == null) Base.makePipe(); if (Base.pipeCopyA == null) Base.makePipeCopyA(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); let texpaint_pack = render_path_render_targets.get("texpaint_pack").image; @@ -79,8 +79,8 @@ class UINodesExt { g4_begin(texpaint_pack.g4); g4_set_pipeline(Base.pipeCopyA); g4_set_tex(Base.pipeCopyATex, texheight); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); @@ -135,9 +135,9 @@ class UINodesExt { ui._y = 2 + startY; ///if (krom_android || krom_ios) - Zui.combo(Base.resHandle, ["2K", "4K"], tr("Resolution")); + zui_combo(Base.resHandle, ["2K", "4K"], tr("Resolution")); ///else - Zui.combo(Base.resHandle, ["2K", "4K", "8K", "16K"], tr("Resolution")); + zui_combo(Base.resHandle, ["2K", "4K", "8K", "16K"], tr("Resolution")); ///end if (Base.resHandle.changed) { Base.onLayersResized(); diff --git a/armorlab/Sources/nodes/ImageTextureNode.ts b/armorlab/Sources/nodes/ImageTextureNode.ts index 0c8cae2be..f326a3841 100644 --- a/armorlab/Sources/nodes/ImageTextureNode.ts +++ b/armorlab/Sources/nodes/ImageTextureNode.ts @@ -20,7 +20,7 @@ class ImageTextureNode extends LogicNode { return image; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Image Texture"), type: "ImageTextureNode", diff --git a/armorlab/Sources/nodes/InpaintNode.ts b/armorlab/Sources/nodes/InpaintNode.ts index a3051f9c8..4e9e2edd7 100644 --- a/armorlab/Sources/nodes/InpaintNode.ts +++ b/armorlab/Sources/nodes/InpaintNode.ts @@ -40,11 +40,11 @@ class InpaintNode extends LogicNode { } } - static buttons = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static buttons = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { InpaintNode.auto = node.buttons[0].default_value == 0 ? false : true; if (!InpaintNode.auto) { - InpaintNode.strength = Zui.slider(Zui.handle("inpaintnode_0", {value: InpaintNode.strength}), tr("strength"), 0, 1, true); - InpaintNode.prompt = Zui.textArea(Zui.handle("inpaintnode_1"), Align.Left, true, tr("prompt"), true); + InpaintNode.strength = zui_slider(zui_handle("inpaintnode_0", { value: InpaintNode.strength }), tr("strength"), 0, 1, true); + InpaintNode.prompt = zui_text_area(zui_handle("inpaintnode_1"), Align.Left, true, tr("prompt"), true); node.buttons[1].height = 1 + InpaintNode.prompt.split("\n").length; } else node.buttons[1].height = 0; @@ -68,13 +68,13 @@ class InpaintNode extends LogicNode { Base.notifyOnNextFrame(() => { this.inputs[0].getAsImage((source: image_t) => { if (Base.pipeCopy == null) Base.makePipe(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g4_begin(InpaintNode.image.g4); g4_set_pipeline(Base.pipeInpaintPreview); g4_set_tex(Base.tex0InpaintPreview, source); g4_set_tex(Base.texaInpaintPreview, InpaintNode.mask); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); }); @@ -106,7 +106,7 @@ class InpaintNode extends LogicNode { let u8 = new Uint8Array(bytes_img); let f32mask = new Float32Array(4 * 64 * 64); - Data.getBlob("models/sd_vae_encoder.quant.onnx", (vae_encoder_blob: ArrayBuffer) => { + data_get_blob("models/sd_vae_encoder.quant.onnx", (vae_encoder_blob: ArrayBuffer) => { // for (let x = 0; x < Math.floor(image.width / 512); ++x) { // for (let y = 0; y < Math.floor(image.height / 512); ++y) { let x = 0; @@ -175,7 +175,7 @@ class InpaintNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Inpaint"), type: "InpaintNode", diff --git a/armorlab/Sources/nodes/PhotoToPBRNode.ts b/armorlab/Sources/nodes/PhotoToPBRNode.ts index 14a7789f9..1b11e0ab4 100644 --- a/armorlab/Sources/nodes/PhotoToPBRNode.ts +++ b/armorlab/Sources/nodes/PhotoToPBRNode.ts @@ -67,7 +67,7 @@ class PhotoToPBRNode extends LogicNode { f32a[i + PhotoToPBRNode.tileWithBorderW * PhotoToPBRNode.tileWithBorderW * 2] = (u8a[i * 4 + 2] / 255 - 0.5) / 0.5; } - Data.getBlob("models/photo_to_" + PhotoToPBRNode.modelNames[from] + ".quant.onnx", (model_blob: ArrayBuffer) => { + data_get_blob("models/photo_to_" + PhotoToPBRNode.modelNames[from] + ".quant.onnx", (model_blob: ArrayBuffer) => { let buf = Krom.mlInference(model_blob, [f32a.buffer], null, null, Config.raw.gpu_inference); let ar = new Float32Array(buf); let u8a = new Uint8Array(4 * PhotoToPBRNode.tileW * PhotoToPBRNode.tileW); @@ -168,7 +168,7 @@ class PhotoToPBRNode extends LogicNode { } ///end - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Photo to PBR"), type: "PhotoToPBRNode", diff --git a/armorlab/Sources/nodes/RGBNode.ts b/armorlab/Sources/nodes/RGBNode.ts index 28a483c1a..3f81ca13e 100644 --- a/armorlab/Sources/nodes/RGBNode.ts +++ b/armorlab/Sources/nodes/RGBNode.ts @@ -30,7 +30,7 @@ class RGBNode extends LogicNode { return this.image; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("RGB"), type: "RGBNode", diff --git a/armorlab/Sources/nodes/TextToPhotoNode.ts b/armorlab/Sources/nodes/TextToPhotoNode.ts index 102069778..83a444c81 100644 --- a/armorlab/Sources/nodes/TextToPhotoNode.ts +++ b/armorlab/Sources/nodes/TextToPhotoNode.ts @@ -23,16 +23,16 @@ class TextToPhotoNode extends LogicNode { return TextToPhotoNode.image; } - static buttons = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static buttons = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { TextToPhotoNode.tiling = node.buttons[0].default_value == 0 ? false : true; - TextToPhotoNode.prompt = Zui.textArea(Zui.handle("texttophotonode_0"), Align.Left, true, tr("prompt"), true); + TextToPhotoNode.prompt = zui_text_area(zui_handle("texttophotonode_0"), Align.Left, true, tr("prompt"), true); node.buttons[1].height = TextToPhotoNode.prompt.split("\n").length; } static stableDiffusion = (prompt: string, done: (img: image_t)=>void, inpaintLatents: Float32Array = null, offset = 0, upscale = true, mask: Float32Array = null, latents_orig: Float32Array = null) => { - Data.getBlob("models/sd_text_encoder.quant.onnx", (_text_encoder_blob: ArrayBuffer) => { - Data.getBlob("models/sd_unet.quant.onnx", (_unet_blob: ArrayBuffer) => { - Data.getBlob("models/sd_vae_decoder.quant.onnx", (_vae_decoder_blob: ArrayBuffer) => { + data_get_blob("models/sd_text_encoder.quant.onnx", (_text_encoder_blob: ArrayBuffer) => { + data_get_blob("models/sd_unet.quant.onnx", (_unet_blob: ArrayBuffer) => { + data_get_blob("models/sd_vae_decoder.quant.onnx", (_vae_decoder_blob: ArrayBuffer) => { TextToPhotoNode.text_encoder_blob = _text_encoder_blob; TextToPhotoNode.unet_blob = _unet_blob; TextToPhotoNode.vae_decoder_blob = _vae_decoder_blob; @@ -188,11 +188,11 @@ class TextToPhotoNode extends LogicNode { } if (counter == (51 - offset)) { - App.removeRender2D(processing); + app_remove_render_2d(processing); done(latents); } } - App.notifyOnRender2D(processing); + app_notify_on_render_2d(processing); } static vaeDecoder = (latents: Float32Array, upscale: bool, done: (img: image_t)=>void) => { @@ -241,7 +241,7 @@ class TextToPhotoNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Text to Photo"), type: "TextToPhotoNode", diff --git a/armorlab/Sources/nodes/TilingNode.ts b/armorlab/Sources/nodes/TilingNode.ts index 5897cc222..04c8f2e74 100644 --- a/armorlab/Sources/nodes/TilingNode.ts +++ b/armorlab/Sources/nodes/TilingNode.ts @@ -18,11 +18,11 @@ class TilingNode extends LogicNode { } } - static buttons = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static buttons = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { TilingNode.auto = node.buttons[0].default_value == 0 ? false : true; if (!TilingNode.auto) { - TilingNode.strength = Zui.slider(Zui.handle("tilingnode_0", {value: TilingNode.strength}), tr("strength"), 0, 1, true); - TilingNode.prompt = Zui.textArea(Zui.handle("tilingnode_1"), Align.Left, true, tr("prompt"), true); + TilingNode.strength = zui_slider(zui_handle("tilingnode_0", { value: TilingNode.strength }), tr("strength"), 0, 1, true); + TilingNode.prompt = zui_text_area(zui_handle("tilingnode_1"), Align.Left, true, tr("prompt"), true); node.buttons[1].height = 1 + TilingNode.prompt.split("\n").length; } else node.buttons[1].height = 0; @@ -85,7 +85,7 @@ class TilingNode extends LogicNode { InpaintNode.sdInpaint(tile, mask, done); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Tiling"), type: "TilingNode", diff --git a/armorlab/Sources/nodes/UpscaleNode.ts b/armorlab/Sources/nodes/UpscaleNode.ts index 8cbff489f..9069c7ab0 100644 --- a/armorlab/Sources/nodes/UpscaleNode.ts +++ b/armorlab/Sources/nodes/UpscaleNode.ts @@ -31,7 +31,7 @@ class UpscaleNode extends LogicNode { } static loadBlob = (done: ()=>void) => { - Data.getBlob("models/esrgan.quant.onnx", (_esrgan_blob: ArrayBuffer) => { + data_get_blob("models/esrgan.quant.onnx", (_esrgan_blob: ArrayBuffer) => { UpscaleNode.esrgan_blob = _esrgan_blob; done(); }); @@ -119,7 +119,7 @@ class UpscaleNode extends LogicNode { return result; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Upscale"), type: "UpscaleNode", diff --git a/armorlab/Sources/nodes/VarianceNode.ts b/armorlab/Sources/nodes/VarianceNode.ts index d616f87f9..85f4ea23b 100644 --- a/armorlab/Sources/nodes/VarianceNode.ts +++ b/armorlab/Sources/nodes/VarianceNode.ts @@ -18,8 +18,8 @@ class VarianceNode extends LogicNode { } } - static buttons = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { - VarianceNode.prompt = Zui.textArea(Zui.handle("variancenode_0"), Align.Left, true, tr("prompt"), true); + static buttons = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { + VarianceNode.prompt = zui_text_area(zui_handle("variancenode_0"), Align.Left, true, tr("prompt"), true); node.buttons[0].height = VarianceNode.prompt.split("\n").length; } @@ -42,7 +42,7 @@ class VarianceNode extends LogicNode { Console.progress(tr("Processing") + " - " + tr("Variance")); Base.notifyOnNextFrame(() => { - Data.getBlob("models/sd_vae_encoder.quant.onnx", (vae_encoder_blob: ArrayBuffer) => { + data_get_blob("models/sd_vae_encoder.quant.onnx", (vae_encoder_blob: ArrayBuffer) => { let latents_buf = Krom.mlInference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], Config.raw.gpu_inference); let latents = new Float32Array(latents_buf); for (let i = 0; i < latents.length; ++i) { @@ -75,7 +75,7 @@ class VarianceNode extends LogicNode { return VarianceNode.image; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Variance"), type: "VarianceNode", diff --git a/armorpaint/Sources/ImportFolder.ts b/armorpaint/Sources/ImportFolder.ts index 1f3fee2fe..59616522e 100644 --- a/armorpaint/Sources/ImportFolder.ts +++ b/armorpaint/Sources/ImportFolder.ts @@ -67,7 +67,7 @@ class ImportFolder { let canvas = Context.raw.material.canvas; let dirs = path.split(Path.sep); canvas.name = dirs[dirs.length - 1]; - let nout: TNode = null; + let nout: zui_node_t = null; for (let n of canvas.nodes) { if (n.type == "OUTPUT_MATERIAL_PBR") { nout = n; @@ -76,7 +76,7 @@ class ImportFolder { } for (let n of canvas.nodes) { if (n.name == "RGB") { - Nodes.removeNode(n, canvas); + zui_remove_node(n, canvas); break; } } @@ -120,12 +120,12 @@ class ImportFolder { History.newMaterial(); } - static placeImageNode = (nodes: NodesRaw, canvas: TNodeCanvas, asset: string, ny: i32, to_id: i32, to_socket: i32) => { + static placeImageNode = (nodes: zui_nodes_t, canvas: zui_node_canvas_t, asset: string, ny: i32, to_id: i32, to_socket: i32) => { let n = NodesMaterial.createNode("TEX_IMAGE"); n.buttons[0].default_value = Base.getAssetIndex(asset); n.x = 72; n.y = ny; - let l: TNodeLink = { id: Nodes.getLinkId(canvas.links), from_id: n.id, from_socket: 0, to_id: to_id, to_socket: to_socket }; + let l: zui_node_link_t = { id: zui_get_link_id(canvas.links), from_id: n.id, from_socket: 0, to_id: to_id, to_socket: to_socket }; canvas.links.push(l); } } diff --git a/armorpaint/Sources/MakeMaterial.ts b/armorpaint/Sources/MakeMaterial.ts index bae903aba..3b8012206 100644 --- a/armorpaint/Sources/MakeMaterial.ts +++ b/armorpaint/Sources/MakeMaterial.ts @@ -86,7 +86,7 @@ class MakeMaterial { m._shader._contexts.push(scon); let mcon: material_context_t; - MaterialContext.create({ name: "mesh" + i, bind_textures: [] }, (self: material_context_t) => { mcon = self; }); + material_context_create({ name: "mesh" + i, bind_textures: [] }, (self: material_context_t) => { mcon = self; }); m.contexts.push(mcon); m._contexts.push(mcon); } @@ -144,7 +144,7 @@ class MakeMaterial { for (let i = 0; i < m._contexts.length; ++i) { if (m._contexts[i].name == "mesh") { - MaterialContext.create(mcon, (self: material_context_t) => { m._contexts[i] = self; }); + material_context_create(mcon, (self: material_context_t) => { m._contexts[i] = self; }); break; } } @@ -221,7 +221,7 @@ class MakeMaterial { scon._override_context = {}; scon._override_context.addressing = "repeat"; let mcon: material_context_t; - MaterialContext.create(tmcon, (_mcon: material_context_t) => { mcon = _mcon; }); + material_context_create(tmcon, (_mcon: material_context_t) => { mcon = _mcon; }); m._shader.contexts.push(scon); m._shader._contexts.push(scon); @@ -245,7 +245,7 @@ class MakeMaterial { } } - static traverseNodes = (nodes: TNode[], group: TNodeCanvas, parents: TNode[]) => { + static traverseNodes = (nodes: zui_node_t[], group: zui_node_canvas_t, parents: zui_node_t[]) => { for (let node of nodes) { MakeMaterial.bakeNodePreview(node, group, parents); if (node.type == "GROUP") { @@ -261,7 +261,7 @@ class MakeMaterial { } } - static bakeNodePreview = (node: TNode, group: TNodeCanvas, parents: TNode[]) => { + static bakeNodePreview = (node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]) => { if (node.type == "BLUR") { let id = ParserMaterial.node_name(node, parents); let image = Context.raw.nodePreviews.get(id); @@ -347,7 +347,7 @@ class MakeMaterial { } } - static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = null): { scon: shader_context_t, mcon: material_context_t } => { + static parseNodePreviewMaterial = (node: zui_node_t, group: zui_node_canvas_t = null, parents: zui_node_t[] = null): { scon: shader_context_t, mcon: material_context_t } => { if (node.outputs.length == 0) return null; let sdata: TMaterial = { name: "Material", canvas: UINodes.getCanvasMaterial() }; let mcon_raw: material_context_t = { name: "mesh", bind_textures: [] }; @@ -360,7 +360,7 @@ class MakeMaterial { }); if (compileError) return null; let mcon: material_context_t; - MaterialContext.create(mcon_raw, (_mcon: material_context_t) => { mcon = _mcon; }); + material_context_create(mcon_raw, (_mcon: material_context_t) => { mcon = _mcon; }); return { scon: scon, mcon: mcon }; } diff --git a/armorpaint/Sources/MakeMeshPreview.ts b/armorpaint/Sources/MakeMeshPreview.ts index d1f0df559..727521e99 100644 --- a/armorpaint/Sources/MakeMeshPreview.ts +++ b/armorpaint/Sources/MakeMeshPreview.ts @@ -21,7 +21,7 @@ class MakeMeshPreview { let pos = "pos"; ///if arm_skin - let skin = MeshData.getVArray(Context.raw.paintObject.data, "bone") != null; + let skin = mesh_data_get_vertex_array(Context.raw.paintObject.data, "bone") != null; if (skin) { pos = "spos"; NodeShaderContext.add_elem(con_mesh, "bone", 'short4norm'); diff --git a/armorpaint/Sources/MakeNodePreview.ts b/armorpaint/Sources/MakeNodePreview.ts index 6e49394c0..a8b7d903a 100644 --- a/armorpaint/Sources/MakeNodePreview.ts +++ b/armorpaint/Sources/MakeNodePreview.ts @@ -1,7 +1,7 @@ class MakeNodePreview { - static run = (data: TMaterial, matcon: material_context_t, node: TNode, group: TNodeCanvas, parents: TNode[]): NodeShaderContextRaw => { + static run = (data: TMaterial, matcon: material_context_t, node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]): NodeShaderContextRaw => { let context_id = "mesh"; let con_mesh = NodeShaderContext.create(data, { name: context_id, @@ -36,7 +36,7 @@ class MakeNodePreview { let links = ParserMaterial.links; let nodes = Context.raw.material.nodes; - let link: TNodeLink = { id: Nodes.getLinkId(links), from_id: node.id, from_socket: Context.raw.nodePreviewSocket, to_id: -1, to_socket: -1 }; + let link: zui_node_link_t = { id: zui_get_link_id(links), from_id: node.id, from_socket: Context.raw.nodePreviewSocket, to_id: -1, to_socket: -1 }; links.push(link); ParserMaterial.con = con_mesh; diff --git a/armorpaint/Sources/MakePaint.ts b/armorpaint/Sources/MakePaint.ts index 196634299..e3c55a5dd 100644 --- a/armorpaint/Sources/MakePaint.ts +++ b/armorpaint/Sources/MakePaint.ts @@ -33,7 +33,7 @@ class MakePaint { con_paint.data.color_writes_green = [true, true, true, true]; con_paint.data.color_writes_blue = [true, true, true, true]; con_paint.data.color_writes_alpha = [true, true, true, true]; - con_paint.allow_vcols = MeshData.getVArray(Context.raw.paintObject.data, 'col') != null; + con_paint.allow_vcols = mesh_data_get_vertex_array(Context.raw.paintObject.data, 'col') != null; let vert = NodeShaderContext.make_vert(con_paint); let frag = NodeShaderContext.make_frag(con_paint); diff --git a/armorpaint/Sources/NodesBrush.ts b/armorpaint/Sources/NodesBrush.ts index e5e81e833..0e04eb766 100644 --- a/armorpaint/Sources/NodesBrush.ts +++ b/armorpaint/Sources/NodesBrush.ts @@ -12,7 +12,7 @@ class NodesBrush { static categories = [_tr("Nodes")]; - static list: TNode[][] = [ + static list: zui_node_t[][] = [ [ // Category 0 TEX_IMAGE.def, InputNode.def, @@ -26,7 +26,7 @@ class NodesBrush { ] ]; - static createNode = (nodeType: string): TNode => { + static createNode = (nodeType: string): zui_node_t => { for (let c of NodesBrush.list) { for (let n of c) { if (n.type == nodeType) { diff --git a/armorpaint/Sources/RenderPathPaint.ts b/armorpaint/Sources/RenderPathPaint.ts index 5e36f6452..42ba6fb7b 100644 --- a/armorpaint/Sources/RenderPathPaint.ts +++ b/armorpaint/Sources/RenderPathPaint.ts @@ -7,8 +7,8 @@ class RenderPathPaint { static dilated = true; static initVoxels = true; // Bake AO static pushUndoLast: bool; - static painto: TMeshObject = null; - static planeo: TMeshObject = null; + static painto: mesh_object_t = null; + static planeo: mesh_object_t = null; static visibles: bool[] = null; static mergedObjectVisible = false; static savedFov = 0.0; @@ -121,14 +121,14 @@ class RenderPathPaint { render_path_bind_target("gbuffer0", "gbuffer0"); } - let mo: TMeshObject = scene_get_child(".ParticleEmitter").ext; + let mo: mesh_object_t = scene_get_child(".ParticleEmitter").ext; mo.base.visible = true; - MeshObject.render(mo,_render_path_current_g, "mesh",render_path_bind_params); + mesh_object_render(mo,_render_path_current_g, "mesh",render_path_bind_params); mo.base.visible = false; mo = scene_get_child(".Particle").ext; mo.base.visible = true; - MeshObject.render(mo,_render_path_current_g, "mesh",render_path_bind_params); + mesh_object_render(mo,_render_path_current_g, "mesh",render_path_bind_params); mo.base.visible = false; render_path_end(); } @@ -348,16 +348,16 @@ class RenderPathPaint { let materialContexts: material_context_t[] = []; let shaderContexts: shader_context_t[] = []; let mats = Project.paintObjects[0].materials; - MeshObject.getContexts(Project.paintObjects[0], "paint", mats, materialContexts, shaderContexts); + mesh_object_get_contexts(Project.paintObjects[0], "paint", mats, materialContexts, shaderContexts); let cc_context = shaderContexts[0]; - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g4_set_pipeline(cc_context._pipe_state); uniforms_set_context_consts(_render_path_current_g, cc_context,render_path_bind_params); uniforms_set_obj_consts(_render_path_current_g, cc_context, Project.paintObjects[0].base); uniforms_set_material_consts(_render_path_current_g, cc_context, materialContexts[0]); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); render_path_end(); ///end @@ -436,8 +436,8 @@ class RenderPathPaint { let _x = Context.raw.paintVec.x; let _y = Context.raw.paintVec.y; if (Context.raw.brushLocked) { - Context.raw.paintVec.x = (Context.raw.lockStartedX - App.x()) / App.w(); - Context.raw.paintVec.y = (Context.raw.lockStartedY - App.y()) / App.h(); + Context.raw.paintVec.x = (Context.raw.lockStartedX - app_x()) / app_w(); + Context.raw.paintVec.y = (Context.raw.lockStartedY - app_y()) / app_h(); } let _lastX = Context.raw.lastPaintVecX; let _lastY = Context.raw.lastPaintVecY; @@ -487,15 +487,15 @@ class RenderPathPaint { let mx = Context.raw.paintVec.x; let my = 1.0 - Context.raw.paintVec.y; if (Context.raw.brushLocked) { - mx = (Context.raw.lockStartedX - App.x()) / App.w(); - my = 1.0 - (Context.raw.lockStartedY - App.y()) / App.h(); + mx = (Context.raw.lockStartedX - app_x()) / app_w(); + my = 1.0 - (Context.raw.lockStartedY - app_y()) / app_h(); } let radius = decalMask ? Context.raw.brushDecalMaskRadius : Context.raw.brushRadius; RenderPathPaint.drawCursor(mx, my, Context.raw.brushNodesRadius * radius / 3.4); } static drawCursor = (mx: f32, my: f32, radius: f32, tintR = 1.0, tintG = 1.0, tintB = 1.0) => { - let plane: TMeshObject = scene_get_child(".Plane").ext; + let plane: mesh_object_t = scene_get_child(".Plane").ext; let geom = plane.data; let g =_render_path_frame_g; @@ -512,15 +512,15 @@ class RenderPathPaint { g4_set_float2(Base.cursorMouse, mx, my); g4_set_float2(Base.cursorTexStep, 1 / gbuffer0.width, 1 / gbuffer0.height); g4_set_float(Base.cursorRadius, radius); - let right = vec4_normalize(CameraObject.rightWorld(scene_camera)); + let right = vec4_normalize(camera_object_right_world(scene_camera)); g4_set_float3(Base.cursorCameraRight, right.x, right.y, right.z); g4_set_float3(Base.cursorTint, tintR, tintG, tintB); - g4_set_mat(Base.cursorVP, scene_camera.VP); + g4_set_mat(Base.cursorVP, scene_camera.vp); let helpMat = mat4_identity(); - mat4_get_inv(helpMat, scene_camera.VP); + mat4_get_inv(helpMat, scene_camera.vp); g4_set_mat(Base.cursorInvVP, helpMat); ///if (krom_metal || krom_vulkan) - g4_set_vertex_buffer(MeshData.get(geom, [{name: "tex", data: "short2norm"}])); + g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}])); ///else g4_set_vertex_buffer(geom._vertex_buffer); ///end @@ -716,10 +716,10 @@ class RenderPathPaint { RenderPathPaint.commandsPaint(); Context.raw.pdirty = 0; if (RenderPathPaint.pushUndoLast) History.paint(); - App.notifyOnInit(_renderFinal); + app_notify_on_init(_renderFinal); } let bakeType = Context.raw.bakeType as BakeType; - App.notifyOnInit(bakeType == BakeType.BakeDerivative ? _renderDeriv : _renderFinal); + app_notify_on_init(bakeType == BakeType.BakeDerivative ? _renderDeriv : _renderFinal); } } else if (Context.raw.bakeType == BakeType.BakeObjectID) { @@ -801,17 +801,17 @@ class RenderPathPaint { mat4_translate(m, 0, 0, 0.5); transform_set_matrix(cam.base.transform, m); cam.data.fov = Base.defaultFov; - CameraObject.buildProjection(cam); - CameraObject.buildMatrix(cam); + camera_object_build_projection(cam); + camera_object_build_matrix(cam); let tw = 0.95 * UIView2D.panScale; let tx = UIView2D.panX / UIView2D.ww; - let ty = UIView2D.panY / App.h(); + let ty = UIView2D.panY / app_h(); mat4_set_identity(m); mat4_scale(m, vec4_create(tw, tw, 1)); mat4_set_loc(m, vec4_create(tx, ty, 0)); let m2 = mat4_identity(); - mat4_get_inv(m2, scene_camera.VP); + mat4_get_inv(m2, scene_camera.vp); mat4_mult_mat(m, m2); let tiled = UIView2D.tiledShow; @@ -834,7 +834,7 @@ class RenderPathPaint { scale_pos: 1.5, scale_tex: 1.0 }; - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { let materials: material_data_t[] = scene_get_child(".Plane").ext.materials; let o = scene_add_mesh_object(md, materials); o.base.name = ".PlaneTiled"; @@ -868,8 +868,8 @@ class RenderPathPaint { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = RenderPathPaint.savedFov; Viewport.updateCameraType(Context.raw.cameraType); - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); RenderPathBase.drawGbuffer(); } diff --git a/armorpaint/Sources/SlotBrush.ts b/armorpaint/Sources/SlotBrush.ts index 15e6eca47..483e3f593 100644 --- a/armorpaint/Sources/SlotBrush.ts +++ b/armorpaint/Sources/SlotBrush.ts @@ -1,7 +1,7 @@ class SlotBrushRaw { - nodes = Nodes.create(); - canvas: TNodeCanvas; + nodes = zui_nodes_create(); + canvas: zui_node_canvas_t; image: image_t = null; // 200px imageIcon: image_t = null; // 50px previewReady = false; @@ -11,13 +11,13 @@ class SlotBrushRaw { class SlotBrush { static defaultCanvas: ArrayBuffer = null; - static create(c: TNodeCanvas = null): SlotBrushRaw { + static create(c: zui_node_canvas_t = null): SlotBrushRaw { let raw = new SlotBrushRaw(); for (let brush of Project.brushes) if (brush.id >= raw.id) raw.id = brush.id + 1; if (c == null) { if (SlotBrush.defaultCanvas == null) { // Synchronous - Data.getBlob("default_brush.arm", (b: ArrayBuffer) => { + data_get_blob("default_brush.arm", (b: ArrayBuffer) => { SlotBrush.defaultCanvas = b; }); } diff --git a/armorpaint/Sources/SlotMaterial.ts b/armorpaint/Sources/SlotMaterial.ts index 0acc12ece..c15edac2f 100644 --- a/armorpaint/Sources/SlotMaterial.ts +++ b/armorpaint/Sources/SlotMaterial.ts @@ -1,7 +1,7 @@ class SlotMaterialRaw { - nodes = Nodes.create(); - canvas: TNodeCanvas; + nodes = zui_nodes_create(); + canvas: zui_node_canvas_t; image: image_t = null; imageIcon: image_t = null; previewReady = false; @@ -22,7 +22,7 @@ class SlotMaterialRaw { class SlotMaterial { static defaultCanvas: ArrayBuffer = null; - static create(m: material_data_t = null, c: TNodeCanvas = null): SlotMaterialRaw { + static create(m: material_data_t = null, c: zui_node_canvas_t = null): SlotMaterialRaw { let raw = new SlotMaterialRaw(); for (let mat of Project.materials) if (mat.id >= raw.id) raw.id = mat.id + 1; raw.data = m; @@ -34,7 +34,7 @@ class SlotMaterial { if (c == null) { if (SlotMaterial.defaultCanvas == null) { // Synchronous - Data.getBlob("default_material.arm", (b: ArrayBuffer) => { + data_get_blob("default_material.arm", (b: ArrayBuffer) => { SlotMaterial.defaultCanvas = b; }); } diff --git a/armorpaint/Sources/TabLayers.ts b/armorpaint/Sources/TabLayers.ts index d60cb210a..09463689c 100644 --- a/armorpaint/Sources/TabLayers.ts +++ b/armorpaint/Sources/TabLayers.ts @@ -2,29 +2,29 @@ class TabLayers { static layerNameEdit = -1; - static layerNameHandle = Handle.create(); + static layerNameHandle = zui_handle_create(); static showContextMenu = false; - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW; mini ? TabLayers.drawMini(htab) : TabLayers.drawFull(htab); } - static drawMini = (htab: HandleRaw) => { + static drawMini = (htab: zui_handle_t) => { let ui = UIBase.ui; - Zui.setHoveredTabName(tr("Layers")); + zui_set_hovered_tab_name(tr("Layers")); let _ELEMENT_H = ui.t.ELEMENT_H; - ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / Zui.SCALE(ui)); + ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / zui_SCALE(ui)); - Zui.beginSticky(); - Zui.separator(5); + zui_begin_sticky(); + zui_separator(5); TabLayers.comboFilter(); TabLayers.button2dView(); TabLayers.buttonNew("+"); - Zui.endSticky(); + zui_end_sticky(); ui._y += 2; TabLayers.highlightOddLines(); @@ -33,17 +33,17 @@ class TabLayers { ui.t.ELEMENT_H = _ELEMENT_H; } - static drawFull = (htab: HandleRaw) => { + static drawFull = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Layers"))) { - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 2]); + if (zui_tab(htab, tr("Layers"))) { + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 2]); TabLayers.buttonNew(tr("New")); TabLayers.button2dView(); TabLayers.comboFilter(); - Zui.endSticky(); + zui_end_sticky(); ui._y += 2; TabLayers.highlightOddLines(); @@ -53,10 +53,10 @@ class TabLayers { static button2dView = () => { let ui = UIBase.ui; - if (Zui.button(tr("2D View"))) { + if (zui_button(tr("2D View"))) { UIBase.show2DView(View2DType.View2DLayer); } - else if (ui.isHovered) Zui.tooltip(tr("Show 2D View") + ` (${Config.keymap.toggle_2d_view})`); + else if (ui.is_hovered) zui_tooltip(tr("Show 2D View") + ` (${Config.keymap.toggle_2d_view})`); } static drawSlots = (mini: bool) => { @@ -71,18 +71,18 @@ class TabLayers { static highlightOddLines = () => { let ui = UIBase.ui; let step = ui.t.ELEMENT_H * 2; - let fullH = ui._windowH - UIBase.hwnds[0].scrollOffset; + let fullH = ui._window_h - UIBase.hwnds[0].scroll_offset; for (let i = 0; i < Math.floor(fullH / step); ++i) { if (i % 2 == 0) { - Zui.fill(0, i * step, (ui._w / Zui.SCALE(ui) - 2), step, ui.t.WINDOW_BG_COL - 0x00040404); + zui_fill(0, i * step, (ui._w / zui_SCALE(ui) - 2), step, ui.t.WINDOW_BG_COL - 0x00040404); } } } static buttonNew = (text: string) => { let ui = UIBase.ui; - if (Zui.button(text)) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(text)) { + UIMenu.draw((ui: zui_t) => { let l = Context.raw.layer; if (UIMenu.menuButton(ui, tr("Paint Layer"))) { Base.newLayer(); @@ -128,7 +128,7 @@ class TabLayers { let _init = () => { SlotLayer.toFillLayer(m); } - App.notifyOnInit(_init); + app_notify_on_init(_init); Context.raw.layerPreviewDirty = true; History.newFillMask(); Base.updateFillLayers(); @@ -160,9 +160,9 @@ class TabLayers { for (let p of Project.paintObjects) ar.push(p.base.name); let atlases = Project.getUsedAtlases(); if (atlases != null) for (let a of atlases) ar.push(a); - let filterHandle = Zui.handle("tablayers_0"); + let filterHandle = zui_handle("tablayers_0"); filterHandle.position = Context.raw.layerFilter; - Context.raw.layerFilter = Zui.combo(filterHandle, ar, tr("Filter"), false, Align.Left); + Context.raw.layerFilter = zui_combo(filterHandle, ar, tr("Filter"), false, Align.Left); if (filterHandle.changed) { for (let p of Project.paintObjects) { p.base.visible = Context.raw.layerFilter == 0 || p.base.name == ar[Context.raw.layerFilter] || Project.isAtlasObject(p); @@ -171,7 +171,7 @@ class TabLayers { UtilMesh.mergeMesh(); } else if (Context.raw.layerFilter > Project.paintObjects.length) { // Atlas - let visibles: TMeshObject[] = []; + let visibles: mesh_object_t[] = []; for (let p of Project.paintObjects) if (p.base.visible) visibles.push(p); UtilMesh.mergeMesh(visibles); } @@ -184,7 +184,7 @@ class TabLayers { } } - static remapLayerPointers = (nodes: TNode[], pointerMap: Map) => { + static remapLayerPointers = (nodes: zui_node_t[], pointerMap: Map) => { for (let n of nodes) { if (n.type == "LAYER" || n.type == "LAYER_MASK") { let i = n.buttons[0].default_value; @@ -231,10 +231,10 @@ class TabLayers { } let step = ui.t.ELEMENT_H; - let checkw = (ui._windowW / 100 * 8) / Zui.SCALE(ui); + let checkw = (ui._window_w / 100 * 8) / zui_SCALE(ui); // Highlight drag destination - let absy = ui._windowY + ui._y; + let absy = ui._window_y + ui._y; if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) { if (mouse_y > absy + step && mouse_y < absy + step * 3) { let down = Project.layers.indexOf(Base.dragLayer) >= i; @@ -246,14 +246,14 @@ class TabLayers { let nestedGroup = SlotLayer.isGroup(Base.dragLayer) && toGroup; if (!nestedGroup) { if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { - Zui.fill(checkw, step * 2, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, step * 2, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } } else if (i == Project.layers.length - 1 && mouse_y < absy + step) { Context.raw.dragDestination = Project.layers.length - 1; if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { - Zui.fill(checkw, 0, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } } @@ -261,12 +261,12 @@ class TabLayers { if (mouse_y > absy + step && mouse_y < absy + step * 3) { Context.raw.dragDestination = i; if (TabLayers.canDropNewLayer(i)) - Zui.fill(checkw, 2 * step, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 2 * step, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } else if (i == Project.layers.length - 1 && mouse_y < absy + step) { Context.raw.dragDestination = Project.layers.length; if (TabLayers.canDropNewLayer(Project.layers.length)) - Zui.fill(checkw, 0, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } @@ -282,15 +282,15 @@ class TabLayers { static drawLayerSlotMini = (l: SlotLayerRaw, i: i32) => { let ui = UIBase.ui; - Zui.row([1, 1]); + zui_row([1, 1]); let uix = ui._x; let uiy = ui._y; let state = TabLayers.drawLayerIcon(l, i, uix, uiy, true); TabLayers.handleLayerIconState(l, i, state, uix, uiy); - Zui.endElement(); + zui_end_element(); - ui._y += Zui.ELEMENT_H(ui); - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y += zui_ELEMENT_H(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); } static drawLayerSlotFull = (l: SlotLayerRaw, i: i32) => { @@ -300,16 +300,16 @@ class TabLayers { let hasPanel = SlotLayer.isGroup(l) || (SlotLayer.isLayer(l) && SlotLayer.getMasks(l, false) != null); if (hasPanel) { - Zui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); + zui_row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); } else { - Zui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100]); + zui_row([8 / 100, 16 / 100, 36 / 100, 30 / 100]); } // Draw eye icon let icons = Res.get("icons.k"); let r = Res.tile18(icons, l.visible ? 0 : 1, 0); - let center = (step / 2) * Zui.SCALE(ui); + let center = (step / 2) * zui_SCALE(ui); ui._x += 2; ui._y += 3; ui._y += center; @@ -317,7 +317,7 @@ class TabLayers { let parentHidden = l.parent != null && (!l.parent.visible || (l.parent.parent != null && !l.parent.parent.visible)); if (parentHidden) col -= 0x99000000; - if (Zui.image(icons, col, null, r.x, r.y, r.w, r.h) == State.Released) { + if (zui_image(icons, col, null, r.x, r.y, r.w, r.h) == State.Released) { TabLayers.layerToggleVisible(l); } ui._x -= 2; @@ -325,7 +325,7 @@ class TabLayers { ui._y -= center; ///if krom_opengl - ui.imageInvertY = l.fill_layer != null; + ui.image_invert_y = l.fill_layer != null; ///end let uix = ui._x; @@ -333,8 +333,8 @@ class TabLayers { ui._x += 2; ui._y += 3; if (l.parent != null) { - ui._x += 10 * Zui.SCALE(ui); - if (l.parent.parent != null) ui._x += 10 * Zui.SCALE(ui); + ui._x += 10 * zui_SCALE(ui); + if (l.parent.parent != null) ui._x += 10 * zui_SCALE(ui); } let state = TabLayers.drawLayerIcon(l, i, uix, uiy, false); @@ -343,11 +343,11 @@ class TabLayers { ui._y -= 3; if (Config.raw.touch_ui) { - ui._x += 12 * Zui.SCALE(ui); + ui._x += 12 * zui_SCALE(ui); } ///if krom_opengl - ui.imageInvertY = false; + ui.image_invert_y = false; ///end TabLayers.handleLayerIconState(l, i, state, uix, uiy); @@ -356,52 +356,52 @@ class TabLayers { ui._y += center; if (TabLayers.layerNameEdit == l.id) { TabLayers.layerNameHandle.text = l.name; - l.name = Zui.textInput(TabLayers.layerNameHandle); - if (ui.textSelectedHandle_ptr != TabLayers.layerNameHandle.ptr) TabLayers.layerNameEdit = -1; + l.name = zui_text_input(TabLayers.layerNameHandle); + if (ui.text_selected_handle_ptr != TabLayers.layerNameHandle.ptr) TabLayers.layerNameEdit = -1; } else { - if (ui.enabled && ui.inputEnabled && ui.comboSelectedHandle_ptr == null && - ui.inputX > ui._windowX + ui._x && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + (step * Zui.SCALE(ui)) * 2) { - if (ui.inputStarted) { + if (ui.enabled && ui.input_enabled && ui.combo_selected_handle_ptr == null && + ui.input_x > ui._window_x + ui._x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y + ui._y - center && ui.input_y < ui._window_y + ui._y - center + (step * zui_SCALE(ui)) * 2) { + if (ui.input_started) { Context.setLayer(l); - TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._windowX - 3), -(mouse_y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._window_x - 3), -(mouse_y - uiy - ui._window_y + 1)); } - else if (ui.inputReleasedR) { + else if (ui.input_released_r) { Context.setLayer(l); TabLayers.showContextMenu = true; } } - let state = Zui.text(l.name); + let state = zui_text(l.name); if (state == State.Released) { if (time_time() - Context.raw.selectTime < 0.25) { TabLayers.layerNameEdit = l.id; TabLayers.layerNameHandle.text = l.name; - Zui.startTextEdit(TabLayers.layerNameHandle); + zui_start_text_edit(TabLayers.layerNameHandle); } Context.raw.selectTime = time_time(); } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && TabLayers.canDelete(Context.raw.layer)) { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && TabLayers.canDelete(Context.raw.layer)) { + ui.is_delete_down = false; let _init = () => { TabLayers.deleteLayer(Context.raw.layer); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } } ui._y -= center; if (l.parent != null) { - ui._x -= 10 * Zui.SCALE(ui); - if (l.parent.parent != null) ui._x -= 10 * Zui.SCALE(ui); + ui._x -= 10 * zui_SCALE(ui); + if (l.parent.parent != null) ui._x -= 10 * zui_SCALE(ui); } if (SlotLayer.isGroup(l)) { - Zui.endElement(); + zui_end_element(); } else { if (SlotLayer.isMask(l)) { @@ -417,43 +417,43 @@ class TabLayers { if (hasPanel) { ui._y += center; - let layerPanel = Zui.nest(Zui.handle("tablayers_1"), l.id); + let layerPanel = zui_nest(zui_handle("tablayers_1"), l.id); layerPanel.selected = l.show_panel; - l.show_panel = Zui.panel(layerPanel, "", true, false, false); + l.show_panel = zui_panel(layerPanel, "", true, false, false); ui._y -= center; } if (SlotLayer.isGroup(l) || SlotLayer.isMask(l)) { - ui._y -= Zui.ELEMENT_OFFSET(ui); - Zui.endElement(); + ui._y -= zui_ELEMENT_OFFSET(ui); + zui_end_element(); } else { - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); - Zui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); - Zui.endElement(); - Zui.endElement(); - Zui.endElement(); + zui_row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); + zui_end_element(); + zui_end_element(); + zui_end_element(); if (Config.raw.touch_ui) { - ui._x += 12 * Zui.SCALE(ui); + ui._x += 12 * zui_SCALE(ui); } TabLayers.comboObject(ui, l); - Zui.endElement(); + zui_end_element(); } - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); } - static comboObject = (ui: ZuiRaw, l: SlotLayerRaw, label = false): HandleRaw => { + static comboObject = (ui: zui_t, l: SlotLayerRaw, label = false): zui_handle_t => { let ar = [tr("Shared")]; for (let p of Project.paintObjects) ar.push(p.base.name); let atlases = Project.getUsedAtlases(); if (atlases != null) for (let a of atlases) ar.push(a); - let objectHandle = Zui.nest(Zui.handle("tablayers_2"), l.id); + let objectHandle = zui_nest(zui_handle("tablayers_2"), l.id); objectHandle.position = l.objectMask; - l.objectMask = Zui.combo(objectHandle, ar, tr("Object"), label, Align.Left); + l.objectMask = zui_combo(objectHandle, ar, tr("Object"), label, Align.Left); if (objectHandle.changed) { Context.setLayer(l); MakeMaterial.parseMeshMaterial(); @@ -463,7 +463,7 @@ class TabLayers { SlotLayer.clear(l); Base.updateFillLayers(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } else { Base.setObjectMask(); @@ -472,10 +472,10 @@ class TabLayers { return objectHandle; } - static comboBlending = (ui: ZuiRaw, l: SlotLayerRaw, label = false): HandleRaw => { - let blendingHandle = Zui.nest(Zui.handle("tablayers_3"), l.id); + static comboBlending = (ui: zui_t, l: SlotLayerRaw, label = false): zui_handle_t => { + let blendingHandle = zui_nest(zui_handle("tablayers_3"), l.id); blendingHandle.position = l.blending; - Zui.combo(blendingHandle, [ + zui_combo(blendingHandle, [ tr("Mix"), tr("Darken"), tr("Multiply"), @@ -515,15 +515,15 @@ class TabLayers { let step = ui.t.ELEMENT_H; // Separator line - Zui.fill(0, 0, (ui._w / Zui.SCALE(ui) - 2), 1 * Zui.SCALE(ui), ui.t.SEPARATOR_COL); + zui_fill(0, 0, (ui._w / zui_SCALE(ui) - 2), 1 * zui_SCALE(ui), ui.t.SEPARATOR_COL); // Highlight selected if (Context.raw.layer == l) { if (mini) { - Zui.rect(1, -step * 2, ui._w / Zui.SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.t.HIGHLIGHT_COL, 3); + zui_rect(1, -step * 2, ui._w / zui_SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.t.HIGHLIGHT_COL, 3); } else { - Zui.rect(1, -step * 2 - 1, ui._w / Zui.SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.t.HIGHLIGHT_COL, 2); + zui_rect(1, -step * 2 - 1, ui._w / zui_SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.t.HIGHLIGHT_COL, 2); } } } @@ -541,27 +541,27 @@ class TabLayers { TabLayers.showContextMenu = false; // Layer preview tooltip - if (ui.isHovered && texpaint_preview != null) { + if (ui.is_hovered && texpaint_preview != null) { if (SlotLayer.isMask(l)) { TabLayers.makeMaskPreviewRgba32(l); - Zui.tooltipImage(Context.raw.maskPreviewRgba32); + zui_tooltip_image(Context.raw.maskPreviewRgba32); } else { - Zui.tooltipImage(texpaint_preview); + zui_tooltip_image(texpaint_preview); } - if (i < 9) Zui.tooltip(l.name + " - (" + Config.keymap.select_layer + " " + (i + 1) + ")"); - else Zui.tooltip(l.name); + if (i < 9) zui_tooltip(l.name + " - (" + Config.keymap.select_layer + " " + (i + 1) + ")"); + else zui_tooltip(l.name); } // Show context menu - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.setLayer(l); TabLayers.showContextMenu = true; } if (state == State.Started) { Context.setLayer(l); - TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._windowX - 3), -(mouse_y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._window_x - 3), -(mouse_y - uiy - ui._window_y + 1)); } else if (state == State.Released) { if (time_time() - Context.raw.selectTime < 0.2) { @@ -577,10 +577,10 @@ class TabLayers { static drawLayerIcon = (l: SlotLayerRaw, i: i32, uix: f32, uiy: f32, mini: bool) => { let ui = UIBase.ui; let icons = Res.get("icons.k"); - let iconH = (Zui.ELEMENT_H(ui) - (mini ? 2 : 3)) * 2; + let iconH = (zui_ELEMENT_H(ui) - (mini ? 2 : 3)) * 2; - if (mini && Zui.SCALE(ui) > 1) { - ui._x -= 1 * Zui.SCALE(ui); + if (mini && zui_SCALE(ui) > 1) { + ui._x -= 1 * zui_SCALE(ui); } if (l.parent != null) { @@ -607,8 +607,8 @@ class TabLayers { let _x = ui._x; let _y = ui._y; let _w = ui._w; - Zui.image(icons, 0xffffffff, iconH, r.x, r.y, r.w, r.h); - ui.curRatio--; + zui_image(icons, 0xffffffff, iconH, r.x, r.y, r.w, r.h); + ui.cur_ratio--; ui._x = _x; ui._y = _y; ui._w = _w; @@ -621,19 +621,19 @@ class TabLayers { Krom.setInt(UIView2D.channelLocation, 1); } - let state = Zui.image(icon, 0xffffffff, iconH); + let state = zui_image(icon, 0xffffffff, iconH); if (l.fill_layer == null && SlotLayer.isMask(l)) { ui.g.pipeline = null; } // Draw layer numbers when selecting a layer via keyboard shortcut - let isTyping = ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping; + let isTyping = ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing; if (!isTyping) { if (i < 9 && Operator.shortcut(Config.keymap.select_layer, ShortcutType.ShortcutDown)) { let number = String(i + 1) ; - let width = font_width(ui.font, ui.fontSize, number) + 10; - let height = font_height(ui.font, ui.fontSize); + let width = font_width(ui.font, ui.font_size, number) + 10; + let height = font_height(ui.font, ui.font_size); ui.g.color = ui.t.TEXT_COL; g2_fill_rect(uix, uiy, width, height); ui.g.color = ui.t.ACCENT_COL; @@ -647,7 +647,7 @@ class TabLayers { let folderClosed = Res.tile50(icons, 2, 1); let folderOpen = Res.tile50(icons, 8, 1); let folder = l.show_panel ? folderOpen : folderClosed; - return Zui.image(icons, ui.t.LABEL_COL - 0x00202020, iconH, folder.x, folder.y, folder.w, folder.h); + return zui_image(icons, ui.t.LABEL_COL - 0x00202020, iconH, folder.x, folder.y, folder.w, folder.h); } } @@ -678,13 +678,13 @@ class TabLayers { } let menuElements = SlotLayer.isGroup(l) ? 7 : (19 + add); - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (mini) { - let visibleHandle = Zui.handle("tablayers_4"); + let visibleHandle = zui_handle("tablayers_4"); visibleHandle.selected = l.visible; UIMenu.menuFill(ui); - Zui.check(visibleHandle, tr("Visible")); + zui_check(visibleHandle, tr("Visible")); if (visibleHandle.changed) { TabLayers.layerToggleVisible(l); UIMenu.keepOpen = true; @@ -730,14 +730,14 @@ class TabLayers { SlotLayer.isLayer(l) ? History.toFillLayer() : History.toFillMask(); SlotLayer.toFillLayer(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (l.fill_layer != null && UIMenu.menuButton(ui, toPaintString)) { let _init = () => { SlotLayer.isLayer(l) ? History.toPaintLayer() : History.toPaintMask(); SlotLayer.toPaintLayer(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } } @@ -746,7 +746,7 @@ class TabLayers { let _init = () => { TabLayers.deleteLayer(Context.raw.layer); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } ui.enabled = true; @@ -767,7 +767,7 @@ class TabLayers { Context.raw.layer = l; } } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (SlotLayer.isMask(l) && l.fill_layer == null && UIMenu.menuButton(ui, tr("Invert"))) { let _init = () => { @@ -775,7 +775,7 @@ class TabLayers { History.invertMask(); SlotLayer.invertMask(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (SlotLayer.isMask(l) && UIMenu.menuButton(ui, tr("Apply"))) { let _init = () => { @@ -786,13 +786,13 @@ class TabLayers { MakeMaterial.parseMeshMaterial(); Context.raw.layersPreviewDirty = true; } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (SlotLayer.isGroup(l) && UIMenu.menuButton(ui, tr("Merge Group"))) { let _init = () => { Base.mergeGroup(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } ui.enabled = TabLayers.canMergeDown(l); if (UIMenu.menuButton(ui, tr("Merge Down"))) { @@ -802,7 +802,7 @@ class TabLayers { Base.mergeDown(); if (Context.raw.layer.fill_layer != null) SlotLayer.toPaintLayer(Context.raw.layer); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } ui.enabled = true; if (UIMenu.menuButton(ui, tr("Duplicate"))) { @@ -811,16 +811,16 @@ class TabLayers { History.duplicateLayer(); Base.duplicateLayer(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - let layerOpacHandle = Zui.nest(Zui.handle("tablayers_5"), l.id); + let layerOpacHandle = zui_nest(zui_handle("tablayers_5"), l.id); layerOpacHandle.value = l.maskOpacity; - Zui.slider(layerOpacHandle, tr("Opacity"), 0.0, 1.0, true); + zui_slider(layerOpacHandle, tr("Opacity"), 0.0, 1.0, true); if (layerOpacHandle.changed) { - if (ui.inputStarted) History.layerOpacity(); + if (ui.input_started) History.layerOpacity(); l.maskOpacity = layerOpacHandle.value; MakeMaterial.parseMeshMaterial(); UIMenu.keepOpen = true; @@ -837,7 +837,7 @@ class TabLayers { ///end let _y = ui._y; Base.resHandle.value = Base.resHandle.position; - Base.resHandle.position = Math.floor(Zui.slider(Base.resHandle, ar[Base.resHandle.position], 0, ar.length - 1, false, 1, false, Align.Left, false)); + Base.resHandle.position = Math.floor(zui_slider(Base.resHandle, ar[Base.resHandle.position], 0, ar.length - 1, false, 1, false, Align.Left, false)); if (Base.resHandle.changed) { UIMenu.keepOpen = true; } @@ -845,18 +845,18 @@ class TabLayers { Base.onLayersResized(); } ui._y = _y; - Zui.drawString(ui.g, tr("Res"), null, 0, Align.Right); - Zui.endElement(); + zui_draw_string(ui.g, tr("Res"), null, 0, Align.Right); + zui_end_element(); UIMenu.menuFill(ui); UIMenu.menuAlign(ui); ///if (krom_android || krom_ios) - Zui.inlineRadio(Base.bitsHandle, ["8bit"]); + zui_inline_radio(Base.bitsHandle, ["8bit"]); ///else - Zui.inlineRadio(Base.bitsHandle, ["8bit", "16bit", "32bit"]); + zui_inline_radio(Base.bitsHandle, ["8bit", "16bit", "32bit"]); ///end if (Base.bitsHandle.changed) { - App.notifyOnInit(Base.setLayerBits); + app_notify_on_init(Base.setLayerBits); UIMenu.keepOpen = true; } } @@ -864,24 +864,24 @@ class TabLayers { if (l.fill_layer != null) { UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - let scaleHandle = Zui.nest(Zui.handle("tablayers_6"), l.id); + let scaleHandle = zui_nest(zui_handle("tablayers_6"), l.id); scaleHandle.value = l.scale; - l.scale = Zui.slider(scaleHandle, tr("UV Scale"), 0.0, 5.0, true); + l.scale = zui_slider(scaleHandle, tr("UV Scale"), 0.0, 5.0, true); if (scaleHandle.changed) { Context.setMaterial(l.fill_layer); Context.setLayer(l); let _init = () => { Base.updateFillLayers(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIMenu.keepOpen = true; } UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - let angleHandle = Zui.nest(Zui.handle("tablayers_7"), l.id); + let angleHandle = zui_nest(zui_handle("tablayers_7"), l.id); angleHandle.value = l.angle; - l.angle = Zui.slider(angleHandle, tr("Angle"), 0.0, 360, true, 1); + l.angle = zui_slider(angleHandle, tr("Angle"), 0.0, 360, true, 1); if (angleHandle.changed) { Context.setMaterial(l.fill_layer); Context.setLayer(l); @@ -889,15 +889,15 @@ class TabLayers { let _init = () => { Base.updateFillLayers(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIMenu.keepOpen = true; } UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - let uvTypeHandle = Zui.nest(Zui.handle("tablayers_8"), l.id); + let uvTypeHandle = zui_nest(zui_handle("tablayers_8"), l.id); uvTypeHandle.position = l.uvType; - l.uvType = Zui.inlineRadio(uvTypeHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], Align.Left); + l.uvType = zui_inline_radio(uvTypeHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], Align.Left); if (uvTypeHandle.changed) { Context.setMaterial(l.fill_layer); Context.setLayer(l); @@ -905,23 +905,23 @@ class TabLayers { let _init = () => { Base.updateFillLayers(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIMenu.keepOpen = true; } } if (!SlotLayer.isGroup(l)) { - let baseHandle = Zui.nest(Zui.handle("tablayers_9"), l.id); - let opacHandle = Zui.nest(Zui.handle("tablayers_10"), l.id); - let norHandle = Zui.nest(Zui.handle("tablayers_11"), l.id); - let norBlendHandle = Zui.nest(Zui.handle("tablayers_12"), l.id); - let occHandle = Zui.nest(Zui.handle("tablayers_13"), l.id); - let roughHandle = Zui.nest(Zui.handle("tablayers_14"), l.id); - let metHandle = Zui.nest(Zui.handle("tablayers_15"), l.id); - let heightHandle = Zui.nest(Zui.handle("tablayers_16"), l.id); - let heightBlendHandle = Zui.nest(Zui.handle("tablayers_17"), l.id); - let emisHandle = Zui.nest(Zui.handle("tablayers_18"), l.id); - let subsHandle = Zui.nest(Zui.handle("tablayers_19"), l.id); + let baseHandle = zui_nest(zui_handle("tablayers_9"), l.id); + let opacHandle = zui_nest(zui_handle("tablayers_10"), l.id); + let norHandle = zui_nest(zui_handle("tablayers_11"), l.id); + let norBlendHandle = zui_nest(zui_handle("tablayers_12"), l.id); + let occHandle = zui_nest(zui_handle("tablayers_13"), l.id); + let roughHandle = zui_nest(zui_handle("tablayers_14"), l.id); + let metHandle = zui_nest(zui_handle("tablayers_15"), l.id); + let heightHandle = zui_nest(zui_handle("tablayers_16"), l.id); + let heightBlendHandle = zui_nest(zui_handle("tablayers_17"), l.id); + let emisHandle = zui_nest(zui_handle("tablayers_18"), l.id); + let subsHandle = zui_nest(zui_handle("tablayers_19"), l.id); baseHandle.selected = l.paintBase; opacHandle.selected = l.paintOpac; norHandle.selected = l.paintNor; @@ -934,27 +934,27 @@ class TabLayers { emisHandle.selected = l.paintEmis; subsHandle.selected = l.paintSubs; UIMenu.menuFill(ui); - l.paintBase = Zui.check(baseHandle, tr("Base Color")); + l.paintBase = zui_check(baseHandle, tr("Base Color")); UIMenu.menuFill(ui); - l.paintOpac = Zui.check(opacHandle, tr("Opacity")); + l.paintOpac = zui_check(opacHandle, tr("Opacity")); UIMenu.menuFill(ui); - l.paintNor = Zui.check(norHandle, tr("Normal")); + l.paintNor = zui_check(norHandle, tr("Normal")); UIMenu.menuFill(ui); - l.paintNorBlend = Zui.check(norBlendHandle, tr("Normal Blending")); + l.paintNorBlend = zui_check(norBlendHandle, tr("Normal Blending")); UIMenu.menuFill(ui); - l.paintOcc = Zui.check(occHandle, tr("Occlusion")); + l.paintOcc = zui_check(occHandle, tr("Occlusion")); UIMenu.menuFill(ui); - l.paintRough = Zui.check(roughHandle, tr("Roughness")); + l.paintRough = zui_check(roughHandle, tr("Roughness")); UIMenu.menuFill(ui); - l.paintMet = Zui.check(metHandle, tr("Metallic")); + l.paintMet = zui_check(metHandle, tr("Metallic")); UIMenu.menuFill(ui); - l.paintHeight = Zui.check(heightHandle, tr("Height")); + l.paintHeight = zui_check(heightHandle, tr("Height")); UIMenu.menuFill(ui); - l.paintHeightBlend = Zui.check(heightBlendHandle, tr("Height Blending")); + l.paintHeightBlend = zui_check(heightBlendHandle, tr("Height Blending")); UIMenu.menuFill(ui); - l.paintEmis = Zui.check(emisHandle, tr("Emission")); + l.paintEmis = zui_check(emisHandle, tr("Emission")); UIMenu.menuFill(ui); - l.paintSubs = Zui.check(subsHandle, tr("Subsurface")); + l.paintSubs = zui_check(subsHandle, tr("Subsurface")); if (baseHandle.changed || opacHandle.changed || norHandle.changed || @@ -981,7 +981,7 @@ class TabLayers { // Convert from R8 to RGBA32 for tooltip display if (Context.raw.maskPreviewLast != l) { Context.raw.maskPreviewLast = l; - App.notifyOnInit(() => { + app_notify_on_init(() => { g2_begin(Context.raw.maskPreviewRgba32.g2); Context.raw.maskPreviewRgba32.g2.pipeline = UIView2D.pipe; g4_set_int(UIView2D.channelLocation, 1); diff --git a/armorpaint/Sources/nodes/BrushOutputNode.ts b/armorpaint/Sources/nodes/BrushOutputNode.ts index 4e1fb26f1..368937f4b 100644 --- a/armorpaint/Sources/nodes/BrushOutputNode.ts +++ b/armorpaint/Sources/nodes/BrushOutputNode.ts @@ -104,7 +104,7 @@ class BrushOutputNode extends LogicNode { !fillLayer && !groupLayer && (SlotLayer.isVisible(Context.raw.layer) || Context.raw.paint2d) && - !UIBase.ui.isHovered && + !UIBase.ui.is_hovered && !Base.isDragging && !Base.isResizing && !Base.isScrolling() && diff --git a/armorpaint/Sources/nodes/InputNode.ts b/armorpaint/Sources/nodes/InputNode.ts index 789f2b2cb..40b8d742e 100644 --- a/armorpaint/Sources/nodes/InputNode.ts +++ b/armorpaint/Sources/nodes/InputNode.ts @@ -20,7 +20,7 @@ class InputNode extends LogicNode { if (!InputNode.registered) { InputNode.registered = true; - App.notifyOnUpdate(this.update); + app_notify_on_update(this.update); } } @@ -37,20 +37,20 @@ class InputNode extends LogicNode { Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) || decalMask); - let paintX = mouse_view_x() / App.w(); - let paintY = mouse_view_y() / App.h(); + let paintX = mouse_view_x() / app_w(); + let paintY = mouse_view_y() / app_h(); if (mouse_started()) { - InputNode.startX = mouse_view_x() / App.w(); - InputNode.startY = mouse_view_y() / App.h(); + InputNode.startX = mouse_view_x() / app_w(); + InputNode.startY = mouse_view_y() / app_h(); } if (pen_down()) { - paintX = pen_view_x() / App.w(); - paintY = pen_view_y() / App.h(); + paintX = pen_view_x() / app_w(); + paintY = pen_view_y() / app_h(); } if (pen_started()) { - InputNode.startX = pen_view_x() / App.w(); - InputNode.startY = pen_view_y() / App.h(); + InputNode.startX = pen_view_x() / app_w(); + InputNode.startY = pen_view_y() / app_h(); } if (Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown)) { @@ -90,8 +90,8 @@ class InputNode extends LogicNode { } if (Context.raw.brushLazyRadius > 0) { - let v1 = vec4_create(Context.raw.brushLazyX * App.w(), Context.raw.brushLazyY * App.h(), 0.0); - let v2 = vec4_create(InputNode.coords.x * App.w(), InputNode.coords.y * App.h(), 0.0); + let v1 = vec4_create(Context.raw.brushLazyX * app_w(), Context.raw.brushLazyY * app_h(), 0.0); + let v2 = vec4_create(InputNode.coords.x * app_w(), InputNode.coords.y * app_h(), 0.0); let d = vec4_dist(v1, v2); let r = Context.raw.brushLazyRadius * 85; if (d > r) { @@ -101,8 +101,8 @@ class InputNode extends LogicNode { vec4_mult(v3, 1.0 - Context.raw.brushLazyStep); vec4_mult(v3, r); vec4_add_vecs(v2, v1, v3); - InputNode.coords.x = v2.x / App.w(); - InputNode.coords.y = v2.y / App.h(); + InputNode.coords.x = v2.x / app_w(); + InputNode.coords.y = v2.y / app_h(); // Parse brush inputs once on next draw Context.raw.painted = -1; } @@ -123,7 +123,7 @@ class InputNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Input"), type: "InputNode", diff --git a/armorpaint/Sources/nodes/TEX_IMAGE.ts b/armorpaint/Sources/nodes/TEX_IMAGE.ts index d50fc555c..1cb3d94c7 100644 --- a/armorpaint/Sources/nodes/TEX_IMAGE.ts +++ b/armorpaint/Sources/nodes/TEX_IMAGE.ts @@ -13,7 +13,7 @@ class TEX_IMAGE extends LogicNode { else done(this.file + ".a"); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Image Texture"), type: "TEX_IMAGE", diff --git a/armorsculpt/Sources/ExportObj.ts b/armorsculpt/Sources/ExportObj.ts index a67fc8bb4..7897fbcd8 100644 --- a/armorsculpt/Sources/ExportObj.ts +++ b/armorsculpt/Sources/ExportObj.ts @@ -7,7 +7,7 @@ class ExportObj { } } - static run = (path: string, paintObjects: TMeshObject[], applyDisplacement = false) => { + static run = (path: string, paintObjects: mesh_object_t[], applyDisplacement = false) => { let o: i32[] = []; ExportObj.writeString(o, "# armorsculpt.org\n"); diff --git a/armorsculpt/Sources/ImportMesh.ts b/armorsculpt/Sources/ImportMesh.ts index 27eca86c6..9c252c863 100644 --- a/armorsculpt/Sources/ImportMesh.ts +++ b/armorsculpt/Sources/ImportMesh.ts @@ -34,8 +34,8 @@ class ImportMesh { static finishImport = () => { if (Context.raw.mergedObject != null) { - MeshObject.remove(Context.raw.mergedObject); - Data.deleteMesh(Context.raw.mergedObject.data._handle); + mesh_object_remove(Context.raw.mergedObject); + data_delete_mesh(Context.raw.mergedObject.data._handle); Context.raw.mergedObject = null; } @@ -79,19 +79,19 @@ class ImportMesh { let raw = ImportMesh.rawMesh(mesh); if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm", padding: 1 }); - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { Context.raw.paintObject = Context.mainObject(); Context.selectPaintObject(Context.mainObject()); for (let i = 0; i < Project.paintObjects.length; ++i) { let p = Project.paintObjects[i]; if (p == Context.raw.paintObject) continue; - Data.deleteMesh(p.data._handle); - MeshObject.remove(p); + data_delete_mesh(p.data._handle); + mesh_object_remove(p); } let handle = Context.raw.paintObject.data._handle; if (handle != "SceneSphere" && handle != "ScenePlane") { - Data.deleteMesh(handle); + data_delete_mesh(handle); } if (ImportMesh.clearLayers) { @@ -100,23 +100,23 @@ class ImportMesh { SlotLayer.unload(l); } Base.newLayer(false); - App.notifyOnInit(Base.initLayers); + app_notify_on_init(Base.initLayers); History.reset(); } - MeshObject.setData(Context.raw.paintObject, md); + mesh_object_set_data(Context.raw.paintObject, md); Context.raw.paintObject.base.name = mesh.name; Project.paintObjects = [Context.raw.paintObject]; md._handle = raw.name; - Data.cachedMeshes.set(md._handle, md); + data_cached_meshes.set(md._handle, md); Context.raw.ddirty = 4; UIBase.hwnds[TabArea.TabSidebar0].redraws = 2; UIBase.hwnds[TabArea.TabSidebar1].redraws = 2; // Wait for addMesh calls to finish - App.notifyOnInit(ImportMesh.finishImport); + app_notify_on_init(ImportMesh.finishImport); Base.notifyOnNextFrame(() => { let f32 = new Float32Array(Config.getTextureResX() * Config.getTextureResY() * 4); @@ -147,7 +147,7 @@ class ImportMesh { let raw = ImportMesh.rawMesh(mesh); if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm", padding: 1 }); - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base); object.base.name = mesh.base.name; @@ -158,14 +158,14 @@ class ImportMesh { if (p.base.name == object.base.name) { p.base.name += ".001"; p.data._handle += ".001"; - Data.cachedMeshes.set(p.data._handle, p.data); + data_cached_meshes.set(p.data._handle, p.data); } } Project.paintObjects.push(object); md._handle = raw.name; - Data.cachedMeshes.set(md._handle, md); + data_cached_meshes.set(md._handle, md); Context.raw.ddirty = 4; UIBase.hwnds[TabArea.TabSidebar0].redraws = 2; diff --git a/armorsculpt/Sources/MakeMaterial.ts b/armorsculpt/Sources/MakeMaterial.ts index d09571737..8c6de914b 100644 --- a/armorsculpt/Sources/MakeMaterial.ts +++ b/armorsculpt/Sources/MakeMaterial.ts @@ -86,7 +86,7 @@ class MakeMaterial { m._shader._contexts.push(scon); let mcon: material_context_t; - MaterialContext.create({ name: "mesh" + i, bind_textures: [] }, (self: material_context_t) => { mcon = self; }); + material_context_create({ name: "mesh" + i, bind_textures: [] }, (self: material_context_t) => { mcon = self; }); m.contexts.push(mcon); m._contexts.push(mcon); } @@ -139,7 +139,7 @@ class MakeMaterial { for (let i = 0; i < m.contexts.length; ++i) { if (m.contexts[i].name == "mesh") { - MaterialContext.create(mcon, (self: material_context_t) => { m.contexts[i] = self; }); + material_context_create(mcon, (self: material_context_t) => { m.contexts[i] = self; }); break; } } @@ -216,7 +216,7 @@ class MakeMaterial { scon2._override_context = {}; scon2._override_context.addressing = "repeat"; let mcon3: material_context_t; - MaterialContext.create(mcon2, (_mcon: material_context_t) => { mcon3 = _mcon; }); + material_context_create(mcon2, (_mcon: material_context_t) => { mcon3 = _mcon; }); m._shader.contexts.push(scon2); m._shader._contexts.push(scon2); @@ -240,7 +240,7 @@ class MakeMaterial { } } - static traverseNodes = (nodes: TNode[], group: TNodeCanvas, parents: TNode[]) => { + static traverseNodes = (nodes: zui_node_t[], group: zui_node_canvas_t, parents: zui_node_t[]) => { for (let node of nodes) { MakeMaterial.bakeNodePreview(node, group, parents); if (node.type == "GROUP") { @@ -256,7 +256,7 @@ class MakeMaterial { } } - static bakeNodePreview = (node: TNode, group: TNodeCanvas, parents: TNode[]) => { + static bakeNodePreview = (node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]) => { if (node.type == "BLUR") { let id = ParserMaterial.node_name(node, parents); let image = Context.raw.nodePreviews.get(id); @@ -291,7 +291,7 @@ class MakeMaterial { } } - static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = null): { scon: shader_context_t, mcon: material_context_t } => { + static parseNodePreviewMaterial = (node: zui_node_t, group: zui_node_canvas_t = null, parents: zui_node_t[] = null): { scon: shader_context_t, mcon: material_context_t } => { if (node.outputs.length == 0) return null; let sdata: TMaterial = { name: "Material", canvas: UINodes.getCanvasMaterial() }; let mcon_raw: material_context_t = { name: "mesh", bind_textures: [] }; @@ -304,7 +304,7 @@ class MakeMaterial { }); if (compileError) return null; let mcon: material_context_t; - MaterialContext.create(mcon_raw, (_mcon: material_context_t) => { mcon = _mcon; }); + material_context_create(mcon_raw, (_mcon: material_context_t) => { mcon = _mcon; }); return { scon: scon, mcon: mcon }; } diff --git a/armorsculpt/Sources/MakeMeshPreview.ts b/armorsculpt/Sources/MakeMeshPreview.ts index 5773710b1..7411cadbd 100644 --- a/armorsculpt/Sources/MakeMeshPreview.ts +++ b/armorsculpt/Sources/MakeMeshPreview.ts @@ -21,7 +21,7 @@ class MakeMeshPreview { let pos = "pos"; ///if arm_skin - let skin = MeshData.getVArray(Context.raw.paintObject.data, "bone") != null; + let skin = mesh_data_get_vertex_array(Context.raw.paintObject.data, "bone") != null; if (skin) { pos = "spos"; NodeShaderContext.add_elem(con_mesh, "bone", 'short4norm'); diff --git a/armorsculpt/Sources/MakeSculpt.ts b/armorsculpt/Sources/MakeSculpt.ts index 416ec4d99..32cc2c721 100644 --- a/armorsculpt/Sources/MakeSculpt.ts +++ b/armorsculpt/Sources/MakeSculpt.ts @@ -17,7 +17,7 @@ class MakeSculpt { con_paint.data.color_writes_green = [true, true, true, true]; con_paint.data.color_writes_blue = [true, true, true, true]; con_paint.data.color_writes_alpha = [true, true, true, true]; - con_paint.allow_vcols = MeshData.getVArray(Context.raw.paintObject.data, "col") != null; + con_paint.allow_vcols = mesh_data_get_vertex_array(Context.raw.paintObject.data, "col") != null; let vert = NodeShaderContext.make_vert(con_paint); let frag = NodeShaderContext.make_frag(con_paint); diff --git a/armorsculpt/Sources/TabLayers.ts b/armorsculpt/Sources/TabLayers.ts index 88abe0ccf..861d1c2e2 100644 --- a/armorsculpt/Sources/TabLayers.ts +++ b/armorsculpt/Sources/TabLayers.ts @@ -2,28 +2,28 @@ class TabLayers { static layerNameEdit = -1; - static layerNameHandle = Handle.create(); + static layerNameHandle = zui_handle_create(); static showContextMenu = false; - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW; mini ? TabLayers.drawMini(htab) : TabLayers.drawFull(htab); } - static drawMini = (htab: HandleRaw) => { + static drawMini = (htab: zui_handle_t) => { let ui = UIBase.ui; - Zui.setHoveredTabName(tr("Layers")); + zui_set_hovered_tab_name(tr("Layers")); let _ELEMENT_H = ui.t.ELEMENT_H; - ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / Zui.SCALE(ui)); + ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / zui_SCALE(ui)); - Zui.beginSticky(); - Zui.separator(5); + zui_begin_sticky(); + zui_separator(5); TabLayers.comboFilter(); TabLayers.buttonNew("+"); - Zui.endSticky(); + zui_end_sticky(); ui._y += 2; TabLayers.highlightOddLines(); @@ -32,16 +32,16 @@ class TabLayers { ui.t.ELEMENT_H = _ELEMENT_H; } - static drawFull = (htab: HandleRaw) => { + static drawFull = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Layers"))) { - Zui.beginSticky(); - Zui.row([1 / 4, 3 / 4]); + if (zui_tab(htab, tr("Layers"))) { + zui_begin_sticky(); + zui_row([1 / 4, 3 / 4]); TabLayers.buttonNew(tr("New")); TabLayers.comboFilter(); - Zui.endSticky(); + zui_end_sticky(); ui._y += 2; TabLayers.highlightOddLines(); @@ -61,18 +61,18 @@ class TabLayers { static highlightOddLines = () => { let ui = UIBase.ui; let step = ui.t.ELEMENT_H * 2; - let fullH = ui._windowH - UIBase.hwnds[0].scrollOffset; + let fullH = ui._window_h - UIBase.hwnds[0].scroll_offset; for (let i = 0; i < Math.floor(fullH / step); ++i) { if (i % 2 == 0) { - Zui.fill(0, i * step, (ui._w / Zui.SCALE(ui) - 2), step, ui.t.WINDOW_BG_COL - 0x00040404); + zui_fill(0, i * step, (ui._w / zui_SCALE(ui) - 2), step, ui.t.WINDOW_BG_COL - 0x00040404); } } } static buttonNew = (text: string) => { let ui = UIBase.ui; - if (Zui.button(text)) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(text)) { + UIMenu.draw((ui: zui_t) => { let l = Context.raw.layer; if (UIMenu.menuButton(ui, tr("Paint Layer"))) { Base.newLayer(); @@ -85,12 +85,12 @@ class TabLayers { static comboFilter = () => { let ui = UIBase.ui; let ar = [tr("All")]; - let filterHandle = Zui.handle("tablayers_0"); + let filterHandle = zui_handle("tablayers_0"); filterHandle.position = Context.raw.layerFilter; - Context.raw.layerFilter = Zui.combo(filterHandle, ar, tr("Filter"), false, Align.Left); + Context.raw.layerFilter = zui_combo(filterHandle, ar, tr("Filter"), false, Align.Left); } - static remapLayerPointers = (nodes: TNode[], pointerMap: Map) => { + static remapLayerPointers = (nodes: zui_node_t[], pointerMap: Map) => { for (let n of nodes) { if (n.type == "LAYER" || n.type == "LAYER_MASK") { let i = n.buttons[0].default_value; @@ -137,10 +137,10 @@ class TabLayers { } let step = ui.t.ELEMENT_H; - let checkw = (ui._windowW / 100 * 8) / Zui.SCALE(ui); + let checkw = (ui._window_w / 100 * 8) / zui_SCALE(ui); // Highlight drag destination - let absy = ui._windowY + ui._y; + let absy = ui._window_y + ui._y; if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) { if (mouse_y > absy + step && mouse_y < absy + step * 3) { let down = Project.layers.indexOf(Base.dragLayer) >= i; @@ -152,14 +152,14 @@ class TabLayers { let nestedGroup = SlotLayer.isGroup(Base.dragLayer) && toGroup; if (!nestedGroup) { if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { - Zui.fill(checkw, step * 2, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, step * 2, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } } else if (i == Project.layers.length - 1 && mouse_y < absy + step) { Context.raw.dragDestination = Project.layers.length - 1; if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { - Zui.fill(checkw, 0, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } } @@ -167,12 +167,12 @@ class TabLayers { if (mouse_y > absy + step && mouse_y < absy + step * 3) { Context.raw.dragDestination = i; if (TabLayers.canDropNewLayer(i)) - Zui.fill(checkw, 2 * step, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 2 * step, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } else if (i == Project.layers.length - 1 && mouse_y < absy + step) { Context.raw.dragDestination = Project.layers.length; if (TabLayers.canDropNewLayer(Project.layers.length)) - Zui.fill(checkw, 0, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); } } @@ -188,14 +188,14 @@ class TabLayers { static drawLayerSlotMini = (l: SlotLayerRaw, i: i32) => { let ui = UIBase.ui; - Zui.row([1, 1]); + zui_row([1, 1]); let uix = ui._x; let uiy = ui._y; - Zui.endElement(); - Zui.endElement(); + zui_end_element(); + zui_end_element(); - ui._y += Zui.ELEMENT_H(ui); - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y += zui_ELEMENT_H(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); } static drawLayerSlotFull = (l: SlotLayerRaw, i: i32) => { @@ -205,16 +205,16 @@ class TabLayers { let hasPanel = SlotLayer.isGroup(l) || (SlotLayer.isLayer(l) && SlotLayer.getMasks(l, false) != null); if (hasPanel) { - Zui.row([8 / 100, 52 / 100, 30 / 100, 10 / 100]); + zui_row([8 / 100, 52 / 100, 30 / 100, 10 / 100]); } else { - Zui.row([8 / 100, 52 / 100, 30 / 100]); + zui_row([8 / 100, 52 / 100, 30 / 100]); } // Draw eye icon let icons = Res.get("icons.k"); let r = Res.tile18(icons, l.visible ? 0 : 1, 0); - let center = (step / 2) * Zui.SCALE(ui); + let center = (step / 2) * zui_SCALE(ui); ui._x += 2; ui._y += 3; ui._y += center; @@ -222,7 +222,7 @@ class TabLayers { let parentHidden = l.parent != null && (!l.parent.visible || (l.parent.parent != null && !l.parent.parent.visible)); if (parentHidden) col -= 0x99000000; - if (Zui.image(icons, col, null, r.x, r.y, r.w, r.h) == State.Released) { + if (zui_image(icons, col, null, r.x, r.y, r.w, r.h) == State.Released) { TabLayers.layerToggleVisible(l); } ui._x -= 2; @@ -236,35 +236,35 @@ class TabLayers { ui._y += center; if (TabLayers.layerNameEdit == l.id) { TabLayers.layerNameHandle.text = l.name; - l.name = Zui.textInput(TabLayers.layerNameHandle); - if (ui.textSelectedHandle_ptr != TabLayers.layerNameHandle.ptr) TabLayers.layerNameEdit = -1; + l.name = zui_text_input(TabLayers.layerNameHandle); + if (ui.text_selected_handle_ptr != TabLayers.layerNameHandle.ptr) TabLayers.layerNameEdit = -1; } else { - if (ui.enabled && ui.inputEnabled && ui.comboSelectedHandle_ptr == null && - ui.inputX > ui._windowX + ui._x && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + (step * Zui.SCALE(ui)) * 2) { - if (ui.inputStarted) { + if (ui.enabled && ui.input_enabled && ui.combo_selected_handle_ptr == null && + ui.input_x > ui._window_x + ui._x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y + ui._y - center && ui.input_y < ui._window_y + ui._y - center + (step * zui_SCALE(ui)) * 2) { + if (ui.input_started) { Context.setLayer(l); - TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._windowX - 3), -(mouse_y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._window_x - 3), -(mouse_y - uiy - ui._window_y + 1)); } - else if (ui.inputReleased) { + else if (ui.input_released) { if (time_time() - Context.raw.selectTime > 0.2) { Context.raw.selectTime = time_time(); } } - else if (ui.inputReleasedR) { + else if (ui.input_released_r) { Context.setLayer(l); TabLayers.showContextMenu = true; } } - let state = Zui.text(l.name); + let state = zui_text(l.name); if (state == State.Released) { let td = time_time() - Context.raw.selectTime; if (td < 0.2 && td > 0.0) { TabLayers.layerNameEdit = l.id; TabLayers.layerNameHandle.text = l.name; - Zui.startTextEdit(TabLayers.layerNameHandle); + zui_start_text_edit(TabLayers.layerNameHandle); } } @@ -275,18 +275,18 @@ class TabLayers { // let _init() = () => { // deleteLayer(Context.raw.layer); // } - // App.notifyOnInit(_init); + // app_notify_on_init(_init); // } } ui._y -= center; if (l.parent != null) { - ui._x -= 10 * Zui.SCALE(ui); - if (l.parent.parent != null) ui._x -= 10 * Zui.SCALE(ui); + ui._x -= 10 * zui_SCALE(ui); + if (l.parent.parent != null) ui._x -= 10 * zui_SCALE(ui); } if (SlotLayer.isGroup(l)) { - Zui.endElement(); + zui_end_element(); } else { if (SlotLayer.isMask(l)) { @@ -294,7 +294,7 @@ class TabLayers { } // comboBlending(ui, l); - Zui.endElement(); + zui_end_element(); if (SlotLayer.isMask(l)) { ui._y -= center; @@ -303,43 +303,43 @@ class TabLayers { if (hasPanel) { ui._y += center; - let layerPanel = Zui.nest(Zui.handle("tablayers_1"), l.id); + let layerPanel = zui_nest(zui_handle("tablayers_1"), l.id); layerPanel.selected = l.show_panel; - l.show_panel = Zui.panel(layerPanel, "", true, false, false); + l.show_panel = zui_panel(layerPanel, "", true, false, false); ui._y -= center; } if (SlotLayer.isGroup(l) || SlotLayer.isMask(l)) { - ui._y -= Zui.ELEMENT_OFFSET(ui); - Zui.endElement(); + ui._y -= zui_ELEMENT_OFFSET(ui); + zui_end_element(); } else { - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); - Zui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); - Zui.endElement(); - Zui.endElement(); - Zui.endElement(); + zui_row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]); + zui_end_element(); + zui_end_element(); + zui_end_element(); if (Config.raw.touch_ui) { - ui._x += 12 * Zui.SCALE(ui); + ui._x += 12 * zui_SCALE(ui); } ui._y -= center; TabLayers.comboObject(ui, l); ui._y += center; - Zui.endElement(); + zui_end_element(); } - ui._y -= Zui.ELEMENT_OFFSET(ui); + ui._y -= zui_ELEMENT_OFFSET(ui); } - static comboObject = (ui: ZuiRaw, l: SlotLayerRaw, label = false): HandleRaw => { + static comboObject = (ui: zui_t, l: SlotLayerRaw, label = false): zui_handle_t => { let ar = [tr("Shared")]; - let objectHandle = Zui.nest(Zui.handle("tablayers_2"), l.id); + let objectHandle = zui_nest(zui_handle("tablayers_2"), l.id); objectHandle.position = l.objectMask; - l.objectMask = Zui.combo(objectHandle, ar, tr("Object"), label, Align.Left); + l.objectMask = zui_combo(objectHandle, ar, tr("Object"), label, Align.Left); return objectHandle; } @@ -354,15 +354,15 @@ class TabLayers { let step = ui.t.ELEMENT_H; // Separator line - Zui.fill(0, 0, (ui._w / Zui.SCALE(ui) - 2), 1 * Zui.SCALE(ui), ui.t.SEPARATOR_COL); + zui_fill(0, 0, (ui._w / zui_SCALE(ui) - 2), 1 * zui_SCALE(ui), ui.t.SEPARATOR_COL); // Highlight selected if (Context.raw.layer == l) { if (mini) { - Zui.rect(1, -step * 2, ui._w / Zui.SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.t.HIGHLIGHT_COL, 3); + zui_rect(1, -step * 2, ui._w / zui_SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.t.HIGHLIGHT_COL, 3); } else { - Zui.rect(1, -step * 2 - 1, ui._w / Zui.SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.t.HIGHLIGHT_COL, 2); + zui_rect(1, -step * 2 - 1, ui._w / zui_SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.t.HIGHLIGHT_COL, 2); } } } diff --git a/armorsculpt/Sources/nodes/BrushOutputNode.ts b/armorsculpt/Sources/nodes/BrushOutputNode.ts index f8176d261..7f0465b70 100644 --- a/armorsculpt/Sources/nodes/BrushOutputNode.ts +++ b/armorsculpt/Sources/nodes/BrushOutputNode.ts @@ -98,7 +98,7 @@ class BrushOutputNode extends LogicNode { !fillLayer && !groupLayer && (SlotLayer.isVisible(Context.raw.layer) || Context.raw.paint2d) && - !UIBase.ui.isHovered && + !UIBase.ui.is_hovered && !Base.isDragging && !Base.isResizing && !Base.isScrolling() && diff --git a/base/Sources/Args.ts b/base/Sources/Args.ts index ecf688be1..c0eeaf6ca 100644 --- a/base/Sources/Args.ts +++ b/base/Sources/Args.ts @@ -81,7 +81,7 @@ class Args { static run = () => { if (Args.useArgs) { - App.notifyOnInit(() => { + app_notify_on_init(() => { if (Project.filepath != "") { ImportArm.runProject(Project.filepath); } @@ -145,13 +145,13 @@ class Args { file = "export_presets/" + BoxExport.files[BoxExport.files.indexOf(f)] + ".json"; } - Data.getBlob(file, (blob: ArrayBuffer) => { + data_get_blob(file, (blob: ArrayBuffer) => { BoxExport.preset = JSON.parse(sys_buffer_to_string(blob)); - Data.deleteBlob("export_presets/" + file); + data_delete_blob("export_presets/" + file); }); // Export queue - App.notifyOnInit(() => { + app_notify_on_init(() => { ExportTexture.run(Args.exportTexturesPath); }); } diff --git a/base/Sources/Base.ts b/base/Sources/Base.ts index 03ef80349..97f2a93c1 100644 --- a/base/Sources/Base.ts +++ b/base/Sources/Base.ts @@ -17,16 +17,16 @@ class Base { static dropX = 0.0; static dropY = 0.0; static font: font_t = null; - static theme: Theme; + static theme: theme_t; static colorWheel: image_t; static colorWheelGradient: image_t; - static uiBox: ZuiRaw; - static uiMenu: ZuiRaw; + static uiBox: zui_t; + static uiMenu: zui_t; static defaultElementW = 100; static defaultElementH = 28; static defaultFontSize = 13; - static resHandle = Handle.create(); - static bitsHandle = Handle.create(); + static resHandle = zui_handle_create(); + static bitsHandle = zui_handle_create(); static dropPaths: string[] = []; static appx = 0; static appy = 0; @@ -138,9 +138,9 @@ class Base { Krom.setSaveAndQuitCallback(Base.saveAndQuitCallback); - Data.getFont("font.ttf", (f: font_t) => { - Data.getImage("color_wheel.k", (imageColorWheel: image_t) => { - Data.getImage("color_wheel_gradient.k", (imageColorWheelGradient: image_t) => { + data_get_font("font.ttf", (f: font_t) => { + data_get_image("color_wheel.k", (imageColorWheel: image_t) => { + data_get_image("color_wheel_gradient.k", (imageColorWheelGradient: image_t) => { Base.font = f; Config.loadTheme(Config.raw.theme, false); @@ -161,10 +161,10 @@ class Base { Base.colorWheel = imageColorWheel; Base.colorWheelGradient = imageColorWheelGradient; - Nodes.enumTexts = Base.enumTexts; - Nodes.tr = tr; - Base.uiBox = Zui.create({ theme: Base.theme, font: f, scaleFactor: Config.raw.window_scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient }); - Base.uiMenu = Zui.create({ theme: Base.theme, font: f, scaleFactor: Config.raw.window_scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient }); + zui_set_enum_texts(Base.enumTexts); + zui_tr = tr; + Base.uiBox = zui_create({ theme: Base.theme, font: f, scaleFactor: Config.raw.window_scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient }); + Base.uiMenu = zui_create({ theme: Base.theme, font: f, scaleFactor: Config.raw.window_scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient }); Base.defaultElementH = Base.uiMenu.t.ELEMENT_H; // Init plugins @@ -185,18 +185,18 @@ class Base { RandomNode.setSeed(Math.floor(time_time() * 4294967295)); ///end - App.notifyOnUpdate(Base.update); - App.notifyOnRender2D(UIView2D.render); - App.notifyOnUpdate(UIView2D.update); + app_notify_on_update(Base.update); + app_notify_on_render_2d(UIView2D.render); + app_notify_on_update(UIView2D.update); ///if (is_paint || is_sculpt) - App.notifyOnRender2D(UIBase.renderCursor); + app_notify_on_render_2d(UIBase.renderCursor); ///end - App.notifyOnUpdate(UINodes.update); - App.notifyOnRender2D(UINodes.render); - App.notifyOnUpdate(UIBase.update); - App.notifyOnRender2D(UIBase.render); - App.notifyOnUpdate(Camera.update); - App.notifyOnRender2D(Base.render); + app_notify_on_update(UINodes.update); + app_notify_on_render_2d(UINodes.render); + app_notify_on_update(UIBase.update); + app_notify_on_render_2d(UIBase.render); + app_notify_on_update(Camera.update); + app_notify_on_render_2d(Base.render); ///if (is_paint || is_sculpt) Base.appx = UIToolbar.toolbarw; @@ -209,7 +209,7 @@ class Base { if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) Base.appy += UIHeader.headerh; let cam = scene_camera; cam.data.fov = Math.floor(cam.data.fov * 100) / 100; - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); Args.run(); @@ -386,10 +386,10 @@ class Base { let cam = scene_camera; if (cam.data.ortho != null) { - cam.data.ortho[2] = -2 * (App.h() / App.w()); - cam.data.ortho[3] = 2 * (App.h() / App.w()); + cam.data.ortho[2] = -2 * (app_h() / app_w()); + cam.data.ortho[3] = 2 * (app_h() / app_w()); } - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); if (Context.raw.cameraType == CameraType.CameraOrthographic) { Viewport.updateCameraType(Context.raw.cameraType); @@ -478,7 +478,7 @@ class Base { ///end } // Disable touch scrolling while dragging is active - Zui.touchScroll = !Base.isDragging; + zui_set_touch_scroll(!Base.isDragging); } if (hasDrag && (mouse_movement_x != 0 || mouse_movement_y != 0)) { @@ -580,7 +580,7 @@ class Base { ///if krom_windows let isPicker = Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial; let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText; - Zui.alwaysRedrawWindow = !Context.raw.cacheDraws || + zui_set_always_redraw_window(!Context.raw.cacheDraws || UIMenu.show || UIBox.show || Base.isDragging || @@ -588,11 +588,11 @@ class Base { decal || UIView2D.show || !Config.raw.brush_3d || - Context.raw.frame < 3; + Context.raw.frame < 3); ///end ///end - if (Zui.alwaysRedrawWindow && Context.raw.ddirty < 0) Context.raw.ddirty = 0; + if (zui_always_redraw_window() && Context.raw.ddirty < 0) Context.raw.ddirty = 0; } ///if (is_paint || is_sculpt) @@ -745,10 +745,10 @@ class Base { let img = Base.getDragImage(); ///if (is_paint || is_sculpt) - let scaleFactor = Zui.SCALE(UIBase.ui); + let scaleFactor = zui_SCALE(UIBase.ui); ///end ///if is_lab - let scaleFactor = Zui.SCALE(Base.uiBox); + let scaleFactor = zui_SCALE(Base.uiBox); ///end let size = (Base.dragSize == -1 ? 50 : Base.dragSize) * scaleFactor; @@ -827,16 +827,16 @@ class Base { static notifyOnNextFrame = (f: ()=>void) => { let _render = (_: any) => { - App.notifyOnInit(() => { + app_notify_on_init(() => { let _update = () => { - App.notifyOnInit(f); - App.removeUpdate(_update); + app_notify_on_init(f); + app_remove_update(_update); } - App.notifyOnUpdate(_update); + app_notify_on_update(_update); }); - App.removeRender(_render); + app_remove_render(_render); } - App.notifyOnRender(_render); + app_notify_on_render(_render); } static toggleFullscreen = () => { @@ -857,16 +857,16 @@ class Base { } static isScrolling = (): bool => { - for (let ui of Base.getUIs()) if (ui.isScrolling) return true; + for (let ui of Base.getUIs()) if (ui.is_scrolling) return true; return false; } static isComboSelected = (): bool => { - for (let ui of Base.getUIs()) if (ui.comboSelectedHandle_ptr != null) return true; + for (let ui of Base.getUIs()) if (ui.combo_selected_handle_ptr != null) return true; return false; } - static getUIs = (): ZuiRaw[] => { + static getUIs = (): zui_t[] => { return [Base.uiBox, Base.uiMenu, UIBase.ui, UINodes.ui, UIView2D.ui]; } @@ -887,7 +887,7 @@ class Base { static redrawConsole = () => { let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (UIBase.ui != null && statush > UIStatus.defaultStatusH * Zui.SCALE(UIBase.ui)) { + if (UIBase.ui != null && statush > UIStatus.defaultStatusH * zui_SCALE(UIBase.ui)) { UIBase.hwnds[TabArea.TabStatus].redraws = 2; } } @@ -904,14 +904,14 @@ class Base { ///end ///if krom_ios - show2d ? Math.floor((App.w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.473) : Math.floor(App.w() * 0.473), // LayoutNodesW + show2d ? Math.floor((app_w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.473) : Math.floor(app_w() * 0.473), // LayoutNodesW ///elseif krom_android - show2d ? Math.floor((App.w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.473) : Math.floor(App.w() * 0.473), + show2d ? Math.floor((app_w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.473) : Math.floor(app_w() * 0.473), ///else - show2d ? Math.floor((App.w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.515) : Math.floor(App.w() * 0.515), // Align with ui header controls + show2d ? Math.floor((app_w() + raw.layout[LayoutSize.LayoutNodesW]) * 0.515) : Math.floor(app_w() * 0.515), // Align with ui header controls ///end - Math.floor(App.h() / 2), // LayoutNodesH + Math.floor(app_h() / 2), // LayoutNodesH Math.floor(UIStatus.defaultStatusH * raw.window_scale), // LayoutStatusH ///if (krom_android || krom_ios) @@ -1597,7 +1597,7 @@ class Base { if (Base.pipeMerge == null) Base.makePipe(); Base.makeTempImg(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g2_begin(Base.tempImage.g2, false); // Copy to temp Base.tempImage.g2.pipeline = Base.pipeCopy; @@ -1622,8 +1622,8 @@ class Base { g4_set_tex(Base.texaMergeMask, Base.tempImage); g4_set_float(Base.opacMergeMask, SlotLayer.getOpacity(l1)); g4_set_int(Base.blendingMergeMask, l1.blending); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1638,8 +1638,8 @@ class Base { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, l1.blending); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1660,8 +1660,8 @@ class Base { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, l1.paintNorBlend ? -2 : -1); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1691,7 +1691,7 @@ class Base { Base.makeTempImg(); Base.makeExportImg(); if (Base.pipeMerge == null) Base.makePipe(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); let empty = render_path_render_targets.get("empty_white").image; // Clear export layer @@ -1741,8 +1741,8 @@ class Base { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, layers.length > 1 ? l1.blending : 0); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1763,8 +1763,8 @@ class Base { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, l1.paintNorBlend ? -2 : -1); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1817,8 +1817,8 @@ class Base { g4_set_tex(Base.texa, empty); g4_set_float(Base.opac, 1.0); g4_set_int(Base.blending, -4); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1840,13 +1840,13 @@ class Base { g2_end(Base.tempImage.g2); // Apply mask - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g4_begin(l.texpaint.g4); g4_set_pipeline(Base.pipeApplyMask); g4_set_tex(Base.tex0Mask, Base.tempImage); g4_set_tex(Base.texaMask, m.texpaint); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -1860,8 +1860,8 @@ class Base { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, i1maskOpacity); g4_set_int(Base.blending, i1blending); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -2045,7 +2045,7 @@ class Base { Context.raw.layer.parent = below.parent; } } - if (clear) App.notifyOnInit(() => { SlotLayer.clear(l); }); + if (clear) app_notify_on_init(() => { SlotLayer.clear(l); }); Context.raw.layerPreviewDirty = true; return l; } @@ -2056,7 +2056,7 @@ class Base { if (position == -1) position = Project.layers.indexOf(parent); Project.layers.splice(position, 0, l); Context.setLayer(l); - if (clear) App.notifyOnInit(() => { SlotLayer.clear(l); }); + if (clear) app_notify_on_init(() => { SlotLayer.clear(l); }); Context.raw.layerPreviewDirty = true; return l; } @@ -2079,7 +2079,7 @@ class Base { History.toFillLayer(); SlotLayer.toFillLayer(l); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } static createImageMask = (asset: TAsset) => { @@ -2102,11 +2102,11 @@ class Base { l.objectMask = Context.raw.layerFilter; SlotLayer.clear(l, baseColor, null, occlusion, roughness, metallic); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } static onLayersResized = () => { - App.notifyOnInit(() => { + app_notify_on_init(() => { Base.resizeLayers(); let _layer = Context.raw.layer; let _material = Context.raw.material; @@ -2141,7 +2141,7 @@ class Base { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); if (nodes.nodesSelectedId.length > 0) { - let node = Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]); + let node = zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]); let brushNode = ParserLogic.getLogicNode(node); if (brushNode != null && brushNode.getCachedImage() != null) { texpaint = brushNode.getCachedImage(); diff --git a/base/Sources/BoxExport.ts b/base/Sources/BoxExport.ts index 4d3105236..310ac26bc 100644 --- a/base/Sources/BoxExport.ts +++ b/base/Sources/BoxExport.ts @@ -1,12 +1,12 @@ class BoxExport { - static htab = Handle.create(); + static htab = zui_handle_create(); static files: string[] = null; - static exportMeshHandle = Handle.create(); + static exportMeshHandle = zui_handle_create(); ///if (is_paint || is_lab) - static hpreset = Handle.create(); + static hpreset = zui_handle_create(); static preset: TExportPreset = null; static channels = ["base_r", "base_g", "base_b", "height", "metal", "nor_r", "nor_g", "nor_g_directx", "nor_b", "occ", "opac", "rough", "smooth", "emis", "subs", "0.0", "1.0"]; static colorSpaces = ["linear", "srgb"]; @@ -14,7 +14,7 @@ class BoxExport { ///if (is_paint || is_lab) static showTextures = () => { - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { if (BoxExport.files == null) { BoxExport.fetchPresets(); @@ -41,7 +41,7 @@ class BoxExport { ///if is_paint static showBakeMaterial = () => { - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { if (BoxExport.files == null) { BoxExport.fetchPresets(); @@ -60,25 +60,25 @@ class BoxExport { ///end ///if (is_paint || is_lab) - static tabExportTextures = (ui: ZuiRaw, title: string, bakeMaterial = false) => { + static tabExportTextures = (ui: zui_t, title: string, bakeMaterial = false) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(BoxExport.htab, title, tabVertical)) { + if (zui_tab(BoxExport.htab, title, tabVertical)) { - Zui.row([0.5, 0.5]); + zui_row([0.5, 0.5]); ///if is_paint ///if (krom_android || krom_ios) - Zui.combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K"], tr("Resolution"), true); + zui_combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K"], tr("Resolution"), true); ///else - Zui.combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"], tr("Resolution"), true); + zui_combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"], tr("Resolution"), true); ///end ///end ///if is_lab ///if (krom_android || krom_ios) - Zui.combo(Base.resHandle, ["2K", "4K"], tr("Resolution"), true); + zui_combo(Base.resHandle, ["2K", "4K"], tr("Resolution"), true); ///else - Zui.combo(Base.resHandle, ["2K", "4K", "8K", "16K"], tr("Resolution"), true); + zui_combo(Base.resHandle, ["2K", "4K", "8K", "16K"], tr("Resolution"), true); ///end ///end @@ -87,52 +87,52 @@ class BoxExport { } ///if (is_lab || krom_android || krom_ios) - Zui.combo(Base.bitsHandle, ["8bit"], tr("Color"), true); + zui_combo(Base.bitsHandle, ["8bit"], tr("Color"), true); ///else - Zui.combo(Base.bitsHandle, ["8bit", "16bit", "32bit"], tr("Color"), true); + zui_combo(Base.bitsHandle, ["8bit", "16bit", "32bit"], tr("Color"), true); ///end ///if is_paint if (Base.bitsHandle.changed) { - App.notifyOnInit(Base.setLayerBits); + app_notify_on_init(Base.setLayerBits); } ///end - Zui.row([0.5, 0.5]); + zui_row([0.5, 0.5]); if (Base.bitsHandle.position == TextureBits.Bits8) { - Context.raw.formatType = Zui.combo(Zui.handle("boxexport_0", { position: Context.raw.formatType }), ["png", "jpg"], tr("Format"), true); + Context.raw.formatType = zui_combo(zui_handle("boxexport_0", { position: Context.raw.formatType }), ["png", "jpg"], tr("Format"), true); } else { - Context.raw.formatType = Zui.combo(Zui.handle("boxexport_1", { position: Context.raw.formatType }), ["exr"], tr("Format"), true); + Context.raw.formatType = zui_combo(zui_handle("boxexport_1", { position: Context.raw.formatType }), ["exr"], tr("Format"), true); } ui.enabled = Context.raw.formatType == TextureLdrFormat.FormatJpg && Base.bitsHandle.position == TextureBits.Bits8; - Context.raw.formatQuality = Zui.slider(Zui.handle("boxexport_2", { value: Context.raw.formatQuality }), tr("Quality"), 0.0, 100.0, true, 1); + Context.raw.formatQuality = zui_slider(zui_handle("boxexport_2", { value: Context.raw.formatQuality }), tr("Quality"), 0.0, 100.0, true, 1); ui.enabled = true; ///if is_paint - Zui.row([0.5, 0.5]); + zui_row([0.5, 0.5]); ui.enabled = !bakeMaterial; - let layersExportHandle = Zui.handle("boxexport_3"); + let layersExportHandle = zui_handle("boxexport_3"); layersExportHandle.position = Context.raw.layersExport; - Context.raw.layersExport = Zui.combo(layersExportHandle, [tr("Visible"), tr("Selected"), tr("Per Object"), tr("Per Udim Tile")], tr("Layers"), true); + Context.raw.layersExport = zui_combo(layersExportHandle, [tr("Visible"), tr("Selected"), tr("Per Object"), tr("Per Udim Tile")], tr("Layers"), true); ui.enabled = true; ///end - Zui.combo(BoxExport.hpreset, BoxExport.files, tr("Preset"), true); + zui_combo(BoxExport.hpreset, BoxExport.files, tr("Preset"), true); if (BoxExport.hpreset.changed) BoxExport.preset = null; - let layersDestinationHandle = Zui.handle("boxexport_4"); + let layersDestinationHandle = zui_handle("boxexport_4"); layersDestinationHandle.position = Context.raw.layersDestination; - Context.raw.layersDestination = Zui.combo(layersDestinationHandle, [tr("Disk"), tr("Packed")], tr("Destination"), true); + Context.raw.layersDestination = zui_combo(layersDestinationHandle, [tr("Disk"), tr("Packed")], tr("Destination"), true); - Zui.endElement(); + zui_end_element(); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIBox.hide(); if (Context.raw.layersDestination == ExportDestination.DestinationPacked) { Context.raw.textureExportPath = "/"; @@ -144,7 +144,7 @@ class BoxExport { ExportTexture.run(Context.raw.textureExportPath); ///end } - App.notifyOnInit(_init); + app_notify_on_init(_init); } else { let filters = Base.bitsHandle.position != TextureBits.Bits8 ? "exr" : Context.raw.formatType == TextureLdrFormat.FormatPng ? "png" : "jpg"; @@ -159,7 +159,7 @@ class BoxExport { ExportTexture.run(Context.raw.textureExportPath); ///end } - App.notifyOnInit(_init); + app_notify_on_init(_init); } ///if (krom_android || krom_ios) Base.notifyOnNextFrame(() => { @@ -172,25 +172,25 @@ class BoxExport { }); } } - if (ui.isHovered) Zui.tooltip(tr("Export texture files") + ` (${Config.keymap.file_export_textures})`); + if (ui.is_hovered) zui_tooltip(tr("Export texture files") + ` (${Config.keymap.file_export_textures})`); } } - static tabPresets = (ui: ZuiRaw) => { + static tabPresets = (ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(BoxExport.htab, tr("Presets"), tabVertical)) { - Zui.row([3 / 5, 1 / 5, 1 / 5]); + if (zui_tab(BoxExport.htab, tr("Presets"), tabVertical)) { + zui_row([3 / 5, 1 / 5, 1 / 5]); - Zui.combo(BoxExport.hpreset, BoxExport.files, tr("Preset")); + zui_combo(BoxExport.hpreset, BoxExport.files, tr("Preset")); if (BoxExport.hpreset.changed) BoxExport.preset = null; - if (Zui.button(tr("New"))) { - UIBox.showCustom((ui: ZuiRaw) => { + if (zui_button(tr("New"))) { + UIBox.showCustom((ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(Zui.handle("boxexport_5"), tr("New Preset"), tabVertical)) { - Zui.row([0.5, 0.5]); - let presetName = Zui.textInput(Zui.handle("boxexport_6", { text: "new_preset" }), tr("Name")); - if (Zui.button(tr("OK")) || ui.isReturnDown) { + if (zui_tab(zui_handle("boxexport_5"), tr("New Preset"), tabVertical)) { + zui_row([0.5, 0.5]); + let presetName = zui_text_input(zui_handle("boxexport_6", { text: "new_preset" }), tr("Name")); + if (zui_button(tr("OK")) || ui.is_return_down) { BoxExport.newPreset(presetName); BoxExport.fetchPresets(); BoxExport.preset = null; @@ -203,7 +203,7 @@ class BoxExport { }); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show("json", false, false, (path: string) => { path = path.toLowerCase(); if (path.endsWith(".json")) { @@ -225,24 +225,24 @@ class BoxExport { } // Texture list - Zui.separator(10, false); - Zui.row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); - Zui.text(tr("Texture")); - Zui.text(tr("R")); - Zui.text(tr("G")); - Zui.text(tr("B")); - Zui.text(tr("A")); - Zui.text(tr("Color Space")); + zui_separator(10, false); + zui_row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); + zui_text(tr("Texture")); + zui_text(tr("R")); + zui_text(tr("G")); + zui_text(tr("B")); + zui_text(tr("A")); + zui_text(tr("Color Space")); ui.changed = false; for (let i = 0; i < BoxExport.preset.textures.length; ++i) { let t = BoxExport.preset.textures[i]; - Zui.row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); - let htex = Zui.nest(BoxExport.hpreset, i); + zui_row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); + let htex = zui_nest(BoxExport.hpreset, i); htex.text = t.name; - t.name = Zui.textInput(htex); + t.name = zui_text_input(htex); - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Delete"))) { array_remove(BoxExport.preset.textures, t); BoxExport.savePreset(); @@ -250,27 +250,27 @@ class BoxExport { }, 1); } - let hr = Zui.nest(htex, 0); + let hr = zui_nest(htex, 0); hr.position = BoxExport.channels.indexOf(t.channels[0]); - let hg = Zui.nest(htex, 1); + let hg = zui_nest(htex, 1); hg.position = BoxExport.channels.indexOf(t.channels[1]); - let hb = Zui.nest(htex, 2); + let hb = zui_nest(htex, 2); hb.position = BoxExport.channels.indexOf(t.channels[2]); - let ha = Zui.nest(htex, 3); + let ha = zui_nest(htex, 3); ha.position = BoxExport.channels.indexOf(t.channels[3]); - Zui.combo(hr, BoxExport.channels, tr("R")); + zui_combo(hr, BoxExport.channels, tr("R")); if (hr.changed) t.channels[0] = BoxExport.channels[hr.position]; - Zui.combo(hg, BoxExport.channels, tr("G")); + zui_combo(hg, BoxExport.channels, tr("G")); if (hg.changed) t.channels[1] = BoxExport.channels[hg.position]; - Zui.combo(hb, BoxExport.channels, tr("B")); + zui_combo(hb, BoxExport.channels, tr("B")); if (hb.changed) t.channels[2] = BoxExport.channels[hb.position]; - Zui.combo(ha, BoxExport.channels, tr("A")); + zui_combo(ha, BoxExport.channels, tr("A")); if (ha.changed) t.channels[3] = BoxExport.channels[ha.position]; - let hspace = Zui.nest(htex, 4); + let hspace = zui_nest(htex, 4); hspace.position = BoxExport.colorSpaces.indexOf(t.color_space); - Zui.combo(hspace, BoxExport.colorSpaces, tr("Color Space")); + zui_combo(hspace, BoxExport.colorSpaces, tr("Color Space")); if (hspace.changed) t.color_space = BoxExport.colorSpaces[hspace.position]; } @@ -278,8 +278,8 @@ class BoxExport { BoxExport.savePreset(); } - Zui.row([1 / 8]); - if (Zui.button(tr("Add"))) { + zui_row([1 / 8]); + if (zui_button(tr("Add"))) { BoxExport.preset.textures.push({ name: "base", channels: ["base_r", "base_g", "base_b", "1.0"], color_space: "linear" }); BoxExport.hpreset.children = null; BoxExport.savePreset(); @@ -289,9 +289,9 @@ class BoxExport { ///end ///if is_paint - static tabAtlases = (ui: ZuiRaw) => { + static tabAtlases = (ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(BoxExport.htab, tr("Atlases"), tabVertical)) { + if (zui_tab(BoxExport.htab, tr("Atlases"), tabVertical)) { if (Project.atlasObjects == null || Project.atlasObjects.length != Project.paintObjects.length) { Project.atlasObjects = []; Project.atlasNames = []; @@ -301,11 +301,11 @@ class BoxExport { } } for (let i = 0; i < Project.paintObjects.length; ++i) { - Zui.row([1 / 2, 1 / 2]); - Zui.text(Project.paintObjects[i].base.name); - let hatlas = Zui.nest(Zui.handle("boxexport_7"), i); + zui_row([1 / 2, 1 / 2]); + zui_text(Project.paintObjects[i].base.name); + let hatlas = zui_nest(zui_handle("boxexport_7"), i); hatlas.position = Project.atlasObjects[i]; - Project.atlasObjects[i] = Zui.combo(hatlas, Project.atlasNames, tr("Atlas")); + Project.atlasObjects[i] = zui_combo(hatlas, Project.atlasNames, tr("Atlas")); } } } @@ -313,25 +313,25 @@ class BoxExport { static showMesh = () => { BoxExport.exportMeshHandle.position = Context.raw.exportMeshIndex; - UIBox.showCustom((ui: ZuiRaw) => { - let htab = Zui.handle("boxexport_8"); + UIBox.showCustom((ui: zui_t) => { + let htab = zui_handle("boxexport_8"); BoxExport.tabExportMesh(ui, htab); }); } - static tabExportMesh = (ui: ZuiRaw, htab: HandleRaw) => { + static tabExportMesh = (ui: zui_t, htab: zui_handle_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(htab, tr("Export Mesh"), tabVertical)) { + if (zui_tab(htab, tr("Export Mesh"), tabVertical)) { - Zui.row([1 / 2, 1 / 2]); + zui_row([1 / 2, 1 / 2]); - Context.raw.exportMeshFormat = Zui.combo(Zui.handle("boxexport_9", { position: Context.raw.exportMeshFormat }), ["obj", "arm"], tr("Format"), true); + Context.raw.exportMeshFormat = zui_combo(zui_handle("boxexport_9", { position: Context.raw.exportMeshFormat }), ["obj", "arm"], tr("Format"), true); let ar = [tr("All")]; for (let p of Project.paintObjects) ar.push(p.base.name); - Zui.combo(BoxExport.exportMeshHandle, ar, tr("Meshes"), true); + zui_combo(BoxExport.exportMeshHandle, ar, tr("Meshes"), true); - let applyDisplacement = Zui.check(Zui.handle("boxexport_10"), tr("Apply Displacement")); + let applyDisplacement = zui_check(zui_handle("boxexport_10"), tr("Apply Displacement")); let tris = 0; let pos = BoxExport.exportMeshHandle.position; @@ -341,13 +341,13 @@ class BoxExport { tris += Math.floor(inda.values.length / 3); } } - Zui.text(tris + " " + tr("triangles")); + zui_text(tris + " " + tr("triangles")); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIBox.hide(); UIFiles.show(Context.raw.exportMeshFormat == MeshFormat.FormatObj ? "obj" : "arm", true, false, (path: string) => { ///if (krom_android || krom_ios) @@ -374,26 +374,26 @@ class BoxExport { ///if (is_paint || is_sculpt) static showMaterial = () => { - UIBox.showCustom((ui: ZuiRaw) => { - let htab = Zui.handle("boxexport_11"); + UIBox.showCustom((ui: zui_t) => { + let htab = zui_handle("boxexport_11"); let tabVertical = Config.raw.touch_ui; - if (Zui.tab(htab, tr("Export Material"), tabVertical)) { - let h1 = Zui.handle("boxexport_12"); - let h2 = Zui.handle("boxexport_13"); + if (zui_tab(htab, tr("Export Material"), tabVertical)) { + let h1 = zui_handle("boxexport_12"); + let h2 = zui_handle("boxexport_13"); h1.selected = Context.raw.packAssetsOnExport; h2.selected = Context.raw.writeIconOnExport; - Context.raw.packAssetsOnExport = Zui.check(h1, tr("Pack Assets")); - Context.raw.writeIconOnExport = Zui.check(h2, tr("Export Icon")); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + Context.raw.packAssetsOnExport = zui_check(h1, tr("Pack Assets")); + Context.raw.writeIconOnExport = zui_check(h2, tr("Export Icon")); + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIBox.hide(); UIFiles.show("arm", true, false, (path: string) => { let f = UIFiles.filename; if (f == "") f = tr("untitled"); - App.notifyOnInit(() => { + app_notify_on_init(() => { ExportArm.runMaterial(path + Path.sep + f); }); }); @@ -403,26 +403,26 @@ class BoxExport { } static showBrush = () => { - UIBox.showCustom((ui: ZuiRaw) => { - let htab = Zui.handle("boxexport_14"); + UIBox.showCustom((ui: zui_t) => { + let htab = zui_handle("boxexport_14"); let tabVertical = Config.raw.touch_ui; - if (Zui.tab(htab, tr("Export Brush"), tabVertical)) { - let h1 = Zui.handle("boxexport_15"); - let h2 = Zui.handle("boxexport_16"); + if (zui_tab(htab, tr("Export Brush"), tabVertical)) { + let h1 = zui_handle("boxexport_15"); + let h2 = zui_handle("boxexport_16"); h1.selected = Context.raw.packAssetsOnExport; h2.selected = Context.raw.writeIconOnExport; - Context.raw.packAssetsOnExport = Zui.check(h1, tr("Pack Assets")); - Context.raw.writeIconOnExport = Zui.check(h2, tr("Export Icon")); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + Context.raw.packAssetsOnExport = zui_check(h1, tr("Pack Assets")); + Context.raw.writeIconOnExport = zui_check(h2, tr("Export Icon")); + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIBox.hide(); UIFiles.show("arm", true, false, (path: string) => { let f = UIFiles.filename; if (f == "") f = tr("untitled"); - App.notifyOnInit(() => { + app_notify_on_init(() => { ExportArm.runBrush(path + Path.sep + f); }); }); @@ -442,9 +442,9 @@ class BoxExport { static parsePreset = () => { let file = "export_presets/" + BoxExport.files[BoxExport.hpreset.position] + ".json"; - Data.getBlob(file, (blob: ArrayBuffer) => { + data_get_blob(file, (blob: ArrayBuffer) => { BoxExport.preset = JSON.parse(sys_buffer_to_string(blob)); - Data.deleteBlob("export_presets/" + file); + data_delete_blob("export_presets/" + file); }); } diff --git a/base/Sources/BoxPreferences.ts b/base/Sources/BoxPreferences.ts index a672167b3..80514a72c 100644 --- a/base/Sources/BoxPreferences.ts +++ b/base/Sources/BoxPreferences.ts @@ -1,26 +1,26 @@ class BoxPreferences { - static htab = Handle.create(); + static htab = zui_handle_create(); static filesPlugin: string[] = null; static filesKeymap: string[] = null; - static themeHandle: HandleRaw; - static presetHandle: HandleRaw; + static themeHandle: zui_handle_t; + static presetHandle: zui_handle_t; static locales: string[] = null; static themes: string[] = null; static worldColor = 0xff080808; static show = () => { - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(BoxPreferences.htab, tr("Interface"), true)) { + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(BoxPreferences.htab, tr("Interface"), true)) { if (BoxPreferences.locales == null) { BoxPreferences.locales = Translator.getSupportedLocales(); } - let localeHandle = Zui.handle("boxpreferences_0", { position: BoxPreferences.locales.indexOf(Config.raw.locale) }); - Zui.combo(localeHandle, BoxPreferences.locales, tr("Language"), true); + let localeHandle = zui_handle("boxpreferences_0", { position: BoxPreferences.locales.indexOf(Config.raw.locale) }); + zui_combo(localeHandle, BoxPreferences.locales, tr("Language"), true); if (localeHandle.changed) { let localeCode = BoxPreferences.locales[localeHandle.position]; Config.raw.locale = localeCode; @@ -28,9 +28,9 @@ class BoxPreferences { UIBase.tagUIRedraw(); } - let hscale = Zui.handle("boxpreferences_1", { value: Config.raw.window_scale }); - Zui.slider(hscale, tr("UI Scale"), 1.0, 4.0, true, 10); - if (Context.raw.hscaleWasChanged && !ui.inputDown) { + let hscale = zui_handle("boxpreferences_1", { value: Config.raw.window_scale }); + zui_slider(hscale, tr("UI Scale"), 1.0, 4.0, true, 10); + if (Context.raw.hscaleWasChanged && !ui.input_down) { Context.raw.hscaleWasChanged = false; if (hscale.value == null || isNaN(hscale.value)) hscale.value = 1.0; Config.raw.window_scale = hscale.value; @@ -38,54 +38,56 @@ class BoxPreferences { } if (hscale.changed) Context.raw.hscaleWasChanged = true; - let hspeed = Zui.handle("boxpreferences_2", { value: Config.raw.camera_zoom_speed }); - Config.raw.camera_zoom_speed = Zui.slider(hspeed, tr("Camera Zoom Speed"), 0.1, 4.0, true); + let hspeed = zui_handle("boxpreferences_2", { value: Config.raw.camera_zoom_speed }); + Config.raw.camera_zoom_speed = zui_slider(hspeed, tr("Camera Zoom Speed"), 0.1, 4.0, true); - hspeed = Zui.handle("boxpreferences_3", { value: Config.raw.camera_rotation_speed }); - Config.raw.camera_rotation_speed = Zui.slider(hspeed, tr("Camera Rotation Speed"), 0.1, 4.0, true); + hspeed = zui_handle("boxpreferences_3", { value: Config.raw.camera_rotation_speed }); + Config.raw.camera_rotation_speed = zui_slider(hspeed, tr("Camera Rotation Speed"), 0.1, 4.0, true); - hspeed = Zui.handle("boxpreferences_4", { value: Config.raw.camera_pan_speed }); - Config.raw.camera_pan_speed = Zui.slider(hspeed, tr("Camera Pan Speed"), 0.1, 4.0, true); + hspeed = zui_handle("boxpreferences_4", { value: Config.raw.camera_pan_speed }); + Config.raw.camera_pan_speed = zui_slider(hspeed, tr("Camera Pan Speed"), 0.1, 4.0, true); - let zoomDirectionHandle = Zui.handle("boxpreferences_5", { position: Config.raw.zoom_direction }); - Zui.combo(zoomDirectionHandle, [tr("Vertical"), tr("Vertical Inverted"), tr("Horizontal"), tr("Horizontal Inverted"), tr("Vertical and Horizontal"), tr("Vertical and Horizontal Inverted")], tr("Direction to Zoom"), true); + let zoomDirectionHandle = zui_handle("boxpreferences_5", { position: Config.raw.zoom_direction }); + zui_combo(zoomDirectionHandle, [tr("Vertical"), tr("Vertical Inverted"), tr("Horizontal"), tr("Horizontal Inverted"), tr("Vertical and Horizontal"), tr("Vertical and Horizontal Inverted")], tr("Direction to Zoom"), true); if (zoomDirectionHandle.changed) { Config.raw.zoom_direction = zoomDirectionHandle.position; } - Config.raw.wrap_mouse = Zui.check(Zui.handle("boxpreferences_6", { selected: Config.raw.wrap_mouse }), tr("Wrap Mouse")); - if (ui.isHovered) Zui.tooltip(tr("Wrap mouse around view boundaries during camera control")); + Config.raw.wrap_mouse = zui_check(zui_handle("boxpreferences_6", { selected: Config.raw.wrap_mouse }), tr("Wrap Mouse")); + if (ui.is_hovered) zui_tooltip(tr("Wrap mouse around view boundaries during camera control")); - Config.raw.node_preview = Zui.check(Zui.handle("boxpreferences_7", { selected: Config.raw.node_preview }), tr("Show Node Preview")); + Config.raw.node_preview = zui_check(zui_handle("boxpreferences_7", { selected: Config.raw.node_preview }), tr("Show Node Preview")); ui.changed = false; - Config.raw.show_asset_names = Zui.check(Zui.handle("boxpreferences_8", { selected: Config.raw.show_asset_names }), tr("Show Asset Names")); + Config.raw.show_asset_names = zui_check(zui_handle("boxpreferences_8", { selected: Config.raw.show_asset_names }), tr("Show Asset Names")); if (ui.changed) { UIBase.tagUIRedraw(); } ///if !(krom_android || krom_ios) ui.changed = false; - Config.raw.touch_ui = Zui.check(Zui.handle("boxpreferences_9", { selected: Config.raw.touch_ui }), tr("Touch UI")); + Config.raw.touch_ui = zui_check(zui_handle("boxpreferences_9", { selected: Config.raw.touch_ui }), tr("Touch UI")); if (ui.changed) { - Zui.touchScroll = Zui.touchHold = Zui.touchTooltip = Config.raw.touch_ui; + zui_set_touch_scroll(Config.raw.touch_ui); + zui_set_touch_hold(Config.raw.touch_ui); + zui_set_touch_tooltip(Config.raw.touch_ui); Config.loadTheme(Config.raw.theme); BoxPreferences.setScale(); UIBase.tagUIRedraw(); } ///end - Config.raw.splash_screen = Zui.check(Zui.handle("boxpreferences_10", { selected: Config.raw.splash_screen }), tr("Splash Screen")); + Config.raw.splash_screen = zui_check(zui_handle("boxpreferences_10", { selected: Config.raw.splash_screen }), tr("Splash Screen")); // Zui.text("Node Editor"); // let gridSnap = Zui.check(Zui.handle("boxpreferences_11", { selected: false }), "Grid Snap"); - Zui.endElement(); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Restore")) && !UIMenu.show) { - UIMenu.draw((ui: ZuiRaw) => { + zui_end_element(); + zui_row([0.5, 0.5]); + if (zui_button(tr("Restore")) && !UIMenu.show) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Confirm"))) { - App.notifyOnInit(() => { + app_notify_on_init(() => { ui.t.ELEMENT_H = Base.defaultElementH; Config.restore(); BoxPreferences.setScale(); @@ -98,9 +100,9 @@ class BoxPreferences { } if (UIMenu.menuButton(ui, tr("Import..."))) { UIFiles.show("json", false, false, (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let raw = JSON.parse(sys_buffer_to_string(b)); - App.notifyOnInit(() => { + app_notify_on_init(() => { ui.t.ELEMENT_H = Base.defaultElementH; Config.importFrom(raw); BoxPreferences.setScale(); @@ -112,8 +114,8 @@ class BoxPreferences { } }, 2); } - if (Zui.button(tr("Reset Layout")) && !UIMenu.show) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Reset Layout")) && !UIMenu.show) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Confirm"))) { Base.initLayout(); Config.save(); @@ -122,28 +124,28 @@ class BoxPreferences { } } - if (Zui.tab(BoxPreferences.htab, tr("Theme"), true)) { + if (zui_tab(BoxPreferences.htab, tr("Theme"), true)) { if (BoxPreferences.themes == null) { BoxPreferences.fetchThemes(); } - BoxPreferences.themeHandle = Zui.handle("boxpreferences_12", { position: BoxPreferences.getThemeIndex() }); + BoxPreferences.themeHandle = zui_handle("boxpreferences_12", { position: BoxPreferences.getThemeIndex() }); - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.combo(BoxPreferences.themeHandle, BoxPreferences.themes, tr("Theme")); + zui_combo(BoxPreferences.themeHandle, BoxPreferences.themes, tr("Theme")); if (BoxPreferences.themeHandle.changed) { Config.raw.theme = BoxPreferences.themes[BoxPreferences.themeHandle.position] + ".json"; Config.loadTheme(Config.raw.theme); } - if (Zui.button(tr("New"))) { - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(Zui.handle("boxpreferences_13"), tr("New Theme"))) { - Zui.row([0.5, 0.5]); - let themeName = Zui.textInput(Zui.handle("boxpreferences_14", { text: "new_theme" }), tr("Name")); - if (Zui.button(tr("OK")) || ui.isReturnDown) { + if (zui_button(tr("New"))) { + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(zui_handle("boxpreferences_13"), tr("New Theme"))) { + zui_row([0.5, 0.5]); + let themeName = zui_text_input(zui_handle("boxpreferences_14", { text: "new_theme" }), tr("Name")); + if (zui_button(tr("OK")) || ui.is_return_down) { let template = JSON.stringify(Base.theme); if (!themeName.endsWith(".json")) themeName += ".json"; let path = Path.data() + Path.sep + "themes" + Path.sep + themeName; @@ -159,13 +161,13 @@ class BoxPreferences { }); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show("json", false, false, (path: string) => { ImportTheme.run(path); }); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIFiles.show("json", true, false, (path: string) => { path += Path.sep + UIFiles.filename; if (!path.endsWith(".json")) path += ".json"; @@ -173,27 +175,27 @@ class BoxPreferences { }); } - Zui.endSticky(); + zui_end_sticky(); let i = 0; let theme: any = Base.theme; - let hlist = Zui.handle("boxpreferences_15"); + let hlist = zui_handle("boxpreferences_15"); // Viewport color - let h = Zui.nest(hlist, i++, { color: BoxPreferences.worldColor }); - Zui.row([1 / 8, 7 / 8]); - Zui.text("", 0, h.color); - if (ui.isHovered && ui.inputReleased) { + let h = zui_nest(hlist, i++, { color: BoxPreferences.worldColor }); + zui_row([1 / 8, 7 / 8]); + zui_text("", 0, h.color); + if (ui.is_hovered && ui.input_released) { UIMenu.draw((ui) => { ui.changed = false; - Zui.colorWheel(h, false, null, 11 * ui.t.ELEMENT_H * Zui.SCALE(ui), true); + zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true); if (ui.changed) UIMenu.keepOpen = true; }, 11); } let val = h.color; if (val < 0) val += 4294967296; h.text = val.toString(16); - Zui.textInput(h, "VIEWPORT_COL"); + zui_text_input(h, "VIEWPORT_COL"); h.color = parseInt(h.text, 16); if (BoxPreferences.worldColor != h.color) { @@ -211,23 +213,23 @@ class BoxPreferences { } // Theme fields - for (let key of Object.getOwnPropertyNames(Theme.prototype)) { + for (let key of Object.getOwnPropertyNames(theme_t.prototype)) { if (key == "constructor") continue; - let h = Zui.nest(hlist, i++); + let h = zui_nest(hlist, i++); let val: any = theme[key]; let isHex = key.endsWith("_COL"); if (isHex && val < 0) val += 4294967296; if (isHex) { - Zui.row([1 / 8, 7 / 8]); - Zui.text("", 0, val); - if (ui.isHovered && ui.inputReleased) { + zui_row([1 / 8, 7 / 8]); + zui_text("", 0, val); + if (ui.is_hovered && ui.input_released) { h.color = theme[key]; UIMenu.draw((ui) => { ui.changed = false; - let color = Zui.colorWheel(h, false, null, 11 * ui.t.ELEMENT_H * Zui.SCALE(ui), true); + let color = zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true); theme[key] = color; if (ui.changed) UIMenu.keepOpen = true; }, 11); @@ -238,33 +240,33 @@ class BoxPreferences { if (typeof val == "boolean") { h.selected = val; - let b = Zui.check(h, key); + let b = zui_check(h, key); theme[key] = b; } else if (key == "LINK_STYLE") { let styles = [tr("Straight"), tr("Curved")]; h.position = val; - let i = Zui.combo(h, styles, key, true); + let i = zui_combo(h, styles, key, true); theme[key] = i; } else { h.text = isHex ? val.toString(16) : val.toString(); - let res = Zui.textInput(h, key); + let res = zui_text_input(h, key); if (isHex) theme[key] = parseInt(h.text, 16); else theme[key] = parseInt(h.text); } if (ui.changed) { for (let ui of Base.getUIs()) { - ui.elementsBaked = false; + ui.elements_baked = false; } } } } - if (Zui.tab(BoxPreferences.htab, tr("Usage"), true)) { - Context.raw.undoHandle = Zui.handle("boxpreferences_16", { value: Config.raw.undo_steps }); - Config.raw.undo_steps = Math.floor(Zui.slider(Context.raw.undoHandle, tr("Undo Steps"), 1, 64, false, 1)); + if (zui_tab(BoxPreferences.htab, tr("Usage"), true)) { + Context.raw.undoHandle = zui_handle("boxpreferences_16", { value: Config.raw.undo_steps }); + Config.raw.undo_steps = Math.floor(zui_slider(Context.raw.undoHandle, tr("Undo Steps"), 1, 64, false, 1)); if (Config.raw.undo_steps < 1) { Config.raw.undo_steps = Math.floor(Context.raw.undoHandle.value = 1); } @@ -287,45 +289,45 @@ class BoxPreferences { } ///if is_paint - Config.raw.dilate_radius = Math.floor(Zui.slider(Zui.handle("boxpreferences_17", { value: Config.raw.dilate_radius }), tr("Dilate Radius"), 0.0, 16.0, true, 1)); - if (ui.isHovered) Zui.tooltip(tr("Dilate painted textures to prevent seams")); + Config.raw.dilate_radius = Math.floor(zui_slider(zui_handle("boxpreferences_17", { value: Config.raw.dilate_radius }), tr("Dilate Radius"), 0.0, 16.0, true, 1)); + if (ui.is_hovered) zui_tooltip(tr("Dilate painted textures to prevent seams")); - let dilateHandle = Zui.handle("boxpreferences_18", { position: Config.raw.dilate }); - Zui.combo(dilateHandle, [tr("Instant"), tr("Delayed")], tr("Dilate"), true); + let dilateHandle = zui_handle("boxpreferences_18", { position: Config.raw.dilate }); + zui_combo(dilateHandle, [tr("Instant"), tr("Delayed")], tr("Dilate"), true); if (dilateHandle.changed) { Config.raw.dilate = dilateHandle.position; } ///end ///if is_lab - let workspaceHandle = Zui.handle("boxpreferences_19", { position: Config.raw.workspace }); - Zui.combo(workspaceHandle, [tr("3D View"), tr("2D View")], tr("Default Workspace"), true); + let workspaceHandle = zui_handle("boxpreferences_19", { position: Config.raw.workspace }); + zui_combo(workspaceHandle, [tr("3D View"), tr("2D View")], tr("Default Workspace"), true); if (workspaceHandle.changed) { Config.raw.workspace = workspaceHandle.position; } ///end - let cameraControlsHandle = Zui.handle("boxpreferences_20", { position: Config.raw.camera_controls }); - Zui.combo(cameraControlsHandle, [tr("Orbit"), tr("Rotate"), tr("Fly")], tr("Default Camera Controls"), true); + let cameraControlsHandle = zui_handle("boxpreferences_20", { position: Config.raw.camera_controls }); + zui_combo(cameraControlsHandle, [tr("Orbit"), tr("Rotate"), tr("Fly")], tr("Default Camera Controls"), true); if (cameraControlsHandle.changed) { Config.raw.camera_controls = cameraControlsHandle.position; } - let layerResHandle = Zui.handle("boxpreferences_21", { position: Config.raw.layer_res }); + let layerResHandle = zui_handle("boxpreferences_21", { position: Config.raw.layer_res }); ///if is_paint ///if (krom_android || krom_ios) - Zui.combo(layerResHandle, ["128", "256", "512", "1K", "2K", "4K"], tr("Default Layer Resolution"), true); + zui_combo(layerResHandle, ["128", "256", "512", "1K", "2K", "4K"], tr("Default Layer Resolution"), true); ///else - Zui.combo(layerResHandle, ["128", "256", "512", "1K", "2K", "4K", "8K"], tr("Default Layer Resolution"), true); + zui_combo(layerResHandle, ["128", "256", "512", "1K", "2K", "4K", "8K"], tr("Default Layer Resolution"), true); ///end ///end ///if is_lab ///if (krom_android || krom_ios) - Zui.combo(layerResHandle, ["2K", "4K"], tr("Default Layer Resolution"), true); + zui_combo(layerResHandle, ["2K", "4K"], tr("Default Layer Resolution"), true); ///else - Zui.combo(layerResHandle, ["2K", "4K", "8K", "16K"], tr("Default Layer Resolution"), true); + zui_combo(layerResHandle, ["2K", "4K", "8K", "16K"], tr("Default Layer Resolution"), true); ///end ///end @@ -333,37 +335,37 @@ class BoxPreferences { Config.raw.layer_res = layerResHandle.position; } - let serverHandle = Zui.handle("boxpreferences_22", { text: Config.raw.server }); - Config.raw.server = Zui.textInput(serverHandle, tr("Cloud Server")); + let serverHandle = zui_handle("boxpreferences_22", { text: Config.raw.server }); + Config.raw.server = zui_text_input(serverHandle, tr("Cloud Server")); ///if (is_paint || is_sculpt) - let materialLiveHandle = Zui.handle("boxpreferences_23", {selected: Config.raw.material_live }); - Config.raw.material_live = Zui.check(materialLiveHandle, tr("Live Material Preview")); - if (ui.isHovered) Zui.tooltip(tr("Instantly update material preview on node change")); + let materialLiveHandle = zui_handle("boxpreferences_23", {selected: Config.raw.material_live }); + Config.raw.material_live = zui_check(materialLiveHandle, tr("Live Material Preview")); + if (ui.is_hovered) zui_tooltip(tr("Instantly update material preview on node change")); - let brushLiveHandle = Zui.handle("boxpreferences_24", { selected: Config.raw.brush_live }); - Config.raw.brush_live = Zui.check(brushLiveHandle, tr("Live Brush Preview")); - if (ui.isHovered) Zui.tooltip(tr("Draw live brush preview in viewport")); + let brushLiveHandle = zui_handle("boxpreferences_24", { selected: Config.raw.brush_live }); + Config.raw.brush_live = zui_check(brushLiveHandle, tr("Live Brush Preview")); + if (ui.is_hovered) zui_tooltip(tr("Draw live brush preview in viewport")); if (brushLiveHandle.changed) Context.raw.ddirty = 2; - let brush3dHandle = Zui.handle("boxpreferences_25", { selected: Config.raw.brush_3d }); - Config.raw.brush_3d = Zui.check(brush3dHandle, tr("3D Cursor")); + let brush3dHandle = zui_handle("boxpreferences_25", { selected: Config.raw.brush_3d }); + Config.raw.brush_3d = zui_check(brush3dHandle, tr("3D Cursor")); if (brush3dHandle.changed) MakeMaterial.parsePaintMaterial(); ui.enabled = Config.raw.brush_3d; - let brushDepthRejectHandle = Zui.handle("boxpreferences_26", { selected: Config.raw.brush_depth_reject }); - Config.raw.brush_depth_reject = Zui.check(brushDepthRejectHandle, tr("Depth Reject")); + let brushDepthRejectHandle = zui_handle("boxpreferences_26", { selected: Config.raw.brush_depth_reject }); + Config.raw.brush_depth_reject = zui_check(brushDepthRejectHandle, tr("Depth Reject")); if (brushDepthRejectHandle.changed) MakeMaterial.parsePaintMaterial(); - Zui.row([0.5, 0.5]); + zui_row([0.5, 0.5]); - let brushAngleRejectHandle = Zui.handle("boxpreferences_27", { selected: Config.raw.brush_angle_reject }); - Config.raw.brush_angle_reject = Zui.check(brushAngleRejectHandle, tr("Angle Reject")); + let brushAngleRejectHandle = zui_handle("boxpreferences_27", { selected: Config.raw.brush_angle_reject }); + Config.raw.brush_angle_reject = zui_check(brushAngleRejectHandle, tr("Angle Reject")); if (brushAngleRejectHandle.changed) MakeMaterial.parsePaintMaterial(); if (!Config.raw.brush_angle_reject) ui.enabled = false; - let angleDotHandle = Zui.handle("boxpreferences_28", { value: Context.raw.brushAngleRejectDot }); - Context.raw.brushAngleRejectDot = Zui.slider(angleDotHandle, tr("Angle"), 0.0, 1.0, true); + let angleDotHandle = zui_handle("boxpreferences_28", { value: Context.raw.brushAngleRejectDot }); + Context.raw.brushAngleRejectDot = zui_slider(angleDotHandle, tr("Angle"), 0.0, 1.0, true); if (angleDotHandle.changed) { MakeMaterial.parsePaintMaterial(); } @@ -371,8 +373,8 @@ class BoxPreferences { ///end ///if is_lab - Config.raw.gpu_inference = Zui.check(Zui.handle("boxpreferences_29", { selected: Config.raw.gpu_inference }), tr("Use GPU")); - if (ui.isHovered) Zui.tooltip(tr("Use GPU to accelerate node graph processing")); + Config.raw.gpu_inference = zui_check(zui_handle("boxpreferences_29", { selected: Config.raw.gpu_inference }), tr("Use GPU")); + if (ui.is_hovered) zui_tooltip(tr("Use GPU to accelerate node graph processing")); ///end } @@ -383,19 +385,19 @@ class BoxPreferences { penName = tr("Pen"); ///end - if (Zui.tab(BoxPreferences.htab, penName, true)) { - Zui.text(tr("Pressure controls")); - Config.raw.pressure_radius = Zui.check(Zui.handle("boxpreferences_30", { selected: Config.raw.pressure_radius }), tr("Brush Radius")); - Config.raw.pressure_sensitivity = Zui.slider(Zui.handle("boxpreferences_31", { value: Config.raw.pressure_sensitivity }), tr("Sensitivity"), 0.0, 10.0, true); + if (zui_tab(BoxPreferences.htab, penName, true)) { + zui_text(tr("Pressure controls")); + Config.raw.pressure_radius = zui_check(zui_handle("boxpreferences_30", { selected: Config.raw.pressure_radius }), tr("Brush Radius")); + Config.raw.pressure_sensitivity = zui_slider(zui_handle("boxpreferences_31", { value: Config.raw.pressure_sensitivity }), tr("Sensitivity"), 0.0, 10.0, true); ///if (is_paint || is_sculpt) - Config.raw.pressure_hardness = Zui.check(Zui.handle("boxpreferences_32", { selected: Config.raw.pressure_hardness }), tr("Brush Hardness")); - Config.raw.pressure_opacity = Zui.check(Zui.handle("boxpreferences_33", { selected: Config.raw.pressure_opacity }), tr("Brush Opacity")); - Config.raw.pressure_angle = Zui.check(Zui.handle("boxpreferences_34", { selected: Config.raw.pressure_angle }), tr("Brush Angle")); + Config.raw.pressure_hardness = zui_check(zui_handle("boxpreferences_32", { selected: Config.raw.pressure_hardness }), tr("Brush Hardness")); + Config.raw.pressure_opacity = zui_check(zui_handle("boxpreferences_33", { selected: Config.raw.pressure_opacity }), tr("Brush Opacity")); + Config.raw.pressure_angle = zui_check(zui_handle("boxpreferences_34", { selected: Config.raw.pressure_angle }), tr("Brush Angle")); ///end - Zui.endElement(); - Zui.row([0.5]); - if (Zui.button(tr("Help"))) { + zui_end_element(); + zui_row([0.5]); + if (zui_button(tr("Help"))) { ///if (is_paint || is_sculpt) File.loadUrl("https://github.com/armory3d/armorpaint_docs///pen"); ///end @@ -405,63 +407,63 @@ class BoxPreferences { } } - Context.raw.hssao = Zui.handle("boxpreferences_35", { selected: Config.raw.rp_ssao }); - Context.raw.hssr = Zui.handle("boxpreferences_36", { selected: Config.raw.rp_ssr }); - Context.raw.hbloom = Zui.handle("boxpreferences_37", { selected: Config.raw.rp_bloom }); - Context.raw.hsupersample = Zui.handle("boxpreferences_38", { position: Config.getSuperSampleQuality(Config.raw.rp_supersample) }); - Context.raw.hvxao = Zui.handle("boxpreferences_39", { selected: Config.raw.rp_gi }); - if (Zui.tab(BoxPreferences.htab, tr("Viewport"), true)) { + Context.raw.hssao = zui_handle("boxpreferences_35", { selected: Config.raw.rp_ssao }); + Context.raw.hssr = zui_handle("boxpreferences_36", { selected: Config.raw.rp_ssr }); + Context.raw.hbloom = zui_handle("boxpreferences_37", { selected: Config.raw.rp_bloom }); + Context.raw.hsupersample = zui_handle("boxpreferences_38", { position: Config.getSuperSampleQuality(Config.raw.rp_supersample) }); + Context.raw.hvxao = zui_handle("boxpreferences_39", { selected: Config.raw.rp_gi }); + if (zui_tab(BoxPreferences.htab, tr("Viewport"), true)) { ///if (krom_direct3d12 || krom_vulkan || krom_metal) - let hpathtracemode = Zui.handle("boxpreferences_40", { position: Context.raw.pathTraceMode }); - Context.raw.pathTraceMode = Zui.combo(hpathtracemode, [tr("Core"), tr("Full")], tr("Path Tracer"), true); + let hpathtracemode = zui_handle("boxpreferences_40", { position: Context.raw.pathTraceMode }); + Context.raw.pathTraceMode = zui_combo(hpathtracemode, [tr("Core"), tr("Full")], tr("Path Tracer"), true); if (hpathtracemode.changed) { RenderPathRaytrace.ready = false; } ///end - let hrendermode = Zui.handle("boxpreferences_41", { position: Context.raw.renderMode }); - Context.raw.renderMode = Zui.combo(hrendermode, [tr("Full"), tr("Mobile")], tr("Renderer"), true); + let hrendermode = zui_handle("boxpreferences_41", { position: Context.raw.renderMode }); + Context.raw.renderMode = zui_combo(hrendermode, [tr("Full"), tr("Mobile")], tr("Renderer"), true); if (hrendermode.changed) { Context.setRenderPath(); } - Zui.combo(Context.raw.hsupersample, ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"], tr("Super Sample"), true); + zui_combo(Context.raw.hsupersample, ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"], tr("Super Sample"), true); if (Context.raw.hsupersample.changed) Config.applyConfig(); if (Context.raw.renderMode == RenderMode.RenderDeferred) { ///if arm_voxels - Zui.check(Context.raw.hvxao, tr("Voxel AO")); - if (ui.isHovered) Zui.tooltip(tr("Cone-traced AO and shadows")); + zui_check(Context.raw.hvxao, tr("Voxel AO")); + if (ui.is_hovered) zui_tooltip(tr("Cone-traced AO and shadows")); if (Context.raw.hvxao.changed) { Config.applyConfig(); } ui.enabled = Context.raw.hvxao.selected; - let h = Zui.handle("boxpreferences_42", { value: Context.raw.vxaoOffset }); - Context.raw.vxaoOffset = Zui.slider(h, tr("Cone Offset"), 1.0, 4.0, true); + let h = zui_handle("boxpreferences_42", { value: Context.raw.vxaoOffset }); + Context.raw.vxaoOffset = zui_slider(h, tr("Cone Offset"), 1.0, 4.0, true); if (h.changed) Context.raw.ddirty = 2; - h = Zui.handle("boxpreferences_43", { value: Context.raw.vxaoAperture }); - Context.raw.vxaoAperture = Zui.slider(h, tr("Aperture"), 1.0, 4.0, true); + h = zui_handle("boxpreferences_43", { value: Context.raw.vxaoAperture }); + Context.raw.vxaoAperture = zui_slider(h, tr("Aperture"), 1.0, 4.0, true); if (h.changed) Context.raw.ddirty = 2; ui.enabled = true; ///end - Zui.check(Context.raw.hssao, tr("SSAO")); + zui_check(Context.raw.hssao, tr("SSAO")); if (Context.raw.hssao.changed) Config.applyConfig(); - Zui.check(Context.raw.hssr, tr("SSR")); + zui_check(Context.raw.hssr, tr("SSR")); if (Context.raw.hssr.changed) Config.applyConfig(); - Zui.check(Context.raw.hbloom, tr("Bloom")); + zui_check(Context.raw.hbloom, tr("Bloom")); if (Context.raw.hbloom.changed) Config.applyConfig(); } - let h = Zui.handle("boxpreferences_44", { value: Config.raw.rp_vignette }); - Config.raw.rp_vignette = Zui.slider(h, tr("Vignette"), 0.0, 1.0, true); + let h = zui_handle("boxpreferences_44", { value: Config.raw.rp_vignette }); + Config.raw.rp_vignette = zui_slider(h, tr("Vignette"), 0.0, 1.0, true); if (h.changed) Context.raw.ddirty = 2; - h = Zui.handle("boxpreferences_45", { value: Config.raw.rp_grain }); - Config.raw.rp_grain = Zui.slider(h, tr("Noise Grain"), 0.0, 1.0, true); + h = zui_handle("boxpreferences_45", { value: Config.raw.rp_grain }); + Config.raw.rp_grain = zui_slider(h, tr("Noise Grain"), 0.0, 1.0, true); if (h.changed) Context.raw.ddirty = 2; // let h = Zui.handle("boxpreferences_46", { value: Context.raw.autoExposureStrength }); @@ -470,46 +472,46 @@ class BoxPreferences { let cam = scene_camera; let camRaw = cam.data; - let near_handle = Zui.handle("boxpreferences_47"); - let far_handle = Zui.handle("boxpreferences_48"); + let near_handle = zui_handle("boxpreferences_47"); + let far_handle = zui_handle("boxpreferences_48"); near_handle.value = Math.floor(camRaw.near_plane * 1000) / 1000; far_handle.value = Math.floor(camRaw.far_plane * 100) / 100; - camRaw.near_plane = Zui.slider(near_handle, tr("Clip Start"), 0.001, 1.0, true); - camRaw.far_plane = Zui.slider(far_handle, tr("Clip End"), 50.0, 100.0, true); + camRaw.near_plane = zui_slider(near_handle, tr("Clip Start"), 0.001, 1.0, true); + camRaw.far_plane = zui_slider(far_handle, tr("Clip End"), 50.0, 100.0, true); if (near_handle.changed || far_handle.changed) { - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); } - let dispHandle = Zui.handle("boxpreferences_49", { value: Config.raw.displace_strength }); - Config.raw.displace_strength = Zui.slider(dispHandle, tr("Displacement Strength"), 0.0, 10.0, true); + let dispHandle = zui_handle("boxpreferences_49", { value: Config.raw.displace_strength }); + Config.raw.displace_strength = zui_slider(dispHandle, tr("Displacement Strength"), 0.0, 10.0, true); if (dispHandle.changed) { Context.raw.ddirty = 2; MakeMaterial.parseMeshMaterial(); } } - if (Zui.tab(BoxPreferences.htab, tr("Keymap"), true)) { + if (zui_tab(BoxPreferences.htab, tr("Keymap"), true)) { if (BoxPreferences.filesKeymap == null) { BoxPreferences.fetchKeymaps(); } - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - BoxPreferences.presetHandle = Zui.handle("boxpreferences_50", { position: BoxPreferences.getPresetIndex() }); - Zui.combo(BoxPreferences.presetHandle, BoxPreferences.filesKeymap, tr("Preset")); + BoxPreferences.presetHandle = zui_handle("boxpreferences_50", { position: BoxPreferences.getPresetIndex() }); + zui_combo(BoxPreferences.presetHandle, BoxPreferences.filesKeymap, tr("Preset")); if (BoxPreferences.presetHandle.changed) { Config.raw.keymap = BoxPreferences.filesKeymap[BoxPreferences.presetHandle.position] + ".json"; Config.applyConfig(); Config.loadKeymap(); } - if (Zui.button(tr("New"))) { - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(Zui.handle("boxpreferences_51"), tr("New Keymap"))) { - Zui.row([0.5, 0.5]); - let keymapName = Zui.textInput(Zui.handle("boxpreferences_52", { text: "new_keymap" }), tr("Name")); - if (Zui.button(tr("OK")) || ui.isReturnDown) { + if (zui_button(tr("New"))) { + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(zui_handle("boxpreferences_51"), tr("New Keymap"))) { + zui_row([0.5, 0.5]); + let keymapName = zui_text_input(zui_handle("boxpreferences_52", { text: "new_keymap" }), tr("Name")); + if (zui_button(tr("OK")) || ui.is_return_down) { let template = JSON.stringify(Base.defaultKeymap); if (!keymapName.endsWith(".json")) keymapName += ".json"; let path = Path.data() + Path.sep + "keymap_presets" + Path.sep + keymapName; @@ -525,12 +527,12 @@ class BoxPreferences { }); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show("json", false, false, (path: string) => { ImportKeymap.run(path); }); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { UIFiles.show("json", true, false, (dest: string) => { if (!UIFiles.filename.endsWith(".json")) UIFiles.filename += ".json"; let path = Path.data() + Path.sep + "keymap_presets" + Path.sep + Config.raw.keymap; @@ -538,16 +540,16 @@ class BoxPreferences { }); } - Zui.endSticky(); + zui_end_sticky(); - Zui.separator(8, false); + zui_separator(8, false); let i = 0; ui.changed = false; for (let key in Config.keymap) { - let h = Zui.nest(Zui.handle("boxpreferences_53"), i++); + let h = zui_nest(zui_handle("boxpreferences_53"), i++); h.text = Config.keymap[key]; - let text = Zui.textInput(h, key, Align.Left); + let text = zui_text_input(h, key, Align.Left); Config.keymap[key] = text; } if (ui.changed) { @@ -555,15 +557,15 @@ class BoxPreferences { Config.saveKeymap(); } } - if (Zui.tab(BoxPreferences.htab, tr("Plugins"), true)) { - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4]); - if (Zui.button(tr("New"))) { - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(Zui.handle("boxpreferences_54"), tr("New Plugin"))) { - Zui.row([0.5, 0.5]); - let pluginName = Zui.textInput(Zui.handle("boxpreferences_55", { text: "new_plugin" }), tr("Name")); - if (Zui.button(tr("OK")) || ui.isReturnDown) { + if (zui_tab(BoxPreferences.htab, tr("Plugins"), true)) { + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4]); + if (zui_button(tr("New"))) { + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(zui_handle("boxpreferences_54"), tr("New Plugin"))) { + zui_row([0.5, 0.5]); + let pluginName = zui_text_input(zui_handle("boxpreferences_55", { text: "new_plugin" }), tr("Name")); + if (zui_button(tr("OK")) || ui.is_return_down) { let template = `let plugin = Plugin.create(); let h1 = new Handle(); @@ -586,40 +588,40 @@ plugin.drawUI = (ui) { => } }); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show("js,zip", false, false, (path: string) => { ImportPlugin.run(path); }); } - Zui.endSticky(); + zui_end_sticky(); if (BoxPreferences.filesPlugin == null) { BoxPreferences.fetchPlugins(); } if (Config.raw.plugins == null) Config.raw.plugins = []; - let h = Zui.handle("boxpreferences_56", { selected: false }); + let h = zui_handle("boxpreferences_56", { selected: false }); for (let f of BoxPreferences.filesPlugin) { let isJs = f.endsWith(".js"); if (!isJs) continue; let enabled = Config.raw.plugins.indexOf(f) >= 0; h.selected = enabled; let tag = isJs ? f.split(".")[0] : f; - Zui.check(h, tag); + zui_check(h, tag); if (h.changed && h.selected != enabled) { h.selected ? Config.enablePlugin(f) : Config.disablePlugin(f); Base.redrawUI(); } - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { let path = Path.data() + Path.sep + "plugins" + Path.sep + f; if (UIMenu.menuButton(ui, tr("Edit in Text Editor"))) { File.start(path); } if (UIMenu.menuButton(ui, tr("Edit in Script Tab"))) { - Data.getBlob("plugins/" + f, (blob: ArrayBuffer) => { + data_get_blob("plugins/" + f, (blob: ArrayBuffer) => { TabScript.hscript.text = sys_buffer_to_string(blob); - Data.deleteBlob("plugins/" + f); + data_delete_blob("plugins/" + f); Console.info(tr("Script opened")); }); @@ -674,15 +676,15 @@ plugin.drawUI = (ui) { => static setScale = () => { let scale = Config.raw.window_scale; - Zui.setScale(UIBase.ui, scale); + zui_set_scale(UIBase.ui, scale); UIHeader.headerh = Math.floor(UIHeader.defaultHeaderH * scale); Config.raw.layout[LayoutSize.LayoutStatusH] = Math.floor(UIStatus.defaultStatusH * scale); UIMenubar.menubarw = Math.floor(UIMenubar.defaultMenubarW * scale); UIBase.setIconScale(); - Zui.setScale(UINodes.ui, scale); - Zui.setScale(UIView2D.ui, scale); - Zui.setScale(Base.uiBox, scale); - Zui.setScale(Base.uiMenu, scale); + zui_set_scale(UINodes.ui, scale); + zui_set_scale(UIView2D.ui, scale); + zui_set_scale(Base.uiBox, scale); + zui_set_scale(Base.uiMenu, scale); Base.resize(); ///if (is_paint || is_sculpt) Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(UIBase.defaultSidebarW * scale); diff --git a/base/Sources/BoxProjects.ts b/base/Sources/BoxProjects.ts index 349fd1e55..c3455b6b0 100644 --- a/base/Sources/BoxProjects.ts +++ b/base/Sources/BoxProjects.ts @@ -1,14 +1,14 @@ class BoxProjects { - static htab = Handle.create(); - static hsearch = Handle.create(); + static htab = zui_handle_create(); + static hsearch = zui_handle_create(); static iconMap: Map = null; static show = () => { if (BoxProjects.iconMap != null) { for (let handle of BoxProjects.iconMap.keys()) { - Data.deleteImage(handle); + data_delete_image(handle); } BoxProjects.iconMap = null; } @@ -20,7 +20,7 @@ class BoxProjects { draggable = true; ///end - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { ///if (krom_android || krom_ios) BoxProjects.alignToFullScreen(); ///end @@ -35,13 +35,13 @@ class BoxProjects { }, 600, 400, null, draggable); } - static projectsTab = (ui: ZuiRaw) => { - if (Zui.tab(BoxProjects.htab, tr("Projects"), true)) { - Zui.beginSticky(); + static projectsTab = (ui: zui_t) => { + if (zui_tab(BoxProjects.htab, tr("Projects"), true)) { + zui_begin_sticky(); BoxProjects.drawBadge(ui); - if (Zui.button(tr("New"))) { + if (zui_button(tr("New"))) { Project.projectNew(); Viewport.scaleToBounds(); UIBox.hide(); @@ -61,10 +61,10 @@ class BoxProjects { } sys_title_set(title); } - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); - let slotw = Math.floor(150 * Zui.SCALE(ui)); + let slotw = Math.floor(150 * zui_SCALE(ui)); let num = Math.floor(sys_width() / slotw); let recent_projects = Config.raw.recent_projects; let show_asset_names = true; @@ -73,18 +73,18 @@ class BoxProjects { let mult = show_asset_names ? 2 : 1; let ar = []; for (let i = 0; i < num * mult; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; - let off = show_asset_names ? Zui.ELEMENT_OFFSET(ui) * 16.0 : 6; + let off = show_asset_names ? zui_ELEMENT_OFFSET(ui) * 16.0 : 6; if (row > 0) ui._y += off; for (let j = 0; j < num; ++j) { - let imgw = Math.floor(128 * Zui.SCALE(ui)); + let imgw = Math.floor(128 * zui_SCALE(ui)); let i = j + row * num; if (i >= recent_projects.length) { - Zui.endElement(imgw); - if (show_asset_names) Zui.endElement(0); + zui_end_element(imgw); + if (show_asset_names) zui_end_element(0); continue; } @@ -100,7 +100,7 @@ class BoxProjects { if (BoxProjects.iconMap == null) BoxProjects.iconMap = new Map(); let icon = BoxProjects.iconMap.get(iconPath); if (icon == null) { - Data.getImage(iconPath, (image: image_t) => { + data_get_image(iconPath, (image: image_t) => { icon = image; BoxProjects.iconMap.set(iconPath, icon); }); @@ -108,16 +108,16 @@ class BoxProjects { let uix = ui._x; if (icon != null) { - Zui.fill(0, 0, 128, 128, ui.t.SEPARATOR_COL); + zui_fill(0, 0, 128, 128, ui.t.SEPARATOR_COL); - let state = Zui.image(icon, 0xffffffff, 128 * Zui.SCALE(ui)); + let state = zui_image(icon, 0xffffffff, 128 * zui_SCALE(ui)); if (state == State.Released) { let _uix = ui._x; ui._x = uix; - Zui.fill(0, 0, 128, 128, 0x66000000); + zui_fill(0, 0, 128, 128, 0x66000000); ui._x = _uix; let doImport = () => { - App.notifyOnInit(() => { + app_notify_on_init(() => { UIBox.hide(); ImportArm.runProject(path); }); @@ -134,11 +134,11 @@ class BoxProjects { } let name = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf(".")); - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { // if (UIMenu.menuButton(ui, tr("Duplicate"))) {} if (UIMenu.menuButton(ui, tr("Delete"))) { - App.notifyOnInit(() => { + app_notify_on_init(() => { File.delete(path); File.delete(iconPath); let dataPath = path.substr(0, path.length - 4); @@ -152,17 +152,17 @@ class BoxProjects { if (show_asset_names) { ui._x = uix - (150 - 128) / 2; ui._y += slotw * 0.9; - Zui.text(name, Align.Center); - if (ui.isHovered) Zui.tooltip(name); + zui_text(name, Align.Center); + if (ui.is_hovered) zui_tooltip(name); ui._y -= slotw * 0.9; if (i == recent_projects.length - 1) { - ui._y += j == num - 1 ? imgw : imgw + Zui.ELEMENT_H(ui) + Zui.ELEMENT_OFFSET(ui); + ui._y += j == num - 1 ? imgw : imgw + zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui); } } } else { - Zui.endElement(0); - if (show_asset_names) Zui.endElement(0); + zui_end_element(0); + if (show_asset_names) zui_end_element(0); ui._x = uix; } } @@ -172,13 +172,13 @@ class BoxProjects { } } - static recentProjectsTab = (ui: ZuiRaw) => { - if (Zui.tab(BoxProjects.htab, tr("Recent"), true)) { + static recentProjectsTab = (ui: zui_t) => { + if (zui_tab(BoxProjects.htab, tr("Recent"), true)) { BoxProjects.drawBadge(ui); ui.enabled = Config.raw.recent_projects.length > 0; - BoxProjects.hsearch.text = Zui.textInput(BoxProjects.hsearch, tr("Search"), Align.Left, true, true); + BoxProjects.hsearch.text = zui_text_input(BoxProjects.hsearch, tr("Search"), Align.Left, true, true); ui.enabled = true; for (let path of Config.raw.recent_projects) { @@ -192,7 +192,7 @@ class BoxProjects { if (file.toLowerCase().indexOf(BoxProjects.hsearch.text.toLowerCase()) < 0) continue; // Search filter - if (Zui.button(file, Align.Left) && File.exists(path)) { + if (zui_button(file, Align.Left) && File.exists(path)) { let current = _g2_current; if (current != null) g2_end(current); @@ -201,51 +201,51 @@ class BoxProjects { if (current != null) g2_begin(current, false); UIBox.hide(); } - if (ui.isHovered) Zui.tooltip(path); + if (ui.is_hovered) zui_tooltip(path); } ui.enabled = Config.raw.recent_projects.length > 0; - if (Zui.button(tr("Clear"), Align.Left)) { + if (zui_button(tr("Clear"), Align.Left)) { Config.raw.recent_projects = []; Config.save(); } ui.enabled = true; - Zui.endElement(); - if (Zui.button(tr("New Project..."), Align.Left)) Project.projectNewBox(); - if (Zui.button(tr("Open..."), Align.Left)) Project.projectOpen(); + zui_end_element(); + if (zui_button(tr("New Project..."), Align.Left)) Project.projectNewBox(); + if (zui_button(tr("Open..."), Align.Left)) Project.projectOpen(); } } - static drawBadge = (ui: ZuiRaw) => { - Data.getImage("badge.k", (img: image_t) => { - Zui.image(img); - Zui.endElement(); + static drawBadge = (ui: zui_t) => { + data_get_image("badge.k", (img: image_t) => { + zui_image(img); + zui_end_element(); }); } - static getStartedTab = (ui: ZuiRaw) => { - if (Zui.tab(BoxProjects.htab, tr("Get Started"), true)) { - if (Zui.button(tr("Manual"))) { + static getStartedTab = (ui: zui_t) => { + if (zui_tab(BoxProjects.htab, tr("Get Started"), true)) { + if (zui_button(tr("Manual"))) { File.loadUrl(manifest_url + "/manual"); } - if (Zui.button(tr("How To"))) { + if (zui_button(tr("How To"))) { File.loadUrl(manifest_url + "/howto"); } - if (Zui.button(tr("What's New"))) { + if (zui_button(tr("What's New"))) { File.loadUrl(manifest_url + "/notes"); } } } static alignToFullScreen = () => { - UIBox.modalW = Math.floor(sys_width() / Zui.SCALE(Base.uiBox)); - UIBox.modalH = Math.floor(sys_height() / Zui.SCALE(Base.uiBox)); + UIBox.modalW = Math.floor(sys_width() / zui_SCALE(Base.uiBox)); + UIBox.modalH = Math.floor(sys_height() / zui_SCALE(Base.uiBox)); let appw = sys_width(); let apph = sys_height(); let mw = appw; let mh = apph; - UIBox.hwnd.dragX = Math.floor(-appw / 2 + mw / 2); - UIBox.hwnd.dragY = Math.floor(-apph / 2 + mh / 2); + UIBox.hwnd.drag_x = Math.floor(-appw / 2 + mw / 2); + UIBox.hwnd.drag_y = Math.floor(-apph / 2 + mh / 2); } } diff --git a/base/Sources/Camera.ts b/base/Sources/Camera.ts index 66a7963b1..9a3b10abb 100644 --- a/base/Sources/Camera.ts +++ b/base/Sources/Camera.ts @@ -16,25 +16,25 @@ class Camera { let camera = scene_camera; if (mouse_view_x() < 0 || - mouse_view_x() > App.w() || + mouse_view_x() > app_w() || mouse_view_y() < 0 || - mouse_view_y() > App.h()) { + mouse_view_y() > app_h()) { if (Config.raw.wrap_mouse && Camera.controlsDown) { if (mouse_view_x() < 0) { - mouse_x = mouse_last_x = App.x() + App.w(); + mouse_x = mouse_last_x = app_x() + app_w(); Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); } - else if (mouse_view_x() > App.w()) { - mouse_x = mouse_last_x = App.x(); + else if (mouse_view_x() > app_w()) { + mouse_x = mouse_last_x = app_x(); Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); } else if (mouse_view_y() < 0) { - mouse_y = mouse_last_y = App.y() + App.h(); + mouse_y = mouse_last_y = app_y() + app_h(); Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); } - else if (mouse_view_y() > App.h()) { - mouse_y = mouse_last_y = App.y(); + else if (mouse_view_y() > app_h()) { + mouse_y = mouse_last_y = app_y(); Krom.setMousePosition(Math.floor(mouse_x), Math.floor(mouse_y)); } } @@ -81,20 +81,20 @@ class Camera { if (controls == CameraControls.ControlsOrbit && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) { Camera.redraws = 2; let dist = Camera.distance(); - transform_move(camera.base.transform, CameraObject.lookWorld(camera), dist); + transform_move(camera.base.transform, camera_object_look_world(camera), dist); transform_rotate(camera.base.transform, vec4_z_axis(), -mouse_movement_x / 100 * Config.raw.camera_rotation_speed); - transform_rotate(camera.base.transform, CameraObject.rightWorld(camera), -mouse_movement_y / 100 * Config.raw.camera_rotation_speed); - if (CameraObject.upWorld(camera).z < 0) { - transform_rotate(camera.base.transform, CameraObject.rightWorld(camera), mouse_movement_y / 100 * Config.raw.camera_rotation_speed); + transform_rotate(camera.base.transform, camera_object_right_world(camera), -mouse_movement_y / 100 * Config.raw.camera_rotation_speed); + if (camera_object_up_world(camera).z < 0) { + transform_rotate(camera.base.transform, camera_object_right_world(camera), mouse_movement_y / 100 * Config.raw.camera_rotation_speed); } - transform_move(camera.base.transform, CameraObject.lookWorld(camera), -dist); + transform_move(camera.base.transform, camera_object_look_world(camera), -dist); } else if (controls == CameraControls.ControlsRotate && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) { Camera.redraws = 2; let t = Context.mainObject().base.transform; let up = vec4_normalize(transform_up(t)); transform_rotate(t, up, mouse_movement_x / 100 * Config.raw.camera_rotation_speed); - let right = vec4_normalize(CameraObject.rightWorld(camera)); + let right = vec4_normalize(camera_object_right_world(camera)); transform_rotate(t, right, mouse_movement_y / 100 * Config.raw.camera_rotation_speed); transform_build_matrix(t); if (transform_up(t).z < 0) { @@ -109,14 +109,14 @@ class Camera { Camera.redraws = 2; let f = Camera.getZoomDelta() / 150; f *= Camera.getCameraZoomSpeed(); - transform_move(camera.base.transform, CameraObject.look(camera), f); + transform_move(camera.base.transform, camera_object_look(camera), f); } if (mouse_wheel_delta != 0 && !modifKey) { Camera.redraws = 2; let f = mouse_wheel_delta * (-0.1); f *= Camera.getCameraZoomSpeed(); - transform_move(camera.base.transform, CameraObject.look(camera), f); + transform_move(camera.base.transform, camera_object_look(camera), f); } } else if (controls == CameraControls.ControlsFly && mouse_down("right")) { @@ -135,10 +135,10 @@ class Camera { Camera.ease += time_delta() * 15; if (Camera.ease > 1.0) Camera.ease = 1.0; vec4_set(Camera.dir, 0, 0, 0); - if (moveForward) vec4_add_f(Camera.dir, CameraObject.look(camera).x, CameraObject.look(camera).y, CameraObject.look(camera).z); - if (moveBackward) vec4_add_f(Camera.dir, -CameraObject.look(camera).x, -CameraObject.look(camera).y, -CameraObject.look(camera).z); - if (strafeRight) vec4_add_f(Camera.dir, CameraObject.right(camera).x, CameraObject.right(camera).y, CameraObject.right(camera).z); - if (strafeLeft) vec4_add_f(Camera.dir, -CameraObject.right(camera).x, -CameraObject.right(camera).y, -CameraObject.right(camera).z); + if (moveForward) vec4_add_f(Camera.dir, camera_object_look(camera).x, camera_object_look(camera).y, camera_object_look(camera).z); + if (moveBackward) vec4_add_f(Camera.dir, -camera_object_look(camera).x, -camera_object_look(camera).y, -camera_object_look(camera).z); + if (strafeRight) vec4_add_f(Camera.dir, camera_object_right(camera).x, camera_object_right(camera).y, camera_object_right(camera).z); + if (strafeLeft) vec4_add_f(Camera.dir, -camera_object_right(camera).x, -camera_object_right(camera).y, -camera_object_right(camera).z); if (strafeUp) vec4_add_f(Camera.dir, 0, 0, 1); if (strafeDown) vec4_add_f(Camera.dir, 0, 0, -1); } @@ -158,7 +158,7 @@ class Camera { Camera.redraws = 2; transform_rotate(camera.base.transform, vec4_z_axis(), -mouse_movement_x / 200 * Config.raw.camera_rotation_speed); - transform_rotate(camera.base.transform, CameraObject.right(camera), -mouse_movement_y / 200 * Config.raw.camera_rotation_speed); + transform_rotate(camera.base.transform, camera_object_right(camera), -mouse_movement_y / 200 * Config.raw.camera_rotation_speed); } if (Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutDown)) { @@ -223,7 +223,7 @@ class Camera { vec4_add(camera.base.transform.loc, right); vec4_add(Camera.origins[Camera.index()], look); vec4_add(Camera.origins[Camera.index()], right); - CameraObject.buildMatrix(camera); + camera_object_build_matrix(camera); } } diff --git a/base/Sources/Config.ts b/base/Sources/Config.ts index 00a763ad0..f76aa8feb 100644 --- a/base/Sources/Config.ts +++ b/base/Sources/Config.ts @@ -10,7 +10,7 @@ class Config { static load = (done: ()=>void) => { try { - Data.getBlob((Path.isProtected() ? Krom.savePath() : "") + "config.json", (blob: ArrayBuffer) => { + data_get_blob((Path.isProtected() ? Krom.savePath() : "") + "config.json", (blob: ArrayBuffer) => { Config.configLoaded = true; Config.raw = JSON.parse(sys_buffer_to_string(blob)); @@ -20,7 +20,7 @@ class Config { catch (e: any) { ///if krom_linux try { // Protected directory - Data.getBlob(Krom.savePath() + "config.json", (blob: ArrayBuffer) => { + data_get_blob(Krom.savePath() + "config.json", (blob: ArrayBuffer) => { Config.configLoaded = true; Config.raw = JSON.parse(sys_buffer_to_string(blob)); done(); @@ -101,14 +101,16 @@ class Config { } } - Zui.touchScroll = Zui.touchHold = Zui.touchTooltip = Config.raw.touch_ui; + zui_set_touch_scroll(Config.raw.touch_ui); + zui_set_touch_hold(Config.raw.touch_ui); + zui_set_touch_tooltip(Config.raw.touch_ui); Base.resHandle.position = Config.raw.layer_res; Config.loadKeymap(); } static getSha = (): string => { let sha = ""; - Data.getBlob("version.json", (blob: ArrayBuffer) => { + data_get_blob("version.json", (blob: ArrayBuffer) => { sha = JSON.parse(sys_buffer_to_string(blob)).sha; }); return sha; @@ -116,7 +118,7 @@ class Config { static getDate = (): string => { let date = ""; - Data.getBlob("version.json", (blob: ArrayBuffer) => { + data_get_blob("version.json", (blob: ArrayBuffer) => { date = JSON.parse(sys_buffer_to_string(blob)).date; }); return date; @@ -143,7 +145,7 @@ class Config { } static restore = () => { - Zui.children = new Map(); // Reset ui handles + zui_children = new Map(); // Reset ui handles Config.configLoaded = false; let _layout = Config.raw.layout; Config.init(); @@ -160,7 +162,7 @@ class Config { Config.raw = from; Config.raw.sha = _sha; Config.raw.version = _version; - Zui.children = new Map(); // Reset ui handles + zui_children = new Map(); // Reset ui handles Config.loadKeymap(); Base.initLayout(); Translator.loadTranslations(Config.raw.locale); @@ -188,7 +190,7 @@ class Config { Config.keymap = Base.defaultKeymap; } else { - Data.getBlob("keymap_presets/" + Config.raw.keymap, (blob: ArrayBuffer) => { + data_get_blob("keymap_presets/" + Config.raw.keymap, (blob: ArrayBuffer) => { Config.keymap = JSON.parse(sys_buffer_to_string(blob)); // Fill in undefined keys with defaults for (let field in Base.defaultKeymap) { @@ -203,7 +205,7 @@ class Config { static saveKeymap = () => { if (Config.raw.keymap == "default.json") return; - let path = Data.dataPath + "keymap_presets/" + Config.raw.keymap; + let path = data_data_path() + "keymap_presets/" + Config.raw.keymap; let buffer = sys_string_to_buffer(JSON.stringify(Config.keymap)); Krom.fileSaveBytes(path, buffer); } @@ -269,12 +271,12 @@ class Config { static loadTheme = (theme: string, tagRedraw = true) => { if (theme == "default.json") { // Built-in default - Base.theme = Theme.create(); + Base.theme = zui_theme_create(); } else { - Data.getBlob("themes/" + theme, (b: ArrayBuffer) => { + data_get_blob("themes/" + theme, (b: ArrayBuffer) => { let parsed = JSON.parse(sys_buffer_to_string(b)); - Base.theme = Theme.create(); + Base.theme = zui_theme_create(); for (let key in Base.theme) { if (key == "theme_") continue; if (key.startsWith("set_")) continue; diff --git a/base/Sources/Console.ts b/base/Sources/Console.ts index 6bd5f5f58..8394091b9 100644 --- a/base/Sources/Console.ts +++ b/base/Sources/Console.ts @@ -10,7 +10,7 @@ class Console { static drawToast = (s: string, g: g2_t) => { g.color = 0x55000000; g2_fill_rect(0, 0, sys_width(), sys_height()); - let scale = Zui.SCALE(Base.getUIs()[0]); + let scale = zui_SCALE(Base.getUIs()[0]); let x = sys_width() / 2; let y = sys_height() - 200 * scale; g2_fill_rect(x - 200 * scale, y, 400 * scale, 80 * scale); @@ -26,11 +26,11 @@ class Console { Console.drawToast(s, g); if (g2 == null) { Base.notifyOnNextFrame(() => { - App.removeRender2D(_render); + app_remove_render_2d(_render); }); } } - g2 != null ? _render(g2) : App.notifyOnRender2D(_render); + g2 != null ? _render(g2) : app_notify_on_render_2d(_render); Console.consoleTrace(s); } @@ -41,10 +41,10 @@ class Console { static progress = (s: string) => { // Keep popup message displayed until s == null if (s == null) { - App.removeRender2D(Console.drawProgress); + app_remove_render_2d(Console.drawProgress); } else if (Console.progressText == null) { - App.notifyOnRender2D(Console.drawProgress); + app_notify_on_render_2d(Console.drawProgress); } if (s != null) Console.consoleTrace(s); Console.progressText = s; diff --git a/base/Sources/Context.ts b/base/Sources/Context.ts index e86fbc28c..599319fbc 100644 --- a/base/Sources/Context.ts +++ b/base/Sources/Context.ts @@ -141,7 +141,7 @@ class Context { } ///end - static selectPaintObject = (o: TMeshObject) => { + static selectPaintObject = (o: mesh_object_t) => { ///if (is_paint || is_sculpt) UIHeader.headerHandle.redraws = 2; for (let p of Project.paintObjects) p.skip_context = "paint"; @@ -163,7 +163,7 @@ class Context { ///end } - static mainObject = (): TMeshObject => { + static mainObject = (): mesh_object_t => { ///if (is_paint || is_sculpt) for (let po of Project.paintObjects) if (po.base.children.length > 0) return po; return Project.paintObjects[0]; @@ -201,10 +201,10 @@ class Context { static inPaintArea = (): bool => { ///if (is_paint || is_sculpt) - let right = App.w(); + let right = app_w(); if (UIView2D.show) right += UIView2D.ww; return mouse_view_x() > 0 && mouse_view_x() < right && - mouse_view_y() > 0 && mouse_view_y() < App.h(); + mouse_view_y() > 0 && mouse_view_y() < app_h(); ///end ///if is_lab @@ -213,11 +213,11 @@ class Context { } static inLayers = (): bool => { - return Zui.getHoveredTabName() == tr("Layers"); + return zui_get_hovered_tab_name() == tr("Layers"); } static inMaterials = (): bool => { - return Zui.getHoveredTabName() == tr("Materials"); + return zui_get_hovered_tab_name() == tr("Materials"); } ///if (is_paint || is_sculpt) @@ -235,11 +235,11 @@ class Context { } static inSwatches = (): bool => { - return Zui.getHoveredTabName() == tr("Swatches"); + return zui_get_hovered_tab_name() == tr("Swatches"); } static inBrowser = (): bool => { - return Zui.getHoveredTabName() == tr("Browser"); + return zui_get_hovered_tab_name() == tr("Browser"); } static getAreaType = (): AreaType => { @@ -274,7 +274,7 @@ class Context { if (!Context.raw.envmapLoaded) { // TODO: Unable to share texture for both radiance and envmap - reload image Context.raw.envmapLoaded = true; - Data.cachedImages.delete("World_radiance.k"); + data_cached_images.delete("World_radiance.k"); } world_data_load_envmap(scene_world, (_) => {}); if (Context.raw.savedEnvmap == null) Context.raw.savedEnvmap = scene_world._envmap; @@ -301,7 +301,7 @@ class Context { else { render_path_commands = RenderPathDeferred.commands; } - App.notifyOnInit(() => { + app_notify_on_init(() => { MakeMaterial.parseMeshMaterial(); }); } @@ -339,7 +339,7 @@ class Context { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); - let inpaint = nodes.nodesSelectedId.length > 0 && Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; + let inpaint = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; // Paint bounds if (inpaint && @@ -379,27 +379,27 @@ class Context { static parseBrushInputs = () => { if (!Context.raw.registered) { Context.raw.registered = true; - App.notifyOnUpdate(Context.update); + app_notify_on_update(Context.update); } Context.raw.paintVec = Context.raw.coords; } static update = () => { - let paintX = mouse_view_x() / App.w(); - let paintY = mouse_view_y() / App.h(); + let paintX = mouse_view_x() / app_w(); + let paintY = mouse_view_y() / app_h(); if (mouse_started()) { - Context.raw.startX = mouse_view_x() / App.w(); - Context.raw.startY = mouse_view_y() / App.h(); + Context.raw.startX = mouse_view_x() / app_w(); + Context.raw.startY = mouse_view_y() / app_h(); } if (pen_down()) { - paintX = pen_view_x() / App.w(); - paintY = pen_view_y() / App.h(); + paintX = pen_view_x() / app_w(); + paintY = pen_view_y() / app_h(); } if (pen_started()) { - Context.raw.startX = pen_view_x() / App.w(); - Context.raw.startY = pen_view_y() / App.h(); + Context.raw.startX = pen_view_x() / app_w(); + Context.raw.startY = pen_view_y() / app_h(); } if (Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown)) { diff --git a/base/Sources/ContextFormat.ts b/base/Sources/ContextFormat.ts index 469900cd2..bb26c607d 100644 --- a/base/Sources/ContextFormat.ts +++ b/base/Sources/ContextFormat.ts @@ -4,8 +4,8 @@ // type TContext = { class TContext { texture?: TAsset = null; - paintObject?: TMeshObject; - mergedObject?: TMeshObject = null; // For object mask + paintObject?: mesh_object_t; + mergedObject?: mesh_object_t = null; // For object mask mergedObjectIsAtlas? = false; // Only objects referenced by atlas are merged ddirty? = 0; // depth @@ -30,9 +30,9 @@ class TContext { previewEnvmap?: image_t = null; envmapLoaded? = false; showEnvmap? = false; - showEnvmapHandle? = Handle.create({ selected: false }); + showEnvmapHandle? = zui_handle_create({ selected: false }); showEnvmapBlur? = false; - showEnvmapBlurHandle? = Handle.create({ selected: false }); + showEnvmapBlurHandle? = zui_handle_create({ selected: false }); envmapAngle? = 0.0; lightAngle? = 0.0; cullBackfaces? = true; @@ -80,7 +80,7 @@ class TContext { showCompass? = true; projectType? = ProjectModel.ModelRoundedCube; projectAspectRatio? = 0; // 1:1, 2:1, 1:2 - projectObjects?: TMeshObject[]; + projectObjects?: mesh_object_t[]; lastPaintVecX? = -1.0; lastPaintVecY? = -1.0; @@ -95,14 +95,14 @@ class TContext { brushCanLock? = false; brushCanUnlock? = false; cameraType? = CameraType.CameraPerspective; - camHandle? = Handle.create(); - fovHandle?: HandleRaw = null; - undoHandle?: HandleRaw = null; - hssao?: HandleRaw = null; - hssr?: HandleRaw = null; - hbloom?: HandleRaw = null; - hsupersample?: HandleRaw = null; - hvxao?: HandleRaw = null; + camHandle? = zui_handle_create(); + fovHandle?: zui_handle_t = null; + undoHandle?: zui_handle_t = null; + hssao?: zui_handle_t = null; + hssr?: zui_handle_t = null; + hbloom?: zui_handle_t = null; + hsupersample?: zui_handle_t = null; + hvxao?: zui_handle_t = null; ///if is_forge vxaoExt? = 2.0; ///else @@ -141,7 +141,7 @@ class TContext { uvxPicked? = 0.0; uvyPicked? = 0.0; pickerSelectMaterial? = true; - pickerMaskHandle? = Handle.create(); + pickerMaskHandle? = zui_handle_create(); pickPosNorTex? = false; posXPicked? = 0.0; posYPicked? = 0.0; @@ -151,11 +151,11 @@ class TContext { norZPicked? = 0.0; drawWireframe? = false; - wireframeHandle? = Handle.create({ selected: false }); + wireframeHandle? = zui_handle_create({ selected: false }); drawTexels? = false; - texelsHandle? = Handle.create({ selected: false }); + texelsHandle? = zui_handle_create({ selected: false }); - colorIdHandle? = Handle.create(); + colorIdHandle? = zui_handle_create(); layersExport? = ExportMode.ExportVisible; decalImage?: image_t = null; @@ -185,16 +185,16 @@ class TContext { runBrush?: (i: i32)=>void = null; parseBrushInputs?: ()=>void = null; - gizmo?: TBaseObject = null; - gizmoTranslateX?: TBaseObject = null; - gizmoTranslateY?: TBaseObject = null; - gizmoTranslateZ?: TBaseObject = null; - gizmoScaleX?: TBaseObject = null; - gizmoScaleY?: TBaseObject = null; - gizmoScaleZ?: TBaseObject = null; - gizmoRotateX?: TBaseObject = null; - gizmoRotateY?: TBaseObject = null; - gizmoRotateZ?: TBaseObject = null; + gizmo?: object_t = null; + gizmoTranslateX?: object_t = null; + gizmoTranslateY?: object_t = null; + gizmoTranslateZ?: object_t = null; + gizmoScaleX?: object_t = null; + gizmoScaleY?: object_t = null; + gizmoScaleZ?: object_t = null; + gizmoRotateX?: object_t = null; + gizmoRotateY?: object_t = null; + gizmoRotateZ?: object_t = null; gizmoStarted? = false; gizmoOffset? = 0.0; gizmoDrag? = 0.0; @@ -227,17 +227,17 @@ class TContext { brushDirectional? = false; brushRadius? = 0.5; - brushRadiusHandle? = Handle.create({ value: 0.5 }); + brushRadiusHandle? = zui_handle_create({ value: 0.5 }); brushScaleX? = 1.0; brushDecalMaskRadius? = 0.5; - brushDecalMaskRadiusHandle? = Handle.create({ value: 0.5 }); - brushScaleXHandle? = Handle.create({ value: 1.0 }); + brushDecalMaskRadiusHandle? = zui_handle_create({ value: 0.5 }); + brushScaleXHandle? = zui_handle_create({ value: 1.0 }); brushBlending? = BlendType.BlendMix; brushOpacity? = 1.0; - brushOpacityHandle? = Handle.create({ value: 1.0 }); + brushOpacityHandle? = zui_handle_create({ value: 1.0 }); brushScale? = 1.0; brushAngle? = 0.0; - brushAngleHandle? = Handle.create({ value: 0.0 }); + brushAngleHandle? = zui_handle_create({ value: 0.0 }); ///if is_paint brushHardness? = 0.8; ///end @@ -267,7 +267,7 @@ class TContext { symX? = false; symY? = false; symZ? = false; - fillTypeHandle? = Handle.create(); + fillTypeHandle? = zui_handle_create(); paint2d? = false; @@ -284,7 +284,7 @@ class TContext { colorPickerPreviousTool? = WorkspaceTool.ToolEraser; brushRadius? = 0.25; - brushRadiusHandle? = Handle.create({ value: 0.25 }); + brushRadiusHandle? = zui_handle_create({ value: 0.25 }); brushScale? = 1.0; coords? = vec4_create(); @@ -301,6 +301,6 @@ class TContext { ///end ///if is_forge - selectedObject?: TBaseObject = null; + selectedObject?: object_t = null; ///end } diff --git a/base/Sources/ExportArm.ts b/base/Sources/ExportArm.ts index 950abb787..5af30646f 100644 --- a/base/Sources/ExportArm.ts +++ b/base/Sources/ExportArm.ts @@ -1,7 +1,7 @@ class ExportArm { - static runMesh = (path: string, paintObjects: TMeshObject[]) => { + static runMesh = (path: string, paintObjects: mesh_object_t[]) => { let mesh_datas: mesh_data_t[] = []; for (let p of paintObjects) mesh_datas.push(p.data); let raw: scene_t = { mesh_datas: mesh_datas }; @@ -12,27 +12,27 @@ class ExportArm { static runProject = () => { ///if (is_paint || is_sculpt) - let mnodes: TNodeCanvas[] = []; + let mnodes: zui_node_canvas_t[] = []; for (let m of Project.materials) { - let c: TNodeCanvas = JSON.parse(JSON.stringify(m.canvas)); + let c: zui_node_canvas_t = JSON.parse(JSON.stringify(m.canvas)); for (let n of c.nodes) ExportArm.exportNode(n); mnodes.push(c); } - let bnodes: TNodeCanvas[] = []; + let bnodes: zui_node_canvas_t[] = []; for (let b of Project.brushes) bnodes.push(b.canvas); ///end ///if is_lab - let c: TNodeCanvas = JSON.parse(JSON.stringify(Project.canvas)); + let c: zui_node_canvas_t = JSON.parse(JSON.stringify(Project.canvas)); for (let n of c.nodes) ExportArm.exportNode(n); ///end - let mgroups: TNodeCanvas[] = null; + let mgroups: zui_node_canvas_t[] = null; if (Project.materialGroups.length > 0) { mgroups = []; for (let g of Project.materialGroups) { - let c: TNodeCanvas = JSON.parse(JSON.stringify(g.canvas)); + let c: zui_node_canvas_t = JSON.parse(JSON.stringify(g.canvas)); for (let n of c.nodes) ExportArm.exportNode(n); mgroups.push(c); } @@ -140,7 +140,7 @@ class ExportArm { ///if (krom_android || krom_ios) let tex = render_path_render_targets.get(Context.raw.renderMode == RenderMode.RenderForward ? "buf" : "tex").image; let mesh_icon = image_create_render_target(256, 256); - let r = App.w() / App.h(); + let r = app_w() / app_h(); g2_begin(mesh_icon.g2, false); ///if krom_opengl g2_draw_scaled_image(tex, -(256 * r - 256) / 2, 256, 256 * r, -256); @@ -205,7 +205,7 @@ class ExportArm { ///end } - static exportNode = (n: TNode, assets: TAsset[] = null) => { + static exportNode = (n: zui_node_t, assets: TAsset[] = null) => { if (n.type == ExportArm.textureNodeName()) { let index = n.buttons[0].default_value; n.buttons[0].data = Base.enumTexts(n.type)[index]; @@ -226,10 +226,10 @@ class ExportArm { ///if (is_paint || is_sculpt) static runMaterial = (path: string) => { if (!path.endsWith(".arm")) path += ".arm"; - let mnodes: TNodeCanvas[] = []; - let mgroups: TNodeCanvas[] = null; + let mnodes: zui_node_canvas_t[] = []; + let mgroups: zui_node_canvas_t[] = null; let m = Context.raw.material; - let c: TNodeCanvas = JSON.parse(JSON.stringify(m.canvas)); + let c: zui_node_canvas_t = JSON.parse(JSON.stringify(m.canvas)); let assets: TAsset[] = []; if (UINodes.hasGroup(c)) { mgroups = []; @@ -292,9 +292,9 @@ class ExportArm { ///if (is_paint || is_sculpt) static runBrush = (path: string) => { if (!path.endsWith(".arm")) path += ".arm"; - let bnodes: TNodeCanvas[] = []; + let bnodes: zui_node_canvas_t[] = []; let b = Context.raw.brush; - let c: TNodeCanvas = JSON.parse(JSON.stringify(b.canvas)); + let c: zui_node_canvas_t = JSON.parse(JSON.stringify(b.canvas)); let assets: TAsset[] = []; for (let n of c.nodes) ExportArm.exportNode(n, assets); bnodes.push(c); diff --git a/base/Sources/ExportMesh.ts b/base/Sources/ExportMesh.ts index e69dbf0bc..4550b72af 100644 --- a/base/Sources/ExportMesh.ts +++ b/base/Sources/ExportMesh.ts @@ -1,7 +1,7 @@ class ExportMesh { - static run = (path: string, paintObjects: TMeshObject[] = null, applyDisplacement = false) => { + static run = (path: string, paintObjects: mesh_object_t[] = null, applyDisplacement = false) => { if (paintObjects == null) paintObjects = Project.paintObjects; if (Context.raw.exportMeshFormat == MeshFormat.FormatObj) ExportObj.run(path, paintObjects, applyDisplacement); else ExportArm.runMesh(path, paintObjects); diff --git a/base/Sources/ExportObj.ts b/base/Sources/ExportObj.ts index bfdc1f2c2..6ab7a6d10 100644 --- a/base/Sources/ExportObj.ts +++ b/base/Sources/ExportObj.ts @@ -7,7 +7,7 @@ class ExportObj { } } - static run = (path: string, paintObjects: TMeshObject[], applyDisplacement = false) => { + static run = (path: string, paintObjects: mesh_object_t[], applyDisplacement = false) => { let o: i32[] = []; ExportObj.writeString(o, "# armorpaint.org\n"); diff --git a/base/Sources/ExportTexture.ts b/base/Sources/ExportTexture.ts index 47d78bbba..012e903d0 100644 --- a/base/Sources/ExportTexture.ts +++ b/base/Sources/ExportTexture.ts @@ -94,7 +94,7 @@ class ExportTexture { Context.raw.tool = WorkspaceTool.ToolFill; MakeMaterial.parsePaintMaterial(); let _paintObject = Context.raw.paintObject; - let planeo: TMeshObject = scene_get_child(".Plane").ext; + let planeo: mesh_object_t = scene_get_child(".Plane").ext; planeo.base.visible = true; Context.raw.paintObject = planeo; Context.raw.pdirty = 1; @@ -140,7 +140,7 @@ class ExportTexture { Base.makeTempImg(); Base.makeExportImg(); if (Base.pipeMerge == null) Base.makePipe(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); let empty = render_path_render_targets.get("empty_white").image; // Append object mask name @@ -205,8 +205,8 @@ class ExportTexture { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, layers.length > 1 ? l1.blending : 0); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -226,8 +226,8 @@ class ExportTexture { g4_set_tex(Base.texa, Base.tempImage); g4_set_float(Base.opac, SlotLayer.getOpacity(l1)); g4_set_int(Base.blending, l1.paintNorBlend ? -2 : -1); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); } @@ -361,7 +361,7 @@ class ExportTexture { if (Context.raw.layersDestination == ExportDestination.DestinationPacked) { let image = image_from_bytes(pixels, resX, resY); - Data.cachedImages.set(file, image); + data_cached_images.set(file, image); let ar = file.split(Path.sep); let name = ar[ar.length - 1]; let asset: TAsset = {name: name, file: file, id: Project.assetId++}; diff --git a/base/Sources/Gizmo.ts b/base/Sources/Gizmo.ts index bd596913c..c2e363fb0 100644 --- a/base/Sources/Gizmo.ts +++ b/base/Sources/Gizmo.ts @@ -17,7 +17,7 @@ class Gizmo { gizmo.visible = (isObject || isDecal) && !hide; if (!gizmo.visible) return; - let paintObject: TBaseObject = Context.raw.paintObject.base; + let paintObject: object_t = Context.raw.paintObject.base; ///if is_forge if (Context.raw.selectedObject != null) { paintObject = Context.raw.selectedObject; diff --git a/base/Sources/History.ts b/base/Sources/History.ts index dd2fbf56e..6b240a618 100644 --- a/base/Sources/History.ts +++ b/base/Sources/History.ts @@ -143,7 +143,7 @@ class History { Context.raw.layer = Project.layers[step.layer]; SlotLayer.invertMask(Context.raw.layer); } - App.notifyOnInit(_next); + app_notify_on_init(_next); } else if (step.name == "Apply Filter") { History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1; @@ -181,7 +181,7 @@ class History { MakeMaterial.parseMeshMaterial(); } else if (step.name == tr("Delete Node Group")) { - Project.materialGroups.splice(step.canvas_group, 0, { canvas: null, nodes: Nodes.create() }); + Project.materialGroups.splice(step.canvas_group, 0, { canvas: null, nodes: zui_nodes_create() }); History.swapCanvas(step); } else if (step.name == tr("New Material")) { @@ -308,8 +308,8 @@ class History { } else if (step.name == tr("Merge Layers")) { Context.raw.layer = Project.layers[step.layer + 1]; - App.notifyOnInit(History.redoMergeLayers); - App.notifyOnInit(Base.mergeDown); + app_notify_on_init(History.redoMergeLayers); + app_notify_on_init(Base.mergeDown); } else if (step.name == tr("Apply Mask")) { Context.raw.layer = Project.layers[step.layer]; @@ -333,7 +333,7 @@ class History { Context.raw.layer = Project.layers[step.layer]; SlotLayer.invertMask(Context.raw.layer); } - App.notifyOnInit(_next); + app_notify_on_init(_next); } else if (step.name == tr("Apply Filter")) { let lay = History.undoLayers[History.undoI]; @@ -434,10 +434,10 @@ class History { } ///if (is_paint || is_sculpt) - static editNodes = (canvas: TNodeCanvas, canvas_type: i32, canvas_group: Null = null) => { + static editNodes = (canvas: zui_node_canvas_t, canvas_type: i32, canvas_group: Null = null) => { ///end ///if is_lab - static editNodes = (canvas: TNodeCanvas, canvas_group: Null = null) => { + static editNodes = (canvas: zui_node_canvas_t, canvas_group: Null = null) => { ///end let step = History.push(tr("Edit Nodes")); step.canvas_group = canvas_group; @@ -505,7 +505,7 @@ class History { } History.steps.shift(); // Merge consumes 2 steps History.undos--; - // TODO: use undo layer in App.mergeDown to save memory + // TODO: use undo layer in app_merge_down to save memory } static applyMask = () => { @@ -723,7 +723,7 @@ class History { type TStep = { name: string; - canvas?: TNodeCanvas; // Node history + canvas?: zui_node_canvas_t; // Node history canvas_group?: i32; ///if (is_paint || is_sculpt) layer: i32; diff --git a/base/Sources/ImportArm.ts b/base/Sources/ImportArm.ts index b3354c018..a4267c669 100644 --- a/base/Sources/ImportArm.ts +++ b/base/Sources/ImportArm.ts @@ -2,7 +2,7 @@ class ImportArm { static runProject = (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let project: TProjectFormat = armpack_decode(b); ///if (is_paint || is_sculpt) @@ -72,7 +72,7 @@ class ImportArm { let base = Path.baseDir(path); if (Project.raw.envmap != null) { - Project.raw.envmap = Data.isAbsolute(Project.raw.envmap) ? Project.raw.envmap : base + Project.raw.envmap; + Project.raw.envmap = data_is_abs(Project.raw.envmap) ? Project.raw.envmap : base + Project.raw.envmap; } if (Project.raw.envmap_strength != null) { scene_world.strength = Project.raw.envmap_strength; @@ -81,7 +81,7 @@ class ImportArm { scene_camera.base.transform.local = mat4_from_f32_array(Project.raw.camera_world); transform_decompose(scene_camera.base.transform); scene_camera.data.fov = Project.raw.camera_fov; - CameraObject.buildProjection(scene_camera); + camera_object_build_projection(scene_camera); let origin = Project.raw.camera_origin; Camera.origins[0].x = origin[0]; Camera.origins[0].y = origin[1]; @@ -95,12 +95,12 @@ class ImportArm { file = file.replaceAll("\\", "/"); ///end // Convert image path from relative to absolute - let abs = Data.isAbsolute(file) ? file : base + file; + let abs = data_is_abs(file) ? file : base + file; if (project.packed_assets != null) { abs = Path.normalize(abs); ImportArm.unpackAsset(project, abs, file); } - if (Data.cachedImages.get(abs) == null && !File.exists(abs)) { + if (data_cached_images.get(abs) == null && !File.exists(abs)) { ImportArm.makePink(abs); } let hdrAsEnvmap = abs.endsWith(".hdr") && Project.raw.envmap == abs; @@ -116,7 +116,7 @@ class ImportArm { file = file.replaceAll("\\", "/"); ///end // Convert font path from relative to absolute - let abs = Data.isAbsolute(file) ? file : base + file; + let abs = data_is_abs(file) ? file : base + file; if (File.exists(abs)) { ImportFont.run(abs); } @@ -126,14 +126,14 @@ class ImportArm { // Synchronous for now ///if (is_paint || is_sculpt) - MeshData.create(project.mesh_datas[0], (md: mesh_data_t) => { + mesh_data_create(project.mesh_datas[0], (md: mesh_data_t) => { ///end ///if is_lab - MeshData.create(project.mesh_data, (md: mesh_data_t) => { + mesh_data_create(project.mesh_data, (md: mesh_data_t) => { ///end - MeshObject.setData(Context.raw.paintObject, md); + mesh_object_set_data(Context.raw.paintObject, md); vec4_set(Context.raw.paintObject.base.transform.scale, 1, 1, 1); transform_build_matrix(Context.raw.paintObject.base.transform); Context.raw.paintObject.base.name = md.name; @@ -143,7 +143,7 @@ class ImportArm { ///if (is_paint || is_sculpt) for (let i = 1; i < project.mesh_datas.length; ++i) { let raw = project.mesh_datas[i]; - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base); object.base.name = md.name; object.skip_context = "paint"; @@ -153,7 +153,7 @@ class ImportArm { if (project.mesh_assets != null && project.mesh_assets.length > 0) { let file = project.mesh_assets[0]; - let abs = Data.isAbsolute(file) ? file : base + file; + let abs = data_is_abs(file) ? file : base + file; Project.meshAssets = [abs]; } @@ -300,7 +300,7 @@ class ImportArm { // Materials let m0: material_data_t = null; - Data.getMaterial("Scene", "Material", (m: material_data_t) => { + data_get_material("Scene", "Material", (m: material_data_t) => { m0 = m; }); @@ -316,7 +316,7 @@ class ImportArm { UINodes.groupStack = []; Project.materialGroups = []; if (project.material_groups != null) { - for (let g of project.material_groups) Project.materialGroups.push({ canvas: g, nodes: Nodes.create() }); + for (let g of project.material_groups) Project.materialGroups.push({ canvas: g, nodes: zui_nodes_create() }); } ///if (is_paint || is_sculpt) @@ -356,7 +356,7 @@ class ImportArm { ///end Context.raw.ddirty = 4; - Data.deleteBlob(path); + data_delete_blob(path); }); } @@ -364,10 +364,10 @@ class ImportArm { static runMesh = (raw: scene_t) => { Project.paintObjects = []; for (let i = 0; i < raw.mesh_datas.length; ++i) { - MeshData.create(raw.mesh_datas[i], (md: mesh_data_t) => { - let object: TMeshObject = null; + mesh_data_create(raw.mesh_datas[i], (md: mesh_data_t) => { + let object: mesh_object_t = null; if (i == 0) { - MeshObject.setData(Context.raw.paintObject, md); + mesh_object_set_data(Context.raw.paintObject, md); object = Context.raw.paintObject; } else { @@ -375,7 +375,7 @@ class ImportArm { object.base.name = md.name; object.skip_context = "paint"; md._handle = md.name; - Data.cachedMeshes.set(md._handle, md); + data_cached_meshes.set(md._handle, md); } vec4_set(object.base.transform.scale, 1, 1, 1); transform_build_matrix(object.base.transform); @@ -385,14 +385,14 @@ class ImportArm { Viewport.scaleToBounds(); }); } - App.notifyOnInit(Base.initLayers); + app_notify_on_init(Base.initLayers); History.reset(); } static runMaterial = (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let project: TProjectFormat = armpack_decode(b); - if (project.version == null) { Data.deleteBlob(path); return; } + if (project.version == null) { data_delete_blob(path); return; } ImportArm.runMaterialFromProject(project, path); }); } @@ -406,19 +406,19 @@ class ImportArm { file = file.replaceAll("\\", "/"); ///end // Convert image path from relative to absolute - let abs = Data.isAbsolute(file) ? file : base + file; + let abs = data_is_abs(file) ? file : base + file; if (project.packed_assets != null) { abs = Path.normalize(abs); ImportArm.unpackAsset(project, abs, file); } - if (Data.cachedImages.get(abs) == null && !File.exists(abs)) { + if (data_cached_images.get(abs) == null && !File.exists(abs)) { ImportArm.makePink(abs); } ImportTexture.run(abs); } let m0: material_data_t = null; - Data.getMaterial("Scene", "Material", (m: material_data_t) => { + data_get_material("Scene", "Material", (m: material_data_t) => { m0 = m; }); @@ -436,7 +436,7 @@ class ImportArm { for (let c of project.material_groups) { while (ImportArm.groupExists(c)) ImportArm.renameGroup(c.name, imported, project.material_groups); // Ensure unique group name ImportArm.initNodes(c.nodes); - Project.materialGroups.push({ canvas: c, nodes: Nodes.create() }); + Project.materialGroups.push({ canvas: c, nodes: zui_nodes_create() }); } } @@ -447,21 +447,21 @@ class ImportArm { UtilRender.makeMaterialPreview(); } } - App.notifyOnInit(_init); + app_notify_on_init(_init); UINodes.groupStack = []; UIBase.hwnds[TabArea.TabSidebar1].redraws = 2; - Data.deleteBlob(path); + data_delete_blob(path); } - static groupExists = (c: TNodeCanvas): bool => { + static groupExists = (c: zui_node_canvas_t): bool => { for (let g of Project.materialGroups) { if (g.canvas.name == c.name) return true; } return false; } - static renameGroup = (name: string, materials: SlotMaterialRaw[], groups: TNodeCanvas[]) => { + static renameGroup = (name: string, materials: SlotMaterialRaw[], groups: zui_node_canvas_t[]) => { for (let m of materials) { for (let n of m.canvas.nodes) { if (n.type == "GROUP" && n.name == name) n.name += ".1"; @@ -476,9 +476,9 @@ class ImportArm { } static runBrush = (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let project: TProjectFormat = armpack_decode(b); - if (project.version == null) { Data.deleteBlob(path); return; } + if (project.version == null) { data_delete_blob(path); return; } ImportArm.runBrushFromProject(project, path); }); } @@ -492,12 +492,12 @@ class ImportArm { file = file.replaceAll("\\", "/"); ///end // Convert image path from relative to absolute - let abs = Data.isAbsolute(file) ? file : base + file; + let abs = data_is_abs(file) ? file : base + file; if (project.packed_assets != null) { abs = Path.normalize(abs); ImportArm.unpackAsset(project, abs, file); } - if (Data.cachedImages.get(abs) == null && !File.exists(abs)) { + if (data_cached_images.get(abs) == null && !File.exists(abs)) { ImportArm.makePink(abs); } ImportTexture.run(abs); @@ -518,17 +518,17 @@ class ImportArm { UtilRender.makeBrushPreview(); } } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIBase.hwnds[TabArea.TabSidebar1].redraws = 2; - Data.deleteBlob(path); + data_delete_blob(path); } ///end static runSwatches = (path: string, replaceExisting = false) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let project: TProjectFormat = armpack_decode(b); - if (project.version == null) { Data.deleteBlob(path); return; } + if (project.version == null) { data_delete_blob(path); return; } ImportArm.runSwatchesFromProject(project, path, replaceExisting); }); } @@ -548,7 +548,7 @@ class ImportArm { } } UIBase.hwnds[TabArea.TabStatus].redraws = 2; - Data.deleteBlob(path); + data_delete_blob(path); } static makePink = (abs: string) => { @@ -559,7 +559,7 @@ class ImportArm { b[2] = 255; b[3] = 255; let pink = image_from_bytes(b.buffer, 1, 1); - Data.cachedImages.set(abs, pink); + data_cached_images.set(abs, pink); } static textureNodeName = (): string => { @@ -570,7 +570,7 @@ class ImportArm { ///end } - static initNodes = (nodes: TNode[]) => { + static initNodes = (nodes: zui_node_t[]) => { for (let node of nodes) { if (node.type == ImportArm.textureNodeName()) { node.buttons[0].default_value = Base.getAssetIndex(node.buttons[0].data); @@ -596,7 +596,7 @@ class ImportArm { Project.raw.packed_assets.push(pa); } image_from_encoded_bytes(pa.bytes, pa.name.endsWith(".jpg") ? ".jpg" : ".png", (image: image_t) => { - Data.cachedImages.set(abs, image); + data_cached_images.set(abs, image); }, null, false); break; } diff --git a/base/Sources/ImportBlendMaterial.ts b/base/Sources/ImportBlendMaterial.ts index c4d318549..3548c7ae8 100644 --- a/base/Sources/ImportBlendMaterial.ts +++ b/base/Sources/ImportBlendMaterial.ts @@ -4,7 +4,7 @@ class ImportBlendMaterial { static run = (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let bl = ParserBlend.init(b); if (bl.dna == null) { Console.error(Strings.error3()); @@ -27,7 +27,7 @@ class ImportBlendMaterial { let nodes = Context.raw.material.nodes; let canvas = Context.raw.material.canvas; canvas.name = BlHandle.get(BlHandle.get(mat, "id"), "name").substr(2); // MAWood - let nout: TNode = null; + let nout: zui_node_t = null; for (let n of canvas.nodes) { if (n.type == "OUTPUT_MATERIAL_PBR") { nout = n; @@ -36,7 +36,7 @@ class ImportBlendMaterial { } for (let n of canvas.nodes) { if (n.name == "RGB") { - Nodes.removeNode(n, canvas); + zui_remove_node(n, canvas); break; } } @@ -69,7 +69,7 @@ class ImportBlendMaterial { while (true) { // Search for node in list let search = BlHandle.get(node, "idname").substr(10).toLowerCase(); - let base: TNode = null; + let base: zui_node_t = null; for (let list of NodesMaterial.list) { let found = false; for (let n of list) { @@ -225,8 +225,8 @@ class ImportBlendMaterial { } if (valid) { - let raw: TNodeLink = { - id: Nodes.getLinkId(canvas.links), + let raw: zui_node_link_t = { + id: zui_get_link_id(canvas.links), from_id: from_id, from_socket: from_socket, to_id: to_id, @@ -250,10 +250,10 @@ class ImportBlendMaterial { UtilRender.makeMaterialPreview(); } } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIBase.hwnds[TabArea.TabSidebar1].redraws = 2; - Data.deleteBlob(path); + data_delete_blob(path); }); } diff --git a/base/Sources/ImportBlendMesh.ts b/base/Sources/ImportBlendMesh.ts index 5eaf4f0c3..77dcebc6e 100644 --- a/base/Sources/ImportBlendMesh.ts +++ b/base/Sources/ImportBlendMesh.ts @@ -4,7 +4,7 @@ class ImportBlendMesh { static eps = 1.0 / 32767; static run = (path: string, replaceExisting = true) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { let bl = ParserBlend.init(b); if (bl.dna == null) { Console.error(Strings.error3()); @@ -436,7 +436,7 @@ class ImportBlendMesh { first = false; } - Data.deleteBlob(path); + data_delete_blob(path); }); } diff --git a/base/Sources/ImportEnvmap.ts b/base/Sources/ImportEnvmap.ts index e9c407d15..8fba7152c 100644 --- a/base/Sources/ImportEnvmap.ts +++ b/base/Sources/ImportEnvmap.ts @@ -36,7 +36,7 @@ class ImportEnvmap { w = Math.floor(w / 2); } - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); } // Down-scale to 1024x512 @@ -93,8 +93,8 @@ class ImportEnvmap { static getRadianceMip = (mip: image_t, level: i32, radiance: image_t) => { g4_begin(mip.g4); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_set_pipeline(ImportEnvmap.pipeline); ImportEnvmap.params.x = 0.1 + level / 8; g4_set_float4(ImportEnvmap.paramsLocation, ImportEnvmap.params.x, ImportEnvmap.params.y, ImportEnvmap.params.z, ImportEnvmap.params.w); diff --git a/base/Sources/ImportFont.ts b/base/Sources/ImportFont.ts index c0c58a430..13bbbe26f 100644 --- a/base/Sources/ImportFont.ts +++ b/base/Sources/ImportFont.ts @@ -10,7 +10,7 @@ class ImportFont { return; } } - Data.getFont(path, (font: font_t) => { + data_get_font(path, (font: font_t) => { font_init(font); // Make sure font_ is ready let count = Krom.g2_font_count(font.font_); let fontSlots: SlotFontRaw[] = []; @@ -30,7 +30,7 @@ class ImportFont { UtilRender.makeFontPreview(); } } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIBase.hwnds[TabArea.TabStatus].redraws = 2; }); diff --git a/base/Sources/ImportGpl.ts b/base/Sources/ImportGpl.ts index a9c0f410f..9ef8d7bde 100644 --- a/base/Sources/ImportGpl.ts +++ b/base/Sources/ImportGpl.ts @@ -2,7 +2,7 @@ class ImportGpl { static run = (path: string, replaceExisting: bool) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { // let swatches = []; // let str = sys_buffer_to_string(b); diff --git a/base/Sources/ImportMesh.ts b/base/Sources/ImportMesh.ts index 6861721c5..e5299d4d9 100644 --- a/base/Sources/ImportMesh.ts +++ b/base/Sources/ImportMesh.ts @@ -61,8 +61,8 @@ class ImportMesh { static finishImport = () => { if (Context.raw.mergedObject != null) { - MeshData.delete(Context.raw.mergedObject.data); - MeshObject.remove(Context.raw.mergedObject); + mesh_data_delete(Context.raw.mergedObject.data); + mesh_object_remove(Context.raw.mergedObject); Context.raw.mergedObject = null; } @@ -106,27 +106,27 @@ class ImportMesh { let raw = ImportMesh.rawMesh(mesh); if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm", padding: 1 }); - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { Context.raw.paintObject = Context.mainObject(); Context.selectPaintObject(Context.mainObject()); for (let i = 0; i < Project.paintObjects.length; ++i) { let p = Project.paintObjects[i]; if (p == Context.raw.paintObject) continue; - Data.deleteMesh(p.data._handle); - MeshObject.remove(p); + data_delete_mesh(p.data._handle); + mesh_object_remove(p); } let handle = Context.raw.paintObject.data._handle; if (handle != "SceneSphere" && handle != "ScenePlane") { - Data.deleteMesh(handle); + data_delete_mesh(handle); } - MeshObject.setData(Context.raw.paintObject, md); + mesh_object_set_data(Context.raw.paintObject, md); Context.raw.paintObject.base.name = mesh.name; Project.paintObjects = [Context.raw.paintObject]; md._handle = raw.name; - Data.cachedMeshes.set(md._handle, md); + data_cached_meshes.set(md._handle, md); Context.raw.ddirty = 4; @@ -145,7 +145,7 @@ class ImportMesh { SlotLayer.unload(l); } Base.newLayer(false); - App.notifyOnInit(Base.initLayers); + app_notify_on_init(Base.initLayers); History.reset(); } ///end @@ -155,7 +155,7 @@ class ImportMesh { Base.notifyOnNextFrame(ImportMesh.finishImport); } else { - App.notifyOnInit(ImportMesh.finishImport); + app_notify_on_init(ImportMesh.finishImport); } }); } @@ -185,7 +185,7 @@ class ImportMesh { let raw = ImportMesh.rawMesh(mesh); if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm", padding: 1 }); - MeshData.create(raw, (md: mesh_data_t) => { + mesh_data_create(raw, (md: mesh_data_t) => { let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base); object.base.name = mesh.name; @@ -196,14 +196,14 @@ class ImportMesh { if (p.base.name == object.base.name) { p.base.name += ".001"; p.data._handle += ".001"; - Data.cachedMeshes.set(p.data._handle, p.data); + data_cached_meshes.set(p.data._handle, p.data); } } Project.paintObjects.push(object); md._handle = raw.name; - Data.cachedMeshes.set(md._handle, md); + data_cached_meshes.set(md._handle, md); Context.raw.ddirty = 4; diff --git a/base/Sources/ImportObj.ts b/base/Sources/ImportObj.ts index 82ced55a0..a47e89726 100644 --- a/base/Sources/ImportObj.ts +++ b/base/Sources/ImportObj.ts @@ -9,7 +9,7 @@ class ImportObj { i == SplitType.SplitGroup ? "g".charCodeAt(0) : "u".charCodeAt(0); // usemtl - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { if (isUdim) { let part = Krom.io_obj_parse(b, splitCode, 0, isUdim); @@ -112,7 +112,7 @@ class ImportObj { ImportMesh.addMesh(parts[i]); } } - Data.deleteBlob(path); + data_delete_blob(path); }); } } diff --git a/base/Sources/ImportTexture.ts b/base/Sources/ImportTexture.ts index 80f62a358..77c8bee78 100644 --- a/base/Sources/ImportTexture.ts +++ b/base/Sources/ImportTexture.ts @@ -14,7 +14,7 @@ class ImportTexture { if (a.file == path) { // Set as envmap if (hdrAsEnvmap && path.toLowerCase().endsWith(".hdr")) { - Data.getImage(path, (image: image_t) => { + data_get_image(path, (image: image_t) => { Base.notifyOnNextFrame(() => { // Make sure file browser process did finish ImportEnvmap.run(path, image); }); @@ -27,11 +27,11 @@ class ImportTexture { let ext = path.substr(path.lastIndexOf(".") + 1); let importer = Path.textureImporters.get(ext); - let cached = Data.cachedImages.get(path) != null; // Already loaded or pink texture for missing file + let cached = data_cached_images.get(path) != null; // Already loaded or pink texture for missing file if (importer == null || cached) importer = ImportTexture.defaultImporter; importer(path, (image: image_t) => { - Data.cachedImages.set(path, image); + data_cached_images.set(path, image); let ar = path.split(Path.sep); let name = ar[ar.length - 1]; let asset: TAsset = {name: name, file: path, id: Project.assetId++}; @@ -52,6 +52,6 @@ class ImportTexture { } static defaultImporter = (path: string, done: (img: image_t)=>void) => { - Data.getImage(path, done); + data_get_image(path, done); } } diff --git a/base/Sources/LineDraw.ts b/base/Sources/LineDraw.ts index 8d5925b5f..3a079a59e 100644 --- a/base/Sources/LineDraw.ts +++ b/base/Sources/LineDraw.ts @@ -182,8 +182,8 @@ class LineDraw { g4_set_index_buffer(LineDraw.indexBuffer); g4_set_pipeline(LineDraw.pipeline); let camera = scene_camera; - mat4_set_from(LineDraw.vp, camera.V); - mat4_mult_mat(LineDraw.vp, camera.P); + mat4_set_from(LineDraw.vp, camera.v); + mat4_mult_mat(LineDraw.vp, camera.p); g4_set_mat(LineDraw.vpID, LineDraw.vp); g4_draw(0, LineDraw.lines * 6); } diff --git a/base/Sources/NodeShaderContext.ts b/base/Sources/NodeShaderContext.ts index 15d94b60e..4531a8811 100644 --- a/base/Sources/NodeShaderContext.ts +++ b/base/Sources/NodeShaderContext.ts @@ -122,5 +122,5 @@ class NodeShaderContext { type TMaterial = { name: string; - canvas: TNodeCanvas; + canvas: zui_node_canvas_t; } diff --git a/base/Sources/NodesMaterial.ts b/base/Sources/NodesMaterial.ts index a81368cfa..9b74ab8be 100644 --- a/base/Sources/NodesMaterial.ts +++ b/base/Sources/NodesMaterial.ts @@ -4,7 +4,7 @@ class NodesMaterial { static categories = [_tr("Input"), _tr("Texture"), _tr("Color"), _tr("Vector"), _tr("Converter"), _tr("Group")]; - static list: TNode[][] = [ + static list: zui_node_t[][] = [ [ // Input { id: 0, @@ -2779,58 +2779,58 @@ class NodesMaterial { ] ]; - static vectorCurvesButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static vectorCurvesButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { let but = node.buttons[0]; - let nhandle = Zui.nest(Zui.handle("nodesmaterial_0"), node.id); - Zui.row([1 / 3, 1 / 3, 1 / 3]); - Zui.radio(Zui.nest(Zui.nest(nhandle, 0), 1), 0, "X"); - Zui.radio(Zui.nest(Zui.nest(nhandle, 0), 1), 1, "Y"); - Zui.radio(Zui.nest(Zui.nest(nhandle, 0), 1), 2, "Z"); + let nhandle = zui_nest(zui_handle("nodesmaterial_0"), node.id); + zui_row([1 / 3, 1 / 3, 1 / 3]); + zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 0, "X"); + zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 1, "Y"); + zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 2, "Z"); // Preview - let axis = Zui.nest(Zui.nest(nhandle, 0), 1).position; + let axis = zui_nest(zui_nest(nhandle, 0), 1).position; let val: Float32Array[] = but.default_value[axis]; // [ [[x, y], [x, y], ..], [[x, y]], ..] let num = val.length; // for (let i = 0; i < num; ++i) { ui.line(); } - ui._y += Nodes.LINE_H() * 5; + ui._y += zui_nodes_LINE_H() * 5; // Edit - Zui.row([1 / 5, 1 / 5, 3 / 5]); - if (Zui.button("+")) { + zui_row([1 / 5, 1 / 5, 3 / 5]); + if (zui_button("+")) { let f32a = new Float32Array(2); f32a[0] = 0; f32a[1] = 0; val.push(f32a); } - if (Zui.button("-")) { + if (zui_button("-")) { if (val.length > 2) val.pop(); } - let ihandle = Zui.nest(Zui.nest(Zui.nest(nhandle, 0), 2), axis, {position: 0}); - let i = Math.floor(Zui.slider(ihandle, "Index", 0, num - 1, false, 1, true, Align.Left)); + let ihandle = zui_nest(zui_nest(zui_nest(nhandle, 0), 2), axis, {position: 0}); + let i = Math.floor(zui_slider(ihandle, "Index", 0, num - 1, false, 1, true, Align.Left)); if (i >= val.length || i < 0) ihandle.value = i = val.length - 1; // Stay in bounds - Zui.row([1 / 2, 1 / 2]); - Zui.nest(Zui.nest(nhandle, 0), 3).value = val[i][0]; - Zui.nest(Zui.nest(nhandle, 0), 4).value = val[i][1]; - val[i][0] = Zui.slider(Zui.nest(Zui.nest(nhandle, 0), 3, {value: 0}), "X", -1, 1, true, 100, true, Align.Left); - val[i][1] = Zui.slider(Zui.nest(Zui.nest(nhandle, 0), 4, {value: 0}), "Y", -1, 1, true, 100, true, Align.Left); + zui_row([1 / 2, 1 / 2]); + zui_nest(zui_nest(nhandle, 0), 3).value = val[i][0]; + zui_nest(zui_nest(nhandle, 0), 4).value = val[i][1]; + val[i][0] = zui_slider(zui_nest(zui_nest(nhandle, 0), 3, {value: 0}), "X", -1, 1, true, 100, true, Align.Left); + val[i][1] = zui_slider(zui_nest(zui_nest(nhandle, 0), 4, {value: 0}), "Y", -1, 1, true, 100, true, Align.Left); } - static colorRampButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static colorRampButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { let but = node.buttons[0]; - let nhandle = Zui.nest(Zui.handle("nodesmaterial_1"), node.id); + let nhandle = zui_nest(zui_handle("nodesmaterial_1"), node.id); let nx = ui._x; let ny = ui._y; // Preview let vals: Float32Array[] = but.default_value; // [[r, g, b, a, pos], ..] - let sw = ui._w / Nodes.SCALE(); + let sw = ui._w / zui_nodes_SCALE(); for (let val of vals) { let pos = val[4]; let col = color_from_floats(val[0], val[1], val[2]); - Zui.fill(pos * sw, 0, (1.0 - pos) * sw, Nodes.LINE_H() - 2 * Nodes.SCALE(), col); + zui_fill(pos * sw, 0, (1.0 - pos) * sw, zui_nodes_LINE_H() - 2 * zui_nodes_SCALE(), col); } - ui._y += Nodes.LINE_H(); + ui._y += zui_nodes_LINE_H(); // Edit - let ihandle = Zui.nest(Zui.nest(nhandle, 0), 2); - Zui.row([1 / 4, 1 / 4, 2 / 4]); - if (Zui.button("+")) { + let ihandle = zui_nest(zui_nest(nhandle, 0), 2); + zui_row([1 / 4, 1 / 4, 2 / 4]); + if (zui_button("+")) { let last = vals[vals.length - 1]; let f32a = new Float32Array(5); f32a[0] = last[0]; @@ -2841,36 +2841,36 @@ class NodesMaterial { vals.push(f32a); ihandle.value += 1; } - if (Zui.button("-") && vals.length > 1) { + if (zui_button("-") && vals.length > 1) { vals.pop(); ihandle.value -= 1; } - but.data = Zui.combo(Zui.nest(Zui.nest(nhandle, 0), 1, {position: but.data}), [tr("Linear"), tr("Constant")], tr("Interpolate")); + but.data = zui_combo(zui_nest(zui_nest(nhandle, 0), 1, {position: but.data}), [tr("Linear"), tr("Constant")], tr("Interpolate")); - Zui.row([1 / 2, 1 / 2]); - let i = Math.floor(Zui.slider(ihandle, "Index", 0, vals.length - 1, false, 1, true, Align.Left)); + zui_row([1 / 2, 1 / 2]); + let i = Math.floor(zui_slider(ihandle, "Index", 0, vals.length - 1, false, 1, true, Align.Left)); if (i >= vals.length || i < 0) ihandle.value = i = vals.length - 1; // Stay in bounds let val = vals[i]; - Zui.nest(Zui.nest(nhandle, 0), 3).value = val[4]; - val[4] = Zui.slider(Zui.nest(Zui.nest(nhandle, 0), 3), "Pos", 0, 1, true, 100, true, Align.Left); + zui_nest(zui_nest(nhandle, 0), 3).value = val[4]; + val[4] = zui_slider(zui_nest(zui_nest(nhandle, 0), 3), "Pos", 0, 1, true, 100, true, Align.Left); if (val[4] > 1.0) val[4] = 1.0; // Stay in bounds else if (val[4] < 0.0) val[4] = 0.0; - let chandle = Zui.nest(Zui.nest(nhandle, 0), 4); + let chandle = zui_nest(zui_nest(nhandle, 0), 4); chandle.color = color_from_floats(val[0], val[1], val[2]); - if (Zui.text("", Align.Right, chandle.color) == State.Started) { - let rx = nx + ui._w - Nodes.p(37); - let ry = ny - Nodes.p(5); - nodes._inputStarted = ui.inputStarted = false; - Nodes.rgbaPopup(ui, chandle, val, Math.floor(rx), Math.floor(ry + Zui.ELEMENT_H(ui))); + if (zui_text("", Align.Right, chandle.color) == State.Started) { + let rx = nx + ui._w - zui_nodes_p(37); + let ry = ny - zui_nodes_p(5); + nodes._inputStarted = ui.input_started = false; + zui_nodes_rgba_popup(ui, chandle, val, Math.floor(rx), Math.floor(ry + zui_ELEMENT_H(ui))); } val[0] = color_get_rb(chandle.color) / 255; val[1] = color_get_gb(chandle.color) / 255; val[2] = color_get_bb(chandle.color) / 255; } - static newGroupButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static newGroupButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { if (node.name == "New Group") { for (let i = 1; i < 999; ++i) { node.name = tr("Group") + " " + i; @@ -2885,9 +2885,9 @@ class NodesMaterial { if (!found) break; } - Nodes.node_replace.push(node); + zui_node_replace.push(node); - let canvas: TNodeCanvas = { + let canvas: zui_node_canvas_t = { name: node.name, nodes: [ { @@ -2927,7 +2927,7 @@ class NodesMaterial { ], links: [] }; - Project.materialGroups.push({ canvas: canvas, nodes: Nodes.create() }); + Project.materialGroups.push({ canvas: canvas, nodes: zui_nodes_create() }); } let group: TNodeGroup = null; @@ -2938,22 +2938,22 @@ class NodesMaterial { } } - if (Zui.button(tr("Nodes"))) { + if (zui_button(tr("Nodes"))) { UINodes.groupStack.push(group); } } - static groupInputButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static groupInputButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { NodesMaterial.addSocketButton(ui, nodes, node, node.outputs); } - static groupOutputButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode) => { + static groupOutputButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => { NodesMaterial.addSocketButton(ui, nodes, node, node.inputs); } - static addSocketButton = (ui: ZuiRaw, nodes: NodesRaw, node: TNode, sockets: TNodeSocket[]) => { - if (Zui.button(tr("Add"))) { - UIMenu.draw((ui: ZuiRaw) => { + static addSocketButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t, sockets: zui_node_socket_t[]) => { + if (zui_button(tr("Add"))) { + UIMenu.draw((ui: zui_t) => { let groupStack = UINodes.groupStack; let c = groupStack[groupStack.length - 1].canvas; if (UIMenu.menuButton(ui, tr("RGBA"))) { @@ -2972,15 +2972,15 @@ class NodesMaterial { } } - static syncSockets = (node: TNode) => { + static syncSockets = (node: zui_node_t) => { 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); - Nodes.node_replace.push(node); + zui_node_replace.push(node); } - static syncGroupSockets = (canvas: TNodeCanvas, groupName: string, node: TNode) => { + static syncGroupSockets = (canvas: zui_node_canvas_t, groupName: string, node: zui_node_t) => { for (let n of canvas.nodes) { if (n.type == "GROUP" && n.name == groupName) { let isInputs = node.name == "Group Input"; @@ -3010,9 +3010,9 @@ class NodesMaterial { return type == "RGBA" ? _tr("Color") : type == "VECTOR" ? _tr("Vector") : _tr("Value"); } - static createSocket = (nodes: NodesRaw, node: TNode, name: string, type: string, canvas: TNodeCanvas, min = 0.0, max = 1.0, default_value: any = null): TNodeSocket => { + static createSocket = (nodes: zui_nodes_t, node: zui_node_t, name: string, type: string, canvas: zui_node_canvas_t, min = 0.0, max = 1.0, default_value: any = null): zui_node_socket_t => { return { - id: Nodes.getSocketId(canvas.nodes), + id: zui_get_socket_id(canvas.nodes), node_id: node.id, name: name == null ? NodesMaterial.get_socket_name(type) : name, type: type, @@ -3023,12 +3023,12 @@ class NodesMaterial { } } - static getTNode = (nodeType: string): TNode => { + static getTNode = (nodeType: string): zui_node_t => { for (let c of NodesMaterial.list) for (let n of c) if (n.type == nodeType) return n; return null; } - static createNode = (nodeType: string, group: TNodeGroup = null): TNode => { + static createNode = (nodeType: string, group: TNodeGroup = null): zui_node_t => { let n = NodesMaterial.getTNode(nodeType); if (n == null) return null; let canvas = group != null ? group.canvas : Context.raw.material.canvas; diff --git a/base/Sources/ParserLogic.ts b/base/Sources/ParserLogic.ts index 9f9ddca7c..47431b3f0 100644 --- a/base/Sources/ParserLogic.ts +++ b/base/Sources/ParserLogic.ts @@ -2,33 +2,33 @@ class ParserLogic { static customNodes = new Map(); - static nodes: TNode[]; - static links: TNodeLink[]; + static nodes: zui_node_t[]; + static links: zui_node_link_t[]; static parsed_nodes: string[] = null; static parsed_labels: Map = null; static nodeMap: Map; - static rawMap: Map; + static rawMap: Map; - static getLogicNode = (node: TNode): LogicNode => { + static getLogicNode = (node: zui_node_t): LogicNode => { return ParserLogic.nodeMap.get(ParserLogic.node_name(node)); } - static getRawNode = (node: LogicNode): TNode => { + static getRawNode = (node: LogicNode): zui_node_t => { return ParserLogic.rawMap.get(node); } - static getNode = (id: i32): TNode => { + static getNode = (id: i32): zui_node_t => { for (let n of ParserLogic.nodes) if (n.id == id) return n; return null; } - static getLink = (id: i32): TNodeLink => { + static getLink = (id: i32): zui_node_link_t => { for (let l of ParserLogic.links) if (l.id == id) return l; return null; } - static getInputLink = (inp: TNodeSocket): TNodeLink => { + static getInputLink = (inp: zui_node_socket_t): zui_node_link_t => { for (let l of ParserLogic.links) { if (l.to_id == inp.node_id) { let node = ParserLogic.getNode(inp.node_id); @@ -39,8 +39,8 @@ class ParserLogic { return null; } - static getOutputLinks = (out: TNodeSocket): TNodeLink[] => { - let res: TNodeLink[] = []; + static getOutputLinks = (out: zui_node_socket_t): zui_node_link_t[] => { + let res: zui_node_link_t[] = []; for (let l of ParserLogic.links) { if (l.from_id == out.node_id) { let node = ParserLogic.getNode(out.node_id); @@ -55,12 +55,12 @@ class ParserLogic { return s.replaceAll(" ", ""); } - static node_name = (node: TNode): string => { + static node_name = (node: zui_node_t): string => { let s = ParserLogic.safe_src(node.name) + node.id; return s; } - static parse = (canvas: TNodeCanvas) => { + static parse = (canvas: zui_node_canvas_t) => { ParserLogic.nodes = canvas.nodes; ParserLogic.links = canvas.links; @@ -73,7 +73,7 @@ class ParserLogic { for (let node of root_nodes) ParserLogic.build_node(node); } - static build_node = (node: TNode): string => { + static build_node = (node: zui_node_t): string => { // Get node name let name = ParserLogic.node_name(node); @@ -94,7 +94,7 @@ class ParserLogic { if (b.type == "ENUM") { // let arrayData = Array.isArray(b.data); let arrayData = b.data.length > 1; - let texts = arrayData ? b.data : Nodes.enumTextsHaxe(node.type); + let texts = arrayData ? b.data : zui_enum_texts_js(node.type); v[b.name] = texts[b.default_value]; } else { @@ -144,8 +144,8 @@ class ParserLogic { return name; } - static get_root_nodes = (node_group: TNodeCanvas): TNode[] => { - let roots: TNode[] = []; + static get_root_nodes = (node_group: zui_node_canvas_t): zui_node_t[] => { + let roots: zui_node_t[] = []; for (let node of node_group.nodes) { let linked = false; for (let out of node.outputs) { @@ -162,7 +162,7 @@ class ParserLogic { return roots; } - static build_default_node = (inp: TNodeSocket): LogicNode => { + static build_default_node = (inp: zui_node_socket_t): LogicNode => { let v: LogicNode = null; diff --git a/base/Sources/ParserMaterial.ts b/base/Sources/ParserMaterial.ts index a928217f5..e766d1fab 100644 --- a/base/Sources/ParserMaterial.ts +++ b/base/Sources/ParserMaterial.ts @@ -23,11 +23,11 @@ class ParserMaterial { static curshader: NodeShaderRaw; static matcon: material_context_t; static parsed: string[]; - static parents: TNode[]; + static parents: zui_node_t[]; - static canvases: TNodeCanvas[]; - static nodes: TNode[]; - static links: TNodeLink[]; + static canvases: zui_node_canvas_t[]; + static nodes: zui_node_t[]; + static links: zui_node_link_t[]; static cotangentFrameWritten: bool; static tex_coord = "texCoord"; @@ -52,26 +52,26 @@ class ParserMaterial { static bake_passthrough_strength = "0.0"; static bake_passthrough_radius = "0.0"; static bake_passthrough_offset = "0.0"; - static start_group: TNodeCanvas = null; - static start_parents: TNode[] = null; - static start_node: TNode = null; + static start_group: zui_node_canvas_t = null; + static start_parents: zui_node_t[] = null; + static start_node: zui_node_t = null; static arm_export_tangents = true; static out_normaltan: string; // Raw tangent space normal parsed from normal map static script_links: Map = null; - static getNode = (id: i32): TNode => { + static getNode = (id: i32): zui_node_t => { for (let n of ParserMaterial.nodes) if (n.id == id) return n; return null; } - static getLink = (id: i32): TNodeLink => { + static getLink = (id: i32): zui_node_link_t => { for (let l of ParserMaterial.links) if (l.id == id) return l; return null; } - static getInputLink = (inp: TNodeSocket): TNodeLink => { + static getInputLink = (inp: zui_node_socket_t): zui_node_link_t => { for (let l of ParserMaterial.links) { if (l.to_id == inp.node_id) { let node = ParserMaterial.getNode(inp.node_id); @@ -82,8 +82,8 @@ class ParserMaterial { return null; } - static getOutputLinks = (out: TNodeSocket): TNodeLink[] => { - let ls: TNodeLink[] = null; + static getOutputLinks = (out: zui_node_socket_t): zui_node_link_t[] => { + let ls: zui_node_link_t[] = null; for (let l of ParserMaterial.links) { if (l.from_id == out.node_id) { let node = ParserMaterial.getNode(out.node_id); @@ -106,8 +106,8 @@ class ParserMaterial { ParserMaterial.parsing_basecolor = false; } - static parse = (canvas: TNodeCanvas, _con: NodeShaderContextRaw, _vert: NodeShaderRaw, _frag: NodeShaderRaw, _matcon: material_context_t): TShaderOut => { - Nodes.updateCanvasFormat(canvas); + static parse = (canvas: zui_node_canvas_t, _con: NodeShaderContextRaw, _vert: NodeShaderRaw, _frag: NodeShaderRaw, _matcon: material_context_t): TShaderOut => { + zui_nodes_update_canvas_format(canvas); ParserMaterial.init(); ParserMaterial.canvases = [canvas]; ParserMaterial.nodes = canvas.nodes; @@ -124,7 +124,7 @@ class ParserMaterial { } if (ParserMaterial.start_node != null) { - let link: TNodeLink = { id: 99999, from_id: ParserMaterial.start_node.id, from_socket: 0, to_id: -1, to_socket: -1 }; + let link: zui_node_link_t = { id: 99999, from_id: ParserMaterial.start_node.id, from_socket: 0, to_id: -1, to_socket: -1 }; ParserMaterial.write_result(link); return { out_basecol: `vec3(0.0, 0.0, 0.0)`, @@ -248,7 +248,7 @@ class ParserMaterial { } } - static parse_output = (node: TNode): TShaderOut => { + static parse_output = (node: zui_node_t): TShaderOut => { if (ParserMaterial.parse_surface || ParserMaterial.parse_opacity) { return ParserMaterial.parse_shader_input(node.inputs[0]); } @@ -256,7 +256,7 @@ class ParserMaterial { // Parse volume, displacement.. } - static parse_output_pbr = (node: TNode): TShaderOut => { + static parse_output_pbr = (node: zui_node_t): TShaderOut => { if (ParserMaterial.parse_surface || ParserMaterial.parse_opacity) { return ParserMaterial.parse_shader(node, null); } @@ -264,12 +264,12 @@ class ParserMaterial { // Parse volume, displacement.. } - static get_group = (name: string): TNodeCanvas => { + static get_group = (name: string): zui_node_canvas_t => { for (let g of Project.materialGroups) if (g.canvas.name == name) return g.canvas; return null; } - static push_group = (g: TNodeCanvas) => { + static push_group = (g: zui_node_canvas_t) => { ParserMaterial.canvases.push(g); ParserMaterial.nodes = g.nodes; ParserMaterial.links = g.links; @@ -282,7 +282,7 @@ class ParserMaterial { ParserMaterial.links = g.links; } - static parse_group = (node: TNode, socket: TNodeSocket): string => { // Entering group + static parse_group = (node: zui_node_t, socket: zui_node_socket_t): string => { // Entering group ParserMaterial.parents.push(node); ParserMaterial.push_group(ParserMaterial.get_group(node.name)); let output_node = ParserMaterial.node_by_type(ParserMaterial.nodes, `GROUP_OUTPUT`); @@ -295,7 +295,7 @@ class ParserMaterial { return out_group; } - static parse_group_input = (node: TNode, socket: TNodeSocket): string => { + static parse_group_input = (node: zui_node_t, socket: zui_node_socket_t): string => { let parent = ParserMaterial.parents.pop(); // Leaving group ParserMaterial.pop_group(); let index = ParserMaterial.socket_index(node, socket); @@ -306,7 +306,7 @@ class ParserMaterial { return res; } - static parse_input = (inp: TNodeSocket): string => { + static parse_input = (inp: zui_node_socket_t): string => { if (inp.type == "RGB") { return ParserMaterial.parse_vector_input(inp); } @@ -322,7 +322,7 @@ class ParserMaterial { return null; } - static parse_shader_input = (inp: TNodeSocket): TShaderOut => { + static parse_shader_input = (inp: zui_node_socket_t): TShaderOut => { let l = ParserMaterial.getInputLink(inp); let from_node = l != null ? ParserMaterial.getNode(l.from_id) : null; if (from_node != null) { @@ -345,7 +345,7 @@ class ParserMaterial { } } - static parse_shader = (node: TNode, socket: TNodeSocket): TShaderOut => { + static parse_shader = (node: zui_node_t, socket: zui_node_socket_t): TShaderOut => { let sout: TShaderOut = { out_basecol: "vec3(0.8, 0.8, 0.8)", out_roughness: "0.0", @@ -396,7 +396,7 @@ class ParserMaterial { return sout; } - static parse_vector_input = (inp: TNodeSocket): string => { + static parse_vector_input = (inp: zui_node_socket_t): string => { let l = ParserMaterial.getInputLink(inp); let from_node = l != null ? ParserMaterial.getNode(l.from_id) : null; if (from_node != null) { @@ -423,7 +423,7 @@ class ParserMaterial { } } - static parse_vector = (node: TNode, socket: TNodeSocket): string => { + static parse_vector = (node: zui_node_t, socket: zui_node_socket_t): string => { if (node.type == `GROUP`) { return ParserMaterial.parse_group(node, socket); } @@ -1082,7 +1082,7 @@ class ParserMaterial { return "vec3(0.0, 0.0, 0.0)"; } - static parse_normal_map_color_input = (inp: TNodeSocket) => { + static parse_normal_map_color_input = (inp: zui_node_socket_t) => { ParserMaterial.frag.write_normal++; ParserMaterial.out_normaltan = ParserMaterial.parse_vector_input(inp); if (!ParserMaterial.arm_export_tangents) { @@ -1104,7 +1104,7 @@ class ParserMaterial { ParserMaterial.frag.write_normal--; } - static parse_value_input = (inp: TNodeSocket, vector_as_grayscale = false) : string => { + static parse_value_input = (inp: zui_node_socket_t, vector_as_grayscale = false) : string => { let l = ParserMaterial.getInputLink(inp); let from_node = l != null ? ParserMaterial.getNode(l.from_id) : null; if (from_node != null) { @@ -1131,7 +1131,7 @@ class ParserMaterial { } } - static parse_value = (node: TNode, socket: TNodeSocket): string => { + static parse_value = (node: zui_node_t, socket: zui_node_socket_t): string => { if (node.type == `GROUP`) { return ParserMaterial.parse_group(node, socket); } @@ -1649,7 +1649,7 @@ class ParserMaterial { return "0.0"; } - static getCoord = (node: TNode): string => { + static getCoord = (node: zui_node_t): string => { if (ParserMaterial.getInputLink(node.inputs[0]) != null) { return ParserMaterial.parse_vector_input(node.inputs[0]); } @@ -1712,14 +1712,14 @@ class ParserMaterial { return `mix(${ys_var}[${index_var}], ${ys_var}[${index_var} + 1], (${fac_var} - ${facs_var}[${index_var}]) * (1.0 / (${facs_var}[${index_var} + 1] - ${facs_var}[${index_var}])))`; } - static res_var_name = (node: TNode, socket: TNodeSocket): string => { + static res_var_name = (node: zui_node_t, socket: zui_node_socket_t): string => { return ParserMaterial.node_name(node) + "_" + ParserMaterial.safesrc(socket.name) + "_res"; } static parsedMap = new Map(); static textureMap = new Map(); - static write_result = (l: TNodeLink): string => { + static write_result = (l: zui_node_link_t): string => { let from_node = ParserMaterial.getNode(l.from_id); let from_socket = from_node.outputs[l.from_socket]; let res_var = ParserMaterial.res_var_name(from_node, from_socket); @@ -1746,11 +1746,11 @@ class ParserMaterial { return res_var; } - static store_var_name = (node: TNode): string => { + static store_var_name = (node: zui_node_t): string => { return ParserMaterial.node_name(node) + "_store"; } - static texture_store = (node: TNode, tex: bind_tex_t, tex_name: string, color_space: i32): string => { + static texture_store = (node: zui_node_t, tex: bind_tex_t, tex_name: string, color_space: i32): string => { ParserMaterial.matcon.bind_textures.push(tex); NodeShaderContext.add_elem(ParserMaterial.curshader.context, "tex", "short2norm"); NodeShader.add_uniform(ParserMaterial.curshader, "sampler2D " + tex_name); @@ -1832,17 +1832,17 @@ class ParserMaterial { ///end } - static node_by_type = (nodes: TNode[], ntype: string): TNode => { + static node_by_type = (nodes: zui_node_t[], ntype: string): zui_node_t => { for (let n of nodes) if (n.type == ntype) return n; return null; } - static socket_index = (node: TNode, socket: TNodeSocket): i32 => { + static socket_index = (node: zui_node_t, socket: zui_node_socket_t): i32 => { for (let i = 0; i < node.outputs.length; ++i) if (node.outputs[i] == socket) return i; return -1; } - static node_name = (node: TNode, _parents: TNode[] = null): string => { + static node_name = (node: zui_node_t, _parents: zui_node_t[] = null): string => { if (_parents == null) _parents = ParserMaterial.parents; let s = node.name; for (let p of _parents) s = p.name + p.id + `_` + s; @@ -1869,7 +1869,7 @@ class ParserMaterial { return ""; } - static make_texture = (image_node: TNode, tex_name: string, matname: string = null): bind_tex_t => { + static make_texture = (image_node: zui_node_t, tex_name: string, matname: string = null): bind_tex_t => { let filepath = ParserMaterial.enumData(Base.enumTexts(image_node.type)[image_node.buttons[0].default_value]); if (filepath == "" || filepath.indexOf(".") == -1) { diff --git a/base/Sources/Path.ts b/base/Sources/Path.ts index b530f5591..c88b61eb0 100644 --- a/base/Sources/Path.ts +++ b/base/Sources/Path.ts @@ -26,7 +26,7 @@ class Path { static workingDirCache: string = null; static data = (): string => { - return Krom.getFilesLocation() + Path.sep + Data.dataPath; + return Krom.getFilesLocation() + Path.sep + data_data_path(); } static toRelative = (from: string, to: string): string => { diff --git a/base/Sources/PhysicsBody.ts b/base/Sources/PhysicsBody.ts index 1ec9d7957..52742a78e 100644 --- a/base/Sources/PhysicsBody.ts +++ b/base/Sources/PhysicsBody.ts @@ -19,7 +19,7 @@ class PhysicsBodyRaw { else this._mass = f; } - object: TBaseObject; + object: object_t; friction = 0.5; restitution = 0.0; collisionMargin = 0.0; @@ -86,12 +86,12 @@ class PhysicsBody { return f - f * pb.collisionMargin; } - static init = (pb: PhysicsBodyRaw, o: TBaseObject) => { + static init = (pb: PhysicsBodyRaw, o: object_t) => { pb.object = o; if (pb.ready) return; pb.ready = true; - if (pb.object.ext.constructor != TMeshObject) return; // No mesh data + if (pb.object.ext.constructor != mesh_object_t) return; // No mesh data let transform = o.transform; let physics = PhysicsWorld.active; @@ -365,7 +365,7 @@ class PhysicsBody { PhysicsBody.convexHullCache.set(data, shape); PhysicsBody.usersCache.set(data, 1); - let positions = MeshData.getVArray(data, 'pos').values; + let positions = mesh_data_get_vertex_array(data, 'pos').values; let sx: f32 = scale.x * (1.0 - margin) * (1 / 32767); let sy: f32 = scale.y * (1.0 - margin) * (1 / 32767); @@ -397,7 +397,7 @@ class PhysicsBody { PhysicsBody.triangleMeshCache.set(data, triangleMesh); PhysicsBody.usersCache.set(data, 1); - let positions = MeshData.getVArray(data, 'pos').values; + let positions = mesh_data_get_vertex_array(data, 'pos').values; let indices = data._indices; let sx: f32 = scale.x * (1 / 32767); diff --git a/base/Sources/Plugin.ts b/base/Sources/Plugin.ts index 025b180d3..e489cfb9e 100644 --- a/base/Sources/Plugin.ts +++ b/base/Sources/Plugin.ts @@ -1,6 +1,6 @@ class PluginRaw { - drawUI: (ui: ZuiRaw)=>void = null; + drawUI: (ui: zui_t)=>void = null; draw: ()=>void = null; update: ()=>void = null; delete: ()=>void = null; @@ -23,11 +23,11 @@ class Plugin { static start = (plugin: string) => { try { - Data.getBlob("plugins/" + plugin, (blob: ArrayBuffer) => { + data_get_blob("plugins/" + plugin, (blob: ArrayBuffer) => { Plugin.pluginName = plugin; // (1, eval)(sys_buffer_to_string(blob)); // Global scope eval(sys_buffer_to_string(blob)); // Local scope - Data.deleteBlob("plugins/" + plugin); + data_delete_blob("plugins/" + plugin); }); } catch (e: any) { diff --git a/base/Sources/Project.ts b/base/Sources/Project.ts index 8f9425961..9b2c66e62 100644 --- a/base/Sources/Project.ts +++ b/base/Sources/Project.ts @@ -8,7 +8,7 @@ class Project { static assetId = 0; static meshAssets: string[] = []; static materialGroups: TNodeGroup[] = []; - static paintObjects: TMeshObject[] = null; + static paintObjects: mesh_object_t[] = null; static assetMap = new Map(); // ImageRaw | FontRaw static meshList: string[] = null; ///if (is_paint || is_sculpt) @@ -22,8 +22,8 @@ class Project { ///if is_lab static materialData: material_data_t = null; //// static materials: any[] = null; //// - static nodes: NodesRaw; - static canvas: TNodeCanvas; + static nodes: zui_nodes_t; + static canvas: zui_node_canvas_t; static defaultCanvas: ArrayBuffer = null; ///end @@ -66,7 +66,7 @@ class Project { ExportArm.runProject(); if (saveAndQuit) sys_stop(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } static projectSaveAs = (saveAndQuit = false) => { @@ -81,8 +81,8 @@ class Project { static projectNewBox = () => { ///if (is_paint || is_sculpt) - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(Zui.handle("project_0"), tr("New Project"))) { + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(zui_handle("project_0"), tr("New Project"))) { if (Project.meshList == null) { Project.meshList = File.readDirectory(Path.data() + Path.sep + "meshes"); for (let i = 0; i < Project.meshList.length; ++i) Project.meshList[i] = Project.meshList[i].substr(0, Project.meshList[i].length - 4); // Trim .arm @@ -91,16 +91,16 @@ class Project { Project.meshList.unshift("rounded_cube"); } - Zui.row([0.5, 0.5]); - Context.raw.projectType = Zui.combo(Zui.handle("project_1", { position: Context.raw.projectType }), Project.meshList, tr("Template"), true); - Context.raw.projectAspectRatio = Zui.combo(Zui.handle("project_2", { position: Context.raw.projectAspectRatio }), ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true); + zui_row([0.5, 0.5]); + Context.raw.projectType = zui_combo(zui_handle("project_1", { position: Context.raw.projectType }), Project.meshList, tr("Template"), true); + Context.raw.projectAspectRatio = zui_combo(zui_handle("project_2", { position: Context.raw.projectAspectRatio }), ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true); - Zui.endElement(); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + zui_end_element(); + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("OK")) || ui.isReturnDown) { + if (zui_button(tr("OK")) || ui.is_return_down) { Project.projectNew(); Viewport.scaleToBounds(); UIBox.hide(); @@ -123,8 +123,8 @@ class Project { ///if (is_paint || is_sculpt) if (Context.raw.mergedObject != null) { - MeshObject.remove(Context.raw.mergedObject); - Data.deleteMesh(Context.raw.mergedObject.data._handle); + mesh_object_remove(Context.raw.mergedObject); + data_delete_mesh(Context.raw.mergedObject.data._handle); Context.raw.mergedObject = null; } Context.raw.layerPreviewDirty = true; @@ -139,8 +139,8 @@ class Project { for (let i = 1; i < Project.paintObjects.length; ++i) { let p = Project.paintObjects[i]; if (p == Context.raw.paintObject) continue; - Data.deleteMesh(p.data._handle); - MeshObject.remove(p); + data_delete_mesh(p.data._handle); + mesh_object_remove(p); } let meshes = scene_meshes; let len = meshes.length; @@ -149,13 +149,13 @@ class Project { if (Context.raw.projectObjects.indexOf(m) == -1 && m.base.name != ".ParticleEmitter" && m.base.name != ".Particle") { - Data.deleteMesh(m.data._handle); - MeshObject.remove(m); + data_delete_mesh(m.data._handle); + mesh_object_remove(m); } } let handle = Context.raw.paintObject.data._handle; if (handle != "SceneSphere" && handle != "ScenePlane") { - Data.deleteMesh(handle); + data_delete_mesh(handle); } if (Context.raw.projectType != ProjectModel.ModelRoundedCube) { @@ -189,14 +189,14 @@ class Project { ///end } else { - Data.getBlob("meshes/" + Project.meshList[Context.raw.projectType] + ".arm", (b: ArrayBuffer) => { + data_get_blob("meshes/" + Project.meshList[Context.raw.projectType] + ".arm", (b: ArrayBuffer) => { raw = armpack_decode(b).mesh_datas[0]; }); } let md: mesh_data_t; - MeshData.create(raw, (mdata: mesh_data_t) => { md = mdata; }); - Data.cachedMeshes.set("SceneTessellated", md); + mesh_data_create(raw, (mdata: mesh_data_t) => { md = mdata; }); + data_cached_meshes.set("SceneTessellated", md); if (Context.raw.projectType == ProjectModel.ModelTessellatedPlane) { Viewport.setView(0, 0, 0.75, 0, 0, 0); // Top @@ -204,7 +204,7 @@ class Project { } let n = Context.raw.projectType == ProjectModel.ModelRoundedCube ? ".Cube" : "Tessellated"; - Data.getMesh("Scene", n, (md: mesh_data_t) => { + data_get_mesh("Scene", n, (md: mesh_data_t) => { let current = _g2_current; if (current != null) g2_end(current); @@ -213,7 +213,7 @@ class Project { Context.raw.pickerMaskHandle.position = PickerMask.MaskNone; ///end - MeshObject.setData(Context.raw.paintObject, md); + mesh_object_set_data(Context.raw.paintObject, md); vec4_set(Context.raw.paintObject.base.transform.scale, 1, 1, 1); transform_build_matrix(Context.raw.paintObject.base.transform); Context.raw.paintObject.base.name = n; @@ -221,7 +221,7 @@ class Project { ///if (is_paint || is_sculpt) while (Project.materials.length > 0) SlotMaterial.unload(Project.materials.pop()); ///end - Data.getMaterial("Scene", "Material", (m: material_data_t) => { + data_get_material("Scene", "Material", (m: material_data_t) => { ///if (is_paint || is_sculpt) Project.materials.push(SlotMaterial.create(m)); ///end @@ -259,7 +259,7 @@ class Project { UtilRender.makeMaterialPreview(); ///end - for (let a of Project.assets) Data.deleteImage(a.file); + for (let a of Project.assets) data_delete_image(a.file); Project.assets = []; Project.assetNames = []; Project.assetMap = new Map(); @@ -281,11 +281,11 @@ class Project { Project.layers.push(layer); Context.setLayer(layer); if (aspectRatioChanged) { - App.notifyOnInit(Base.resizeLayers); + app_notify_on_init(Base.resizeLayers); } ///end - App.notifyOnInit(Base.initLayers); + app_notify_on_init(Base.initLayers); } if (current != null) g2_begin(current, false); @@ -344,7 +344,7 @@ class Project { n.buttons[0].default_value = assetIndex; let links = Context.raw.brush.canvas.links; links.push({ - id: Nodes.getLinkId(links), + id: zui_get_link_id(links), from_id: n.id, from_socket: 0, to_id: 0, @@ -357,7 +357,7 @@ class Project { let _init = () => { UtilRender.makeBrushPreview(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } // Import from project file else { @@ -377,21 +377,21 @@ class Project { ///if krom_ios // Import immediately while access to resource is unlocked - // Data.getBlob(path, (b: Blob) => {}); + // data_get_blob(path, (b: Blob) => {}); ///end - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(Zui.handle("project_3"), tr("Import Mesh"), tabVertical)) { + if (zui_tab(zui_handle("project_3"), tr("Import Mesh"), tabVertical)) { if (path.toLowerCase().endsWith(".obj")) { - Context.raw.splitBy = Zui.combo(Zui.handle("project_4"), [ + Context.raw.splitBy = zui_combo(zui_handle("project_4"), [ tr("Object"), tr("Group"), tr("Material"), tr("UDIM Tile"), ], tr("Split By"), true); - if (ui.isHovered) Zui.tooltip(tr("Split .obj mesh into objects")); + if (ui.is_hovered) zui_tooltip(tr("Split .obj mesh into objects")); } // if (path.toLowerCase().endsWith(".fbx")) { @@ -402,16 +402,16 @@ class Project { ///if (is_paint || is_sculpt) // if (path.toLowerCase().endsWith(".fbx") || path.toLowerCase().endsWith(".blend")) { if (path.toLowerCase().endsWith(".blend")) { - Context.raw.parseVCols = Zui.check(Zui.handle("project_6", { selected: Context.raw.parseVCols }), tr("Parse Vertex Colors")); - if (ui.isHovered) Zui.tooltip(tr("Import vertex color data")); + Context.raw.parseVCols = zui_check(zui_handle("project_6", { selected: Context.raw.parseVCols }), tr("Parse Vertex Colors")); + if (ui.is_hovered) zui_tooltip(tr("Import vertex color data")); } ///end - Zui.row([0.45, 0.45, 0.1]); - if (Zui.button(tr("Cancel"))) { + zui_row([0.45, 0.45, 0.1]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Import")) || ui.isReturnDown) { + if (zui_button(tr("Import")) || ui.is_return_down) { UIBox.hide(); let doImport = () => { ///if (is_paint || is_sculpt) @@ -431,7 +431,7 @@ class Project { doImport(); ///end } - if (Zui.button(tr("?"))) { + if (zui_button(tr("?"))) { File.loadUrl("https://github.com/armory3d/armorpaint_docs/blob/master/faq.md"); } } @@ -447,9 +447,9 @@ class Project { } static unwrapMeshBox = (mesh: any, done: (a: any)=>void, skipUI = false) => { - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(Zui.handle("project_7"), tr("Unwrap Mesh"), tabVertical)) { + if (zui_tab(zui_handle("project_7"), tr("Unwrap Mesh"), tabVertical)) { let unwrapPlugins: string[] = []; if (BoxPreferences.filesPlugin == null) { @@ -462,13 +462,13 @@ class Project { } unwrapPlugins.push("equirect"); - let unwrapBy = Zui.combo(Zui.handle("project_8"), unwrapPlugins, tr("Plugin"), true); + let unwrapBy = zui_combo(zui_handle("project_8"), unwrapPlugins, tr("Plugin"), true); - Zui.row([0.5, 0.5]); - if (Zui.button(tr("Cancel"))) { + zui_row([0.5, 0.5]); + if (zui_button(tr("Cancel"))) { UIBox.hide(); } - if (Zui.button(tr("Unwrap")) || ui.isReturnDown || skipUI) { + if (zui_button(tr("Unwrap")) || ui.is_return_down || skipUI) { UIBox.hide(); let doUnwrap = () => { if (unwrapBy == unwrapPlugins.length - 1) { @@ -521,7 +521,7 @@ class Project { let load = (path: string) => { asset.file = path; let i = Project.assets.indexOf(asset); - Data.deleteImage(asset.file); + data_delete_image(asset.file); Project.assetMap.delete(asset.id); let oldAsset = Project.assets[i]; Project.assets.splice(i, 1); @@ -570,17 +570,17 @@ class Project { else return null; } - static isAtlasObject = (p: TMeshObject): bool => { + static isAtlasObject = (p: mesh_object_t): bool => { if (Context.raw.layerFilter <= Project.paintObjects.length) return false; let atlasName = Project.getUsedAtlases()[Context.raw.layerFilter - Project.paintObjects.length - 1]; let atlasI = Project.atlasNames.indexOf(atlasName); return atlasI == Project.atlasObjects[Project.paintObjects.indexOf(p)]; } - static getAtlasObjects = (objectMask: i32): TMeshObject[] => { + static getAtlasObjects = (objectMask: i32): mesh_object_t[] => { let atlasName = Project.getUsedAtlases()[objectMask - Project.paintObjects.length - 1]; let atlasI = Project.atlasNames.indexOf(atlasName); - let visibles: TMeshObject[] = []; + let visibles: mesh_object_t[] = []; for (let i = 0; i < Project.paintObjects.length; ++i) if (Project.atlasObjects[i] == atlasI) visibles.push(Project.paintObjects[i]); return visibles; } @@ -623,7 +623,7 @@ class Project { ///if (is_paint || is_sculpt) static isMaterialGroupInUse = (group: TNodeGroup): bool => { - let canvases: TNodeCanvas[] = []; + let canvases: zui_node_canvas_t[] = []; for (let m of Project.materials) canvases.push(m.canvas); for (let m of Project.materialGroups) canvases.push(m.canvas); for (let canvas of canvases) { @@ -639,6 +639,6 @@ class Project { } type TNodeGroup = { - nodes: NodesRaw; - canvas: TNodeCanvas; + nodes: zui_nodes_t; + canvas: zui_node_canvas_t; } diff --git a/base/Sources/ProjectFormat.ts b/base/Sources/ProjectFormat.ts index 7e77799f9..739fa8811 100644 --- a/base/Sources/ProjectFormat.ts +++ b/base/Sources/ProjectFormat.ts @@ -12,10 +12,10 @@ type TProjectFormat = { swatches?: TSwatchColor[]; ///if (is_paint || is_sculpt) - brush_nodes?: TNodeCanvas[]; + brush_nodes?: zui_node_canvas_t[]; brush_icons?: ArrayBuffer[]; - material_nodes?: TNodeCanvas[]; - material_groups?: TNodeCanvas[]; + material_nodes?: zui_node_canvas_t[]; + material_groups?: zui_node_canvas_t[]; material_icons?: ArrayBuffer[]; font_assets?: string[]; layer_datas?: TLayerData[]; @@ -30,8 +30,8 @@ type TProjectFormat = { ///end ///if is_lab - material?: TNodeCanvas; - material_groups?: TNodeCanvas[]; + material?: zui_node_canvas_t; + material_groups?: zui_node_canvas_t[]; mesh_data?: mesh_data_t; mesh_icon?: ArrayBuffer; ///end diff --git a/base/Sources/RenderPathBase.ts b/base/Sources/RenderPathBase.ts index 38c5067a1..1a02d8894 100644 --- a/base/Sources/RenderPathBase.ts +++ b/base/Sources/RenderPathBase.ts @@ -58,26 +58,26 @@ class RenderPathBase { static drawCompass = (currentG: g4_t) => { if (Context.raw.showCompass) { let cam = scene_camera; - let compass: TMeshObject = scene_get_child(".Compass").ext; + let compass: mesh_object_t = scene_get_child(".Compass").ext; let _visible = compass.base.visible; let _parent = compass.base.parent; let _loc = compass.base.transform.loc; let _rot = compass.base.transform.rot; let crot = cam.base.transform.rot; - let ratio = App.w() / App.h(); - let _P = cam.P; - cam.P = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); + let ratio = app_w() / app_h(); + let _P = cam.p; + cam.p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); compass.base.visible = true; compass.base.parent = cam.base; compass.base.transform.loc = vec4_create(7.4 * ratio, 7.0, -1); compass.base.transform.rot = quat_create(-crot.x, -crot.y, -crot.z, crot.w); vec4_set(compass.base.transform.scale, 0.4, 0.4, 0.4); transform_build_matrix(compass.base.transform); - compass.frustumCulling = false; - MeshObject.render(compass, currentG, "overlay", []); + compass.frustum_culling = false; + mesh_object_render(compass, currentG, "overlay", []); - cam.P = _P; + cam.p = _P; compass.base.visible = _visible; compass.base.parent = _parent; compass.base.transform.loc = _loc; @@ -112,15 +112,15 @@ class RenderPathBase { } transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - CameraObject.buildMatrix(cam); - CameraObject.buildProjection(cam); + camera_object_build_matrix(cam); + camera_object_build_projection(cam); } // Match projection matrix jitter let skipTaa = Context.raw.splitView || ((Context.raw.tool == WorkspaceTool.ToolClone || Context.raw.tool == WorkspaceTool.ToolBlur || Context.raw.tool == WorkspaceTool.ToolSmudge) && Context.raw.pdirty > 0); scene_camera.frame = skipTaa ? 0 : RenderPathBase.taaFrame; - CameraObject.projectionJitter(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_projection_jitter(scene_camera); + camera_object_build_matrix(scene_camera); } static end = () => { @@ -254,8 +254,8 @@ class RenderPathBase { Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0; transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - CameraObject.buildMatrix(cam); - CameraObject.buildProjection(cam); + camera_object_build_matrix(cam); + camera_object_build_projection(cam); RenderPathBase.drawGbuffer(); @@ -272,8 +272,8 @@ class RenderPathBase { Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0; transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]); - CameraObject.buildMatrix(cam); - CameraObject.buildProjection(cam); + camera_object_build_matrix(cam); + camera_object_build_projection(cam); } } diff --git a/base/Sources/RenderPathRaytrace.ts b/base/Sources/RenderPathRaytrace.ts index 2f6368936..a421c0d66 100644 --- a/base/Sources/RenderPathRaytrace.ts +++ b/base/Sources/RenderPathRaytrace.ts @@ -79,8 +79,8 @@ class RenderPathRaytrace { let cam = scene_camera; let ct = cam.base.transform; - mat4_set_from(RenderPathRaytrace.helpMat, cam.V); - mat4_mult_mat(RenderPathRaytrace.helpMat, cam.P); + mat4_set_from(RenderPathRaytrace.helpMat, cam.v); + mat4_mult_mat(RenderPathRaytrace.helpMat, cam.p); mat4_get_inv(RenderPathRaytrace.helpMat, RenderPathRaytrace.helpMat); RenderPathRaytrace.f32a[0] = transform_world_x(ct); RenderPathRaytrace.f32a[1] = transform_world_y(ct); @@ -142,7 +142,7 @@ class RenderPathRaytrace { scene_embed_data("bnoise_rank.k", () => {}); } - Data.getBlob(shaderName, (shader: ArrayBuffer) => { + data_get_blob(shaderName, (shader: ArrayBuffer) => { if (build) RenderPathRaytrace.buildData(); let bnoise_sobol = scene_embedded.get("bnoise_sobol.k"); let bnoise_scramble = scene_embedded.get("bnoise_scramble.k"); diff --git a/base/Sources/Res.ts b/base/Sources/Res.ts index 1a2c8a622..ee0a342a8 100644 --- a/base/Sources/Res.ts +++ b/base/Sources/Res.ts @@ -6,7 +6,7 @@ class Res { static load = (names: string[], done: ()=>void) => { let loaded = 0; for (let s of names) { - Data.getImage(s, (image: image_t) => { + data_get_image(s, (image: image_t) => { Res.bundled.set(s, image); loaded++; if (loaded == names.length) done(); @@ -35,17 +35,17 @@ class Res { ///if arm_snapshot static embedRaw = (handle: string, name: string, file: ArrayBuffer) => { - Data.cachedBlobs.set(name, file); - Data.getSceneRaw(handle, (_) => {}); - Data.cachedBlobs.delete(name); + data_cached_blobs.set(name, file); + data_get_scene_raw(handle, (_) => {}); + data_cached_blobs.delete(name); } static embedBlob = (name: string, file: ArrayBuffer) => { - Data.cachedBlobs.set(name, file); + data_cached_blobs.set(name, file); } static embedFont = (name: string, file: ArrayBuffer) => { - Data.cachedFonts.set(name, font_create(file)); + data_cached_fonts.set(name, font_create(file)); } ///end } diff --git a/base/Sources/TabBrowser.ts b/base/Sources/TabBrowser.ts index bea0e89fe..fa2021053 100644 --- a/base/Sources/TabBrowser.ts +++ b/base/Sources/TabBrowser.ts @@ -1,8 +1,8 @@ class TabBrowser { - static hpath = Handle.create(); - static hsearch = Handle.create(); + static hpath = zui_handle_create(); + static hsearch = zui_handle_create(); static known = false; static lastPath = ""; @@ -12,35 +12,35 @@ class TabBrowser { UIBase.htabs[TabArea.TabStatus].position = 0; } - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Browser")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Browser")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { if (Config.raw.bookmarks == null) { Config.raw.bookmarks = []; } - let bookmarksW = Math.floor(100 * Zui.SCALE(ui)); + let bookmarksW = Math.floor(100 * zui_SCALE(ui)); if (TabBrowser.hpath.text == "" && Config.raw.bookmarks.length > 0) { // Init to first bookmark TabBrowser.hpath.text = Config.raw.bookmarks[0]; } - Zui.beginSticky(); + zui_begin_sticky(); let step = (1 - bookmarksW / ui._w); if (TabBrowser.hsearch.text != "") { - Zui.row([bookmarksW / ui._w, step * 0.73, step * 0.07, step * 0.17, step * 0.03]); + zui_row([bookmarksW / ui._w, step * 0.73, step * 0.07, step * 0.17, step * 0.03]); } else { - Zui.row([bookmarksW / ui._w, step * 0.73, step * 0.07, step * 0.2]); + zui_row([bookmarksW / ui._w, step * 0.73, step * 0.07, step * 0.2]); } - if (Zui.button("+")) { + if (zui_button("+")) { Config.raw.bookmarks.push(TabBrowser.hpath.text); Config.save(); } - if (ui.isHovered) Zui.tooltip(tr("Add bookmark")); + if (ui.is_hovered) zui_tooltip(tr("Add bookmark")); ///if krom_android let stripped = false; @@ -51,7 +51,7 @@ class TabBrowser { } ///end - TabBrowser.hpath.text = Zui.textInput(TabBrowser.hpath, tr("Path")); + TabBrowser.hpath.text = zui_text_input(TabBrowser.hpath, tr("Path")); ///if krom_android if (stripped) { @@ -60,20 +60,20 @@ class TabBrowser { ///end let refresh = false; - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (Zui.button(tr("Refresh")) || (inFocus && ui.isKeyPressed && ui.key == KeyCode.F5)) { + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (zui_button(tr("Refresh")) || (inFocus && ui.is_key_pressed && ui.key == KeyCode.F5)) { refresh = true; } - TabBrowser.hsearch.text = Zui.textInput(TabBrowser.hsearch, tr("Search"), Align.Left, true, true); - if (ui.isHovered) Zui.tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel")); - if (ui.isCtrlDown && ui.isKeyPressed && ui.key == KeyCode.F) { // Start searching via ctrl+f - Zui.startTextEdit(TabBrowser.hsearch); + TabBrowser.hsearch.text = zui_text_input(TabBrowser.hsearch, tr("Search"), Align.Left, true, true); + if (ui.is_hovered) zui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel")); + if (ui.is_ctrl_down && ui.is_key_pressed && ui.key == KeyCode.F) { // Start searching via ctrl+f + zui_start_text_edit(TabBrowser.hsearch); } - if (TabBrowser.hsearch.text != "" && (Zui.button(tr("X")) || ui.isEscapeDown)) { + if (TabBrowser.hsearch.text != "" && (zui_button(tr("X")) || ui.is_escape_down)) { TabBrowser.hsearch.text = ""; } - Zui.endSticky(); + zui_end_sticky(); if (TabBrowser.lastPath != TabBrowser.hpath.text) { TabBrowser.hsearch.text = ""; @@ -86,7 +86,7 @@ class TabBrowser { UIFiles.fileBrowser(ui, TabBrowser.hpath, false, true, TabBrowser.hsearch.text, refresh, (file: string) => { let fileName = file.substr(file.lastIndexOf(Path.sep) + 1); if (fileName != "..") { - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Import"))) { ImportAsset.run(file); } @@ -161,7 +161,7 @@ class TabBrowser { if (TabBrowser.known) { let path = TabBrowser.hpath.text; - App.notifyOnInit(() => { + app_notify_on_init(() => { ImportAsset.run(path); }); TabBrowser.hpath.text = TabBrowser.hpath.text.substr(0, TabBrowser.hpath.text.lastIndexOf(Path.sep)); @@ -176,13 +176,13 @@ class TabBrowser { ui._y = _y; ui._w = bookmarksW; - if (Zui.button(tr("Cloud"), Align.Left)) { + if (zui_button(tr("Cloud"), Align.Left)) { TabBrowser.hpath.text = "cloud"; } - if (Zui.button(tr("Disk"), Align.Left)) { + if (zui_button(tr("Disk"), Align.Left)) { ///if krom_android - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Download"))) { TabBrowser.hpath.text = UIFiles.defaultPath; } @@ -204,12 +204,12 @@ class TabBrowser { for (let b of Config.raw.bookmarks) { let folder = b.substr(b.lastIndexOf(Path.sep) + 1); - if (Zui.button(folder, Align.Left)) { + if (zui_button(folder, Align.Left)) { TabBrowser.hpath.text = b; } - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Delete"))) { array_remove(Config.raw.bookmarks, b); Config.save(); diff --git a/base/Sources/TabBrushes.ts b/base/Sources/TabBrushes.ts index eda59e2a7..12840f88b 100644 --- a/base/Sources/TabBrushes.ts +++ b/base/Sources/TabBrushes.ts @@ -3,48 +3,48 @@ class TabBrushes { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Brushes"))) { - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 4]); - if (Zui.button(tr("New"))) { + if (zui_tab(htab, tr("Brushes"))) { + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 4]); + if (zui_button(tr("New"))) { Context.raw.brush = SlotBrush.create(); Project.brushes.push(Context.raw.brush); MakeMaterial.parseBrush(); UINodes.hwnd.redraws = 2; } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { Project.importBrush(); } - if (Zui.button(tr("Nodes"))) { + if (zui_button(tr("Nodes"))) { UIBase.showBrushNodes(); } - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); - let slotw = Math.floor(51 * Zui.SCALE(ui)); + let slotw = Math.floor(51 * zui_SCALE(ui)); let num = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] / slotw); for (let row = 0; row < Math.floor(Math.ceil(Project.brushes.length / num)); ++row) { let mult = Config.raw.show_asset_names ? 2 : 1; let ar = []; for (let i = 0; i < num * mult; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; - let off = Config.raw.show_asset_names ? Zui.ELEMENT_OFFSET(ui) * 10.0 : 6; + let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6; if (row > 0) ui._y += off; for (let j = 0; j < num; ++j) { - let imgw = Math.floor(50 * Zui.SCALE(ui)); + let imgw = Math.floor(50 * zui_SCALE(ui)); let i = j + row * num; if (i >= Project.brushes.length) { - Zui.endElement(imgw); - if (Config.raw.show_asset_names) Zui.endElement(0); + zui_end_element(imgw); + if (Config.raw.show_asset_names) zui_end_element(0); continue; } - let img = Zui.SCALE(ui) > 1 ? Project.brushes[i].image : Project.brushes[i].imageIcon; + let img = zui_SCALE(ui) > 1 ? Project.brushes[i].image : Project.brushes[i].imageIcon; let imgFull = Project.brushes[i].image; if (Context.raw.brush == Project.brushes[i]) { @@ -52,28 +52,28 @@ class TabBrushes { let off = row % 2 == 1 ? 1 : 0; let w = 50; if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2); - Zui.fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); + zui_fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); } let uix = ui._x; //let uiy = ui._y; - let tile = Zui.SCALE(ui) > 1 ? 100 : 50; - let state = Project.brushes[i].previewReady ? Zui.image(img) : Zui.image(Res.get("icons.k"), -1, null, tile * 5, tile, tile, tile); + let tile = zui_SCALE(ui) > 1 ? 100 : 50; + let state = Project.brushes[i].previewReady ? zui_image(img) : zui_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.showBrushNodes(); Context.raw.selectTime = time_time(); - // App.dragOffX = -(mouse_x - uix - ui._windowX - 3); - // App.dragOffY = -(mouse_y - uiy - ui._windowY + 1); - // App.dragBrush = Context.raw.brush; + // app_drag_off_x = -(mouse_x - uix - ui._windowX - 3); + // app_drag_off_y = -(mouse_y - uiy - ui._windowY + 1); + // app_drag_brush = Context.raw.brush; } - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.selectBrush(i); let add = Project.brushes.length > 1 ? 1 : 0; - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { //let b = Project.brushes[i]; if (UIMenu.menuButton(ui, tr("Export"))) { @@ -90,7 +90,7 @@ class TabBrushes { Context.setBrush(Context.raw.brush); UtilRender.makeBrushPreview(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (Project.brushes.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) { @@ -99,9 +99,9 @@ class TabBrushes { }, 2 + add); } - if (ui.isHovered) { + if (ui.is_hovered) { if (imgFull == null) { - App.notifyOnInit(() => { + app_notify_on_init(() => { let _brush = Context.raw.brush; Context.raw.brush = Project.brushes[i]; MakeMaterial.parseBrush(); @@ -110,19 +110,19 @@ class TabBrushes { }); } else { - Zui.tooltipImage(imgFull); - Zui.tooltip(Project.brushes[i].canvas.name); + zui_tooltip_image(imgFull); + zui_tooltip(Project.brushes[i].canvas.name); } } if (Config.raw.show_asset_names) { ui._x = uix; ui._y += slotw * 0.9; - Zui.text(Project.brushes[i].canvas.name, Align.Center); - if (ui.isHovered) Zui.tooltip(Project.brushes[i].canvas.name); + zui_text(Project.brushes[i].canvas.name, Align.Center); + if (ui.is_hovered) zui_tooltip(Project.brushes[i].canvas.name); ui._y -= slotw * 0.9; if (i == Project.brushes.length - 1) { - ui._y += j == num - 1 ? imgw : imgw + Zui.ELEMENT_H(ui) + Zui.ELEMENT_OFFSET(ui); + ui._y += j == num - 1 ? imgw : imgw + zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui); } } } @@ -130,10 +130,10 @@ class TabBrushes { ui._y += 6; } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && Project.brushes.length > 1) { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && Project.brushes.length > 1) { + ui.is_delete_down = false; TabBrushes.deleteBrush(Context.raw.brush); } } diff --git a/base/Sources/TabConsole.ts b/base/Sources/TabConsole.ts index 01eaa1a58..bf8fb8ef8 100644 --- a/base/Sources/TabConsole.ts +++ b/base/Sources/TabConsole.ts @@ -1,36 +1,36 @@ class TabConsole { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let title = Console.messageTimer > 0 ? Console.message + " " : tr("Console"); let color = Console.messageTimer > 0 ? Console.messageColor : -1; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, title, false, color) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, title, false, color) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); ///if (krom_windows || krom_linux || krom_darwin) // Copy if (Config.raw.touch_ui) { - Zui.row([1 / 4, 1 / 4, 1 / 4]); + zui_row([1 / 4, 1 / 4, 1 / 4]); } else { - Zui.row([1 / 14, 1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14, 1 / 14]); } ///else if (Config.raw.touch_ui) { - Zui.row([1 / 4, 1 / 4]); + zui_row([1 / 4, 1 / 4]); } else { - Zui.row([1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14]); } ///end - if (Zui.button(tr("Clear"))) { + if (zui_button(tr("Clear"))) { Console.lastTraces = []; } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { let str = Console.lastTraces.join("\n"); UIFiles.show("txt", true, false, (path: string) => { let f = UIFiles.filename; @@ -41,23 +41,23 @@ class TabConsole { }); } ///if (krom_windows || krom_linux || krom_darwin) - if (Zui.button(tr("Copy"))) { + if (zui_button(tr("Copy"))) { let str = Console.lastTraces.join("\n"); Krom.copyToClipboard(str); } ///end - Zui.endSticky(); + zui_end_sticky(); let _font = ui.font; - let _fontSize = ui.fontSize; - Data.getFont("font_mono.ttf", (f: font_t) => { Zui.setFont(ui, f); }); // Sync - ui.fontSize = Math.floor(15 * Zui.SCALE(ui)); + let _fontSize = ui.font_size; + data_get_font("font_mono.ttf", (f: font_t) => { zui_set_font(ui, f); }); // Sync + ui.font_size = Math.floor(15 * zui_SCALE(ui)); for (let t of Console.lastTraces) { - Zui.text(t); + zui_text(t); } - Zui.setFont(ui, _font); - ui.fontSize = _fontSize; + zui_set_font(ui, _font); + ui.font_size = _fontSize; } } } diff --git a/base/Sources/TabFonts.ts b/base/Sources/TabFonts.ts index ecf301ceb..07bc5c693 100644 --- a/base/Sources/TabFonts.ts +++ b/base/Sources/TabFonts.ts @@ -3,48 +3,48 @@ class TabFonts { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Fonts")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Fonts")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); if (Config.raw.touch_ui) { - Zui.row([1 / 4, 1 / 4]); + zui_row([1 / 4, 1 / 4]); } else { - Zui.row([1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14]); } - if (Zui.button(tr("Import"))) Project.importAsset("ttf,ttc,otf"); - if (ui.isHovered) Zui.tooltip(tr("Import font file")); + if (zui_button(tr("Import"))) Project.importAsset("ttf,ttc,otf"); + if (ui.is_hovered) zui_tooltip(tr("Import font file")); - if (Zui.button(tr("2D View"))) { + if (zui_button(tr("2D View"))) { UIBase.show2DView(View2DType.View2DFont); } - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); let statusw = sys_width() - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW]; - let slotw = Math.floor(51 * Zui.SCALE(ui)); + let slotw = Math.floor(51 * zui_SCALE(ui)); let num = Math.floor(statusw / slotw); for (let row = 0; row < Math.floor(Math.ceil(Project.fonts.length / num)); ++row) { let mult = Config.raw.show_asset_names ? 2 : 1; let ar = []; for (let i = 0; i < num * mult; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; - let off = Config.raw.show_asset_names ? Zui.ELEMENT_OFFSET(ui) * 10.0 : 6; + let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6; if (row > 0) ui._y += off; for (let j = 0; j < num; ++j) { - let imgw = Math.floor(50 * Zui.SCALE(ui)); + let imgw = Math.floor(50 * zui_SCALE(ui)); let i = j + row * num; if (i >= Project.fonts.length) { - Zui.endElement(imgw); - if (Config.raw.show_asset_names) Zui.endElement(0); + zui_end_element(imgw); + if (Config.raw.show_asset_names) zui_end_element(0); continue; } let img = Project.fonts[i].image; @@ -54,14 +54,14 @@ class TabFonts { let off = row % 2 == 1 ? 1 : 0; let w = 50; if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2); - Zui.fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); + zui_fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); } let uix = ui._x; - let tile = Zui.SCALE(ui) > 1 ? 100 : 50; + let tile = zui_SCALE(ui) > 1 ? 100 : 50; let state = State.Idle; if (Project.fonts[i].previewReady) { // ui.g.pipeline = UIView2D.pipe; // L8 @@ -69,11 +69,11 @@ class TabFonts { // ui.currentWindow.texture.g4.setPipeline(UIView2D.pipe); // ///end // ui.currentWindow.texture.g4.setInt(UIView2D.channelLocation, 1); - state = Zui.image(img); + state = zui_image(img); // ui.g.pipeline = null; } else { - state = Zui.image(Res.get("icons.k"), -1, null, tile * 6, tile, tile, tile); + state = zui_image(Res.get("icons.k"), -1, null, tile * 6, tile, tile, tile); } if (state == State.Started) { @@ -81,24 +81,24 @@ class TabFonts { let _init = () => { Context.selectFont(i); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (time_time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DFont); Context.raw.selectTime = time_time(); } - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.selectFont(i); let add = Project.fonts.length > 1 ? 1 : 0; let fontName = Project.fonts[i].name; - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (Project.fonts.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete") && Project.fonts[i].file != "") { TabFonts.deleteFont(Project.fonts[i]); } }, 0 + add); } - if (ui.isHovered) { + if (ui.is_hovered) { if (img == null) { - App.notifyOnInit(() => { + app_notify_on_init(() => { let _font = Context.raw.font; Context.raw.font = Project.fonts[i]; UtilRender.makeFontPreview(); @@ -106,19 +106,19 @@ class TabFonts { }); } else { - Zui.tooltipImage(img); - Zui.tooltip(Project.fonts[i].name); + zui_tooltip_image(img); + zui_tooltip(Project.fonts[i].name); } } if (Config.raw.show_asset_names) { ui._x = uix; ui._y += slotw * 0.9; - Zui.text(Project.fonts[i].name, Align.Center); - if (ui.isHovered) Zui.tooltip(Project.fonts[i].name); + zui_text(Project.fonts[i].name, Align.Center); + if (ui.is_hovered) zui_tooltip(Project.fonts[i].name); ui._y -= slotw * 0.9; if (i == Project.fonts.length - 1) { - ui._y += j == num - 1 ? imgw : imgw + Zui.ELEMENT_H(ui) + Zui.ELEMENT_OFFSET(ui); + ui._y += j == num - 1 ? imgw : imgw + zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui); } } } @@ -126,10 +126,10 @@ class TabFonts { ui._y += 6; } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && Project.fonts.length > 1 && Context.raw.font.file != "") { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && Project.fonts.length > 1 && Context.raw.font.file != "") { + ui.is_delete_down = false; TabFonts.deleteFont(Context.raw.font); } } @@ -139,10 +139,10 @@ class TabFonts { let i = Project.fonts.indexOf(font); let _init = () => { Context.selectFont(i == Project.fonts.length - 1 ? i - 1 : i + 1); - Data.deleteFont(Project.fonts[i].file); + data_delete_font(Project.fonts[i].file); Project.fonts.splice(i, 1); } - App.notifyOnInit(_init); + app_notify_on_init(_init); UIBase.hwnds[2].redraws = 2; } } diff --git a/base/Sources/TabHistory.ts b/base/Sources/TabHistory.ts index 6ab08809c..e697359ab 100644 --- a/base/Sources/TabHistory.ts +++ b/base/Sources/TabHistory.ts @@ -3,16 +3,16 @@ class TabHistory { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("History"))) { + if (zui_tab(htab, tr("History"))) { for (let i = 0; i < History.steps.length; ++i) { let active = History.steps.length - 1 - History.redos; if (i == active) { - Zui.fill(0, 0, ui._windowW, ui.t.ELEMENT_H, ui.t.HIGHLIGHT_COL); + zui_fill(0, 0, ui._window_w, ui.t.ELEMENT_H, ui.t.HIGHLIGHT_COL); } - Zui.text(History.steps[i].name); - if (ui.isReleased) { // Jump to undo step + zui_text(History.steps[i].name); + if (ui.is_released) { // Jump to undo step let diff = i - active; while (diff > 0) { diff--; @@ -23,7 +23,7 @@ class TabHistory { History.undo(); } } - Zui.fill(0, 0, (ui._windowW / Zui.SCALE(ui) - 2), 1 * Zui.SCALE(ui), ui.t.SEPARATOR_COL); + zui_fill(0, 0, (ui._window_w / zui_SCALE(ui) - 2), 1 * zui_SCALE(ui), ui.t.SEPARATOR_COL); } } } diff --git a/base/Sources/TabMaterials.ts b/base/Sources/TabMaterials.ts index 17f7ef900..5afc91f3b 100644 --- a/base/Sources/TabMaterials.ts +++ b/base/Sources/TabMaterials.ts @@ -3,115 +3,115 @@ class TabMaterials { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW; mini ? TabMaterials.drawMini(htab) : TabMaterials.drawFull(htab); } - static drawMini = (htab: HandleRaw) => { + static drawMini = (htab: zui_handle_t) => { let ui = UIBase.ui; - Zui.setHoveredTabName(tr("Materials")); + zui_set_hovered_tab_name(tr("Materials")); - Zui.beginSticky(); - Zui.separator(5); + zui_begin_sticky(); + zui_separator(5); TabMaterials.buttonNodes(); TabMaterials.buttonNew("+"); - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); TabMaterials.drawSlots(true); } - static drawFull = (htab: HandleRaw) => { + static drawFull = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Materials"))) { - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 4]); + if (zui_tab(htab, tr("Materials"))) { + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 4]); TabMaterials.buttonNew(tr("New")); - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { Project.importMaterial(); } TabMaterials.buttonNodes(); - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); TabMaterials.drawSlots(false); } } static buttonNodes = () => { let ui = UIBase.ui; - if (Zui.button(tr("Nodes"))) { + if (zui_button(tr("Nodes"))) { UIBase.showMaterialNodes(); } - else if (ui.isHovered) Zui.tooltip(tr("Show Node Editor") + ` (${Config.keymap.toggle_node_editor})`); + else if (ui.is_hovered) zui_tooltip(tr("Show Node Editor") + ` (${Config.keymap.toggle_node_editor})`); } static drawSlots = (mini: bool) => { let ui = UIBase.ui; - let slotw = Math.floor(51 * Zui.SCALE(ui)); + let slotw = Math.floor(51 * zui_SCALE(ui)); let num = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] / slotw); for (let row = 0; row < Math.floor(Math.ceil(Project.materials.length / num)); ++row) { let mult = Config.raw.show_asset_names ? 2 : 1; let ar = []; for (let i = 0; i < num * mult; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; - let off = Config.raw.show_asset_names ? Zui.ELEMENT_OFFSET(ui) * 10.0 : 6; + let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6; if (row > 0) ui._y += off; for (let j = 0; j < num; ++j) { - let imgw = Math.floor(50 * Zui.SCALE(ui)); + let imgw = Math.floor(50 * zui_SCALE(ui)); let i = j + row * num; if (i >= Project.materials.length) { - Zui.endElement(imgw); - if (Config.raw.show_asset_names) Zui.endElement(0); + zui_end_element(imgw); + if (Config.raw.show_asset_names) zui_end_element(0); continue; } - let img = Zui.SCALE(ui) > 1 ? Project.materials[i].image : Project.materials[i].imageIcon; + let img = zui_SCALE(ui) > 1 ? Project.materials[i].image : Project.materials[i].imageIcon; let imgFull = Project.materials[i].image; // Highligh selected if (Context.raw.material == Project.materials[i]) { if (mini) { - let w = ui._w / Zui.SCALE(ui); - Zui.rect(0, -2, w - 2, w - 4, ui.t.HIGHLIGHT_COL, 3); + let w = ui._w / zui_SCALE(ui); + zui_rect(0, -2, w - 2, w - 4, ui.t.HIGHLIGHT_COL, 3); } else { let off = row % 2 == 1 ? 1 : 0; let w = 50; if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2); - Zui.fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); - Zui.fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, w + 3, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-1, w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2, 2, w + 3, ui.t.HIGHLIGHT_COL); + zui_fill(w + 1, -2, 2, w + 4, ui.t.HIGHLIGHT_COL); } } ///if krom_opengl - ui.imageInvertY = Project.materials[i].previewReady; + ui.image_invert_y = Project.materials[i].previewReady; ///end // Draw material icon let uix = ui._x; let uiy = ui._y; - let tile = Zui.SCALE(ui) > 1 ? 100 : 50; - let imgh: Null = mini ? UIBase.defaultSidebarMiniW * 0.85 * Zui.SCALE(ui) : null; + let tile = zui_SCALE(ui) > 1 ? 100 : 50; + let imgh: Null = mini ? UIBase.defaultSidebarMiniW * 0.85 * zui_SCALE(ui) : null; let state = Project.materials[i].previewReady ? - Zui.image(img, 0xffffffff, imgh) : - Zui.image(Res.get("icons.k"), 0xffffffff, null, tile, tile, tile, tile); + zui_image(img, 0xffffffff, imgh) : + zui_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.ui.isTyping || UINodes.ui.isTyping; + let isTyping = ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing; if (!isTyping) { if (i < 9 && Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) { let number = String(i + 1); - let width = font_width(ui.font, ui.fontSize, number) + 10; - let height = font_height(ui.font, ui.fontSize); + let width = font_width(ui.font, ui.font_size, number) + 10; + let height = font_height(ui.font, ui.font_size); ui.g.color = ui.t.TEXT_COL; g2_fill_rect(uix, uiy, width, height); ui.g.color = ui.t.ACCENT_COL; @@ -120,7 +120,7 @@ class TabMaterials { } // Select material - if (state == State.Started && ui.inputY > ui._windowY) { + if (state == State.Started && ui.input_y > ui._window_y) { if (Context.raw.material != Project.materials[i]) { Context.selectMaterial(i); ///if is_paint @@ -128,12 +128,12 @@ class TabMaterials { let _init = () => { Base.updateFillLayers(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } ///end } - Base.dragOffX = -(mouse_x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse_y - uiy - ui._windowY + 1); + Base.dragOffX = -(mouse_x - uix - ui._window_x - 3); + Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1); Base.dragMaterial = Context.raw.material; // Double click to show nodes if (time_time() - Context.raw.selectTime < 0.25) { @@ -145,11 +145,11 @@ class TabMaterials { } // Context menu - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.selectMaterial(i); let add = Project.materials.length > 1 ? 1 : 0; - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { let m = Project.materials[i]; if (UIMenu.menuButton(ui, tr("To Fill Layer"))) { @@ -178,40 +178,40 @@ class TabMaterials { TabMaterials.updateMaterial(); History.duplicateMaterial(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } if (Project.materials.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) { TabMaterials.deleteMaterial(m); } - let baseHandle = Zui.nest(Zui.handle("tabmaterials_0"), m.id, {selected: m.paintBase}); - let opacHandle = Zui.nest(Zui.handle("tabmaterials_1"), m.id, {selected: m.paintOpac}); - let norHandle = Zui.nest(Zui.handle("tabmaterials_2"), m.id, {selected: m.paintNor}); - let occHandle = Zui.nest(Zui.handle("tabmaterials_3"), m.id, {selected: m.paintOcc}); - let roughHandle = Zui.nest(Zui.handle("tabmaterials_4"), m.id, {selected: m.paintRough}); - let metHandle = Zui.nest(Zui.handle("tabmaterials_5"), m.id, {selected: m.paintMet}); - let heightHandle = Zui.nest(Zui.handle("tabmaterials_6"), m.id, {selected: m.paintHeight}); - let emisHandle = Zui.nest(Zui.handle("tabmaterials_7"), m.id, {selected: m.paintEmis}); - let subsHandle = Zui.nest(Zui.handle("tabmaterials_8"), m.id, {selected: m.paintSubs}); + let baseHandle = zui_nest(zui_handle("tabmaterials_0"), m.id, {selected: m.paintBase}); + let opacHandle = zui_nest(zui_handle("tabmaterials_1"), m.id, {selected: m.paintOpac}); + let norHandle = zui_nest(zui_handle("tabmaterials_2"), m.id, {selected: m.paintNor}); + let occHandle = zui_nest(zui_handle("tabmaterials_3"), m.id, {selected: m.paintOcc}); + let roughHandle = zui_nest(zui_handle("tabmaterials_4"), m.id, {selected: m.paintRough}); + let metHandle = zui_nest(zui_handle("tabmaterials_5"), m.id, {selected: m.paintMet}); + let heightHandle = zui_nest(zui_handle("tabmaterials_6"), m.id, {selected: m.paintHeight}); + let emisHandle = zui_nest(zui_handle("tabmaterials_7"), m.id, {selected: m.paintEmis}); + let subsHandle = zui_nest(zui_handle("tabmaterials_8"), m.id, {selected: m.paintSubs}); UIMenu.menuFill(ui); - m.paintBase = Zui.check(baseHandle, tr("Base Color")); + m.paintBase = zui_check(baseHandle, tr("Base Color")); UIMenu.menuFill(ui); - m.paintOpac = Zui.check(opacHandle, tr("Opacity")); + m.paintOpac = zui_check(opacHandle, tr("Opacity")); UIMenu.menuFill(ui); - m.paintNor = Zui.check(norHandle, tr("Normal")); + m.paintNor = zui_check(norHandle, tr("Normal")); UIMenu.menuFill(ui); - m.paintOcc = Zui.check(occHandle, tr("Occlusion")); + m.paintOcc = zui_check(occHandle, tr("Occlusion")); UIMenu.menuFill(ui); - m.paintRough = Zui.check(roughHandle, tr("Roughness")); + m.paintRough = zui_check(roughHandle, tr("Roughness")); UIMenu.menuFill(ui); - m.paintMet = Zui.check(metHandle, tr("Metallic")); + m.paintMet = zui_check(metHandle, tr("Metallic")); UIMenu.menuFill(ui); - m.paintHeight = Zui.check(heightHandle, tr("Height")); + m.paintHeight = zui_check(heightHandle, tr("Height")); UIMenu.menuFill(ui); - m.paintEmis = Zui.check(emisHandle, tr("Emission")); + m.paintEmis = zui_check(emisHandle, tr("Emission")); UIMenu.menuFill(ui); - m.paintSubs = Zui.check(subsHandle, tr("Subsurface")); + m.paintSubs = zui_check(subsHandle, tr("Subsurface")); if (baseHandle.changed || opacHandle.changed || norHandle.changed || @@ -226,23 +226,23 @@ class TabMaterials { } }, 13 + add); } - if (ui.isHovered) { - Zui.tooltipImage(imgFull); - if (i < 9) Zui.tooltip(Project.materials[i].canvas.name + " - (" + Config.keymap.select_material + " " + (i + 1) + ")"); - else Zui.tooltip(Project.materials[i].canvas.name); + if (ui.is_hovered) { + zui_tooltip_image(imgFull); + if (i < 9) zui_tooltip(Project.materials[i].canvas.name + " - (" + Config.keymap.select_material + " " + (i + 1) + ")"); + else zui_tooltip(Project.materials[i].canvas.name); } if (Config.raw.show_asset_names) { ui._x = uix; ui._y += slotw * 0.9; - Zui.text(Project.materials[i].canvas.name, Align.Center); - if (ui.isHovered) { - if (i < 9) Zui.tooltip(Project.materials[i].canvas.name + " - (" + Config.keymap.select_material + " " + (i + 1) + ")"); - else Zui.tooltip(Project.materials[i].canvas.name); + zui_text(Project.materials[i].canvas.name, Align.Center); + if (ui.is_hovered) { + if (i < 9) zui_tooltip(Project.materials[i].canvas.name + " - (" + Config.keymap.select_material + " " + (i + 1) + ")"); + else zui_tooltip(Project.materials[i].canvas.name); } ui._y -= slotw * 0.9; if (i == Project.materials.length - 1) { - ui._y += j == num - 1 ? imgw : imgw + Zui.ELEMENT_H(ui) + Zui.ELEMENT_OFFSET(ui); + ui._y += j == num - 1 ? imgw : imgw + zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui); } } } @@ -250,21 +250,21 @@ class TabMaterials { ui._y += mini ? 0 : 6; ///if krom_opengl - ui.imageInvertY = false; // Material preview + ui.image_invert_y = false; // Material preview ///end } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && Project.materials.length > 1) { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && Project.materials.length > 1) { + ui.is_delete_down = false; TabMaterials.deleteMaterial(Context.raw.material); } } static buttonNew = (text: string) => { let ui = UIBase.ui; - if (Zui.button(text)) { + if (zui_button(text)) { g2_end(ui.g); Context.raw.material = SlotMaterial.create(Project.materials[0].data); Project.materials.push(Context.raw.material); @@ -284,7 +284,7 @@ class TabMaterials { if (decal) UtilRender.makeDecalPreview(); } - static updateMaterialPointers = (nodes: TNode[], i: i32) => { + static updateMaterialPointers = (nodes: zui_node_t[], i: i32) => { for (let n of nodes) { if (n.type == "MATERIAL") { if (n.buttons[0].default_value == i) { diff --git a/base/Sources/TabMeshes.ts b/base/Sources/TabMeshes.ts index 55371831b..a9dccb182 100644 --- a/base/Sources/TabMeshes.ts +++ b/base/Sources/TabMeshes.ts @@ -1,33 +1,33 @@ class TabMeshes { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Meshes")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Meshes")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); ///if (is_paint || is_sculpt) if (Config.raw.touch_ui) { - Zui.row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); + zui_row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]); } else { - Zui.row([1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]); + zui_row([1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]); } ///end ///if is_lab if (Config.raw.touch_ui) { - Zui.row([1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7]); + zui_row([1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7]); } else { - Zui.row([1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]); + zui_row([1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]); } ///end - if (Zui.button(tr("Import"))) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Import"))) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Replace Existing"), `${Config.keymap.file_import_assets}`)) { Project.importMesh(true); } @@ -36,11 +36,11 @@ class TabMeshes { } }, 2); } - if (ui.isHovered) Zui.tooltip(tr("Import mesh file")); + if (ui.is_hovered) zui_tooltip(tr("Import mesh file")); ///if is_lab - if (Zui.button(tr("Set Default"))) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Set Default"))) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Cube"))) TabMeshes.setDefaultMesh(".Cube"); if (UIMenu.menuButton(ui, tr("Plane"))) TabMeshes.setDefaultMesh(".Plane"); if (UIMenu.menuButton(ui, tr("Sphere"))) TabMeshes.setDefaultMesh(".Sphere"); @@ -49,24 +49,24 @@ class TabMeshes { } ///end - if (Zui.button(tr("Flip Normals"))) { + if (zui_button(tr("Flip Normals"))) { UtilMesh.flipNormals(); Context.raw.ddirty = 2; } - if (Zui.button(tr("Calculate Normals"))) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Calculate Normals"))) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Smooth"))) { UtilMesh.calcNormals(true); Context.raw.ddirty = 2; } if (UIMenu.menuButton(ui, tr("Flat"))) { UtilMesh.calcNormals(false); Context.raw.ddirty = 2; } }, 2); } - if (Zui.button(tr("Geometry to Origin"))) { + if (zui_button(tr("Geometry to Origin"))) { UtilMesh.toOrigin(); Context.raw.ddirty = 2; } - if (Zui.button(tr("Apply Displacement"))) { + if (zui_button(tr("Apply Displacement"))) { ///if is_paint UtilMesh.applyDisplacement(Project.layers[0].texpaint_pack); ///end @@ -80,8 +80,8 @@ class TabMeshes { Context.raw.ddirty = 2; } - if (Zui.button(tr("Rotate"))) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Rotate"))) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Rotate X"))) { UtilMesh.swapAxis(1, 2); Context.raw.ddirty = 2; @@ -99,15 +99,15 @@ class TabMeshes { }, 3); } - Zui.endSticky(); + zui_end_sticky(); for (let i = 0; i < Project.paintObjects.length; ++i) { let o = Project.paintObjects[i]; - let h = Zui.handle("tabmeshes_0"); + let h = zui_handle("tabmeshes_0"); h.selected = o.base.visible; - o.base.visible = Zui.check(h, o.base.name); - if (ui.isHovered && ui.inputReleasedR) { - UIMenu.draw((ui: ZuiRaw) => { + o.base.visible = zui_check(h, o.base.name); + if (ui.is_hovered && ui.input_released_r) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Export"))) { Context.raw.exportMeshIndex = i + 1; BoxExport.showMesh(); @@ -116,17 +116,17 @@ class TabMeshes { array_remove(Project.paintObjects, o); while (o.base.children.length > 0) { let child = o.base.children[0]; - BaseObject.setParent(child, null); + object_set_parent(child, null); if (Project.paintObjects[0].base != child) { - BaseObject.setParent(child, Project.paintObjects[0].base); + object_set_parent(child, Project.paintObjects[0].base); } if (o.base.children.length == 0) { vec4_set_from(Project.paintObjects[0].base.transform.scale, o.base.transform.scale); transform_build_matrix(Project.paintObjects[0].base.transform); } } - Data.deleteMesh(o.data._handle); - MeshObject.remove(o); + data_delete_mesh(o.data._handle); + mesh_object_remove(o); Context.raw.paintObject = Context.mainObject(); UtilMesh.mergeMesh(); Context.raw.ddirty = 2; @@ -134,7 +134,7 @@ class TabMeshes { }, Project.paintObjects.length > 1 ? 2 : 1); } if (h.changed) { - let visibles: TMeshObject[] = []; + let visibles: mesh_object_t[] = []; for (let p of Project.paintObjects) if (p.base.visible) visibles.push(p); UtilMesh.mergeMesh(visibles); Context.raw.ddirty = 2; @@ -145,7 +145,7 @@ class TabMeshes { ///if is_lab static setDefaultMesh = (name: string) => { - let mo: TMeshObject = null; + let mo: mesh_object_t = null; if (name == ".Plane" || name == ".Sphere") { let res = Config.raw.rp_supersample > 1.0 ? 2048 : 1024; 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); @@ -163,8 +163,8 @@ class TabMeshes { scale_tex: mesh.scaleTex }; let md: mesh_data_t; - MeshData.create(raw, (_md: mesh_data_t) => { md = _md; }); - mo = MeshObject.create(md, Context.raw.paintObject.materials); + mesh_data_create(raw, (_md: mesh_data_t) => { md = _md; }); + mo = mesh_object_create(md, Context.raw.paintObject.materials); array_remove(scene_meshes, mo); mo.base.name = "Tessellated"; } diff --git a/base/Sources/TabParticles.ts b/base/Sources/TabParticles.ts index e6157920b..fbfed3604 100644 --- a/base/Sources/TabParticles.ts +++ b/base/Sources/TabParticles.ts @@ -3,14 +3,14 @@ class TabParticles { - static draw = (htab: HandleRaw) => { - if (Zui.tab(htab, tr("Particles"))) { - Zui.beginSticky(); - Zui.row([1 / 4, 1 / 4, 1 / 4]); - if (Zui.button(tr("New"))) {} - if (Zui.button(tr("Import"))) {} - if (Zui.button(tr("Nodes"))) {} - Zui.endSticky(); + static draw = (htab: zui_handle_t) => { + if (zui_tab(htab, tr("Particles"))) { + zui_begin_sticky(); + zui_row([1 / 4, 1 / 4, 1 / 4]); + if (zui_button(tr("New"))) {} + if (zui_button(tr("Import"))) {} + if (zui_button(tr("Nodes"))) {} + zui_end_sticky(); } } } diff --git a/base/Sources/TabPlugins.ts b/base/Sources/TabPlugins.ts index 7a5e00727..7a967affa 100644 --- a/base/Sources/TabPlugins.ts +++ b/base/Sources/TabPlugins.ts @@ -1,24 +1,24 @@ class TabPlugins { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; - if (Zui.tab(htab, tr("Plugins"))) { + if (zui_tab(htab, tr("Plugins"))) { - Zui.beginSticky(); + zui_begin_sticky(); ///if (is_paint || is_sculpt) - Zui.row([1 / 4]); + zui_row([1 / 4]); ///end ///if is_lab - Zui.row([1 / 14]); + zui_row([1 / 14]); ///end - if (Zui.button(tr("Manager"))) { + if (zui_button(tr("Manager"))) { BoxPreferences.htab.position = 6; // Plugins BoxPreferences.show(); } - Zui.endSticky(); + zui_end_sticky(); // Draw plugins for (let p of Plugin.plugins.values()) if (p.drawUI != null) p.drawUI(ui); diff --git a/base/Sources/TabScript.ts b/base/Sources/TabScript.ts index 2ab5d2ada..3dca38737 100644 --- a/base/Sources/TabScript.ts +++ b/base/Sources/TabScript.ts @@ -1,22 +1,22 @@ class TabScript { - static hscript = Handle.create(); - static textColoring: TTextColoring = null; + static hscript = zui_handle_create(); + static textColoring: zui_text_coloring_t = null; - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Script")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Script")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); if (Config.raw.touch_ui) { - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); } else { - Zui.row([1 / 14, 1 / 14, 1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14, 1 / 14, 1 / 14]); } - if (Zui.button(tr("Run"))) { + if (zui_button(tr("Run"))) { try { eval(TabScript.hscript.text); } @@ -24,18 +24,18 @@ class TabScript { Console.log(e); } } - if (Zui.button(tr("Clear"))) { + if (zui_button(tr("Clear"))) { TabScript.hscript.text = ""; } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show("js", false, false, (path: string) => { - Data.getBlob(path, (b: ArrayBuffer) => { + data_get_blob(path, (b: ArrayBuffer) => { TabScript.hscript.text = sys_buffer_to_string(b); - Data.deleteBlob(path); + data_delete_blob(path); }); }); } - if (Zui.button(tr("Export"))) { + if (zui_button(tr("Export"))) { let str = TabScript.hscript.text; UIFiles.show("js", true, false, (path: string) => { let f = UIFiles.filename; @@ -45,27 +45,27 @@ class TabScript { Krom.fileSaveBytes(path, sys_string_to_buffer(str)); }); } - Zui.endSticky(); + zui_end_sticky(); let _font = ui.font; - let _fontSize = ui.fontSize; - Data.getFont("font_mono.ttf", (f: font_t) => { Zui.setFont(ui, f); }); // Sync - ui.fontSize = Math.floor(15 * Zui.SCALE(ui)); - Zui.textAreaLineNumbers = true; - Zui.textAreaScrollPastEnd = true; - Zui.textAreaColoring = TabScript.getTextColoring(); - Zui.textArea(TabScript.hscript); - Zui.textAreaLineNumbers = false; - Zui.textAreaScrollPastEnd = false; - Zui.textAreaColoring = null; - Zui.setFont(ui, _font); - ui.fontSize = _fontSize; + let _fontSize = ui.font_size; + data_get_font("font_mono.ttf", (f: font_t) => { zui_set_font(ui, f); }); // Sync + ui.font_size = Math.floor(15 * zui_SCALE(ui)); + zui_set_text_area_line_numbers(true); + zui_set_text_area_scroll_past_end(true); + zui_set_text_area_coloring(TabScript.getTextColoring()); + zui_text_area(TabScript.hscript); + zui_set_text_area_line_numbers(false); + zui_set_text_area_scroll_past_end(false); + zui_set_text_area_coloring(null); + zui_set_font(ui, _font); + ui.font_size = _fontSize; } } - static getTextColoring = (): TTextColoring => { + static getTextColoring = (): zui_text_coloring_t => { if (TabScript.textColoring == null) { - Data.getBlob("text_coloring.json", (blob: ArrayBuffer) => { + data_get_blob("text_coloring.json", (blob: ArrayBuffer) => { TabScript.textColoring = JSON.parse(sys_buffer_to_string(blob)); TabScript.textColoring.default_color = Math.floor(TabScript.textColoring.default_color); for (let coloring of TabScript.textColoring.colorings) coloring.color = Math.floor(coloring.color); diff --git a/base/Sources/TabSwatches.ts b/base/Sources/TabSwatches.ts index 394175343..3e77bbff0 100644 --- a/base/Sources/TabSwatches.ts +++ b/base/Sources/TabSwatches.ts @@ -21,27 +21,27 @@ class TabSwatches { static dragPosition: i32 = -1; - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Swatches")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Swatches")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); if (Config.raw.touch_ui) { - Zui.row([1 / 5, 1 / 5, 1 / 5, 1 / 5, 1 / 5]); + zui_row([1 / 5, 1 / 5, 1 / 5, 1 / 5, 1 / 5]); } else { - Zui.row([1 / 14, 1 / 14, 1 / 14, 1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14, 1 / 14, 1 / 14, 1 / 14]); } - if (Zui.button(tr("New"))) { + if (zui_button(tr("New"))) { Context.setSwatch(Project.makeSwatch()); Project.raw.swatches.push(Context.raw.swatch); } - if (ui.isHovered) Zui.tooltip(tr("Add new swatch")); + if (ui.is_hovered) zui_tooltip(tr("Add new swatch")); - if (Zui.button(tr("Import"))) { - UIMenu.draw((ui: ZuiRaw) => { + if (zui_button(tr("Import"))) { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Replace Existing"))) { Project.importSwatches(true); Context.setSwatch(Project.raw.swatches[0]); @@ -51,26 +51,26 @@ class TabSwatches { } }, 2); } - if (ui.isHovered) Zui.tooltip(tr("Import swatches")); + if (ui.is_hovered) zui_tooltip(tr("Import swatches")); - if (Zui.button(tr("Export"))) Project.exportSwatches(); - if (ui.isHovered) Zui.tooltip(tr("Export swatches")); + if (zui_button(tr("Export"))) Project.exportSwatches(); + if (ui.is_hovered) zui_tooltip(tr("Export swatches")); - if (Zui.button(tr("Clear"))) { + if (zui_button(tr("Clear"))) { Context.setSwatch(Project.makeSwatch()); Project.raw.swatches = [Context.raw.swatch]; } - if (Zui.button(tr("Restore"))) { + if (zui_button(tr("Restore"))) { Project.setDefaultSwatches(); Context.setSwatch(Project.raw.swatches[0]); } - if (ui.isHovered) Zui.tooltip(tr("Restore default swatches")); + if (ui.is_hovered) zui_tooltip(tr("Restore default swatches")); - Zui.endSticky(); - Zui.separator(3, false); + zui_end_sticky(); + zui_separator(3, false); - let slotw = Math.floor(26 * Zui.SCALE(ui)); + let slotw = Math.floor(26 * zui_SCALE(ui)); let num = Math.floor(ui._w / (slotw + 3)); let dragPositionSet = false; @@ -79,7 +79,7 @@ class TabSwatches { for (let row = 0; row < Math.floor(Math.ceil(Project.raw.swatches.length / num)); ++row) { let ar = []; for (let i = 0; i < num; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; if (row > 0) ui._y += 6; @@ -87,14 +87,14 @@ class TabSwatches { for (let j = 0; j < num; ++j) { let i = j + row * num; if (i >= Project.raw.swatches.length) { - Zui.endElement(slotw); + zui_end_element(slotw); continue; } if (Context.raw.swatch == Project.raw.swatches[i]) { let off = row % 2 == 1 ? 1 : 0; let w = 32; - Zui.fill(-2, -2, w, w, ui.t.HIGHLIGHT_COL); + zui_fill(-2, -2, w, w, ui.t.HIGHLIGHT_COL); } uix = ui._x; @@ -102,60 +102,60 @@ class TabSwatches { // Draw the drag position indicator if (Base.dragSwatch != null && TabSwatches.dragPosition == i) { - Zui.fill(-1, -2 , 2, 32, ui.t.HIGHLIGHT_COL); + zui_fill(-1, -2 , 2, 32, ui.t.HIGHLIGHT_COL); } - let state = Zui.image(TabSwatches.empty, Project.raw.swatches[i].base, slotw); + let state = zui_image(TabSwatches.empty, Project.raw.swatches[i].base, slotw); if (state == State.Started) { Context.setSwatch(Project.raw.swatches[i]); - Base.dragOffX = -(mouse_x - uix - ui._windowX - 2 * slotw); - Base.dragOffY = -(mouse_y - uiy - ui._windowY + 1); + Base.dragOffX = -(mouse_x - uix - ui._window_x - 2 * slotw); + Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1); Base.dragSwatch = Context.raw.swatch; } else if (state == State.Hovered) { - TabSwatches.dragPosition = (mouse_x > uix + ui._windowX + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center + TabSwatches.dragPosition = (mouse_x > uix + ui._window_x + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center dragPositionSet = true; } else if (state == State.Released) { if (time_time() - Context.raw.selectTime < 0.25) { - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { ui.changed = false; - let h = Zui.handle("tabswatches_0"); + let h = zui_handle("tabswatches_0"); h.color = Context.raw.swatch.base; - Context.raw.swatch.base = Zui.colorWheel(h, false, null, 11 * ui.t.ELEMENT_H * Zui.SCALE(ui), true, () => { + Context.raw.swatch.base = zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true, () => { Context.raw.colorPickerPreviousTool = Context.raw.tool; Context.selectTool(WorkspaceTool.ToolPicker); Context.raw.colorPickerCallback = (color: TSwatchColor) => { Project.raw.swatches[i] = Project.cloneSwatch(color); }; }); - let hopacity = Zui.handle("tabswatches_1"); + let hopacity = zui_handle("tabswatches_1"); hopacity.value = Context.raw.swatch.opacity; - Context.raw.swatch.opacity = Zui.slider(hopacity, "Opacity", 0, 1, true); - let hocclusion = Zui.handle("tabswatches_2"); + Context.raw.swatch.opacity = zui_slider(hopacity, "Opacity", 0, 1, true); + let hocclusion = zui_handle("tabswatches_2"); hocclusion.value = Context.raw.swatch.occlusion; - Context.raw.swatch.occlusion = Zui.slider(hocclusion, "Occlusion", 0, 1, true); - let hroughness = Zui.handle("tabswatches_3"); + Context.raw.swatch.occlusion = zui_slider(hocclusion, "Occlusion", 0, 1, true); + let hroughness = zui_handle("tabswatches_3"); hroughness.value = Context.raw.swatch.roughness; - Context.raw.swatch.roughness = Zui.slider(hroughness, "Roughness", 0, 1, true); - let hmetallic = Zui.handle("tabswatches_4"); + Context.raw.swatch.roughness = zui_slider(hroughness, "Roughness", 0, 1, true); + let hmetallic = zui_handle("tabswatches_4"); hmetallic.value = Context.raw.swatch.metallic; - Context.raw.swatch.metallic = Zui.slider(hmetallic, "Metallic", 0, 1, true); - let hheight = Zui.handle("tabswatches_5"); + Context.raw.swatch.metallic = zui_slider(hmetallic, "Metallic", 0, 1, true); + let hheight = zui_handle("tabswatches_5"); hheight.value = Context.raw.swatch.height; - Context.raw.swatch.height = Zui.slider(hheight, "Height", 0, 1, true); + Context.raw.swatch.height = zui_slider(hheight, "Height", 0, 1, true); - if (ui.changed || ui.isTyping) UIMenu.keepOpen = true; - if (ui.inputReleased) Context.setSwatch(Context.raw.swatch); // Trigger material preview update - }, 16, Math.floor(mouse_x - 200 * Zui.SCALE(ui)), Math.floor(mouse_y - 250 * Zui.SCALE(ui))); + if (ui.changed || ui.is_typing) UIMenu.keepOpen = true; + if (ui.input_released) Context.setSwatch(Context.raw.swatch); // Trigger material preview update + }, 16, Math.floor(mouse_x - 200 * zui_SCALE(ui)), Math.floor(mouse_y - 250 * zui_SCALE(ui))); } Context.raw.selectTime = time_time(); } - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.setSwatch(Project.raw.swatches[i]); let add = Project.raw.swatches.length > 1 ? 1 : 0; ///if (krom_windows || krom_linux || krom_darwin) @@ -169,7 +169,7 @@ class TabSwatches { add += 1; ///end - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Duplicate"))) { Context.setSwatch(Project.cloneSwatch(Context.raw.swatch)); Project.raw.swatches.push(Context.raw.swatch); @@ -198,12 +198,12 @@ class TabSwatches { ///end }, add); } - if (ui.isHovered) { + if (ui.is_hovered) { let color = Project.raw.swatches[i].base; color = color_set_ab(color, Project.raw.swatches[i].opacity * 255); let val = color; if (val < 0) val += 4294967296; - Zui.tooltip("#" + val.toString(16)); + zui_tooltip("#" + val.toString(16)); } } } @@ -212,7 +212,7 @@ class TabSwatches { if (Base.dragSwatch != null && TabSwatches.dragPosition == Project.raw.swatches.length) { ui._x = uix; // Reset the position because otherwise it would start in the row below ui._y = uiy; - Zui.fill(28, -2, 2, 32, ui.t.HIGHLIGHT_COL); + zui_fill(28, -2, 2, 32, ui.t.HIGHLIGHT_COL); } // Currently there is no valid dragPosition so reset it @@ -220,10 +220,10 @@ class TabSwatches { TabSwatches.dragPosition = -1; } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && Project.raw.swatches.length > 1) { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && Project.raw.swatches.length > 1) { + ui.is_delete_down = false; TabSwatches.deleteSwatch(Context.raw.swatch); } } diff --git a/base/Sources/TabTextures.ts b/base/Sources/TabTextures.ts index fb3d8c2e0..8e75c593e 100644 --- a/base/Sources/TabTextures.ts +++ b/base/Sources/TabTextures.ts @@ -1,31 +1,31 @@ class TabTextures { - static draw = (htab: HandleRaw) => { + static draw = (htab: zui_handle_t) => { let ui = UIBase.ui; let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.tab(htab, tr("Textures")) && statush > UIStatus.defaultStatusH * Zui.SCALE(ui)) { + if (zui_tab(htab, tr("Textures")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) { - Zui.beginSticky(); + zui_begin_sticky(); if (Config.raw.touch_ui) { - Zui.row([1 / 4, 1 / 4]); + zui_row([1 / 4, 1 / 4]); } else { - Zui.row([1 / 14, 1 / 14]); + zui_row([1 / 14, 1 / 14]); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show(Path.textureFormats.join(","), false, true, (path: string) => { ImportAsset.run(path, -1.0, -1.0, true, false); UIBase.hwnds[TabArea.TabStatus].redraws = 2; }); } - if (ui.isHovered) Zui.tooltip(tr("Import texture file") + ` (${Config.keymap.file_import_assets})`); + if (ui.is_hovered) zui_tooltip(tr("Import texture file") + ` (${Config.keymap.file_import_assets})`); - if (Zui.button(tr("2D View"))) UIBase.show2DView(View2DType.View2DAsset); + if (zui_button(tr("2D View"))) UIBase.show2DView(View2DType.View2DAsset); - Zui.endSticky(); + zui_end_sticky(); if (Project.assets.length > 0) { @@ -36,25 +36,25 @@ class TabTextures { let statusw = sys_width(); ///end - let slotw = Math.floor(52 * Zui.SCALE(ui)); + let slotw = Math.floor(52 * zui_SCALE(ui)); let num = Math.floor(statusw / slotw); for (let row = 0; row < Math.floor(Math.ceil(Project.assets.length / num)); ++row) { let mult = Config.raw.show_asset_names ? 2 : 1; let ar = []; for (let i = 0; i < num * mult; ++i) ar.push(1 / num); - Zui.row(ar); + zui_row(ar); ui._x += 2; - let off = Config.raw.show_asset_names ? Zui.ELEMENT_OFFSET(ui) * 10.0 : 6; + let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6; if (row > 0) ui._y += off; for (let j = 0; j < num; ++j) { - let imgw = Math.floor(50 * Zui.SCALE(ui)); + let imgw = Math.floor(50 * zui_SCALE(ui)); let i = j + row * num; if (i >= Project.assets.length) { - Zui.endElement(imgw); - if (Config.raw.show_asset_names) Zui.endElement(0); + zui_end_element(imgw); + if (Config.raw.show_asset_names) zui_end_element(0); continue; } @@ -63,9 +63,9 @@ class TabTextures { let uix = ui._x; let uiy = ui._y; let sw = img.height < img.width ? img.height : 0; - if (Zui.image(img, 0xffffffff, slotw, 0, 0, sw, sw) == State.Started && ui.inputY > ui._windowY) { - Base.dragOffX = -(mouse_x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse_y - uiy - ui._windowY + 1); + if (zui_image(img, 0xffffffff, slotw, 0, 0, sw, sw) == State.Started && ui.input_y > ui._window_y) { + Base.dragOffX = -(mouse_x - uix - ui._window_x - 3); + Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1); Base.dragAsset = asset; Context.raw.texture = asset; @@ -81,22 +81,22 @@ class TabTextures { ui._y = uiy; let off = i % 2 == 1 ? 1 : 0; let w = 50; - Zui.fill(0, 0, w + 3, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(0, w - off + 2, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); - Zui.fill(0, 0, 2, w + 3, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(0, 0, w + 3, 2, ui.t.HIGHLIGHT_COL); + zui_fill(0, w - off + 2, w + 3, 2 + off, ui.t.HIGHLIGHT_COL); + zui_fill(0, 0, 2, w + 3, ui.t.HIGHLIGHT_COL); + zui_fill(w + 2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); ui._x = _uix; ui._y = _uiy; } let isPacked = Project.raw.packed_assets != null && Project.packedAssetExists(Project.raw.packed_assets, asset.file); - if (ui.isHovered) { - Zui.tooltipImage(img, 256); - Zui.tooltip(asset.name + (isPacked ? " " + tr("(packed)") : "")); + if (ui.is_hovered) { + zui_tooltip_image(img, 256); + zui_tooltip(asset.name + (isPacked ? " " + tr("(packed)") : "")); } - if (ui.isHovered && ui.inputReleasedR) { + if (ui.is_hovered && ui.input_released_r) { Context.raw.texture = asset; let count = 0; @@ -108,7 +108,7 @@ class TabTextures { count = isPacked ? 6 : 6; ///end - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Export"))) { UIFiles.show("png", true, false, (path: string) => { Base.notifyOnNextFrame(() => { @@ -180,11 +180,11 @@ class TabTextures { if (Config.raw.show_asset_names) { ui._x = uix; ui._y += slotw * 0.9; - Zui.text(Project.assets[i].name, Align.Center); - if (ui.isHovered) Zui.tooltip(Project.assets[i].name); + zui_text(Project.assets[i].name, Align.Center); + if (ui.is_hovered) zui_tooltip(Project.assets[i].name); ui._y -= slotw * 0.9; if (i == Project.assets.length - 1) { - ui._y += j == num - 1 ? imgw : imgw + Zui.ELEMENT_H(ui) + Zui.ELEMENT_OFFSET(ui); + ui._y += j == num - 1 ? imgw : imgw + zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui); } } } @@ -193,14 +193,14 @@ class TabTextures { else { let img = Res.get("icons.k"); let r = Res.tile50(img, 0, 1); - Zui.image(img, ui.t.BUTTON_COL, r.h, r.x, r.y, r.w, r.h); - if (ui.isHovered) Zui.tooltip(tr("Drag and drop files here")); + zui_image(img, ui.t.BUTTON_COL, r.h, r.x, r.y, r.w, r.h); + if (ui.is_hovered) zui_tooltip(tr("Drag and drop files here")); } - let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && - ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH; - if (inFocus && ui.isDeleteDown && Project.assets.length > 0 && Project.assets.indexOf(Context.raw.texture) >= 0) { - ui.isDeleteDown = false; + let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && + ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (inFocus && ui.is_delete_down && Project.assets.length > 0 && Project.assets.indexOf(Context.raw.texture) >= 0) { + ui.is_delete_down = false; TabTextures.deleteTexture(Context.raw.texture); } } @@ -217,7 +217,7 @@ class TabTextures { return i; } - static updateTexturePointers = (nodes: TNode[], i: i32) => { + static updateTexturePointers = (nodes: zui_node_t[], i: i32) => { for (let n of nodes) { if (n.type == "TEX_IMAGE") { if (n.buttons[0].default_value == i) { @@ -246,7 +246,7 @@ class TabTextures { } ///end - Data.deleteImage(asset.file); + data_delete_image(asset.file); Project.assetMap.delete(asset.id); Project.assets.splice(i, 1); Project.assetNames.splice(i, 1); diff --git a/base/Sources/Translator.ts b/base/Sources/Translator.ts index 28448963c..acd6d471c 100644 --- a/base/Sources/Translator.ts +++ b/base/Sources/Translator.ts @@ -113,8 +113,8 @@ class Translator { static initFont = (cjk: bool, fontPath: string, fontScale: f32) => { _g2_font_glyphs.sort((a: i32, b: i32) => { return a - b; }); // Load and assign font with cjk characters - App.notifyOnInit(() => { - Data.getFont(fontPath, (f: font_t) => { + app_notify_on_init(() => { + data_get_font(fontPath, (f: font_t) => { if (cjk) { let acjkFontIndices = Translator.cjkFontIndices as any; let fontIndex = Translator.cjkFontIndices.has(Config.raw.locale) ? acjkFontIndices[Config.raw.locale] : 0; @@ -126,8 +126,8 @@ class Translator { Base.theme.ELEMENT_W = Math.floor(Base.defaultElementW * (Config.raw.locale != "en" ? 1.4 : 1.0)); let uis = Base.getUIs(); for (let ui of uis) { - Zui.setFont(ui, f); - Zui.setScale(ui, Zui.SCALE(ui)); + zui_set_font(ui, f); + zui_set_scale(ui, zui_SCALE(ui)); } }); }); diff --git a/base/Sources/UIBase.ts b/base/Sources/UIBase.ts index 9b5622bad..e954a798d 100644 --- a/base/Sources/UIBase.ts +++ b/base/Sources/UIBase.ts @@ -25,7 +25,7 @@ class UIBase { static show = true; - static ui: ZuiRaw; + static ui: zui_t; static borderStarted = 0; static borderHandle_ptr: i32 = 0; static action_paint_remap = ""; @@ -33,27 +33,27 @@ class UIBase { static undoTapTime = 0.0; static redoTapTime = 0.0; - static init_hwnds = (): HandleRaw[] => { + static init_hwnds = (): zui_handle_t[] => { ///if is_paint - return [Handle.create(), Handle.create(), Handle.create()]; + return [zui_handle_create(), zui_handle_create(), zui_handle_create()]; ///end ///if is_sculpt - return [Handle.create(), Handle.create(), Handle.create()]; + return [zui_handle_create(), zui_handle_create(), zui_handle_create()]; ///end ///if is_lab - return [Handle.create()]; + return [zui_handle_create()]; ///end } - static init_htabs = (): HandleRaw[] => { + static init_htabs = (): zui_handle_t[] => { ///if is_paint - return [Handle.create(), Handle.create(), Handle.create()]; + return [zui_handle_create(), zui_handle_create(), zui_handle_create()]; ///end ///if is_sculpt - return [Handle.create(), Handle.create(), Handle.create()]; + return [zui_handle_create(), zui_handle_create(), zui_handle_create()]; ///end ///if is_lab - return [Handle.create()]; + return [zui_handle_create()]; ///end } @@ -100,7 +100,7 @@ class UIBase { static defaultSidebarW = UIBase.defaultSidebarFullW; ///end static tabx = 0; - static hminimized = Handle.create(); + static hminimized = zui_handle_create(); static sidebarMiniW = UIBase.defaultSidebarMiniW; ///end @@ -121,7 +121,7 @@ class UIBase { ///if (is_paint || is_sculpt) if (Project.materials == null) { Project.materials = []; - Data.getMaterial("Scene", "Material", (m: material_data_t) => { + data_get_material("Scene", "Material", (m: material_data_t) => { Project.materials.push(SlotMaterial.create(m)); Context.raw.material = Project.materials[0]; }); @@ -149,18 +149,18 @@ class UIBase { ///if is_lab if (Project.materialData == null) { - Data.getMaterial("Scene", "Material", (m: material_data_t) => { + data_get_material("Scene", "Material", (m: material_data_t) => { Project.materialData = m; }); } if (Project.defaultCanvas == null) { // Synchronous - Data.getBlob("default_brush.arm", (b: ArrayBuffer) => { + data_get_blob("default_brush.arm", (b: ArrayBuffer) => { Project.defaultCanvas = b; }); } - Project.nodes = Nodes.create(); + Project.nodes = zui_nodes_create(); Project.canvas = armpack_decode(Project.defaultCanvas); Project.canvas.name = "Brush 1"; @@ -204,11 +204,11 @@ class UIBase { History.reset(); let scale = Config.raw.window_scale; - UIBase.ui = Zui.create({ 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; + UIBase.ui = zui_create({ theme: Base.theme, font: Base.font, scaleFactor: scale, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient }); + zui_set_on_border_hover(UIBase.onBorderHover); + zui_set_on_text_hover(UIBase.onTextHover); + zui_set_on_deselect_text(UIBase.onDeselectText); + zui_set_on_tab_drop(UIBase.onTabDrop); ///if (is_paint || is_sculpt) let resources = ["cursor.k", "icons.k"]; @@ -219,26 +219,26 @@ class UIBase { ///if (is_paint || is_sculpt) Context.raw.gizmo = scene_get_child(".Gizmo"); - Context.raw.gizmoTranslateX = BaseObject.getChild(Context.raw.gizmo, ".TranslateX"); - Context.raw.gizmoTranslateY = BaseObject.getChild(Context.raw.gizmo, ".TranslateY"); - Context.raw.gizmoTranslateZ = BaseObject.getChild(Context.raw.gizmo, ".TranslateZ"); - Context.raw.gizmoScaleX = BaseObject.getChild(Context.raw.gizmo, ".ScaleX"); - Context.raw.gizmoScaleY = BaseObject.getChild(Context.raw.gizmo, ".ScaleY"); - Context.raw.gizmoScaleZ = BaseObject.getChild(Context.raw.gizmo, ".ScaleZ"); - Context.raw.gizmoRotateX = BaseObject.getChild(Context.raw.gizmo, ".RotateX"); - Context.raw.gizmoRotateY = BaseObject.getChild(Context.raw.gizmo, ".RotateY"); - Context.raw.gizmoRotateZ = BaseObject.getChild(Context.raw.gizmo, ".RotateZ"); + Context.raw.gizmoTranslateX = object_get_child(Context.raw.gizmo, ".TranslateX"); + Context.raw.gizmoTranslateY = object_get_child(Context.raw.gizmo, ".TranslateY"); + Context.raw.gizmoTranslateZ = object_get_child(Context.raw.gizmo, ".TranslateZ"); + Context.raw.gizmoScaleX = object_get_child(Context.raw.gizmo, ".ScaleX"); + Context.raw.gizmoScaleY = object_get_child(Context.raw.gizmo, ".ScaleY"); + Context.raw.gizmoScaleZ = object_get_child(Context.raw.gizmo, ".ScaleZ"); + Context.raw.gizmoRotateX = object_get_child(Context.raw.gizmo, ".RotateX"); + Context.raw.gizmoRotateY = object_get_child(Context.raw.gizmo, ".RotateY"); + Context.raw.gizmoRotateZ = object_get_child(Context.raw.gizmo, ".RotateZ"); ///end Res.load(resources, () => {}); - if (Zui.SCALE(UIBase.ui) > 1) UIBase.setIconScale(); + if (zui_SCALE(UIBase.ui) > 1) UIBase.setIconScale(); Context.raw.paintObject = scene_get_child(".Cube").ext; Project.paintObjects = [Context.raw.paintObject]; if (Project.filepath == "") { - App.notifyOnInit(Base.initLayers); + app_notify_on_init(Base.initLayers); } Context.raw.projectObjects = []; @@ -255,7 +255,7 @@ class UIBase { if (!Base.uiEnabled) return; - if (!UINodes.ui.isTyping && !UIBase.ui.isTyping) { + if (!UINodes.ui.is_typing && !UIBase.ui.is_typing) { if (Operator.shortcut(Config.keymap.toggle_node_editor)) { ///if (is_paint || is_sculpt) UINodes.canvasType == CanvasType.CanvasMaterial ? UIBase.showMaterialNodes() : UIBase.showBrushNodes(); @@ -296,7 +296,7 @@ class UIBase { let _init = () => { ExportTexture.run(Context.raw.textureExportPath); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } } else if (Operator.shortcut(Config.keymap.file_export_textures_as)) { @@ -383,7 +383,7 @@ class UIBase { } ///end - let isTyping = UIBase.ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping; + let isTyping = UIBase.ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing; ///if (is_paint || is_sculpt) if (!isTyping) { @@ -501,7 +501,7 @@ class UIBase { ///end // Viewpoint - if (mouse_view_x() < App.w()) { + if (mouse_view_x() < app_w()) { if (Operator.shortcut(Config.keymap.view_reset)) { Viewport.reset(); Viewport.scaleToBounds(); @@ -541,10 +541,10 @@ class UIBase { ///end ///end - UIMenu.draw((ui: ZuiRaw) => { - let modeHandle = Zui.handle("uibase_0"); + UIMenu.draw((ui: zui_t) => { + let modeHandle = zui_handle("uibase_0"); modeHandle.position = Context.raw.viewportMode; - Zui.text(tr("Viewport Mode"), Align.Right, ui.t.HIGHLIGHT_COL); + zui_text(tr("Viewport Mode"), Align.Right, ui.t.HIGHLIGHT_COL); let modes = [ tr("Lit"), tr("Base Color"), @@ -575,11 +575,11 @@ class UIBase { ///end for (let i = 0; i < modes.length; ++i) { - Zui.radio(modeHandle, i, modes[i], shortcuts[i]); + zui_radio(modeHandle, i, modes[i], shortcuts[i]); } let index = shortcuts.indexOf(keyboard_key_code(ui.key)); - if (ui.isKeyPressed && index != -1) { + if (ui.is_key_pressed && index != -1) { modeHandle.position = index; ui.changed = true; Context.setViewportMode(modeHandle.position); @@ -639,7 +639,7 @@ class UIBase { else { // UINodes / UIView2D ratio Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(mouse_movement_y); if (Config.raw.layout[LayoutSize.LayoutNodesH] < 32) Config.raw.layout[LayoutSize.LayoutNodesH] = 32; - else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95); + else if (Config.raw.layout[LayoutSize.LayoutNodesH] > app_h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(app_h() * 0.95); } } else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) { @@ -678,7 +678,7 @@ class UIBase { else { // UINodes / UIView2D ratio Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(mouse_movement_y); if (Config.raw.layout[LayoutSize.LayoutNodesH] < 32) Config.raw.layout[LayoutSize.LayoutNodesH] = 32; - else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95); + else if (Config.raw.layout[LayoutSize.LayoutNodesH] > app_h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(app_h() * 0.95); } } else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) { @@ -710,9 +710,9 @@ class UIBase { } History.pushUndo = true; Context.raw.particleHitX = Context.raw.particleHitY = Context.raw.particleHitZ = 0; - scene_spawn_object(".Sphere", null, (o: TBaseObject) => { - Data.getMaterial("Scene", ".Gizmo", (md: material_data_t) => { - let mo: TMeshObject = o.ext; + scene_spawn_object(".Sphere", null, (o: object_t) => { + data_get_material("Scene", ".Gizmo", (md: material_data_t) => { + let mo: mesh_object_t = o.ext; mo.base.name = ".Bullet"; mo.materials[0] = md; mo.base.visible = true; @@ -735,7 +735,7 @@ class UIBase { let ray = raycast_get_ray(mouse_view_x(), mouse_view_y(), camera); PhysicsBody.applyImpulse(body, vec4_mult(ray.dir, 0.15)); - Context.raw.particleTimer = tween_timer(5, function() { MeshObject.remove(mo); }); + Context.raw.particleTimer = tween_timer(5, function() { mesh_object_remove(mo); }); }); }); } @@ -758,31 +758,31 @@ class UIBase { } static view_top = () => { - let isTyping = UIBase.ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping; + let isTyping = UIBase.ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing; if (Context.inPaintArea() && !isTyping) { - if (mouse_view_x() < App.w()) { + if (mouse_view_x() < app_w()) { Viewport.setView(0, 0, 1, 0, 0, 0); } } } static operatorSearch = () => { - let searchHandle = Zui.handle("uibase_1"); + let searchHandle = zui_handle("uibase_1"); let first = true; - UIMenu.draw((ui: ZuiRaw) => { - Zui.fill(0, 0, ui._w / Zui.SCALE(ui), ui.t.ELEMENT_H * 8, ui.t.SEPARATOR_COL); - let search = Zui.textInput(searchHandle, "", Align.Left, true, true); + UIMenu.draw((ui: zui_t) => { + zui_fill(0, 0, ui._w / zui_SCALE(ui), ui.t.ELEMENT_H * 8, ui.t.SEPARATOR_COL); + let search = zui_text_input(searchHandle, "", Align.Left, true, true); ui.changed = false; if (first) { first = false; searchHandle.text = ""; - Zui.startTextEdit(searchHandle); // Focus search bar + zui_start_text_edit(searchHandle); // Focus search bar } if (searchHandle.changed) UIBase.operatorSearchOffset = 0; - if (ui.isKeyPressed) { // Move selection + if (ui.is_key_pressed) { // Move selection if (ui.key == KeyCode.Down && UIBase.operatorSearchOffset < 6) UIBase.operatorSearchOffset++; if (ui.key == KeyCode.Up && UIBase.operatorSearchOffset > 0) UIBase.operatorSearchOffset--; } @@ -793,7 +793,7 @@ class UIBase { for (let n in Config.keymap) { if (n.indexOf(search) >= 0) { ui.t.BUTTON_COL = count == UIBase.operatorSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL; - if (Zui.button(n, Align.Left, Config.keymap[n]) || (enter && count == UIBase.operatorSearchOffset)) { + if (zui_button(n, Align.Left, Config.keymap[n]) || (enter && count == UIBase.operatorSearchOffset)) { if (enter) { ui.changed = true; count = 6; // Trigger break @@ -842,7 +842,7 @@ class UIBase { } ///if (is_paint || is_sculpt) - UIBase.sidebarMiniW = Math.floor(UIBase.defaultSidebarMiniW * Zui.SCALE(UIBase.ui)); + UIBase.sidebarMiniW = Math.floor(UIBase.defaultSidebarMiniW * zui_SCALE(UIBase.ui)); ///end if (!Base.uiEnabled) return; @@ -978,19 +978,19 @@ class UIBase { if (down) { let mx = mouse_view_x(); let my = mouse_view_y(); - let ww = App.w(); + let ww = app_w(); ///if (is_paint || is_sculpt) if (Context.raw.paint2d) { - mx -= App.w(); + mx -= app_w(); ww = UIView2D.ww; } ///end if (mx < ww && - mx > App.x() && - my < App.h() && - my > App.y()) { + mx > app_x() && + my < app_h() && + my > app_y()) { if (setCloneSource) { Context.raw.cloneStartX = mx; @@ -1013,14 +1013,14 @@ class UIBase { if (Context.raw.tool == WorkspaceTool.ToolClone && Context.raw.cloneStartX >= 0.0) { // Clone delta Context.raw.cloneDeltaX = (Context.raw.cloneStartX - mx) / ww; - Context.raw.cloneDeltaY = (Context.raw.cloneStartY - my) / App.h(); + Context.raw.cloneDeltaY = (Context.raw.cloneStartY - my) / app_h(); Context.raw.cloneStartX = -1; } else if (Context.raw.tool == WorkspaceTool.ToolParticle) { // Reset particles ///if arm_particles - let emitter: TMeshObject = scene_get_child(".ParticleEmitter").ext; - let psys = emitter.particleSystems[0]; + let emitter: mesh_object_t = scene_get_child(".ParticleEmitter").ext; + let psys = emitter.particle_systems[0]; psys.time = 0; // psys.time = psys.seed * psys.animtime; // psys.seed++; @@ -1133,21 +1133,21 @@ class UIBase { static render = (g: g2_t) => { if (!UIBase.show && Config.raw.touch_ui) { - UIBase.ui.inputEnabled = true; + UIBase.ui.input_enabled = true; g2_end(g); - Zui.begin(UIBase.ui, g); - if (Zui.window(UIBase.ui, Zui.handle("uibase_2"), 0, 0, 150, Math.floor(Zui.ELEMENT_H(UIBase.ui) + Zui.ELEMENT_OFFSET(UIBase.ui) + 1))) { - if (Zui.button(tr("Close"))) { + zui_begin(UIBase.ui, g); + if (zui_window(UIBase.ui, zui_handle("uibase_2"), 0, 0, 150, Math.floor(zui_ELEMENT_H(UIBase.ui) + zui_ELEMENT_OFFSET(UIBase.ui) + 1))) { + if (zui_button(tr("Close"))) { UIBase.toggleDistractFree(); } } - Zui.end(); + zui_end(); g2_begin(g, false); } if (!UIBase.show || sys_width() == 0 || sys_height() == 0) return; - UIBase.ui.inputEnabled = Base.uiEnabled; + UIBase.ui.input_enabled = Base.uiEnabled; // Remember last tab positions for (let i = 0; i < UIBase.htabs.length; ++i) { @@ -1163,7 +1163,7 @@ class UIBase { } g2_end(g); - Zui.begin(UIBase.ui, g); + zui_begin(UIBase.ui, g); ///if (is_paint || is_sculpt) UIToolbar.renderUI(g); @@ -1176,7 +1176,7 @@ class UIBase { UIBase.drawSidebar(); ///end - Zui.end(); + zui_end(); g2_begin(g, false); } @@ -1184,35 +1184,35 @@ class UIBase { static drawSidebar = () => { // Tabs let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW; - let expandButtonOffset = Config.raw.touch_ui ? Math.floor(Zui.ELEMENT_H(UIBase.ui) + Zui.ELEMENT_OFFSET(UIBase.ui)) : 0; + let expandButtonOffset = Config.raw.touch_ui ? Math.floor(zui_ELEMENT_H(UIBase.ui) + zui_ELEMENT_OFFSET(UIBase.ui)) : 0; UIBase.tabx = sys_width() - Config.raw.layout[LayoutSize.LayoutSidebarW]; let _SCROLL_W = UIBase.ui.t.SCROLL_W; if (mini) UIBase.ui.t.SCROLL_W = UIBase.ui.t.SCROLL_MINI_W; - if (Zui.window(UIBase.ui, UIBase.hwnds[TabArea.TabSidebar0], UIBase.tabx, 0, Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH0])) { + if (zui_window(UIBase.ui, 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 (Zui.window(UIBase.ui, UIBase.hwnds[TabArea.TabSidebar1], UIBase.tabx, Config.raw.layout[LayoutSize.LayoutSidebarH0], Config.raw.layout[LayoutSize.LayoutSidebarW], Config.raw.layout[LayoutSize.LayoutSidebarH1] - expandButtonOffset)) { + if (zui_window(UIBase.ui, 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]); } - Zui.endWindow(); + zui_end_window(); 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(Zui.ELEMENT_H(UIBase.ui) + Zui.ELEMENT_OFFSET(UIBase.ui)); - if (Zui.window(UIBase.ui, Zui.handle("uibase_3"), sys_width() - width, sys_height() - height, width, height + 1)) { + let height = Math.floor(zui_ELEMENT_H(UIBase.ui) + zui_ELEMENT_OFFSET(UIBase.ui)); + if (zui_window(UIBase.ui, zui_handle("uibase_3"), sys_width() - width, sys_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 (Zui.button(mini ? "<<" : ">>")) { + if (zui_button(mini ? "<<" : ">>")) { Config.raw.layout[LayoutSize.LayoutSidebarW] = mini ? UIBase.defaultSidebarFullW : UIBase.defaultSidebarMiniW; - Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] * Zui.SCALE(UIBase.ui)); + Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] * zui_SCALE(UIBase.ui)); } UIBase.ui.t.BUTTON_H = _BUTTON_H; UIBase.ui.t.BUTTON_COL = _BUTTON_COL; @@ -1221,15 +1221,15 @@ class UIBase { // Expand button if (Config.raw.layout[LayoutSize.LayoutSidebarW] == 0) { - let width = Math.floor(font_width(UIBase.ui.font, UIBase.ui.fontSize, "<<") + 25 * Zui.SCALE(UIBase.ui)); - if (Zui.window(UIBase.ui, UIBase.hminimized, sys_width() - width, 0, width, Math.floor(Zui.ELEMENT_H(UIBase.ui) + Zui.ELEMENT_OFFSET(UIBase.ui) + 1))) { + let width = Math.floor(font_width(UIBase.ui.font, UIBase.ui.font_size, "<<") + 25 * zui_SCALE(UIBase.ui)); + if (zui_window(UIBase.ui, UIBase.hminimized, sys_width() - width, 0, width, Math.floor(zui_ELEMENT_H(UIBase.ui) + zui_ELEMENT_OFFSET(UIBase.ui) + 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 (Zui.button("<<")) { + if (zui_button("<<")) { Config.raw.layout[LayoutSize.LayoutSidebarW] = Context.raw.maximizedSidebarWidth != 0 ? Context.raw.maximizedSidebarWidth : Math.floor(UIBase.defaultSidebarW * Config.raw.window_scale); } UIBase.ui.t.BUTTON_H = _BUTTON_H; @@ -1321,12 +1321,12 @@ class UIBase { } let cursorImg = Res.get("cursor.k"); - let psize = Math.floor(cursorImg.width * (Context.raw.brushRadius * Context.raw.brushNodesRadius) * Zui.SCALE(UIBase.ui)); + let psize = Math.floor(cursorImg.width * (Context.raw.brushRadius * Context.raw.brushNodesRadius) * zui_SCALE(UIBase.ui)); // Clone source cursor if (Context.raw.tool == WorkspaceTool.ToolClone && !keyboard_down("alt") && (mouse_down() || pen_down())) { g.color = 0x66ffffff; - g2_draw_scaled_image(cursorImg, mx + Context.raw.cloneDeltaX * App.w() - psize / 2, my + Context.raw.cloneDeltaY * App.h() - psize / 2, psize, psize); + g2_draw_scaled_image(cursorImg, mx + Context.raw.cloneDeltaX * app_w() - psize / 2, my + Context.raw.cloneDeltaY * app_h() - psize / 2, psize, psize); g.color = 0xffffffff; } @@ -1349,8 +1349,8 @@ class UIBase { } if (!Config.raw.brush_live) { - let psizex = Math.floor(256 * Zui.SCALE(UIBase.ui) * (Context.raw.brushRadius * Context.raw.brushNodesRadius * Context.raw.brushScaleX)); - let psizey = Math.floor(256 * Zui.SCALE(UIBase.ui) * (Context.raw.brushRadius * Context.raw.brushNodesRadius)); + let psizex = Math.floor(256 * zui_SCALE(UIBase.ui) * (Context.raw.brushRadius * Context.raw.brushNodesRadius * Context.raw.brushScaleX)); + let psizey = Math.floor(256 * zui_SCALE(UIBase.ui) * (Context.raw.brushRadius * Context.raw.brushNodesRadius)); Context.raw.viewIndex = Context.raw.viewIndexLast; let decalX = Base.x() + Context.raw.decalX * Base.w() - psizex / 2; @@ -1380,7 +1380,7 @@ class UIBase { (decalMask && !Config.raw.brush_3d) || (decalMask && Context.in2dView())) { if (decalMask) { - psize = Math.floor(cursorImg.width * (Context.raw.brushDecalMaskRadius * Context.raw.brushNodesRadius) * Zui.SCALE(UIBase.ui)); + psize = Math.floor(cursorImg.width * (Context.raw.brushDecalMaskRadius * Context.raw.brushNodesRadius) * zui_SCALE(UIBase.ui)); } if (Config.raw.brush_3d && Context.in2dView()) { psize = Math.floor(psize * UIView2D.panScale); @@ -1411,7 +1411,7 @@ class UIBase { static showMaterialNodes = () => { // Clear input state as ui receives input events even when not drawn - Zui.endInput(); + zui_end_input(); ///if (is_paint || is_sculpt) UINodes.show = !UINodes.show || UINodes.canvasType != CanvasType.CanvasMaterial; @@ -1427,7 +1427,7 @@ class UIBase { ///if (is_paint || is_sculpt) static showBrushNodes = () => { // Clear input state as ui receives input events even when not drawn - Zui.endInput(); + zui_end_input(); UINodes.show = !UINodes.show || UINodes.canvasType != CanvasType.CanvasBrush; UINodes.canvasType = CanvasType.CanvasBrush; Base.resize(); @@ -1436,7 +1436,7 @@ class UIBase { static show2DView = (type: View2DType) => { // Clear input state as ui receives input events even when not drawn - Zui.endInput(); + zui_end_input(); if (UIView2D.type != type) UIView2D.show = true; else UIView2D.show = !UIView2D.show; UIView2D.type = type; @@ -1451,7 +1451,7 @@ class UIBase { } static setIconScale = () => { - if (Zui.SCALE(UIBase.ui) > 1) { + if (zui_SCALE(UIBase.ui) > 1) { Res.load(["icons2x.k"], () => { Res.bundled.set("icons.k", Res.get("icons2x.k")); }); @@ -1491,7 +1491,7 @@ class UIBase { Krom.setMouseCursor(3) : // Horizontal Krom.setMouseCursor(4); // Vertical - if (Zui.current.inputStarted) { + if (zui_current.input_started) { UIBase.borderStarted = side; UIBase.borderHandle_ptr = handle_ptr; Base.isResizing = true; diff --git a/base/Sources/UIBox.ts b/base/Sources/UIBox.ts index 9ac55f127..18937efc3 100644 --- a/base/Sources/UIBox.ts +++ b/base/Sources/UIBox.ts @@ -3,10 +3,10 @@ class UIBox { static show = false; static draggable = true; - static hwnd = Handle.create(); + static hwnd = zui_handle_create(); static boxTitle = ""; static boxText = ""; - static boxCommands: (ui: ZuiRaw)=>void = null; + static boxCommands: (ui: zui_t)=>void = null; static clickToHide = true; static modalW = 400; static modalH = 170; @@ -20,17 +20,17 @@ class UIBox { static render = (g: g2_t) => { if (!UIMenu.show) { let ui = Base.uiBox; - let inUse = ui.comboSelectedHandle_ptr != null; + let inUse = ui.combo_selected_handle_ptr != null; let isEscape = keyboard_started("escape"); - if (UIBox.draws > 2 && (ui.inputReleased || isEscape) && !inUse && !ui.isTyping) { + if (UIBox.draws > 2 && (ui.input_released || isEscape) && !inUse && !ui.is_typing) { let appw = sys_width(); let apph = sys_height(); - let mw = Math.floor(UIBox.modalW * Zui.SCALE(ui)); - let mh = Math.floor(UIBox.modalH * Zui.SCALE(ui)); - let left = (appw / 2 - mw / 2) + UIBox.hwnd.dragX; - let right = (appw / 2 + mw / 2) + UIBox.hwnd.dragX; - let top = (apph / 2 - mh / 2) + UIBox.hwnd.dragY; - let bottom = (apph / 2 + mh / 2) + UIBox.hwnd.dragY; + let mw = Math.floor(UIBox.modalW * zui_SCALE(ui)); + let mh = Math.floor(UIBox.modalH * zui_SCALE(ui)); + let left = (appw / 2 - mw / 2) + UIBox.hwnd.drag_x; + let right = (appw / 2 + mw / 2) + UIBox.hwnd.drag_x; + let top = (apph / 2 - mh / 2) + UIBox.hwnd.drag_y; + let bottom = (apph / 2 + mh / 2) + UIBox.hwnd.drag_y; let mx = mouse_x; let my = mouse_y; if ((UIBox.clickToHide && (mx < left || mx > right || my < top || my > bottom)) || isEscape) { @@ -53,56 +53,56 @@ class UIBox { let ui = Base.uiBox; let appw = sys_width(); let apph = sys_height(); - let mw = Math.floor(UIBox.modalW * Zui.SCALE(ui)); - let mh = Math.floor(UIBox.modalH * Zui.SCALE(ui)); + let mw = Math.floor(UIBox.modalW * zui_SCALE(ui)); + let mh = Math.floor(UIBox.modalH * zui_SCALE(ui)); if (mw > appw) mw = appw; if (mh > apph) mh = apph; let left = Math.floor(appw / 2 - mw / 2); let top = Math.floor(apph / 2 - mh / 2); if (UIBox.boxCommands == null) { - Zui.begin(ui, g); - if (Zui.window(ui, UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) { + zui_begin(ui, g); + if (zui_window(ui, UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) { ui._y += 10; let tabVertical = Config.raw.touch_ui; - if (Zui.tab(Zui.handle("uibox_0"), UIBox.boxTitle, tabVertical)) { - let htext = Zui.handle("uibox_1"); + if (zui_tab(zui_handle("uibox_0"), UIBox.boxTitle, tabVertical)) { + let htext = zui_handle("uibox_1"); htext.text = UIBox.boxText; UIBox.copyable ? - Zui.textArea(htext, Align.Left, false) : - Zui.text(UIBox.boxText); - Zui.endElement(); + zui_text_area(htext, Align.Left, false) : + zui_text(UIBox.boxText); + zui_end_element(); ///if (krom_windows || krom_linux || krom_darwin) - if (UIBox.copyable) Zui.row([1 / 3, 1 / 3, 1 / 3]); - else Zui.row([2 / 3, 1 / 3]); + if (UIBox.copyable) zui_row([1 / 3, 1 / 3, 1 / 3]); + else zui_row([2 / 3, 1 / 3]); ///else - Zui.row([2 / 3, 1 / 3]); + zui_row([2 / 3, 1 / 3]); ///end - Zui.endElement(); + zui_end_element(); ///if (krom_windows || krom_linux || krom_darwin) - if (UIBox.copyable && Zui.button(tr("Copy"))) { + if (UIBox.copyable && zui_button(tr("Copy"))) { Krom.copyToClipboard(UIBox.boxText); } ///end - if (Zui.button(tr("OK"))) { + if (zui_button(tr("OK"))) { UIBox.hide(); } } UIBox.windowBorder(ui); } - Zui.end(); + zui_end(); } else { - Zui.begin(ui, g); - if (Zui.window(ui, UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) { + zui_begin(ui, g); + if (zui_window(ui, UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) { ui._y += 10; UIBox.boxCommands(ui); UIBox.windowBorder(ui); } - Zui.end(); + zui_end(); } g2_begin(g, false); @@ -124,7 +124,7 @@ class UIBox { ///end } - static showCustom = (commands: (ui: ZuiRaw)=>void = null, mw = 400, mh = 200, onHide: ()=>void = null, draggable = true) => { + static showCustom = (commands: (ui: zui_t)=>void = null, mw = 400, mh = 200, onHide: ()=>void = null, draggable = true) => { UIBox.init(); UIBox.modalW = mw; UIBox.modalH = mh; @@ -154,7 +154,7 @@ class UIBox { static tweenIn = () => { tween_reset(); tween_to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: Ease.ExpoOut}); - UIBox.hwnd.dragY = Math.floor(sys_height() / 2); + UIBox.hwnd.drag_y = Math.floor(sys_height() / 2); tween_to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: Ease.ExpoOut, tick: () => { Base.redrawUI(); }}); } @@ -166,22 +166,22 @@ class UIBox { static init = () => { UIBox.hwnd.redraws = 2; - UIBox.hwnd.dragX = 0; - UIBox.hwnd.dragY = 0; + UIBox.hwnd.drag_x = 0; + UIBox.hwnd.drag_y = 0; UIBox.show = true; UIBox.draws = 0; UIBox.clickToHide = true; } - static windowBorder = (ui: ZuiRaw) => { + static windowBorder = (ui: zui_t) => { if (ui.scissor) { ui.scissor = false; g2_disable_scissor(ui.g); } // Border ui.g.color = ui.t.SEPARATOR_COL; - g2_fill_rect(0, 0, 1, ui._windowH); - g2_fill_rect(0 + ui._windowW - 1, 0, 1, ui._windowH); - g2_fill_rect(0, 0 + ui._windowH - 1, ui._windowW, 1); + g2_fill_rect(0, 0, 1, ui._window_h); + g2_fill_rect(0 + ui._window_w - 1, 0, 1, ui._window_h); + g2_fill_rect(0, 0 + ui._window_h - 1, ui._window_w, 1); } } diff --git a/base/Sources/UIFiles.ts b/base/Sources/UIFiles.ts index 2a94d2f2c..00a232c67 100644 --- a/base/Sources/UIFiles.ts +++ b/base/Sources/UIFiles.ts @@ -79,7 +79,7 @@ class UIFiles { ///end } - static fileBrowser = (ui: ZuiRaw, handle: HandleRaw, foldersOnly = false, dragFiles = false, search = "", refresh = false, contextMenu: (s: string)=>void = null): string => { + static fileBrowser = (ui: zui_t, handle: zui_handle_t, foldersOnly = false, dragFiles = false, search = "", refresh = false, contextMenu: (s: string)=>void = null): string => { let icons = Res.get("icons.k"); let folder = Res.tile50(icons, 2, 1); @@ -125,7 +125,7 @@ class UIFiles { UIFiles.lastSearch = search; handle.changed = false; - let slotw = Math.floor(70 * Zui.SCALE(ui)); + let slotw = Math.floor(70 * zui_SCALE(ui)); let num = Math.floor(ui._w / slotw); ui._y += 4; // Don't cut off the border around selected materials @@ -133,14 +133,14 @@ class UIFiles { for (let row = 0; row < Math.floor(Math.ceil(UIFiles.files.length / num)); ++row) { let ar = []; for (let i = 0; i < num * 2; ++i) ar.push(1 / num); - Zui.row(ar); - if (row > 0) ui._y += Zui.ELEMENT_OFFSET(ui) * 14.0; + zui_row(ar); + if (row > 0) ui._y += zui_ELEMENT_OFFSET(ui) * 14.0; for (let j = 0; j < num; ++j) { let i = j + row * num; if (i >= UIFiles.files.length) { - Zui.endElement(slotw); - Zui.endElement(slotw); + zui_end_element(slotw); + zui_end_element(slotw); continue; } @@ -151,7 +151,7 @@ class UIFiles { let col = rect == file ? ui.t.LABEL_COL : ui.t.LABEL_COL - 0x00202020; if (UIFiles.selected == i) col = ui.t.HIGHLIGHT_COL; - let off = ui._w / 2 - 25 * Zui.SCALE(ui); + let off = ui._w / 2 - 25 * zui_SCALE(ui); ui._x += off; let uix = ui._x; @@ -171,8 +171,8 @@ class UIFiles { UIFiles.iconMap.set(handle.text + Path.sep + f, empty); File.cacheCloud(handle.text + Path.sep + iconFile, (abs: string) => { if (abs != null) { - Data.getImage(abs, (image: image_t) => { - App.notifyOnInit(() => { + data_get_image(abs, (image: image_t) => { + app_notify_on_init(() => { if (Base.pipeCopyRGB == null) Base.makePipeCopyRGB(); icon = image_create_render_target(image.width, image.height); if (f.endsWith(".arm")) { // Used for material sphere alpha cutout @@ -201,15 +201,15 @@ class UIFiles { if (icon != null) { let w = 50; if (i == UIFiles.selected) { - Zui.fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); + zui_fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); } - state = Zui.image(icon, 0xffffffff, w * Zui.SCALE(ui)); - if (ui.isHovered) { - Zui.tooltipImage(icon); - Zui.tooltip(f); + state = zui_image(icon, 0xffffffff, w * zui_SCALE(ui)); + if (ui.is_hovered) { + zui_tooltip_image(icon); + zui_tooltip(f); } generic = false; } @@ -257,15 +257,15 @@ class UIFiles { if (icon != null) { let w = 50; if (i == UIFiles.selected) { - Zui.fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); + zui_fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); } - state = Zui.image(icon, 0xffffffff, w * Zui.SCALE(ui)); - if (ui.isHovered) { - Zui.tooltipImage(icon); - Zui.tooltip(f); + state = zui_image(icon, 0xffffffff, w * zui_SCALE(ui)); + if (ui.is_hovered) { + zui_tooltip_image(icon); + zui_tooltip(f); } generic = false; } @@ -279,8 +279,8 @@ class UIFiles { if (icon == null) { let empty = render_path_render_targets.get("empty_black").image; UIFiles.iconMap.set(shandle, empty); - Data.getImage(shandle, (image: image_t) => { - App.notifyOnInit(() => { + data_get_image(shandle, (image: image_t) => { + app_notify_on_init(() => { if (Base.pipeCopyRGB == null) Base.makePipeCopyRGB(); let sw = image.width > image.height ? w : Math.floor(1.0 * image.width / image.height * w); let sh = image.width > image.height ? Math.floor(1.0 * image.height / image.width * w) : w; @@ -292,34 +292,34 @@ class UIFiles { g2_end(icon.g2); UIFiles.iconMap.set(shandle, icon); UIBase.hwnds[TabArea.TabStatus].redraws = 3; - Data.deleteImage(shandle); // The big image is not needed anymore + data_delete_image(shandle); // The big image is not needed anymore }); }); } if (icon != null) { if (i == UIFiles.selected) { - Zui.fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); - Zui.fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); - Zui.fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); + zui_fill(-2, -2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, w + 2, w + 4, 2, ui.t.HIGHLIGHT_COL); + zui_fill(-2, 0, 2, w + 4, ui.t.HIGHLIGHT_COL); + zui_fill(w + 2 , -2, 2, w + 6, ui.t.HIGHLIGHT_COL); } - state = Zui.image(icon, 0xffffffff, icon.height * Zui.SCALE(ui)); + state = zui_image(icon, 0xffffffff, icon.height * zui_SCALE(ui)); generic = false; } } if (generic) { - state = Zui.image(icons, col, 50 * Zui.SCALE(ui), rect.x, rect.y, rect.w, rect.h); + state = zui_image(icons, col, 50 * zui_SCALE(ui), rect.x, rect.y, rect.w, rect.h); } - if (ui.isHovered && ui.inputReleasedR && contextMenu != null) { + if (ui.is_hovered && ui.input_released_r && contextMenu != null) { contextMenu(handle.text + Path.sep + f); } if (state == State.Started) { if (f != ".." && dragFiles) { - Base.dragOffX = -(mouse_x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse_y - uiy - ui._windowY + 1); + Base.dragOffX = -(mouse_x - uix - ui._window_x - 3); + Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1); Base.dragFile = handle.text; ///if krom_ios if (!isCloud) Base.dragFile = documentDirectory + Base.dragFile; @@ -358,19 +358,19 @@ class UIFiles { ui._y += slotw * 0.75; let label0 = (UIFiles.showExtensions || f.indexOf(".") <= 0) ? f : f.substr(0, f.lastIndexOf(".")); let label1 = ""; - while (label0.length > 0 && font_width(ui.font, ui.fontSize, label0) > ui._w - 6) { // 2 line split + while (label0.length > 0 && font_width(ui.font, ui.font_size, label0) > ui._w - 6) { // 2 line split label1 = label0.charAt(label0.length - 1) + label1; label0 = label0.substr(0, label0.length - 1); } - if (label1 != "") ui.curRatio--; - Zui.text(label0, Align.Center); - if (ui.isHovered) Zui.tooltip(label0 + label1); + if (label1 != "") ui.cur_ratio--; + zui_text(label0, Align.Center); + if (ui.is_hovered) zui_tooltip(label0 + label1); if (label1 != "") { // Second line ui._x = _x; - ui._y += font_height(ui.font, ui.fontSize); - Zui.text(label1, Align.Center); - if (ui.isHovered) Zui.tooltip(label0 + label1); - ui._y -= font_height(ui.font, ui.fontSize); + ui._y += font_height(ui.font, ui.font_size); + zui_text(label1, Align.Center); + if (ui.is_hovered) zui_tooltip(label0 + label1); + ui._y -= font_height(ui.font, ui.font_size); } ui._y -= slotw * 0.75; diff --git a/base/Sources/UIHeader.ts b/base/Sources/UIHeader.ts index e2c288672..8b70dc11f 100644 --- a/base/Sources/UIHeader.ts +++ b/base/Sources/UIHeader.ts @@ -3,8 +3,8 @@ class UIHeader { static defaultHeaderH = 28; static headerh = UIHeader.defaultHeaderH; - static headerHandle = Handle.create({ layout: Layout.Horizontal }); - static worktab = Handle.create(); + static headerHandle = zui_handle_create({ layout: Layout.Horizontal }); + static worktab = zui_handle_create(); constructor() { } @@ -17,7 +17,7 @@ class UIHeader { else { UIHeader.headerh = UIHeader.defaultHeaderH; } - UIHeader.headerh = Math.floor(UIHeader.headerh * Zui.SCALE(ui)); + UIHeader.headerh = Math.floor(UIHeader.headerh * zui_SCALE(ui)); if (Config.raw.layout[LayoutSize.LayoutHeader] == 0) return; @@ -28,7 +28,7 @@ class UIHeader { let ww = sys_width() - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW] - nodesw; ///end - if (Zui.window(ui, UIHeader.headerHandle, App.x(), UIHeader.headerh, ww, UIHeader.headerh)) { + if (zui_window(ui, UIHeader.headerHandle, app_x(), UIHeader.headerh, ww, UIHeader.headerh)) { ui._y += 2; UIHeader.drawToolProperties(ui); } @@ -36,30 +36,30 @@ class UIHeader { ///if is_paint - static drawToolProperties = (ui: ZuiRaw) => { + static drawToolProperties = (ui: zui_t) => { if (Context.raw.tool == WorkspaceTool.ToolColorId) { - Zui.text(tr("Picked Color")); + zui_text(tr("Picked Color")); if (Context.raw.colorIdPicked) { - Zui.image(render_path_render_targets.get("texpaint_colorid").image, 0xffffffff, 64); + zui_image(render_path_render_targets.get("texpaint_colorid").image, 0xffffffff, 64); } ui.enabled = Context.raw.colorIdPicked; - if (Zui.button(tr("Clear"))) { + if (zui_button(tr("Clear"))) { Context.raw.colorIdPicked = false; UIToolbar.toolbarHandle.redraws = 1; } ui.enabled = true; - Zui.text(tr("Color ID Map")); + zui_text(tr("Color ID Map")); if (Project.assetNames.length > 0) { - let cid = Zui.combo(Context.raw.colorIdHandle, Base.enumTexts("TEX_IMAGE"), tr("Color ID")); + let cid = zui_combo(Context.raw.colorIdHandle, Base.enumTexts("TEX_IMAGE"), tr("Color ID")); if (Context.raw.colorIdHandle.changed) { Context.raw.ddirty = 2; Context.raw.colorIdPicked = false; UIToolbar.toolbarHandle.redraws = 1; } - Zui.image(Project.getImage(Project.assets[cid])); - if (ui.isHovered) Zui.tooltipImage(Project.getImage(Project.assets[cid]), 256); + zui_image(Project.getImage(Project.assets[cid])); + if (ui.is_hovered) zui_tooltip_image(Project.getImage(Project.assets[cid]), 256); } - if (Zui.button(tr("Import"))) { + if (zui_button(tr("Import"))) { UIFiles.show(Path.textureFormats.join(","), false, true, (path: string) => { ImportAsset.run(path, -1.0, -1.0, true, false); @@ -75,18 +75,18 @@ class UIHeader { }); } ui.enabled = Context.raw.colorIdPicked; - if (Zui.button(tr("To Mask"))) { + if (zui_button(tr("To Mask"))) { if (SlotLayer.isMask(Context.raw.layer)) Context.setLayer(Context.raw.layer.parent); let m = Base.newMask(false, Context.raw.layer); let _next = () => { if (Base.pipeMerge == null) Base.makePipe(); - if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); + if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data(); g4_begin(m.texpaint.g4); g4_set_pipeline(Base.pipeColorIdToMask); g4_set_tex(Base.texpaintColorId,render_path_render_targets.get("texpaint_colorid").image); g4_set_tex(Base.texColorId, Project.getImage(Project.assets[Context.raw.colorIdHandle.position])); - g4_set_vertex_buffer(ConstData.screenAlignedVB); - g4_set_index_buffer(ConstData.screenAlignedIB); + g4_set_vertex_buffer(const_data_screen_aligned_vb); + g4_set_index_buffer(const_data_screen_aligned_ib); g4_draw(); g4_end(); Context.raw.colorIdPicked = false; @@ -113,46 +113,46 @@ class UIHeader { let heightPicked = Math.round(Context.raw.pickedColor.height * 100) / 100; let opacityPicked = Math.round(Context.raw.pickedColor.opacity * 100) / 100; - let h = Zui.handle("uiheader_0"); + let h = zui_handle("uiheader_0"); let color: Color = 0xffffffff; color = color_set_rb(color, baseRPicked * 255); color = color_set_gb(color, baseGPicked * 255); color = color_set_bb(color, baseBPicked * 255); h.color = color; - let state = Zui.text("", 0, h.color); + let state = zui_text("", 0, h.color); if (state == State.Started) { let uix = ui._x; let uiy = ui._y; - Base.dragOffX = -(mouse_x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse_y - uiy - ui._windowY + 1); + Base.dragOffX = -(mouse_x - uix - ui._window_x - 3); + Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1); Base.dragSwatch = Project.cloneSwatch(Context.raw.pickedColor); } - if (ui.isHovered) Zui.tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor")); - if (ui.isHovered && ui.inputReleased) { - UIMenu.draw((ui: ZuiRaw) => { - Zui.fill(0, 0, ui._w / Zui.SCALE(ui), ui.t.ELEMENT_H * 9, ui.t.SEPARATOR_COL); + if (ui.is_hovered) zui_tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor")); + if (ui.is_hovered && ui.input_released) { + UIMenu.draw((ui: zui_t) => { + zui_fill(0, 0, ui._w / zui_SCALE(ui), ui.t.ELEMENT_H * 9, ui.t.SEPARATOR_COL); ui.changed = false; - Zui.colorWheel(h, false, null, 10 * ui.t.ELEMENT_H * Zui.SCALE(ui), false); + zui_color_wheel(h, false, null, 10 * ui.t.ELEMENT_H * zui_SCALE(ui), false); if (ui.changed) UIMenu.keepOpen = true; }, 10); } - if (Zui.button(tr("Add Swatch"))) { + if (zui_button(tr("Add Swatch"))) { let newSwatch = Project.cloneSwatch(Context.raw.pickedColor); Context.setSwatch(newSwatch); Project.raw.swatches.push(newSwatch); UIBase.hwnds[2].redraws = 1; } - if (ui.isHovered) Zui.tooltip(tr("Add picked color to swatches")); - - Zui.text(tr("Base") + ` (${baseRPicked},${baseGPicked},${baseBPicked})`); - Zui.text(tr("Normal") + ` (${normalRPicked},${normalGPicked},${normalBPicked})`); - Zui.text(tr("Occlusion") + ` (${occlusionPicked})`); - Zui.text(tr("Roughness") + ` (${roughnessPicked})`); - Zui.text(tr("Metallic") + ` (${metallicPicked})`); - Zui.text(tr("Height") + ` (${heightPicked})`); - Zui.text(tr("Opacity") + ` (${opacityPicked})`); - Context.raw.pickerSelectMaterial = Zui.check(Zui.handle("uiheader_1", { selected: Context.raw.pickerSelectMaterial }), tr("Select Material")); - Zui.combo(Context.raw.pickerMaskHandle, [tr("None"), tr("Material")], tr("Mask"), true); + if (ui.is_hovered) zui_tooltip(tr("Add picked color to swatches")); + + zui_text(tr("Base") + ` (${baseRPicked},${baseGPicked},${baseBPicked})`); + zui_text(tr("Normal") + ` (${normalRPicked},${normalGPicked},${normalBPicked})`); + zui_text(tr("Occlusion") + ` (${occlusionPicked})`); + zui_text(tr("Roughness") + ` (${roughnessPicked})`); + zui_text(tr("Metallic") + ` (${metallicPicked})`); + zui_text(tr("Height") + ` (${heightPicked})`); + zui_text(tr("Opacity") + ` (${opacityPicked})`); + Context.raw.pickerSelectMaterial = zui_check(zui_handle("uiheader_1", { selected: Context.raw.pickerSelectMaterial }), tr("Select Material")); + zui_combo(Context.raw.pickerMaskHandle, [tr("None"), tr("Material")], tr("Mask"), true); if (Context.raw.pickerMaskHandle.changed) { MakeMaterial.parsePaintMaterial(); } @@ -163,7 +163,7 @@ class UIHeader { ///if (krom_direct3d12 || krom_vulkan || krom_metal) let baking = Context.raw.pdirty > 0; let rtBake = Context.raw.bakeType == BakeType.BakeAO || Context.raw.bakeType == BakeType.BakeLightmap || Context.raw.bakeType == BakeType.BakeBentNormal || Context.raw.bakeType == BakeType.BakeThickness; - if (baking && Zui.button(tr("Stop"))) { + if (baking && zui_button(tr("Stop"))) { Context.raw.pdirty = 0; Context.raw.rdirty = 2; } @@ -172,7 +172,7 @@ class UIHeader { let rtBake = false; ///end - if (!baking && Zui.button(tr("Bake"))) { + if (!baking && zui_button(tr("Bake"))) { Context.raw.pdirty = rtBake ? Context.raw.bakeSamples : 1; Context.raw.rdirty = 3; Base.notifyOnNextFrame(() => { @@ -185,7 +185,7 @@ class UIHeader { ///end } - let bakeHandle = Zui.handle("uiheader_2", { position: Context.raw.bakeType }); + let bakeHandle = zui_handle("uiheader_2", { position: Context.raw.bakeType }); let bakes = [ tr("AO"), tr("Curvature"), @@ -210,7 +210,7 @@ class UIHeader { } ///end - Context.raw.bakeType = Zui.combo(bakeHandle, bakes, tr("Bake")); + Context.raw.bakeType = zui_combo(bakeHandle, bakes, tr("Bake")); ///if (krom_direct3d12 || krom_vulkan || krom_metal) if (!Krom.raytraceSupported()) { @@ -220,26 +220,26 @@ class UIHeader { ///if (krom_direct3d12 || krom_vulkan || krom_metal) if (rtBake) { - let samplesHandle = Zui.handle("uiheader_3", { value: Context.raw.bakeSamples }); - Context.raw.bakeSamples = Math.floor(Zui.slider(samplesHandle, tr("Samples"), 1, 512, true, 1)); + let samplesHandle = zui_handle("uiheader_3", { value: Context.raw.bakeSamples }); + Context.raw.bakeSamples = Math.floor(zui_slider(samplesHandle, tr("Samples"), 1, 512, true, 1)); } ///end if (Context.raw.bakeType == BakeType.BakeNormalObject || Context.raw.bakeType == BakeType.BakePosition || Context.raw.bakeType == BakeType.BakeBentNormal) { - let bakeUpAxisHandle = Zui.handle("uiheader_4", { position: Context.raw.bakeUpAxis }); - Context.raw.bakeUpAxis = Zui.combo(bakeUpAxisHandle, [tr("Z"), tr("Y")], tr("Up Axis"), true); + let bakeUpAxisHandle = zui_handle("uiheader_4", { position: Context.raw.bakeUpAxis }); + Context.raw.bakeUpAxis = zui_combo(bakeUpAxisHandle, [tr("Z"), tr("Y")], tr("Up Axis"), true); } if (Context.raw.bakeType == BakeType.BakeAO || Context.raw.bakeType == BakeType.BakeCurvature) { - let bakeAxisHandle = Zui.handle("uiheader_5", { position: Context.raw.bakeAxis }); - Context.raw.bakeAxis = Zui.combo(bakeAxisHandle, [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")], tr("Axis"), true); + let bakeAxisHandle = zui_handle("uiheader_5", { position: Context.raw.bakeAxis }); + Context.raw.bakeAxis = zui_combo(bakeAxisHandle, [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")], tr("Axis"), true); } if (Context.raw.bakeType == BakeType.BakeAO) { - let strengthHandle = Zui.handle("uiheader_6", { value: Context.raw.bakeAoStrength }); - Context.raw.bakeAoStrength = Zui.slider(strengthHandle, tr("Strength"), 0.0, 2.0, true); - let radiusHandle = Zui.handle("uiheader_7", { value: Context.raw.bakeAoRadius }); - Context.raw.bakeAoRadius = Zui.slider(radiusHandle, tr("Radius"), 0.0, 2.0, true); - let offsetHandle = Zui.handle("uiheader_8", { value: Context.raw.bakeAoOffset }); - Context.raw.bakeAoOffset = Zui.slider(offsetHandle, tr("Offset"), 0.0, 2.0, true); + let strengthHandle = zui_handle("uiheader_6", { value: Context.raw.bakeAoStrength }); + Context.raw.bakeAoStrength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true); + let radiusHandle = zui_handle("uiheader_7", { value: Context.raw.bakeAoRadius }); + Context.raw.bakeAoRadius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true); + let offsetHandle = zui_handle("uiheader_8", { value: Context.raw.bakeAoOffset }); + Context.raw.bakeAoOffset = zui_slider(offsetHandle, tr("Offset"), 0.0, 2.0, true); } ///if (krom_direct3d12 || krom_vulkan || krom_metal) if (rtBake) { @@ -247,30 +247,30 @@ class UIHeader { if (progress > 1.0) progress = 1.0; // Progress bar ui.g.color = ui.t.SEPARATOR_COL; - Zui.drawRect(ui.g, true, ui._x + 1, ui._y, ui._w - 2, Zui.ELEMENT_H(ui)); + zui_draw_rect(ui.g, true, ui._x + 1, ui._y, ui._w - 2, zui_ELEMENT_H(ui)); ui.g.color = ui.t.HIGHLIGHT_COL; - Zui.drawRect(ui.g, true, ui._x + 1, ui._y, (ui._w - 2) * progress, Zui.ELEMENT_H(ui)); + zui_draw_rect(ui.g, true, ui._x + 1, ui._y, (ui._w - 2) * progress, zui_ELEMENT_H(ui)); ui.g.color = 0xffffffff; - Zui.text(tr("Samples") + ": " + RenderPathRaytraceBake.currentSample); - Zui.text(tr("Rays/pixel" + ": ") + RenderPathRaytraceBake.raysPix); - Zui.text(tr("Rays/second" + ": ") + RenderPathRaytraceBake.raysSec); + zui_text(tr("Samples") + ": " + RenderPathRaytraceBake.currentSample); + zui_text(tr("Rays/pixel" + ": ") + RenderPathRaytraceBake.raysPix); + zui_text(tr("Rays/second" + ": ") + RenderPathRaytraceBake.raysSec); } ///end if (Context.raw.bakeType == BakeType.BakeCurvature) { - let strengthHandle = Zui.handle("uiheader_9", { value: Context.raw.bakeCurvStrength }); - Context.raw.bakeCurvStrength = Zui.slider(strengthHandle, tr("Strength"), 0.0, 2.0, true); - let radiusHandle = Zui.handle("uiheader_10", { value: Context.raw.bakeCurvRadius }); - Context.raw.bakeCurvRadius = Zui.slider(radiusHandle, tr("Radius"), 0.0, 2.0, true); - let offsetHandle = Zui.handle("uiheader_11", { value: Context.raw.bakeCurvOffset }); - Context.raw.bakeCurvOffset = Zui.slider(offsetHandle, tr("Offset"), -2.0, 2.0, true); - let smoothHandle = Zui.handle("uiheader_12", { value: Context.raw.bakeCurvSmooth }); - Context.raw.bakeCurvSmooth = Math.floor(Zui.slider(smoothHandle, tr("Smooth"), 0, 5, false, 1)); + let strengthHandle = zui_handle("uiheader_9", { value: Context.raw.bakeCurvStrength }); + Context.raw.bakeCurvStrength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true); + let radiusHandle = zui_handle("uiheader_10", { value: Context.raw.bakeCurvRadius }); + Context.raw.bakeCurvRadius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true); + let offsetHandle = zui_handle("uiheader_11", { value: Context.raw.bakeCurvOffset }); + Context.raw.bakeCurvOffset = zui_slider(offsetHandle, tr("Offset"), -2.0, 2.0, true); + let smoothHandle = zui_handle("uiheader_12", { value: Context.raw.bakeCurvSmooth }); + Context.raw.bakeCurvSmooth = Math.floor(zui_slider(smoothHandle, tr("Smooth"), 0, 5, false, 1)); } if (Context.raw.bakeType == BakeType.BakeNormal || Context.raw.bakeType == BakeType.BakeHeight || Context.raw.bakeType == BakeType.BakeDerivative) { let ar = []; for (let p of Project.paintObjects) ar.push(p.base.name); - let polyHandle = Zui.handle("uiheader_13", { position: Context.raw.bakeHighPoly }); - Context.raw.bakeHighPoly = Zui.combo(polyHandle, ar, tr("High Poly")); + let polyHandle = zui_handle("uiheader_13", { position: Context.raw.bakeHighPoly }); + Context.raw.bakeHighPoly = zui_combo(polyHandle, ar, tr("High Poly")); } if (ui.changed) { MakeMaterial.parsePaintMaterial(); @@ -290,25 +290,25 @@ class UIHeader { let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown); if (Context.raw.tool != WorkspaceTool.ToolFill) { if (decalMask) { - Context.raw.brushDecalMaskRadius = Zui.slider(Context.raw.brushDecalMaskRadiusHandle, tr("Radius"), 0.01, 2.0, true); - if (ui.isHovered) Zui.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]]))); + Context.raw.brushDecalMaskRadius = zui_slider(Context.raw.brushDecalMaskRadiusHandle, tr("Radius"), 0.01, 2.0, true); + if (ui.is_hovered) zui_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]]))); } else { - Context.raw.brushRadius = Zui.slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); - if (ui.isHovered) Zui.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]]))); + Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); + if (ui.is_hovered) zui_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]]))); } } if (Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText) { - Context.raw.brushScaleX = Zui.slider(Context.raw.brushScaleXHandle, tr("Scale X"), 0.01, 2.0, true); + Context.raw.brushScaleX = zui_slider(Context.raw.brushScaleXHandle, tr("Scale X"), 0.01, 2.0, true); } if (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolFill || Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText) { - let brushScaleHandle = Zui.handle("uiheader_14", { value: Context.raw.brushScale }); - Context.raw.brushScale = Zui.slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true); + let brushScaleHandle = zui_handle("uiheader_14", { value: Context.raw.brushScale }); + Context.raw.brushScale = zui_slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true); if (brushScaleHandle.changed) { if (Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText) { g2_end(ui.g); @@ -317,24 +317,24 @@ class UIHeader { } } - Context.raw.brushAngle = Zui.slider(Context.raw.brushAngleHandle, tr("Angle"), 0.0, 360.0, true, 1); - if (ui.isHovered) Zui.tooltip(tr("Hold {brush_angle} and move mouse to the left to decrease the angle\nHold {brush_angle} and move mouse to the right to increase the angle", new Map([["brush_angle", Config.keymap.brush_angle]]))); + Context.raw.brushAngle = zui_slider(Context.raw.brushAngleHandle, tr("Angle"), 0.0, 360.0, true, 1); + if (ui.is_hovered) zui_tooltip(tr("Hold {brush_angle} and move mouse to the left to decrease the angle\nHold {brush_angle} and move mouse to the right to increase the angle", new Map([["brush_angle", Config.keymap.brush_angle]]))); if (Context.raw.brushAngleHandle.changed) { MakeMaterial.parsePaintMaterial(); } } - Context.raw.brushOpacity = Zui.slider(Context.raw.brushOpacityHandle, tr("Opacity"), 0.0, 1.0, true); - if (ui.isHovered) Zui.tooltip(tr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to increase the opacity", new Map([["brush_opacity", Config.keymap.brush_opacity]]))); + Context.raw.brushOpacity = zui_slider(Context.raw.brushOpacityHandle, tr("Opacity"), 0.0, 1.0, true); + if (ui.is_hovered) zui_tooltip(tr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to increase the opacity", new Map([["brush_opacity", Config.keymap.brush_opacity]]))); if (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolEraser || Context.raw.tool == WorkspaceTool.ToolClone || decalMask) { - Context.raw.brushHardness = Zui.slider(Zui.handle("uiheader_15", { value: Context.raw.brushHardness }), tr("Hardness"), 0.0, 1.0, true); + Context.raw.brushHardness = zui_slider(zui_handle("uiheader_15", { value: Context.raw.brushHardness }), tr("Hardness"), 0.0, 1.0, true); } if (Context.raw.tool != WorkspaceTool.ToolEraser) { - let brushBlendingHandle = Zui.handle("uiheader_16", { value: Context.raw.brushBlending }); - Context.raw.brushBlending = Zui.combo(brushBlendingHandle, [ + let brushBlendingHandle = zui_handle("uiheader_16", { value: Context.raw.brushBlending }); + Context.raw.brushBlending = zui_combo(brushBlendingHandle, [ tr("Mix"), tr("Darken"), tr("Multiply"), @@ -360,21 +360,21 @@ class UIHeader { } if (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolFill) { - let paintHandle = Zui.handle("uiheader_17"); - Context.raw.brushPaint = Zui.combo(paintHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], tr("TexCoord")); + let paintHandle = zui_handle("uiheader_17"); + Context.raw.brushPaint = zui_combo(paintHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], tr("TexCoord")); if (paintHandle.changed) { MakeMaterial.parsePaintMaterial(); } } if (Context.raw.tool == WorkspaceTool.ToolText) { - let h = Zui.handle("uiheader_18"); + let h = zui_handle("uiheader_18"); h.text = Context.raw.textToolText; let w = ui._w; - if (ui.textSelectedHandle_ptr == h.ptr || ui.submitTextHandle_ptr == h.ptr) { + if (ui.text_selected_handle_ptr == h.ptr || ui.submit_text_handle_ptr == h.ptr) { ui._w *= 3; } - Context.raw.textToolText = Zui.textInput(h, "", Align.Left, true, true); + Context.raw.textToolText = zui_text_input(h, "", Align.Left, true, true); ui._w = w; if (h.changed) { @@ -386,7 +386,7 @@ class UIHeader { } if (Context.raw.tool == WorkspaceTool.ToolFill) { - Zui.combo(Context.raw.fillTypeHandle, [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")], tr("Fill Mode")); + zui_combo(Context.raw.fillTypeHandle, [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")], tr("Fill Mode")); if (Context.raw.fillTypeHandle.changed) { if (Context.raw.fillTypeHandle.position == FillType.FillFace) { g2_end(ui.g); @@ -401,49 +401,49 @@ class UIHeader { } else { let _w = ui._w; - let sc = Zui.SCALE(ui); + let sc = zui_SCALE(ui); let touchHeader = (Config.raw.touch_ui && Config.raw.layout[LayoutSize.LayoutHeader] == 1); if (touchHeader) ui._x -= 4 * sc; ui._w = Math.floor((touchHeader ? 54 : 60) * sc); - let xrayHandle = Zui.handle("uiheader_19", { selected: Context.raw.xray }); - Context.raw.xray = Zui.check(xrayHandle, tr("X-Ray")); + let xrayHandle = zui_handle("uiheader_19", { selected: Context.raw.xray }); + Context.raw.xray = zui_check(xrayHandle, tr("X-Ray")); if (xrayHandle.changed) { MakeMaterial.parsePaintMaterial(); } - let symXHandle = Zui.handle("uiheader_20", { selected: false }); - let symYHandle = Zui.handle("uiheader_21", { selected: false }); - let symZHandle = Zui.handle("uiheader_22", { selected: false }); + let symXHandle = zui_handle("uiheader_20", { selected: false }); + let symYHandle = zui_handle("uiheader_21", { selected: false }); + let symZHandle = zui_handle("uiheader_22", { selected: false }); if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) { if (Config.raw.touch_ui) { ui._w = Math.floor(19 * sc); - Context.raw.symX = Zui.check(symXHandle, ""); + Context.raw.symX = zui_check(symXHandle, ""); ui._x -= 4 * sc; - Context.raw.symY = Zui.check(symYHandle, ""); + Context.raw.symY = zui_check(symYHandle, ""); ui._x -= 4 * sc; - Context.raw.symZ = Zui.check(symZHandle, ""); + Context.raw.symZ = zui_check(symZHandle, ""); ui._x -= 4 * sc; ui._w = Math.floor(40 * sc); - Zui.text(tr("X") + tr("Y") + tr("Z")); + zui_text(tr("X") + tr("Y") + tr("Z")); } else { ui._w = Math.floor(56 * sc); - Zui.text(tr("Symmetry")); + zui_text(tr("Symmetry")); ui._w = Math.floor(25 * sc); - Context.raw.symX = Zui.check(symXHandle, tr("X")); - Context.raw.symY = Zui.check(symYHandle, tr("Y")); - Context.raw.symZ = Zui.check(symZHandle, tr("Z")); + Context.raw.symX = zui_check(symXHandle, tr("X")); + Context.raw.symY = zui_check(symYHandle, tr("Y")); + Context.raw.symZ = zui_check(symZHandle, tr("Z")); } ui._w = _w; } else { // Popup ui._w = _w; - Context.raw.symX = Zui.check(symXHandle, tr("Symmetry") + " " + tr("X")); - Context.raw.symY = Zui.check(symYHandle, tr("Symmetry") + " " + tr("Y")); - Context.raw.symZ = Zui.check(symZHandle, tr("Symmetry") + " " + tr("Z")); + Context.raw.symX = zui_check(symXHandle, tr("Symmetry") + " " + tr("X")); + Context.raw.symY = zui_check(symYHandle, tr("Symmetry") + " " + tr("Y")); + Context.raw.symZ = zui_check(symZHandle, tr("Symmetry") + " " + tr("Z")); } if (symXHandle.changed || symYHandle.changed || symZHandle.changed) { @@ -453,9 +453,9 @@ class UIHeader { ///if arm_physics if (Context.raw.tool == WorkspaceTool.ToolParticle) { - ui._x += 10 * Zui.SCALE(ui); - let physHandle = Zui.handle("uiheader_23", { selected: false }); - Context.raw.particlePhysics = Zui.check(physHandle, tr("Physics")); + ui._x += 10 * zui_SCALE(ui); + let physHandle = zui_handle("uiheader_23", { selected: false }); + Context.raw.particlePhysics = zui_check(physHandle, tr("Physics")); if (physHandle.changed) { UtilParticle.initParticlePhysics(); MakeMaterial.parsePaintMaterial(); @@ -468,16 +468,16 @@ class UIHeader { ///end ///if is_sculpt - static drawToolProperties = (ui: ZuiRaw) => { + static drawToolProperties = (ui: zui_t) => { if (Context.raw.tool == WorkspaceTool.ToolBrush) { - Context.raw.brushRadius = Zui.slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); - if (ui.isHovered) Zui.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]]))); + Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); + if (ui.is_hovered) zui_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]]))); } } ///end ///if is_lab - static drawToolProperties = (ui: ZuiRaw) => { + static drawToolProperties = (ui: zui_t) => { if (Context.raw.tool == WorkspaceTool.ToolPicker) { } @@ -488,10 +488,10 @@ class UIHeader { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); - let inpaint = nodes.nodesSelectedId.length > 0 && Nodes.getNode(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; + let inpaint = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode"; if (inpaint) { - Context.raw.brushRadius = Zui.slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); - if (ui.isHovered) Zui.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]]))); + Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true); + if (ui.is_hovered) zui_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]]))); } } } diff --git a/base/Sources/UIMenu.ts b/base/Sources/UIMenu.ts index 5f955d169..4073d7349 100644 --- a/base/Sources/UIMenu.ts +++ b/base/Sources/UIMenu.ts @@ -9,13 +9,13 @@ class UIMenu { static menuY = 0; static menuElements = 0; static keepOpen = false; - static menuCommands: (ui: ZuiRaw)=>void = null; + static menuCommands: (ui: zui_t)=>void = null; static showMenuFirst = true; static hideMenu = false; static render = (g: g2_t) => { let ui = Base.uiMenu; - let menuW = UIMenu.menuCommands != null ? Math.floor(Base.defaultElementW * Zui.SCALE(Base.uiMenu) * 2.3) : Math.floor(Zui.ELEMENT_W(ui) * 2.3); + let menuW = UIMenu.menuCommands != null ? Math.floor(Base.defaultElementW * zui_SCALE(Base.uiMenu) * 2.3) : Math.floor(zui_ELEMENT_W(ui) * 2.3); let _BUTTON_COL = ui.t.BUTTON_COL; ui.t.BUTTON_COL = ui.t.SEPARATOR_COL; let _ELEMENT_OFFSET = ui.t.ELEMENT_OFFSET; @@ -23,13 +23,13 @@ class UIMenu { let _ELEMENT_H = ui.t.ELEMENT_H; ui.t.ELEMENT_H = Config.raw.touch_ui ? (28 + 2) : 28; - Zui.beginRegion(ui, g, UIMenu.menuX, UIMenu.menuY, menuW); + zui_begin_region(ui, g, UIMenu.menuX, UIMenu.menuY, menuW); if (UIMenu.menuCommands != null) { ui.g.color = ui.t.ACCENT_SELECT_COL; - Zui.drawRect(ui.g, true, ui._x + -1, ui._y + -1, ui._w + 2, Zui.ELEMENT_H(ui) * UIMenu.menuElements + 2); + zui_draw_rect(ui.g, true, ui._x + -1, ui._y + -1, ui._w + 2, zui_ELEMENT_H(ui) * UIMenu.menuElements + 2); ui.g.color = ui.t.SEPARATOR_COL; - Zui.drawRect(ui.g, true, ui._x + 0, ui._y + 0, ui._w, Zui.ELEMENT_H(ui) * UIMenu.menuElements); + zui_draw_rect(ui.g, true, ui._x + 0, ui._y + 0, ui._w, zui_ELEMENT_H(ui) * UIMenu.menuElements); ui.g.color = 0xffffffff; UIMenu.menuCommands(ui); @@ -108,7 +108,7 @@ class UIMenu { else if (UIMenu.menuCategory == MenuCategory.MenuViewport) { if (UIMenu.menuButton(ui, tr("Distract Free"), Config.keymap.view_distract_free)) { UIBase.toggleDistractFree(); - UIBase.ui.isHovered = false; + UIBase.ui.is_hovered = false; } ///if !(krom_android || krom_ios) @@ -121,14 +121,14 @@ class UIMenu { UIMenu.menuFill(ui); let p = scene_world; - let envHandle = Zui.handle("uimenu_0"); + let envHandle = zui_handle("uimenu_0"); envHandle.value = p.strength; UIMenu.menuAlign(ui); - p.strength = Zui.slider(envHandle, tr("Environment"), 0.0, 8.0, true); + p.strength = zui_slider(envHandle, tr("Environment"), 0.0, 8.0, true); if (envHandle.changed) Context.raw.ddirty = 2; UIMenu.menuFill(ui); - let envaHandle = Zui.handle("uimenu_1"); + let envaHandle = zui_handle("uimenu_1"); envaHandle.value = Context.raw.envmapAngle / Math.PI * 180.0; if (envaHandle.value < 0) { envaHandle.value += (Math.floor(-envaHandle.value / 360) + 1) * 360; @@ -137,29 +137,29 @@ class UIMenu { envaHandle.value -= Math.floor(envaHandle.value / 360) * 360; } UIMenu.menuAlign(ui); - Context.raw.envmapAngle = Zui.slider(envaHandle, tr("Environment Angle"), 0.0, 360.0, true, 1) / 180.0 * Math.PI; - if (ui.isHovered) Zui.tooltip(tr("{shortcut} and move mouse", new Map([["shortcut", Config.keymap.rotate_envmap]]))); + Context.raw.envmapAngle = zui_slider(envaHandle, tr("Environment Angle"), 0.0, 360.0, true, 1) / 180.0 * Math.PI; + if (ui.is_hovered) zui_tooltip(tr("{shortcut} and move mouse", new Map([["shortcut", Config.keymap.rotate_envmap]]))); if (envaHandle.changed) Context.raw.ddirty = 2; if (scene_lights.length > 0) { let light = scene_lights[0]; UIMenu.menuFill(ui); - let lhandle = Zui.handle("uimenu_2"); + let lhandle = zui_handle("uimenu_2"); let scale = 1333; lhandle.value = light.data.strength / scale; lhandle.value = Math.floor(lhandle.value * 100) / 100; UIMenu.menuAlign(ui); - light.data.strength = Zui.slider(lhandle, tr("Light"), 0.0, 4.0, true) * scale; + light.data.strength = zui_slider(lhandle, tr("Light"), 0.0, 4.0, true) * scale; if (lhandle.changed) Context.raw.ddirty = 2; UIMenu.menuFill(ui); light = scene_lights[0]; - let lahandle = Zui.handle("uimenu_3"); + let lahandle = zui_handle("uimenu_3"); lahandle.value = Context.raw.lightAngle / Math.PI * 180; UIMenu.menuAlign(ui); - let newAngle = Zui.slider(lahandle, tr("Light Angle"), 0.0, 360.0, true, 1) / 180 * Math.PI; - if (ui.isHovered) Zui.tooltip(tr("{shortcut} and move mouse", new Map([["shortcut", Config.keymap.rotate_light]]))); + let newAngle = zui_slider(lahandle, tr("Light Angle"), 0.0, 360.0, true, 1) / 180 * Math.PI; + if (ui.is_hovered) zui_tooltip(tr("{shortcut} and move mouse", new Map([["shortcut", Config.keymap.rotate_light]]))); let ldiff = newAngle - Context.raw.lightAngle; if (Math.abs(ldiff) > 0.005) { if (newAngle < 0) newAngle += (Math.floor(-newAngle / (2 * Math.PI)) + 1) * 2 * Math.PI; @@ -172,17 +172,17 @@ class UIMenu { } UIMenu.menuFill(ui); - let sxhandle = Zui.handle("uimenu_4"); + let sxhandle = zui_handle("uimenu_4"); sxhandle.value = light.data.size; UIMenu.menuAlign(ui); - light.data.size = Zui.slider(sxhandle, tr("Light Size"), 0.0, 4.0, true); + light.data.size = zui_slider(sxhandle, tr("Light Size"), 0.0, 4.0, true); if (sxhandle.changed) Context.raw.ddirty = 2; } ///if (is_paint || is_sculpt) UIMenu.menuFill(ui); - let splitViewHandle = Zui.handle("uimenu_5", { selected: Context.raw.splitView }); - Context.raw.splitView = Zui.check(splitViewHandle, " " + tr("Split View")); + let splitViewHandle = zui_handle("uimenu_5", { selected: Context.raw.splitView }); + Context.raw.splitView = zui_check(splitViewHandle, " " + tr("Split View")); if (splitViewHandle.changed) { Base.resize(); } @@ -190,9 +190,9 @@ class UIMenu { ///if is_lab UIMenu.menuFill(ui); - let brushScaleHandle = Zui.handle("uimenu_6", { value: Context.raw.brushScale }); + let brushScaleHandle = zui_handle("uimenu_6", { value: Context.raw.brushScale }); UIMenu.menuAlign(ui); - Context.raw.brushScale = Zui.slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true); + Context.raw.brushScale = zui_slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true); if (brushScaleHandle.changed) { MakeMaterial.parseMeshMaterial(); ///if (krom_direct3d12 || krom_vulkan || krom_metal) @@ -203,15 +203,15 @@ class UIMenu { ///end UIMenu.menuFill(ui); - let cullHandle = Zui.handle("uimenu_7", { selected: Context.raw.cullBackfaces }); - Context.raw.cullBackfaces = Zui.check(cullHandle, " " + tr("Cull Backfaces")); + let cullHandle = zui_handle("uimenu_7", { selected: Context.raw.cullBackfaces }); + Context.raw.cullBackfaces = zui_check(cullHandle, " " + tr("Cull Backfaces")); if (cullHandle.changed) { MakeMaterial.parseMeshMaterial(); } UIMenu.menuFill(ui); - let filterHandle = Zui.handle("uimenu_8", { selected: Context.raw.textureFilter }); - Context.raw.textureFilter = Zui.check(filterHandle, " " + tr("Filter Textures")); + let filterHandle = zui_handle("uimenu_8", { selected: Context.raw.textureFilter }); + Context.raw.textureFilter = zui_check(filterHandle, " " + tr("Filter Textures")); if (filterHandle.changed) { MakeMaterial.parsePaintMaterial(); MakeMaterial.parseMeshMaterial(); @@ -219,7 +219,7 @@ class UIMenu { ///if (is_paint || is_sculpt) UIMenu.menuFill(ui); - Context.raw.drawWireframe = Zui.check(Context.raw.wireframeHandle, " " + tr("Wireframe")); + Context.raw.drawWireframe = zui_check(Context.raw.wireframeHandle, " " + tr("Wireframe")); if (Context.raw.wireframeHandle.changed) { g2_end(ui.g); UtilUV.cacheUVMap(); @@ -230,26 +230,26 @@ class UIMenu { ///if is_paint UIMenu.menuFill(ui); - Context.raw.drawTexels = Zui.check(Context.raw.texelsHandle, " " + tr("Texels")); + Context.raw.drawTexels = zui_check(Context.raw.texelsHandle, " " + tr("Texels")); if (Context.raw.texelsHandle.changed) { MakeMaterial.parseMeshMaterial(); } ///end UIMenu.menuFill(ui); - let compassHandle = Zui.handle("uimenu_9", { selected: Context.raw.showCompass }); - Context.raw.showCompass = Zui.check(compassHandle, " " + tr("Compass")); + let compassHandle = zui_handle("uimenu_9", { selected: Context.raw.showCompass }); + Context.raw.showCompass = zui_check(compassHandle, " " + tr("Compass")); if (compassHandle.changed) Context.raw.ddirty = 2; UIMenu.menuFill(ui); - Context.raw.showEnvmap = Zui.check(Context.raw.showEnvmapHandle, " " + tr("Envmap")); + Context.raw.showEnvmap = zui_check(Context.raw.showEnvmapHandle, " " + tr("Envmap")); if (Context.raw.showEnvmapHandle.changed) { Context.loadEnvmap(); Context.raw.ddirty = 2; } UIMenu.menuFill(ui); - Context.raw.showEnvmapBlur = Zui.check(Context.raw.showEnvmapBlurHandle, " " + tr("Blur Envmap")); + Context.raw.showEnvmapBlur = zui_check(Context.raw.showEnvmapBlurHandle, " " + tr("Blur Envmap")); if (Context.raw.showEnvmapBlurHandle.changed) Context.raw.ddirty = 2; Context.updateEnvmap(); @@ -257,7 +257,7 @@ class UIMenu { if (ui.changed) UIMenu.keepOpen = true; } else if (UIMenu.menuCategory == MenuCategory.MenuMode) { - let modeHandle = Zui.handle("uimenu_10"); + let modeHandle = zui_handle("uimenu_10"); modeHandle.position = Context.raw.viewportMode; let modes = [ tr("Lit"), @@ -294,7 +294,7 @@ class UIMenu { for (let i = 0; i < modes.length; ++i) { UIMenu.menuFill(ui); let shortcut = Config.raw.touch_ui ? "" : Config.keymap.viewport_mode + ", " + shortcuts[i]; - Zui.radio(modeHandle, i, modes[i], shortcut); + zui_radio(modeHandle, i, modes[i], shortcut); } if (modeHandle.changed) { @@ -359,18 +359,18 @@ class UIMenu { UIMenu.menuFill(ui); let cam = scene_camera; - Context.raw.fovHandle = Zui.handle("uimenu_11", { value: Math.floor(cam.data.fov * 100) / 100 }); + Context.raw.fovHandle = zui_handle("uimenu_11", { value: Math.floor(cam.data.fov * 100) / 100 }); UIMenu.menuAlign(ui); - cam.data.fov = Zui.slider(Context.raw.fovHandle, tr("FoV"), 0.3, 1.4, true); + cam.data.fov = zui_slider(Context.raw.fovHandle, tr("FoV"), 0.3, 1.4, true); if (Context.raw.fovHandle.changed) { Viewport.updateCameraType(Context.raw.cameraType); } UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - let cameraControlsHandle = Zui.handle("uimenu_12"); + let cameraControlsHandle = zui_handle("uimenu_12"); cameraControlsHandle.position = Context.raw.cameraControls; - Context.raw.cameraControls = Zui.inlineRadio(cameraControlsHandle, [tr("Orbit"), tr("Rotate"), tr("Fly")], Align.Left); + Context.raw.cameraControls = zui_inline_radio(cameraControlsHandle, [tr("Orbit"), tr("Rotate"), tr("Fly")], Align.Left); let orbitAndRotateTooltip = tr("Orbit and Rotate mode:\n{rotate_shortcut} or move right mouse button to rotate.\n{zoom_shortcut} or scroll to zoom.\n{pan_shortcut} or move middle mouse to pan.", new Map([ @@ -380,12 +380,12 @@ class UIMenu { ]) ); let flyTooltip = tr("Fly mode:\nHold the right mouse button and one of the following commands:\nmove mouse to rotate.\nw, up or scroll up to move forward.\ns, down or scroll down to move backward.\na or left to move left.\nd or right to move right.\ne to move up.\nq to move down.\nHold shift to move faster or alt to move slower."); - if (ui.isHovered) Zui.tooltip(orbitAndRotateTooltip + "\n\n" + flyTooltip); + if (ui.is_hovered) zui_tooltip(orbitAndRotateTooltip + "\n\n" + flyTooltip); UIMenu.menuFill(ui); UIMenu.menuAlign(ui); - Context.raw.cameraType = Zui.inlineRadio(Context.raw.camHandle, [tr("Perspective"), tr("Orthographic")], Align.Left); - if (ui.isHovered) Zui.tooltip(tr("Camera Type") + ` (${Config.keymap.view_camera_type})`); + Context.raw.cameraType = zui_inline_radio(Context.raw.camHandle, [tr("Perspective"), tr("Orthographic")], Align.Left); + if (ui.is_hovered) zui_tooltip(tr("Camera Type") + ` (${Config.keymap.view_camera_type})`); if (Context.raw.camHandle.changed) { Viewport.updateCameraType(Context.raw.cameraType); } @@ -479,31 +479,31 @@ class UIMenu { // { lshw -C display } ///end - UIBox.showCustom((ui: ZuiRaw) => { + UIBox.showCustom((ui: zui_t) => { let tabVertical = Config.raw.touch_ui; - if (Zui.tab(Zui.handle("uimenu_13"), tr("About"), tabVertical)) { + if (zui_tab(zui_handle("uimenu_13"), tr("About"), tabVertical)) { - Data.getImage("badge.k", (img: image_t) => { - Zui.image(img); - Zui.endElement(); + data_get_image("badge.k", (img: image_t) => { + zui_image(img); + zui_end_element(); }); - Zui.textArea(Zui.handle("uimenu_14", { text: msg }), Align.Left, false); + zui_text_area(zui_handle("uimenu_14", { text: msg }), Align.Left, false); - Zui.row([1 / 3, 1 / 3, 1 / 3]); + zui_row([1 / 3, 1 / 3, 1 / 3]); ///if (krom_windows || krom_linux || krom_darwin) - if (Zui.button(tr("Copy"))) { + if (zui_button(tr("Copy"))) { Krom.copyToClipboard(msg); } ///else - Zui.endElement(); + zui_end_element(); ///end - if (Zui.button(tr("Contributors"))) { + if (zui_button(tr("Contributors"))) { File.loadUrl("https://github.com/armory3d/armortools/graphs/contributors"); } - if (Zui.button(tr("OK"))) { + if (zui_button(tr("OK"))) { UIBox.hide(); } } @@ -512,14 +512,14 @@ class UIMenu { } } - UIMenu.hideMenu = ui.comboSelectedHandle_ptr == null && !UIMenu.keepOpen && !UIMenu.showMenuFirst && (ui.changed || ui.inputReleased || ui.inputReleasedR || ui.isEscapeDown); + UIMenu.hideMenu = ui.combo_selected_handle_ptr == null && !UIMenu.keepOpen && !UIMenu.showMenuFirst && (ui.changed || ui.input_released || ui.input_released_r || ui.is_escape_down); UIMenu.showMenuFirst = false; UIMenu.keepOpen = false; ui.t.BUTTON_COL = _BUTTON_COL; ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET; ui.t.ELEMENT_H = _ELEMENT_H; - Zui.endRegion(); + zui_end_region(); if (UIMenu.hideMenu) { UIMenu.hide(); @@ -533,8 +533,8 @@ class UIMenu { Base.redrawUI(); } - static draw = (commands: (ui: ZuiRaw)=>void = null, elements: i32, x = -1, y = -1) => { - Zui.endInput(); + static draw = (commands: (ui: zui_t)=>void = null, elements: i32, x = -1, y = -1) => { + zui_end_input(); UIMenu.show = true; UIMenu.menuCommands = commands; UIMenu.menuElements = elements; @@ -545,7 +545,7 @@ class UIMenu { static fitToScreen = () => { // Prevent the menu going out of screen - let menuW = Base.defaultElementW * Zui.SCALE(Base.uiMenu) * 2.3; + let menuW = Base.defaultElementW * zui_SCALE(Base.uiMenu) * 2.3; if (UIMenu.menuX + menuW > sys_width()) { if (UIMenu.menuX - menuW > 0) { UIMenu.menuX = Math.floor(UIMenu.menuX - menuW); @@ -554,7 +554,7 @@ class UIMenu { UIMenu.menuX = Math.floor(sys_width() - menuW); } } - let menuH = Math.floor(UIMenu.menuElements * 30 * Zui.SCALE(Base.uiMenu)); // ui.t.ELEMENT_H + let menuH = Math.floor(UIMenu.menuElements * 30 * zui_SCALE(Base.uiMenu)); // ui.t.ELEMENT_H if (UIMenu.menuY + menuH > sys_height()) { if (UIMenu.menuY - menuH > 0) { UIMenu.menuY = Math.floor(UIMenu.menuY - menuH); @@ -566,25 +566,25 @@ class UIMenu { } } - static menuFill = (ui: ZuiRaw) => { + static menuFill = (ui: zui_t) => { ui.g.color = ui.t.ACCENT_SELECT_COL; - g2_fill_rect(ui._x - 1, ui._y, ui._w + 2, Zui.ELEMENT_H(ui) + 1 + 1); + g2_fill_rect(ui._x - 1, ui._y, ui._w + 2, zui_ELEMENT_H(ui) + 1 + 1); ui.g.color = ui.t.SEPARATOR_COL; - g2_fill_rect(ui._x, ui._y, ui._w, Zui.ELEMENT_H(ui) + 1); + g2_fill_rect(ui._x, ui._y, ui._w, zui_ELEMENT_H(ui) + 1); ui.g.color = 0xffffffff; } - static menuSeparator = (ui: ZuiRaw) => { + static menuSeparator = (ui: zui_t) => { ui._y++; if (Config.raw.touch_ui) { - Zui.fill(0, 0, ui._w / Zui.SCALE(ui), 1, ui.t.ACCENT_SELECT_COL); + zui_fill(0, 0, ui._w / zui_SCALE(ui), 1, ui.t.ACCENT_SELECT_COL); } else { - Zui.fill(26, 0, ui._w / Zui.SCALE(ui) - 26, 1, ui.t.ACCENT_SELECT_COL); + zui_fill(26, 0, ui._w / zui_SCALE(ui) - 26, 1, ui.t.ACCENT_SELECT_COL); } } - static menuButton = (ui: ZuiRaw, text: string, label = ""/*, icon = -1*/): bool => { + static menuButton = (ui: zui_t, text: string, label = ""/*, icon = -1*/): bool => { UIMenu.menuFill(ui); if (Config.raw.touch_ui) { label = ""; @@ -594,17 +594,17 @@ class UIMenu { // let r = Res.tile25(icons, icon, 8); // return Zui.button(Config.buttonSpacing + text, Config.buttonAlign, label, icons, r.x, r.y, r.w, r.h); - return Zui.button(Config.buttonSpacing + text, Config.buttonAlign, label); + return zui_button(Config.buttonSpacing + text, Config.buttonAlign, label); } - static menuAlign = (ui: ZuiRaw) => { + static menuAlign = (ui: zui_t) => { if (!Config.raw.touch_ui) { - Zui.row([12 / 100, 88 / 100]); - Zui.endElement(); + zui_row([12 / 100, 88 / 100]); + zui_end_element(); } } - static menuStart = (ui: ZuiRaw) => { + static menuStart = (ui: zui_t) => { // Draw top border ui.g.color = ui.t.ACCENT_SELECT_COL; if (Config.raw.touch_ui) { diff --git a/base/Sources/UIMenubar.ts b/base/Sources/UIMenubar.ts index 8d9c3c202..5e4f0330d 100644 --- a/base/Sources/UIMenubar.ts +++ b/base/Sources/UIMenubar.ts @@ -2,13 +2,13 @@ class UIMenubar { static defaultMenubarW = 330; - static workspaceHandle = Handle.create({ layout: Layout.Horizontal }); - static menuHandle = Handle.create({ layout: Layout.Horizontal }); + static workspaceHandle = zui_handle_create({ layout: Layout.Horizontal }); + static menuHandle = zui_handle_create({ layout: Layout.Horizontal }); static menubarw = UIMenubar.defaultMenubarW; ///if is_lab static _savedCamera: mat4_t = null; - static _plane: TMeshObject = null; + static _plane: mesh_object_t = null; ///end constructor() { @@ -18,16 +18,16 @@ class UIMenubar { let ui = UIBase.ui; ///if (is_paint || is_sculpt) - let panelx = App.x() - UIToolbar.toolbarw; + let panelx = app_x() - UIToolbar.toolbarw; ///end ///if is_lab - let panelx = App.x(); + let panelx = app_x(); ///end - if (Zui.window(ui, UIMenubar.menuHandle, panelx, 0, UIMenubar.menubarw, UIHeader.headerh)) { + if (zui_window(ui, UIMenubar.menuHandle, panelx, 0, UIMenubar.menubarw, UIHeader.headerh)) { ui._x += 1; // Prevent "File" button highlight on startup - Zui.beginMenu(); + zui_begin_menu(); if (Config.raw.touch_ui) { @@ -52,14 +52,14 @@ class UIMenubar { ///if (is_paint || is_lab) if (UIMenubar.iconButton(ui, 5, 2)) BoxExport.showTextures(); ///end - let size = Math.floor(ui._w / Zui.SCALE(ui)); - if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuViewport) Zui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); + let size = Math.floor(ui._w / zui_SCALE(ui)); + if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuViewport) zui_fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); if (UIMenubar.iconButton(ui, 8, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuViewport); - if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuMode) Zui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); + if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuMode) zui_fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); if (UIMenubar.iconButton(ui, 9, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuMode); - if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuCamera) Zui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); + if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuCamera) zui_fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); if (UIMenubar.iconButton(ui, 10, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuCamera); - if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuHelp) Zui.fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); + if (UIMenu.show && UIMenu.menuCategory == MenuCategory.MenuHelp) zui_fill(0, -6, size, size - 4, ui.t.HIGHLIGHT_COL); if (UIMenubar.iconButton(ui, 11, 2)) UIMenubar.showMenu(ui, MenuCategory.MenuHelp); ui.enabled = History.undos > 0; if (UIMenubar.iconButton(ui, 6, 2)) History.undo(); @@ -70,7 +70,7 @@ class UIMenubar { else { let categories = [tr("File"), tr("Edit"), tr("Viewport"), tr("Mode"), tr("Camera"), tr("Help")]; for (let i = 0; i < categories.length; ++i) { - if (Zui.menuButton(categories[i]) || (UIMenu.show && UIMenu.menuCommands == null && ui.isHovered)) { + if (zui_menu_button(categories[i]) || (UIMenu.show && UIMenu.menuCommands == null && ui.is_hovered)) { UIMenubar.showMenu(ui, i); } } @@ -84,29 +84,29 @@ class UIMenubar { ///end } - Zui.endMenu(); + zui_end_menu(); } let nodesw = (UINodes.show || UIView2D.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0; ///if (is_paint || is_sculpt) let ww = sys_width() - Config.raw.layout[LayoutSize.LayoutSidebarW] - UIMenubar.menubarw - nodesw; - panelx = (App.x() - UIToolbar.toolbarw) + UIMenubar.menubarw; + panelx = (app_x() - UIToolbar.toolbarw) + UIMenubar.menubarw; ///else let ww = sys_width() - UIMenubar.menubarw - nodesw; - panelx = (App.x()) + UIMenubar.menubarw; + panelx = (app_x()) + UIMenubar.menubarw; ///end - if (Zui.window(ui, UIMenubar.workspaceHandle, panelx, 0, ww, UIHeader.headerh)) { + if (zui_window(ui, UIMenubar.workspaceHandle, panelx, 0, ww, UIHeader.headerh)) { if (!Config.raw.touch_ui) { - Zui.tab(UIHeader.worktab, tr("3D View")); + zui_tab(UIHeader.worktab, tr("3D View")); } else { - Zui.fill(0, 0, ui._windowW, ui._windowH + 4, ui.t.SEPARATOR_COL); + zui_fill(0, 0, ui._window_w, ui._window_h + 4, ui.t.SEPARATOR_COL); } ///if is_lab - Zui.tab(UIHeader.worktab, tr("2D View")); + zui_tab(UIHeader.worktab, tr("2D View")); if (UIHeader.worktab.changed) { Context.raw.ddirty = 2; Context.raw.brushBlendDirty = true; @@ -137,9 +137,9 @@ class UIMenubar { scale_tex: mesh.scaleTex }; let md: mesh_data_t; - MeshData.create(raw, (_md: mesh_data_t) => { md = _md; }); - let dotPlane: TMeshObject = scene_get_child(".Plane").ext; - UIMenubar._plane = MeshObject.create(md, dotPlane.materials); + mesh_data_create(raw, (_md: mesh_data_t) => { md = _md; }); + let dotPlane: mesh_object_t = scene_get_child(".Plane").ext; + UIMenubar._plane = mesh_object_create(md, dotPlane.materials); array_remove(scene_meshes, UIMenubar._plane); } @@ -159,30 +159,30 @@ class UIMenubar { } } - static showMenu = (ui: ZuiRaw, category: i32) => { + static showMenu = (ui: zui_t, category: i32) => { UIMenu.show = true; UIMenu.menuCommands = null; UIMenu.menuCategory = category; UIMenu.menuCategoryW = ui._w; - UIMenu.menuCategoryH = Math.floor(Zui.MENUBAR_H(ui)); + UIMenu.menuCategoryH = Math.floor(zui_MENUBAR_H(ui)); UIMenu.menuX = Math.floor(ui._x - ui._w); - UIMenu.menuY = Math.floor(Zui.MENUBAR_H(ui)); + UIMenu.menuY = Math.floor(zui_MENUBAR_H(ui)); if (Config.raw.touch_ui) { - let menuW = Math.floor(Base.defaultElementW * Zui.SCALE(Base.uiMenu) * 2.0); + let menuW = Math.floor(Base.defaultElementW * zui_SCALE(Base.uiMenu) * 2.0); UIMenu.menuX -= Math.floor((menuW - ui._w) / 2) + Math.floor(UIHeader.headerh / 2); - UIMenu.menuX += Math.floor(2 * Zui.SCALE(Base.uiMenu)); - UIMenu.menuY -= Math.floor(2 * Zui.SCALE(Base.uiMenu)); + UIMenu.menuX += Math.floor(2 * zui_SCALE(Base.uiMenu)); + UIMenu.menuY -= Math.floor(2 * zui_SCALE(Base.uiMenu)); UIMenu.keepOpen = true; } } - static iconButton = (ui: ZuiRaw, i: i32, j: i32): bool => { + static iconButton = (ui: zui_t, i: i32, j: i32): bool => { let col = ui.t.WINDOW_BG_COL; if (col < 0) col += 4294967296; let light = col > 0xff666666 + 4294967296; let iconAccent = light ? 0xff666666 : 0xffaaaaaa; let img = Res.get("icons.k"); let rect = Res.tile50(img, i, j); - return Zui.image(img, iconAccent, null, rect.x, rect.y, rect.w, rect.h) == State.Released; + return zui_image(img, iconAccent, null, rect.x, rect.y, rect.w, rect.h) == State.Released; } } diff --git a/base/Sources/UINodes.ts b/base/Sources/UINodes.ts index a188b38e9..e2ebb08fd 100644 --- a/base/Sources/UINodes.ts +++ b/base/Sources/UINodes.ts @@ -13,7 +13,7 @@ class UINodes { static ww: i32; static wh: i32; - static ui: ZuiRaw; + static ui: zui_t; static canvasType = CanvasType.CanvasMaterial; static showMenu = false; static showMenuFirst = true; @@ -25,46 +25,46 @@ class UINodes { static uichangedLast = false; static recompileMat = false; // Mat preview static recompileMatFinal = false; - static nodeSearchSpawn: TNode = null; + static nodeSearchSpawn: zui_node_t = null; static nodeSearchOffset = 0; - static lastCanvas: TNodeCanvas = null; + static lastCanvas: zui_node_canvas_t = null; static lastNodeSelectedId = -1; static releaseLink = false; static isNodeMenuOperation = false; static grid: image_t = null; - static hwnd = Handle.create(); + static hwnd = zui_handle_create(); static groupStack: TNodeGroup[] = []; static controlsDown = false; constructor() { - Nodes.onLinkDrag = UINodes.onLinkDrag; - Nodes.onSocketReleased = UINodes.onSocketReleased; - Nodes.onCanvasReleased = UINodes.onCanvasReleased; - Nodes.onCanvasControl = UINodes.onCanvasControl; + zui_set_on_link_drag(UINodes.onLinkDrag); + zui_set_on_socket_released(UINodes.onSocketReleased); + zui_set_on_canvas_released(UINodes.onCanvasReleased); + zui_set_on_canvas_control(UINodes.onCanvasControl); let scale = Config.raw.window_scale; - UINodes.ui = Zui.create({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale }); - UINodes.ui.scrollEnabled = false; + UINodes.ui = zui_create({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale }); + UINodes.ui.scroll_enabled = false; } static onLinkDrag = (linkDragId: i32, isNewLink: bool) => { if (isNewLink) { 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); + let linkDrag = zui_get_link(UINodes.getCanvas(true).links, linkDragId); + let node = zui_get_node(UINodes.getCanvas(true).nodes, linkDrag.from_id > -1 ? linkDrag.from_id : linkDrag.to_id); + let linkX = UINodes.ui._window_x + zui_nodes_NODE_X(node); + let linkY = UINodes.ui._window_y + zui_nodes_NODE_Y(node); if (linkDrag.from_id > -1) { - linkX += Nodes.NODE_W(node); - linkY += Nodes.OUTPUT_Y(node.outputs, linkDrag.from_socket); + linkX += zui_nodes_NODE_W(node); + linkY += zui_nodes_OUTPUT_Y(node.outputs, linkDrag.from_socket); } else { - linkY += Nodes.INPUT_Y(UINodes.getCanvas(true), node.inputs, linkDrag.to_socket) + Nodes.OUTPUTS_H(node.outputs) + Nodes.BUTTONS_H(node); + linkY += zui_nodes_INPUT_Y(UINodes.getCanvas(true), node.inputs, linkDrag.to_socket) + zui_nodes_OUTPUTS_H(node.outputs) + zui_nodes_BUTTONS_H(node); } if (Math.abs(mouse_x - linkX) > 5 || Math.abs(mouse_y - linkY) > 5) { // Link length UINodes.nodeSearch(-1, -1, () => { - let n = Nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]); + let n = zui_get_node(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; @@ -103,21 +103,21 @@ class UINodes { 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 (UINodes.ui.inputReleasedR) { + let socket = zui_get_socket(canvas.nodes, socket_id); + let node = zui_get_node(canvas.nodes, socket.node_id); + if (UINodes.ui.input_released_r) { if (node.type == "GROUP_INPUT" || node.type == "GROUP_OUTPUT") { Base.notifyOnNextFrame(() => { - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { if (UIMenu.menuButton(ui, tr("Edit"))) { - let htype = Zui.handle("uinodes_0"); - let hname = Zui.handle("uinodes_1"); - let hmin = Zui.handle("uinodes_2"); - let hmax = Zui.handle("uinodes_3"); - let hval0 = Zui.handle("uinodes_4"); - let hval1 = Zui.handle("uinodes_5"); - let hval2 = Zui.handle("uinodes_6"); - let hval3 = Zui.handle("uinodes_7"); + let htype = zui_handle("uinodes_0"); + let hname = zui_handle("uinodes_1"); + let hmin = zui_handle("uinodes_2"); + let hmax = zui_handle("uinodes_3"); + let hval0 = zui_handle("uinodes_4"); + let hval1 = zui_handle("uinodes_5"); + let hval2 = zui_handle("uinodes_6"); + let hval3 = zui_handle("uinodes_7"); htype.position = socket.type == "RGBA" ? 0 : socket.type == "VECTOR" ? 1 : 2; hname.text = socket.name; hmin.value = socket.min; @@ -132,34 +132,34 @@ class UINodes { } else hval0.value = socket.default_value; Base.notifyOnNextFrame(() => { - Zui.endInput(); - UIBox.showCustom((ui: ZuiRaw) => { - if (Zui.tab(Zui.handle("uinodes_8"), tr("Socket"))) { - let type = Zui.combo(htype, [tr("Color"), tr("Vector"), tr("Value")], tr("Type"), true); + zui_end_input(); + UIBox.showCustom((ui: zui_t) => { + if (zui_tab(zui_handle("uinodes_8"), tr("Socket"))) { + let type = zui_combo(htype, [tr("Color"), tr("Vector"), tr("Value")], tr("Type"), true); if (htype.changed) hname.text = type == 0 ? tr("Color") : type == 1 ? tr("Vector") : tr("Value"); - let name = Zui.textInput(hname, tr("Name")); - let min = Zui.floatInput(hmin, tr("Min")); - let max = Zui.floatInput(hmax, tr("Max")); + let name = zui_text_input(hname, tr("Name")); + let min = zui_float_input(hmin, tr("Min")); + let max = zui_float_input(hmax, tr("Max")); let default_value: any = null; if (type == 0) { - Zui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); - Zui.floatInput(hval0, tr("R")); - Zui.floatInput(hval1, tr("G")); - Zui.floatInput(hval2, tr("B")); - Zui.floatInput(hval3, tr("A")); + zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]); + zui_float_input(hval0, tr("R")); + zui_float_input(hval1, tr("G")); + zui_float_input(hval2, tr("B")); + zui_float_input(hval3, tr("A")); default_value = new Float32Array([hval0.value, hval1.value, hval2.value, hval3.value]); } else if (type == 1) { - Zui.row([1 / 3, 1 / 3, 1 / 3]); - hval0.value = Zui.floatInput(hval0, tr("X")); - hval1.value = Zui.floatInput(hval1, tr("Y")); - hval2.value = Zui.floatInput(hval2, tr("Z")); + zui_row([1 / 3, 1 / 3, 1 / 3]); + hval0.value = zui_float_input(hval0, tr("X")); + hval1.value = zui_float_input(hval1, tr("Y")); + hval2.value = zui_float_input(hval2, tr("Z")); default_value = new Float32Array([hval0.value, hval1.value, hval2.value]); } else { - default_value = Zui.floatInput(hval0, tr("default_value")); + default_value = zui_float_input(hval0, tr("default_value")); } - if (Zui.button(tr("OK"))) { // || ui.isReturnDown + if (zui_button(tr("OK"))) { // || ui.isReturnDown socket.name = name; socket.type = type == 0 ? "RGBA" : type == 1 ? "VECTOR" : "VALUE"; socket.color = NodesMaterial.get_socket_color(socket.type); @@ -208,13 +208,13 @@ class UINodes { } static onCanvasReleased = () => { - if (UINodes.ui.inputReleasedR && Math.abs(UINodes.ui.inputX - UINodes.ui.inputStartedX) < 2 && Math.abs(UINodes.ui.inputY - UINodes.ui.inputStartedY) < 2) { + if (UINodes.ui.input_released_r && Math.abs(UINodes.ui.input_x - UINodes.ui.input_started_x) < 2 && Math.abs(UINodes.ui.input_y - UINodes.ui.input_started_y) < 2) { // Node selection let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); - let selected: TNode = null; + let selected: zui_node_t = null; for (let node of canvas.nodes) { - if (Zui.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 (zui_get_input_in_rect(UINodes.ui._window_x + zui_nodes_NODE_X(node), UINodes.ui._window_y + zui_nodes_NODE_Y(node), zui_nodes_NODE_W(node), zui_nodes_NODE_H(canvas, node))) { selected = node; break; } @@ -223,12 +223,12 @@ class UINodes { else if (nodes.nodesSelectedId.indexOf(selected.id) == -1) nodes.nodesSelectedId = [selected.id]; // Node context menu - if (!Nodes.socketReleased) { + if (!zui_socket_released()) { let numberOfEntries = 5; if (UINodes.canvasType == CanvasType.CanvasMaterial) ++numberOfEntries; if (selected != null && selected.type == "RGB") ++numberOfEntries; - UIMenu.draw((uiMenu: ZuiRaw) => { + UIMenu.draw((uiMenu: zui_t) => { uiMenu._y += 1; let isProtected = selected == null || ///if (is_paint || is_sculpt) @@ -241,22 +241,22 @@ class UINodes { if (UIMenu.menuButton(uiMenu, tr("Cut"), "ctrl+x")) { Base.notifyOnNextFrame(() => { UINodes.hwnd.redraws = 2; - Zui.isCopy = true; - Zui.isCut = true; + zui_set_is_copy(true); + zui_set_is_cut(true); UINodes.isNodeMenuOperation = true; }); } if (UIMenu.menuButton(uiMenu, tr("Copy"), "ctrl+c")) { Base.notifyOnNextFrame(() => { - Zui.isCopy = true; + zui_set_is_copy(true); UINodes.isNodeMenuOperation = true; }); } - uiMenu.enabled = Nodes.clipboard != ""; + uiMenu.enabled = zui_clipboard != ""; if (UIMenu.menuButton(uiMenu, tr("Paste"), "ctrl+v")) { Base.notifyOnNextFrame(() => { UINodes.hwnd.redraws = 2; - Zui.isPaste = true; + zui_set_is_paste(true); UINodes.isNodeMenuOperation = true; }); } @@ -264,15 +264,15 @@ class UINodes { if (UIMenu.menuButton(uiMenu, tr("Delete"), "delete")) { Base.notifyOnNextFrame(() => { UINodes.hwnd.redraws = 2; - UINodes.ui.isDeleteDown = true; + UINodes.ui.is_delete_down = true; UINodes.isNodeMenuOperation = true; }); } if (UIMenu.menuButton(uiMenu, tr("Duplicate"))) { Base.notifyOnNextFrame(() => { UINodes.hwnd.redraws = 2; - Zui.isCopy = true; - Zui.isPaste = true; + zui_set_is_copy(true); + zui_set_is_paste(true); UINodes.isNodeMenuOperation = true; }); } @@ -298,11 +298,11 @@ class UINodes { } } - if (UINodes.ui.inputReleased) { + if (UINodes.ui.input_released) { let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); for (let node of canvas.nodes) { - if (Zui.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 (zui_get_input_in_rect(UINodes.ui._window_x + zui_nodes_NODE_X(node), UINodes.ui._window_y + zui_nodes_NODE_Y(node), zui_nodes_NODE_W(node), zui_nodes_NODE_H(canvas, node))) { if (node.id == nodes.nodesSelectedId[0]) { UIView2D.hwnd.redraws = 2; if (time_time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DNode); @@ -314,40 +314,40 @@ class UINodes { } } - static onCanvasControl = (): CanvasControl => { + static onCanvasControl = (): zui_canvas_control_t => { return UINodes.getCanvasControl(UINodes.ui, UINodes); } - static getCanvasControl = (ui: ZuiRaw, parent: any): CanvasControl => { + static getCanvasControl = (ui: zui_t, parent: any): zui_canvas_control_t => { if (Config.raw.wrap_mouse && parent.controlsDown) { - if (ui.inputX < ui._windowX) { - ui.inputX = ui._windowX + ui._windowW; - Krom.setMousePosition(Math.floor(ui.inputX), Math.floor(ui.inputY)); + if (ui.input_x < ui._window_x) { + ui.input_x = ui._window_x + ui._window_w; + Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); } - else if (ui.inputX > ui._windowX + ui._windowW) { - ui.inputX = ui._windowX; - Krom.setMousePosition(Math.floor(ui.inputX), Math.floor(ui.inputY)); + else if (ui.input_x > ui._window_x + ui._window_w) { + ui.input_x = ui._window_x; + Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); } - else if (ui.inputY < ui._windowY) { - ui.inputY = ui._windowY + ui._windowH; - Krom.setMousePosition(Math.floor(ui.inputX), Math.floor(ui.inputY)); + else if (ui.input_y < ui._window_y) { + ui.input_y = ui._window_y + ui._window_h; + Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); } - else if (ui.inputY > ui._windowY + ui._windowH) { - ui.inputY = ui._windowY; - Krom.setMousePosition(Math.floor(ui.inputX), Math.floor(ui.inputY)); + else if (ui.input_y > ui._window_y + ui._window_h) { + ui.input_y = ui._window_y; + Krom.setMousePosition(Math.floor(ui.input_x), Math.floor(ui.input_y)); } } if (Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutStarted) || Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutStarted) || - ui.inputStartedR || - ui.inputWheelDelta != 0.0) { + ui.input_started_r || + ui.input_wheel_delta != 0.0) { parent.controlsDown = true; } else if (!Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) && !Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown) && - !ui.inputDownR && - ui.inputWheelDelta == 0.0) { + !ui.input_down_r && + ui.input_wheel_delta == 0.0) { parent.controlsDown = false; } if (!parent.controlsDown) { @@ -358,26 +358,26 @@ class UINodes { } } - let pan = ui.inputDownR || Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown); + let pan = ui.input_down_r || Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown); let zoomDelta = Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown) ? UINodes.getZoomDelta(ui) / 100.0 : 0.0; let control = { - panX: pan ? ui.inputDX : 0.0, - panY: pan ? ui.inputDY : 0.0, - zoom: ui.inputWheelDelta != 0.0 ? -ui.inputWheelDelta / 10 : zoomDelta + panX: pan ? ui.input_dx : 0.0, + panY: pan ? ui.input_dy : 0.0, + zoom: ui.input_wheel_delta != 0.0 ? -ui.input_wheel_delta / 10 : zoomDelta }; if (Base.isComboSelected()) control.zoom = 0.0; return control; } - static getZoomDelta = (ui: ZuiRaw): f32 => { - return Config.raw.zoom_direction == ZoomDirection.ZoomVertical ? -ui.inputDY : - Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ? -ui.inputDY : - Config.raw.zoom_direction == ZoomDirection.ZoomHorizontal ? ui.inputDX : - Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ? ui.inputDX : - -(ui.inputDY - ui.inputDX); + static getZoomDelta = (ui: zui_t): f32 => { + return Config.raw.zoom_direction == ZoomDirection.ZoomVertical ? -ui.input_dy : + Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ? -ui.input_dy : + Config.raw.zoom_direction == ZoomDirection.ZoomHorizontal ? ui.input_dx : + Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ? ui.input_dx : + -(ui.input_dy - ui.input_dx); } - static getCanvas = (groups = false): TNodeCanvas => { + static getCanvas = (groups = false): zui_node_canvas_t => { ///if (is_paint || is_sculpt) if (UINodes.canvasType == CanvasType.CanvasMaterial) { if (groups && UINodes.groupStack.length > 0) return UINodes.groupStack[UINodes.groupStack.length - 1].canvas; @@ -392,12 +392,12 @@ class UINodes { } ///if (is_paint || is_sculpt) - static getCanvasMaterial = (): TNodeCanvas => { + static getCanvasMaterial = (): zui_node_canvas_t => { return Context.raw.material.canvas; } ///end - static getNodes = (): NodesRaw => { + static getNodes = (): zui_nodes_t => { ///if (is_paint || is_sculpt) if (UINodes.canvasType == CanvasType.CanvasMaterial) { if (UINodes.groupStack.length > 0) return UINodes.groupStack[UINodes.groupStack.length - 1].nodes; @@ -416,15 +416,15 @@ class UINodes { if (!UINodes.show || !Base.uiEnabled) return; ///if (is_paint || is_sculpt) - UINodes.wx = Math.floor(App.w()) + UIToolbar.toolbarw; + UINodes.wx = Math.floor(app_w()) + UIToolbar.toolbarw; ///end ///if is_lab - UINodes.wx = Math.floor(App.w()); + UINodes.wx = Math.floor(app_w()); ///end UINodes.wy = UIHeader.headerh * 2; if (UIView2D.show) { - UINodes.wy += App.h() - Config.raw.layout[LayoutSize.LayoutNodesH]; + UINodes.wy += app_h() - Config.raw.layout[LayoutSize.LayoutNodesH]; } let ww = Config.raw.layout[LayoutSize.LayoutNodesW]; @@ -439,21 +439,21 @@ class UINodes { let mx = mouse_x; let my = mouse_y; if (mx < UINodes.wx || mx > UINodes.wx + ww || my < UINodes.wy) return; - if (UINodes.ui.isTyping || !UINodes.ui.inputEnabled) return; + if (UINodes.ui.is_typing || !UINodes.ui.input_enabled) return; 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; + if (nodes.nodesSelectedId.length > 0 && UINodes.ui.is_key_pressed) { + if (UINodes.ui.key == KeyCode.Left) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x -= 1; + else if (UINodes.ui.key == KeyCode.Right) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x += 1; + if (UINodes.ui.key == KeyCode.Up) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y -= 1; + else if (UINodes.ui.key == KeyCode.Down) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y += 1; } // Node search popup 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.ui.input_x = mouse_x; // Fix inputDX after popup removal + UINodes.ui.input_y = mouse_y; UINodes.nodeSearchSpawn = null; } @@ -470,24 +470,24 @@ class UINodes { } static nodeSearch = (x = -1, y = -1, done: ()=>void = null) => { - let searchHandle = Zui.handle("uinodes_9"); + let searchHandle = zui_handle("uinodes_9"); let first = true; - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { ui.g.color = ui.t.SEPARATOR_COL; - Zui.drawRect(ui.g, true, ui._x, ui._y, ui._w, Zui.ELEMENT_H(ui) * 8); + zui_draw_rect(ui.g, true, ui._x, ui._y, ui._w, zui_ELEMENT_H(ui) * 8); ui.g.color = 0xffffffff; - let search = Zui.textInput(searchHandle, "", Align.Left, true, true).toLowerCase(); + let search = zui_text_input(searchHandle, "", Align.Left, true, true).toLowerCase(); ui.changed = false; if (first) { first = false; searchHandle.text = ""; - Zui.startTextEdit(searchHandle); // Focus search bar + zui_start_text_edit(searchHandle); // Focus search bar } if (searchHandle.changed) UINodes.nodeSearchOffset = 0; - if (ui.isKeyPressed) { // Move selection + if (ui.is_key_pressed) { // Move selection if (ui.key == KeyCode.Down && UINodes.nodeSearchOffset < 6) UINodes.nodeSearchOffset++; if (ui.key == KeyCode.Up && UINodes.nodeSearchOffset > 0) UINodes.nodeSearchOffset--; } @@ -506,7 +506,7 @@ class UINodes { for (let n of list) { if (tr(n.name).toLowerCase().indexOf(search) >= 0) { ui.t.BUTTON_COL = count == UINodes.nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL; - if (Zui.button(tr(n.name), Align.Left) || (enter && count == UINodes.nodeSearchOffset)) { + if (zui_button(tr(n.name), Align.Left) || (enter && count == UINodes.nodeSearchOffset)) { UINodes.pushUndo(); let nodes = UINodes.getNodes(); let canvas = UINodes.getCanvas(true); @@ -540,11 +540,11 @@ class UINodes { } static getNodeX = (): i32 => { - return Math.floor((mouse_x - UINodes.wx - Nodes.PAN_X()) / Nodes.SCALE()); + return Math.floor((mouse_x - UINodes.wx - zui_nodes_PAN_X()) / zui_nodes_SCALE()); } static getNodeY = (): i32 => { - return Math.floor((mouse_y - UINodes.wy - Nodes.PAN_Y()) / Nodes.SCALE()); + return Math.floor((mouse_y - UINodes.wy - zui_nodes_PAN_Y()) / zui_nodes_SCALE()); } static drawGrid = () => { @@ -556,8 +556,8 @@ class UINodes { } ///end - let wh = App.h(); - let step = 100 * Zui.SCALE(UINodes.ui); + let wh = app_h(); + let step = 100 * zui_SCALE(UINodes.ui); let w = Math.floor(ww + step * 3); let h = Math.floor(wh + step * 3); if (w < 1) w = 1; @@ -566,7 +566,7 @@ class UINodes { g2_begin(UINodes.grid.g2, true, UINodes.ui.t.SEPARATOR_COL); UINodes.grid.g2.color = UINodes.ui.t.SEPARATOR_COL - 0x00050505; - step = 20 * Zui.SCALE(UINodes.ui); + step = 20 * zui_SCALE(UINodes.ui); for (let i = 0; i < Math.floor(h / step) + 1; ++i) { g2_draw_line(0, i * step, w, i * step); } @@ -575,7 +575,7 @@ class UINodes { } UINodes.grid.g2.color = UINodes.ui.t.SEPARATOR_COL - 0x00090909; - step = 100 * Zui.SCALE(UINodes.ui); + step = 100 * zui_SCALE(UINodes.ui); for (let i = 0; i < Math.floor(h / step) + 1; ++i) { g2_draw_line(0, i * step, w, i * step); } @@ -648,14 +648,14 @@ class UINodes { // Remove dragged link when mouse is released out of the node viewport let c = UINodes.getCanvas(true); if (UINodes.releaseLink && nodes.linkDragId != -1) { - array_remove(c.links, Nodes.getLink(c.links, nodes.linkDragId)); + array_remove(c.links, zui_get_link(c.links, nodes.linkDragId)); nodes.linkDragId = -1; } - UINodes.releaseLink = UINodes.ui.inputReleased; + UINodes.releaseLink = UINodes.ui.input_released; if (!UINodes.show || sys_width() == 0 || sys_height() == 0) return; - UINodes.ui.inputEnabled = Base.uiEnabled; + UINodes.ui.input_enabled = Base.uiEnabled; g2_end(g); @@ -668,16 +668,16 @@ class UINodes { ///end // Start with UI - Zui.begin(UINodes.ui, g); + zui_begin(UINodes.ui, g); // Make window UINodes.ww = Config.raw.layout[LayoutSize.LayoutNodesW]; ///if (is_paint || is_sculpt) - UINodes.wx = Math.floor(App.w()) + UIToolbar.toolbarw; + UINodes.wx = Math.floor(app_w()) + UIToolbar.toolbarw; ///end ///if is_lab - UINodes.wx = Math.floor(App.w()); + UINodes.wx = Math.floor(app_w()); ///end UINodes.wy = 0; @@ -689,43 +689,43 @@ class UINodes { } ///end - let ew = Math.floor(Zui.ELEMENT_W(UINodes.ui) * 0.7); - UINodes.wh = App.h() + UIHeader.headerh; + let ew = Math.floor(zui_ELEMENT_W(UINodes.ui) * 0.7); + UINodes.wh = app_h() + UIHeader.headerh; if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) UINodes.wh += UIHeader.headerh; if (UIView2D.show) { UINodes.wh = Config.raw.layout[LayoutSize.LayoutNodesH]; - UINodes.wy = App.h() - Config.raw.layout[LayoutSize.LayoutNodesH] + UIHeader.headerh; + 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 (Zui.window(UINodes.ui, UINodes.hwnd, UINodes.wx, UINodes.wy, UINodes.ww, UINodes.wh)) { + if (zui_window(UINodes.ui, UINodes.hwnd, UINodes.wx, UINodes.wy, UINodes.ww, UINodes.wh)) { - Zui.tab(Zui.handle("uinodes_10"), tr("Nodes")); + zui_tab(zui_handle("uinodes_10"), tr("Nodes")); // Grid UINodes.ui.g.color = 0xffffffff; - let step = 100 * Zui.SCALE(UINodes.ui); - g2_draw_image(UINodes.grid, (nodes.panX * Nodes.SCALE()) % step - step, (nodes.panY * Nodes.SCALE()) % step - step); + let step = 100 * zui_SCALE(UINodes.ui); + g2_draw_image(UINodes.grid, (nodes.panX * zui_nodes_SCALE()) % step - step, (nodes.panY * zui_nodes_SCALE()) % step - step); // Undo - if (UINodes.ui.inputStarted || UINodes.ui.isKeyPressed) { + if (UINodes.ui.input_started || UINodes.ui.is_key_pressed) { UINodes.lastCanvas = JSON.parse(JSON.stringify(UINodes.getCanvas(true))); } // Nodes - let _inputEnabled = UINodes.ui.inputEnabled; - UINodes.ui.inputEnabled = _inputEnabled && !UINodes.showMenu; + let _inputEnabled = UINodes.ui.input_enabled; + UINodes.ui.input_enabled = _inputEnabled && !UINodes.showMenu; ///if (is_paint || is_sculpt) - UINodes.ui.windowBorderRight = Config.raw.layout[LayoutSize.LayoutSidebarW]; + UINodes.ui.window_border_right = Config.raw.layout[LayoutSize.LayoutSidebarW]; ///end - UINodes.ui.windowBorderTop = UIHeader.headerh * 2; - UINodes.ui.windowBorderBottom = Config.raw.layout[LayoutSize.LayoutStatusH]; - Nodes.nodeCanvas(nodes, UINodes.ui, c); - UINodes.ui.inputEnabled = _inputEnabled; + UINodes.ui.window_border_top = UIHeader.headerh * 2; + UINodes.ui.window_border_bottom = Config.raw.layout[LayoutSize.LayoutStatusH]; + zui_node_canvas(nodes, UINodes.ui, c); + UINodes.ui.input_enabled = _inputEnabled; if (nodes.colorPickerCallback != null) { Context.raw.colorPickerPreviousTool = Context.raw.tool; @@ -750,7 +750,7 @@ class UINodes { } // Remove nodes with unknown id for this canvas type - if (Zui.isPaste) { + if (zui_is_paste) { ///if (is_paint || is_sculpt) let nodeList = UINodes.canvasType == CanvasType.CanvasMaterial ? NodesMaterial.list : NodesBrush.list; ///end @@ -761,7 +761,7 @@ class UINodes { let i = 0; while (i++ < c.nodes.length) { let canvasNode = c.nodes[i - 1]; - if (Nodes.excludeRemove.indexOf(canvasNode.type) >= 0) { + if (zui_exclude_remove.indexOf(canvasNode.type) >= 0) { continue; } let found = false; @@ -778,7 +778,7 @@ class UINodes { found = false; } if (!found) { - Nodes.removeNode(canvasNode, c); + zui_remove_node(canvasNode, c); array_remove(nodes.nodesSelectedId, canvasNode.id); i--; } @@ -786,16 +786,19 @@ class UINodes { } if (UINodes.isNodeMenuOperation) { - Zui.isCopy = Zui.isCut = Zui.isPaste = UINodes.ui.isDeleteDown = false; + zui_set_is_copy(false); + zui_set_is_cut(false); + zui_set_is_paste(false); + UINodes.ui.is_delete_down = false; } // Recompile material on change if (UINodes.ui.changed) { ///if (is_paint || is_sculpt) - UINodes.recompileMat = (UINodes.ui.inputDX != 0 || UINodes.ui.inputDY != 0 || !UINodes.uichangedLast) && Config.raw.material_live; // Instant preview + UINodes.recompileMat = (UINodes.ui.input_dx != 0 || UINodes.ui.input_dy != 0 || !UINodes.uichangedLast) && Config.raw.material_live; // Instant preview ///end ///if is_lab - UINodes.recompileMat = (UINodes.ui.inputDX != 0 || UINodes.ui.inputDY != 0 || !UINodes.uichangedLast); // Instant preview + UINodes.recompileMat = (UINodes.ui.input_dx != 0 || UINodes.ui.input_dy != 0 || !UINodes.uichangedLast); // Instant preview ///end } else if (UINodes.uichangedLast) { @@ -807,7 +810,7 @@ class UINodes { // Node previews if (Config.raw.node_preview && nodes.nodesSelectedId.length > 0) { let img: image_t = null; - let sel = Nodes.getNode(c.nodes, nodes.nodesSelectedId[0]); + let sel = zui_get_node(c.nodes, nodes.nodesSelectedId[0]); ///if (is_paint || is_sculpt) @@ -846,10 +849,10 @@ class UINodes { ///end if (img != null) { - let tw = 128 * Zui.SCALE(UINodes.ui); + let tw = 128 * zui_SCALE(UINodes.ui); let th = tw * (img.height / img.width); - let tx = UINodes.ww - tw - 8 * Zui.SCALE(UINodes.ui); - let ty = UINodes.wh - th - 8 * Zui.SCALE(UINodes.ui); + let tx = UINodes.ww - tw - 8 * zui_SCALE(UINodes.ui); + let ty = UINodes.wh - th - 8 * zui_SCALE(UINodes.ui); ///if krom_opengl let invertY = sel.type == "MATERIAL"; @@ -882,20 +885,20 @@ class UINodes { // Menu UINodes.ui.g.color = UINodes.ui.t.SEPARATOR_COL; - g2_fill_rect(0, Zui.ELEMENT_H(UINodes.ui), UINodes.ww, Zui.ELEMENT_H(UINodes.ui) + Zui.ELEMENT_OFFSET(UINodes.ui) * 2); + g2_fill_rect(0, zui_ELEMENT_H(UINodes.ui), UINodes.ww, zui_ELEMENT_H(UINodes.ui) + zui_ELEMENT_OFFSET(UINodes.ui) * 2); UINodes.ui.g.color = 0xffffffff; - let startY = Zui.ELEMENT_H(UINodes.ui) + Zui.ELEMENT_OFFSET(UINodes.ui); + let startY = zui_ELEMENT_H(UINodes.ui) + zui_ELEMENT_OFFSET(UINodes.ui); 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"); + let h = zui_handle("uinodes_11"); h.text = c.name; - UINodes.ui._w = Math.floor(Math.min(font_width(UINodes.ui.font, UINodes.ui.fontSize, h.text) + 15 * Zui.SCALE(UINodes.ui), 100 * Zui.SCALE(UINodes.ui))); - let newName = Zui.textInput(h, ""); + UINodes.ui._w = Math.floor(Math.min(font_width(UINodes.ui.font, UINodes.ui.font_size, h.text) + 15 * zui_SCALE(UINodes.ui), 100 * zui_SCALE(UINodes.ui))); + let newName = zui_text_input(h, ""); UINodes.ui._x += UINodes.ui._w + 3; UINodes.ui._y = 2 + startY; UINodes.ui._w = ew; @@ -910,7 +913,7 @@ class UINodes { if (canRename) { let oldName = c.name; c.name = newName; - let canvases: TNodeCanvas[] = []; + let canvases: zui_node_canvas_t[] = []; for (let m of Project.materials) canvases.push(m.canvas); for (let m of Project.materialGroups) canvases.push(m.canvas); for (let canvas of canvases) { @@ -929,7 +932,7 @@ class UINodes { ///end ///if is_lab - UINodes.ui.windowBorderTop = 0; + UINodes.ui.window_border_top = 0; UINodesExt.drawButtons(ew, startY); ///end @@ -944,7 +947,7 @@ class UINodes { ///end for (let i = 0; i < cats.length; ++i) { - if ((Zui.menuButton(tr(cats[i]))) || (UINodes.ui.isHovered && UINodes.showMenu)) { + if ((zui_menu_button(tr(cats[i]))) || (UINodes.ui.is_hovered && UINodes.showMenu)) { UINodes.showMenu = true; UINodes.menuCategory = i; UINodes.popupX = UINodes.wx + UINodes.ui._x; @@ -956,7 +959,7 @@ class UINodes { UINodes.popupX += UINodes.ui._w / 2; } UIMenu.menuCategoryW = UINodes.ui._w; - UIMenu.menuCategoryH = Math.floor(Zui.MENUBAR_H(UINodes.ui)); + UIMenu.menuCategoryH = Math.floor(zui_MENUBAR_H(UINodes.ui)); } UINodes.ui._x += UINodes.ui._w + 3; UINodes.ui._y = 2 + startY; @@ -964,20 +967,20 @@ class UINodes { if (Config.raw.touch_ui) { let _w = UINodes.ui._w; - UINodes.ui._w = Math.floor(36 * Zui.SCALE(UINodes.ui)); - UINodes.ui._y = 4 * Zui.SCALE(UINodes.ui) + startY; + UINodes.ui._w = Math.floor(36 * zui_SCALE(UINodes.ui)); + UINodes.ui._y = 4 * zui_SCALE(UINodes.ui) + 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)); + UINodes.nodeSearch(Math.floor(UINodes.ui._window_x + UINodes.ui._x), Math.floor(UINodes.ui._window_y + UINodes.ui._y)); } UINodes.ui._w = _w; } else { - if (Zui.menuButton(tr("Search"))) { - UINodes.nodeSearch(Math.floor(UINodes.ui._windowX + UINodes.ui._x), Math.floor(UINodes.ui._windowY + UINodes.ui._y)); + if (zui_menu_button(tr("Search"))) { + UINodes.nodeSearch(Math.floor(UINodes.ui._window_x + UINodes.ui._x), Math.floor(UINodes.ui._window_y + UINodes.ui._y)); } } - if (UINodes.ui.isHovered) { - Zui.tooltip(tr("Search for nodes") + ` (${Config.keymap.node_search})`); + if (UINodes.ui.is_hovered) { + zui_tooltip(tr("Search for nodes") + ` (${Config.keymap.node_search})`); } UINodes.ui._x += UINodes.ui._w + 3; UINodes.ui._y = 2 + startY; @@ -985,12 +988,12 @@ class UINodes { UINodes.ui.t.BUTTON_COL = _BUTTON_COL; // Close node group - if (UINodes.groupStack.length > 0 && Zui.menuButton(tr("Close"))) { + if (UINodes.groupStack.length > 0 && zui_menu_button(tr("Close"))) { UINodes.groupStack.pop(); } } - Zui.end(!UINodes.showMenu); + zui_end(!UINodes.showMenu); g2_begin(g, false); @@ -1015,7 +1018,7 @@ class UINodes { let py = UINodes.popupY; let menuw = Math.floor(ew * 2.3); - Zui.beginRegion(UINodes.ui, g, Math.floor(UINodes.popupX), Math.floor(py), menuw); + zui_begin_region(UINodes.ui, 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; @@ -1039,19 +1042,19 @@ class UINodes { ///end } // Next column - if (UINodes.ui._y - UINodes.wy + Zui.ELEMENT_H(UINodes.ui) / 2 > UINodes.wh) { + if (UINodes.ui._y - UINodes.wy + zui_ELEMENT_H(UINodes.ui) / 2 > UINodes.wh) { UINodes.ui._x += menuw; UINodes.ui._y = py; } } if (isGroupCategory) { for (let g of Project.materialGroups) { - Zui.fill(0, 1, UINodes.ui._w / Zui.SCALE(UINodes.ui), UINodes.ui.t.BUTTON_H + 2, UINodes.ui.t.ACCENT_SELECT_COL); - Zui.fill(1, 1, UINodes.ui._w / Zui.SCALE(UINodes.ui) - 2, UINodes.ui.t.BUTTON_H + 1, UINodes.ui.t.SEPARATOR_COL); + zui_fill(0, 1, UINodes.ui._w / zui_SCALE(UINodes.ui), UINodes.ui.t.BUTTON_H + 2, UINodes.ui.t.ACCENT_SELECT_COL); + zui_fill(1, 1, UINodes.ui._w / zui_SCALE(UINodes.ui) - 2, UINodes.ui.t.BUTTON_H + 1, UINodes.ui.t.SEPARATOR_COL); UINodes.ui.enabled = UINodes.canPlaceGroup(g.canvas.name); UIMenu.menuFill(UINodes.ui); - Zui.row([5 / 6, 1 / 6]); - if (Zui.button(Config.buttonSpacing + g.canvas.name, Align.Left)) { + zui_row([5 / 6, 1 / 6]); + if (zui_button(Config.buttonSpacing + g.canvas.name, Align.Left)) { UINodes.pushUndo(); let canvas = UINodes.getCanvas(true); let nodes = UINodes.getNodes(); @@ -1063,7 +1066,7 @@ class UINodes { ///if (is_paint || is_sculpt) UINodes.ui.enabled = !Project.isMaterialGroupInUse(g); - if (Zui.button("x", Align.Center)) { + if (zui_button("x", Align.Center)) { History.deleteMaterialGroup(g); array_remove(Project.materialGroups, g); } @@ -1073,13 +1076,13 @@ class UINodes { } } - UINodes.hideMenu = UINodes.ui.comboSelectedHandle_ptr == null && !UINodes.showMenuFirst && (UINodes.ui.changed || UINodes.ui.inputReleased || UINodes.ui.inputReleasedR || UINodes.ui.isEscapeDown); + UINodes.hideMenu = UINodes.ui.combo_selected_handle_ptr == null && !UINodes.showMenuFirst && (UINodes.ui.changed || UINodes.ui.input_released || UINodes.ui.input_released_r || UINodes.ui.is_escape_down); UINodes.showMenuFirst = false; UINodes.ui.t.BUTTON_COL = _BUTTON_COL; UINodes.ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET; UINodes.ui.t.ELEMENT_H = _ELEMENT_H; - Zui.endRegion(); + zui_end_region(); } if (UINodes.hideMenu) { @@ -1122,7 +1125,7 @@ class UINodes { return true; } - static pushUndo = (lastCanvas: TNodeCanvas = null) => { + static pushUndo = (lastCanvas: zui_node_canvas_t = null) => { if (lastCanvas == null) lastCanvas = UINodes.getCanvas(true); let canvasGroup = UINodes.groupStack.length > 0 ? Project.materialGroups.indexOf(UINodes.groupStack[UINodes.groupStack.length - 1]) : null; @@ -1187,34 +1190,34 @@ class UINodes { ///end } - static makeNode = (n: TNode, nodes: NodesRaw, canvas: TNodeCanvas): TNode => { - let node: TNode = JSON.parse(JSON.stringify(n)); - node.id = Nodes.getNodeId(canvas.nodes); + static makeNode = (n: zui_node_t, nodes: zui_nodes_t, canvas: zui_node_canvas_t): zui_node_t => { + let node: zui_node_t = JSON.parse(JSON.stringify(n)); + node.id = zui_get_node_id(canvas.nodes); node.x = UINodes.getNodeX(); node.y = UINodes.getNodeY(); let count = 0; for (let soc of node.inputs) { - soc.id = Nodes.getSocketId(canvas.nodes) + count; + soc.id = zui_get_socket_id(canvas.nodes) + count; soc.node_id = node.id; count++; } for (let soc of node.outputs) { - soc.id = Nodes.getSocketId(canvas.nodes) + count; + soc.id = zui_get_socket_id(canvas.nodes) + count; soc.node_id = node.id; count++; } return node; } - static makeGroupNode = (groupCanvas: TNodeCanvas, nodes: NodesRaw, canvas: TNodeCanvas): TNode => { + static makeGroupNode = (groupCanvas: zui_node_canvas_t, nodes: zui_nodes_t, canvas: zui_node_canvas_t): zui_node_t => { let n = NodesMaterial.list[5][0]; - let node: TNode = JSON.parse(JSON.stringify(n)); + let node: zui_node_t = JSON.parse(JSON.stringify(n)); node.name = groupCanvas.name; - node.id = Nodes.getNodeId(canvas.nodes); + node.id = zui_get_node_id(canvas.nodes); node.x = UINodes.getNodeX(); node.y = UINodes.getNodeY(); - let groupInput: TNode = null; - let groupOutput: TNode = null; + let groupInput: zui_node_t = null; + let groupOutput: zui_node_t = null; for (let g of Project.materialGroups) { if (g.canvas.name == node.name) { for (let n of g.canvas.nodes) { @@ -1240,7 +1243,7 @@ class UINodes { let nodes = Context.raw.material.nodes; if (nodes.nodesSelectedId.length == 0) return; - let node = Nodes.getNode(Context.raw.material.canvas.nodes, nodes.nodesSelectedId[0]); + let node = zui_get_node(Context.raw.material.canvas.nodes, nodes.nodesSelectedId[0]); // if (node == null) return; Context.raw.nodePreviewName = node.name; @@ -1261,16 +1264,16 @@ class UINodes { } ///end - static hasGroup = (c: TNodeCanvas): bool => { + static hasGroup = (c: zui_node_canvas_t): bool => { for (let n of c.nodes) if (n.type == "GROUP") return true; return false; } - static traverseGroup = (mgroups: TNodeCanvas[], c: TNodeCanvas) => { + static traverseGroup = (mgroups: zui_node_canvas_t[], c: zui_node_canvas_t) => { for (let n of c.nodes) { if (n.type == "GROUP") { if (UINodes.getGroup(mgroups, n.name) == null) { - let canvases: TNodeCanvas[] = []; + let canvases: zui_node_canvas_t[] = []; for (let g of Project.materialGroups) canvases.push(g.canvas); let group = UINodes.getGroup(canvases, n.name); mgroups.push(JSON.parse(JSON.stringify(group))); @@ -1280,7 +1283,7 @@ class UINodes { } } - static getGroup = (canvases: TNodeCanvas[], name: string): TNodeCanvas => { + static getGroup = (canvases: zui_node_canvas_t[], name: string): zui_node_canvas_t => { for (let c of canvases) if (c.name == name) return c; return null; } diff --git a/base/Sources/UIStatus.ts b/base/Sources/UIStatus.ts index e892859ae..250cdff51 100644 --- a/base/Sources/UIStatus.ts +++ b/base/Sources/UIStatus.ts @@ -20,13 +20,13 @@ class UIStatus { let statush = Config.raw.layout[LayoutSize.LayoutStatusH]; - if (Zui.window(ui, UIBase.hwnds[TabArea.TabStatus], App.x(), sys_height() - statush, UIStatus.width, statush)) { + if (zui_window(ui, UIBase.hwnds[TabArea.TabStatus], app_x(), sys_height() - statush, UIStatus.width, statush)) { ui._y += 2; // Border ui.g.color = ui.t.SEPARATOR_COL; - g2_fill_rect(0, 0, 1, ui._windowH); - g2_fill_rect(ui._windowW - 1, 0, 1, ui._windowH); + g2_fill_rect(0, 0, 1, ui._window_h); + g2_fill_rect(ui._window_w - 1, 0, 1, ui._window_h); // Draw tabs for (let draw of UIBase.hwndTabs[TabArea.TabStatus]) draw(UIBase.htabs[TabArea.TabStatus]); @@ -39,12 +39,12 @@ class UIStatus { } } - static drawVersionTab = (htab: HandleRaw) => { + static drawVersionTab = (htab: zui_handle_t) => { // Version label if (!Config.raw.touch_ui) { let ui = UIBase.ui; ui.enabled = false; - Zui.tab(UIBase.htabs[TabArea.TabStatus], manifest_version); + zui_tab(UIBase.htabs[TabArea.TabStatus], manifest_version); ui.enabled = true; } } diff --git a/base/Sources/UIToolbar.ts b/base/Sources/UIToolbar.ts index c8f953e09..6dec7afac 100644 --- a/base/Sources/UIToolbar.ts +++ b/base/Sources/UIToolbar.ts @@ -5,7 +5,7 @@ class UIToolbar { static defaultToolbarW = 36; - static toolbarHandle = Handle.create(); + static toolbarHandle = zui_handle_create(); static toolbarw = UIToolbar.defaultToolbarW; static lastTool = 0; @@ -38,14 +38,14 @@ class UIToolbar { else { UIToolbar.toolbarw = UIToolbar.defaultToolbarW; } - UIToolbar.toolbarw = Math.floor(UIToolbar.toolbarw * Zui.SCALE(ui)); + UIToolbar.toolbarw = Math.floor(UIToolbar.toolbarw * zui_SCALE(ui)); - if (Zui.window(ui, UIToolbar.toolbarHandle, 0, UIHeader.headerh, UIToolbar.toolbarw, sys_height() - UIHeader.headerh)) { - ui._y -= 4 * Zui.SCALE(ui); + if (zui_window(ui, UIToolbar.toolbarHandle, 0, UIHeader.headerh, UIToolbar.toolbarw, sys_height() - UIHeader.headerh)) { + ui._y -= 4 * zui_SCALE(ui); - ui.imageScrollAlign = false; + ui.image_scroll_align = false; let img = Res.get("icons.k"); - let imgw = Zui.SCALE(ui) > 1 ? 100 : 50; + let imgw = zui_SCALE(ui) > 1 ? 100 : 50; let col = ui.t.WINDOW_BG_COL; if (col < 0) col += 4294967296; @@ -55,7 +55,7 @@ class UIToolbar { // Properties icon if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) { let rect = Res.tile50(img, 7, 1); - if (Zui.image(img, light ? 0xff666666 : ui.t.BUTTON_COL, null, rect.x, rect.y, rect.w, rect.h) == State.Released) { + if (zui_image(img, light ? 0xff666666 : ui.t.BUTTON_COL, null, rect.x, rect.y, rect.w, rect.h) == State.Released) { Config.raw.layout[LayoutSize.LayoutHeader] = 0; } } @@ -64,16 +64,16 @@ class UIToolbar { let _ELEMENT_H = ui.t.ELEMENT_H; let _BUTTON_H = ui.t.BUTTON_H; let _BUTTON_COL = ui.t.BUTTON_COL; - let _fontOffsetY = ui.fontOffsetY; + let _fontOffsetY = ui.font_offset_y; ui.t.ELEMENT_H = Math.floor(ui.t.ELEMENT_H * 1.5); ui.t.BUTTON_H = ui.t.ELEMENT_H; ui.t.BUTTON_COL = ui.t.WINDOW_BG_COL; - let fontHeight = font_height(ui.font, ui.fontSize); - ui.fontOffsetY = (Zui.ELEMENT_H(ui) - fontHeight) / 2; + let fontHeight = font_height(ui.font, ui.font_size); + ui.font_offset_y = (zui_ELEMENT_H(ui) - fontHeight) / 2; let _w = ui._w; ui._w = UIToolbar.toolbarw; - if (Zui.button(">>")) { + if (zui_button(">>")) { UIToolbar.toolPropertiesMenu(); } @@ -81,10 +81,10 @@ class UIToolbar { ui.t.ELEMENT_H = _ELEMENT_H; ui.t.BUTTON_H = _BUTTON_H; ui.t.BUTTON_COL = _BUTTON_COL; - ui.fontOffsetY = _fontOffsetY; + ui.font_offset_y = _fontOffsetY; } - if (ui.isHovered) Zui.tooltip(tr("Toggle header")); - ui._y -= 4 * Zui.SCALE(ui); + if (ui.is_hovered) zui_tooltip(tr("Toggle header")); + ui._y -= 4 * zui_SCALE(ui); let keys = [ "(" + Config.keymap.tool_brush + ") - " + tr("Hold {action_paint} to paint\nHold {key} and press {action_paint} to paint a straight line (ruler mode)", new Map([["key", Config.keymap.brush_ruler], ["action_paint", Config.keymap.action_paint]])), @@ -111,7 +111,7 @@ class UIToolbar { let rect = Res.tile50(img, tileX, tileY); let _y = ui._y; - let imageState = Zui.image(img, iconAccent, null, rect.x, rect.y, rect.w, rect.h); + let imageState = zui_image(img, iconAccent, null, rect.x, rect.y, rect.w, rect.h); if (imageState == State.Started) { Context.selectTool(i); } @@ -124,11 +124,11 @@ class UIToolbar { ///if is_paint if (i == WorkspaceTool.ToolColorId && Context.raw.colorIdPicked) { - g2_draw_scaled_sub_image(render_path_render_targets.get("texpaint_colorid").image, 0, 0, 1, 1, 0, _y + 1.5 * Zui.SCALE(ui), 5 * Zui.SCALE(ui), 34 * Zui.SCALE(ui)); + g2_draw_scaled_sub_image(render_path_render_targets.get("texpaint_colorid").image, 0, 0, 1, 1, 0, _y + 1.5 * zui_SCALE(ui), 5 * zui_SCALE(ui), 34 * zui_SCALE(ui)); } ///end - if (ui.isHovered) Zui.tooltip(tr(UIToolbar.toolNames[i]) + " " + keys[i]); + if (ui.is_hovered) zui_tooltip(tr(UIToolbar.toolNames[i]) + " " + keys[i]); ui._x -= 2; ui._y += 2; } @@ -153,14 +153,14 @@ class UIToolbar { drawTool(WorkspaceTool.ToolGizmo); ///end - ui.imageScrollAlign = true; + ui.image_scroll_align = true; } if (Config.raw.touch_ui) { // Hide scrollbar let _SCROLL_W = ui.t.SCROLL_W; ui.t.SCROLL_W = 0; - Zui.endWindow(); + zui_end_window(); ui.t.SCROLL_W = _SCROLL_W; } } @@ -170,7 +170,7 @@ class UIToolbar { let _x = ui._x; let _y = ui._y; let _w = ui._w; - UIMenu.draw((ui: ZuiRaw) => { + UIMenu.draw((ui: zui_t) => { let startY = ui._y; ui.changed = false; @@ -180,14 +180,14 @@ class UIToolbar { UIMenu.keepOpen = true; } - if (Zui.button(tr("Pin to Header"), Align.Left)) { + if (zui_button(tr("Pin to Header"), Align.Left)) { Config.raw.layout[LayoutSize.LayoutHeader] = 1; } let h = ui._y - startY; - UIMenu.menuElements = Math.floor(h / Zui.ELEMENT_H(ui)); + UIMenu.menuElements = Math.floor(h / zui_ELEMENT_H(ui)); UIMenu.menuX = Math.floor(_x + _w + 2); - UIMenu.menuY = Math.floor(_y - 6 * Zui.SCALE(ui)); + UIMenu.menuY = Math.floor(_y - 6 * zui_SCALE(ui)); UIMenu.fitToScreen(); }, 0); @@ -201,7 +201,7 @@ class UIToolbar { let ui = UIBase.ui; let size = UIToolbar.toolbarw - 4; ui.g.color = ui.t.HIGHLIGHT_COL; - Zui.drawRect(ui.g, true, ui._x + -1, ui._y + 2, size + 2, size + 2); + zui_draw_rect(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 d7e5bedc7..20b9a2ea9 100644 --- a/base/Sources/UIView2D.ts +++ b/base/Sources/UIView2D.ts @@ -21,8 +21,8 @@ class UIView2D { static wy: i32; static ww: i32; static wh: i32; - static ui: ZuiRaw; - static hwnd = Handle.create(); + static ui: zui_t; + static hwnd = zui_handle_create(); static panX = 0.0; static panY = 0.0; static panScale = 1.0; @@ -47,8 +47,8 @@ class UIView2D { ///end let scale = Config.raw.window_scale; - UIView2D.ui = Zui.create({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale }); - UIView2D.ui.scrollEnabled = false; + UIView2D.ui = zui_create({ theme: Base.theme, font: Base.font, color_wheel: Base.colorWheel, black_white_gradient: Base.colorWheelGradient, scaleFactor: scale }); + UIView2D.ui.scroll_enabled = false; } static render = (g: g2_t) => { @@ -56,9 +56,9 @@ class UIView2D { UIView2D.ww = Config.raw.layout[LayoutSize.LayoutNodesW]; ///if (is_paint || is_sculpt) - UIView2D.wx = Math.floor(App.w()) + UIToolbar.toolbarw; + UIView2D.wx = Math.floor(app_w()) + UIToolbar.toolbarw; ///else - UIView2D.wx = Math.floor(App.w()); + UIView2D.wx = Math.floor(app_w()); ///end UIView2D.wy = 0; @@ -90,7 +90,7 @@ class UIView2D { if (Context.raw.font.image == null) UtilRender.makeFontPreview(); ///end - Zui.begin(UIView2D.ui, g); + zui_begin(UIView2D.ui, g); let headerh = Config.raw.layout[LayoutSize.LayoutHeader] == 1 ? UIHeader.headerh * 2 : UIHeader.headerh; let apph = sys_height() - Config.raw.layout[LayoutSize.LayoutStatusH] + headerh; @@ -101,9 +101,9 @@ class UIView2D { if (Config.raw.touch_ui) UIView2D.wh += UIHeader.headerh; } - if (Zui.window(UIView2D.ui, UIView2D.hwnd, UIView2D.wx, UIView2D.wy, UIView2D.ww, UIView2D.wh)) { + if (zui_window(UIView2D.ui, UIView2D.hwnd, UIView2D.wx, UIView2D.wy, UIView2D.ww, UIView2D.wh)) { - Zui.tab(Zui.handle("uiview2d_0"), tr("2D View")); + zui_tab(zui_handle("uiview2d_0"), tr("2D View")); // Grid UIView2D.ui.g.color = 0xffffffff; @@ -133,7 +133,7 @@ class UIView2D { let nodes = UINodes.getNodes(); if (nodes.nodesSelectedId.length > 0) { - let sel = Nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]); + let sel = zui_get_node(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]); let brushNode = ParserLogic.getLogicNode(sel); if (brushNode != null) { tex = brushNode.getCachedImage(); @@ -227,9 +227,9 @@ class UIView2D { } // Texture and node preview color picking - 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; + if ((Context.in2dView(View2DType.View2DAsset) || Context.in2dView(View2DType.View2DNode)) && Context.raw.tool == WorkspaceTool.ToolPicker && UIView2D.ui.input_down) { + let x = UIView2D.ui.input_x - tx - UIView2D.wx; + let y = UIView2D.ui.input_y - ty - UIView2D.wy; Base.notifyOnNextFrame(() => { let texpaint_picker = render_path_render_targets.get("texpaint_picker").image; let g2 = texpaint_picker.g2; @@ -264,18 +264,18 @@ class UIView2D { ///end // Menu - let ew = Math.floor(Zui.ELEMENT_W(UIView2D.ui)); + let ew = Math.floor(zui_ELEMENT_W(UIView2D.ui)); UIView2D.ui.g.color = UIView2D.ui.t.SEPARATOR_COL; - g2_fill_rect(0, Zui.ELEMENT_H(UIView2D.ui), UIView2D.ww, Zui.ELEMENT_H(UIView2D.ui) + Zui.ELEMENT_OFFSET(UIView2D.ui) * 2); + g2_fill_rect(0, zui_ELEMENT_H(UIView2D.ui), UIView2D.ww, zui_ELEMENT_H(UIView2D.ui) + zui_ELEMENT_OFFSET(UIView2D.ui) * 2); UIView2D.ui.g.color = 0xffffffff; - let startY = Zui.ELEMENT_H(UIView2D.ui) + Zui.ELEMENT_OFFSET(UIView2D.ui); + let startY = zui_ELEMENT_H(UIView2D.ui) + zui_ELEMENT_OFFSET(UIView2D.ui); UIView2D.ui._x = 2; UIView2D.ui._y = 2 + startY; UIView2D.ui._w = ew; // Editable layer name - let h = Zui.handle("uiview2d_1"); + let h = zui_handle("uiview2d_1"); ///if (is_paint || is_sculpt) let text = UIView2D.type == View2DType.View2DNode ? Context.raw.nodePreviewName : h.text; @@ -283,7 +283,7 @@ class UIView2D { let text = h.text; ///end - UIView2D.ui._w = Math.floor(Math.min(font_width(UIView2D.ui.font, UIView2D.ui.fontSize, text) + 15 * Zui.SCALE(UIView2D.ui), 100 * Zui.SCALE(UIView2D.ui))); + UIView2D.ui._w = Math.floor(Math.min(font_width(UIView2D.ui.font, UIView2D.ui.font_size, text) + 15 * zui_SCALE(UIView2D.ui), 100 * zui_SCALE(UIView2D.ui))); if (UIView2D.type == View2DType.View2DAsset) { let asset = Context.raw.texture; @@ -291,20 +291,20 @@ class UIView2D { let assetNames = Project.assetNames; let i = assetNames.indexOf(asset.name); h.text = asset.name; - asset.name = Zui.textInput(h, ""); + asset.name = zui_text_input(h, ""); assetNames[i] = asset.name; } } else if (UIView2D.type == View2DType.View2DNode) { ///if (is_paint || is_sculpt) - Zui.text(Context.raw.nodePreviewName); + zui_text(Context.raw.nodePreviewName); ///else let nodes = UINodes.getNodes(); if (nodes.nodesSelectedId.length > 0) { - Zui.text(Nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]).name); + zui_text(zui_get_node(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]).name); } ///end @@ -312,12 +312,12 @@ class UIView2D { ///if (is_paint || is_sculpt) else if (UIView2D.type == View2DType.View2DLayer) { h.text = l.name; - l.name = Zui.textInput(h, ""); - UIView2D.textInputHover = UIView2D.ui.isHovered; + l.name = zui_text_input(h, ""); + UIView2D.textInputHover = UIView2D.ui.is_hovered; } else if (UIView2D.type == View2DType.View2DFont) { h.text = Context.raw.font.name; - Context.raw.font.name = Zui.textInput(h, ""); + Context.raw.font.name = zui_text_input(h, ""); } ///end @@ -328,7 +328,7 @@ class UIView2D { ///if (is_paint || is_sculpt) if (UIView2D.type == View2DType.View2DLayer) { - UIView2D.layerMode = Zui.combo(Zui.handle("uiview2d_2", { position: UIView2D.layerMode }), [ + UIView2D.layerMode = zui_combo(zui_handle("uiview2d_2", { position: UIView2D.layerMode }), [ tr("Visible"), tr("Selected"), ], tr("Layers")); @@ -336,7 +336,7 @@ class UIView2D { UIView2D.ui._y = 2 + startY; if (!SlotLayer.isMask(Context.raw.layer)) { - UIView2D.texType = Zui.combo(Zui.handle("uiview2d_3", { position: UIView2D.texType }), [ + UIView2D.texType = zui_combo(zui_handle("uiview2d_3", { position: UIView2D.texType }), [ tr("Base Color"), tr("Normal Map"), tr("Occlusion"), @@ -350,36 +350,36 @@ class UIView2D { } UIView2D.ui._w = Math.floor(ew * 0.7 + 3); - UIView2D.uvmapShow = Zui.check(Zui.handle("uiview2d_4", { selected: UIView2D.uvmapShow }), tr("UV Map")); + UIView2D.uvmapShow = zui_check(zui_handle("uiview2d_4", { selected: UIView2D.uvmapShow }), tr("UV Map")); UIView2D.ui._x += ew * 0.7 + 3; UIView2D.ui._y = 2 + startY; } ///end - UIView2D.tiledShow = Zui.check(Zui.handle("uiview2d_5", { selected: UIView2D.tiledShow }), tr("Tiled")); + UIView2D.tiledShow = zui_check(zui_handle("uiview2d_5", { selected: UIView2D.tiledShow }), tr("Tiled")); UIView2D.ui._x += ew * 0.7 + 3; UIView2D.ui._y = 2 + startY; if (UIView2D.type == View2DType.View2DAsset && tex != null) { // Texture resolution - Zui.text(tex.width + "x" + tex.height); + zui_text(tex.width + "x" + tex.height); } // Picked position ///if (is_paint || is_sculpt) if (Context.raw.tool == WorkspaceTool.ToolPicker && (UIView2D.type == View2DType.View2DLayer || UIView2D.type == View2DType.View2DAsset)) { let cursorImg = Res.get("cursor.k"); - let hsize = 16 * Zui.SCALE(UIView2D.ui); + let hsize = 16 * zui_SCALE(UIView2D.ui); let size = hsize * 2; g2_draw_scaled_image(cursorImg, tx + tw * Context.raw.uvxPicked - hsize, ty + th * Context.raw.uvyPicked - hsize, size, size); } ///end } - Zui.end(); + zui_end(); g2_begin(g, false); } static update = () => { - let headerh = Zui.ELEMENT_H(UIView2D.ui) * 1.4; + let headerh = zui_ELEMENT_H(UIView2D.ui) * 1.4; ///if (is_paint || is_sculpt) Context.raw.paint2d = false; @@ -409,10 +409,10 @@ class UIView2D { UIView2D.panX = _panX * UIView2D.panScale; UIView2D.panY = _panY * UIView2D.panScale; - if (Zui.touchScroll) { + if (zui_touch_scroll()) { // Zoom to finger location - 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; + UIView2D.panX -= (UIView2D.ui.input_x - UIView2D.ui._window_x - UIView2D.ui._window_w / 2) * control.zoom; + UIView2D.panY -= (UIView2D.ui.input_y - UIView2D.ui._window_y - UIView2D.ui._window_h / 2) * control.zoom; } } @@ -432,7 +432,7 @@ class UIView2D { } ///end - if (UIView2D.ui.isTyping) return; + if (UIView2D.ui.is_typing) return; if (keyboard_started("left")) UIView2D.panX -= 5; else if (keyboard_started("right")) UIView2D.panX += 5; @@ -443,7 +443,7 @@ class UIView2D { let border = 32; let tw = UIView2D.ww * 0.95 * UIView2D.panScale; let tx = UIView2D.ww / 2 - tw / 2 + UIView2D.panX; - let hh = App.h(); + let hh = app_h(); let ty = hh / 2 - tw / 2 + UIView2D.panY; if (tx + border > UIView2D.ww) UIView2D.panX = UIView2D.ww / 2 + tw / 2 - border; diff --git a/base/Sources/UniformsExt.ts b/base/Sources/UniformsExt.ts index 7da3efebf..27a1efaeb 100644 --- a/base/Sources/UniformsExt.ts +++ b/base/Sources/UniformsExt.ts @@ -14,11 +14,11 @@ class UniformsExt { uniforms_tex_links = [UniformsExt.linkTex]; } - static linkInt = (object: TBaseObject, mat: material_data_t, link: string): Null => { + static linkInt = (object: object_t, mat: material_data_t, link: string): Null => { return null; } - static linkFloat = (object: TBaseObject, mat: material_data_t, link: string): Null => { + static linkFloat = (object: object_t, mat: material_data_t, link: string): Null => { switch (link) { case "_brushRadius": { ///if (is_paint || is_sculpt) @@ -148,7 +148,7 @@ class UniformsExt { return null; } - static linkVec2 = (object: TBaseObject, mat: material_data_t, link: string): vec4_t => { + static linkVec2 = (object: object_t, mat: material_data_t, link: string): vec4_t => { switch (link) { case "_gbufferSize": { vec4_set(UniformsExt.vec, 0, 0, 0); @@ -180,7 +180,7 @@ class UniformsExt { return null; } - static linkVec3 = (object: TBaseObject, mat: material_data_t, link: string): vec4_t => { + static linkVec3 = (object: object_t, mat: material_data_t, link: string): vec4_t => { let v: vec4_t = null; switch (link) { ///if (is_paint || is_sculpt) @@ -261,7 +261,7 @@ class UniformsExt { } ///end - static linkVec4 = (object: TBaseObject, mat: material_data_t, link: string): vec4_t => { + static linkVec4 = (object: object_t, mat: material_data_t, link: string): vec4_t => { switch (link) { case "_inputBrush": { let down = mouse_down() || pen_down(); @@ -316,7 +316,7 @@ class UniformsExt { return null; } - static linkMat4 = (object: TBaseObject, mat: material_data_t, link: string): mat4_t => { + static linkMat4 = (object: object_t, mat: material_data_t, link: string): mat4_t => { switch (link) { ///if (is_paint || is_sculpt) case "_decalLayerMatrix": { // Decal layer @@ -332,7 +332,7 @@ class UniformsExt { return null; } - static linkTex = (object: TBaseObject, mat: material_data_t, link: string): image_t => { + static linkTex = (object: object_t, mat: material_data_t, link: string): image_t => { switch (link) { case "_texpaint_undo": { ///if (is_paint || is_sculpt) @@ -366,12 +366,12 @@ class UniformsExt { } case "_ltcMat": { - if (ConstData.ltcMatTex == null) ConstData.initLTC(); - return ConstData.ltcMatTex; + if (const_data_ltc_mat_tex == null) const_data_init_ltc(); + return const_data_ltc_mat_tex; } case "_ltcMag": { - if (ConstData.ltcMagTex == null) ConstData.initLTC(); - return ConstData.ltcMagTex; + if (const_data_ltc_mag_tex == null) const_data_init_ltc(); + return const_data_ltc_mag_tex; } ///if (is_paint || is_sculpt) @@ -399,7 +399,7 @@ class UniformsExt { let _init = () => { UtilUV.cacheUVMap(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } return UtilUV.uvmap; } @@ -408,7 +408,7 @@ class UniformsExt { let _init = () => { UtilUV.cacheTriangleMap(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); } return UtilUV.trianglemap; } @@ -416,7 +416,7 @@ class UniformsExt { let _init = () => { UtilUV.cacheUVIslandMap(); } - App.notifyOnInit(_init); + app_notify_on_init(_init); return UtilUV.uvislandmapCached ? UtilUV.uvislandmap :render_path_render_targets.get("empty_black").image; } case "_texdilatemap": { diff --git a/base/Sources/UtilMesh.ts b/base/Sources/UtilMesh.ts index de055aa30..caf0be5a6 100644 --- a/base/Sources/UtilMesh.ts +++ b/base/Sources/UtilMesh.ts @@ -3,7 +3,7 @@ class UtilMesh { static unwrappers: Mapvoid)> = new Map(); - static mergeMesh = (paintObjects: TMeshObject[] = null) => { + static mergeMesh = (paintObjects: mesh_object_t[] = null) => { if (paintObjects == null) paintObjects = Project.paintObjects; if (paintObjects.length == 0) return; Context.raw.mergedObjectIsAtlas = paintObjects.length < Project.paintObjects.length; @@ -76,11 +76,11 @@ class UtilMesh { if (va3 != null) raw.vertex_arrays.push({ values: va3, attrib: "col", data: "short4norm", padding: 1 }); UtilMesh.removeMergedMesh(); - MeshData.create(raw, (md: mesh_data_t) => { - Context.raw.mergedObject = MeshObject.create(md, Context.raw.paintObject.materials); + mesh_data_create(raw, (md: mesh_data_t) => { + Context.raw.mergedObject = mesh_object_create(md, Context.raw.paintObject.materials); Context.raw.mergedObject.base.name = Context.raw.paintObject.base.name + "_merged"; Context.raw.mergedObject.force_context = "paint"; - BaseObject.setParent(Context.raw.mergedObject.base, Context.mainObject().base); + object_set_parent(Context.raw.mergedObject.base, Context.mainObject().base); }); ///if (krom_direct3d12 || krom_vulkan || krom_metal) @@ -90,8 +90,8 @@ class UtilMesh { static removeMergedMesh = () => { if (Context.raw.mergedObject != null) { - MeshData.delete(Context.raw.mergedObject.data); - MeshObject.remove(Context.raw.mergedObject); + mesh_data_delete(Context.raw.mergedObject.data); + mesh_object_remove(Context.raw.mergedObject); Context.raw.mergedObject = null; } } diff --git a/base/Sources/UtilParticle.ts b/base/Sources/UtilParticle.ts index a4ecd3c21..215a9b04f 100644 --- a/base/Sources/UtilParticle.ts +++ b/base/Sources/UtilParticle.ts @@ -53,7 +53,7 @@ class UtilParticle { } } - Data.getMaterial("Scene", "MaterialParticle", (md: material_data_t) => { + data_get_material("Scene", "MaterialParticle", (md: material_data_t) => { Context.raw.particleMaterial = md; for (let obj of _scene_raw.objects) { @@ -68,13 +68,13 @@ class UtilParticle { } } - scene_spawn_object(".Sphere", null, (o: TBaseObject) => { - let mo: TMeshObject = o.ext; + scene_spawn_object(".Sphere", null, (o: object_t) => { + let mo: mesh_object_t = o.ext; mo.base.name = ".ParticleEmitter"; mo.base.raw = JSON.parse(JSON.stringify(mo.base.raw)); mo.base.raw.particle_refs = particle_refs; ///if arm_particles - MeshObject.setupParticleSystem(mo, "Scene", particle_refs[0]); + mesh_object_setup_particle_system(mo, "Scene", particle_refs[0]); ///end }); }); diff --git a/base/Sources/UtilRender.ts b/base/Sources/UtilRender.ts index 7ec4e4edd..e67e1b21d 100644 --- a/base/Sources/UtilRender.ts +++ b/base/Sources/UtilRender.ts @@ -12,7 +12,7 @@ class UtilRender { static makeMaterialPreview = () => { Context.raw.materialPreview = true; - let sphere: TMeshObject = scene_get_child(".Sphere").ext; + let sphere: mesh_object_t = scene_get_child(".Sphere").ext; sphere.base.visible = true; let meshes = scene_meshes; scene_meshes = [sphere]; @@ -45,8 +45,8 @@ class UtilRender { // No resize render_path_last_w = UtilRender.materialPreviewSize; render_path_last_h = UtilRender.materialPreviewSize; - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); MakeMaterial.parseMeshPreviewMaterial(); let _commands = render_path_commands; @@ -55,8 +55,8 @@ class UtilRender { render_path_commands = _commands; Context.raw.materialPreview = false; - render_path_last_w = App.w(); - render_path_last_h = App.h(); + render_path_last_w = app_w(); + render_path_last_h = app_h(); // Restore sphere.base.visible = false; @@ -66,8 +66,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); Viewport.updateCameraType(Context.raw.cameraType); scene_camera.data.fov = savedFov; - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); light.data.strength = _lightStrength; probe.strength = _probeStrength; Context.raw.envmapAngle = _envmapAngle; @@ -87,7 +87,7 @@ class UtilRender { } Context.raw.decalPreview = true; - let plane: TMeshObject = scene_get_child(".Plane").ext; + let plane: mesh_object_t = scene_get_child(".Plane").ext; vec4_set(plane.base.transform.scale, 1, 1, 1); quat_from_euler(plane.base.transform.rot, -Math.PI / 2, 0, 0); transform_build_matrix(plane.base.transform); @@ -111,8 +111,8 @@ class UtilRender { // No resize render_path_last_w = UtilRender.decalPreviewSize; render_path_last_h = UtilRender.decalPreviewSize; - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); MakeMaterial.parseMeshPreviewMaterial(); let _commands = render_path_commands; @@ -121,8 +121,8 @@ class UtilRender { render_path_commands = _commands; Context.raw.decalPreview = false; - render_path_last_w = App.w(); - render_path_last_h = App.h(); + render_path_last_w = app_w(); + render_path_last_h = app_h(); // Restore plane.base.visible = false; @@ -132,8 +132,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); light = scene_lights[0]; light.base.visible = true; scene_world._envmap = Context.raw.showEnvmap ? Context.raw.savedEnvmap : Context.raw.emptyEnvmap; @@ -261,11 +261,11 @@ class UtilRender { mat4_translate(m, 0, 0, 0.5); transform_set_matrix(cam.base.transform, m); cam.data.fov = 0.92; - CameraObject.buildProjection(cam); - CameraObject.buildMatrix(cam); - mat4_get_inv(m, scene_camera.VP); + camera_object_build_projection(cam); + camera_object_build_matrix(cam); + mat4_get_inv(m, scene_camera.vp); - let planeo: TMeshObject = scene_get_child(".Plane").ext; + let planeo: mesh_object_t = scene_get_child(".Plane").ext; planeo.base.visible = true; Context.raw.paintObject = planeo; @@ -321,7 +321,7 @@ class UtilRender { let _init = () => { MakeMaterial.parsePaintMaterial(false); } - App.notifyOnInit(_init); + app_notify_on_init(_init); // Restore paint mesh Context.raw.materialPreview = false; @@ -336,8 +336,8 @@ class UtilRender { transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera); scene_camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); - CameraObject.buildProjection(scene_camera); - CameraObject.buildMatrix(scene_camera); + camera_object_build_projection(scene_camera); + camera_object_build_matrix(scene_camera); // Scale layer down to to image preview if (Base.pipeMerge == null) Base.makePipe(); @@ -362,7 +362,7 @@ class UtilRender { if (current != null) g2_begin(current, false); } - static makeNodePreview = (canvas: TNodeCanvas, node: TNode, image: image_t, group: TNodeCanvas = null, parents: TNode[] = null) => { + static makeNodePreview = (canvas: zui_node_canvas_t, node: zui_node_t, image: image_t, group: zui_node_canvas_t = null, parents: zui_node_t[] = null) => { let res = MakeMaterial.parseNodePreviewMaterial(node, group, parents); if (res == null || res.scon == null) return; diff --git a/base/Sources/UtilUV.ts b/base/Sources/UtilUV.ts index 6b6c626cf..a7ab31bf0 100644 --- a/base/Sources/UtilUV.ts +++ b/base/Sources/UtilUV.ts @@ -131,7 +131,7 @@ class UtilUV { g4_clear(0x00000000); g4_set_pipeline(UtilUV.pipeDilate); ///if (krom_metal || krom_vulkan) - g4_set_vertex_buffer(MeshData.get(geom, [{name: "tex", data: "short2norm"}])); + g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}])); ///else g4_set_vertex_buffer(geom._vertex_buffer); ///end diff --git a/base/Sources/Viewport.ts b/base/Sources/Viewport.ts index df23bfec4..14bafbc90 100644 --- a/base/Sources/Viewport.ts +++ b/base/Sources/Viewport.ts @@ -4,7 +4,7 @@ class Viewport { static scaleToBounds = () => { let po = Context.raw.mergedObject == null ? Context.mainObject() : Context.raw.mergedObject; let md = po.data; - let aabb = MeshData.calculateAABB(md); + let aabb = mesh_data_calculate_aabb(md); let r = Math.sqrt(aabb.x * aabb.x + aabb.y * aabb.y + aabb.z * aabb.z); po = Context.mainObject(); po.base.transform.dim.x = aabb.x; @@ -28,7 +28,7 @@ class Viewport { if (Context.raw.fovHandle != null) Context.raw.fovHandle.value = cam.data.fov = Base.defaultFov; Context.raw.camHandle.position = 0; cam.data.ortho = null; - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); Context.raw.ddirty = 2; Camera.reset(); transform_reset(Context.mainObject().base.transform); @@ -45,7 +45,7 @@ class Viewport { vec4_set(cam.base.transform.loc, x * dist, y * dist, z * dist); quat_from_euler(cam.base.transform.rot, rx, ry, rz); transform_build_matrix(cam.base.transform); - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); Context.raw.ddirty = 2; Camera.reset(Context.raw.viewIndexLast); } @@ -53,22 +53,22 @@ class Viewport { static orbit = (x: f32, y: f32) => { let cam = scene_camera; let dist = Camera.distance(); - transform_move(cam.base.transform, CameraObject.lookWorld(cam), dist); + transform_move(cam.base.transform, camera_object_look_world(cam), dist); transform_rotate(cam.base.transform, vec4_create(0, 0, 1), x); - transform_rotate(cam.base.transform, CameraObject.rightWorld(cam), y); - transform_move(cam.base.transform, CameraObject.lookWorld(cam), -dist); + transform_rotate(cam.base.transform, camera_object_right_world(cam), y); + transform_move(cam.base.transform, camera_object_look_world(cam), -dist); Context.raw.ddirty = 2; } static orbitOpposite = () => { let cam = scene_camera; - let z = Math.abs(CameraObject.look(cam).z) - 1.0; + let z = Math.abs(camera_object_look(cam).z) - 1.0; (z < 0.0001 && z > -0.0001) ? Viewport.orbit(0, Math.PI) : Viewport.orbit(Math.PI, 0); } static zoom = (f: f32) => { let cam = scene_camera; - transform_move(cam.base.transform, CameraObject.look(cam), f); + transform_move(cam.base.transform, camera_object_look(cam), f); Context.raw.ddirty = 2; } @@ -84,12 +84,12 @@ class Viewport { let f = cam.data.fov * vec4_len(mat4_get_loc(cam.base.transform.world)) / 2.5; f32a[0] = -2 * f; f32a[1] = 2 * f; - f32a[2] = -2 * f * (App.h() / App.w()); - f32a[3] = 2 * f * (App.h() / App.w()); + f32a[2] = -2 * f * (app_h() / app_w()); + f32a[3] = 2 * f * (app_h() / app_w()); cam.data.ortho = f32a; light.base.visible = false; } - CameraObject.buildProjection(cam); + camera_object_build_projection(cam); Context.raw.ddirty = 2; } } diff --git a/base/Sources/main.ts b/base/Sources/main.ts index 002b3bd95..54d231d92 100644 --- a/base/Sources/main.ts +++ b/base/Sources/main.ts @@ -30,18 +30,18 @@ function kickstart() { } function main_start() { - App.onResize = Base.onResize; - App.w = Base.w; - App.h = Base.h; - App.x = Base.x; - App.y = Base.y; + app_on_resize = Base.onResize; + app_w = Base.w; + app_h = Base.h; + app_x = Base.x; + app_y = Base.y; Config.init(); sys_start(Config.getOptions(), function() { if (Config.raw.layout == null) Base.initLayout(); Krom.setApplicationName(manifest_title); - App.init(function() { - scene_set_active("Scene", function(o: TBaseObject) { + app_init(function() { + scene_set_active("Scene", function(o: object_t) { UniformsExt.init(); RenderPathBase.init(); diff --git a/base/Sources/nodes/FloatNode.ts b/base/Sources/nodes/FloatNode.ts index 6860fa2a7..b42c3f506 100644 --- a/base/Sources/nodes/FloatNode.ts +++ b/base/Sources/nodes/FloatNode.ts @@ -32,7 +32,7 @@ class FloatNode extends LogicNode { else this.value = value; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Value"), type: "FloatNode", diff --git a/base/Sources/nodes/MathNode.ts b/base/Sources/nodes/MathNode.ts index 1caa5b82e..9068567c9 100644 --- a/base/Sources/nodes/MathNode.ts +++ b/base/Sources/nodes/MathNode.ts @@ -127,7 +127,7 @@ class MathNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Math"), type: "MathNode", diff --git a/base/Sources/nodes/RandomNode.ts b/base/Sources/nodes/RandomNode.ts index 021f54cfc..d4bf9f5b7 100644 --- a/base/Sources/nodes/RandomNode.ts +++ b/base/Sources/nodes/RandomNode.ts @@ -51,7 +51,7 @@ class RandomNode extends LogicNode { return RandomNode.getInt() / 0x7fffffff; } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Random"), type: "RandomNode", diff --git a/base/Sources/nodes/SeparateVectorNode.ts b/base/Sources/nodes/SeparateVectorNode.ts index d4510c9b5..524323d2b 100644 --- a/base/Sources/nodes/SeparateVectorNode.ts +++ b/base/Sources/nodes/SeparateVectorNode.ts @@ -13,7 +13,7 @@ class SeparateVectorNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Separate Vector"), type: "SeparateVectorNode", diff --git a/base/Sources/nodes/TimeNode.ts b/base/Sources/nodes/TimeNode.ts index 8f6555a71..b6f9c17d8 100644 --- a/base/Sources/nodes/TimeNode.ts +++ b/base/Sources/nodes/TimeNode.ts @@ -11,7 +11,7 @@ class TimeNode extends LogicNode { else done(Context.raw.brushTime); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Time"), type: "TimeNode", diff --git a/base/Sources/nodes/VectorMathNode.ts b/base/Sources/nodes/VectorMathNode.ts index 1bb9e836f..5fd9c1b27 100644 --- a/base/Sources/nodes/VectorMathNode.ts +++ b/base/Sources/nodes/VectorMathNode.ts @@ -133,7 +133,7 @@ class VectorMathNode extends LogicNode { }); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Vector Math"), type: "VectorMathNode", diff --git a/base/Sources/nodes/VectorNode.ts b/base/Sources/nodes/VectorNode.ts index c41c47e36..f5369edfa 100644 --- a/base/Sources/nodes/VectorNode.ts +++ b/base/Sources/nodes/VectorNode.ts @@ -51,7 +51,7 @@ class VectorNode extends LogicNode { this.inputs[2].set(value.z); } - static def: TNode = { + static def: zui_node_t = { id: 0, name: _tr("Vector"), type: "VectorNode", diff --git a/misc/pad/Sources/main.ts b/misc/pad/Sources/main.ts index 9082a1182..747b47b3e 100644 --- a/misc/pad/Sources/main.ts +++ b/misc/pad/Sources/main.ts @@ -15,9 +15,9 @@ type TStorage = { class Main { static ui: ZuiRaw; - static text_handle = Handle.create(); - static sidebar_handle = Handle.create(); - static editor_handle = Handle.create(); + static text_handle = zui_handle_create(); + static sidebar_handle = zui_handle_create(); + static editor_handle = zui_handle_create(); static storage: TStorage = null; static resizing_sidebar = false; static minimap_w = 150; @@ -63,9 +63,9 @@ class Main { }; sys_start(ops, () => { - Data.getFont("font_mono.ttf", (font: FontRaw) => { - Data.getBlob("themes/dark.json", (blob_theme: ArrayBuffer) => { - Data.getBlob("text_coloring.json", (blob_coloring: ArrayBuffer) => { + data_get_font("font_mono.ttf", (font: FontRaw) => { + data_get_blob("themes/dark.json", (blob_theme: ArrayBuffer) => { + data_get_blob("text_coloring.json", (blob_coloring: ArrayBuffer) => { let parsed = JSON.parse(sys_buffer_to_string(blob_theme)); let theme: any = Theme.create();