Refactor
This commit is contained in:
@@ -12,7 +12,7 @@ class ExportObj {
|
||||
ExportObj.writeString(o, "# armorsculpt.org\n");
|
||||
|
||||
let texpaint = Project.layers[0].texpaint;
|
||||
let pixels = Image.getPixels(texpaint);
|
||||
let pixels = image_get_pixels(texpaint);
|
||||
let pixelsView = new DataView(pixels);
|
||||
let mesh = paintObjects[0].data;
|
||||
let inda = mesh.index_arrays[0].values;
|
||||
|
||||
@@ -28,7 +28,7 @@ class ImportMesh {
|
||||
Project.meshAssets = [path];
|
||||
|
||||
///if (krom_android || krom_ios)
|
||||
System.title = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
|
||||
sys_title_set(path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf(".")));
|
||||
///end
|
||||
}
|
||||
|
||||
@@ -79,7 +79,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: TMeshData) => {
|
||||
MeshData.create(raw, (md: mesh_data_t) => {
|
||||
Context.raw.paintObject = Context.mainObject();
|
||||
|
||||
Context.selectPaintObject(Context.mainObject());
|
||||
@@ -127,13 +127,13 @@ class ImportMesh {
|
||||
f32[i * 4 + 2] = mesh.posa[index * 4 + 2] / 32767;
|
||||
f32[i * 4 + 3] = 1.0;
|
||||
}
|
||||
let imgmesh = Image.fromBytes(f32.buffer, Config.getTextureResX(), Config.getTextureResY(), TextureFormat.RGBA128);
|
||||
let imgmesh = image_from_bytes(f32.buffer, Config.getTextureResX(), Config.getTextureResY(), TextureFormat.RGBA128);
|
||||
let texpaint = Project.layers[0].texpaint;
|
||||
Graphics2.begin(texpaint.g2, false);
|
||||
g2_begin(texpaint.g2, false);
|
||||
texpaint.g2.pipeline = Base.pipeCopy128;
|
||||
Graphics2.drawScaledImage(imgmesh, 0, 0, Config.getTextureResX(), Config.getTextureResY());
|
||||
g2_draw_scaled_image(imgmesh, 0, 0, Config.getTextureResX(), Config.getTextureResY());
|
||||
texpaint.g2.pipeline = null;
|
||||
Graphics2.end(texpaint.g2);
|
||||
g2_end(texpaint.g2);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -147,9 +147,9 @@ 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: TMeshData) => {
|
||||
MeshData.create(raw, (md: mesh_data_t) => {
|
||||
|
||||
let object = Scene.addMeshObject(md, Context.raw.paintObject.materials, Context.raw.paintObject.base);
|
||||
let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base);
|
||||
object.base.name = mesh.base.name;
|
||||
object.skip_context = "paint";
|
||||
|
||||
@@ -175,7 +175,7 @@ class ImportMesh {
|
||||
_addMesh();
|
||||
}
|
||||
|
||||
static rawMesh = (mesh: any): TMeshData => {
|
||||
static rawMesh = (mesh: any): mesh_data_t => {
|
||||
let posa = new Int16Array(Math.floor(mesh.inda.length * 4));
|
||||
for (let i = 0; i < posa.length; ++i) posa[i] = 32767;
|
||||
let inda = new Uint32Array(mesh.inda.length);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
class MakeMaterial {
|
||||
|
||||
static defaultScon: TShaderContext = null;
|
||||
static defaultMcon: TMaterialContext = null;
|
||||
static defaultScon: shader_context_t = null;
|
||||
static defaultMcon: material_context_t = null;
|
||||
|
||||
static heightUsed = false;
|
||||
static emisUsed = false;
|
||||
@@ -57,36 +57,36 @@ class MakeMaterial {
|
||||
}
|
||||
|
||||
let con = MakeMesh.run({ name: "Material", canvas: null });
|
||||
let scon: TShaderContext;
|
||||
ShaderContext.create(con.data, (_scon: TShaderContext) => { scon = _scon; });
|
||||
scon._overrideContext = {};
|
||||
let scon: shader_context_t;
|
||||
shader_context_create(con.data, (_scon: shader_context_t) => { scon = _scon; });
|
||||
scon._override_context = {};
|
||||
if (con.frag.sharedSamplers.length > 0) {
|
||||
let sampler = con.frag.sharedSamplers[0];
|
||||
scon._overrideContext.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
|
||||
scon._override_context.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
|
||||
}
|
||||
if (!Context.raw.textureFilter) {
|
||||
scon._overrideContext.filter = "point";
|
||||
scon._override_context.filter = "point";
|
||||
}
|
||||
m._shader.contexts.push(scon);
|
||||
m._shader._contexts.push(scon);
|
||||
|
||||
for (let i = 1; i < MakeMesh.layerPassCount; ++i) {
|
||||
let con = MakeMesh.run({ name: "Material", canvas: null }, i);
|
||||
let scon: TShaderContext;
|
||||
ShaderContext.create(con.data, (_scon: TShaderContext) => { scon = _scon; });
|
||||
scon._overrideContext = {};
|
||||
let scon: shader_context_t;
|
||||
shader_context_create(con.data, (_scon: shader_context_t) => { scon = _scon; });
|
||||
scon._override_context = {};
|
||||
if (con.frag.sharedSamplers.length > 0) {
|
||||
let sampler = con.frag.sharedSamplers[0];
|
||||
scon._overrideContext.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
|
||||
scon._override_context.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
|
||||
}
|
||||
if (!Context.raw.textureFilter) {
|
||||
scon._overrideContext.filter = "point";
|
||||
scon._override_context.filter = "point";
|
||||
}
|
||||
m._shader.contexts.push(scon);
|
||||
m._shader._contexts.push(scon);
|
||||
|
||||
let mcon: TMaterialContext;
|
||||
MaterialContext.create({ name: "mesh" + i, bind_textures: [] }, (self: TMaterialContext) => { mcon = self; });
|
||||
let mcon: material_context_t;
|
||||
MaterialContext.create({ name: "mesh" + i, bind_textures: [] }, (self: material_context_t) => { mcon = self; });
|
||||
m.contexts.push(mcon);
|
||||
m._contexts.push(mcon);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class MakeMaterial {
|
||||
|
||||
static parseParticleMaterial = () => {
|
||||
let m = Context.raw.particleMaterial;
|
||||
let sc: TShaderContext = null;
|
||||
let sc: shader_context_t = null;
|
||||
for (let c of m._shader._contexts) {
|
||||
if (c.name == "mesh") {
|
||||
sc = c;
|
||||
@@ -113,7 +113,7 @@ class MakeMaterial {
|
||||
}
|
||||
let con = MakeParticle.run({ name: "MaterialParticle", canvas: null });
|
||||
if (sc != null) MakeMaterial.deleteContext(sc);
|
||||
ShaderContext.create(con.data, (_sc: TShaderContext) => { sc = _sc; });
|
||||
shader_context_create(con.data, (_sc: shader_context_t) => { sc = _sc; });
|
||||
m._shader.contexts.push(sc);
|
||||
m._shader._contexts.push(sc);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class MakeMaterial {
|
||||
if (!MakeMaterial.getMOut()) return;
|
||||
|
||||
let m = Project.materials[0].data;
|
||||
let scon: TShaderContext = null;
|
||||
let scon: shader_context_t = null;
|
||||
for (let c of m._shader._contexts) {
|
||||
if (c.name == "mesh") {
|
||||
scon = c;
|
||||
@@ -132,14 +132,14 @@ class MakeMaterial {
|
||||
array_remove(m._shader.contexts, scon);
|
||||
array_remove(m._shader._contexts, scon);
|
||||
|
||||
let mcon: TMaterialContext = { name: "mesh", bind_textures: [] };
|
||||
let mcon: material_context_t = { name: "mesh", bind_textures: [] };
|
||||
|
||||
let sd: TMaterial = { name: "Material", canvas: null };
|
||||
let con = MakeMeshPreview.run(sd, mcon);
|
||||
|
||||
for (let i = 0; i < m.contexts.length; ++i) {
|
||||
if (m.contexts[i].name == "mesh") {
|
||||
MaterialContext.create(mcon, (self: TMaterialContext) => { m.contexts[i] = self; });
|
||||
MaterialContext.create(mcon, (self: material_context_t) => { m.contexts[i] = self; });
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ class MakeMaterial {
|
||||
if (scon != null) MakeMaterial.deleteContext(scon);
|
||||
|
||||
let compileError = false;
|
||||
ShaderContext.create(con.data, (_scon: TShaderContext) => {
|
||||
shader_context_create(con.data, (_scon: shader_context_t) => {
|
||||
if (_scon == null) compileError = true;
|
||||
scon = _scon;
|
||||
});
|
||||
@@ -158,10 +158,10 @@ class MakeMaterial {
|
||||
}
|
||||
|
||||
///if arm_voxels
|
||||
static makeVoxel = (m: TMaterialData) => {
|
||||
static makeVoxel = (m: material_data_t) => {
|
||||
let rebuild = MakeMaterial.heightUsed;
|
||||
if (Config.raw.rp_gi != false && rebuild) {
|
||||
let scon: TShaderContext = null;
|
||||
let scon: shader_context_t = null;
|
||||
for (let c of m._shader._contexts) {
|
||||
if (c.name == "voxel") {
|
||||
scon = c;
|
||||
@@ -177,15 +177,15 @@ class MakeMaterial {
|
||||
if (!MakeMaterial.getMOut()) return;
|
||||
|
||||
if (bakePreviews) {
|
||||
let current = Graphics2.current;
|
||||
if (current != null) Graphics2.end(current);
|
||||
let current = _g2_current;
|
||||
if (current != null) g2_end(current);
|
||||
MakeMaterial.bakeNodePreviews();
|
||||
if (current != null) Graphics2.begin(current, false);
|
||||
if (current != null) g2_begin(current, false);
|
||||
}
|
||||
|
||||
let m = Project.materials[0].data;
|
||||
let scon: TShaderContext = null;
|
||||
let mcon: TMaterialContext = null;
|
||||
let scon: shader_context_t = null;
|
||||
let mcon: material_context_t = null;
|
||||
for (let c of m._shader._contexts) {
|
||||
if (c.name == "paint") {
|
||||
array_remove(m._shader.contexts, c);
|
||||
@@ -203,20 +203,20 @@ class MakeMaterial {
|
||||
}
|
||||
|
||||
let sdata: TMaterial = { name: "Material", canvas: UINodes.getCanvasMaterial() };
|
||||
let mcon2: TMaterialContext = { name: "paint", bind_textures: [] };
|
||||
let mcon2: material_context_t = { name: "paint", bind_textures: [] };
|
||||
let con = MakeSculpt.run(sdata, mcon2);
|
||||
|
||||
let compileError = false;
|
||||
let scon2: TShaderContext;
|
||||
ShaderContext.create(con.data, (_scon: TShaderContext) => {
|
||||
let scon2: shader_context_t;
|
||||
shader_context_create(con.data, (_scon: shader_context_t) => {
|
||||
if (_scon == null) compileError = true;
|
||||
scon2 = _scon;
|
||||
});
|
||||
if (compileError) return;
|
||||
scon2._overrideContext = {};
|
||||
scon2._overrideContext.addressing = "repeat";
|
||||
let mcon3: TMaterialContext;
|
||||
MaterialContext.create(mcon2, (_mcon: TMaterialContext) => { mcon3 = _mcon; });
|
||||
scon2._override_context = {};
|
||||
scon2._override_context.addressing = "repeat";
|
||||
let mcon3: material_context_t;
|
||||
MaterialContext.create(mcon2, (_mcon: material_context_t) => { mcon3 = _mcon; });
|
||||
|
||||
m._shader.contexts.push(scon2);
|
||||
m._shader._contexts.push(scon2);
|
||||
@@ -234,7 +234,7 @@ class MakeMaterial {
|
||||
for (let key of Context.raw.nodePreviews.keys()) {
|
||||
if (Context.raw.nodePreviewsUsed.indexOf(key) == -1) {
|
||||
let image = Context.raw.nodePreviews.get(key);
|
||||
Base.notifyOnNextFrame(function() { Image.unload(image); });
|
||||
Base.notifyOnNextFrame(function() { image_unload(image); });
|
||||
Context.raw.nodePreviews.delete(key);
|
||||
}
|
||||
}
|
||||
@@ -264,8 +264,8 @@ class MakeMaterial {
|
||||
let resX = Math.floor(Config.getTextureResX() / 4);
|
||||
let resY = Math.floor(Config.getTextureResY() / 4);
|
||||
if (image == null || image.width != resX || image.height != resY) {
|
||||
if (image != null) Image.unload(image);
|
||||
image = Image.createRenderTarget(resX, resY);
|
||||
if (image != null) image_unload(image);
|
||||
image = image_create_render_target(resX, resY);
|
||||
Context.raw.nodePreviews.set(id, image);
|
||||
}
|
||||
|
||||
@@ -280,8 +280,8 @@ class MakeMaterial {
|
||||
let resX = Math.floor(Config.getTextureResX());
|
||||
let resY = Math.floor(Config.getTextureResY());
|
||||
if (image == null || image.width != resX || image.height != resY) {
|
||||
if (image != null) Image.unload(image);
|
||||
image = Image.createRenderTarget(resX, resY);
|
||||
if (image != null) image_unload(image);
|
||||
image = image_create_render_target(resX, resY);
|
||||
Context.raw.nodePreviews.set(id, image);
|
||||
}
|
||||
|
||||
@@ -291,20 +291,20 @@ class MakeMaterial {
|
||||
}
|
||||
}
|
||||
|
||||
static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = null): { scon: TShaderContext, mcon: TMaterialContext } => {
|
||||
static parseNodePreviewMaterial = (node: TNode, group: TNodeCanvas = null, parents: TNode[] = 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: TMaterialContext = { name: "mesh", bind_textures: [] };
|
||||
let mcon_raw: material_context_t = { name: "mesh", bind_textures: [] };
|
||||
let con = MakeNodePreview.run(sdata, mcon_raw, node, group, parents);
|
||||
let compileError = false;
|
||||
let scon: TShaderContext;
|
||||
ShaderContext.create(con.data, (_scon: TShaderContext) => {
|
||||
let scon: shader_context_t;
|
||||
shader_context_create(con.data, (_scon: shader_context_t) => {
|
||||
if (_scon == null) compileError = true;
|
||||
scon = _scon;
|
||||
});
|
||||
if (compileError) return null;
|
||||
let mcon: TMaterialContext;
|
||||
MaterialContext.create(mcon_raw, (_mcon: TMaterialContext) => { mcon = _mcon; });
|
||||
let mcon: material_context_t;
|
||||
MaterialContext.create(mcon_raw, (_mcon: material_context_t) => { mcon = _mcon; });
|
||||
return { scon: scon, mcon: mcon };
|
||||
}
|
||||
|
||||
@@ -322,9 +322,9 @@ class MakeMaterial {
|
||||
return `const vec3 voxelgiHalfExtents = vec3(${ext}, ${ext}, ${ext});`;
|
||||
}
|
||||
|
||||
static deleteContext = (c: TShaderContext) => {
|
||||
static deleteContext = (c: shader_context_t) => {
|
||||
Base.notifyOnNextFrame(() => { // Ensure pipeline is no longer in use
|
||||
ShaderContext.delete(c);
|
||||
shader_context_delete(c);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class MakeMeshPreview {
|
||||
|
||||
static opacityDiscardDecal = 0.05;
|
||||
|
||||
static run = (data: TMaterial, matcon: TMaterialContext): NodeShaderContextRaw => {
|
||||
static run = (data: TMaterial, matcon: material_context_t): NodeShaderContextRaw => {
|
||||
let context_id = "mesh";
|
||||
let con_mesh = NodeShaderContext.create(data, {
|
||||
name: context_id,
|
||||
@@ -21,7 +21,7 @@ class MakeMeshPreview {
|
||||
let pos = "pos";
|
||||
|
||||
///if arm_skin
|
||||
let skin = Context.raw.paintObject.data.getVArray("bone") != null;
|
||||
let skin = MeshData.getVArray(Context.raw.paintObject.data, "bone") != null;
|
||||
if (skin) {
|
||||
pos = "spos";
|
||||
NodeShaderContext.add_elem(con_mesh, "bone", 'short4norm');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
class MakeSculpt {
|
||||
|
||||
static run = (data: TMaterial, matcon: TMaterialContext): NodeShaderContextRaw => {
|
||||
static run = (data: TMaterial, matcon: material_context_t): NodeShaderContextRaw => {
|
||||
let context_id = "paint";
|
||||
let con_paint = NodeShaderContext.create(data, {
|
||||
name: context_id,
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
class TabLayers {
|
||||
|
||||
static layerNameEdit = -1;
|
||||
static layerNameHandle = new Handle();
|
||||
static layerNameHandle = Handle.create();
|
||||
static showContextMenu = false;
|
||||
|
||||
static draw = (htab: Handle) => {
|
||||
static draw = (htab: HandleRaw) => {
|
||||
let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW;
|
||||
mini ? TabLayers.drawMini(htab) : TabLayers.drawFull(htab);
|
||||
}
|
||||
|
||||
static drawMini = (htab: Handle) => {
|
||||
static drawMini = (htab: HandleRaw) => {
|
||||
let ui = UIBase.ui;
|
||||
ui.setHoveredTabName(tr("Layers"));
|
||||
Zui.setHoveredTabName(tr("Layers"));
|
||||
|
||||
let _ELEMENT_H = ui.t.ELEMENT_H;
|
||||
ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / ui.SCALE());
|
||||
ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / Zui.SCALE(ui));
|
||||
|
||||
ui.beginSticky();
|
||||
ui.separator(5);
|
||||
Zui.beginSticky();
|
||||
Zui.separator(5);
|
||||
|
||||
TabLayers.comboFilter();
|
||||
TabLayers.buttonNew("+");
|
||||
|
||||
ui.endSticky();
|
||||
Zui.endSticky();
|
||||
ui._y += 2;
|
||||
|
||||
TabLayers.highlightOddLines();
|
||||
@@ -32,16 +32,16 @@ class TabLayers {
|
||||
ui.t.ELEMENT_H = _ELEMENT_H;
|
||||
}
|
||||
|
||||
static drawFull = (htab: Handle) => {
|
||||
static drawFull = (htab: HandleRaw) => {
|
||||
let ui = UIBase.ui;
|
||||
if (ui.tab(htab, tr("Layers"))) {
|
||||
ui.beginSticky();
|
||||
ui.row([1 / 4, 3 / 4]);
|
||||
if (Zui.tab(htab, tr("Layers"))) {
|
||||
Zui.beginSticky();
|
||||
Zui.row([1 / 4, 3 / 4]);
|
||||
|
||||
TabLayers.buttonNew(tr("New"));
|
||||
TabLayers.comboFilter();
|
||||
|
||||
ui.endSticky();
|
||||
Zui.endSticky();
|
||||
ui._y += 2;
|
||||
|
||||
TabLayers.highlightOddLines();
|
||||
@@ -64,15 +64,15 @@ class TabLayers {
|
||||
let fullH = ui._windowH - UIBase.hwnds[0].scrollOffset;
|
||||
for (let i = 0; i < Math.floor(fullH / step); ++i) {
|
||||
if (i % 2 == 0) {
|
||||
ui.fill(0, i * step, (ui._w / ui.SCALE() - 2), step, ui.t.WINDOW_BG_COL - 0x00040404);
|
||||
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 (ui.button(text)) {
|
||||
UIMenu.draw((ui: Zui) => {
|
||||
if (Zui.button(text)) {
|
||||
UIMenu.draw((ui: ZuiRaw) => {
|
||||
let l = Context.raw.layer;
|
||||
if (UIMenu.menuButton(ui, tr("Paint Layer"))) {
|
||||
Base.newLayer();
|
||||
@@ -87,7 +87,7 @@ class TabLayers {
|
||||
let ar = [tr("All")];
|
||||
let filterHandle = Zui.handle("tablayers_0");
|
||||
filterHandle.position = Context.raw.layerFilter;
|
||||
Context.raw.layerFilter = ui.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<i32, i32>) => {
|
||||
@@ -137,12 +137,12 @@ class TabLayers {
|
||||
}
|
||||
|
||||
let step = ui.t.ELEMENT_H;
|
||||
let checkw = (ui._windowW / 100 * 8) / ui.SCALE();
|
||||
let checkw = (ui._windowW / 100 * 8) / Zui.SCALE(ui);
|
||||
|
||||
// Highlight drag destination
|
||||
let absy = ui._windowY + ui._y;
|
||||
if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) {
|
||||
if (Mouse.y > absy + step && Mouse.y < absy + step * 3) {
|
||||
if (mouse_y > absy + step && mouse_y < absy + step * 3) {
|
||||
let down = Project.layers.indexOf(Base.dragLayer) >= i;
|
||||
Context.raw.dragDestination = down ? i : i - 1;
|
||||
|
||||
@@ -152,27 +152,27 @@ class TabLayers {
|
||||
let nestedGroup = SlotLayer.isGroup(Base.dragLayer) && toGroup;
|
||||
if (!nestedGroup) {
|
||||
if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) {
|
||||
ui.fill(checkw, step * 2, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
|
||||
Zui.fill(checkw, step * 2, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i == Project.layers.length - 1 && Mouse.y < absy + step) {
|
||||
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)) {
|
||||
ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
|
||||
Zui.fill(checkw, 0, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Base.isDragging && (Base.dragMaterial != null || Base.dragSwatch != null) && Context.inLayers()) {
|
||||
if (Mouse.y > absy + step && Mouse.y < absy + step * 3) {
|
||||
if (mouse_y > absy + step && mouse_y < absy + step * 3) {
|
||||
Context.raw.dragDestination = i;
|
||||
if (TabLayers.canDropNewLayer(i))
|
||||
ui.fill(checkw, 2 * step, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
|
||||
Zui.fill(checkw, 2 * step, (ui._windowW / Zui.SCALE(ui) - 2) - checkw, 2 * Zui.SCALE(ui), ui.t.HIGHLIGHT_COL);
|
||||
}
|
||||
else if (i == Project.layers.length - 1 && Mouse.y < absy + step) {
|
||||
else if (i == Project.layers.length - 1 && mouse_y < absy + step) {
|
||||
Context.raw.dragDestination = Project.layers.length;
|
||||
if (TabLayers.canDropNewLayer(Project.layers.length))
|
||||
ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
|
||||
Zui.fill(checkw, 0, (ui._windowW / 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;
|
||||
|
||||
ui.row([1, 1]);
|
||||
Zui.row([1, 1]);
|
||||
let uix = ui._x;
|
||||
let uiy = ui._y;
|
||||
ui.endElement();
|
||||
ui.endElement();
|
||||
Zui.endElement();
|
||||
Zui.endElement();
|
||||
|
||||
ui._y += ui.ELEMENT_H();
|
||||
ui._y -= ui.ELEMENT_OFFSET();
|
||||
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) {
|
||||
ui.row([8 / 100, 52 / 100, 30 / 100, 10 / 100]);
|
||||
Zui.row([8 / 100, 52 / 100, 30 / 100, 10 / 100]);
|
||||
}
|
||||
else {
|
||||
ui.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) * ui.SCALE();
|
||||
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 (ui.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,20 +236,20 @@ class TabLayers {
|
||||
ui._y += center;
|
||||
if (TabLayers.layerNameEdit == l.id) {
|
||||
TabLayers.layerNameHandle.text = l.name;
|
||||
l.name = ui.textInput(TabLayers.layerNameHandle);
|
||||
l.name = Zui.textInput(TabLayers.layerNameHandle);
|
||||
if (ui.textSelectedHandle_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 * ui.SCALE()) * 2) {
|
||||
ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + (step * Zui.SCALE(ui)) * 2) {
|
||||
if (ui.inputStarted) {
|
||||
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._windowX - 3), -(mouse_y - uiy - ui._windowY + 1));
|
||||
}
|
||||
else if (ui.inputReleased) {
|
||||
if (Time.time() - Context.raw.selectTime > 0.2) {
|
||||
Context.raw.selectTime = Time.time();
|
||||
if (time_time() - Context.raw.selectTime > 0.2) {
|
||||
Context.raw.selectTime = time_time();
|
||||
}
|
||||
}
|
||||
else if (ui.inputReleasedR) {
|
||||
@@ -258,13 +258,13 @@ class TabLayers {
|
||||
}
|
||||
}
|
||||
|
||||
let state = ui.text(l.name);
|
||||
let state = Zui.text(l.name);
|
||||
if (state == State.Released) {
|
||||
let td = Time.time() - Context.raw.selectTime;
|
||||
let td = time_time() - Context.raw.selectTime;
|
||||
if (td < 0.2 && td > 0.0) {
|
||||
TabLayers.layerNameEdit = l.id;
|
||||
TabLayers.layerNameHandle.text = l.name;
|
||||
ui.startTextEdit(TabLayers.layerNameHandle);
|
||||
Zui.startTextEdit(TabLayers.layerNameHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,12 +281,12 @@ class TabLayers {
|
||||
ui._y -= center;
|
||||
|
||||
if (l.parent != null) {
|
||||
ui._x -= 10 * ui.SCALE();
|
||||
if (l.parent.parent != null) ui._x -= 10 * ui.SCALE();
|
||||
ui._x -= 10 * Zui.SCALE(ui);
|
||||
if (l.parent.parent != null) ui._x -= 10 * Zui.SCALE(ui);
|
||||
}
|
||||
|
||||
if (SlotLayer.isGroup(l)) {
|
||||
ui.endElement();
|
||||
Zui.endElement();
|
||||
}
|
||||
else {
|
||||
if (SlotLayer.isMask(l)) {
|
||||
@@ -294,7 +294,7 @@ class TabLayers {
|
||||
}
|
||||
|
||||
// comboBlending(ui, l);
|
||||
ui.endElement();
|
||||
Zui.endElement();
|
||||
|
||||
if (SlotLayer.isMask(l)) {
|
||||
ui._y -= center;
|
||||
@@ -303,43 +303,43 @@ class TabLayers {
|
||||
|
||||
if (hasPanel) {
|
||||
ui._y += center;
|
||||
let layerPanel = Zui.handle("tablayers_1").nest(l.id);
|
||||
let layerPanel = Zui.nest(Zui.handle("tablayers_1"), l.id);
|
||||
layerPanel.selected = l.show_panel;
|
||||
l.show_panel = ui.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 -= ui.ELEMENT_OFFSET();
|
||||
ui.endElement();
|
||||
ui._y -= Zui.ELEMENT_OFFSET(ui);
|
||||
Zui.endElement();
|
||||
}
|
||||
else {
|
||||
ui._y -= ui.ELEMENT_OFFSET();
|
||||
ui._y -= Zui.ELEMENT_OFFSET(ui);
|
||||
|
||||
ui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]);
|
||||
ui.endElement();
|
||||
ui.endElement();
|
||||
ui.endElement();
|
||||
Zui.row([8 / 100, 16 / 100, 36 / 100, 30 / 100, 10 / 100]);
|
||||
Zui.endElement();
|
||||
Zui.endElement();
|
||||
Zui.endElement();
|
||||
|
||||
if (Config.raw.touch_ui) {
|
||||
ui._x += 12 * ui.SCALE();
|
||||
ui._x += 12 * Zui.SCALE(ui);
|
||||
}
|
||||
|
||||
ui._y -= center;
|
||||
TabLayers.comboObject(ui, l);
|
||||
ui._y += center;
|
||||
|
||||
ui.endElement();
|
||||
Zui.endElement();
|
||||
}
|
||||
|
||||
ui._y -= ui.ELEMENT_OFFSET();
|
||||
ui._y -= Zui.ELEMENT_OFFSET(ui);
|
||||
}
|
||||
|
||||
static comboObject = (ui: Zui, l: SlotLayerRaw, label = false): Handle => {
|
||||
static comboObject = (ui: ZuiRaw, l: SlotLayerRaw, label = false): HandleRaw => {
|
||||
let ar = [tr("Shared")];
|
||||
let objectHandle = Zui.handle("tablayers_2").nest(l.id);
|
||||
let objectHandle = Zui.nest(Zui.handle("tablayers_2"), l.id);
|
||||
objectHandle.position = l.objectMask;
|
||||
l.objectMask = ui.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
|
||||
ui.fill(0, 0, (ui._w / ui.SCALE() - 2), 1 * ui.SCALE(), 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) {
|
||||
ui.rect(1, -step * 2, ui._w / ui.SCALE() - 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 {
|
||||
ui.rect(1, -step * 2 - 1, ui._w / ui.SCALE() - 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class BrushOutputNode extends LogicNode {
|
||||
!Base.isScrolling() &&
|
||||
!Base.isComboSelected()) {
|
||||
|
||||
let down = Mouse.down() || Pen.down();
|
||||
let down = mouse_down() || pen_down();
|
||||
|
||||
// Prevent painting the same spot
|
||||
let sameSpot = Context.raw.paintVec.x == Context.raw.lastPaintX && Context.raw.paintVec.y == Context.raw.lastPaintY;
|
||||
|
||||
Reference in New Issue
Block a user