From 4cc4b0d0692aa42696bae509fad0b6bcf5aeca8e Mon Sep 17 00:00:00 2001 From: luboslenco Date: Fri, 8 Nov 2024 23:46:39 +0100 Subject: [PATCH] Cleanup --- armorforge/sources/tab_objects.ts | 9 +- armorlab/sources/make_material.ts | 3 + armorsculpt/sources/tab_layers.ts | 4 +- base/assets/plugins/export_gpl.js | 24 ++++ .../plugins/import_gpl.js} | 10 +- base/sources/base.ts | 2 +- base/sources/box_export.ts | 31 ++---- base/sources/box_preferences.ts | 15 +-- base/sources/box_projects.ts | 12 +- base/sources/context.ts | 18 +-- base/sources/export_arm.ts | 7 -- base/sources/export_gpl.ts | 18 --- base/sources/file.ts | 48 ++++---- base/sources/gizmo.ts | 4 - base/sources/history.ts | 15 --- base/sources/import_asset.ts | 2 +- base/sources/import_mesh.ts | 3 - base/sources/nodes_material.ts | 19 ++-- base/sources/parser_blend.ts | 64 +++++------ base/sources/parser_exr.ts | 12 +- base/sources/project.ts | 105 ++++++++++++------ base/sources/render_path_base.ts | 8 -- base/sources/render_path_deferred.ts | 4 +- base/sources/tab_browser.ts | 5 +- base/sources/tab_brushes.ts | 4 - base/sources/tab_console.ts | 4 +- base/sources/tab_fonts.ts | 4 - base/sources/tab_history.ts | 4 - base/sources/tab_layers.ts | 5 +- base/sources/tab_materials.ts | 4 +- base/sources/tab_meshes.ts | 6 +- base/sources/tab_particles.ts | 4 - base/sources/tab_script.ts | 3 +- base/sources/tab_swatches.ts | 5 +- base/sources/tab_textures.ts | 2 - base/sources/translator.ts | 13 +-- base/sources/ui_base.ts | 94 ++-------------- base/sources/ui_box.ts | 7 +- base/sources/ui_files.ts | 27 ++--- base/sources/ui_menu.ts | 3 +- base/sources/ui_nodes.ts | 49 +++----- base/sources/ui_toolbar.ts | 5 +- base/sources/ui_view2d.ts | 13 +-- base/sources/uniforms_ext.ts | 22 ---- base/sources/util_particle.ts | 4 +- base/sources/util_render.ts | 7 +- 46 files changed, 287 insertions(+), 444 deletions(-) create mode 100644 base/assets/plugins/export_gpl.js rename base/{sources/import_gpl.ts => assets/plugins/import_gpl.js} (82%) delete mode 100644 base/sources/export_gpl.ts diff --git a/armorforge/sources/tab_objects.ts b/armorforge/sources/tab_objects.ts index 9783e871..135b1d14 100644 --- a/armorforge/sources/tab_objects.ts +++ b/armorforge/sources/tab_objects.ts @@ -162,8 +162,7 @@ function tab_objects_draw(htab: ui_handle_t) { rot = vec4_mult(rot, 180 / 3.141592); let f: f32 = 0.0; - let row: f32[] = [1 / 4, 1 / 4, 1 / 4, 1 / 4]; - ui_row(row); + ui_row4(); ui_text("Loc"); h = ui_handle(__ID__); @@ -187,7 +186,7 @@ function tab_objects_draw(htab: ui_handle_t) { local_pos.z = f; } - ui_row(row); + ui_row4(); ui_text("Rotation"); h = ui_handle(__ID__); @@ -224,7 +223,7 @@ function tab_objects_draw(htab: ui_handle_t) { // ///end } - ui_row(row); + ui_row4(); ui_text("Scale"); h = ui_handle(__ID__); @@ -248,7 +247,7 @@ function tab_objects_draw(htab: ui_handle_t) { scale.z = f; } - ui_row(row); + ui_row4(); ui_text("Dimensions"); h = ui_handle(__ID__); diff --git a/armorlab/sources/make_material.ts b/armorlab/sources/make_material.ts index 83d0dbd2..9c067072 100644 --- a/armorlab/sources/make_material.ts +++ b/armorlab/sources/make_material.ts @@ -152,3 +152,6 @@ function make_material_parse_mesh_preview_material(md: material_data_t = null) { function make_material_parse_node_preview_material(node: ui_node_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null): parse_node_preview_result_t { } + +function make_material_parse_particle_material() { +} diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index 4c099299..c8385f10 100644 --- a/armorsculpt/sources/tab_layers.ts +++ b/armorsculpt/sources/tab_layers.ts @@ -198,10 +198,8 @@ function tab_layers_draw_layer_slot(l: slot_layer_t, i: i32, mini: bool) { function tab_layers_draw_layer_slot_mini(l: slot_layer_t, i: i32) { let ui: ui_t = ui_base_ui; - let row: f32[] = [1, 1]; + let row: f32[] = [1 / 1, 1 / 1]; ui_row(row); - let uix: i32 = ui._x; - let uiy: i32 = ui._y; _ui_end_element(); _ui_end_element(); diff --git a/base/assets/plugins/export_gpl.js b/base/assets/plugins/export_gpl.js new file mode 100644 index 00000000..193e8b7c --- /dev/null +++ b/base/assets/plugins/export_gpl.js @@ -0,0 +1,24 @@ + +function export_gpl(path, name, swatches) { + let o: string = ""; + o += "GIMP Palette\n"; + o += "Name: " + name + "\n"; + o += "# armorpaint.org\n"; + o += "#\n"; + + for (let i = 0; i < swatches.length; ++i) { + let swatch = swatches[i]; + let rb = color_get_rb(swatch.base); + let gb = color_get_gb(swatch.base); + let bb = color_get_bb(swatch.base); + o += rb + " " + gb + " " + bb + "\n"; + } + + iron_file_save_bytes(path, sys_string_to_buffer(o), o.length); +} + +let plugin = plugin_create(); +path_swatch_exporters_set("gpl", export_gpl); +plugin_notify_on_delete(plugin, function() { + path_swatch_exporters_delete("gpl"); +}); diff --git a/base/sources/import_gpl.ts b/base/assets/plugins/import_gpl.js similarity index 82% rename from base/sources/import_gpl.ts rename to base/assets/plugins/import_gpl.js index 1256abca..f879ee65 100644 --- a/base/sources/import_gpl.ts +++ b/base/assets/plugins/import_gpl.js @@ -1,6 +1,6 @@ -function import_gpl_run(path: string, replace_existing: bool) { - let b: buffer_t = data_get_blob(path); +function import_gpl(path, replace_existing) { + let b = data_get_blob(path); // let swatches: TSwatchColor[] = []; // let str: string = sys_buffer_to_string(b); @@ -39,3 +39,9 @@ function import_gpl_run(path: string, replace_existing: bool) { // } // } } + +let plugin = plugin_create(); +path_swatch_importers_set("gpl", import_gpl); +plugin_notify_on_delete(plugin, function() { + path_swatch_importers_delete("gpl"); +}); diff --git a/base/sources/base.ts b/base/sources/base.ts index e5916f93..4063394d 100644 --- a/base/sources/base.ts +++ b/base/sources/base.ts @@ -1652,7 +1652,7 @@ function base_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool = } function base_flatten(height_to_normal: bool = false, layers: slot_layer_t[] = null): slot_layer_t { - base_ext_flatten(height_to_normal, layers); + return base_ext_flatten(height_to_normal, layers); } function base_on_layers_resized() { diff --git a/base/sources/box_export.ts b/base/sources/box_export.ts index c9ebfd7a..253f6dc5 100644 --- a/base/sources/box_export.ts +++ b/base/sources/box_export.ts @@ -80,8 +80,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: let tab_vertical: bool = config_raw.touch_ui; if (ui_tab(box_export_htab, title, tab_vertical)) { - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); ///if (arm_android || arm_ios) let base_res_combo: string[] = ["128", "256", "512", "1K", "2K", "4K"]; @@ -105,7 +104,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: app_notify_on_init(base_set_layer_bits); } - ui_row(row); + ui_row2(); if (base_bits_handle.position == texture_bits_t.BITS8) { let h: ui_handle_t = ui_handle(__ID__); if (h.init) { @@ -135,7 +134,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: ui.enabled = true; ///if is_paint - ui_row(row); + ui_row2(); ui.enabled = !bake_material; let layers_export_handle: ui_handle_t = ui_handle(__ID__); layers_export_handle.position = context_raw.layers_export; @@ -157,7 +156,7 @@ function box_export_tab_export_textures(ui: ui_t, title: string, bake_material: _ui_end_element(); - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } @@ -208,8 +207,7 @@ function box_export_tab_presets(ui: ui_t) { ui_box_show_custom(function (ui: ui_t) { let tab_vertical: bool = config_raw.touch_ui; if (ui_tab(ui_handle(__ID__), tr("New Preset"), tab_vertical)) { - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let h_preset: ui_handle_t = ui_handle(__ID__); if (h_preset.init) { h_preset.text = "new_preset"; @@ -253,8 +251,7 @@ function box_export_tab_presets(ui: ui_t) { // Texture list ui_separator(10, false); - row = [1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]; - ui_row(row); + ui_row6(); ui_text(tr("Texture")); ui_text(tr("R")); ui_text(tr("G")); @@ -264,7 +261,7 @@ function box_export_tab_presets(ui: ui_t) { ui.changed = false; for (let i: i32 = 0; i < box_export_preset.textures.length; ++i) { let t: export_preset_texture_t = box_export_preset.textures[i]; - ui_row(row); + ui_row6(); let htex: ui_handle_t = ui_nest(box_export_hpreset, i); htex.text = t.name; t.name = ui_text_input(htex); @@ -345,8 +342,7 @@ function box_export_tab_atlases(ui: ui_t) { } } for (let i: i32 = 0; i < project_paint_objects.length; ++i) { - let row: f32[] = [1 / 2, 1 / 2]; - ui_row(row); + ui_row2(); ui_text(project_paint_objects[i].base.name); let hatlas: ui_handle_t = ui_nest(ui_handle(__ID__), i); hatlas.position = project_atlas_objects[i]; @@ -367,8 +363,7 @@ function box_export_tab_export_mesh(ui: ui_t, htab: ui_handle_t) { let tab_vertical: bool = config_raw.touch_ui; if (ui_tab(htab, tr("Export Mesh"), tab_vertical)) { - let row: f32[] = [1 / 2, 1 / 2]; - ui_row(row); + ui_row2(); let h_export_mesh_format: ui_handle_t = ui_handle(__ID__); if (h_export_mesh_format.init) { @@ -405,7 +400,7 @@ function box_export_tab_export_mesh(ui: ui_t, htab: ui_handle_t) { } ui_text(tris + " " + tr("triangles")); - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } @@ -451,8 +446,7 @@ function box_export_show_material() { h2.selected = context_raw.write_icon_on_export; context_raw.pack_assets_on_export = ui_check(h1, tr("Pack Assets")); context_raw.write_icon_on_export = ui_check(h2, tr("Export Icon")); - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } @@ -483,8 +477,7 @@ function box_export_show_brush() { h2.selected = context_raw.write_icon_on_export; context_raw.pack_assets_on_export = ui_check(h1, tr("Pack Assets")); context_raw.write_icon_on_export = ui_check(h2, tr("Export Icon")); - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } diff --git a/base/sources/box_preferences.ts b/base/sources/box_preferences.ts index 0c586e5d..0029fb40 100644 --- a/base/sources/box_preferences.ts +++ b/base/sources/box_preferences.ts @@ -198,8 +198,7 @@ function box_preferences_show() { if (ui_button(tr("New"))) { ui_box_show_custom(function (ui: ui_t) { if (ui_tab(ui_handle(__ID__), tr("New Theme"))) { - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let h: ui_handle_t = ui_handle(__ID__); if (h.init) { h.text = "new_theme"; @@ -483,8 +482,7 @@ function box_preferences_show() { make_material_parse_paint_material(); } - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let brush_angle_reject_handle: ui_handle_t = ui_handle(__ID__); if (brush_angle_reject_handle.init) { @@ -724,8 +722,7 @@ function box_preferences_show() { } ui_begin_sticky(); - let row: f32[] = [1 / 4, 1 / 4, 1 / 4, 1 / 4]; - ui_row(row); + ui_row4(); box_preferences_preset_handle = ui_handle(__ID__); if (box_preferences_preset_handle.init) { @@ -741,8 +738,7 @@ function box_preferences_show() { if (ui_button(tr("New"))) { ui_box_show_custom(function (ui: ui_t) { if (ui_tab(ui_handle(__ID__), tr("New Keymap"))) { - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let h: ui_handle_t = ui_handle(__ID__); if (h.init) { h.text = "new_keymap"; @@ -810,8 +806,7 @@ function box_preferences_show() { if (ui_button(tr("New"))) { ui_box_show_custom(function (ui: ui_t) { if (ui_tab(ui_handle(__ID__), tr("New Plugin"))) { - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let h: ui_handle_t = ui_handle(__ID__); if (h.init) { h.text = "new_plugin"; diff --git a/base/sources/box_projects.ts b/base/sources/box_projects.ts index 4ae00320..9a53d12b 100644 --- a/base/sources/box_projects.ts +++ b/base/sources/box_projects.ts @@ -3,6 +3,10 @@ let box_projects_htab: ui_handle_t = ui_handle_create(); let box_projects_hsearch: ui_handle_t = ui_handle_create(); let box_projects_icon_map: map_t = null; +let _box_projects_path: string; +let _box_projects_icon_path: string; +let _box_projects_i: i32; + function box_projects_show() { if (box_projects_icon_map != null) { let keys: string[] = map_keys(box_projects_icon_map); @@ -35,10 +39,6 @@ function box_projects_show() { }, 600, 400, null, draggable); } -let _box_projects_path: string; -let _box_projects_icon_path: string; -let _box_projects_i: i32; - function box_projects_tab(ui: ui_t) { if (ui_tab(box_projects_htab, tr("Projects"), true)) { ui_begin_sticky(); @@ -142,7 +142,7 @@ function box_projects_tab(ui: ui_t) { _box_projects_icon_path = icon_path; _box_projects_i = i; ui_menu_draw(function (ui: ui_t) { - // if (menuButton(ui, tr("Duplicate"))) {} + // if (ui_menu_button(ui, tr("Duplicate"))) {} if (ui_menu_button(ui, tr("Delete"))) { app_notify_on_init(function () { file_delete(_box_projects_path); @@ -228,7 +228,7 @@ function box_projects_recent_tab(ui: ui_t) { ui.enabled = true; _ui_end_element(); - if (ui_button(tr("New .."), ui_align_t.LEFT)) { + if (ui_button(tr("New Project..."), ui_align_t.LEFT)) { project_new_box(); } if (ui_button(tr("Open..."), ui_align_t.LEFT)) { diff --git a/base/sources/context.ts b/base/sources/context.ts index 5632b355..1bcfe620 100644 --- a/base/sources/context.ts +++ b/base/sources/context.ts @@ -268,6 +268,8 @@ type context_t = { ///end } +let context_raw: context_t; + function context_create(): context_t { let c: context_t = {}; c.merged_object_is_atlas = false; // Only objects referenced by atlas are merged @@ -490,20 +492,12 @@ function context_create(): context_t { return c; } -let context_raw: context_t; - function context_init() { context_raw = context_create(); } function context_use_deferred(): bool { - ///if is_paint return context_raw.render_mode != render_mode_t.FORWARD && (context_raw.viewport_mode == viewport_mode_t.LIT || context_raw.viewport_mode == viewport_mode_t.PATH_TRACE) && context_raw.tool != workspace_tool_t.COLORID; - ///end - - ///if (is_sculpt || is_lab) - return context_raw.render_mode != render_mode_t.FORWARD && (context_raw.viewport_mode == viewport_mode_t.LIT || context_raw.viewport_mode == viewport_mode_t.PATH_TRACE); - ///end } function context_select_material(i: i32) { @@ -602,14 +596,11 @@ function context_select_tool(i: i32) { context_raw.viewport_mode = viewport_mode_t.MINUS_ONE; context_set_viewport_mode(_viewport_mode); - ///if (is_paint || is_sculpt) context_init_tool(); ui_header_handle.redraws = 2; ui_toolbar_handle.redraws = 2; - ///end } -///if (is_paint || is_sculpt) function context_init_tool() { let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; if (decal) { @@ -623,7 +614,6 @@ function context_init_tool() { util_particle_init(); make_material_parse_particle_material(); } - else if (context_raw.tool == workspace_tool_t.BAKE) { ///if (arm_direct3d12 || arm_vulkan || arm_metal) // Bake in lit mode for now @@ -632,7 +622,6 @@ function context_init_tool() { } ///end } - else if (context_raw.tool == workspace_tool_t.MATERIAL) { base_update_fill_layers(); context_main_object().skip_context = null; @@ -643,7 +632,6 @@ function context_init_tool() { config_raw.brush_live = decal; ///end } -///end function context_select_paint_object(o: mesh_object_t) { ///if (is_paint || is_sculpt) @@ -762,7 +750,6 @@ function context_get_area_type(): area_type_t { if (context_in_browser()) { return area_type_t.BROWSER; } - ///if (is_paint || is_sculpt) if (context_in_2d_view()) { return area_type_t.VIEW2D; } @@ -772,7 +759,6 @@ function context_get_area_type(): area_type_t { if (context_in_materials()) { return area_type_t.MATERIALS; } - ///end return area_type_t.MINUS_ONE; } diff --git a/base/sources/export_arm.ts b/base/sources/export_arm.ts index be6f0e07..ade506bd 100644 --- a/base/sources/export_arm.ts +++ b/base/sources/export_arm.ts @@ -144,9 +144,6 @@ function export_arm_run_project() { layer_datas: ld, font_assets: font_files, mesh_assets: mesh_files, - ///end - - ///if is_paint atlas_objects: project_atlas_objects, atlas_names: project_atlas_names, ///end @@ -335,7 +332,6 @@ function export_arm_run_material(path: string) { iron_file_save_bytes(path, buffer, buffer.length + 1); } -///if (arm_metal || arm_vulkan) function export_arm_bgra_swap(buffer: buffer_t): buffer_t { for (let i: i32 = 0; i < math_floor((buffer.length) / 4); ++i) { let r: i32 = buffer[i * 4]; @@ -344,7 +340,6 @@ function export_arm_bgra_swap(buffer: buffer_t): buffer_t { } return buffer; } -///end function export_arm_run_brush(path: string) { if (!ends_with(path, ".arm")) { @@ -420,7 +415,6 @@ function export_arm_assets_to_files(project_path: string, assets: asset_t[]): st return texture_files; } -///if (is_paint || is_sculpt) function export_arm_meshes_to_files(project_path: string): string[] { let mesh_files: string[] = []; for (let i: i32 = 0; i < project_mesh_assets.length; ++i) { @@ -460,7 +454,6 @@ function export_arm_fonts_to_files(project_path: string, fonts: slot_font_t[]): } return font_files; } -///end function export_arm_get_packed_assets(project_path: string, texture_files: string[]): packed_asset_t[] { let packed_assets: packed_asset_t[] = null; diff --git a/base/sources/export_gpl.ts b/base/sources/export_gpl.ts deleted file mode 100644 index 649ed0bf..00000000 --- a/base/sources/export_gpl.ts +++ /dev/null @@ -1,18 +0,0 @@ - -function export_gpl_run(path: string, name: string, swatches: swatch_color_t[]) { - let o: string = ""; - o += "GIMP Palette\n"; - o += "Name: " + name + "\n"; - o += "# armorpaint.org\n"; - o += "#\n"; - - for (let i: i32 = 0; i < swatches.length; ++i) { - let swatch: swatch_color_t = swatches[i]; - let rb: i32 = color_get_rb(swatch.base); - let gb: i32 = color_get_gb(swatch.base); - let bb: i32 = color_get_bb(swatch.base); - o += rb + " " + gb + " " + bb + "\n"; - } - - iron_file_save_bytes(path, sys_string_to_buffer(o), o.length); -} diff --git a/base/sources/file.ts b/base/sources/file.ts index 8bf9f945..31445a35 100644 --- a/base/sources/file.ts +++ b/base/sources/file.ts @@ -1,4 +1,25 @@ +type file_download_data_t = { + dst_path: string; + done: (url: string)=>void; +}; + +type file_download_bytes_data_t = { + url: string; + save: string; + done: (url: string, ab: buffer_t)=>void; +}; + +type file_cache_cloud_data_t = { + dest: string; + path: string; + done: (dest: string)=>void; +}; + +let _file_download_map: map_t = map_create(); +let _file_download_bytes_map: map_t = map_create(); +let _file_cache_cloud_map: map_t = map_create(); + ///if arm_windows let file_cmd_mkdir: string = "mkdir"; let file_cmd_copy: string = "copy"; @@ -10,6 +31,8 @@ let file_cmd_copy: string = "cp"; let file_cloud: map_t = null; let file_cloud_sizes: map_t = null; +let _file_init_cloud_bytes_done: ()=>void; + // ///if arm_android // let let file_internal: map_t = null; // .apk contents // ///end @@ -85,13 +108,6 @@ function file_exists(path: string): bool { return iron_file_exists(path); } -type file_download_data_t = { - dst_path: string; - done: (url: string)=>void; -}; - -let _file_download_map: map_t = map_create(); - function file_download(url: string, dst_path: string, done: (url: string)=>void, size: i32 = 0) { ///if (arm_windows || arm_macos || arm_ios || arm_android) let fdd: file_download_data_t = { dst_path: dst_path, done: done }; @@ -112,14 +128,6 @@ function file_download(url: string, dst_path: string, done: (url: string)=>void, ///end } -type file_download_bytes_data_t = { - url: string; - save: string; - done: (url: string, ab: buffer_t)=>void; -}; - -let _file_download_bytes_map: map_t = map_create(); - function file_download_bytes(url: string, done: (url: string, ab: buffer_t)=>void) { let save: string; if (path_is_protected()) { @@ -139,14 +147,6 @@ function file_download_bytes(url: string, done: (url: string, ab: buffer_t)=>voi }); } -type file_cache_cloud_data_t = { - dest: string; - path: string; - done: (dest: string)=>void; -}; - -let _file_cache_cloud_map: map_t = map_create(); - function file_cache_cloud(path: string, done: (s: string)=>void) { ///if arm_ios let path2: string = string_replace_all(path, "/", "_"); // Cache everything into root folder @@ -214,8 +214,6 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { }, map_get(file_cloud_sizes, path)); } -let _file_init_cloud_bytes_done: ()=>void; - function file_init_cloud_bytes(done: ()=>void, append: string = "") { _file_init_cloud_bytes_done = done; file_download_bytes(config_raw.server + "/?list-type=2" + append, function (url: string, buffer: buffer_t) { diff --git a/base/sources/gizmo.ts b/base/sources/gizmo.ts index 7e09438a..dc51822c 100644 --- a/base/sources/gizmo.ts +++ b/base/sources/gizmo.ts @@ -1,6 +1,4 @@ -///if (is_paint || is_sculpt) - let gizmo_v: vec4_t = vec4_create(); let gizmo_v0: vec4_t = vec4_create(); let gizmo_q: quat_t = quat_create(); @@ -318,5 +316,3 @@ function gizmo_update() { _input_occupied = (context_raw.translate_x || context_raw.translate_y || context_raw.translate_z || context_raw.scale_x || context_raw.scale_y || context_raw.scale_z || context_raw.rotate_x || context_raw.rotate_y || context_raw.rotate_z) && mouse_view_x() < base_w(); } - -///end diff --git a/base/sources/history.ts b/base/sources/history.ts index 148dc379..15248671 100644 --- a/base/sources/history.ts +++ b/base/sources/history.ts @@ -15,8 +15,6 @@ function history_undo() { if (step.name == tr("Edit Nodes")) { history_swap_canvas(step); } - - ///if (is_paint || is_sculpt) else if (step.name == tr("New Layer") || step.name == tr("New Black Mask") || step.name == tr("New White Mask") || step.name == tr("New Fill Mask")) { context_raw.layer = project_layers[step.layer]; slot_layer_delete(context_raw.layer); @@ -217,13 +215,11 @@ function history_undo() { slot_layer_swap(context_raw.layer, lay); context_raw.layer_preview_dirty = true; } - ///end history_undos--; history_redos++; context_raw.ddirty = 2; - ///if (is_paint || is_sculpt) ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; ui_base_hwnds[tab_area_t.SIDEBAR1].redraws = 2; if (ui_view2d_show) { @@ -234,7 +230,6 @@ function history_undo() { // Refresh undo & redo buttons ui_menubar_menu_handle.redraws = 2; } - ///end } } @@ -246,8 +241,6 @@ function history_redo() { if (step.name == tr("Edit Nodes")) { history_swap_canvas(step); } - - ///if (is_paint || is_sculpt) else if (step.name == tr("New Layer") || step.name == tr("New Black Mask") || step.name == tr("New White Mask") || step.name == tr("New Fill Mask")) { let parent: slot_layer_t = step.layer_parent > 0 ? project_layers[step.layer_parent - 1] : null; let l: slot_layer_t = slot_layer_create("", step.layer_type, parent); @@ -413,13 +406,11 @@ function history_redo() { context_raw.layer_preview_dirty = true; history_undo_i = (history_undo_i + 1) % config_raw.undo_steps; } - ///end history_undos++; history_redos--; context_raw.ddirty = 2; - ///if (is_paint || is_sculpt) ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; ui_base_hwnds[tab_area_t.SIDEBAR1].redraws = 2; if (ui_view2d_show) { @@ -430,7 +421,6 @@ function history_redo() { // Refresh undo & redo buttons ui_menubar_menu_handle.redraws = 2; } - ///end } } @@ -461,12 +451,7 @@ function history_reset() { history_undo_i = 0; } -///if (is_paint || is_sculpt) function history_edit_nodes(canvas: ui_node_canvas_t, canvas_type: i32, canvas_group: i32 = -1) { -///end -///if is_lab -function history_edit_nodes(canvas: ui_node_canvas_t, canvas_group: i32 = -1) { -///end let step: step_t = history_push(tr("Edit Nodes")); step.canvas_group = canvas_group; ///if (is_paint || is_sculpt) diff --git a/base/sources/import_asset.ts b/base/sources/import_asset.ts index 61e33fad..7a5bc9fa 100644 --- a/base/sources/import_asset.ts +++ b/base/sources/import_asset.ts @@ -64,7 +64,7 @@ function import_asset_run(path: string, drop_x: f32 = -1.0, drop_y: f32 = -1.0, import_plugin_run(path); } else if (path_is_gimp_color_palette(path)) { - import_gpl_run(path, false); + // import_gpl_run(path, false); } else if (path_is_font(path)) { import_font_run(path); diff --git a/base/sources/import_mesh.ts b/base/sources/import_mesh.ts index c98f9ddd..4fcb411a 100644 --- a/base/sources/import_mesh.ts +++ b/base/sources/import_mesh.ts @@ -1,8 +1,5 @@ -///if (is_paint || is_sculpt) let import_mesh_clear_layers: bool = true; -///end - let import_mesh_meshes_to_unwrap: any[] = null; ///if (is_paint || is_sculpt) diff --git a/base/sources/nodes_material.ts b/base/sources/nodes_material.ts index b9507ed7..2b896a58 100644 --- a/base/sources/nodes_material.ts +++ b/base/sources/nodes_material.ts @@ -3841,6 +3841,10 @@ let nodes_material_list: node_list_t[] = [ nodes_material_group ]; +let _nodes_material_nodes: ui_nodes_t; +let _nodes_material_node: ui_node_t; +let _nodes_material_sockets: ui_node_socket_t[]; + function nodes_material_init() { map_set(ui_nodes_custom_buttons, "nodes_material_vector_curves_button", nodes_material_vector_curves_button); map_set(ui_nodes_custom_buttons, "nodes_material_color_ramp_button", nodes_material_color_ramp_button); @@ -3856,8 +3860,7 @@ function nodes_material_vector_curves_button(node_id: i32) { let but: ui_node_button_t = node.buttons[0]; let nhandle: ui_handle_t = ui_nest(ui_handle(__ID__), node.id); - let row: f32[] = [1 / 3, 1 / 3, 1 / 3]; - ui_row(row); + ui_row3(); ui_radio(ui_nest(ui_nest(nhandle, 0), 1), 0, "X"); ui_radio(ui_nest(ui_nest(nhandle, 0), 1), 1, "Y"); ui_radio(ui_nest(ui_nest(nhandle, 0), 1), 2, "Z"); @@ -3877,7 +3880,7 @@ function nodes_material_vector_curves_button(node_id: i32) { } // Edit - row = [1 / 5, 1 / 5, 3 / 5]; + let row: f32[] = [1 / 5, 1 / 5, 3 / 5]; ui_row(row); if (ui_button("+")) { val[axis * 32 + num * 2 + 0] = 0.0; @@ -3902,8 +3905,7 @@ function nodes_material_vector_curves_button(node_id: i32) { ihandle.value = i = num - 1; // Stay in bounds } - row = [1 / 2, 1 / 2]; - ui_row(row); + ui_row2(); ui_nest(ui_nest(nhandle, 0), 3).value = val[axis * 32 + i * 2 + 0]; ui_nest(ui_nest(nhandle, 0), 4).value = val[axis * 32 + i * 2 + 1]; @@ -3966,8 +3968,7 @@ function nodes_material_color_ramp_button(node_id: i32) { let interpolate_combo: string[] = [tr("Linear"), tr("Constant")]; but.data[0] = ui_combo(h, interpolate_combo, tr("Interpolate")); - row = [1 / 2, 1 / 2]; - ui_row(row); + ui_row2(); let i: i32 = math_floor(ui_slider(ihandle, "Index", 0, (vals.length / 5) - 1, false, 1, true, ui_align_t.LEFT)); if (i >= (vals.length * 5) || i < 0) { ihandle.value = i = (vals.length / 5) - 1; // Stay in bounds @@ -4096,10 +4097,6 @@ function nodes_material_group_output_button(node_id: i32) { nodes_material_add_socket_button(ui, nodes, node, node.inputs); } -let _nodes_material_nodes: ui_nodes_t; -let _nodes_material_node: ui_node_t; -let _nodes_material_sockets: ui_node_socket_t[]; - function nodes_material_add_socket_button(ui: ui_t, nodes: ui_nodes_t, node: ui_node_t, sockets: ui_node_socket_t[]) { if (ui_button(tr("Add"))) { _nodes_material_nodes = nodes; diff --git a/base/sources/parser_blend.ts b/base/sources/parser_blend.ts index 8fc66567..c9e6306d 100644 --- a/base/sources/parser_blend.ts +++ b/base/sources/parser_blend.ts @@ -16,6 +16,38 @@ type blend_t = { map?: map_t; // Map blocks by memory address }; +type block_t = { + blend?: blend_t; + code?: string; + size?: i32; + sdna_index?: i32; + count?: i32; + pos?: i32; // Byte pos of data start in blob +}; + +type dna_t = { + names?: string[]; + types?: string[]; + types_length?: i32[]; + structs?: dna_struct_t[]; +}; + +type dna_struct_t = { + dna?: dna_t; + type?: i32; // Index in dna.types + field_types?: i32[]; // Index in dna.types + field_names?: i32[]; // Index in dna.names +}; + +type bl_handle_t = { + block?: block_t; + offset?: i32; // Block data bytes offset + ds?: dna_struct_t; +}; + +let bl_handle_tmp_i: i64; +let bl_handle_tmp_f: f64; + function parser_blend_init(buffer: buffer_t): blend_t { let raw: blend_t = {}; raw.blocks = []; @@ -300,35 +332,6 @@ function parser_blend_read_pointer(raw: blend_t): string { return u64_to_string(i); } -type block_t = { - blend?: blend_t; - code?: string; - size?: i32; - sdna_index?: i32; - count?: i32; - pos?: i32; // Byte pos of data start in blob -}; - -type dna_t = { - names?: string[]; - types?: string[]; - types_length?: i32[]; - structs?: dna_struct_t[]; -}; - -type dna_struct_t = { - dna?: dna_t; - type?: i32; // Index in dna.types - field_types?: i32[]; // Index in dna.types - field_names?: i32[]; // Index in dna.names -}; - -type bl_handle_t = { - block?: block_t; - offset?: i32; // Block data bytes offset - ds?: dna_struct_t; -}; - function bl_handle_get_size(raw: bl_handle_t, index: i32): i32 { let name_index: i32 = raw.ds.field_names[index]; let type_index: i32 = raw.ds.field_types[index]; @@ -361,9 +364,6 @@ function bl_handle_get_array_len(s: string): i32 { return parse_int(substring(s, string_index_of(s, "[") + 1, string_index_of(s, "]"))); } -let bl_handle_tmp_i: i64; -let bl_handle_tmp_f: f64; - function bl_handle_get_f(raw: bl_handle_t, name: string): f64 { let p: f64_ptr = bl_handle_get(raw, name); return DEREFERENCE(p); diff --git a/base/sources/parser_exr.ts b/base/sources/parser_exr.ts index df70f657..42351c3b 100644 --- a/base/sources/parser_exr.ts +++ b/base/sources/parser_exr.ts @@ -2,18 +2,18 @@ // https://github.com/aras-p/miniexr // https://www.openexr.com/documentation/openexrfilelayout.pdf -function parser_exr_write_string(out: i32[], str: string) { - for (let i: i32 = 0; i < str.length; ++i) { - array_push(out, char_code_at(str, i)); - } -} - let _parser_exr_width: i32; let _parser_exr_stride: i32; let _parser_exr_out: u8[]; let _parser_exr_src_view: buffer_t; let _parser_exr_write_line: (byte_pos: i32)=> void; +function parser_exr_write_string(out: i32[], str: string) { + for (let i: i32 = 0; i < str.length; ++i) { + array_push(out, char_code_at(str, i)); + } +} + function parser_exr_write_line16(byte_pos: i32) { for (let x: i32 = 0; x < _parser_exr_width; ++x) { array_push(_parser_exr_out, buffer_get_u8(_parser_exr_src_view, byte_pos )); diff --git a/base/sources/project.ts b/base/sources/project.ts index 822397e0..d7384ab2 100644 --- a/base/sources/project.ts +++ b/base/sources/project.ts @@ -23,6 +23,19 @@ let project_nodes: ui_nodes_t; let project_canvas: ui_node_canvas_t; let project_default_canvas: buffer_t = null; +let _project_save_and_quit: bool; +let _project_import_mesh_replace_existing: bool; +let _project_import_mesh_done: ()=>void; +let _project_import_mesh_box_path: string; +let _project_import_mesh_box_replace_existing: bool; +let _project_import_mesh_box_clear_layers: bool; +let _project_import_mesh_box_done: ()=>void; +let _project_unwrap_mesh_box_mesh: raw_mesh_t; +let _project_unwrap_mesh_box_done: (a: raw_mesh_t)=>void; +let _project_unwrap_mesh_box_skip_ui: bool; +let _project_import_asset_hdr_as_envmap: bool; +let _project_import_swatches_replace_existing: bool; +let _project_reimport_texture_asset: asset_t; function project_open() { ui_files_show("arm", false, false, function (path: string) { @@ -41,8 +54,6 @@ function project_open() { }); } -let _project_save_and_quit: bool; - function project_save(save_and_quit: bool = false) { if (project_filepath == "") { ///if arm_ios @@ -102,8 +113,7 @@ function project_new_box() { array_insert(project_mesh_list, 0, "rounded_cube"); } - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); let h_project_type: ui_handle_t = ui_handle(__ID__); if (h_project_type.init) { h_project_type.position = context_raw.project_type; @@ -118,7 +128,7 @@ function project_new_box() { context_raw.project_aspect_ratio = ui_combo(h_project_aspect_ratio, project_aspect_ratio_combo, tr("Aspect Ratio"), true); _ui_end_element(); - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } @@ -386,9 +396,6 @@ function project_import_brush() { }); } -let _project_import_mesh_replace_existing: bool; -let _project_import_mesh_done: ()=>void; - function project_import_mesh(replace_existing: bool = true, done: ()=>void = null) { _project_import_mesh_replace_existing = replace_existing; _project_import_mesh_done = done; @@ -397,11 +404,6 @@ function project_import_mesh(replace_existing: bool = true, done: ()=>void = nul }); } -let _project_import_mesh_box_path: string; -let _project_import_mesh_box_replace_existing: bool; -let _project_import_mesh_box_clear_layers: bool; -let _project_import_mesh_box_done: ()=>void; - function project_import_mesh_box(path: string, replace_existing: bool = true, clear_layers: bool = true, done: ()=>void = null) { _project_import_mesh_box_path = path; @@ -486,10 +488,6 @@ function project_reimport_mesh() { } } -let _project_unwrap_mesh_box_mesh: raw_mesh_t; -let _project_unwrap_mesh_box_done: (a: raw_mesh_t)=>void; -let _project_unwrap_mesh_box_skip_ui: bool; - function project_unwrap_mesh_box(mesh: raw_mesh_t, done: (a: raw_mesh_t)=>void, skip_ui: bool = false) { _project_unwrap_mesh_box_mesh = mesh; @@ -519,8 +517,7 @@ function project_unwrap_mesh_box(mesh: raw_mesh_t, done: (a: raw_mesh_t)=>void, let unwrap_by: i32 = ui_combo(ui_handle(__ID__), unwrap_plugins, tr("Plugin"), true); - let row: f32[] = [0.5, 0.5]; - ui_row(row); + ui_row2(); if (ui_button(tr("Cancel"))) { ui_box_hide(); } @@ -549,8 +546,6 @@ function project_unwrap_mesh_box(mesh: raw_mesh_t, done: (a: raw_mesh_t)=>void, }); } -let _project_import_asset_hdr_as_envmap: bool; - function project_import_asset(filters: string = null, hdr_as_envmap: bool = true) { if (filters == null) { filters = string_array_join(path_texture_formats, ",") + "," + string_array_join(path_mesh_formats, ","); @@ -563,13 +558,11 @@ function project_import_asset(filters: string = null, hdr_as_envmap: bool = true }); } -let _project_import_swatches_replace_existing: bool; - function project_import_swatches(replace_existing: bool = false) { _project_import_swatches_replace_existing = replace_existing; ui_files_show("arm,gpl", false, false, function (path: string) { if (path_is_gimp_color_palette(path)) { - import_gpl_run(path, _project_import_swatches_replace_existing); + // import_gpl_run(path, _project_import_swatches_replace_existing); } else { import_arm_run_swatches(path, _project_import_swatches_replace_existing); @@ -612,8 +605,6 @@ function project_reimport_texture_load(path: string, asset: asset_t) { }); } -let _project_reimport_texture_asset: asset_t; - function project_reimport_texture(asset: asset_t) { if (!file_exists(asset.file)) { let filters: string = string_array_join(path_texture_formats, ","); @@ -691,7 +682,7 @@ function project_export_swatches() { f = tr("untitled"); } if (path_is_gimp_color_palette(f)) { - export_gpl_run(path + path_sep + f, substring(f, 0, string_last_index_of(f, ".")), project_raw.swatches); + // export_gpl_run(path + path_sep + f, substring(f, 0, string_last_index_of(f, ".")), project_raw.swatches); } else { export_arm_run_swatches(path + path_sep + f); @@ -700,12 +691,32 @@ function project_export_swatches() { } function make_swatch(base: i32 = 0xffffffff): swatch_color_t { - let s: swatch_color_t = { base: base, opacity: 1.0, occlusion: 1.0, roughness: 0.0, metallic: 0.0, normal: 0xff8080ff, emission: 0.0, height: 0.0, subsurface: 0.0 }; + let s: swatch_color_t = { + base: base, + opacity: 1.0, + occlusion: 1.0, + roughness: 0.0, + metallic: 0.0, + normal: 0xff8080ff, + emission: 0.0, + height: 0.0, + subsurface: 0.0 + }; return s; } function project_clone_swatch(swatch: swatch_color_t): swatch_color_t { - let s: swatch_color_t = { base: swatch.base, opacity: swatch.opacity, occlusion: swatch.occlusion, roughness: swatch.roughness, metallic: swatch.metallic, normal: swatch.normal, emission: swatch.emission, height: swatch.height, subsurface: swatch.subsurface }; + let s: swatch_color_t = { + base: swatch.base, + opacity: swatch.opacity, + occlusion: swatch.occlusion, + roughness: swatch.roughness, + metallic: swatch.metallic, + normal: swatch.normal, + emission: swatch.emission, + height: swatch.height, + subsurface: swatch.subsurface + }; return s; } @@ -713,7 +724,39 @@ function project_set_default_swatches() { // 32-Color Palette by Andrew Kensler // http://eastfarthing.com/blog/2016-05-06-palette/ project_raw.swatches = []; - let colors: i32[] = [0xffffffff, 0xff000000, 0xffd6a090, 0xffa12c32, 0xfffa2f7a, 0xfffb9fda, 0xffe61cf7, 0xff992f7c, 0xff47011f, 0xff051155, 0xff4f02ec, 0xff2d69cb, 0xff00a6ee, 0xff6febff, 0xff08a29a, 0xff2a666a, 0xff063619, 0xff4a4957, 0xff8e7ba4, 0xffb7c0ff, 0xffacbe9c, 0xff827c70, 0xff5a3b1c, 0xffae6507, 0xfff7aa30, 0xfff4ea5c, 0xff9b9500, 0xff566204, 0xff11963b, 0xff51e113, 0xff08fdcc]; + let colors: i32[] = [ + 0xffffffff, + 0xff000000, + 0xffd6a090, + 0xffa12c32, + 0xfffa2f7a, + 0xfffb9fda, + 0xffe61cf7, + 0xff992f7c, + 0xff47011f, + 0xff051155, + 0xff4f02ec, + 0xff2d69cb, + 0xff00a6ee, + 0xff6febff, + 0xff08a29a, + 0xff2a666a, + 0xff063619, + 0xff4a4957, + 0xff8e7ba4, + 0xffb7c0ff, + 0xffacbe9c, + 0xff827c70, + 0xff5a3b1c, + 0xffae6507, + 0xfff7aa30, + 0xfff4ea5c, + 0xff9b9500, + 0xff566204, + 0xff11963b, + 0xff51e113, + 0xff08fdcc + ]; for (let i: i32 = 0; i < colors.length; ++i) { let c: i32 = colors[i]; array_push(project_raw.swatches, make_swatch(c)); @@ -730,7 +773,6 @@ function project_get_material_group_by_name(group_name: string): node_group_t { return null; } -///if (is_paint || is_sculpt) function project_is_material_group_in_use(group: node_group_t): bool { let canvases: ui_node_canvas_t[] = []; for (let i: i32 = 0; i < project_materials.length; ++i) { @@ -753,7 +795,6 @@ function project_is_material_group_in_use(group: node_group_t): bool { } return false; } -///end type node_group_t = { nodes?: ui_nodes_t; diff --git a/base/sources/render_path_base.ts b/base/sources/render_path_base.ts index 1de1d97e..0f6f262f 100644 --- a/base/sources/render_path_base.ts +++ b/base/sources/render_path_base.ts @@ -194,11 +194,7 @@ function render_path_base_commands(draw_commands: ()=>void) { ///if (arm_direct3d12 || arm_vulkan || arm_metal) if (context_raw.viewport_mode == viewport_mode_t.PATH_TRACE) { - ///if is_paint let use_live_layer: bool = context_raw.tool == workspace_tool_t.MATERIAL; - ///else - let use_live_layer: bool = false; - ///end render_path_raytrace_draw(use_live_layer); return; } @@ -265,11 +261,7 @@ function render_path_base_draw_split(draw_commands: ()=>void) { render_path_base_draw_gbuffer(); ///if (arm_direct3d12 || arm_vulkan || arm_metal) - ///if is_paint let use_live_layer: bool = context_raw.tool == workspace_tool_t.MATERIAL; - ///else - let use_live_layer: bool = false; - ///end context_raw.viewport_mode == viewport_mode_t.PATH_TRACE ? render_path_raytrace_draw(use_live_layer) : draw_commands(); ///else draw_commands(); diff --git a/base/sources/render_path_deferred.ts b/base/sources/render_path_deferred.ts index 13381b09..272d1cdb 100644 --- a/base/sources/render_path_deferred.ts +++ b/base/sources/render_path_deferred.ts @@ -180,8 +180,8 @@ function render_path_deferred_draw_deferred() { render_path_base_draw_deferred_light(); render_path_base_draw_bloom(); render_path_base_draw_ssr(); - // drawMotionBlur(); - // drawHistogram(); + // draw_motion_blur(); + // draw_histogram(); render_path_set_target("buf"); render_path_bind_target("tex", "tex"); diff --git a/base/sources/tab_browser.ts b/base/sources/tab_browser.ts index ce3f14f8..9fc4a291 100644 --- a/base/sources/tab_browser.ts +++ b/base/sources/tab_browser.ts @@ -3,6 +3,8 @@ let tab_browser_hpath: ui_handle_t = ui_handle_create(); let tab_browser_hsearch: ui_handle_t = ui_handle_create(); let tab_browser_known: bool = false; let tab_browser_last_path: string = ""; +let _tab_browser_draw_file: string; +let _tab_browser_draw_b: string; function tab_browser_show_directory(directory: string) { tab_browser_hpath.text = directory; @@ -10,9 +12,6 @@ function tab_browser_show_directory(directory: string) { ui_base_htabs[tab_area_t.STATUS].position = 0; } -let _tab_browser_draw_file: string; -let _tab_browser_draw_b: string; - function tab_browser_draw(htab: ui_handle_t) { let ui: ui_t = ui_base_ui; let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; diff --git a/base/sources/tab_brushes.ts b/base/sources/tab_brushes.ts index 377ae148..87c90f69 100644 --- a/base/sources/tab_brushes.ts +++ b/base/sources/tab_brushes.ts @@ -1,6 +1,4 @@ -///if (is_paint || is_sculpt) - let _tab_brushes_draw_i: i32; function tab_brushes_draw(htab: ui_handle_t) { @@ -169,5 +167,3 @@ function tab_brushes_delete_brush(b: slot_brush_t) { array_splice(project_brushes, i, 1); ui_base_hwnds[1].redraws = 2; } - -///end diff --git a/base/sources/tab_console.ts b/base/sources/tab_console.ts index cb238828..68c7aab1 100644 --- a/base/sources/tab_console.ts +++ b/base/sources/tab_console.ts @@ -56,7 +56,7 @@ function tab_console_draw(htab: ui_handle_t) { ui_end_sticky(); let _font: g2_font_t = ui.ops.font; - let _fontSize: i32 = ui.font_size; + let _font_size: i32 = ui.font_size; let f: g2_font_t = data_get_font("font_mono.ttf"); ui_set_font(ui, f); ui.font_size = math_floor(15 * ui_SCALE(ui)); @@ -65,6 +65,6 @@ function tab_console_draw(htab: ui_handle_t) { ui_text(t); } ui_set_font(ui, _font); - ui.font_size = _fontSize; + ui.font_size = _font_size; } } diff --git a/base/sources/tab_fonts.ts b/base/sources/tab_fonts.ts index 5a8fa060..52c4dcdc 100644 --- a/base/sources/tab_fonts.ts +++ b/base/sources/tab_fonts.ts @@ -1,6 +1,4 @@ -///if (is_paint || is_sculpt) - let _tab_fonts_draw_i: i32; function tab_fonts_draw(htab: ui_handle_t) { @@ -172,5 +170,3 @@ function tab_fonts_delete_font(font: slot_font_t) { ui_base_hwnds[2].redraws = 2; } - -///end diff --git a/base/sources/tab_history.ts b/base/sources/tab_history.ts index 45384014..ecd8dadb 100644 --- a/base/sources/tab_history.ts +++ b/base/sources/tab_history.ts @@ -1,6 +1,4 @@ -///if (is_paint || is_sculpt) - function tab_history_draw(htab: ui_handle_t) { let ui: ui_t = ui_base_ui; if (ui_tab(htab, tr("History"))) { @@ -25,5 +23,3 @@ function tab_history_draw(htab: ui_handle_t) { } } } - -///end diff --git a/base/sources/tab_layers.ts b/base/sources/tab_layers.ts index cc78a245..0c5cab94 100644 --- a/base/sources/tab_layers.ts +++ b/base/sources/tab_layers.ts @@ -2,6 +2,8 @@ let tab_layers_layer_name_edit: i32 = -1; let tab_layers_layer_name_handle: ui_handle_t = ui_handle_create(); let tab_layers_show_context_menu: bool = false; +let tab_layers_l: slot_layer_t; +let tab_layers_mini: bool; function tab_layers_draw(htab: ui_handle_t) { let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_base_sidebar_mini_w; @@ -717,9 +719,6 @@ function tab_layers_can_merge_down(l: slot_layer_t): bool { return true; } -let tab_layers_l: slot_layer_t; -let tab_layers_mini: bool; - function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { tab_layers_l = l; diff --git a/base/sources/tab_materials.ts b/base/sources/tab_materials.ts index d5cae309..ada3d8d1 100644 --- a/base/sources/tab_materials.ts +++ b/base/sources/tab_materials.ts @@ -1,4 +1,6 @@ +let _tab_materials_draw_slots: i32; + function tab_materials_draw(htab: ui_handle_t) { let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_base_sidebar_mini_w; mini ? tab_materials_draw_mini(htab) : tab_materials_draw_full(htab); @@ -46,8 +48,6 @@ function tab_materials_button_nodes() { } } -let _tab_materials_draw_slots: i32; - function tab_materials_draw_slots(mini: bool) { let ui: ui_t = ui_base_ui; let slotw: i32 = math_floor(51 * ui_SCALE(ui)); diff --git a/base/sources/tab_meshes.ts b/base/sources/tab_meshes.ts index a136b738..3b793fc8 100644 --- a/base/sources/tab_meshes.ts +++ b/base/sources/tab_meshes.ts @@ -10,8 +10,7 @@ function tab_meshes_draw(htab: ui_handle_t) { ///if (is_paint || is_sculpt) if (config_raw.touch_ui) { - let row: f32[] = [1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]; - ui_row(row); + ui_row6(); } else { let row: f32[] = [1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]; @@ -21,8 +20,7 @@ function tab_meshes_draw(htab: ui_handle_t) { ///if is_lab if (config_raw.touch_ui) { - let row: f32[] = [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7]; - ui_row(row); + ui_row7(); } else { let row: f32[] = [1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14]; diff --git a/base/sources/tab_particles.ts b/base/sources/tab_particles.ts index 0552b23f..9f88178a 100644 --- a/base/sources/tab_particles.ts +++ b/base/sources/tab_particles.ts @@ -1,6 +1,4 @@ -///if (is_paint || is_sculpt) - function tab_particles_draw(htab: ui_handle_t) { if (ui_tab(htab, tr("Particles"))) { ui_begin_sticky(); @@ -18,5 +16,3 @@ function tab_particles_draw(htab: ui_handle_t) { ui_end_sticky(); } } - -///end diff --git a/base/sources/tab_script.ts b/base/sources/tab_script.ts index 9fe34d68..b28d8695 100644 --- a/base/sources/tab_script.ts +++ b/base/sources/tab_script.ts @@ -9,8 +9,7 @@ function tab_script_draw(htab: ui_handle_t) { ui_begin_sticky(); if (config_raw.touch_ui) { - let row: f32[] = [1 / 4, 1 / 4, 1 / 4, 1 / 4]; - ui_row(row); + ui_row4(); } else { let row: f32[] = [1 / 14, 1 / 14, 1 / 14, 1 / 14]; diff --git a/base/sources/tab_swatches.ts b/base/sources/tab_swatches.ts index 3e84328b..74e37c75 100644 --- a/base/sources/tab_swatches.ts +++ b/base/sources/tab_swatches.ts @@ -1,6 +1,7 @@ let _tab_swatches_empty: image_t; let tab_swatches_drag_pos: i32 = -1; +let _tab_swatches_draw_i: i32; function tab_swatches_empty_set(image: image_t) { _tab_swatches_empty = image; @@ -18,8 +19,6 @@ function tab_swatches_empty_get(): image_t { return _tab_swatches_empty; } -let _tab_swatches_draw_i: i32; - function tab_swatches_draw(htab: ui_handle_t) { let ui: ui_t = ui_base_ui; let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; @@ -28,7 +27,7 @@ function tab_swatches_draw(htab: ui_handle_t) { ui_begin_sticky(); if (config_raw.touch_ui) { let row: f32[] = [1 / 5, 1 / 5, 1 / 5, 1 / 5, 1 / 5]; - ui_row(row); + ui_row5(); } else { let row: f32[] = [1 / 14, 1 / 14, 1 / 14, 1 / 14, 1 / 14]; diff --git a/base/sources/tab_textures.ts b/base/sources/tab_textures.ts index f7309a5f..76987bfb 100644 --- a/base/sources/tab_textures.ts +++ b/base/sources/tab_textures.ts @@ -274,14 +274,12 @@ function tab_textures_delete_texture(asset: asset_t) { } ui_base_hwnds[tab_area_t.STATUS].redraws = 2; - ///if is_paint if (context_raw.tool == workspace_tool_t.COLORID && i == context_raw.colorid_handle.position) { ui_header_handle.redraws = 2; context_raw.ddirty = 2; context_raw.colorid_picked = false; ui_toolbar_handle.redraws = 1; } - ///end data_delete_image(asset.file); map_delete(project_asset_map, asset.id); diff --git a/base/sources/translator.ts b/base/sources/translator.ts index 39dd6786..74efd412 100644 --- a/base/sources/translator.ts +++ b/base/sources/translator.ts @@ -2,8 +2,12 @@ let translator_translations: map_t = map_create(); // The font index is a value specific to font_cjk.ttc let translator_cjk_font_indices: map_t = null; - let translator_last_locale: string = "en"; +let _translator_load_translations_cjk_font_path: string; +let _translator_load_translations_cjk_font_disk_path: string; +let _translator_init_font_cjk: bool; +let _translator_init_font_font_path: string; +let _translator_init_font_font_scale: f32; // Mark strings as localizable in order to be parsed by the extract_locale script // The string will not be translated to the currently selected locale though @@ -32,9 +36,6 @@ function tr(id: string, vars: map_t = null): string { return translation; } -let _translator_load_translations_cjk_font_path: string; -let _translator_load_translations_cjk_font_disk_path: string; - // (Re)loads translations for the specified locale function translator_load_translations(new_locale: string) { @@ -140,10 +141,6 @@ function translator_load_translations(new_locale: string) { } } -let _translator_init_font_cjk: bool; -let _translator_init_font_font_path: string; -let _translator_init_font_font_scale: f32; - function translator_init_font(cjk: bool, font_path: string, font_scale: f32) { i32_array_sort(_g2_font_glyphs, function (pa: u32_ptr, pb: u32_ptr): i32 { let a: i32 = (i32)DEREFERENCE(pa); diff --git a/base/sources/ui_base.ts b/base/sources/ui_base.ts index f4508c5a..48ae002a 100644 --- a/base/sources/ui_base.ts +++ b/base/sources/ui_base.ts @@ -1,4 +1,9 @@ +type tab_draw_t = { + f: (h: ui_handle_t)=>void; +}; +type tab_draw_array_t = tab_draw_t[]; + let ui_base_show: bool = true; let ui_base_ui: ui_t; let ui_base_border_started: i32 = 0; @@ -7,14 +12,8 @@ let ui_base_action_paint_remap: string = ""; let ui_base_operator_search_offset: i32 = 0; let ui_base_undo_tap_time: f32 = 0.0; let ui_base_redo_tap_time: f32 = 0.0; - let ui_base_hwnds: ui_handle_t[] = ui_base_init_hwnds(); let ui_base_htabs: ui_handle_t[] = ui_base_init_htabs(); - -type tab_draw_t = { - f: (h: ui_handle_t)=>void; -}; -type tab_draw_array_t = tab_draw_t[]; let ui_base_hwnd_tabs: tab_draw_array_t[] = ui_base_init_hwnd_tabs(); ///if is_lab @@ -34,6 +33,7 @@ let ui_base_default_sidebar_w: i32 = ui_base_default_sidebar_full_w; let ui_base_tabx: i32 = 0; let ui_base_hminimized: ui_handle_t = ui_handle_create(); let ui_base_sidebar_mini_w: i32 = ui_base_default_sidebar_mini_w; +let _ui_base_operator_search_first: bool; function ui_base_init_hwnds(): ui_handle_t[] { let hwnds: ui_handle_t[] = [ui_handle_create(), ui_handle_create(), ui_handle_create()]; @@ -207,7 +207,7 @@ function ui_base_init() { let world: world_data_t = scene_world; if (context_raw.saved_envmap == null) { - // raw.savedEnvmap = world._envmap; + // raw.saved_envmap = world._envmap; context_raw.default_irradiance = world._.irradiance; context_raw.default_radiance = world._.radiance; context_raw.default_radiance_mipmaps = world._.radiance_mipmaps; @@ -332,12 +332,9 @@ function ui_base_update() { else if (operator_shortcut(map_get(config_keymap, "file_new"))) { project_new_box(); } - ///if (is_paint || is_lab) else if (operator_shortcut(map_get(config_keymap, "file_export_textures"))) { if (context_raw.texture_export_path == "") { // First export, ask for path - ///if is_paint context_raw.layers_export = export_mode_t.VISIBLE; - ///end box_export_show_textures(); } else { @@ -347,12 +344,9 @@ function ui_base_update() { } } else if (operator_shortcut(map_get(config_keymap, "file_export_textures_as"))) { - ///if (is_paint || is_sculpt) context_raw.layers_export = export_mode_t.VISIBLE; - ///end box_export_show_textures(); } - ///end else if (operator_shortcut(map_get(config_keymap, "file_import_assets"))) { project_import_asset(); } @@ -731,7 +725,6 @@ function ui_base_update() { } } - ///if (is_paint || is_sculpt) if (ui_base_border_handle != null) { if (ui_base_border_handle == ui_nodes_hwnd || ui_base_border_handle == ui_view2d_hwnd) { if (ui_base_border_started == border_side_t.LEFT) { @@ -780,38 +773,6 @@ function ui_base_update() { } } } - ///end - - ///if is_lab - if (ui_base_border_handle != null) { - if (ui_base_border_handle == ui_nodes_hwnd || ui_base_border_handle == ui_view2d_hwnd) { - if (ui_base_border_started == border_side_t.LEFT) { - config_raw.layout[layout_size_t.NODES_W] -= math_floor(mouse_movement_x); - if (config_raw.layout[layout_size_t.NODES_W] < 32) { - config_raw.layout[layout_size_t.NODES_W] = 32; - } - else if (config_raw.layout[layout_size_t.NODES_W] > sys_width() * 0.7) { - config_raw.layout[layout_size_t.NODES_W] = math_floor(sys_width() * 0.7); - } - } - else { // UINodes / UIView2D ratio - config_raw.layout[layout_size_t.NODES_H] -= math_floor(mouse_movement_y); - if (config_raw.layout[layout_size_t.NODES_H] < 32) { - config_raw.layout[layout_size_t.NODES_H] = 32; - } - else if (config_raw.layout[layout_size_t.NODES_H] > app_h() * 0.95) { - config_raw.layout[layout_size_t.NODES_H] = math_floor(app_h() * 0.95); - } - } - } - else if (ui_base_border_handle == ui_base_hwnds[tab_area_t.STATUS]) { - let my: i32 = math_floor(mouse_movement_y); - if (config_raw.layout[layout_size_t.STATUS_H] - my >= ui_status_default_status_h * config_raw.window_scale && config_raw.layout[layout_size_t.STATUS_H] - my < sys_height() * 0.7) { - config_raw.layout[layout_size_t.STATUS_H] -= my; - } - } - } - ///end if (!mouse_down()) { ui_base_border_handle = null; @@ -888,8 +849,6 @@ function ui_base_view_top() { } } -let _ui_base_operator_search_first: bool; - function ui_base_operator_search() { _ui_base_operator_search_first = true; @@ -959,7 +918,6 @@ function ui_base_hit_rect(mx: f32, my: f32, x: i32, y: i32, w: i32, h: i32): boo return mx > x && mx < x + w && my > y && my < y + h; } -///if (is_paint || is_sculpt) function ui_base_get_brush_stencil_rect(): rect_t { let w: i32 = math_floor(context_raw.brush_stencil_image.width * (base_h() / context_raw.brush_stencil_image.height) * context_raw.brush_stencil_scale); let h: i32 = math_floor(base_h() * context_raw.brush_stencil_scale); @@ -973,7 +931,6 @@ function ui_base_get_brush_stencil_rect(): rect_t { }; return r; } -///end function ui_base_update_ui() { if (console_message_timer > 0) { @@ -983,15 +940,12 @@ function ui_base_update_ui() { } } - ///if (is_paint || is_sculpt) ui_base_sidebar_mini_w = math_floor(ui_base_default_sidebar_mini_w * ui_SCALE(ui_base_ui)); - ///end if (!base_ui_enabled) { return; } - ///if (is_paint || is_sculpt) // Same mapping for paint and rotate (predefined in touch keymap) if (context_in_viewport()) { if (mouse_started() && map_get(config_keymap, "action_paint") == map_get(config_keymap, "action_rotate")) { @@ -1074,13 +1028,13 @@ function ui_base_update_ui() { context_raw.brush_stencil_x += (old_w - new_w) / base_w() / 2; context_raw.brush_stencil_y += (old_h - new_h) / base_h() / 2; } - ///end let set_clone_source: bool = context_raw.tool == workspace_tool_t.CLONE && operator_shortcut(map_get(config_keymap, "set_clone_source") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); - ///if (is_paint || is_sculpt) let decal: bool = context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT; let decal_mask: bool = decal && operator_shortcut(map_get(config_keymap, "decal_mask") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN); + + ///if (is_paint || is_sculpt) let down: bool = operator_shortcut(map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN) || decal_mask || set_clone_source || @@ -1109,7 +1063,6 @@ function ui_base_update_ui() { } ///end - ///if (is_paint || is_sculpt) ///if arm_ios // No hover on iPad, decals are painted by pen release if (decal) { @@ -1119,19 +1072,16 @@ function ui_base_update_ui() { } } ///end - ///end if (down) { let mx: i32 = mouse_view_x(); let my: i32 = mouse_view_y(); let ww: i32 = app_w(); - ///if (is_paint || is_sculpt) if (context_raw.paint2d) { mx -= app_w(); ww = ui_view2d_ww; } - ///end if (mx < ww && mx > app_x() && @@ -1154,7 +1104,6 @@ function ui_base_update_ui() { context_raw.last_paint_vec_y = context_raw.last_paint_y; } - ///if (is_paint || is_sculpt) history_push_undo = true; if (context_raw.tool == workspace_tool_t.CLONE && context_raw.clone_start_x >= 0.0) { // Clone delta @@ -1175,7 +1124,6 @@ function ui_base_update_ui() { else if (context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.UV_ISLAND) { util_uv_uvislandmap_cached = false; } - ///end } context_raw.brush_time += time_delta(); @@ -1198,7 +1146,7 @@ function ui_base_update_ui() { context_raw.brush_time = 0; context_raw.prev_paint_vec_x = -1; context_raw.prev_paint_vec_y = -1; - ///if (!arm_direct3d12 && !arm_vulkan && !arm_metal) // Keep accumulated samples for D3D12 + ///if (arm_opengl || arm_direct3d11) // Keep accumulated samples for D3D12 context_raw.ddirty = 3; ///end context_raw.brush_blend_dirty = true; // Update brush mask @@ -1431,11 +1379,9 @@ function ui_base_render_cursor() { return; } - ///if is_paint if (context_raw.tool == workspace_tool_t.MATERIAL || context_raw.tool == workspace_tool_t.BAKE) { return; } - ///end g2_set_color(0xffffffff); @@ -1450,7 +1396,6 @@ function ui_base_render_cursor() { my += context_raw.lock_started_y - sys_height() / 2; } - ///if is_paint if (context_raw.brush_stencil_image != null && // @ts-ignore context_raw.tool != workspace_tool_t.BAKE && @@ -1487,7 +1432,6 @@ function ui_base_render_cursor() { g2_set_transformation(mat3_nan()); } } - ///end // Show picked material next to cursor if (context_raw.tool == workspace_tool_t.PICKER && context_raw.picker_select_material && context_raw.color_picker_callback == null) { @@ -1607,7 +1551,6 @@ function ui_base_show_material_nodes() { base_resize(); } -///if (is_paint || is_sculpt) function ui_base_show_brush_nodes() { // Clear input state as ui receives input events even when not drawn _ui_end_input(ui_nodes_ui); @@ -1615,7 +1558,6 @@ function ui_base_show_brush_nodes() { ui_nodes_canvas_type = canvas_type_t.BRUSH; base_resize(); } -///end function ui_base_show_2d_view(type: view_2d_type_t) { // Clear input state as ui receives input events even when not drawn @@ -1652,7 +1594,6 @@ function ui_base_set_icon_scale() { function ui_base_on_border_hover(handle: ui_handle_t, side: i32) { if (!base_ui_enabled) return; - ///if (is_paint || is_sculpt) if (handle != ui_base_hwnds[tab_area_t.SIDEBAR0] && handle != ui_base_hwnds[tab_area_t.SIDEBAR1] && handle != ui_base_hwnds[tab_area_t.STATUS] && @@ -1669,19 +1610,6 @@ function ui_base_on_border_hover(handle: ui_handle_t, side: i32) { if (handle == ui_base_hwnds[tab_area_t.SIDEBAR0] && side == border_side_t.TOP) { return; } - ///end - - ///if is_lab - if (handle != ui_base_hwnds[tab_area_t.STATUS] && - handle != ui_nodes_hwnd && - handle != ui_view2d_hwnd) return; // Scalable handles - if (handle == ui_view2d_hwnd && side != border_side_t.LEFT) { - return; - } - if (handle == ui_nodes_hwnd && side == border_side_t.TOP && !ui_view2d_show) { - return; - } - ///end if (handle == ui_nodes_hwnd && side != border_side_t.LEFT && side != border_side_t.TOP) { return; @@ -1744,9 +1672,7 @@ function ui_base_tag_ui_redraw() { ui_base_hwnds[tab_area_t.STATUS].redraws = 2; ui_menubar_workspace_handle.redraws = 2; ui_menubar_menu_handle.redraws = 2; - ///if (is_paint || is_sculpt) ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; ui_base_hwnds[tab_area_t.SIDEBAR1].redraws = 2; ui_toolbar_handle.redraws = 2; - ///end } diff --git a/base/sources/ui_box.ts b/base/sources/ui_box.ts index 2673c794..ea063106 100644 --- a/base/sources/ui_box.ts +++ b/base/sources/ui_box.ts @@ -11,9 +11,7 @@ let ui_box_modalh: i32 = 170; let ui_box_modal_on_hide: ()=>void = null; let ui_box_draws: i32 = 0; let ui_box_copyable: bool = false; -///if (arm_android || arm_ios) let ui_box_tween_alpha: f32 = 0.0; -///end function ui_box_init() { ui_box_hwnd.redraws = 2; @@ -89,8 +87,7 @@ function ui_box_render() { ///if (arm_windows || arm_linux || arm_macos) if (ui_box_copyable) { - let row: f32[] = [1 / 3, 1 / 3, 1 / 3]; - ui_row(row); + ui_row3(); } else { let row: f32[] = [2 / 3, 1 / 3]; @@ -173,7 +170,6 @@ function ui_box_hide_internal() { base_redraw_ui(); } -///if (arm_android || arm_ios) function ui_box_tween_in() { tween_reset(); @@ -196,7 +192,6 @@ function ui_box_tween_out() { function ui_box_tween_tick() { base_redraw_ui(); } -///end function ui_box_window_border(ui: ui_t) { if (ui.scissor) { diff --git a/base/sources/ui_files.ts b/base/sources/ui_files.ts index 7d4c6caf..c1bd5635 100644 --- a/base/sources/ui_files.ts +++ b/base/sources/ui_files.ts @@ -1,4 +1,9 @@ +type draw_cloud_icon_data_t = { + f: string; + image: image_t; +}; + let ui_files_default_path: string = ///if arm_windows "C:\\Users" @@ -20,6 +25,8 @@ let ui_files_icon_map: map_t = null; let ui_files_selected: i32 = -1; let ui_files_show_extensions: bool = false; let ui_files_offline: bool = false; +let _ui_files_file_browser_handle: ui_handle_t; +let _ui_files_file_browser_f: string; function ui_files_show(filters: string, is_save: bool, open_multiple: bool, files_done: (s: string)=>void) { if (is_save) { @@ -63,14 +70,6 @@ function ui_files_release_keys() { ///end } -let _ui_files_file_browser_handle: ui_handle_t; -let _ui_files_file_browser_f: string; - -type draw_cloud_icon_data_t = { - f: string; - image: image_t; -}; - function make_draw_cloud_icon_data(f: string, image: image_t): draw_cloud_icon_data_t { let data: draw_cloud_icon_data_t = { f: f, image: image }; return data; @@ -97,7 +96,10 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = document_directory = substring(document_directory, 0, document_directory.length - 8); // Strip /"untitled" ///end - if (handle.text == "") handle.text = ui_files_default_path; + if (handle.text == "") { + handle.text = ui_files_default_path; + } + if (handle.text != ui_files_last_path || search != ui_files_last_search || refresh) { ui_files_files = []; @@ -263,8 +265,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = ///if arm_ios blob_path = document_directory + blob_path; - // TODO: implement native .arm parsing first - ///else + ///end let buffer: buffer_t = iron_load_blob(blob_path); let raw: project_format_t = armpack_decode(buffer); @@ -272,8 +273,6 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let bytes_icon: any = raw.material_icons[0]; icon = image_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } - - ///if (is_paint || is_sculpt) else if (raw.mesh_icons != null) { let bytes_icon: any = raw.mesh_icons[0]; icon = image_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); @@ -282,7 +281,6 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = let bytes_icon: any = raw.brush_icons[0]; icon = image_from_bytes(lz4_decode(bytes_icon, 256 * 256 * 4), 256, 256); } - ///end ///if is_lab if (raw.mesh_icon != null) { @@ -292,7 +290,6 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = ///end map_set(ui_files_icon_map, key, icon); - ///end } if (icon != null) { let w: i32 = 50; diff --git a/base/sources/ui_menu.ts b/base/sources/ui_menu.ts index 9c85e53a..6410984c 100644 --- a/base/sources/ui_menu.ts +++ b/base/sources/ui_menu.ts @@ -590,8 +590,7 @@ function ui_menu_render() { } ui_text_area(h, ui_align_t.LEFT, false); - let row: f32[] = [1 / 3, 1 / 3, 1 / 3]; - ui_row(row); + ui_row3(); ///if (arm_windows || arm_linux || arm_macos) if (ui_button(tr("Copy"))) { diff --git a/base/sources/ui_nodes.ts b/base/sources/ui_nodes.ts index a427b4d0..141400a4 100644 --- a/base/sources/ui_nodes.ts +++ b/base/sources/ui_nodes.ts @@ -38,6 +38,22 @@ let ui_nodes_hwnd: ui_handle_t = ui_handle_create(); let ui_nodes_group_stack: node_group_t[] = []; let ui_nodes_controls_down: bool = false; +let _ui_nodes_on_link_drag_link_drag: ui_node_link_t; +let _ui_nodes_on_link_drag_node: ui_node_t; +let _ui_nodes_on_socket_released_socket: ui_node_socket_t; +let _ui_nodes_on_socket_released_node: ui_node_t; +let _ui_nodes_htype: ui_handle_t = ui_handle_create(); +let _ui_nodes_hname: ui_handle_t = ui_handle_create(); +let _ui_nodes_hmin: ui_handle_t = ui_handle_create(); +let _ui_nodes_hmax: ui_handle_t = ui_handle_create(); +let _ui_nodes_hval0: ui_handle_t = ui_handle_create(); +let _ui_nodes_hval1: ui_handle_t = ui_handle_create(); +let _ui_nodes_hval2: ui_handle_t = ui_handle_create(); +let _ui_nodes_hval3: ui_handle_t = ui_handle_create(); +let _ui_nodes_on_canvas_released_selected: ui_node_t; +let _ui_nodes_node_search_first: bool; +let _ui_nodes_node_search_done: ()=>void; + function ui_viewnodes_init() { ui_nodes_on_link_drag = ui_viewnodes_on_link_drag; ui_nodes_on_socket_released = ui_viewnodes_on_socket_released; @@ -57,9 +73,6 @@ function ui_viewnodes_init() { ui_nodes_ui.scroll_enabled = false; } -let _ui_nodes_on_link_drag_link_drag: ui_node_link_t; -let _ui_nodes_on_link_drag_node: ui_node_t; - function ui_viewnodes_on_link_drag(link_drag_id: i32, is_new_link: bool) { if (!is_new_link) { return; @@ -132,18 +145,6 @@ function ui_viewnodes_on_link_drag(link_drag_id: i32, is_new_link: bool) { } } -let _ui_nodes_on_socket_released_socket: ui_node_socket_t; -let _ui_nodes_on_socket_released_node: ui_node_t; - -let _ui_nodes_htype: ui_handle_t = ui_handle_create(); -let _ui_nodes_hname: ui_handle_t = ui_handle_create(); -let _ui_nodes_hmin: ui_handle_t = ui_handle_create(); -let _ui_nodes_hmax: ui_handle_t = ui_handle_create(); -let _ui_nodes_hval0: ui_handle_t = ui_handle_create(); -let _ui_nodes_hval1: ui_handle_t = ui_handle_create(); -let _ui_nodes_hval2: ui_handle_t = ui_handle_create(); -let _ui_nodes_hval3: ui_handle_t = ui_handle_create(); - function ui_viewnodes_on_socket_released(socket_id: i32) { let nodes: ui_nodes_t = ui_nodes_get_nodes(); let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true); @@ -197,8 +198,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { let max: f32 = ui_float_input(_ui_nodes_hmax, tr("Max")); let default_value: f32_array_t = null; if (type == 0) { - let row: f32[] = [1 / 4, 1 / 4, 1 / 4, 1 / 4]; - ui_row(row); + ui_row4(); ui_float_input(_ui_nodes_hval0, tr("R")); ui_float_input(_ui_nodes_hval1, tr("G")); ui_float_input(_ui_nodes_hval2, tr("B")); @@ -207,8 +207,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { _ui_nodes_hval0.value, _ui_nodes_hval1.value, _ui_nodes_hval2.value, _ui_nodes_hval3.value); } else if (type == 1) { - let row: f32[] = [1 / 3, 1 / 3, 1 / 3]; - ui_row(row); + ui_row3(); _ui_nodes_hval0.value = ui_float_input(_ui_nodes_hval0, tr("X")); _ui_nodes_hval1.value = ui_float_input(_ui_nodes_hval1, tr("Y")); _ui_nodes_hval2.value = ui_float_input(_ui_nodes_hval2, tr("Z")); @@ -270,8 +269,6 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { } } -let _ui_nodes_on_canvas_released_selected: ui_node_t; - function ui_viewnodes_on_canvas_released() { if (ui_nodes_ui.input_released_r && context_in_nodes() && @@ -603,9 +600,6 @@ function ui_nodes_canvas_changed() { ui_nodes_recompile_mat_final = true; } -let _ui_nodes_node_search_first: bool; -let _ui_nodes_node_search_done: ()=>void; - function ui_nodes_node_search(x: i32 = -1, y: i32 = -1, done: ()=>void = null) { _ui_nodes_node_search_first = true; _ui_nodes_node_search_done = done; @@ -1347,13 +1341,8 @@ function ui_nodes_push_undo(last_canvas: ui_node_canvas_t = null) { canvas_group = array_index_of(project_material_groups, ui_nodes_group_stack[ui_nodes_group_stack.length - 1]); } - ///if (is_paint || is_sculpt) ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2; history_edit_nodes(last_canvas, ui_nodes_canvas_type, canvas_group); - ///end - ///if is_lab - history_edit_nodes(last_canvas, canvas_group); - ///end } function ui_nodes_accept_asset_drag(index: i32) { @@ -1512,7 +1501,6 @@ function ui_nodes_make_group_node(group_canvas: ui_node_canvas_t, nodes: ui_node return node; } -///if (is_paint || is_sculpt) function ui_nodes_make_node_preview() { let ui_nodes: ui_nodes_t = context_raw.material.nodes; if (ui_nodes.nodes_selected_id.length == 0) { @@ -1542,7 +1530,6 @@ function ui_nodes_make_node_preview() { ui_nodes_hwnd.redraws = 2; util_render_make_node_preview(context_raw.material.canvas, node, context_raw.node_preview); } -///end function ui_nodes_has_group(c: ui_node_canvas_t): bool { for (let i: i32 = 0; i < c.nodes.length; ++i) { diff --git a/base/sources/ui_toolbar.ts b/base/sources/ui_toolbar.ts index 83ee8bb6..75ca1662 100644 --- a/base/sources/ui_toolbar.ts +++ b/base/sources/ui_toolbar.ts @@ -8,7 +8,6 @@ let ui_toolbar_default_w: i32 = 36; let ui_toolbar_handle: ui_handle_t = ui_handle_create(); let ui_toolbar_w: i32 = ui_toolbar_default_w; let ui_toolbar_last_tool: i32 = 0; - let ui_toolbar_tool_names: string[] = [ _tr("Brush"), _tr("Eraser"), @@ -26,11 +25,11 @@ let ui_toolbar_tool_names: string[] = [ _tr("Material"), ]; +let _ui_toolbar_i: i32; + function ui_toolbar_init() { } -let _ui_toolbar_i: i32; - function ui_toolbar_draw_tool(i: i32, ui: ui_t, img: image_t, icon_accent: i32, keys: string[]) { ui._x += 2; if (context_raw.tool == i) { diff --git a/base/sources/ui_view2d.ts b/base/sources/ui_view2d.ts index 7fe72087..a2bd05bc 100644 --- a/base/sources/ui_view2d.ts +++ b/base/sources/ui_view2d.ts @@ -5,13 +5,11 @@ let ui_view2d_text_input_hover: bool = false; let ui_view2d_uvmap_show: bool = false; let ui_view2d_tex_type: paint_tex_t = paint_tex_t.BASE; let ui_view2d_layer_mode: view_2d_layer_mode_t = view_2d_layer_mode_t.SELECTED; - ///if (is_paint || is_sculpt) let ui_view2d_type: view_2d_type_t = view_2d_type_t.LAYER; ///else let ui_view2d_type: view_2d_type_t = view_2d_type_t.ASSET; ///end - let ui_view2d_show: bool = false; let ui_view2d_wx: i32; let ui_view2d_wy: i32; @@ -24,6 +22,11 @@ let ui_view2d_pan_y: f32 = 0.0; let ui_view2d_pan_scale: f32 = 1.0; let ui_view2d_tiled_show: bool = false; let ui_view2d_controls_down: bool = false; +let _ui_view2d_render_tex: image_t; +let _ui_view2d_render_x: f32; +let _ui_view2d_render_y: f32; +let _ui_view2d_render_tw: f32; +let _ui_view2d_render_th: f32; function ui_view2d_init() { ///if (is_paint || is_sculpt) @@ -54,12 +57,6 @@ function ui_view2d_init() { ui_view2d_ui.scroll_enabled = false; } -let _ui_view2d_render_tex: image_t; -let _ui_view2d_render_x: f32; -let _ui_view2d_render_y: f32; -let _ui_view2d_render_tw: f32; -let _ui_view2d_render_th: f32; - function ui_view2d_render() { ui_view2d_ww = config_raw.layout[layout_size_t.NODES_W]; diff --git a/base/sources/uniforms_ext.ts b/base/sources/uniforms_ext.ts index 1191d7e3..d7c4377b 100644 --- a/base/sources/uniforms_ext.ts +++ b/base/sources/uniforms_ext.ts @@ -68,8 +68,6 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str else if (link == "_bloom_sample_scale") { return render_path_base_bloom_sample_scale; } - - ///if (is_paint || is_sculpt) else if (link == "_brush_scale_x") { return 1 / context_raw.brush_scale_x; } @@ -129,7 +127,6 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str else if (link == "_picker_height") { return context_raw.picked_color.height; } - ///end if (parser_material_script_links != null) { let keys: string[] = map_keys(parser_material_script_links); @@ -157,7 +154,6 @@ function uniforms_ext_vec2_link(object: object_t, mat: material_data_t, link: st else if (link == "_texpaint_size") { return vec2_create(config_get_texture_res_x(), config_get_texture_res_y()); } - ///if (is_paint || is_sculpt) else if (link == "_brush_angle") { let brush_angle: f32 = context_raw.brush_angle + context_raw.brush_nodes_angle; let angle: f32 = context_raw.layer.fill_layer != null ? context_raw.layer.angle : brush_angle; @@ -167,7 +163,6 @@ function uniforms_ext_vec2_link(object: object_t, mat: material_data_t, link: st } return vec2_create(math_cos(-angle), math_sin(-angle)); } - ///end return vec2_nan(); } @@ -175,7 +170,6 @@ function uniforms_ext_vec2_link(object: object_t, mat: material_data_t, link: st function uniforms_ext_vec3_link(object: object_t, mat: material_data_t, link: string): vec4_t { let v: vec4_t = vec4_nan(); - ///if (is_paint || is_sculpt) if (link == "_brush_direction") { v = _uniforms_vec; // Discard first paint for directional brush @@ -238,12 +232,10 @@ function uniforms_ext_vec3_link(object: object_t, mat: material_data_t, link: st return v; } ///end - ///end return v; } -///if (is_paint || is_sculpt) function vec2d(x: f32): f32 { // Transform from 3d viewport coord to 2d view coord context_raw.paint2d_view = false; @@ -251,30 +243,23 @@ function vec2d(x: f32): f32 { context_raw.paint2d_view = true; return res; } -///end function uniforms_ext_vec4_link(object: object_t, mat: material_data_t, link: string): vec4_t { if (link == "_input_brush") { let down: bool = mouse_down() || pen_down(); let v: vec4_t = vec4_create(context_raw.paint_vec.x, context_raw.paint_vec.y, down ? 1.0 : 0.0, 0.0); - - ///if (is_paint || is_sculpt) if (context_raw.paint2d) { v.x = vec2d(v.x); } - ///end return v; } else if (link == "_input_brush_last") { let down: bool = mouse_down() || pen_down(); let v: vec4_t = vec4_create(context_raw.last_paint_vec_x, context_raw.last_paint_vec_y, down ? 1.0 : 0.0, 0.0); - - ///if (is_paint || is_sculpt) if (context_raw.paint2d) { v.x = vec2d(v.x); } - ///end return v; } @@ -284,7 +269,6 @@ function uniforms_ext_vec4_link(object: object_t, mat: material_data_t, link: st else if (link == "_envmap_data_world") { return vec4_create(context_raw.envmap_angle, math_sin(-context_raw.envmap_angle), math_cos(-context_raw.envmap_angle), context_raw.show_envmap ? scene_world.strength : 1.0); } - ///if (is_paint || is_sculpt) else if (link == "_stencil_transform") { let v: vec4_t = vec4_create(context_raw.brush_stencil_x, context_raw.brush_stencil_y, context_raw.brush_stencil_scale, context_raw.brush_stencil_angle); if (context_raw.paint2d) { @@ -303,19 +287,16 @@ function uniforms_ext_vec4_link(object: object_t, mat: material_data_t, link: st } return v; } - ///end return vec4_nan(); } function uniforms_ext_mat4_link(object: object_t, mat: material_data_t, link: string): mat4_t { - ///if (is_paint || is_sculpt) if (link == "_decal_layer_matrix") { // Decal layer let m: mat4_t = mat4_inv(context_raw.layer.decal_mat); m = mat4_mult_mat(m, uniforms_ext_ortho_p); return m; } - ///end return mat4_nan(); } @@ -455,8 +436,6 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str return brush_output_node_inst.texpaint; ///end } - - ///if (is_paint || is_sculpt) if (starts_with(link, "_texblur_")) { let id: string = substring(link, 9, link.length); if (context_raw.node_previews != null) { @@ -487,7 +466,6 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str return rt._image; } } - ///end return null; } diff --git a/base/sources/util_particle.ts b/base/sources/util_particle.ts index b211f476..18fe934b 100644 --- a/base/sources/util_particle.ts +++ b/base/sources/util_particle.ts @@ -1,6 +1,8 @@ function util_particle_init() { - if (context_raw.particle_material != null) return; + if (context_raw.particle_material != null) { + return; + } let raw: particle_data_t = { name: "Particles", diff --git a/base/sources/util_render.ts b/base/sources/util_render.ts index 04170093..0c6eb60f 100644 --- a/base/sources/util_render.ts +++ b/base/sources/util_render.ts @@ -19,7 +19,12 @@ function util_render_make_material_preview() { context_raw.material.preview_ready = true; context_raw.saved_camera = mat4_clone(scene_camera.base.transform.local); - let m: mat4_t = mat4_create(0.9146286343879498, -0.0032648027153306235, 0.404281837254303, 0.4659988049397712, 0.404295023959927, 0.007367569133732468, -0.9145989516155143, -1.0687517188018691, 0.000007410128652369705, 0.9999675337275382, 0.008058532943908717, 0.015935682577325486, 0, 0, 0, 1); + let m: mat4_t = mat4_create( + 0.9146286343879498, -0.0032648027153306235, 0.404281837254303, 0.4659988049397712, + 0.404295023959927, 0.007367569133732468, -0.9145989516155143, -1.0687517188018691, + 0.000007410128652369705, 0.9999675337275382, 0.008058532943908717, 0.015935682577325486, + 0, 0, 0, 1 + ); transform_set_matrix(scene_camera.base.transform, m); let saved_fov: f32 = scene_camera.data.fov; scene_camera.data.fov = 0.92;