summaryrefslogtreecommitdiffstats
path: root/editor/import_dock.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-02-05 12:10:37 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-03-12 21:34:40 +0200
commitfee14eb5e86757e0a915ef6a0cf645a65a1296de (patch)
treec30056bbf14ae06d82274a391c5ea66b4d362900 /editor/import_dock.cpp
parent61282068f4d59cb48f35ad95391728c58d9008ab (diff)
downloadredot-engine-fee14eb5e86757e0a915ef6a0cf645a65a1296de.tar.gz
[Import] Add "skip file" import option to skip (and exclude from export) importable formats, auto set it for the images used by bitmap font.
Diffstat (limited to 'editor/import_dock.cpp')
-rw-r--r--editor/import_dock.cpp58
1 files changed, 46 insertions, 12 deletions
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 47572a991c..6f4a376496 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -48,7 +48,8 @@ public:
Ref<ResourceImporter> importer;
Vector<String> paths;
HashSet<StringName> 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<ConfigFile> &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<String> &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<ConfigFile>());
+ } else if (name == "skip") {
+ params->importer.unref();
+ params->skip = true;
_update_options(params->base_options_path, Ref<ConfigFile>());
} else {
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name);
ERR_FAIL_COND(importer.is_null());
params->importer = importer;
+ params->skip = false;
Ref<ConfigFile> 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<ConfigFile> 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<ConfigFile> 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");