From 619de08f0d91f4ddf1e5355f9e9b6cfb15e43a51 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 1 Mar 2026 19:08:07 +0100 Subject: [PATCH] base: move path.ts to c --- base/sources/iron.h | 1 + base/sources/iron_file.h | 2 +- base/sources/iron_path.c | 355 ++++++++++++++++++ base/sources/iron_path.h | 45 +++ base/sources/ts/file.ts | 4 +- base/sources/ts/iron.ts | 31 ++ base/sources/ts/path.ts | 195 ---------- paint/plugins/plugins.c | 12 +- paint/sources/args.ts | 4 +- paint/sources/box_export.ts | 16 +- paint/sources/box_preferences.ts | 28 +- paint/sources/box_projects.ts | 6 +- paint/sources/config.ts | 2 +- paint/sources/export_texture.ts | 20 +- paint/sources/history.ts | 2 +- paint/sources/import_arm.ts | 2 +- paint/sources/import_folder.ts | 4 +- paint/sources/import_font.ts | 2 +- paint/sources/import_keymap.ts | 4 +- paint/sources/import_mesh.ts | 6 +- paint/sources/import_plugin.ts | 4 +- paint/sources/import_texture.ts | 6 +- paint/sources/import_theme.ts | 4 +- paint/sources/neural_nodes/edit_image_node.ts | 2 +- .../neural_nodes/image_to_3d_mesh_node.ts | 4 +- .../neural_nodes/image_to_depth_node.ts | 2 +- .../neural_nodes/image_to_normal_map_node.ts | 2 +- .../sources/neural_nodes/image_to_pbr_node.ts | 4 +- .../neural_nodes/inpaint_image_node.ts | 6 +- paint/sources/neural_nodes/neural_node.ts | 6 +- .../neural_nodes/outpaint_image_node.ts | 4 +- paint/sources/neural_nodes/tile_image_node.ts | 4 +- .../neural_nodes/upscale_image_node.ts | 2 +- paint/sources/neural_nodes/vary_image_node.ts | 4 +- paint/sources/project.ts | 18 +- paint/sources/tab_browser.ts | 8 +- paint/sources/tab_console.ts | 2 +- paint/sources/tab_layers.ts | 2 +- paint/sources/tab_scripts.ts | 2 +- paint/sources/tab_textures.ts | 8 +- paint/sources/translator.ts | 4 +- paint/sources/ui_files.ts | 40 +- paint/sources/ui_header.ts | 2 +- paint/sources/ui_menubar.ts | 2 +- 44 files changed, 562 insertions(+), 321 deletions(-) create mode 100644 base/sources/iron_path.c create mode 100644 base/sources/iron_path.h delete mode 100644 base/sources/ts/path.ts diff --git a/base/sources/iron.h b/base/sources/iron.h index 3fe03c95..fde4ffb1 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -6,6 +6,7 @@ #include "iron_array.h" #include "iron_draw.h" #include "iron_file.h" +#include "iron_path.h" #include "iron_gc.h" #include "iron_gpu.h" #include "iron_json.h" diff --git a/base/sources/iron_file.h b/base/sources/iron_file.h index 8496d7bd..39b0b087 100644 --- a/base/sources/iron_file.h +++ b/base/sources/iron_file.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "iron_global.h" #include #include #include diff --git a/base/sources/iron_path.c b/base/sources/iron_path.c new file mode 100644 index 00000000..bbc3c2d6 --- /dev/null +++ b/base/sources/iron_path.c @@ -0,0 +1,355 @@ +#include "iron_path.h" + +#include + +#include "iron_array.h" +#include "iron_file.h" +#include "iron_map.h" +#include "iron_string.h" +#include "iron_gc.h" + +#ifdef IRON_LINUX +bool path_is_protected_linux = false; +#endif + +static char_ptr_array_t *_path_mesh_formats = NULL; +static char_ptr_array_t *_path_texture_formats = NULL; +static char_ptr_array_t *_path_base_color_ext = NULL; +static char_ptr_array_t *_path_opacity_ext = NULL; +static char_ptr_array_t *_path_normal_map_ext = NULL; +static char_ptr_array_t *_path_occlusion_ext = NULL; +static char_ptr_array_t *_path_roughness_ext = NULL; +static char_ptr_array_t *_path_metallic_ext = NULL; +static char_ptr_array_t *_path_displacement_ext = NULL; + +char_ptr_array_t *path_mesh_formats(void) { + if (_path_mesh_formats == NULL) { + _path_mesh_formats = char_ptr_array_create(0); + gc_root(_path_mesh_formats); + char_ptr_array_push(_path_mesh_formats, "obj"); + char_ptr_array_push(_path_mesh_formats, "blend"); + } + return _path_mesh_formats; +} + +char_ptr_array_t *path_texture_formats(void) { + if (_path_texture_formats == NULL) { + _path_texture_formats = char_ptr_array_create(0); + gc_root(_path_texture_formats); + char_ptr_array_push(_path_texture_formats, "jpg"); + char_ptr_array_push(_path_texture_formats, "jpeg"); + char_ptr_array_push(_path_texture_formats, "png"); + char_ptr_array_push(_path_texture_formats, "tga"); + char_ptr_array_push(_path_texture_formats, "bmp"); + char_ptr_array_push(_path_texture_formats, "psd"); + char_ptr_array_push(_path_texture_formats, "gif"); + char_ptr_array_push(_path_texture_formats, "hdr"); + char_ptr_array_push(_path_texture_formats, "k"); + } + return _path_texture_formats; +} + +char_ptr_array_t *path_base_color_ext(void) { + if (_path_base_color_ext == NULL) { + _path_base_color_ext = char_ptr_array_create(0); + gc_root(_path_base_color_ext); + char_ptr_array_push(_path_base_color_ext, "albedo"); + char_ptr_array_push(_path_base_color_ext, "alb"); + char_ptr_array_push(_path_base_color_ext, "basecol"); + char_ptr_array_push(_path_base_color_ext, "basecolor"); + char_ptr_array_push(_path_base_color_ext, "diffuse"); + char_ptr_array_push(_path_base_color_ext, "diff"); + char_ptr_array_push(_path_base_color_ext, "base"); + char_ptr_array_push(_path_base_color_ext, "bc"); + char_ptr_array_push(_path_base_color_ext, "d"); + char_ptr_array_push(_path_base_color_ext, "color"); + char_ptr_array_push(_path_base_color_ext, "col"); + } + return _path_base_color_ext; +} + +char_ptr_array_t *path_opacity_ext(void) { + if (_path_opacity_ext == NULL) { + _path_opacity_ext = char_ptr_array_create(0); + gc_root(_path_opacity_ext); + char_ptr_array_push(_path_opacity_ext, "opac"); + char_ptr_array_push(_path_opacity_ext, "opacity"); + char_ptr_array_push(_path_opacity_ext, "alpha"); + } + return _path_opacity_ext; +} + +char_ptr_array_t *path_normal_map_ext(void) { + if (_path_normal_map_ext == NULL) { + _path_normal_map_ext = char_ptr_array_create(0); + gc_root(_path_normal_map_ext); + char_ptr_array_push(_path_normal_map_ext, "normal"); + char_ptr_array_push(_path_normal_map_ext, "normals"); + char_ptr_array_push(_path_normal_map_ext, "nor"); + char_ptr_array_push(_path_normal_map_ext, "n"); + char_ptr_array_push(_path_normal_map_ext, "nrm"); + char_ptr_array_push(_path_normal_map_ext, "normalgl"); + } + return _path_normal_map_ext; +} + +char_ptr_array_t *path_occlusion_ext(void) { + if (_path_occlusion_ext == NULL) { + _path_occlusion_ext = char_ptr_array_create(0); + gc_root(_path_occlusion_ext); + char_ptr_array_push(_path_occlusion_ext, "ao"); + char_ptr_array_push(_path_occlusion_ext, "occlusion"); + char_ptr_array_push(_path_occlusion_ext, "ambientOcclusion"); + char_ptr_array_push(_path_occlusion_ext, "o"); + char_ptr_array_push(_path_occlusion_ext, "occ"); + } + return _path_occlusion_ext; +} + +char_ptr_array_t *path_roughness_ext(void) { + if (_path_roughness_ext == NULL) { + _path_roughness_ext = char_ptr_array_create(0); + gc_root(_path_roughness_ext); + char_ptr_array_push(_path_roughness_ext, "roughness"); + char_ptr_array_push(_path_roughness_ext, "rough"); + char_ptr_array_push(_path_roughness_ext, "r"); + char_ptr_array_push(_path_roughness_ext, "rgh"); + } + return _path_roughness_ext; +} + +char_ptr_array_t *path_metallic_ext(void) { + if (_path_metallic_ext == NULL) { + _path_metallic_ext = char_ptr_array_create(0); + gc_root(_path_metallic_ext); + char_ptr_array_push(_path_metallic_ext, "metallic"); + char_ptr_array_push(_path_metallic_ext, "metal"); + char_ptr_array_push(_path_metallic_ext, "metalness"); + char_ptr_array_push(_path_metallic_ext, "m"); + char_ptr_array_push(_path_metallic_ext, "met"); + } + return _path_metallic_ext; +} + +char_ptr_array_t *path_displacement_ext(void) { + if (_path_displacement_ext == NULL) { + _path_displacement_ext = char_ptr_array_create(0); + gc_root(_path_displacement_ext); + char_ptr_array_push(_path_displacement_ext, "displacement"); + char_ptr_array_push(_path_displacement_ext, "height"); + char_ptr_array_push(_path_displacement_ext, "h"); + char_ptr_array_push(_path_displacement_ext, "disp"); + } + return _path_displacement_ext; +} + +static char *data_path(void) { +#ifdef IRON_ANDROID + return "data" PATH_SEP; +#else + return "." PATH_SEP "data" PATH_SEP; +#endif +} + +char *path_data(void) { + return string_join(iron_internal_files_location(), string_join(PATH_SEP, data_path())); +} + +char *path_to_relative(char *from, char *to) { + any_array_t *a = string_split(from, PATH_SEP); + any_array_t *b = string_split(to, PATH_SEP); + while (a->length > 0 && b->length > 0) { + char *a0 = a->buffer[0]; + char *b0 = b->buffer[0]; + if (string_equals(a0, b0)) { + array_shift(a); + array_shift(b); + } + else { + break; + } + } + char *p = ""; + for (uint32_t i = 0; i < a->length; ++i) { + p = string_join(p, ".." PATH_SEP); + } + p = string_join(p, string_array_join(b, PATH_SEP)); + return p; +} + +char *path_normalize(char *path) { + size_t path_len = strlen(path); + if (path_len > 0 && ends_with(path, PATH_SEP)) { + path = substring(path, 0, path_len - 1); + } + any_array_t *ar = string_split(path, PATH_SEP); + uint32_t i = 0; + while (i < ar->length) { + if (i > 0) { + char *ar_i = ar->buffer[i]; + char *ar_i_1 = ar->buffer[i - 1]; + if (string_equals(ar_i, "..") && !string_equals(ar_i_1, "..")) { + array_splice(ar, i - 1, 2); + i--; + } + else { + i++; + } + } + else { + i++; + } + } + return string_array_join(ar, PATH_SEP); +} + +char *path_base_dir(char *path) { + int32_t last = string_last_index_of(path, PATH_SEP); + return substring(path, 0, last + 1); +} + +char *path_base_name(char *path) { + int32_t last_sep = string_last_index_of(path, PATH_SEP); + int32_t last_dot = string_last_index_of(path, "."); + return substring(path, last_sep + 1, last_dot); +} + +bool path_is_mesh(char *path) { + char *p = to_lower_case(path); + char_ptr_array_t *formats = path_mesh_formats(); + for (uint32_t i = 0; i < formats->length; ++i) { + char *s = formats->buffer[i]; + char *ext = string_join(".", s); + if (ends_with(p, ext)) { + return true; + } + } + return false; +} + +bool path_is_texture(char *path) { + char *p = to_lower_case(path); + char_ptr_array_t *formats = path_texture_formats(); + for (uint32_t i = 0; i < formats->length; ++i) { + char *s = formats->buffer[i]; + char *ext = string_join(".", s); + if (ends_with(p, ext)) { + return true; + } + } + return false; +} + +bool path_is_font(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".ttf") || ends_with(p, ".ttc") || ends_with(p, ".otf"); +} + +bool path_is_project(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".arm"); +} + +bool path_is_plugin(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".js"); +} + +bool path_is_json(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".json"); +} + +bool path_is_text(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".txt"); +} + +bool path_is_gimp_color_palette(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".gpl"); +} + +bool path_is_ext_format(char *path) { + char *p = to_lower_case(path); + return ends_with(p, ".fbx") || ends_with(p, ".gltf") || ends_with(p, ".glb") || ends_with(p, ".stl") || ends_with(p, ".svg"); +} + +bool path_is_known(char *path) { + return path_is_mesh(path) || path_is_texture(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) || path_is_text(path) || + path_is_gimp_color_palette(path) || path_is_ext_format(path); +} + +bool path_check_ext(char *p, char_ptr_array_t *exts) { + p = string_replace_all(p, "-", "_"); + for (uint32_t i = 0; i < exts->length; ++i) { + char *ext = exts->buffer[i]; + char *ext_underscore = string_join("_", ext); + if (ends_with(p, ext_underscore)) { + return true; + } + char *ext_underscore_mid = string_join("_", string_join(ext, "_")); + if (string_index_of(p, ext_underscore_mid) >= 0 && !ends_with(p, "_preview") && !ends_with(p, "_icon")) { + return true; + } + } + return false; +} + +bool path_is_base_color_tex(char *p) { + return path_check_ext(p, path_base_color_ext()); +} + +bool path_is_opacity_tex(char *p) { + return path_check_ext(p, path_opacity_ext()); +} + +bool path_is_normal_map_tex(char *p) { + return path_check_ext(p, path_normal_map_ext()); +} + +bool path_is_occlusion_tex(char *p) { + return path_check_ext(p, path_occlusion_ext()); +} + +bool path_is_roughness_tex(char *p) { + return path_check_ext(p, path_roughness_ext()); +} + +bool path_is_metallic_tex(char *p) { + return path_check_ext(p, path_metallic_ext()); +} + +bool path_is_displacement_tex(char *p) { + return path_check_ext(p, path_displacement_ext()); +} + +bool path_is_folder(char *p) { + char *p_slash = string_replace_all(p, "\\", "/"); + any_array_t *split = string_split(p_slash, "/"); + char *last = array_pop(split); + return string_index_of(last, ".") < 0; +} + +bool path_is_protected(void) { +#ifdef IRON_WINDOWS + return string_index_of(iron_internal_files_location(), "Program Files") >= 0; +#elif defined(IRON_LINUX) + return path_is_protected_linux; +#elif defined(IRON_ANDROID) + return true; +#elif defined(IRON_IOS) + return true; +#else + return false; +#endif +} + +char *path_join(char *a, char *b) { + char *path = a; + if (!ends_with(path, PATH_SEP)) { + path = string_join(path, PATH_SEP); + } + path = string_join(path, b); + return path; +} diff --git a/base/sources/iron_path.h b/base/sources/iron_path.h new file mode 100644 index 00000000..7144a30e --- /dev/null +++ b/base/sources/iron_path.h @@ -0,0 +1,45 @@ +#pragma once + +#include "iron_array.h" +#include "iron_global.h" +#include +#include + +#ifdef IRON_WINDOWS +#define PATH_SEP "\\" +#else +#define PATH_SEP "/" +#endif + +#ifdef IRON_LINUX +extern bool path_is_protected_linux; +#endif + +char_ptr_array_t *path_mesh_formats(void); +char_ptr_array_t *path_texture_formats(void); + +char *path_data(void); +char *path_to_relative(char *from, char *to); +char *path_normalize(char *path); +char *path_base_dir(char *path); +char *path_base_name(char *path); +bool path_is_mesh(char *path); +bool path_is_texture(char *path); +bool path_is_font(char *path); +bool path_is_project(char *path); +bool path_is_plugin(char *path); +bool path_is_json(char *path); +bool path_is_text(char *path); +bool path_is_gimp_color_palette(char *path); +bool path_is_ext_format(char *path); +bool path_is_known(char *path); +bool path_is_base_color_tex(char *p); +bool path_is_opacity_tex(char *p); +bool path_is_normal_map_tex(char *p); +bool path_is_occlusion_tex(char *p); +bool path_is_roughness_tex(char *p); +bool path_is_metallic_tex(char *p); +bool path_is_displacement_tex(char *p); +bool path_is_folder(char *p); +bool path_is_protected(void); +char *path_join(char *a, char *b); diff --git a/base/sources/ts/file.ts b/base/sources/ts/file.ts index 8a6dc0d7..d058cf0d 100644 --- a/base/sources/ts/file.ts +++ b/base/sources/ts/file.ts @@ -109,7 +109,7 @@ function file_cache_cloud(path: string, done: (s: string) => void) { dest = iron_internal_save_path(); } else { - dest = iron_internal_files_location() + path_sep; + dest = iron_internal_files_location() + PATH_SEP; } dest += path; @@ -118,7 +118,7 @@ function file_cache_cloud(path: string, done: (s: string) => void) { return; } - let file_dir: string = substring(dest, 0, string_last_index_of(dest, path_sep)); + let file_dir: string = substring(dest, 0, string_last_index_of(dest, PATH_SEP)); if (file_read_directory(file_dir)[0] == "") { file_create_directory(file_dir); } diff --git a/base/sources/ts/iron.ts b/base/sources/ts/iron.ts index ebbca4d9..0860bff2 100644 --- a/base/sources/ts/iron.ts +++ b/base/sources/ts/iron.ts @@ -994,3 +994,34 @@ function ui_set_font(ui: ui_t, font: draw_font_t) { draw_font_init(font); // Make sure font is ready ui.ops.font = font; } + +declare let PATH_SEP: string; +declare function path_mesh_formats(): string[]; +declare function path_texture_formats(): string[]; +declare function path_displacement_ext(): string[]; +declare function path_data(): string; +declare function path_to_relative(from: string, to: string): string; +declare function path_normalize(path: string): string; +declare function path_base_dir(path: string): string; +declare function path_base_name(path: string): string; +declare function path_is_mesh(path: string): bool; +declare function path_is_texture(path: string): bool; +declare function path_is_font(path: string): bool; +declare function path_is_project(path: string): bool; +declare function path_is_plugin(path: string): bool; +declare function path_is_json(path: string): bool; +declare function path_is_text(path: string): bool; +declare function path_is_gimp_color_palette(path: string): bool; +declare function path_is_ext_format(path: string): bool; +declare function path_is_known(path: string): bool; +declare function path_check_ext(p: string, exts: string[]): bool; +declare function path_is_base_color_tex(p: string): bool; +declare function path_is_opacity_tex(p: string): bool; +declare function path_is_normal_map_tex(p: string): bool; +declare function path_is_occlusion_tex(p: string): bool; +declare function path_is_roughness_tex(p: string): bool; +declare function path_is_metallic_tex(p: string): bool; +declare function path_is_displacement_tex(p: string): bool; +declare function path_is_folder(p: string): bool; +declare function path_is_protected(): bool; +declare function path_join(a: string, b: string): string; diff --git a/base/sources/ts/path.ts b/base/sources/ts/path.ts deleted file mode 100644 index 2c917830..00000000 --- a/base/sources/ts/path.ts +++ /dev/null @@ -1,195 +0,0 @@ - -/// if arm_windows -let path_sep: string = "\\"; -/// else -let path_sep: string = "/"; -/// end - -/// if arm_linux -let path_is_protected_linux: bool = false; -/// end - -let path_mesh_formats: string[] = [ "obj", "blend" ]; -let path_texture_formats: string[] = [ "jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k" ]; - -let path_mesh_importers: map_t = map_create(); // JSValue -> (s: string)=>raw_mesh_t -let path_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>gpu_texture_t - -let path_base_color_ext: string[] = [ "albedo", "alb", "basecol", "basecolor", "diffuse", "diff", "base", "bc", "d", "color", "col" ]; -let path_opacity_ext: string[] = [ "opac", "opacity", "alpha" ]; -let path_normal_map_ext: string[] = [ "normal", "normals", "nor", "n", "nrm", "normalgl" ]; -let path_occlusion_ext: string[] = [ "ao", "occlusion", "ambientOcclusion", "o", "occ" ]; -let path_roughness_ext: string[] = [ "roughness", "rough", "r", "rgh" ]; -let path_metallic_ext: string[] = [ "metallic", "metal", "metalness", "m", "met" ]; -let path_displacement_ext: string[] = [ "displacement", "height", "h", "disp" ]; - -function path_data(): string { - return iron_internal_files_location() + path_sep + data_path(); -} - -function path_to_relative(from: string, to: string): string { - let a: string[] = string_split(from, path_sep); - let b: string[] = string_split(to, path_sep); - while (a[0] == b[0]) { - array_shift(a); - array_shift(b); - if (a.length == 0 || b.length == 0) { - break; - } - } - let p: string = ""; - for (let i: i32 = 0; i < a.length; ++i) { - p += ".." + path_sep; - } - p += string_array_join(b, path_sep); - return p; -} - -function path_normalize(path: string): string { - if (ends_with(path, path_sep)) { - path = substring(path, 0, path.length - 1); - } - let ar: string[] = string_split(path, path_sep); - let i: i32 = 0; - while (i < ar.length) { - if (i > 0 && ar[i] == ".." && ar[i - 1] != "..") { - array_splice(ar, i - 1, 2); - i--; - } - else { - i++; - } - } - return string_array_join(ar, path_sep); -} - -function path_base_dir(path: string): string { - return substring(path, 0, string_last_index_of(path, path_sep) + 1); -} - -function path_base_name(path: string): string { - return substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, ".")); -} - -function path_is_mesh(path: string): bool { - let p: string = to_lower_case(path); - for (let i: i32 = 0; i < path_mesh_formats.length; ++i) { - let s: string = path_mesh_formats[i]; - if (ends_with(p, "." + s)) { - return true; - } - } - return false; -} - -function path_is_texture(path: string): bool { - let p: string = to_lower_case(path); - for (let i: i32 = 0; i < path_texture_formats.length; ++i) { - let s: string = path_texture_formats[i]; - if (ends_with(p, "." + s)) { - return true; - } - } - return false; -} - -function path_is_font(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".ttf") || ends_with(p, ".ttc") || ends_with(p, ".otf"); -} - -function path_is_project(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".arm"); -} - -function path_is_plugin(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".js"); -} - -function path_is_json(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".json"); -} - -function path_is_text(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".txt"); -} - -function path_is_gimp_color_palette(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".gpl"); -} - -function path_is_ext_format(path: string): bool { - let p: string = to_lower_case(path); - return ends_with(p, ".fbx") || ends_with(p, ".gltf") || ends_with(p, ".glb") || ends_with(p, ".stl") || ends_with(p, ".svg"); -} - -function path_is_known(path: string): bool { - return path_is_mesh(path) || path_is_texture(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) || path_is_text(path) || - path_is_gimp_color_palette(path) || path_is_ext_format(path); -} - -function path_check_ext(p: string, exts: string[]): bool { - p = string_replace_all(p, "-", "_"); - for (let i: i32 = 0; i < exts.length; ++i) { - let ext: string = exts[i]; - if (ends_with(p, "_" + ext) || (string_index_of(p, "_" + ext + "_") >= 0 && !ends_with(p, "_preview") && !ends_with(p, "_icon"))) { - return true; - } - } - return false; -} - -function path_is_base_color_tex(p: string): bool { - return path_check_ext(p, path_base_color_ext); -} -function path_is_opacity_tex(p: string): bool { - return path_check_ext(p, path_opacity_ext); -} -function path_is_normal_map_tex(p: string): bool { - return path_check_ext(p, path_normal_map_ext); -} -function path_is_occlusion_tex(p: string): bool { - return path_check_ext(p, path_occlusion_ext); -} -function path_is_roughness_tex(p: string): bool { - return path_check_ext(p, path_roughness_ext); -} -function path_is_metallic_tex(p: string): bool { - return path_check_ext(p, path_metallic_ext); -} -function path_is_displacement_tex(p: string): bool { - return path_check_ext(p, path_displacement_ext); -} - -function path_is_folder(p: string): bool { - let last: string = array_pop(string_split(string_replace_all(p, "\\", "/"), "/")); - return string_index_of(last, ".") == -1; -} - -function path_is_protected(): bool { - /// if arm_windows - return string_index_of(iron_internal_files_location(), "Program Files") >= 0; - /// elseif arm_linux - return path_is_protected_linux; - /// elseif arm_android - return true; - /// elseif arm_ios - return true; - /// else - return false; - /// end -} - -function path_join(a: string, b: string): string { - let path: string = a; - if (!ends_with(path, path_sep)) { - path += path_sep; - } - path += b; - return path; -} diff --git a/paint/plugins/plugins.c b/paint/plugins/plugins.c index 4bb35e6f..8398e139 100644 --- a/paint/plugins/plugins.c +++ b/paint/plugins/plugins.c @@ -214,40 +214,40 @@ FN(util_mesh_unwrappers_delete) { return JS_UNDEFINED; } -extern any_map_t *path_mesh_importers; +extern any_map_t *import_mesh_importers; extern char_ptr_array_t *path_mesh_formats; FN(path_mesh_importers_set) { char *format_name = (char *)JS_ToCString(ctx, argv[0]); JSValue *p = malloc(sizeof(JSValue)); JSValue dup = JS_DupValue(ctx, argv[1]); memcpy(p, &dup, sizeof(JSValue)); - any_map_set(path_mesh_importers, format_name, p); + any_map_set(import_mesh_importers, format_name, p); any_array_push(path_mesh_formats, format_name); return JS_UNDEFINED; } FN(path_mesh_importers_delete) { char *format_name = (char *)JS_ToCString(ctx, argv[0]); - map_delete(path_mesh_importers, format_name); + map_delete(import_mesh_importers, format_name); array_splice(path_mesh_formats, char_ptr_array_index_of(path_mesh_formats, format_name), 1); return JS_UNDEFINED; } -extern any_map_t *path_texture_importers; +extern any_map_t *import_texture_importers; extern char_ptr_array_t *path_texture_formats; FN(path_texture_importers_set) { char *format_name = (char *)JS_ToCString(ctx, argv[0]); JSValue *p = malloc(sizeof(JSValue)); JSValue dup = JS_DupValue(ctx, argv[1]); memcpy(p, &dup, sizeof(JSValue)); - any_map_set(path_texture_importers, format_name, p); + any_map_set(import_texture_importers, format_name, p); any_array_push(path_texture_formats, format_name); return JS_UNDEFINED; } FN(path_texture_importers_delete) { char *format_name = (char *)JS_ToCString(ctx, argv[0]); - map_delete(path_texture_importers, format_name); + map_delete(import_texture_importers, format_name); array_splice(path_texture_formats, char_ptr_array_index_of(path_texture_formats, format_name), 1); return JS_UNDEFINED; } diff --git a/paint/sources/args.ts b/paint/sources/args.ts index 7c8cd698..6638f850 100644 --- a/paint/sources/args.ts +++ b/paint/sources/args.ts @@ -103,7 +103,7 @@ function args_run() { context_raw.layers_export = export_mode_t.VISIBLE; // Get export preset and apply the correct one from args - box_export_files = file_read_directory(path_data() + path_sep + "export_presets"); + box_export_files = file_read_directory(path_data() + PATH_SEP + "export_presets"); for (let i: i32 = 0; i < box_export_files.length; ++i) { let s: string = box_export_files[i]; box_export_files[i] = substring(s, 0, s.length - 5); // Strip .json @@ -135,7 +135,7 @@ function args_run() { if (f == "") { f = tr("untitled"); } - export_mesh_run(args_export_mesh_path + path_sep + f, null, false); + export_mesh_run(args_export_mesh_path + PATH_SEP + f, null, false); } else if (args_export_material) { context_raw.write_icon_on_export = true; diff --git a/paint/sources/box_export.ts b/paint/sources/box_export.ts index 3c308a27..748e6563 100644 --- a/paint/sources/box_export.ts +++ b/paint/sources/box_export.ts @@ -201,8 +201,8 @@ function box_export_tab_presets() { ui_files_show("json", false, false, function(path: string) { path = to_lower_case(path); if (ends_with(path, ".json")) { - let filename: string = substring(path, string_last_index_of(path, path_sep) + 1, path.length); - let dst_path: string = path_data() + path_sep + "export_presets" + path_sep + filename; + let filename: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); + let dst_path: string = path_data() + PATH_SEP + "export_presets" + PATH_SEP + filename; file_copy(path, dst_path); // Copy to presets folder box_export_fetch_presets(); box_export_preset = null; @@ -400,7 +400,7 @@ function box_export_tab_export_mesh(htab: ui_handle_t) { paint_objects = [ po ]; } - export_mesh_run(path + path_sep + f, paint_objects, _box_export_apply_displacement, _box_export_merge_vertices); + export_mesh_run(path + PATH_SEP + f, paint_objects, _box_export_apply_displacement, _box_export_merge_vertices); }); } } @@ -430,7 +430,7 @@ function box_export_show_material() { } sys_notify_on_next_frame(function(path: string) { export_arm_run_material(path); - }, path + path_sep + f); + }, path + PATH_SEP + f); }); } } @@ -460,7 +460,7 @@ function box_export_show_brush() { f = tr("untitled"); sys_notify_on_next_frame(function(path: string) { export_arm_run_brush(path); - }, path + path_sep + f); + }, path + PATH_SEP + f); }); } } @@ -468,7 +468,7 @@ function box_export_show_brush() { } function box_export_fetch_presets() { - box_export_files = file_read_directory(path_data() + path_sep + "export_presets"); + box_export_files = file_read_directory(path_data() + PATH_SEP + "export_presets"); for (let i: i32 = 0; i < box_export_files.length; ++i) { let s: string = box_export_files[i]; box_export_files[i] = substring(s, 0, s.length - 5); // Strip .json @@ -492,7 +492,7 @@ function box_export_new_preset(name: string) { if (!ends_with(name, ".json")) { name += ".json"; } - let path: string = path_data() + path_sep + "export_presets" + path_sep + name; + let path: string = path_data() + PATH_SEP + "export_presets" + PATH_SEP + name; iron_file_save_bytes(path, sys_string_to_buffer(template), 0); } @@ -501,7 +501,7 @@ function box_export_save_preset() { if (name == "generic") { return; // generic is const } - let path: string = path_data() + path_sep + "export_presets" + path_sep + name + ".json"; + let path: string = path_data() + PATH_SEP + "export_presets" + PATH_SEP + name + ".json"; iron_file_save_bytes(path, sys_string_to_buffer(box_export_preset_to_json(box_export_preset)), 0); } diff --git a/paint/sources/box_preferences.ts b/paint/sources/box_preferences.ts index 5f548532..c2941feb 100644 --- a/paint/sources/box_preferences.ts +++ b/paint/sources/box_preferences.ts @@ -181,7 +181,7 @@ function box_preferences_theme_tab() { if (!ends_with(theme_name, ".json")) { theme_name += ".json"; } - let path: string = path_data() + path_sep + "themes" + path_sep + theme_name; + let path: string = path_data() + PATH_SEP + "themes" + PATH_SEP + theme_name; iron_file_save_bytes(path, sys_string_to_buffer(template), 0); box_preferences_fetch_themes(); // Refresh file list config_raw.theme = theme_name; @@ -201,7 +201,7 @@ function box_preferences_theme_tab() { if (ui_icon_button(tr("Export"), icon_t.EXPORT)) { ui_files_show("json", true, false, function(path: string) { - path += path_sep; + path += PATH_SEP; path += ui_files_filename; if (!ends_with(path, ".json")) { path += ".json"; @@ -564,7 +564,7 @@ function box_preferences_keymap_tab() { if (!ends_with(keymap_name, ".json")) { keymap_name += ".json"; } - let path: string = path_data() + path_sep + "keymap_presets" + path_sep + keymap_name; + let path: string = path_data() + PATH_SEP + "keymap_presets" + PATH_SEP + keymap_name; iron_file_save_bytes(path, sys_string_to_buffer(template), 0); box_preferences_fetch_keymaps(); // Refresh file list config_raw.keymap = keymap_name; @@ -586,8 +586,8 @@ function box_preferences_keymap_tab() { if (!ends_with(ui_files_filename, ".json")) { ui_files_filename += ".json"; } - let path: string = path_data() + path_sep + "keymap_presets" + path_sep + config_raw.keymap; - file_copy(path, dest + path_sep + ui_files_filename); + let path: string = path_data() + PATH_SEP + "keymap_presets" + PATH_SEP + config_raw.keymap; + file_copy(path, dest + PATH_SEP + ui_files_filename); }); } @@ -648,7 +648,7 @@ function box_preferences_neural_tab() { } function box_preferences_model_exists(file_name: string): bool { - return iron_file_exists(neural_node_dir() + path_sep + file_name); + return iron_file_exists(neural_node_dir() + PATH_SEP + file_name); } function box_preferences_file_name_from_url(url: string): string { @@ -710,7 +710,7 @@ function box_preferences_model_panel(m: neural_node_model_t) { for (let i: i32 = 0; i < m.urls.length; ++i) { let url: string = m.urls[i]; let file_name: string = box_preferences_file_name_from_url(url); - iron_delete_file(neural_node_dir() + path_sep + file_name); + iron_delete_file(neural_node_dir() + PATH_SEP + file_name); } } } @@ -742,7 +742,7 @@ plugin_notify_on_ui(plugin, function() {\ if (!ends_with(plugin_name, ".js")) { plugin_name += ".js"; } - let path: string = path_data() + path_sep + "plugins" + path_sep + plugin_name; + let path: string = path_data() + PATH_SEP + "plugins" + PATH_SEP + plugin_name; iron_file_save_bytes(path, sys_string_to_buffer(template), 0); box_preferences_files_plugin = null; // Refresh file list ui_box_hide(); @@ -786,7 +786,7 @@ plugin_notify_on_ui(plugin, function() {\ if (ui.is_hovered && ui.input_released_r) { _box_preferences_f = f; ui_menu_draw(function() { - let path: string = path_data() + path_sep + "plugins" + path_sep + _box_preferences_f; + let path: string = path_data() + PATH_SEP + "plugins" + PATH_SEP + _box_preferences_f; if (ui_menu_button(tr("Edit in Text Editor"))) { file_start(path); } @@ -801,8 +801,8 @@ plugin_notify_on_ui(plugin, function() {\ if (!ends_with(ui_files_filename, ".js")) { ui_files_filename += ".js"; } - let path: string = path_data() + path_sep + "plugins" + path_sep + _box_preferences_f; - file_copy(path, dest + path_sep + ui_files_filename); + let path: string = path_data() + PATH_SEP + "plugins" + PATH_SEP + _box_preferences_f; + file_copy(path, dest + PATH_SEP + ui_files_filename); }); } if (ui_menu_button(tr("Delete"), "", icon_t.DELETE)) { @@ -863,7 +863,7 @@ function box_preferences_show() { } function box_preferences_fetch_themes() { - box_preferences_themes = file_read_directory(path_data() + path_sep + "themes"); + box_preferences_themes = file_read_directory(path_data() + PATH_SEP + "themes"); for (let i: i32 = 0; i < box_preferences_themes.length; ++i) { let s: string = box_preferences_themes[i]; box_preferences_themes[i] = substring(box_preferences_themes[i], 0, s.length - 5); // Strip .json @@ -872,7 +872,7 @@ function box_preferences_fetch_themes() { } function box_preferences_fetch_keymaps() { - box_preferences_files_keymap = file_read_directory(path_data() + path_sep + "keymap_presets"); + box_preferences_files_keymap = file_read_directory(path_data() + PATH_SEP + "keymap_presets"); for (let i: i32 = 0; i < box_preferences_files_keymap.length; ++i) { let s: string = box_preferences_files_keymap[i]; box_preferences_files_keymap[i] = substring(box_preferences_files_keymap[i], 0, s.length - 5); // Strip .json @@ -881,7 +881,7 @@ function box_preferences_fetch_keymaps() { } function box_preferences_fetch_plugins() { - box_preferences_files_plugin = file_read_directory(path_data() + path_sep + "plugins"); + box_preferences_files_plugin = file_read_directory(path_data() + PATH_SEP + "plugins"); } function box_preferences_get_theme_index(): i32 { diff --git a/paint/sources/box_projects.ts b/paint/sources/box_projects.ts index 8087e6c2..43115dc8 100644 --- a/paint/sources/box_projects.ts +++ b/paint/sources/box_projects.ts @@ -54,7 +54,7 @@ function box_projects_tab() { let title: string = "" + tr("untitled") + i; while (j < config_raw.recent_projects.length) { let base: string = config_raw.recent_projects[j]; - base = substring(base, string_last_index_of(base, path_sep) + 1, string_last_index_of(base, ".")); + base = substring(base, string_last_index_of(base, PATH_SEP) + 1, string_last_index_of(base, ".")); j++; if (title == base) { i++; @@ -138,7 +138,7 @@ function box_projects_tab() { }, path); } - let name: string = substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, ".")); + let name: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, ".")); if (ui.is_hovered && ui.input_released_r) { _box_projects_path = path; _box_projects_icon_path = icon_path; @@ -201,7 +201,7 @@ function box_projects_recent_tab() { /// else path = string_replace_all(path, "\\", "/"); /// end - let file: string = substring(path, string_last_index_of(path, path_sep) + 1, path.length); + let file: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); if (string_index_of(to_lower_case(file), to_lower_case(box_projects_hsearch.text)) < 0) { continue; // Search filter diff --git a/paint/sources/config.ts b/paint/sources/config.ts index 3ae7ba37..021253f2 100644 --- a/paint/sources/config.ts +++ b/paint/sources/config.ts @@ -44,7 +44,7 @@ function config_save() { } else { path += path_data(); - path += path_sep; + path += PATH_SEP; } path += "config.json"; diff --git a/paint/sources/export_texture.ts b/paint/sources/export_texture.ts index d313af12..5ccda38a 100644 --- a/paint/sources/export_texture.ts +++ b/paint/sources/export_texture.ts @@ -330,28 +330,28 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ let tex_name: string = t.name != "" ? "_" + t.name : ""; let single_channel: bool = c[0] == c[1] && c[1] == c[2] && c[3] == "1.0"; if (c[0] == "base_r" && c[1] == "base_g" && c[2] == "base_b" && c[3] == "1.0" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint, 1); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint, 1); } else if (c[0] == "nor_r" && c[1] == "nor_g" && c[2] == "nor_b" && c[3] == "1.0" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_nor, 1); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_nor, 1); } else if (c[0] == "occ" && c[1] == "rough" && c[2] == "metal" && c[3] == "1.0" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_pack, 1); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_pack, 1); } else if (single_channel && c[0] == "occ" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_pack, 2, 0); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_pack, 2, 0); } else if (single_channel && c[0] == "rough" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_pack, 2, 1); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_pack, 2, 1); } else if (single_channel && c[0] == "metal" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_pack, 2, 2); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_pack, 2, 2); } else if (single_channel && c[0] == "height" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint_pack, 2, 3); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint_pack, 2, 3); } else if (single_channel && c[0] == "opac" && t.color_space == "linear") { - export_texture_write_texture(path + path_sep + f + tex_name + ext, pixpaint, 2, 3); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pixpaint, 2, 3); } else { if (pix == null) { @@ -411,7 +411,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ export_texture_set_channel(255, pix, i); } } - export_texture_write_texture(path + path_sep + f + tex_name + ext, pix, 3); + export_texture_write_texture(path + PATH_SEP + f + tex_name + ext, pix, 3); } } @@ -451,7 +451,7 @@ function export_texture_write_texture(file: string, pixels: buffer_t, type: i32 /// end let image: gpu_texture_t = gpu_create_texture_from_bytes(pixels, res_x, res_y); map_set(data_cached_images, file, image); - let ar: string[] = string_split(file, path_sep); + let ar: string[] = string_split(file, PATH_SEP); let name: string = ar[ar.length - 1]; let asset: asset_t = {name : name, file : file, id : project_asset_id++}; array_push(project_assets, asset); diff --git a/paint/sources/history.ts b/paint/sources/history.ts index 375a3e5e..4a926a0a 100644 --- a/paint/sources/history.ts +++ b/paint/sources/history.ts @@ -579,7 +579,7 @@ function history_push(name: string): history_step_t { /// if (arm_windows || arm_linux || arm_macos) let filename: string = project_filepath == "" ? ui_files_filename - : substring(project_filepath, string_last_index_of(project_filepath, path_sep) + 1, project_filepath.length - 4); + : substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, project_filepath.length - 4); sys_title_set(filename + "* - " + manifest_title); /// end diff --git a/paint/sources/import_arm.ts b/paint/sources/import_arm.ts index b4efcc71..dfd48d79 100644 --- a/paint/sources/import_arm.ts +++ b/paint/sources/import_arm.ts @@ -38,7 +38,7 @@ function import_arm_run_project(path: string) { project_new(import_as_mesh); project_filepath = path; - ui_files_filename = substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, ".")); + ui_files_filename = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, ".")); /// if (arm_android || arm_ios) sys_title_set(ui_files_filename); /// else diff --git a/paint/sources/import_folder.ts b/paint/sources/import_folder.ts index 85c13d42..e57242c3 100644 --- a/paint/sources/import_folder.ts +++ b/paint/sources/import_folder.ts @@ -51,7 +51,7 @@ function import_folder_run(path: string) { } if (valid) { - import_texture_run(path + path_sep + f, false); + import_texture_run(path + PATH_SEP + f, false); found_texture = true; } } @@ -66,7 +66,7 @@ function import_folder_run(path: string) { array_push(project_materials, context_raw.material); let nodes: ui_nodes_t = context_raw.material.nodes; let canvas: ui_node_canvas_t = context_raw.material.canvas; - let dirs: string[] = string_split(path, path_sep); + let dirs: string[] = string_split(path, PATH_SEP); canvas.name = dirs[dirs.length - 1]; let nout: ui_node_t = null; for (let i: i32 = 0; i < canvas.nodes.length; ++i) { diff --git a/paint/sources/import_font.ts b/paint/sources/import_font.ts index 91dfd494..25b0aab5 100644 --- a/paint/sources/import_font.ts +++ b/paint/sources/import_font.ts @@ -14,7 +14,7 @@ function import_font_run(path: string) { let font_slots: slot_font_t[] = []; for (let i: i32 = 0; i < count; ++i) { - let ar: string[] = string_split(path, path_sep); + let ar: string[] = string_split(path, PATH_SEP); let name: string = ar[ar.length - 1]; let f: draw_font_t = {buf : font.buf, index : font.index}; draw_font_init(f); diff --git a/paint/sources/import_keymap.ts b/paint/sources/import_keymap.ts index 9145555d..65d5239c 100644 --- a/paint/sources/import_keymap.ts +++ b/paint/sources/import_keymap.ts @@ -5,8 +5,8 @@ function import_keymap_run(path: string) { return; } - let filename: string = substring(path, string_last_index_of(path, path_sep) + 1, path.length); - let dst_path: string = path_data() + path_sep + "keymap_presets" + path_sep + filename; + let filename: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); + let dst_path: string = path_data() + PATH_SEP + "keymap_presets" + PATH_SEP + filename; file_copy(path, dst_path); // Copy to preset folder box_preferences_fetch_keymaps(); // Refresh file list box_preferences_h_preset.i = box_preferences_get_preset_index(); diff --git a/paint/sources/import_mesh.ts b/paint/sources/import_mesh.ts index 10c2dd86..fec97a77 100644 --- a/paint/sources/import_mesh.ts +++ b/paint/sources/import_mesh.ts @@ -2,6 +2,8 @@ let import_mesh_clear_layers: bool = true; let import_mesh_meshes_to_unwrap: any[] = null; +let import_mesh_importers: map_t = map_create(); // JSValue -> (s: string)=>raw_mesh_t + function import_mesh_run(path: string, _clear_layers: bool = true, replace_existing: bool = true) { if (!path_is_mesh(path)) { if (!context_enable_import_plugin(path)) { @@ -24,7 +26,7 @@ function import_mesh_run(path: string, _clear_layers: bool = true, replace_exist } else { let ext: string = substring(path, string_last_index_of(path, ".") + 1, path.length); - let importer: any = map_get(path_mesh_importers, ext); // JSValue -> (s: string)=>raw_mesh_t + let importer: any = map_get(import_mesh_importers, ext); // JSValue -> (s: string)=>raw_mesh_t let mesh: raw_mesh_t = js_pcall_str(importer, path); if (mesh.name == "") { mesh.name = path_base_name(path); @@ -46,7 +48,7 @@ function import_mesh_run(path: string, _clear_layers: bool = true, replace_exist project_mesh_assets = [ path ]; /// if (arm_android || arm_ios) - sys_title_set(substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, "."))); + sys_title_set(substring(path, string_last_index_of(path, PATH_SEP) + 1, string_last_index_of(path, "."))); /// end } diff --git a/paint/sources/import_plugin.ts b/paint/sources/import_plugin.ts index d43abbd9..9736649e 100644 --- a/paint/sources/import_plugin.ts +++ b/paint/sources/import_plugin.ts @@ -5,8 +5,8 @@ function import_plugin_run(path: string) { return; } - let filename: string = substring(path, string_last_index_of(path, path_sep) + 1, path.length); - let dst_path: string = path_data() + path_sep + "plugins" + path_sep + filename; + let filename: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); + let dst_path: string = path_data() + PATH_SEP + "plugins" + PATH_SEP + filename; file_copy(path, dst_path); // Copy to plugin folder box_preferences_files_plugin = null; // Refresh file list console_info(tr("Plugin imported:") + " " + filename); diff --git a/paint/sources/import_texture.ts b/paint/sources/import_texture.ts index fdf165b2..3e826d44 100644 --- a/paint/sources/import_texture.ts +++ b/paint/sources/import_texture.ts @@ -3,6 +3,8 @@ type import_texture_data_t = { path: string; image : gpu_texture_t; }; +let import_texture_importers: map_t = map_create(); // JSValue -> (s: string)=>gpu_texture_t + function import_texture_run(path: string, hdr_as_envmap: bool = true) { if (!path_is_texture(path)) { if (!context_enable_import_plugin(path)) { @@ -29,7 +31,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } let ext: string = substring(path, string_last_index_of(path, ".") + 1, path.length); - let importer: any = map_get(path_texture_importers, ext); // JSValue -> (s: string)=>gpu_texture_t + let importer: any = map_get(import_texture_importers, ext); // JSValue -> (s: string)=>gpu_texture_t let cached: bool = map_get(data_cached_images, path) != null; // Already loaded or pink texture for missing file let image: gpu_texture_t; if (importer == null || cached) { @@ -44,7 +46,7 @@ function import_texture_run(path: string, hdr_as_envmap: bool = true) { } map_set(data_cached_images, path, image); - let ar: string[] = string_split(path, path_sep); + let ar: string[] = string_split(path, PATH_SEP); let name: string = ar[ar.length - 1]; let asset: asset_t = {name : name, file : path, id : project_asset_id++}; array_push(project_assets, asset); diff --git a/paint/sources/import_theme.ts b/paint/sources/import_theme.ts index 1842c323..e16bdee2 100644 --- a/paint/sources/import_theme.ts +++ b/paint/sources/import_theme.ts @@ -5,8 +5,8 @@ function import_theme_run(path: string) { return; } - let filename: string = substring(path, string_last_index_of(path, path_sep) + 1, path.length); - let dst_path: string = path_data() + path_sep + "themes" + path_sep + filename; + let filename: string = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); + let dst_path: string = path_data() + PATH_SEP + "themes" + PATH_SEP + filename; file_copy(path, dst_path); // Copy to preset folder box_preferences_fetch_themes(); // Refresh file list config_raw.theme = filename; diff --git a/paint/sources/neural_nodes/edit_image_node.ts b/paint/sources/neural_nodes/edit_image_node.ts index b0819f15..28694348 100644 --- a/paint/sources/neural_nodes/edit_image_node.ts +++ b/paint/sources/neural_nodes/edit_image_node.ts @@ -28,7 +28,7 @@ function edit_image_node_button(node_id: i32) { /// end let dir: string = neural_node_dir(); - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); if (prompt == "") { prompt = "."; diff --git a/paint/sources/neural_nodes/image_to_3d_mesh_node.ts b/paint/sources/neural_nodes/image_to_3d_mesh_node.ts index 0831869a..56baa5fc 100644 --- a/paint/sources/neural_nodes/image_to_3d_mesh_node.ts +++ b/paint/sources/neural_nodes/image_to_3d_mesh_node.ts @@ -34,7 +34,7 @@ function image_to_3d_mesh_node_button(node_id: i32) { /// else let input_buf: buffer_t = image_to_3d_mesh_node_remove_background(gpu_get_texture_pixels(input)); /// end - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); dir = string_replace_all(dir, "\\", "/"); let argv: string[] = [ @@ -56,7 +56,7 @@ function image_to_3d_mesh_node_check_result(node: ui_node_t) { neural_node_current = node; iron_delay_idle_sleep(); if (iron_exec_async_done == 1) { - let file: string = neural_node_dir() + path_sep + "output.obj"; + let file: string = neural_node_dir() + PATH_SEP + "output.obj"; if (iron_file_exists(file)) { // let result: gpu_texture_t = ; // map_set(neural_node_results, node.id, result); diff --git a/paint/sources/neural_nodes/image_to_depth_node.ts b/paint/sources/neural_nodes/image_to_depth_node.ts index ddcc6d6f..c838491c 100644 --- a/paint/sources/neural_nodes/image_to_depth_node.ts +++ b/paint/sources/neural_nodes/image_to_depth_node.ts @@ -25,7 +25,7 @@ function image_to_depth_node_button(node_id: i32) { /// else let input_buf: buffer_t = gpu_get_texture_pixels(input); /// end - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); let argv: string[] = [ dir + "/" + neural_node_sd_bin(), diff --git a/paint/sources/neural_nodes/image_to_normal_map_node.ts b/paint/sources/neural_nodes/image_to_normal_map_node.ts index fe6dbf66..31703a85 100644 --- a/paint/sources/neural_nodes/image_to_normal_map_node.ts +++ b/paint/sources/neural_nodes/image_to_normal_map_node.ts @@ -25,7 +25,7 @@ function image_to_normal_map_node_button(node_id: i32) { /// else let input_buf: buffer_t = gpu_get_texture_pixels(input); /// end - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); let argv: string[] = [ dir + "/" + neural_node_sd_bin(), diff --git a/paint/sources/neural_nodes/image_to_pbr_node.ts b/paint/sources/neural_nodes/image_to_pbr_node.ts index 750eff33..67e79d55 100644 --- a/paint/sources/neural_nodes/image_to_pbr_node.ts +++ b/paint/sources/neural_nodes/image_to_pbr_node.ts @@ -108,7 +108,7 @@ function image_to_pbr_node_button(node_id: i32) { /// else let input_buf: buffer_t = gpu_get_texture_pixels(input); /// end - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); image_to_pbr_node_run_sd("marigold-normals-v1-1.q8_0.gguf", "_normals", function(tex: gpu_texture_t) { image_to_pbr_node_result_normal = tex; @@ -170,7 +170,7 @@ function image_to_pbr_node_check_result(done: (tex: gpu_texture_t) => void) { iron_delay_idle_sleep(); if (iron_exec_async_done == 1) { let dir: string = neural_node_dir(); - let file: string = dir + path_sep + "output.png"; + let file: string = dir + PATH_SEP + "output.png"; if (iron_file_exists(file)) { let tex: gpu_texture_t = iron_load_texture(file); done(tex); diff --git a/paint/sources/neural_nodes/inpaint_image_node.ts b/paint/sources/neural_nodes/inpaint_image_node.ts index ab7970ca..13e84e6f 100644 --- a/paint/sources/neural_nodes/inpaint_image_node.ts +++ b/paint/sources/neural_nodes/inpaint_image_node.ts @@ -43,8 +43,8 @@ function inpaint_image_node_button(node_id: i32) { /// else let input_buf: buffer_t = gpu_get_texture_pixels(input); /// end - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); - iron_write_png(dir + path_sep + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); } else { let masked: gpu_texture_t = gpu_create_render_target(512, 512); @@ -55,7 +55,7 @@ function inpaint_image_node_button(node_id: i32) { draw_scaled_image(mask, 0, 0, 512, 512); draw_set_pipeline(null); draw_end(); - iron_write_png(dir + path_sep + "input.png", gpu_get_texture_pixels(masked), masked.width, masked.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", gpu_get_texture_pixels(masked), masked.width, masked.height, 0); } let argv: string[]; diff --git a/paint/sources/neural_nodes/neural_node.ts b/paint/sources/neural_nodes/neural_node.ts index bdfcadf7..189be491 100644 --- a/paint/sources/neural_nodes/neural_node.ts +++ b/paint/sources/neural_nodes/neural_node.ts @@ -69,7 +69,7 @@ function neural_node_check_result(node: ui_node_t) { neural_node_current = node; iron_delay_idle_sleep(); if (iron_exec_async_done == 1) { - let file: string = neural_node_dir() + path_sep + "output.png"; + let file: string = neural_node_dir() + PATH_SEP + "output.png"; if (iron_file_exists(file)) { let result: gpu_texture_t = iron_load_texture(file); map_set(neural_node_results, node.id, result); @@ -104,7 +104,7 @@ function neural_node_dir(): string { dir = iron_internal_save_path() + "models"; } else { - dir = iron_internal_files_location() + path_sep + "models"; + dir = iron_internal_files_location() + PATH_SEP + "models"; } return dir; } @@ -113,7 +113,7 @@ let neural_node_downloading: i32 = 0; function neural_node_download(url: string) { let file_name: string = substring(url, string_last_index_of(url, "/") + 1, url.length); - let file_path: string = neural_node_dir() + path_sep + file_name; + let file_path: string = neural_node_dir() + PATH_SEP + file_name; let found: bool = iron_file_exists(file_path); if (found) { return; diff --git a/paint/sources/neural_nodes/outpaint_image_node.ts b/paint/sources/neural_nodes/outpaint_image_node.ts index 02611481..f89236aa 100644 --- a/paint/sources/neural_nodes/outpaint_image_node.ts +++ b/paint/sources/neural_nodes/outpaint_image_node.ts @@ -51,8 +51,8 @@ function outpaint_image_node_button(node_id: i32) { // /// end let dir: string = neural_node_dir(); - iron_write_png(dir + path_sep + "input.png", gpu_get_texture_pixels(input_scaled), input_scaled.width, input_scaled.height, 0); - iron_write_png(dir + path_sep + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", gpu_get_texture_pixels(input_scaled), input_scaled.width, input_scaled.height, 0); + iron_write_png(dir + PATH_SEP + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); let argv: string[]; if (model == 0) { diff --git a/paint/sources/neural_nodes/tile_image_node.ts b/paint/sources/neural_nodes/tile_image_node.ts index b50ba94d..6125156d 100644 --- a/paint/sources/neural_nodes/tile_image_node.ts +++ b/paint/sources/neural_nodes/tile_image_node.ts @@ -54,8 +54,8 @@ function tile_image_node_button(node_id: i32) { let mask: gpu_texture_t = gpu_create_texture_from_bytes(u8a, 512, 512, gpu_texture_format_t.R8); let dir: string = neural_node_dir(); - iron_write_png(dir + path_sep + "input.png", gpu_get_texture_pixels(tile), tile.width, tile.height, 0); - iron_write_png(dir + path_sep + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 1); + iron_write_png(dir + PATH_SEP + "input.png", gpu_get_texture_pixels(tile), tile.width, tile.height, 0); + iron_write_png(dir + PATH_SEP + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 1); if (prompt == "") { prompt = "."; diff --git a/paint/sources/neural_nodes/upscale_image_node.ts b/paint/sources/neural_nodes/upscale_image_node.ts index fecac967..87474c79 100644 --- a/paint/sources/neural_nodes/upscale_image_node.ts +++ b/paint/sources/neural_nodes/upscale_image_node.ts @@ -25,7 +25,7 @@ function upscale_image_node_button(node_id: i32) { /// end let dir: string = neural_node_dir(); - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); let argv: string[] = [ dir + "/" + neural_node_sd_bin(), "-M", "upscale", "--upscale-model", dir + "/RealESRGAN_x4plus.pth", "-i", dir + "/input.png", "-o", diff --git a/paint/sources/neural_nodes/vary_image_node.ts b/paint/sources/neural_nodes/vary_image_node.ts index 1a06341c..014fd972 100644 --- a/paint/sources/neural_nodes/vary_image_node.ts +++ b/paint/sources/neural_nodes/vary_image_node.ts @@ -35,8 +35,8 @@ function vary_image_node_button(node_id: i32) { /// end let dir: string = neural_node_dir(); - iron_write_png(dir + path_sep + "input.png", input_buf, input.width, input.height, 0); - iron_write_png(dir + path_sep + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); + iron_write_png(dir + PATH_SEP + "input.png", input_buf, input.width, input.height, 0); + iron_write_png(dir + PATH_SEP + "mask.png", gpu_get_texture_pixels(mask), mask.width, mask.height, 0); let node_name: string = parser_material_node_name(node); let h: ui_handle_t = ui_handle(node_name); diff --git a/paint/sources/project.ts b/paint/sources/project.ts index 0847b305..51a1d4e7 100644 --- a/paint/sources/project.ts +++ b/paint/sources/project.ts @@ -64,7 +64,7 @@ function project_save(save_and_quit: bool = false) { } /// if (arm_windows || arm_linux || arm_macos) - let filename: string = substring(project_filepath, string_last_index_of(project_filepath, path_sep) + 1, project_filepath.length - 4); + let filename: string = substring(project_filepath, string_last_index_of(project_filepath, PATH_SEP) + 1, project_filepath.length - 4); sys_title_set(filename + " - " + manifest_title); /// end @@ -85,7 +85,7 @@ function project_save_as(save_and_quit: bool = false) { if (f == "") { f = tr("untitled"); } - project_filepath = path + path_sep + f; + project_filepath = path + PATH_SEP + f; if (!ends_with(project_filepath, ".arm")) { project_filepath += ".arm"; } @@ -95,7 +95,7 @@ function project_save_as(save_and_quit: bool = false) { function project_fetch_default_meshes() { if (project_mesh_list == null) { - project_mesh_list = file_read_directory(path_data() + path_sep + "meshes"); + project_mesh_list = file_read_directory(path_data() + PATH_SEP + "meshes"); for (let i: i32 = 0; i < project_mesh_list.length; ++i) { let s: string = project_mesh_list[i]; project_mesh_list[i] = substring(project_mesh_list[i], 0, s.length - 4); // Trim .arm @@ -324,7 +324,7 @@ function project_create_node_link(links: ui_node_link_t[], from_id: i32, from_so } function project_import_brush() { - let formats: string = string_array_join(path_texture_formats, ","); + let formats: string = string_array_join(path_texture_formats(), ","); ui_files_show("arm," + formats, false, true, function(path: string) { // Create brush from texture if (path_is_texture(path)) { @@ -366,7 +366,7 @@ function project_import_brush() { function project_import_mesh(replace_existing: bool = true, done: () => void = null) { _project_import_mesh_replace_existing = replace_existing; _project_import_mesh_done = done; - let formats: string = string_array_join(path_mesh_formats, ","); + let formats: string = string_array_join(path_mesh_formats(), ","); if (string_index_of(formats, "fbx") == -1) { // Show .fbx in the file picker even when fbx plugin is not yet enabled formats += ",fbx"; @@ -513,7 +513,7 @@ function project_unwrap_mesh(mesh: raw_mesh_t, done: (a: raw_mesh_t) => void) { 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, ","); + filters = string_array_join(path_texture_formats(), ",") + "," + string_array_join(path_mesh_formats(), ","); } _project_import_asset_hdr_as_envmap = hdr_as_envmap; @@ -568,7 +568,7 @@ function project_reimport_texture_load(path: string, asset: asset_t) { function project_reimport_texture(asset: asset_t) { if (!iron_file_exists(asset.file)) { - let filters: string = string_array_join(path_texture_formats, ","); + let filters: string = string_array_join(path_texture_formats(), ","); _project_reimport_texture_asset = asset; ui_files_show(filters, false, false, function(path: string) { project_reimport_texture_load(path, _project_reimport_texture_asset); @@ -649,10 +649,10 @@ 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); + export_arm_run_swatches(path + PATH_SEP + f); } }); } diff --git a/paint/sources/tab_browser.ts b/paint/sources/tab_browser.ts index 94783e6c..68e3388b 100644 --- a/paint/sources/tab_browser.ts +++ b/paint/sources/tab_browser.ts @@ -88,11 +88,11 @@ function tab_browser_draw(htab: ui_handle_t) { // Previous folder let text: string = tab_browser_hpath.text; - let i1: i32 = string_index_of(text, path_sep); + let i1: i32 = string_index_of(text, PATH_SEP); let nested: bool = i1 > -1 && text.length - 1 > i1; /// if arm_windows // Server addresses like \\server are not nested - nested = nested && !(text.length >= 2 && char_at(text, 0) == path_sep && char_at(text, 1) == path_sep && string_last_index_of(text, path_sep) == 1); + nested = nested && !(text.length >= 2 && char_at(text, 0) == PATH_SEP && char_at(text, 1) == PATH_SEP && string_last_index_of(text, PATH_SEP) == 1); /// end ui.enabled = nested; @@ -235,11 +235,11 @@ function tab_browser_draw(htab: ui_handle_t) { sys_notify_on_next_frame(function(path: string) { import_asset_run(path); }, path); - tab_browser_hpath.text = substring(tab_browser_hpath.text, 0, string_last_index_of(tab_browser_hpath.text, path_sep)); + tab_browser_hpath.text = substring(tab_browser_hpath.text, 0, string_last_index_of(tab_browser_hpath.text, PATH_SEP)); } let hpath_text: string = tab_browser_hpath.text; tab_browser_known = - string_index_of(substring(tab_browser_hpath.text, string_last_index_of(tab_browser_hpath.text, path_sep), hpath_text.length), ".") > 0; + string_index_of(substring(tab_browser_hpath.text, string_last_index_of(tab_browser_hpath.text, PATH_SEP), hpath_text.length), ".") > 0; /// if arm_android if (ends_with(tab_browser_hpath.text, "." + to_lower_case(manifest_title))) { tab_browser_known = false; diff --git a/paint/sources/tab_console.ts b/paint/sources/tab_console.ts index bb2eb8c7..3c3eff90 100644 --- a/paint/sources/tab_console.ts +++ b/paint/sources/tab_console.ts @@ -23,7 +23,7 @@ function tab_console_draw(htab: ui_handle_t) { if (f == "") { f = tr("untitled"); } - path = path + path_sep + f; + path = path + PATH_SEP + f; if (!ends_with(path, ".txt")) { path += ".txt"; } diff --git a/paint/sources/tab_layers.ts b/paint/sources/tab_layers.ts index 5baa5aeb..16f31c56 100644 --- a/paint/sources/tab_layers.ts +++ b/paint/sources/tab_layers.ts @@ -726,7 +726,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { if (!ends_with(f, ".png")) { f += ".png"; } - iron_write_png(path + path_sep + f, gpu_get_texture_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 + iron_write_png(path + PATH_SEP + f, gpu_get_texture_pixels(l.texpaint), l.texpaint.width, l.texpaint.height, 3); // RRR1 }); } else { diff --git a/paint/sources/tab_scripts.ts b/paint/sources/tab_scripts.ts index 296695a5..9e18bb9f 100644 --- a/paint/sources/tab_scripts.ts +++ b/paint/sources/tab_scripts.ts @@ -33,7 +33,7 @@ function tab_scripts_draw(htab: ui_handle_t) { if (f == "") { f = tr("untitled"); } - path = path + path_sep + f; + path = path + PATH_SEP + f; if (!ends_with(path, ".js")) { path += ".js"; } diff --git a/paint/sources/tab_textures.ts b/paint/sources/tab_textures.ts index 3b97b214..b1eb37f6 100644 --- a/paint/sources/tab_textures.ts +++ b/paint/sources/tab_textures.ts @@ -15,7 +15,7 @@ function tab_textures_draw(htab: ui_handle_t) { ui_row(row); if (ui_icon_button(tr("Import"), icon_t.IMPORT)) { - ui_files_show(string_array_join(path_texture_formats, ","), false, true, function(path: string) { + ui_files_show(string_array_join(path_texture_formats(), ","), false, true, function(path: string) { import_asset_run(path, -1.0, -1.0, true, false); ui_base_hwnds[tab_area_t.STATUS].redraws = 2; }); @@ -144,7 +144,7 @@ function tab_textures_draw(htab: ui_handle_t) { } let buf: buffer_t = gpu_get_texture_pixels(target); - iron_write_png(path + path_sep + f, buf, target.width, target.height, 0); + iron_write_png(path + PATH_SEP + f, buf, target.width, target.height, 0); gpu_delete_texture(target); }, target); }); @@ -180,11 +180,11 @@ function tab_textures_draw(htab: ui_handle_t) { tab_textures_delete_texture(_tab_textures_draw_asset); } if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open Containing Directory..."), "", icon_t.FOLDER_OPEN)) { - file_start(substring(_tab_textures_draw_asset.file, 0, string_last_index_of(_tab_textures_draw_asset.file, path_sep))); + file_start(substring(_tab_textures_draw_asset.file, 0, string_last_index_of(_tab_textures_draw_asset.file, PATH_SEP))); } if (!_tab_textures_draw_is_packed && ui_menu_button(tr("Open in Browser"))) { tab_browser_show_directory( - substring(_tab_textures_draw_asset.file, 0, string_last_index_of(_tab_textures_draw_asset.file, path_sep))); + substring(_tab_textures_draw_asset.file, 0, string_last_index_of(_tab_textures_draw_asset.file, PATH_SEP))); } }); } diff --git a/paint/sources/translator.ts b/paint/sources/translator.ts index 09209a22..1792ac0a 100644 --- a/paint/sources/translator.ts +++ b/paint/sources/translator.ts @@ -113,7 +113,7 @@ function translator_load_translations(new_locale: string) { } else { _translator_load_translations_cjk_font_path = ""; - _translator_load_translations_cjk_font_disk_path = path_data() + path_sep; + _translator_load_translations_cjk_font_disk_path = path_data() + PATH_SEP; } _translator_load_translations_cjk_font_path += "font_cjk.ttc"; _translator_load_translations_cjk_font_disk_path += "font_cjk.ttc"; @@ -186,7 +186,7 @@ function translator_extended_glyphs() { // Returns a list of supported locales (plus English and the automatically detected system locale) function translator_get_supported_locales(): string[] { let locales: string[] = [ "system", "en" ]; - let files: string[] = file_read_directory(path_data() + path_sep + "locale"); + let files: string[] = file_read_directory(path_data() + PATH_SEP + "locale"); for (let i: i32 = 0; i < files.length; ++i) { let locale_filename: string = files[i]; // Trim the ".json" file extension from file names diff --git a/paint/sources/ui_files.ts b/paint/sources/ui_files.ts index 379b9424..caa6a754 100644 --- a/paint/sources/ui_files.ts +++ b/paint/sources/ui_files.ts @@ -32,13 +32,13 @@ function ui_files_show(filters: string, is_save: bool, open_multiple: bool, file if (is_save) { ui_files_path = iron_save_dialog(filters, ""); if (ui_files_path != null) { - let sep2: string = path_sep + path_sep; + let sep2: string = PATH_SEP + PATH_SEP; while (string_index_of(ui_files_path, sep2) >= 0) { - ui_files_path = string_replace_all(ui_files_path, sep2, path_sep); + ui_files_path = string_replace_all(ui_files_path, sep2, PATH_SEP); } ui_files_path = string_replace_all(ui_files_path, "\r", ""); - ui_files_filename = substring(ui_files_path, string_last_index_of(ui_files_path, path_sep) + 1, ui_files_path.length); - ui_files_path = substring(ui_files_path, 0, string_last_index_of(ui_files_path, path_sep)); + ui_files_filename = substring(ui_files_path, string_last_index_of(ui_files_path, PATH_SEP) + 1, ui_files_path.length); + ui_files_path = substring(ui_files_path, 0, string_last_index_of(ui_files_path, PATH_SEP)); files_done(ui_files_path); } } @@ -47,12 +47,12 @@ function ui_files_show(filters: string, is_save: bool, open_multiple: bool, file if (paths != null) { for (let i: i32 = 0; i < paths.length; ++i) { let path: string = paths[i]; - let sep2: string = path_sep + path_sep; + let sep2: string = PATH_SEP + PATH_SEP; while (string_index_of(path, sep2) >= 0) { - path = string_replace_all(path, sep2, path_sep); + path = string_replace_all(path, sep2, PATH_SEP); } path = string_replace_all(path, "\r", ""); - ui_files_filename = substring(path, string_last_index_of(path, path_sep) + 1, path.length); + ui_files_filename = substring(path, string_last_index_of(path, PATH_SEP) + 1, path.length); files_done(path); } } @@ -204,19 +204,19 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se if (ui_files_icon_file_map == null) { ui_files_icon_file_map = map_create(); } - icon = map_get(ui_files_icon_map, handle.text + path_sep + f); + icon = map_get(ui_files_icon_map, handle.text + PATH_SEP + f); if (icon == null) { let dot: i32 = string_last_index_of(f, "."); if (dot > -1) { let files_all: string[] = file_read_directory(handle.text); let icon_file: string = substring(f, 0, dot) + "_icon.jpg"; if (array_index_of(files_all, icon_file) >= 0) { - map_set(ui_files_icon_map, handle.text + path_sep + f, icons); + map_set(ui_files_icon_map, handle.text + PATH_SEP + f, icons); _ui_files_file_browser_handle = handle; map_set(ui_files_icon_file_map, icon_file, f); - file_cache_cloud(handle.text + path_sep + icon_file, function(abs: string) { + file_cache_cloud(handle.text + PATH_SEP + icon_file, function(abs: string) { if (abs != null) { let image: gpu_texture_t = data_get_image(abs); if (image != null) { @@ -241,7 +241,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se draw_set_pipeline(null); draw_end(); - map_set(ui_files_icon_map, _ui_files_file_browser_handle.text + path_sep + data.f, icon); + map_set(ui_files_icon_map, _ui_files_file_browser_handle.text + PATH_SEP + data.f, icon); ui_base_hwnds[tab_area_t.STATUS].redraws = 3; }, data); } @@ -274,7 +274,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se if (ui_files_icon_map == null) { ui_files_icon_map = map_create(); } - let key: string = handle.text + path_sep + f; + let key: string = handle.text + PATH_SEP + f; icon = map_get(ui_files_icon_map, key); if (icon == null) { let blob_path: string = key; @@ -339,7 +339,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se if (ui_files_icon_map == null) { ui_files_icon_map = map_create(); } - let shandle: string = handle.text + path_sep + f; + let shandle: string = handle.text + PATH_SEP + f; /// if arm_ios shandle = document_directory + shandle; /// end @@ -370,7 +370,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se } if (ui.is_hovered && ui.input_released_r && context_menu != null) { - context_menu(handle.text + path_sep + f); + context_menu(handle.text + PATH_SEP + f); } if (state == ui_state_t.STARTED) { @@ -383,8 +383,8 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se base_drag_file = document_directory + base_drag_file; } /// end - if (char_at(base_drag_file, base_drag_file.length - 1) != path_sep) { - base_drag_file += path_sep; + if (char_at(base_drag_file, base_drag_file.length - 1) != PATH_SEP) { + base_drag_file += PATH_SEP; } base_drag_file += f; base_drag_file_icon = icon; @@ -396,8 +396,8 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se base_drag_file_icon = null; base_is_dragging = false; handle.changed = ui.changed = true; - if (char_at(handle.text, handle.text.length - 1) != path_sep) { - handle.text += path_sep; + if (char_at(handle.text, handle.text.length - 1) != PATH_SEP) { + handle.text += PATH_SEP; } handle.text += f; ui_files_selected = -1; @@ -476,10 +476,10 @@ function ui_files_make_icon(args: ui_files_make_icon_t) { } function ui_files_go_up(handle: ui_handle_t) { - handle.text = substring(handle.text, 0, string_last_index_of(handle.text, path_sep)); + handle.text = substring(handle.text, 0, string_last_index_of(handle.text, PATH_SEP)); // Drive root if (handle.text.length == 2 && char_at(handle.text, 1) == ":") { - handle.text += path_sep; + handle.text += PATH_SEP; } } diff --git a/paint/sources/ui_header.ts b/paint/sources/ui_header.ts index 4faa6f6f..36e7298b 100644 --- a/paint/sources/ui_header.ts +++ b/paint/sources/ui_header.ts @@ -62,7 +62,7 @@ function ui_header_draw_tool_properties() { } } if (ui_button(tr("Import"))) { - ui_files_show(string_array_join(path_texture_formats, ","), false, true, function(path: string) { + ui_files_show(string_array_join(path_texture_formats(), ","), false, true, function(path: string) { import_asset_run(path, -1.0, -1.0, true, false); context_raw.colorid_handle.i = project_asset_names.length - 1; diff --git a/paint/sources/ui_menubar.ts b/paint/sources/ui_menubar.ts index 69383fe4..f05be519 100644 --- a/paint/sources/ui_menubar.ts +++ b/paint/sources/ui_menubar.ts @@ -229,7 +229,7 @@ function ui_menubar_draw_category_items() { if (ui_menu_sub_button(ui_handle(__ID__), tr("Import"))) { ui_menu_sub_begin(7); if (ui_menu_button(tr("Texture..."), map_get(config_keymap, "file_import_assets"), icon_t.IMAGE)) { - project_import_asset(string_array_join(path_texture_formats, ","), false); + project_import_asset(string_array_join(path_texture_formats(), ","), false); } if (ui_menu_button(tr("Envmap..."), "", icon_t.LANDSCAPE)) { ui_files_show("hdr", false, false, function(path: string) {