From 4ba39c0ee805497517ecccaf6e409ff5ee2a4250 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 1 Sep 2025 13:44:44 +0200 Subject: [PATCH] Cleanup --- base/sources/ts/box_preferences.ts | 4 ++-- base/sources/ts/box_projects.ts | 14 +++++++------- base/sources/ts/config.ts | 2 +- base/sources/ts/file.ts | 16 ++-------------- base/sources/ts/import_arm.ts | 8 ++++---- base/sources/ts/project.ts | 6 +++--- base/sources/ts/translator.ts | 4 ++-- base/sources/ts/ui_menubar.ts | 22 +++++++++++----------- 8 files changed, 32 insertions(+), 44 deletions(-) diff --git a/base/sources/ts/box_preferences.ts b/base/sources/ts/box_preferences.ts index 32e81eb3..561cbd22 100644 --- a/base/sources/ts/box_preferences.ts +++ b/base/sources/ts/box_preferences.ts @@ -541,7 +541,7 @@ function box_preferences_show() { let name: string = to_lower_case(manifest_title); url += name; url += "_docs#pen"; - file_load_url(url); + iron_load_url(url); } } @@ -840,7 +840,7 @@ plugin_notify_on_ui(plugin, function() {\ plugin_stop(_box_preferences_f); } array_remove(box_preferences_files_plugin, _box_preferences_f); - file_delete(path); + iron_delete_file(path); } }); } diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index de5caf36..76e0344d 100644 --- a/base/sources/ts/box_projects.ts +++ b/base/sources/ts/box_projects.ts @@ -148,10 +148,10 @@ function box_projects_tab() { // if (ui_menu_button(tr("Duplicate"))) {} if (ui_menu_button(tr("Delete"))) { sys_notify_on_next_frame(function () { - file_delete(_box_projects_path); - file_delete(_box_projects_icon_path); + iron_delete_file(_box_projects_path); + iron_delete_file(_box_projects_icon_path); let data_path: string = substring(_box_projects_path, 0, _box_projects_path.length - 4); - file_delete(data_path); + iron_delete_file(data_path); let recent_projects: string[] = config_raw.recent_projects; array_splice(recent_projects, _box_projects_i, 1); }); @@ -208,7 +208,7 @@ function box_projects_recent_tab() { continue; // Search filter } - if (ui_button(file, ui_align_t.LEFT) && file_exists(path)) { + if (ui_button(file, ui_align_t.LEFT) && iron_file_exists(path)) { let current: gpu_texture_t = _draw_current; let in_use: bool = gpu_in_use; if (in_use) draw_end(); @@ -249,13 +249,13 @@ function box_projects_draw_badge() { function box_projects_get_started_tab() { if (ui_tab(box_projects_htab, tr("Get Started"), true)) { if (ui_button(tr("Manual"))) { - file_load_url(manifest_url + "/manual"); + iron_load_url(manifest_url + "/manual"); } if (ui_button(tr("How To"))) { - file_load_url(manifest_url + "/howto"); + iron_load_url(manifest_url + "/howto"); } if (ui_button(tr("What's New"))) { - file_load_url(manifest_url + "/notes"); + iron_load_url(manifest_url + "/notes"); } } } diff --git a/base/sources/ts/config.ts b/base/sources/ts/config.ts index aa9aedb3..54c874f9 100644 --- a/base/sources/ts/config.ts +++ b/base/sources/ts/config.ts @@ -106,7 +106,7 @@ function config_save() { iron_file_save_bytes(path, buffer, 0); ///if arm_linux // Protected directory - if (!file_exists(path)) { + if (!iron_file_exists(path)) { iron_file_save_bytes(iron_internal_save_path() + "config.json", buffer, 0); } ///end diff --git a/base/sources/ts/file.ts b/base/sources/ts/file.ts index 3f8563bd..2ee4f592 100644 --- a/base/sources/ts/file.ts +++ b/base/sources/ts/file.ts @@ -96,18 +96,6 @@ function file_start(path: string) { ///end } -function file_load_url(url: string) { - iron_load_url(url); -} - -function file_delete(path: string) { - iron_delete_file(path); -} - -function file_exists(path: string): bool { - return iron_file_exists(path); -} - 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 }; @@ -162,7 +150,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { } dest += path2; - if (file_exists(dest)) { + if (iron_file_exists(dest)) { ///if (arm_macos || arm_ios) done(dest); ///else @@ -193,7 +181,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) { file_download(url, dest, function (url: string) { let fccd: file_cache_cloud_data_t = map_get(_file_cache_cloud_map, url); - if (!file_exists(fccd.dest)) { + if (!iron_file_exists(fccd.dest)) { console_error(strings_check_internet_connection()); fccd.done(null); return; diff --git a/base/sources/ts/import_arm.ts b/base/sources/ts/import_arm.ts index 49406556..26b63ae5 100644 --- a/base/sources/ts/import_arm.ts +++ b/base/sources/ts/import_arm.ts @@ -110,7 +110,7 @@ function import_arm_run_project(path: string) { abs = path_normalize(abs); import_arm_unpack_asset(project, abs, file); } - if (map_get(data_cached_images, abs) == null && !file_exists(abs)) { + if (map_get(data_cached_images, abs) == null && !iron_file_exists(abs)) { import_arm_make_pink(abs); } let hdr_as_envmap: bool = ends_with(abs, ".hdr") && project_raw.envmap == abs; @@ -128,7 +128,7 @@ function import_arm_run_project(path: string) { ///end // Convert font path from relative to absolute let abs: string = data_is_abs(file) ? file : base + file; - if (file_exists(abs)) { + if (iron_file_exists(abs)) { import_font_run(abs); } } @@ -444,7 +444,7 @@ function import_arm_run_material_from_project(project: project_format_t, path: s abs = path_normalize(abs); import_arm_unpack_asset(project, abs, file); } - if (map_get(data_cached_images, abs) == null && !file_exists(abs)) { + if (map_get(data_cached_images, abs) == null && !iron_file_exists(abs)) { import_arm_make_pink(abs); } import_texture_run(abs); @@ -555,7 +555,7 @@ function import_arm_run_brush_from_project(project: project_format_t, path: stri abs = path_normalize(abs); import_arm_unpack_asset(project, abs, file); } - if (map_get(data_cached_images, abs) == null && !file_exists(abs)) { + if (map_get(data_cached_images, abs) == null && !iron_file_exists(abs)) { import_arm_make_pink(abs); } import_texture_run(abs); diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 2682509e..e7aa5c0a 100644 --- a/base/sources/ts/project.ts +++ b/base/sources/ts/project.ts @@ -475,7 +475,7 @@ function project_import_mesh_box(path: string, replace_existing: bool = true, cl } } if (ui_button(tr("?"))) { - file_load_url("https://github.com/armory3d/armorpaint_web/blob/main/manual.md#faq"); + iron_load_url("https://github.com/armory3d/armorpaint_web/blob/main/manual.md#faq"); } } }); @@ -484,7 +484,7 @@ function project_import_mesh_box(path: string, replace_existing: bool = true, cl } function project_reimport_mesh() { - if (project_mesh_assets != null && project_mesh_assets.length > 0 && file_exists(project_mesh_assets[0])) { + if (project_mesh_assets != null && project_mesh_assets.length > 0 && iron_file_exists(project_mesh_assets[0])) { project_import_mesh_box(project_mesh_assets[0], true, false); } else { @@ -624,7 +624,7 @@ function project_reimport_texture_load(path: string, asset: asset_t) { } function project_reimport_texture(asset: asset_t) { - if (!file_exists(asset.file)) { + if (!iron_file_exists(asset.file)) { let filters: string = string_array_join(path_texture_formats, ","); _project_reimport_texture_asset = asset; ui_files_show(filters, false, false, function (path: string) { diff --git a/base/sources/ts/translator.ts b/base/sources/ts/translator.ts index ec9e115f..5c1afd89 100644 --- a/base/sources/ts/translator.ts +++ b/base/sources/ts/translator.ts @@ -118,10 +118,10 @@ function translator_load_translations(new_locale: string) { _translator_load_translations_cjk_font_path += "font_cjk.ttc"; _translator_load_translations_cjk_font_disk_path += "font_cjk.ttc"; - if (!file_exists(_translator_load_translations_cjk_font_disk_path)) { + if (!iron_file_exists(_translator_load_translations_cjk_font_disk_path)) { file_download("https://github.com/armory3d/armorbase/raw/main/Assets/common/extra/font_cjk.ttc", _translator_load_translations_cjk_font_disk_path, function () { - if (!file_exists(_translator_load_translations_cjk_font_disk_path)) { + if (!iron_file_exists(_translator_load_translations_cjk_font_disk_path)) { // Fall back to English config_raw.locale = "en"; translator_extended_glyphs(); diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index e39b80a2..a634f85c 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -607,38 +607,38 @@ function ui_menubar_draw_category_items() { } else if (ui_menubar_category == menubar_category_t.HELP) { if (ui_menu_button(tr("Manual"))) { - file_load_url(manifest_url + "/manual"); + iron_load_url(manifest_url + "/manual"); } if (ui_menu_button(tr("How To"))) { - file_load_url(manifest_url + "/howto"); + iron_load_url(manifest_url + "/howto"); } if (ui_menu_button(tr("What's New"))) { - file_load_url(manifest_url + "/notes"); + iron_load_url(manifest_url + "/notes"); } if (ui_menu_button(tr("Issue Tracker"))) { - file_load_url("https://github.com/armory3d/armortools/issues"); + iron_load_url("https://github.com/armory3d/armortools/issues"); } if (ui_menu_button(tr("Report Bug"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); + iron_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); + iron_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); ///end } if (ui_menu_button(tr("Request Feature"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); + iron_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Feature description:**%0A%0A"); + iron_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + iron_system_id() + "*%0A%0A**Feature description:**%0A%0A"); ///end } ui_menu_separator(); if (ui_menu_button(tr("Check for Updates..."))) { ///if arm_android - file_load_url(manifest_url_android); + iron_load_url(manifest_url_android); ///elseif arm_ios - file_load_url(manifest_url_ios); + iron_load_url(manifest_url_ios); ///else // Retrieve latest version number file_download_bytes("https://server.armorpaint.org/" + to_lower_case(manifest_title) + ".html", function (url: string, buffer: buffer_t) { @@ -704,7 +704,7 @@ function ui_menubar_draw_category_items() { ///end if (ui_button(tr("Contributors"))) { - file_load_url("https://github.com/armory3d/armortools/graphs/contributors"); + iron_load_url("https://github.com/armory3d/armortools/graphs/contributors"); } if (ui_button(tr("OK"))) { ui_box_hide();