From 6f27383e2ccbd347fb9e9bdb1131a9e2e0b6b271 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 24 Apr 2024 12:14:47 +0200 Subject: [PATCH] minits progress --- armorforge/Assets/default_brush.arm | Bin 2390 -> 2439 bytes armorforge/Assets/default_material.arm | Bin 2435 -> 2479 bytes armorforge/Sources/tab_objects.ts | 28 +- armorlab/Assets/default_brush.arm | Bin 3425 -> 3337 bytes armorlab/Sources/nodes/image_texture_node.ts | 10 +- armorlab/Sources/nodes/inpaint_node.ts | 10 +- armorlab/Sources/nodes/photo_to_pbr_node.ts | 8 +- armorlab/Sources/nodes/text_to_photo_node.ts | 2 +- armorlab/Sources/nodes/tiling_node.ts | 9 +- armorlab/Sources/nodes/variance_node.ts | 2 +- armorpaint/Assets/default_brush.arm | Bin 2390 -> 2439 bytes armorpaint/Assets/default_material.arm | Bin 2435 -> 2479 bytes armorpaint/Sources/import_folder.ts | 2 +- armorpaint/Sources/nodes/brush_output_node.ts | 16 +- armorpaint/Sources/nodes/input_node.ts | 4 +- armorpaint/Sources/nodes/tex_image_node.ts | 10 +- armorsculpt/Assets/default_brush.arm | Bin 2043 -> 2082 bytes armorsculpt/Assets/default_material.arm | Bin 586 -> 596 bytes armorsculpt/Sources/tab_layers.ts | 14 +- base/Sources/box_export.ts | 30 +- base/Sources/box_preferences.ts | 271 +++++++++++--- base/Sources/context.ts | 23 +- base/Sources/export_arm.ts | 4 +- base/Sources/import_arm.ts | 4 +- base/Sources/import_blend_material.ts | 34 +- base/Sources/nodes/float_node.ts | 4 +- base/Sources/nodes/math_node.ts | 12 +- base/Sources/nodes/random_node.ts | 6 +- base/Sources/nodes/separate_vector_node.ts | 6 +- base/Sources/nodes/time_node.ts | 6 +- base/Sources/nodes/vector_math_node.ts | 6 +- base/Sources/nodes/vector_node.ts | 6 +- base/Sources/nodes_material.ts | 353 +++++++++--------- base/Sources/parser_logic.ts | 29 +- base/Sources/parser_material.ts | 54 +-- base/Sources/project.ts | 21 +- base/Sources/tab_materials.ts | 76 +++- base/Sources/tab_textures.ts | 8 +- base/Sources/ui_header.ts | 111 ++++-- base/Sources/ui_menu.ts | 36 +- base/Sources/ui_menubar.ts | 6 +- base/Sources/ui_nodes.ts | 68 +++- base/Sources/ui_view2d.ts | 24 +- misc/pad/Assets/themes/dark.json | 35 -- misc/pad/Sources/main.ts | 127 +++---- misc/pad/project.js | 2 +- 46 files changed, 936 insertions(+), 541 deletions(-) delete mode 100644 misc/pad/Assets/themes/dark.json diff --git a/armorforge/Assets/default_brush.arm b/armorforge/Assets/default_brush.arm index c140c4c473829d4d379fab90aa72dfc57a22eea3..a08509fef2819fe15078674015953fa8c2d9588c 100644 GIT binary patch delta 178 zcmca6)GoY%oss=6BLf4&DTc`p*&QeIv&c=>Wa67##^{J7?zfqpsfdXSs*s_|{A+|H;xU3CP^j zED2l?*;zAZ+5vUgO-^9uom|Zt4;2O(2@~F|#U{syMSSuM_E>Dft{jP|!p@W5aZCjO D5;iUp delta 91 zcmZ24+$_A|2qWWx&F2`|n3ygxPL|{Fo2N`z 0) { zui_row([1 / 13, 12 / 13]); - b = zui_panel(zui_nest(list_handle, tab_objects_line_counter, {selected: true}), "", true, false, false); + let h: zui_handle_t = zui_nest(list_handle, tab_objects_line_counter); + if (h.init) { + h.selected = true; + } + b = zui_panel(h, "", true, false, false); zui_text(current_object.name); } else { @@ -120,7 +124,12 @@ function tab_objects_draw(htab: zui_handle_t) { } zui_end_sticky(); - if (zui_panel(zui_handle(__ID__, {selected: true}), "Outliner")) { + let outliner_handle: zui_handle_t = zui_handle(__ID__); + if (outliner_handle.init) { + outliner_handle.selected = true; + } + + if (zui_panel(outliner_handle, "Outliner")) { // ui.indent(); ui._y -= zui_ELEMENT_OFFSET(ui); @@ -134,7 +143,12 @@ function tab_objects_draw(htab: zui_handle_t) { // ui.unindent(); } - if (zui_panel(zui_handle(__ID__, {selected: true}), "Properties")) { + let properties_handle: zui_handle_t = zui_handle(__ID__); + if (properties_handle.init) { + properties_handle.selected = true; + } + + if (zui_panel(properties_handle, "Properties")) { // ui.indent(); if (context_raw.selected_object != null) { @@ -263,7 +277,13 @@ function tab_objects_draw(htab: zui_handle_t) { if (context_raw.selected_object.name == "Scene") { let p = scene_world; - p.strength = zui_slider(zui_handle(__ID__, {value: p.strength}), "Environment", 0.0, 5.0, true); + + let p_handle: zui_handle_t = zui_handle(__ID__); + if (p_handle.init) { + p_handle.value = p.strength; + } + + p.strength = zui_slider(p_handle, "Environment", 0.0, 5.0, true); } else if (context_raw.selected_object.ext_type == "light_object_t") { let light = context_raw.selected_object.ext; diff --git a/armorlab/Assets/default_brush.arm b/armorlab/Assets/default_brush.arm index b6942901e7b2824b4a92b4a4f433d3731b4da4ca..2325fa0d7ee17b24d3cbb1e008356dc2a68b765e 100644 GIT binary patch delta 291 zcmaDT)hV@spHb{C3j+hgDIi7y4fc~A7*})MWdw==rGVTIsN4litJtBklO5P4C#Nz` z7rM&~QO#fvq=6W0i1*}NmRMw^o1d~c;IY(hGA}FdV^FeWg;xl<8L z)5*7(;u$YZ-oWBC*@1<3avyV&@_lBQxdx|zEPJqRh6tt++#u7*zAUkfmo{%;i6YZw z8k6JL>d5ufdRF<#G3<`Wz5xljFkuM&WO4v|QVJXxAVq7Lbtf<96r;pyTP{0<)f$@* IbGb1A0A`7C82|tP diff --git a/armorlab/Sources/nodes/image_texture_node.ts b/armorlab/Sources/nodes/image_texture_node.ts index 8fcf74e9..077dbc71 100644 --- a/armorlab/Sources/nodes/image_texture_node.ts +++ b/armorlab/Sources/nodes/image_texture_node.ts @@ -64,7 +64,7 @@ let image_texture_node_def: zui_node_t = { name: _tr("Alpha"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -76,8 +76,8 @@ let image_texture_node_def: zui_node_t = { name: _tr("file"), type: "ENUM", output: -1, - default_value: 0, - data: "", + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), min: 0.0, max: 1.0, precision: 100, @@ -87,8 +87,8 @@ let image_texture_node_def: zui_node_t = { name: _tr("color_space"), type: "ENUM", output: -1, - default_value: 0, - data: ["linear", "srgb"], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string("linear\0srgb"), min: 0.0, max: 1.0, precision: 100, diff --git a/armorlab/Sources/nodes/inpaint_node.ts b/armorlab/Sources/nodes/inpaint_node.ts index dcc46eed..f302756e 100644 --- a/armorlab/Sources/nodes/inpaint_node.ts +++ b/armorlab/Sources/nodes/inpaint_node.ts @@ -51,7 +51,13 @@ function inpaint_node_init() { function inpaint_node_buttons(ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) { inpaint_node_auto = node.buttons[0].default_value == 0 ? false : true; if (!inpaint_node_auto) { - inpaint_node_strength = zui_slider(zui_handle(__ID__, { value: inpaint_node_strength }), tr("strength"), 0, 1, true); + + let inpaint_node_strength_handle: zui_handle_t = zui_handle(__ID__); + if (inpaint_node_strength_handle.init) { + inpaint_node_strength_handle.value = inpaint_node_strength; + } + + inpaint_node_strength = zui_slider(inpaint_node_strength_handle, tr("strength"), 0, 1, true); inpaint_node_prompt = zui_text_area(zui_handle(__ID__), zui_align_t.LEFT, true, tr("prompt"), true); node.buttons[1].height = 1 + string_split(inpaint_node_prompt, "\n").length; } @@ -223,7 +229,7 @@ let inpaint_node_def: zui_node_t = { name: _tr("auto"), type: "BOOL", output: 0, - default_value: true, + default_value: f32_array_create_x(1), data: null, min: 0.0, max: 1.0, diff --git a/armorlab/Sources/nodes/photo_to_pbr_node.ts b/armorlab/Sources/nodes/photo_to_pbr_node.ts index 2e5859b7..c141aed2 100644 --- a/armorlab/Sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/Sources/nodes/photo_to_pbr_node.ts @@ -217,7 +217,7 @@ let photo_to_pbr_node_def: zui_node_t = { name: _tr("Occlusion"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -229,7 +229,7 @@ let photo_to_pbr_node_def: zui_node_t = { name: _tr("Roughness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -241,7 +241,7 @@ let photo_to_pbr_node_def: zui_node_t = { name: _tr("Metallic"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -265,7 +265,7 @@ let photo_to_pbr_node_def: zui_node_t = { name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, diff --git a/armorlab/Sources/nodes/text_to_photo_node.ts b/armorlab/Sources/nodes/text_to_photo_node.ts index 0045698b..b4b93ce8 100644 --- a/armorlab/Sources/nodes/text_to_photo_node.ts +++ b/armorlab/Sources/nodes/text_to_photo_node.ts @@ -277,7 +277,7 @@ let text_to_photo_node_def: zui_node_t = { name: _tr("tiling"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, diff --git a/armorlab/Sources/nodes/tiling_node.ts b/armorlab/Sources/nodes/tiling_node.ts index 646fb1ef..fc0492c7 100644 --- a/armorlab/Sources/nodes/tiling_node.ts +++ b/armorlab/Sources/nodes/tiling_node.ts @@ -27,7 +27,12 @@ function tiling_node_init() { function tiling_node_buttons(ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) { tiling_node_auto = node.buttons[0].default_value == 0 ? false : true; if (!tiling_node_auto) { - tiling_node_strength = zui_slider(zui_handle(__ID__, { value: tiling_node_strength }), tr("strength"), 0, 1, true); + let tiling_node_strength_handle: zui_handle_t = zui_handle(__ID__); + if (tiling_node_strength_handle.init) { + tiling_node_strength_handle.value = tiling_node_strength; + } + + tiling_node_strength = zui_slider(tiling_node_strength_handle, tr("strength"), 0, 1, true); tiling_node_prompt = zui_text_area(zui_handle(__ID__), zui_align_t.LEFT, true, tr("prompt"), true); node.buttons[1].height = 1 + string_split(tiling_node_prompt, "\n").length; } @@ -136,7 +141,7 @@ let tiling_node_def: zui_node_t = { name: _tr("auto"), type: "BOOL", output: 0, - default_value: true, + default_value: f32_array_create_x(1), data: null, min: 0.0, max: 1.0, diff --git a/armorlab/Sources/nodes/variance_node.ts b/armorlab/Sources/nodes/variance_node.ts index 42b633e6..43b7c1d4 100644 --- a/armorlab/Sources/nodes/variance_node.ts +++ b/armorlab/Sources/nodes/variance_node.ts @@ -106,7 +106,7 @@ let variance_node_def: zui_node_t = { name: _tr("Strength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, diff --git a/armorpaint/Assets/default_brush.arm b/armorpaint/Assets/default_brush.arm index c140c4c473829d4d379fab90aa72dfc57a22eea3..a08509fef2819fe15078674015953fa8c2d9588c 100644 GIT binary patch delta 178 zcmca6)GoY%oss=6BLf4&DTc`p*&QeIv&c=>Wa67##^{J7?zfqpsfdXSs*s_|{A+|H;xU3CP^j zED2l?*;zAZ+5vUgO-^9uom|Zt4;2O(2@~F|#U{syMSSuM_E>Dft{jP|!p@W5aZCjO D5;iUp delta 91 zcmZ24+$_A|2qWWx&F2`|n3ygxPL|{Fo2N`zLo{0;hgn^;Ke)2_T@5v`w i;?RZ4S>w@#)Y#Be*-ie%$UFH8TRL1N1H)t+_Wb}*XDIyu delta 88 zcmZ1^@SA@FJ0s(z$-Io~!KBk>7N&Y8rb~>I`565s-(ZP@F}qpgVN82AsHo%Qr)(wM Yhi= elems.length) { - array_push(elems, [1.0, 1.0, 1.0, 1.0, 0.0]); - } - let cbdata: any = bl_handle_get(ramp, "data", i, "CBData"); - elems[i][0] = math_floor(bl_handle_get(cbdata, "r") * 100) / 100; - elems[i][1] = math_floor(bl_handle_get(cbdata, "g") * 100) / 100; - elems[i][2] = math_floor(bl_handle_get(cbdata, "b") * 100) / 100; - elems[i][3] = math_floor(bl_handle_get(cbdata, "a") * 100) / 100; - elems[i][4] = math_floor(bl_handle_get(cbdata, "pos") * 100) / 100; - } + // let ramp: any = bl_handle_get(node, "storage", 0, "ColorBand"); + // n.buttons[0].data = bl_handle_get(ramp, "ipotype") == 0 ? 0 : 1; // Linear / Constant + // let elems: f32[][] = n.buttons[0].default_value; + // for (let i: i32 = 0; i < bl_handle_get(ramp, "tot"); ++i) { + // if (i >= elems.length) { + // array_push(elems, [1.0, 1.0, 1.0, 1.0, 0.0]); + // } + // let cbdata: any = bl_handle_get(ramp, "data", i, "CBData"); + // elems[i][0] = math_floor(bl_handle_get(cbdata, "r") * 100) / 100; + // elems[i][1] = math_floor(bl_handle_get(cbdata, "g") * 100) / 100; + // elems[i][2] = math_floor(bl_handle_get(cbdata, "b") * 100) / 100; + // elems[i][3] = math_floor(bl_handle_get(cbdata, "a") * 100) / 100; + // elems[i][4] = math_floor(bl_handle_get(cbdata, "pos") * 100) / 100; + // } } else if (search == "mixrgb" || search == "math") { - n.buttons[0].default_value = bl_handle_get(node, "custom1"); - n.buttons[1].default_value = bl_handle_get(node, "custom2") & 2; + n.buttons[0].default_value = f32_array_create_x(bl_handle_get(node, "custom1")); + n.buttons[1].default_value = f32_array_create_x(bl_handle_get(node, "custom2") & 2); } else if (search == "mapping") { let storage: any = bl_handle_get(node, "storage", 0, "TexMapping"); diff --git a/base/Sources/nodes/float_node.ts b/base/Sources/nodes/float_node.ts index 8fffd312..2b64a273 100644 --- a/base/Sources/nodes/float_node.ts +++ b/base/Sources/nodes/float_node.ts @@ -65,7 +65,7 @@ let float_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 10.0, precision: 100, @@ -79,7 +79,7 @@ let float_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes/math_node.ts b/base/Sources/nodes/math_node.ts index ef51aac9..e174736b 100644 --- a/base/Sources/nodes/math_node.ts +++ b/base/Sources/nodes/math_node.ts @@ -145,7 +145,7 @@ let math_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -157,7 +157,7 @@ let math_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -171,7 +171,7 @@ let math_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -183,8 +183,8 @@ let math_node_def: zui_node_t = { name: _tr("operation"), type: "ENUM", output: 0, - default_value: 0, - data: ["Add", "Subtract", "Multiply", "Divide", "Power", "Logarithm", "Square Root", "Inverse Square Root", "Absolute", "Exponent", "Minimum", "Maximum", "Less Than", "Greater Than", "Sign", "Round", "Floor", "Ceil", "Truncate", "Fraction", "Modulo", "Snap", "Ping-Pong", "Sine", "Cosine", "Tangent", "Arcsine", "Arccosine", "Arctangent", "Arctan2", "Hyperbolic Sine", "Hyperbolic Cosine", "Hyperbolic Tangent", "To Radians", "To Degrees"], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string("Add\0Subtract\0Multiply\0Divide\0Power\0Logarithm\0Square Root\0Inverse Square Root\0Absolute\0Exponent\0Minimum\0Maximum\0Less Than\0Greater Than\0Sign\0Round\0Floor\0Ceil\0Truncate\0Fraction\0Modulo\0Snap\0Ping-Pong\0Sine\0Cosine\0Tangent\0Arcsine\0Arccosine\0Arctangent\0Arctan2\0Hyperbolic Sine\0Hyperbolic Cosine\0Hyperbolic Tangent\0To Radians\0To Degrees"), min: 0.0, max: 1.0, precision: 100, @@ -194,7 +194,7 @@ let math_node_def: zui_node_t = { name: _tr("use_clamp"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, diff --git a/base/Sources/nodes/random_node.ts b/base/Sources/nodes/random_node.ts index 4373fd24..ac09630a 100644 --- a/base/Sources/nodes/random_node.ts +++ b/base/Sources/nodes/random_node.ts @@ -70,7 +70,7 @@ let random_node_def: zui_node_t = { name: _tr("Min"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -82,7 +82,7 @@ let random_node_def: zui_node_t = { name: _tr("Max"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -96,7 +96,7 @@ let random_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes/separate_vector_node.ts b/base/Sources/nodes/separate_vector_node.ts index ebee1733..7c878d5c 100644 --- a/base/Sources/nodes/separate_vector_node.ts +++ b/base/Sources/nodes/separate_vector_node.ts @@ -54,7 +54,7 @@ let separate_vector_node_def: zui_node_t = { name: _tr("X"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -66,7 +66,7 @@ let separate_vector_node_def: zui_node_t = { name: _tr("Y"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -78,7 +78,7 @@ let separate_vector_node_def: zui_node_t = { name: _tr("Z"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes/time_node.ts b/base/Sources/nodes/time_node.ts index 1793ab70..3b38c41f 100644 --- a/base/Sources/nodes/time_node.ts +++ b/base/Sources/nodes/time_node.ts @@ -40,7 +40,7 @@ let time_node_def: zui_node_t = { name: _tr("Time"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -52,7 +52,7 @@ let time_node_def: zui_node_t = { name: _tr("Delta"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -64,7 +64,7 @@ let time_node_def: zui_node_t = { name: _tr("Brush"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes/vector_math_node.ts b/base/Sources/nodes/vector_math_node.ts index b205b567..b9c0ff0f 100644 --- a/base/Sources/nodes/vector_math_node.ts +++ b/base/Sources/nodes/vector_math_node.ts @@ -192,7 +192,7 @@ let vector_math_node_def: zui_node_t = { name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -204,8 +204,8 @@ let vector_math_node_def: zui_node_t = { name: _tr("operation"), type: "ENUM", output: 0, - default_value: 0, - data: ["Add", "Subtract", "Multiply", "Divide", "Average", "Cross Product", "Project", "Reflect", "Dot Product", "Distance", "Length", "Scale", "Normalize", "Absolute", "Minimum", "Maximum", "Floor", "Ceil", "Fraction", "Modulo", "Snap", "Sine", "Cosine", "Tangent"], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string("Add\0Subtract\0Multiply\0Divide\0Average\0Cross Product\0Project\0Reflect\0Dot Product\0Distance\0Length\0Scale\0Normalize\0Absolute\0Minimum\0Maximum\0Floor\0Ceil\0Fraction\0Modulo\0Snap\0Sine\0Cosine\0Tangent"), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes/vector_node.ts b/base/Sources/nodes/vector_node.ts index 41fdfabc..183d90fe 100644 --- a/base/Sources/nodes/vector_node.ts +++ b/base/Sources/nodes/vector_node.ts @@ -70,7 +70,7 @@ let vector_node_def: zui_node_t = { name: _tr("X"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -82,7 +82,7 @@ let vector_node_def: zui_node_t = { name: _tr("Y"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -94,7 +94,7 @@ let vector_node_def: zui_node_t = { name: _tr("Z"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, diff --git a/base/Sources/nodes_material.ts b/base/Sources/nodes_material.ts index 6ba7ca5a..9e786c97 100644 --- a/base/Sources/nodes_material.ts +++ b/base/Sources/nodes_material.ts @@ -49,7 +49,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -61,7 +61,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Name"), type: "STRING", output: -1, - default_value: null, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -98,7 +98,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("View Z Depth"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -110,7 +110,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("View Distance"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -134,7 +134,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("IOR"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.45, + default_value: f32_array_create_x(1.45), min: 0.0, max: 3.0, precision: 100, @@ -160,7 +160,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -257,7 +257,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Backfacing"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -269,7 +269,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Pointiness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -281,7 +281,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Random Per Island"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -318,7 +318,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Opacity"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -330,7 +330,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Occlusion"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -342,7 +342,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Roughness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -354,7 +354,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Metallic"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -378,7 +378,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Emission"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -390,7 +390,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -402,7 +402,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Subsurface"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -414,8 +414,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Layer"), type: "ENUM", output: -1, - default_value: 0, - data: "", + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), min: 0.0, max: 1.0, precision: 100, @@ -439,7 +439,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -451,8 +451,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Layer"), type: "ENUM", output: -1, - default_value: 0, - data: "", + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), min: 0.0, max: 1.0, precision: 100, @@ -475,7 +475,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Blend"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -501,7 +501,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fresnel"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -513,7 +513,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Facing"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -550,7 +550,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Opacity"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -562,7 +562,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Occlusion"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -574,7 +574,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Roughness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -586,7 +586,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Metallic"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -610,7 +610,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Emission"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -622,7 +622,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -634,7 +634,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Subsurface"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -646,8 +646,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Material"), type: "ENUM", output: -1, - default_value: 0, - data: "", + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), min: 0.0, max: 1.0, precision: 100, @@ -695,7 +695,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Object Index"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -707,7 +707,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Material Index"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -719,7 +719,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Random"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -756,7 +756,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Opacity"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -768,7 +768,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Occlusion"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -780,7 +780,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Roughness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -792,7 +792,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Metallic"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -816,7 +816,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Emission"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -828,7 +828,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -840,7 +840,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Subsurface"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -877,7 +877,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("default_value"), type: "RGBA", output: 0, - default_value: null, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -902,7 +902,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -914,7 +914,7 @@ let nodes_material_list: zui_node_t[][] = [ name: " ", type: "STRING", output: -1, - default_value: "", + default_value: f32_array_create_x(0), // "", data: null, min: 0.0, max: 1.0, @@ -939,7 +939,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -951,7 +951,7 @@ let nodes_material_list: zui_node_t[][] = [ name: " ", type: "STRING", output: -1, - default_value: "", + default_value: f32_array_create_x(0), // "", data: null, min: 0.0, max: 1.0, @@ -1122,7 +1122,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -1134,7 +1134,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("default_value"), type: "VALUE", output: 0, - default_value: null, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 10.0, @@ -1171,7 +1171,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Alpha"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -1195,7 +1195,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Size"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.01, + default_value: f32_array_create_x(0.01), min: 0.0, max: 0.1, precision: 100, @@ -1209,7 +1209,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -1221,7 +1221,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Pixel Size"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -1259,7 +1259,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Opacity"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 1.0, + // default_value: f32_array_create_x(1.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1271,7 +1271,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Occlusion"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 1.0, + // default_value: f32_array_create_x(1.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1283,7 +1283,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Roughness"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 0.1, + // default_value: f32_array_create_x(0.1), // min: 0.0, // max: 1.0, // precision: 100, @@ -1295,7 +1295,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Metallic"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 0.0, + // default_value: f32_array_create_x(0.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1319,7 +1319,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Emission"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 0.0, + // default_value: f32_array_create_x(0.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1331,7 +1331,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Height"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 0.0, + // default_value: f32_array_create_x(0.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1343,7 +1343,7 @@ let nodes_material_list: zui_node_t[][] = [ // name: _tr("Subsurface"), // type: "VALUE", // color: 0xffa1a1a1, - // default_value: 0.0, + // default_value: f32_array_create_x(0.0), // min: 0.0, // max: 1.0, // precision: 100, @@ -1418,7 +1418,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -1444,7 +1444,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1504,7 +1504,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 1.0, precision: 100, @@ -1530,7 +1530,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1554,7 +1554,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Strength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 2.0, precision: 100, @@ -1566,7 +1566,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Radius"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 2.0, precision: 100, @@ -1578,7 +1578,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Offset"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: -2.0, max: 2.0, precision: 100, @@ -1592,7 +1592,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1642,7 +1642,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1654,9 +1654,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("gradient_type"), type: "ENUM", output: 0, - default_value: 0, - // data: ["Linear", "Quadratic", "Easing", "Diagonal", "Radial", "Quadratic Sphere", "Spherical"] - data: [_tr("Linear"), _tr("Diagonal"), _tr("Radial"), _tr("Spherical")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Linear") + "\0" + _tr("Diagonal") + "\0" + _tr("Radial") + "\0" + _tr("Spherical")), min: 0.0, max: 1.0, precision: 100, @@ -1705,7 +1704,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Alpha"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1717,8 +1716,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("File"), type: "ENUM", output: -1, - default_value: 0, - data: "", + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(""), min: 0.0, max: 1.0, precision: 100, @@ -1728,8 +1727,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Color Space"), type: "ENUM", output: -1, - default_value: 0, - data: [_tr("Auto"), _tr("Linear"), _tr("sRGB"), _tr("DirectX Normal Map")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Auto") + "\0" + _tr("Linear") + "\0" + _tr("sRGB") + "\0" + _tr("DirectX Normal Map")), min: 0.0, max: 1.0, precision: 100, @@ -1764,7 +1763,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -1790,7 +1789,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1826,7 +1825,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -1840,7 +1839,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1876,7 +1875,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -1902,7 +1901,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1938,7 +1937,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -1964,7 +1963,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -1976,8 +1975,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("coloring"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Intensity"), _tr("Cells")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Intensity") + "\0" + _tr("Cells")), min: 0.0, max: 1.0, precision: 100, @@ -2012,7 +2011,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Scale"), type: "VALUE", color: 0xffa1a1a1, - default_value: 5.0, + default_value: f32_array_create_x(5.0), min: 0.0, max: 10.0, precision: 100, @@ -2038,7 +2037,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2076,7 +2075,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Strength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -2126,7 +2125,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Bright"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -2138,7 +2137,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Contrast"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -2188,7 +2187,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Gamma"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2226,7 +2225,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Hue"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -2238,7 +2237,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Saturation"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2250,7 +2249,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2262,7 +2261,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2312,7 +2311,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2362,7 +2361,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -2412,8 +2411,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("blend_type"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Mix"), _tr("Darken"), _tr("Multiply"), _tr("Burn"), _tr("Lighten"), _tr("Screen"), _tr("Dodge"), _tr("Add"), _tr("Overlay"), _tr("Soft Light"), _tr("Linear Light"), _tr("Difference"), _tr("Subtract"), _tr("Divide"), _tr("Hue"), _tr("Saturation"), _tr("Color"), _tr("Value")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Mix") + "\0" + _tr("Darken") + "\0" + _tr("Multiply") + "\0" + _tr("Burn") + "\0" + _tr("Lighten") + "\0" + _tr("Screen") + "\0" + _tr("Dodge") + "\0" + _tr("Add") + "\0" + _tr("Overlay") + "\0" + _tr("Soft Light") + "\0" + _tr("Linear Light") + "\0" + _tr("Difference") + "\0" + _tr("Subtract") + "\0" + _tr("Divide") + "\0" + _tr("Hue") + "\0" + _tr("Saturation") + "\0" + _tr("Color") + "\0" + _tr("Value")), min: 0.0, max: 1.0, precision: 100, @@ -2423,7 +2422,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("use_clamp"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -2447,7 +2446,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Stength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.1, + default_value: f32_array_create_x(0.1), min: 0.0, max: 1.0, precision: 100, @@ -2509,7 +2508,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Angle"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 360.0, precision: 100, @@ -2521,7 +2520,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Mask"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -2561,7 +2560,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Strength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2573,7 +2572,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Distance"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -2585,7 +2584,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Height"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2747,8 +2746,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("blend_type"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Partial Derivative"), _tr("Whiteout"), _tr("Reoriented")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Partial Derivative") + "\0" + _tr("Whiteout") + "\0" + _tr("Reoriented")), min: 0.0, max: 1.0, precision: 100, @@ -2797,7 +2796,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Dot"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2833,7 +2832,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Stength"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 2.0, precision: 100, @@ -2883,7 +2882,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2921,7 +2920,8 @@ let nodes_material_list: zui_node_t[][] = [ name: "nodes_material_vector_curves_button", type: "CUSTOM", output: 0, - default_value: [[f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)], [f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)], [f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)]], + // default_value: [[f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)], [f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)], [f32_array_create_xy(0.0, 0.0), f32_array_create_xy(0.0, 0.0)]], + default_value: f32_array_create_from_array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), data: null, min: 0.0, max: 1.0, @@ -2947,7 +2947,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -2959,7 +2959,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Min"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -2971,7 +2971,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Max"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -2985,7 +2985,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -2997,8 +2997,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("operation"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Min Max"), _tr("Range")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Min Max") + "\0" + _tr("Range")), min: 0.0, max: 1.0, precision: 100, @@ -3021,7 +3021,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fac"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -3047,7 +3047,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Alpha"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3059,8 +3059,9 @@ let nodes_material_list: zui_node_t[][] = [ name: "nodes_material_color_ramp_button", type: "CUSTOM", output: 0, - default_value: [f32_array_create_xyzwv(1.0, 1.0, 1.0, 1.0, 0.0)], - data: 0, + // default_value: [f32_array_create_xyzwv(1.0, 1.0, 1.0, 1.0, 0.0)], + default_value: f32_array_create_xyzwv(1.0, 1.0, 1.0, 1.0, 0.0), + data: u8_array_create(1), min: 0.0, max: 1.0, precision: 100, @@ -3107,7 +3108,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Radius"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.1, + default_value: f32_array_create_x(0.1), min: 0.0, max: 1.74, precision: 100, @@ -3119,7 +3120,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Fuzziness"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3133,7 +3134,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Mask"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3157,7 +3158,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("H"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3169,7 +3170,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("S"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3181,7 +3182,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("V"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3219,7 +3220,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("R"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3231,7 +3232,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("G"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3243,7 +3244,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("B"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3281,7 +3282,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("X"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3293,7 +3294,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Y"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3305,7 +3306,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Z"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3343,7 +3344,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -3355,7 +3356,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("From Min"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3367,7 +3368,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("From Max"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -3379,7 +3380,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("To Min"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3391,7 +3392,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("To Max"), type: "VALUE", color: 0xffa1a1a1, - default_value: 1.0, + default_value: f32_array_create_x(1.0), min: 0.0, max: 1.0, precision: 100, @@ -3405,7 +3406,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3417,7 +3418,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("use_clamp"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -3441,7 +3442,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -3453,7 +3454,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.5, + default_value: f32_array_create_x(0.5), min: 0.0, max: 1.0, precision: 100, @@ -3467,7 +3468,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3479,8 +3480,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("operation"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Add"), _tr("Subtract"), _tr("Multiply"), _tr("Divide"), _tr("Power"), _tr("Logarithm"), _tr("Square Root"), _tr("Inverse Square Root"), _tr("Absolute"), _tr("Exponent"), _tr("Minimum"), _tr("Maximum"), _tr("Less Than"), _tr("Greater Than"), _tr("Sign"), _tr("Round"), _tr("Floor"), _tr("Ceil"), _tr("Truncate"), _tr("Fraction"), _tr("Modulo"), _tr("Snap"), _tr("Ping-Pong"), _tr("Sine"), _tr("Cosine"), _tr("Tangent"), _tr("Arcsine"), _tr("Arccosine"), _tr("Arctangent"), _tr("Arctan2"), _tr("Hyperbolic Sine"), _tr("Hyperbolic Cosine"), _tr("Hyperbolic Tangent"), _tr("To Radians"), _tr("To Degrees")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Add") + "\0" + _tr("Subtract") + "\0" + _tr("Multiply") + "\0" + _tr("Divide") + "\0" + _tr("Power") + "\0" + _tr("Logarithm") + "\0" + _tr("Square Root") + "\0" + _tr("Inverse Square Root") + "\0" + _tr("Absolute") + "\0" + _tr("Exponent") + "\0" + _tr("Minimum") + "\0" + _tr("Maximum") + "\0" + _tr("Less Than") + "\0" + _tr("Greater Than") + "\0" + _tr("Sign") + "\0" + _tr("Round") + "\0" + _tr("Floor") + "\0" + _tr("Ceil") + "\0" + _tr("Truncate") + "\0" + _tr("Fraction") + "\0" + _tr("Modulo") + "\0" + _tr("Snap") + "\0" + _tr("Ping-Pong") + "\0" + _tr("Sine") + "\0" + _tr("Cosine") + "\0" + _tr("Tangent") + "\0" + _tr("Arcsine") + "\0" + _tr("Arccosine") + "\0" + _tr("Arctangent") + "\0" + _tr("Arctan2") + "\0" + _tr("Hyperbolic Sine") + "\0" + _tr("Hyperbolic Cosine") + "\0" + _tr("Hyperbolic Tangent") + "\0" + _tr("To Radians") + "\0" + _tr("To Degrees")), min: 0.0, max: 1.0, precision: 100, @@ -3490,7 +3491,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("use_clamp"), type: "BOOL", output: 0, - default_value: false, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -3528,7 +3529,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Val"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3566,7 +3567,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("H"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3578,7 +3579,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("S"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3590,7 +3591,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("V"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3628,7 +3629,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("R"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3640,7 +3641,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("G"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3652,7 +3653,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("B"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3690,7 +3691,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("X"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3702,7 +3703,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Y"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3714,7 +3715,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Z"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3776,7 +3777,7 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("Value"), type: "VALUE", color: 0xffa1a1a1, - default_value: 0.0, + default_value: f32_array_create_x(0.0), min: 0.0, max: 1.0, precision: 100, @@ -3788,8 +3789,8 @@ let nodes_material_list: zui_node_t[][] = [ name: _tr("operation"), type: "ENUM", output: 0, - default_value: 0, - data: [_tr("Add"), _tr("Subtract"), _tr("Multiply"), _tr("Divide"), _tr("Average"), _tr("Cross Product"), _tr("Project"), _tr("Reflect"), _tr("Dot Product"), _tr("Distance"), _tr("Length"), _tr("Scale"), _tr("Normalize"), _tr("Absolute"), _tr("Minimum"), _tr("Maximum"), _tr("Floor"), _tr("Ceil"), _tr("Fraction"), _tr("Modulo"), _tr("Snap"), _tr("Sine"), _tr("Cosine"), _tr("Tangent")], + default_value: f32_array_create_x(0), + data: u8_array_create_from_string(_tr("Add") + "\0" + _tr("Subtract") + "\0" + _tr("Multiply") + "\0" + _tr("Divide") + "\0" + _tr("Average") + "\0" + _tr("Cross Product") + "\0" + _tr("Project") + "\0" + _tr("Reflect") + "\0" + _tr("Dot Product") + "\0" + _tr("Distance") + "\0" + _tr("Length") + "\0" + _tr("Scale") + "\0" + _tr("Normalize") + "\0" + _tr("Absolute") + "\0" + _tr("Minimum") + "\0" + _tr("Maximum") + "\0" + _tr("Floor") + "\0" + _tr("Ceil") + "\0" + _tr("Fraction") + "\0" + _tr("Modulo") + "\0" + _tr("Snap") + "\0" + _tr("Sine") + "\0" + _tr("Cosine") + "\0" + _tr("Tangent")), min: 0.0, max: 1.0, precision: 100, @@ -3814,7 +3815,7 @@ let nodes_material_list: zui_node_t[][] = [ name: "nodes_material_new_group_button", type: "CUSTOM", output: -1, - default_value: null, + default_value: f32_array_create_x(0), data: null, min: 0.0, max: 1.0, @@ -3836,7 +3837,7 @@ function nodes_material_vector_curves_button(ui: zui_t, nodes: zui_nodes_t, node zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 2, "Z"); // Preview let axis: i32 = zui_nest(zui_nest(nhandle, 0), 1).position; - let val: f32_array_t[] = but.default_value[axis]; // [ [[x, y], [x, y], ..], [[x, y]], ..] + let val: f32_array_t[] = null; // but.default_value[axis]; // [ [[x, y], [x, y], ..], [[x, y]], ..] let num: i32 = val.length; // for (let i: i32 = 0; i < num; ++i) { ui.line(); } ui._y += zui_nodes_LINE_H() * 5; @@ -3852,7 +3853,10 @@ function nodes_material_vector_curves_button(ui: zui_t, nodes: zui_nodes_t, node val.pop(); } } - let ihandle: zui_handle_t = zui_nest(zui_nest(zui_nest(nhandle, 0), 2), axis, {position: 0}); + let ihandle: zui_handle_t = zui_nest(zui_nest(zui_nest(nhandle, 0), 2), axis); + if (ihandle.init) { + ihandle.position = 0; + } let i: i32 = math_floor(zui_slider(ihandle, "Index", 0, num - 1, false, 1, true, zui_align_t.LEFT)); if (i >= val.length || i < 0) { ihandle.value = i = val.length - 1; // Stay in bounds @@ -3860,8 +3864,16 @@ function nodes_material_vector_curves_button(ui: zui_t, nodes: zui_nodes_t, node 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, zui_align_t.LEFT); - val[i][1] = zui_slider(zui_nest(zui_nest(nhandle, 0), 4, {value: 0}), "Y", -1, 1, true, 100, true, zui_align_t.LEFT); + let h1: zui_handle_t = zui_nest(zui_nest(nhandle, 0), 3); + if (h1.init) { + h1.value = 0.0; + } + let h2: zui_handle_t = zui_nest(zui_nest(nhandle, 0), 4); + if (h2.init) { + h2.value = 0.0; + } + val[i][0] = zui_slider(h1, "X", -1, 1, true, 100, true, zui_align_t.LEFT); + val[i][1] = zui_slider(h2, "Y", -1, 1, true, 100, true, zui_align_t.LEFT); } function nodes_material_color_ramp_button(ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) { @@ -3871,7 +3883,7 @@ function nodes_material_color_ramp_button(ui: zui_t, nodes: zui_nodes_t, node: z let ny: f32 = ui._y; // Preview - let vals: f32_array_t[] = but.default_value; // [[r, g, b, a, pos], ..] + let vals: f32_array_t[] = null; // but.default_value; // [[r, g, b, a, pos], ..] let sw: f32 = ui._w / zui_nodes_SCALE(); for (let i: i32 = 0; i < vals.length; ++i) { let val: f32_array_t = vals[i]; @@ -3898,7 +3910,8 @@ function nodes_material_color_ramp_button(ui: zui_t, nodes: zui_nodes_t, node: z 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: i32 = math_floor(zui_slider(ihandle, "Index", 0, vals.length - 1, false, 1, true, zui_align_t.LEFT)); diff --git a/base/Sources/parser_logic.ts b/base/Sources/parser_logic.ts index a97add51..8f391f9b 100644 --- a/base/Sources/parser_logic.ts +++ b/base/Sources/parser_logic.ts @@ -111,18 +111,17 @@ function parser_logic_build_node(node: zui_node_t): string { map_set(parser_logic_raw_map, v, node); // Expose button values in node - for (let i: i32 = 0; i < node.buttons.length; ++i) { - let b: zui_node_button_t = node.buttons[i]; - if (b.type == "ENUM") { - // let array_data: bool = is_array(b.data); - let array_data: bool = b.data.length > 1; - let texts: string[] = array_data ? b.data : zui_enum_texts_js(node.type); - v[b.name] = texts[b.default_value]; - } - else { - v[b.name] = b.default_value; - } - } + // for (let i: i32 = 0; i < node.buttons.length; ++i) { + // let b: zui_node_button_t = node.buttons[i]; + // if (b.type == "ENUM") { + // let array_data: bool = b.data.length > 1; + // let texts: string[] = array_data ? b.data : zui_enum_texts_js(node.type); + // v[b.name] = texts[b.default_value]; + // } + // else { + // v[b.name] = b.default_value; + // } + // } // Create inputs let inp_node: logic_node_t = null; @@ -193,19 +192,19 @@ function parser_logic_build_default_node(inp: zui_node_socket_t): logic_node_t { if (inp.type == "VECTOR") { if (inp.default_value == null) { - inp.default_value = [0, 0, 0]; // TODO + inp.default_value = f32_array_create_xyz(0, 0, 0); } v = parser_logic_create_node_instance("vector_node", inp.default_value); } else if (inp.type == "RGBA") { if (inp.default_value == null) { - inp.default_value = [0, 0, 0, 0]; // TODO + inp.default_value = f32_array_create_xyzw(0, 0, 0, 0); } v = parser_logic_create_node_instance("color_node", inp.default_value); } else if (inp.type == "RGB") { if (inp.default_value == null) { - inp.default_value = [0, 0, 0, 0]; // TODO + inp.default_value = f32_array_create_xyzw(0, 0, 0, 0); } v = parser_logic_create_node_instance("color_node", inp.default_value); } diff --git a/base/Sources/parser_material.ts b/base/Sources/parser_material.ts index 7de166e9..6ec95aba 100644 --- a/base/Sources/parser_material.ts +++ b/base/Sources/parser_material.ts @@ -446,7 +446,7 @@ function parser_material_parse_vector_input(inp: zui_node_socket_t): string { } else { if (inp.type == "VALUE") { // Unlinked reroute - return parser_material_vec3([0.0, 0.0, 0.0]); + return parser_material_vec3(f32_array_create_xyz(0.0, 0.0, 0.0)); } else { return parser_material_vec3(inp.default_value); @@ -511,7 +511,7 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ else if (node.type == "TEX_GRADIENT") { let co: string = parser_material_get_coord(node); let but: zui_node_button_t = node.buttons[0]; //gradient_type; - let grad: string = but.data[but.default_value].toUpperCase(); + let grad: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); grad = string_replace_all(grad, " ", "_"); let f: string = parser_material_get_gradient(grad, co); let res: string = parser_material_to_vec3("clamp(" + f + ", 0.0, 1.0)"); @@ -526,7 +526,7 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ let tex_name: string = parser_material_node_name(node); let tex: bind_tex_t = parser_material_make_texture(node, tex_name); if (tex != null) { - let color_space: i32 = node.buttons[1].default_value; + let color_space: i32 = node.buttons[1].default_value[0]; let texstore: string = parser_material_texture_store(node, tex, tex_name, color_space); return texstore + ".rgb"; } @@ -556,7 +556,7 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ let co: string = parser_material_get_coord(node); let scale: string = parser_material_parse_value_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; //coloring; - let coloring: string = but.data[but.default_value].toUpperCase(); + let coloring: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); coloring = string_replace_all(coloring, " ", "_"); let res: string = ""; if (coloring == "INTENSITY") { @@ -642,9 +642,9 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ let col1: string = parser_material_parse_vector_input(node.inputs[1]); let col2: string = parser_material_parse_vector_input(node.inputs[2]); let but: zui_node_button_t = node.buttons[0]; // blend_type - let blend: string = but.data[but.default_value].toUpperCase(); + let blend: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); blend = string_replace_all(blend, " ", "_"); - let use_clamp: bool = node.buttons[1].default_value == true; + let use_clamp: bool = node.buttons[1].default_value[0] > 0; let out_col: string = ""; if (blend == "MIX") { out_col = "mix(" + col1 + ", " + col2 + ", " + fac_var + ")"; @@ -724,16 +724,16 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ } else if (node.type == "VALTORGB") { // ColorRamp let fac: string = parser_material_parse_value_input(node.inputs[0]); - let interp: string = node.buttons[0].data == 0 ? "LINEAR" : "CONSTANT"; - let elems: f32[][] = node.buttons[0].default_value; + let interp: string = node.buttons[0].data[0] == 0 ? "LINEAR" : "CONSTANT"; + let elems: f32[][] = null; //node.buttons[0].default_value; if (elems.length == 1) { - return parser_material_vec3(elems[0]); + // return parser_material_vec3(elems[0]); } // Write cols array let cols_var: string = parser_material_node_name(node) + "_cols"; node_shader_write(parser_material_curshader, "vec3 " + cols_var + "[" + elems.length + "];"); // TODO: Make const for (let i: i32 = 0; i < elems.length; ++i) { - node_shader_write(parser_material_curshader, cols_var + "[" + i + "] = " + parser_material_vec3(elems[i]) + ";"); + // node_shader_write(parser_material_curshader, cols_var + "[" + i + "] = " + parser_material_vec3(elems[i]) + ";"); } // Get index let fac_var: string = parser_material_node_name(node) + "_fac"; @@ -1001,7 +1001,7 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ let nm1: string = parser_material_parse_vector_input(node.inputs[0]); let nm2: string = parser_material_parse_vector_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; - let blend: string = but.data[but.default_value].toUpperCase(); // blend_type + let blend: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); // blend_type blend = string_replace_all(blend, " ", "_"); let store: string = parser_material_store_var_name(node); @@ -1040,7 +1040,7 @@ function parser_material_parse_vector(node: zui_node_t, socket: zui_node_socket_ let vec1: string = parser_material_parse_vector_input(node.inputs[0]); let vec2: string = parser_material_parse_vector_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; //operation; - let op: string = but.data[but.default_value].toUpperCase(); + let op: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); op = string_replace_all(op, " ", "_"); if (op == "ADD") { return "(" + vec1 + " + " + vec2 + ")"; @@ -1170,7 +1170,7 @@ function parser_material_parse_value_input(inp: zui_node_socket_t, vector_as_gra } } else { - return parser_material_vec1(inp.default_value); + return parser_material_vec1(inp.default_value[0]); } } @@ -1351,7 +1351,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t } } else if (node.type == "VALUE") { - return parser_material_vec1(node.outputs[0].default_value); + return parser_material_vec1(node.outputs[0].default_value[0]); } else if (node.type == "TEX_BRICK") { node_shader_add_function(parser_material_curshader, str_tex_brick); @@ -1370,7 +1370,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t else if (node.type == "TEX_GRADIENT") { let co: string = parser_material_get_coord(node); let but: zui_node_button_t = node.buttons[0]; //gradient_type; - let grad: string = but.data[but.default_value].toUpperCase(); + let grad: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); grad = string_replace_all(grad, " ", "_"); let f: string = parser_material_get_gradient(grad, co); let res: string = "(clamp(" + f + ", 0.0, 1.0))"; @@ -1385,7 +1385,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let tex_name: string = parser_material_node_name(node); let tex: bind_tex_t = parser_material_make_texture(node, tex_name); if (tex != null) { - let color_space: i32 = node.buttons[1].default_value; + let color_space: i32 = node.buttons[1].default_value[0]; let texstore: string = parser_material_texture_store(node, tex, tex_name, color_space); return texstore + ".a"; } @@ -1417,7 +1417,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let co: string = parser_material_get_coord(node); let scale: string = parser_material_parse_value_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; // coloring - let coloring: string = but.data[but.default_value].toUpperCase(); + let coloring: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); coloring = string_replace_all(coloring, " ", "_"); let res: string = ""; if (coloring == "INTENSITY") { @@ -1464,9 +1464,9 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let val1: string = parser_material_parse_value_input(node.inputs[0]); let val2: string = parser_material_parse_value_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; // operation - let op: string = but.data[but.default_value].toUpperCase(); + let op: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); op = string_replace_all(op, " ", "_"); - let use_clamp: bool = node.buttons[1].default_value == true; + let use_clamp: bool = node.buttons[1].default_value[0] > 0; let out_val: string = ""; if (op == "ADD") { out_val = "(" + val1 + " + " + val2 + ")"; @@ -1640,7 +1640,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let vec1: string = parser_material_parse_vector_input(node.inputs[0]); let vec2: string = parser_material_parse_vector_input(node.inputs[1]); let but: zui_node_button_t = node.buttons[0]; //operation; - let op: string = but.data[but.default_value].toUpperCase(); + let op: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); op = string_replace_all(op, " ", "_"); if (op == "DOT_PRODUCT") { return "dot(" + vec1 + ", " + vec2 + ")"; @@ -1660,7 +1660,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let min: string = parser_material_parse_value_input(node.inputs[1]); let max: string = parser_material_parse_value_input(node.inputs[2]); let but: zui_node_button_t = node.buttons[0]; //operation; - let op: string = but.data[but.default_value].toUpperCase(); + let op: string = to_upper_case(u8_array_string_at(but.data, but.default_value[0])); op = string_replace_all(op, " ", "_"); if (op == "MIN_MAX") { @@ -1677,7 +1677,7 @@ function parser_material_parse_value(node: zui_node_t, socket: zui_node_socket_t let tmin: string = parser_material_parse_value_input(node.inputs[3]); let tmax: string = parser_material_parse_value_input(node.inputs[4]); - let use_clamp: bool = node.buttons[0].default_value == true; + let use_clamp: bool = node.buttons[0].default_value[0] > 0; let a: string = "((" + tmin + " - " + tmax + ") / (" + fmin + " - " + fmax + "))"; let out_val: string = "(" + a + " * " + val + " + " + tmin + " - " + a + " * " + fmin + ")"; @@ -1858,7 +1858,7 @@ function parser_material_vec1(v: f32): string { ///end } -function parser_material_vec3(v: f32[]): string { +function parser_material_vec3(v: f32_array_t): string { ///if krom_android return "vec3(float(" + v[0] + "), float(" + v[1] + "), float(" + v[2] + "))"; ///else @@ -1937,7 +1937,7 @@ function parser_material_enum_data(s: string): string { } function parser_material_make_texture(image_node: zui_node_t, tex_name: string, matname: string = null): bind_tex_t { - let filepath: string = parser_material_enum_data(base_enum_texts(image_node.type)[image_node.buttons[0].default_value]); + let filepath: string = parser_material_enum_data(base_enum_texts(image_node.type)[image_node.buttons[0].default_value[0]]); if (filepath == "" || string_index_of(filepath, ".") == -1) { return null; } @@ -1981,6 +1981,12 @@ function parser_material_safestr(s: string): string { return s; } +function u8_array_string_at(a: u8_array_t, i: i32): string { + let s: string = u8_array_to_string(a); + let ss: string[] = string_split(s, "\0"); + return ss[i]; +} + type shader_out_t = { out_basecol?: string; out_roughness?: string; diff --git a/base/Sources/project.ts b/base/Sources/project.ts index b2bf3578..269429c6 100644 --- a/base/Sources/project.ts +++ b/base/Sources/project.ts @@ -103,8 +103,17 @@ function project_new_box() { } zui_row([0.5, 0.5]); - context_raw.project_type = zui_combo(zui_handle(__ID__, { position: context_raw.project_type }), project_mesh_list, tr("Template"), true); - context_raw.project_aspect_ratio = zui_combo(zui_handle(__ID__, { position: context_raw.project_aspect_ratio }), ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true); + let h_project_type: zui_handle_t = zui_handle(__ID__); + if (h_project_type.init) { + h_project_type.position = context_raw.project_type; + } + context_raw.project_type = zui_combo(h_project_type, project_mesh_list, tr("Template"), true); + + let h_project_aspect_ratio: zui_handle_t = zui_handle(__ID__); + if (h_project_aspect_ratio.init) { + h_project_aspect_ratio.position = context_raw.project_aspect_ratio; + } + context_raw.project_aspect_ratio = zui_combo(h_project_aspect_ratio, ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true); zui_end_element(); zui_row([0.5, 0.5]); @@ -358,7 +367,7 @@ function project_import_brush() { let n: zui_node_t = nodes_brush_create_node("TEX_IMAGE"); n.x = 83; n.y = 340; - n.buttons[0].default_value = asset_index; + n.buttons[0].default_value = f32_array_create_x(asset_index); let links: zui_node_link_t[] = context_raw.brush.canvas.links; array_push(links, { id: zui_get_link_id(links), @@ -439,7 +448,11 @@ function project_import_mesh_box(path: string, replace_existing: bool = true, cl ///if (is_paint || is_sculpt) // if (ends_with(to_lower_case(path), ".fbx") || ends_with(to_lower_case(path), ".blend")) { if (ends_with(to_lower_case(path), ".blend")) { - context_raw.parse_vcols = zui_check(zui_handle(__ID__, { selected: context_raw.parse_vcols }), tr("Parse Vertex Colors")); + let h: zui_handle_t = zui_handle(__ID__); + if (h.init) { + h.selected = context_raw.parse_vcols; + } + context_raw.parse_vcols = zui_check(h, tr("Parse Vertex Colors")); if (ui.is_hovered) { zui_tooltip(tr("Import vertex color data")); } diff --git a/base/Sources/tab_materials.ts b/base/Sources/tab_materials.ts index 00f77cc6..27b3eeef 100644 --- a/base/Sources/tab_materials.ts +++ b/base/Sources/tab_materials.ts @@ -193,15 +193,51 @@ function tab_materials_draw_slots(mini: bool) { tab_materials_delete_material(m); } - let base_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_base}); - let opac_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_opac}); - let nor_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_nor}); - let occ_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_occ}); - let rough_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_rough}); - let met_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_met}); - let height_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_height}); - let emis_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_emis}); - let subs_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id, {selected: m.paint_subs}); + let base_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (base_handle.init) { + base_handle.selected = m.paint_base; + } + + let opac_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (opac_handle.init) { + opac_handle.selected = m.paint_opac; + } + + let nor_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (nor_handle.init) { + nor_handle.selected = m.paint_nor; + } + + let occ_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (occ_handle.init) { + occ_handle.selected = m.paint_occ; + } + + let rough_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (rough_handle.init) { + rough_handle.selected = m.paint_rough; + } + + let met_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (met_handle.init) { + met_handle.selected = m.paint_met; + } + + let height_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (height_handle.init) { + height_handle.selected = m.paint_height; + } + + let emis_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (emis_handle.init) { + emis_handle.selected = m.paint_emis; + } + + let subs_handle: zui_handle_t = zui_nest(zui_handle(__ID__), m.id); + if (subs_handle.init) { + subs_handle.selected = m.paint_subs; + } + ui_menu_fill(ui); m.paint_base = zui_check(base_handle, tr("Base Color")); ui_menu_fill(ui); @@ -306,11 +342,11 @@ function tab_materials_update_material_pointers(nodes: zui_node_t[], i: i32) { for (let i: i32 = 0; i < nodes.length; ++i) { let n: zui_node_t = nodes[i]; if (n.type == "MATERIAL") { - if (n.buttons[0].default_value == i) { - n.buttons[0].default_value = 9999; // Material deleted + if (n.buttons[0].default_value[0] == i) { + n.buttons[0].default_value[0] = 9999; // Material deleted } - else if (n.buttons[0].default_value > i) { - n.buttons[0].default_value--; // Offset by deleted material + else if (n.buttons[0].default_value[0] > i) { + n.buttons[0].default_value[0]--; // Offset by deleted material } } } @@ -321,19 +357,19 @@ function tab_materials_accept_swatch_drag(swatch: swatch_color_t) { for (let i: i32 = 0; i < context_raw.material.canvas.nodes.length; ++i) { let node: zui_node_t = context_raw.material.canvas.nodes[i]; if (node.type == "RGB" ) { - node.outputs[0].default_value = [ + node.outputs[0].default_value = f32_array_create_xyzw( color_get_rb(swatch.base) / 255, color_get_gb(swatch.base) / 255, color_get_bb(swatch.base) / 255, color_get_ab(swatch.base) / 255 - ]; + ); } else if (node.type == "OUTPUT_MATERIAL_PBR") { - node.inputs[1].default_value = swatch.opacity; - node.inputs[2].default_value = swatch.occlusion; - node.inputs[3].default_value = swatch.roughness; - node.inputs[4].default_value = swatch.metallic; - node.inputs[7].default_value = swatch.height; + node.inputs[1].default_value[0] = swatch.opacity; + node.inputs[2].default_value[0] = swatch.occlusion; + node.inputs[3].default_value[0] = swatch.roughness; + node.inputs[4].default_value[0] = swatch.metallic; + node.inputs[7].default_value[0] = swatch.height; } } array_push(project_materials, context_raw.material); diff --git a/base/Sources/tab_textures.ts b/base/Sources/tab_textures.ts index 333d4d36..ebd52ca9 100644 --- a/base/Sources/tab_textures.ts +++ b/base/Sources/tab_textures.ts @@ -253,11 +253,11 @@ function tab_textures_update_texture_pointers(nodes: zui_node_t[], i: i32) { for (let i: i32 = 0; i < nodes.length; ++i) { let n: zui_node_t = nodes[i]; if (n.type == "TEX_IMAGE") { - if (n.buttons[0].default_value == i) { - n.buttons[0].default_value = 9999; // Texture deleted, use pink now + if (n.buttons[0].default_value[0] == i) { + n.buttons[0].default_value[0] = 9999; // Texture deleted, use pink now } - else if (n.buttons[0].default_value > i) { - n.buttons[0].default_value--; // Offset by deleted texture + else if (n.buttons[0].default_value[0] > i) { + n.buttons[0].default_value[0]--; // Offset by deleted texture } } } diff --git a/base/Sources/ui_header.ts b/base/Sources/ui_header.ts index eb53a72e..7d6a7931 100644 --- a/base/Sources/ui_header.ts +++ b/base/Sources/ui_header.ts @@ -1,11 +1,11 @@ let ui_header_default_h: i32 = 28; let ui_header_h: i32 = ui_header_default_h; -let ui_header_handle: zui_handle_t = zui_handle_create({ layout: zui_layout_t.HORIZONTAL }); +let ui_header_handle: zui_handle_t = zui_handle_create(); let ui_header_worktab: zui_handle_t = zui_handle_create(); function ui_header_init() { - + ui_header_handle.layout = zui_layout_t.HORIZONTAL; } function ui_header_render_ui() { @@ -171,7 +171,11 @@ function ui_header_draw_tool_properties(ui: zui_t) { zui_text(tr("Metallic") + " (" + metallic_picked + ")"); zui_text(tr("Height") + " (" + height_picked + ")"); zui_text(tr("Opacity") + " (" + opacity_picked + ")"); - context_raw.picker_select_material = zui_check(zui_handle(__ID__, { selected: context_raw.picker_select_material }), tr("Select Material")); + let h_select_mat: zui_handle_t = zui_handle(__ID__); + if (h_select_mat.init) { + h_select_mat.selected = context_raw.picker_select_material; + } + context_raw.picker_select_material = zui_check(h_select_mat, tr("Select Material")); zui_combo(context_raw.picker_mask_handle, [tr("None"), tr("Material")], tr("Mask"), true); if (context_raw.picker_mask_handle.changed) { make_material_parse_paint_material(); @@ -205,7 +209,10 @@ function ui_header_draw_tool_properties(ui: zui_t) { ///end } - let bake_handle: zui_handle_t = zui_handle(__ID__, { position: context_raw.bake_type }); + let bake_handle: zui_handle_t = zui_handle(__ID__); + if (bake_handle.init) { + bake_handle.position = context_raw.bake_type; + } let bakes: string[] = [ tr("AO"), tr("Curvature"), @@ -240,25 +247,43 @@ function ui_header_draw_tool_properties(ui: zui_t) { ///if (krom_direct3d12 || krom_vulkan || krom_metal) if (rt_bake) { - let samples_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_samples }); + let samples_handle: zui_handle_t = zui_handle(__ID__); + if (samples_handle.init) { + samples_handle.value = context_raw.bake_samples; + } context_raw.bake_samples = math_floor(zui_slider(samples_handle, tr("Samples"), 1, 512, true, 1)); } ///end if (context_raw.bake_type == bake_type_t.NORMAL_OBJECT || context_raw.bake_type == bake_type_t.POSITION || context_raw.bake_type == bake_type_t.BENT_NORMAL) { - let bake_up_axis_handle: zui_handle_t = zui_handle(__ID__, { position: context_raw.bake_up_axis }); + let bake_up_axis_handle: zui_handle_t = zui_handle(__ID__); + if (bake_up_axis_handle.init) { + bake_up_axis_handle.position = context_raw.bake_up_axis; + } context_raw.bake_up_axis = zui_combo(bake_up_axis_handle, [tr("Z"), tr("Y")], tr("Up Axis"), true); } if (context_raw.bake_type == bake_type_t.AO || context_raw.bake_type == bake_type_t.CURVATURE) { - let bake_axis_handle: zui_handle_t = zui_handle(__ID__, { position: context_raw.bake_axis }); + let bake_axis_handle: zui_handle_t = zui_handle(__ID__); + if (bake_axis_handle.init) { + bake_axis_handle.position = context_raw.bake_axis; + } context_raw.bake_axis = zui_combo(bake_axis_handle, [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")], tr("Axis"), true); } if (context_raw.bake_type == bake_type_t.AO) { - let strength_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_ao_strength }); + let strength_handle: zui_handle_t = zui_handle(__ID__); + if (strength_handle.init) { + strength_handle.value = context_raw.bake_ao_strength; + } context_raw.bake_ao_strength = zui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true); - let radius_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_ao_radius }); + let radius_handle: zui_handle_t = zui_handle(__ID__); + if (radius_handle.init) { + radius_handle.value = context_raw.bake_ao_radius; + } context_raw.bake_ao_radius = zui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true); - let offset_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_ao_offset }); + let offset_handle: zui_handle_t = zui_handle(__ID__); + if (offset_handle.init) { + offset_handle.value = context_raw.bake_ao_offset; + } context_raw.bake_ao_offset = zui_slider(offset_handle, tr("Offset"), 0.0, 2.0, true); } ///if (krom_direct3d12 || krom_vulkan || krom_metal) @@ -277,13 +302,25 @@ function ui_header_draw_tool_properties(ui: zui_t) { } ///end if (context_raw.bake_type == bake_type_t.CURVATURE) { - let strength_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_curv_strength }); + let strength_handle: zui_handle_t = zui_handle(__ID__); + if (strength_handle.init) { + strength_handle.value = context_raw.bake_curv_strength; + } context_raw.bake_curv_strength = zui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true); - let radius_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_curv_radius }); + let radius_handle: zui_handle_t = zui_handle(__ID__); + if (radius_handle.init) { + radius_handle.value = context_raw.bake_curv_radius; + } context_raw.bake_curv_radius = zui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true); - let offset_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_curv_offset }); + let offset_handle: zui_handle_t = zui_handle(__ID__); + if (offset_handle.init) { + offset_handle.value = context_raw.bake_curv_offset; + } context_raw.bake_curv_offset = zui_slider(offset_handle, tr("Offset"), -2.0, 2.0, true); - let smooth_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.bake_curv_smooth }); + let smooth_handle: zui_handle_t = zui_handle(__ID__); + if (smooth_handle.init) { + smooth_handle.value = context_raw.bake_curv_smooth; + } context_raw.bake_curv_smooth = math_floor(zui_slider(smooth_handle, tr("Smooth"), 0, 5, false, 1)); } if (context_raw.bake_type == bake_type_t.NORMAL || context_raw.bake_type == bake_type_t.HEIGHT || context_raw.bake_type == bake_type_t.DERIVATIVE) { @@ -292,7 +329,10 @@ function ui_header_draw_tool_properties(ui: zui_t) { let p: mesh_object_t = project_paint_objects[i]; array_push(ar, p.base.name); } - let poly_handle: zui_handle_t = zui_handle(__ID__, { position: context_raw.bake_high_poly }); + let poly_handle: zui_handle_t = zui_handle(__ID__); + if (poly_handle.init) { + poly_handle.position = context_raw.bake_high_poly; + } context_raw.bake_high_poly = zui_combo(poly_handle, ar, tr("High Poly")); } if (ui.changed) { @@ -342,7 +382,10 @@ function ui_header_draw_tool_properties(ui: zui_t) { context_raw.tool == workspace_tool_t.FILL || context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) { - let brush_scale_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.brush_scale }); + let brush_scale_handle: zui_handle_t = zui_handle(__ID__); + if (brush_scale_handle.init) { + brush_scale_handle.value = context_raw.brush_scale; + } context_raw.brush_scale = zui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true); if (brush_scale_handle.changed) { if (context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) { @@ -373,11 +416,18 @@ function ui_header_draw_tool_properties(ui: zui_t) { } if (context_raw.tool == workspace_tool_t.BRUSH || context_raw.tool == workspace_tool_t.ERASER || context_raw.tool == workspace_tool_t.CLONE || decal_mask) { - context_raw.brush_hardness = zui_slider(zui_handle(__ID__, { value: context_raw.brush_hardness }), tr("Hardness"), 0.0, 1.0, true); + let h: zui_handle_t = zui_handle(__ID__); + if (h.init) { + h.value = context_raw.brush_hardness; + } + context_raw.brush_hardness = zui_slider(h, tr("Hardness"), 0.0, 1.0, true); } if (context_raw.tool != workspace_tool_t.ERASER) { - let brush_blending_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.brush_blending }); + let brush_blending_handle: zui_handle_t = zui_handle(__ID__); + if (brush_blending_handle.init) { + brush_blending_handle.value = context_raw.brush_blending; + } context_raw.brush_blending = zui_combo(brush_blending_handle, [ tr("Mix"), tr("Darken"), @@ -454,15 +504,27 @@ function ui_header_draw_tool_properties(ui: zui_t) { } ui._w = math_floor((touch_header ? 54 : 60) * sc); - let xray_handle: zui_handle_t = zui_handle(__ID__, { selected: context_raw.xray }); + let xray_handle: zui_handle_t = zui_handle(__ID__); + if (xray_handle.init) { + xray_handle.selected = context_raw.xray; + } context_raw.xray = zui_check(xray_handle, tr("X-Ray")); if (xray_handle.changed) { make_material_parse_paint_material(); } - let sym_x_handle: zui_handle_t = zui_handle(__ID__, { selected: false }); - let sym_y_handle: zui_handle_t = zui_handle(__ID__, { selected: false }); - let sym_z_handle: zui_handle_t = zui_handle(__ID__, { selected: false }); + let sym_x_handle: zui_handle_t = zui_handle(__ID__); + if (sym_x_handle.init) { + sym_x_handle.selected = false; + } + let sym_y_handle: zui_handle_t = zui_handle(__ID__); + if (sym_y_handle.init) { + sym_y_handle.selected = false; + } + let sym_z_handle: zui_handle_t = zui_handle(__ID__); + if (sym_z_handle.init) { + sym_z_handle.selected = false; + } if (config_raw.layout[layout_size_t.HEADER] == 1) { if (config_raw.touch_ui) { @@ -502,7 +564,10 @@ function ui_header_draw_tool_properties(ui: zui_t) { ///if arm_physics if (context_raw.tool == workspace_tool_t.PARTICLE) { ui._x += 10 * zui_SCALE(ui); - let phys_handle: zui_handle_t = zui_handle(__ID__, { selected: false }); + let phys_handle: zui_handle_t = zui_handle(__ID__); + if (phys_handle.init) { + phys_handle.selected = false; + } context_raw.particle_physics = zui_check(phys_handle, tr("Physics")); if (phys_handle.changed) { util_particle_init_physics(); diff --git a/base/Sources/ui_menu.ts b/base/Sources/ui_menu.ts index 41810170..358000f2 100644 --- a/base/Sources/ui_menu.ts +++ b/base/Sources/ui_menu.ts @@ -245,7 +245,10 @@ function ui_menu_render() { ///if (is_paint || is_sculpt) ui_menu_fill(ui); - let split_view_handle: zui_handle_t = zui_handle(__ID__, { selected: context_raw.split_view }); + let split_view_handle = zui_handle(__ID__); + if (split_view_handle.init) { + split_view_handle.selected = context_raw.split_view; + } context_raw.split_view = zui_check(split_view_handle, " " + tr("Split View")); if (split_view_handle.changed) { base_resize(); @@ -254,7 +257,10 @@ function ui_menu_render() { ///if is_lab ui_menu_fill(ui); - let brush_scale_handle: zui_handle_t = zui_handle(__ID__, { value: context_raw.brush_scale }); + let brush_scale_handle: zui_handle_t = zui_handle(__ID__); + if (brush_scale_handle.init) { + brush_scale_handle.value = context_raw.brush_scale; + } ui_menu_align(ui); context_raw.brush_scale = zui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true); if (brush_scale_handle.changed) { @@ -267,14 +273,20 @@ function ui_menu_render() { ///end ui_menu_fill(ui); - let cull_handle: zui_handle_t = zui_handle(__ID__, { selected: context_raw.cull_backfaces }); + let cull_handle: zui_handle_t = zui_handle(__ID__); + if (cull_handle.init) { + cull_handle.selected = context_raw.cull_backfaces; + } context_raw.cull_backfaces = zui_check(cull_handle, " " + tr("Cull Backfaces")); if (cull_handle.changed) { make_material_parse_mesh_material(); } ui_menu_fill(ui); - let filter_handle: zui_handle_t = zui_handle(__ID__, { selected: context_raw.texture_filter }); + let filter_handle: zui_handle_t = zui_handle(__ID__); + if (filter_handle.init) { + filter_handle.selected = context_raw.texture_filter; + } context_raw.texture_filter = zui_check(filter_handle, " " + tr("Filter Textures")); if (filter_handle.changed) { make_material_parse_paint_material(); @@ -302,7 +314,10 @@ function ui_menu_render() { ///end ui_menu_fill(ui); - let compass_handle: zui_handle_t = zui_handle(__ID__, { selected: context_raw.show_compass }); + let compass_handle: zui_handle_t = zui_handle(__ID__); + if (compass_handle.init) { + compass_handle.selected = context_raw.show_compass; + } context_raw.show_compass = zui_check(compass_handle, " " + tr("Compass")); if (compass_handle.changed) { context_raw.ddirty = 2; @@ -430,7 +445,10 @@ function ui_menu_render() { ui_menu_fill(ui); let cam: camera_object_t = scene_camera; - context_raw.fov_handle = zui_handle(__ID__, { value: math_floor(cam.data.fov * 100) / 100 }); + context_raw.fov_handle = zui_handle(__ID__); + if (context_raw.fov_handle.init) { + context_raw.fov_handle.value = math_floor(cam.data.fov * 100) / 100; + } ui_menu_align(ui); cam.data.fov = zui_slider(context_raw.fov_handle, tr("FoV"), 0.3, 1.4, true); if (context_raw.fov_handle.changed) { @@ -570,7 +588,11 @@ function ui_menu_render() { zui_image(img); zui_end_element(); - zui_text_area(zui_handle(__ID__, { text: _ui_menu_render_msg }), zui_align_t.LEFT, false); + let h: zui_handle_t = zui_handle(__ID__); + if (h.init) { + h.text = _ui_menu_render_msg; + } + zui_text_area(h, zui_align_t.LEFT, false); zui_row([1 / 3, 1 / 3, 1 / 3]); diff --git a/base/Sources/ui_menubar.ts b/base/Sources/ui_menubar.ts index cc315d9e..ebc8575f 100644 --- a/base/Sources/ui_menubar.ts +++ b/base/Sources/ui_menubar.ts @@ -1,7 +1,7 @@ let ui_menubar_default_w: i32 = 330; -let ui_menubar_workspace_handle: zui_handle_t = zui_handle_create({ layout: zui_layout_t.HORIZONTAL }); -let ui_menubar_menu_handle: zui_handle_t = zui_handle_create({ layout: zui_layout_t.HORIZONTAL }); +let ui_menubar_workspace_handle: zui_handle_t = zui_handle_create(); +let ui_menubar_menu_handle: zui_handle_t = zui_handle_create(); let ui_menubar_w: i32 = ui_menubar_default_w; ///if is_lab @@ -10,6 +10,8 @@ let _ui_menubar_plane: mesh_object_t = null; ///end function ui_menubar_init() { + ui_menubar_workspace_handle.layout = zui_layout_t.HORIZONTAL; + ui_menubar_menu_handle.layout = zui_layout_t.HORIZONTAL; } function ui_menubar_render_ui() { diff --git a/base/Sources/ui_nodes.ts b/base/Sources/ui_nodes.ts index 1f9b56f1..1ce5781e 100644 --- a/base/Sources/ui_nodes.ts +++ b/base/Sources/ui_nodes.ts @@ -149,7 +149,7 @@ function ui_nodes_on_socket_released(socket_id: i32) { } } else { - _ui_nodes_hval0.value = socket.default_value; + _ui_nodes_hval0.value = socket.default_value[0]; } app_notify_on_next_frame(function () { @@ -1308,7 +1308,7 @@ function ui_nodes_accept_asset_drag(index: i32) { let n: zui_node_t = nodes_brush_create_node("ImageTextureNode"); ///end - n.buttons[0].default_value = index; + n.buttons[0].default_value[0] = index; ui_nodes_get_nodes().nodes_selected_id = [n.id]; ///if is_lab @@ -1324,7 +1324,7 @@ function ui_nodes_accept_layer_drag(index: i32) { } let g: node_group_t = ui_nodes_group_stack.length > 0 ? ui_nodes_group_stack[ui_nodes_group_stack.length - 1] : null; let n: zui_node_t = nodes_material_create_node(slot_layer_is_mask(context_raw.layer) ? "LAYER_MASK" : "LAYER", g); - n.buttons[0].default_value = index; + n.buttons[0].default_value[0] = index; ui_nodes_get_nodes().nodes_selected_id = [n.id]; } @@ -1332,7 +1332,7 @@ function ui_nodes_accept_material_drag(index: i32) { ui_nodes_push_undo(); let g: node_group_t = ui_nodes_group_stack.length > 0 ? ui_nodes_group_stack[ui_nodes_group_stack.length - 1] : null; let n: zui_node_t = nodes_material_create_node("MATERIAL", g); - n.buttons[0].default_value = index; + n.buttons[0].default_value[0] = index; ui_nodes_get_nodes().nodes_selected_id = [n.id]; } ///end @@ -1342,34 +1342,76 @@ function ui_nodes_accept_swatch_drag(swatch: swatch_color_t) { ui_nodes_push_undo(); let g: node_group_t = ui_nodes_group_stack.length > 0 ? ui_nodes_group_stack[ui_nodes_group_stack.length - 1] : null; let n: zui_node_t = nodes_material_create_node("RGB", g); - n.outputs[0].default_value = [ + n.outputs[0].default_value = f32_array_create_xyzw( color_get_rb(swatch.base) / 255, color_get_gb(swatch.base) / 255, color_get_bb(swatch.base) / 255, color_get_ab(swatch.base) / 255 - ]; + ); ui_nodes_get_nodes().nodes_selected_id = [n.id]; ///end } function ui_nodes_make_node(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)); + let node: zui_node_t = {}; node.id = zui_get_node_id(canvas.nodes); + node.name = n.name; + node.type = n.type; node.x = ui_nodes_get_node_x(); node.y = ui_nodes_get_node_y(); + node.color = n.color; + node.inputs = []; + node.outputs = []; + node.buttons = []; + node.width = 0; + let count: i32 = 0; - for (let i: i32 = 0; i < node.inputs.length; ++i) { - let soc: zui_node_socket_t = node.inputs[i]; + for (let i: i32 = 0; i < n.inputs.length; ++i) { + let soc: zui_node_socket_t = {} soc.id = zui_get_socket_id(canvas.nodes) + count; - soc.node_id = node.id; count++; + soc.node_id = node.id; + soc.name = n.inputs[i].name; + soc.type = n.inputs[i].type; + soc.color = n.inputs[i].color; + soc.default_value = n.inputs[i].default_value; + soc.min = n.inputs[i].min; + soc.max = n.inputs[i].max; + soc.precision = n.inputs[i].precision; + soc.display = n.inputs[i].display; + array_push(node.inputs, soc); } - for (let i: i32 = 0; i < node.outputs.length; ++i) { - let soc: zui_node_socket_t = node.outputs[i]; + + for (let i: i32 = 0; i < n.outputs.length; ++i) { + let soc: zui_node_socket_t = {}; soc.id = zui_get_socket_id(canvas.nodes) + count; - soc.node_id = node.id; count++; + soc.node_id = node.id; + soc.name = n.outputs[i].name; + soc.type = n.outputs[i].type; + soc.color = n.outputs[i].color; + soc.default_value = n.outputs[i].default_value; + soc.min = n.outputs[i].min; + soc.max = n.outputs[i].max; + soc.precision = n.outputs[i].precision; + soc.display = n.outputs[i].display; + array_push(node.outputs, soc); } + + for (let i: i32 = 0; i < n.buttons.length; ++i) { + let but: zui_node_button_t = {}; + but.name = n.buttons[i].name; + but.type = n.buttons[i].type; + but.output = n.buttons[i].output; + but.default_value = n.buttons[i].default_value; + but.data = n.buttons[i].data; + but.min = n.buttons[i].min; + but.max = n.buttons[i].max; + but.precision = n.buttons[i].precision; + but.height = n.buttons[i].height; + array_push(node.buttons, but); + } + return node; } diff --git a/base/Sources/ui_view2d.ts b/base/Sources/ui_view2d.ts index 86b03852..87901967 100644 --- a/base/Sources/ui_view2d.ts +++ b/base/Sources/ui_view2d.ts @@ -351,7 +351,11 @@ function ui_view2d_render() { ///if (is_paint || is_sculpt) if (ui_view2d_type == view_2d_type_t.LAYER) { - ui_view2d_layer_mode = zui_combo(zui_handle(__ID__, { position: ui_view2d_layer_mode }), [ + let h_layer_mode: zui_handle_t = zui_handle(__ID__); + if (h_layer_mode.init) { + h_layer_mode.position = ui_view2d_layer_mode; + } + ui_view2d_layer_mode = zui_combo(h_layer_mode, [ tr("Visible"), tr("Selected"), ], tr("Layers")); @@ -359,7 +363,11 @@ function ui_view2d_render() { ui_view2d_ui._y = 2 + start_y; if (!slot_layer_is_mask(context_raw.layer)) { - ui_view2d_tex_type = zui_combo(zui_handle(__ID__, { position: ui_view2d_tex_type }), [ + let h_tex_type: zui_handle_t = zui_handle(__ID__); + if (h_tex_type.init) { + h_tex_type.position = ui_view2d_tex_type; + } + ui_view2d_tex_type = zui_combo(h_tex_type, [ tr("Base Color"), tr("Normal Map"), tr("Occlusion"), @@ -373,13 +381,21 @@ function ui_view2d_render() { } ui_view2d_ui._w = math_floor(ew * 0.7 + 3); - ui_view2d_uvmap_show = zui_check(zui_handle(__ID__, { selected: ui_view2d_uvmap_show }), tr("UV Map")); + let h_uvmap_show: zui_handle_t = zui_handle(__ID__); + if (h_uvmap_show.init) { + h_uvmap_show.selected = ui_view2d_uvmap_show; + } + ui_view2d_uvmap_show = zui_check(h_uvmap_show, tr("UV Map")); ui_view2d_ui._x += ew * 0.7 + 3; ui_view2d_ui._y = 2 + start_y; } ///end - ui_view2d_tiled_show = zui_check(zui_handle(__ID__, { selected: ui_view2d_tiled_show }), tr("Tiled")); + let h_tiled_show: zui_handle_t = zui_handle(__ID__); + if (h_tiled_show.init) { + h_tiled_show.selected = ui_view2d_tiled_show; + } + ui_view2d_tiled_show = zui_check(h_tiled_show, tr("Tiled")); ui_view2d_ui._x += ew * 0.7 + 3; ui_view2d_ui._y = 2 + start_y; diff --git a/misc/pad/Assets/themes/dark.json b/misc/pad/Assets/themes/dark.json deleted file mode 100644 index 151a9aba..00000000 --- a/misc/pad/Assets/themes/dark.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "WINDOW_BG_COL": 4278190080, - "WINDOW_TINT_COL": 4294967295, - "ACCENT_COL": 4282598211, - "ACCENT_HOVER_COL": 4282598211, - "ACCENT_SELECT_COL": 4283453520, - "BUTTON_COL": 4278190080, - "BUTTON_TEXT_COL": 4293453797, - "BUTTON_HOVER_COL": 4282992969, - "BUTTON_PRESSED_COL": 4279966491, - "TEXT_COL": 4293453797, - "LABEL_COL": 4291348680, - "SEPARATOR_COL": 4278519045, - "HIGHLIGHT_COL": 4282992969, - "CONTEXT_COL": 4280427042, - "PANEL_BG_COL": 4278190080, - "FONT_SIZE": 24, - "ELEMENT_W": 100, - "ELEMENT_H": 24, - "ELEMENT_OFFSET": 4, - "ARROW_SIZE": 5, - "BUTTON_H": 22, - "CHECK_SIZE": 15, - "CHECK_SELECT_SIZE": 8, - "SCROLL_W": 9, - "SCROLL_MINI_W": 3, - "TEXT_OFFSET": 8, - "TAB_W": 16, - "FILL_WINDOW_BG": true, - "FILL_BUTTON_BG": false, - "FILL_ACCENT_BG": false, - "LINK_STYLE": 0, - "FULL_TABS": false, - "ROUND_CORNERS": false -} diff --git a/misc/pad/Sources/main.ts b/misc/pad/Sources/main.ts index 7129cc72..a536a706 100644 --- a/misc/pad/Sources/main.ts +++ b/misc/pad/Sources/main.ts @@ -13,6 +13,7 @@ type storage_t = { }; let ui: zui_t; +let theme: zui_theme_t; let text_handle: zui_handle_t = zui_handle_create(); let sidebar_handle: zui_handle_t = zui_handle_create(); let editor_handle: zui_handle_t = zui_handle_create(); @@ -31,14 +32,13 @@ function drop_files(path: string) { } function shutdown() { - krom_file_save_bytes(krom_save_path() + "/config.json", sys_string_to_buffer(json_stringify(storage))); + let storage_string: string = sys_string_to_buffer(json_stringify(storage)); + krom_file_save_bytes(krom_save_path() + "/config.json", storage_string, 0); } function main() { - zui_set_text_area_line_numbers(true); - zui_set_text_area_scroll_past_end(true); - krom_set_app_name("ArmorPad"); + let blob_storage: buffer_t = krom_load_blob(krom_save_path() + "/config.json"); if (blob_storage == null) { storage = {}; @@ -59,47 +59,37 @@ function main() { text_handle.text = storage.text; - let ops: kinc_sys_ops_t = {}; - ops.title = "ArmorPad"; - ops.x = storage.window_x; - ops.y = storage.window_y; - ops.width = storage.window_w; - ops.height = storage.window_h; - ops.features = window_features_t.RESIZABLE | window_features_t.MAXIMIZABLE | window_features_t.MINIMIZABLE; - ops.mode = window_mode_t.WINDOWED; - ops.frequency = 60; - ops.vsync = true; + let ops: kinc_sys_ops_t = { + title: "ArmorPad", + x: storage.window_x, + y: storage.window_y, + width: storage.window_w, + height: storage.window_h, + features: window_features_t.RESIZABLE | + window_features_t.MAXIMIZABLE | + window_features_t.MINIMIZABLE, + mode: window_mode_t.WINDOWED, + frequency: 60, + vsync: true, + }; sys_start(ops); let font: g2_font_t = data_get_font("font_mono.ttf"); - let blob_theme: buffer_t = data_get_blob("themes/dark.json"); - let blob_coloring: buffer_t = data_get_blob("text_coloring.json"); - let parsed: any = json_parse(sys_buffer_to_string(blob_theme)); - let theme: any = zui_theme_create(); - for (let key of Object.getOwnPropertyNames(theme_t.prototype)) { - if (key == "constructor") { - continue; - } - theme[key] = parsed[key]; - } - g2_font_init(font); - let zui_ops: zui_ops_t = {}; - zui_ops.theme = theme; - zui_ops.font = font; - zui_ops.scaleFactor = 1.0; - zui_ops.color_wheel = null; - zui_ops.black_white_gradient = null; - ui = zui_create(zui_ops); - zui_set_on_border_hover(on_border_hover); - zui_set_on_text_hover(on_text_hover); + theme = {}; + zui_theme_default(theme); + + let zui_ops: zui_options_t = { scale_factor: 1.0, theme: theme, font: font.font_ }; + ui = zui_create(zui_ops); + + let blob_coloring: buffer_t = data_get_blob("text_coloring.json"); let text_coloring: zui_text_coloring_t = json_parse(sys_buffer_to_string(blob_coloring)); - text_coloring.default_color = math_floor(text_coloring.default_color); - for (let coloring of text_coloring.colorings) { - coloring.color = math_floor(coloring.color); - } - zui_set_text_area_coloring(text_coloring); + zui_text_area_coloring = text_coloring; + zui_on_border_hover = on_border_hover; + zui_on_text_hover = on_text_hover; + zui_text_area_line_numbers = true; + zui_text_area_scroll_past_end = true; sys_notify_on_frames(render); krom_set_drop_files_callback(drop_files); @@ -116,7 +106,7 @@ function list_folder(path: string) { // Active file if (abs == storage.file) { - zui_fill(0, 1, ui._w - 1, zui_ELEMENT_H(ui) - 1, ui.t.BUTTON_PRESSED_COL); + zui_fill(0, 1, ui._w - 1, ZUI_ELEMENT_H() - 1, theme.BUTTON_PRESSED_COL); } let prefix: string = ""; @@ -124,7 +114,7 @@ function list_folder(path: string) { prefix = is_expanded ? "- " : "+ "; } - if (zui_button(prefix + f, Align.Left)) { + if (zui_button(prefix + f, ZUI_ALIGN_LEFT, "")) { // Open file if (is_file) { storage.file = abs; @@ -142,9 +132,7 @@ function list_folder(path: string) { } if (is_expanded) { - // ui.indent(false); list_folder(abs); - // ui.unindent(false); } } } @@ -161,41 +149,46 @@ function render() { zui_begin(ui); if (zui_window(sidebar_handle, 0, 0, storage.sidebar_w, sys_height(), false)) { - let _BUTTON_TEXT_COL: i32 = ui.t.BUTTON_TEXT_COL; - ui.t.BUTTON_TEXT_COL = ui.t.ACCENT_COL; + let _BUTTON_TEXT_COL: i32 = theme.BUTTON_TEXT_COL; + theme.BUTTON_TEXT_COL = theme.ACCENT_COL; if (storage.project != "") { list_folder(storage.project); } else { - zui_button("Drop folder here", Align.Left); + zui_button("Drop folder here", ZUI_ALIGN_LEFT, ""); } - ui.t.BUTTON_TEXT_COL = _BUTTON_TEXT_COL; + theme.BUTTON_TEXT_COL = _BUTTON_TEXT_COL; } - zui_fill(sys_width() - minimap_w, 0, minimap_w, zui_ELEMENT_H(ui) + zui_ELEMENT_OFFSET(ui) + 1, ui.t.SEPARATOR_COL); - zui_fill(storage.sidebar_w, 0, 1, sys_height(), ui.t.SEPARATOR_COL); + zui_fill(sys_width() - minimap_w, 0, minimap_w, ZUI_ELEMENT_H() + ZUI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL); + zui_fill(storage.sidebar_w, 0, 1, sys_height(), theme.SEPARATOR_COL); let editor_updated: bool = false; if (zui_window(editor_handle, storage.sidebar_w + 1, 0, sys_width() - storage.sidebar_w - minimap_w, sys_height(), false)) { editor_updated = true; - let htab: zui_handle_t = zui_handle("main_0", { position: 0 }); - let file_name: string = substring(storage.file, string_last_index_of(storage.file, "/") + 1); + let htab: zui_handle_t = zui_handle(__ID__); + let file_name: string = substring(storage.file, string_last_index_of(storage.file, "/") + 1, storage.file.length); let file_names: string[] = [file_name]; - for (let file_name of file_names) { - if (zui_tab(htab, file_name + (storage.modified ? "*" : ""))) { + for (let i: i32 = 0; i < file_names.length; ++i) { + let tab_name: string = file_names[i]; + if (storage.modified) { + tab_name += "*"; + } + if (zui_tab(htab, tab_name, false, -1)) { // File modified if (ui.is_key_pressed) { storage.modified = true; } // Save - if (ui.is_ctrl_down && ui.key == key_code_t.S) { + if (ui.is_ctrl_down && ui.key_code == key_code_t.S) { save_file(); } - storage.text = zui_text_area(text_handle); + // storage.text = zui_text_area(text_handle, ZUI_ALIGN_LEFT, true, "", false); + zui_text_area(text_handle, ZUI_ALIGN_LEFT, true, "", false); } } @@ -220,18 +213,16 @@ function render() { minimap_scrolling = false; } if (minimap_scrolling) { - // editor_handle.scroll_offset -= ui.input_dy * zui_ELEMENT_H(ui) / 2; - // // editor_handle.scroll_offset = -((ui.input_y - minimap_y - minimap_box_h / 2) * zui_ELEMENT_H(ui) / 2); redraw = true; } // Build project - if (ui.is_ctrl_down && ui.key == key_code_t.B) { + if (ui.is_ctrl_down && ui.key_code == key_code_t.B) { save_file(); build_project(); } - zui_end(); + zui_end(false); if (redraw) { editor_handle.redraws = 2; @@ -251,16 +242,16 @@ function render() { function save_file() { // Trim let lines: string[] = string_split(storage.text, "\n"); - for (let i = 0; i < lines.length; ++i) { + for (let i: i32 = 0; i < lines.length; ++i) { lines[i] = trim_end(lines[i]); } - storage.text = lines.join("\n"); + storage.text = string_array_join(lines, "\n"); // Spaces to tabs storage.text = string_replace_all(storage.text, " ", "\t"); text_handle.text = storage.text; // Write bytes - let bytes = ends_with(storage.file, ".arm") ? armpack_encode(json_parse(storage.text)) : sys_string_to_buffer(storage.text); - krom_file_save_bytes(storage.file, bytes, buffer_size(bytes)); + // let bytes: buffer_t = ends_with(storage.file, ".arm") ? armpack_encode(json_parse(storage.text)) : sys_string_to_buffer(storage.text); + // krom_file_save_bytes(storage.file, bytes, buffer_size(bytes)); storage.modified = false; } @@ -273,7 +264,7 @@ function build_file(): string { } function build_project() { - krom_sys_command(storage.project + build_file() + " " + storage.project); + krom_sys_command(storage.project + build_file() + " " + storage.project, null); } function draw_minimap() { @@ -286,11 +277,11 @@ function draw_minimap() { } g2_begin(minimap); - g2_clear(ui.t.SEPARATOR_COL); + g2_clear(theme.SEPARATOR_COL); g2_set_color(0xff333333); let lines: string[] = string_split(storage.text, "\n"); let minimap_full_h: i32 = lines.length * 2; - let scroll_progress: f32 = -editor_handle.scroll_offset / (lines.length * zui_ELEMENT_H(ui)); + let scroll_progress: f32 = -editor_handle.scroll_offset / (lines.length * ZUI_ELEMENT_H()); let out_of_screen: i32 = minimap_full_h - minimap_h; if (out_of_screen < 0) { out_of_screen = 0; @@ -314,7 +305,7 @@ function draw_minimap() { // Current position let visible_area: i32 = out_of_screen > 0 ? minimap_h : minimap_full_h; g2_set_color(0x11ffffff); - minimap_box_h = math_floor((sys_height() - window_header_h) / zui_ELEMENT_H(ui) * 2); + minimap_box_h = math_floor((sys_height() - window_header_h) / ZUI_ELEMENT_H() * 2); g2_fill_rect(0, scroll_progress * visible_area, minimap_w, minimap_box_h); g2_end(); } @@ -341,5 +332,3 @@ function on_border_hover(handle: zui_handle_t, side: i32) { function on_text_hover() { krom_set_mouse_cursor(2); // I-cursor } - -main(); diff --git a/misc/pad/project.js b/misc/pad/project.js index 43e1e443..2dbd6fec 100644 --- a/misc/pad/project.js +++ b/misc/pad/project.js @@ -2,6 +2,7 @@ let flags = globalThis.flags; flags.name = 'ArmorPad'; flags.package = 'org.armorpad'; +flags.with_minits = true; flags.with_nfd = true; flags.with_tinydir = true; flags.with_g2 = true; @@ -14,7 +15,6 @@ flags.on_c_project_created = function(c_project, platform, graphics) { let project = new Project("ArmorPad"); let root = "../../"; project.addSources("Sources"); -project.addAssets("Assets/themes/*.json", { destination: "data/themes/{name}" }); project.addShaders(root + "armorcore/Shaders/*.glsl",); project.addAssets(root + "base/Assets/font_mono.ttf", { destination: "data/{name}" }); project.addAssets(root + "base/Assets/text_coloring.json", { destination: "data/{name}" });