diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 83e71292a39..ff42b824359 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -439,7 +439,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo } } - if (importer_name == "keep") { + if (importer_name == "keep" || importer_name == "skip") { return false; //keep mode, do not reimport } @@ -1859,7 +1859,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector source_file_options[p_files[i]] = HashMap(); importer_name = file_importer_name; - if (importer_name == "keep") { + if (importer_name == "keep" || importer_name == "skip") { continue; //do nothing } @@ -1885,7 +1885,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector base_paths[p_files[i]] = ResourceFormatImporter::get_singleton()->get_import_base_path(p_files[i]); } - if (importer_name == "keep") { + if (importer_name == "keep" || importer_name == "skip") { return OK; // (do nothing) } @@ -2078,7 +2078,7 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapfiles[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index c212bdb84f3..d2a187bcfd5 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -1196,6 +1196,11 @@ Error EditorExportPlatform::export_project_files(bool p_main_pack, const Refget_value("remap", "importer"); + if (importer_type == "skip") { + // Skip file. + continue; + } + if (importer_type == "keep") { // Just keep file as-is. Vector array = FileAccess::get_file_as_bytes(path); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 88fed16db14..fc170d606a0 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1160,7 +1160,7 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit if (err == OK) { if (config->has_section_key("remap", "importer")) { String importer = config->get_value("remap", "importer"); - if (importer == "keep") { + if (importer == "keep" || importer == "skip") { EditorNode::get_singleton()->show_warning(TTR("Importing has been disabled for this file, so it can't be opened for editing.")); return; } diff --git a/editor/import/resource_importer_bmfont.cpp b/editor/import/resource_importer_bmfont.cpp index a2cb306c942..085ca1362d2 100644 --- a/editor/import/resource_importer_bmfont.cpp +++ b/editor/import/resource_importer_bmfont.cpp @@ -30,6 +30,7 @@ #include "resource_importer_bmfont.h" +#include "core/io/config_file.h" #include "core/io/resource_saver.h" String ResourceImporterBMFont::get_importer_name() const { @@ -75,9 +76,24 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String & Ref font; font.instantiate(); - Error err = font->load_bitmap_font(p_source_file); + List image_files; + Error err = font->_load_bitmap_font(p_source_file, &image_files); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot load font to file \"" + p_source_file + "\"."); + // Update import settings for the image files used by font. + for (List::Element *E = image_files.front(); E; E = E->next()) { + Ref config; + config.instantiate(); + + err = config->load(E->get() + ".import"); + if (err == OK) { + config->clear(); + config->set_value("remap", "importer", "skip"); + + config->save(E->get() + ".import"); + } + } + font->set_allow_system_fallback(false); font->set_fallbacks(fallbacks); font->set_fixed_size_scale_mode(smode); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 47572a991c5..6f4a376496f 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -48,7 +48,8 @@ public: Ref importer; Vector paths; HashSet checked; - bool checking; + bool checking = false; + bool skip = false; String base_options_path; bool _set(const StringName &p_name, const Variant &p_value) { @@ -91,10 +92,6 @@ public: void update() { notify_property_list_changed(); } - - ImportDockParameters() { - checking = false; - } }; ImportDock *ImportDock::singleton = nullptr; @@ -109,8 +106,16 @@ void ImportDock::set_edit_path(const String &p_path) { } String importer_name = config->get_value("remap", "importer"); - - params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); + if (importer_name == "keep") { + params->importer.unref(); + params->skip = false; + } else if (importer_name == "skip") { + params->importer.unref(); + params->skip = true; + } else { + params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); + params->skip = false; + } params->paths.clear(); params->paths.push_back(p_path); @@ -152,9 +157,13 @@ void ImportDock::set_edit_path(const String &p_path) { void ImportDock::_add_keep_import_option(const String &p_importer_name) { import_as->add_separator(); - import_as->add_item(TTR("Keep File (No Import)")); + import_as->add_item(TTR("Keep File (exported as is)")); import_as->set_item_metadata(-1, "keep"); + import_as->add_item(TTR("Skip File (not exported)")); + import_as->set_item_metadata(-1, "skip"); if (p_importer_name == "keep") { + import_as->select(import_as->get_item_count() - 2); + } else if (p_importer_name == "skip") { import_as->select(import_as->get_item_count() - 1); } } @@ -163,7 +172,7 @@ void ImportDock::_update_options(const String &p_path, const Ref &p_ // Set the importer class to fetch the correct class in the XML class reference. // This allows tooltips to display when hovering properties. if (params->importer != nullptr) { - // Null check to avoid crashing if the "Keep File (No Import)" mode is selected. + // Null check to avoid crashing if the "Keep File (exported as is)" mode is selected. import_opts->set_object_class(params->importer->get_class_name()); } @@ -215,7 +224,17 @@ void ImportDock::set_edit_multiple_paths(const Vector &p_paths) { ERR_CONTINUE(err != OK); if (i == 0) { - params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap", "importer")); + String importer_name = config->get_value("remap", "importer"); + if (importer_name == "keep") { + params->importer.unref(); + params->skip = false; + } else if (importer_name == "skip") { + params->importer.unref(); + params->skip = true; + } else { + params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); + params->skip = false; + } if (params->importer.is_null()) { clear(); return; @@ -372,12 +391,18 @@ void ImportDock::_importer_selected(int i_idx) { String name = import_as->get_selected_metadata(); if (name == "keep") { params->importer.unref(); + params->skip = false; + _update_options(params->base_options_path, Ref()); + } else if (name == "skip") { + params->importer.unref(); + params->skip = true; _update_options(params->base_options_path, Ref()); } else { Ref importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name); ERR_FAIL_COND(importer.is_null()); params->importer = importer; + params->skip = false; Ref config; if (params->paths.size()) { String path = params->paths[0]; @@ -490,7 +515,11 @@ void ImportDock::_reimport_attempt() { if (params->importer.is_valid()) { importer_name = params->importer->get_importer_name(); } else { - importer_name = "keep"; + if (params->skip) { + importer_name = "skip"; + } else { + importer_name = "keep"; + } } for (int i = 0; i < params->paths.size(); i++) { Ref config; @@ -566,6 +595,7 @@ void ImportDock::_advanced_options() { params->importer->show_advanced_options(params->paths[0]); } } + void ImportDock::_reimport() { for (int i = 0; i < params->paths.size(); i++) { Ref config; @@ -611,7 +641,11 @@ void ImportDock::_reimport() { } else { //set to no import config->clear(); - config->set_value("remap", "importer", "keep"); + if (params->skip) { + config->set_value("remap", "importer", "skip"); + } else { + config->set_value("remap", "importer", "keep"); + } } config->save(params->paths[i] + ".import"); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index f2efa7fcbab..bc8e0b90156 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1417,6 +1417,10 @@ static const char32_t _oem_to_unicode[][129] = { }; Error FontFile::load_bitmap_font(const String &p_path) { + return _load_bitmap_font(p_path, nullptr); +} + +Error FontFile::_load_bitmap_font(const String &p_path, List *r_image_files) { reset_state(); antialiasing = TextServer::FONT_ANTIALIASING_NONE; @@ -1558,6 +1562,9 @@ Error FontFile::load_bitmap_font(const String &p_path) { img.instantiate(); Error err = ImageLoader::load_image(file, img); ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_READ, vformat("Can't load font texture: %s.", file)); + if (r_image_files) { + r_image_files->push_back(file); + } if (packed) { if (ch[3] == 0) { // 4 x 8 bit monochrome, no outline @@ -1849,6 +1856,10 @@ Error FontFile::load_bitmap_font(const String &p_path) { img.instantiate(); Error err = ImageLoader::load_image(file, img); ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_CANT_READ, vformat("Can't load font texture: %s.", file)); + if (r_image_files) { + r_image_files->push_back(file); + } + if (packed) { if (ch[3] == 0) { // 4 x 8 bit monochrome, no outline outline = 0; diff --git a/scene/resources/font.h b/scene/resources/font.h index a435d14a02e..1878539a3ff 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -227,6 +227,8 @@ protected: virtual void reset_state() override; public: + Error _load_bitmap_font(const String &p_path, List *r_image_files); + Error load_bitmap_font(const String &p_path); Error load_dynamic_font(const String &p_path);