summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_inspector.cpp1
-rw-r--r--editor/import_dock.cpp51
-rw-r--r--editor/import_dock.h1
3 files changed, 48 insertions, 5 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 1324ad0e65..1230588016 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2303,6 +2303,7 @@ void EditorInspector::_bind_methods() {
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property")));
+ ADD_SIGNAL(MethodInfo("property_toggled", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::BOOL, "checked")));
ADD_SIGNAL(MethodInfo("restart_requested"));
}
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 31eb193461..2e68609a56 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -38,11 +38,17 @@ public:
List<PropertyInfo> properties;
Ref<ResourceImporter> importer;
Vector<String> paths;
+ Set<StringName> checked;
+ bool checking;
bool _set(const StringName &p_name, const Variant &p_value) {
if (values.has(p_name)) {
values[p_name] = p_value;
+ if (checking) {
+ checked.insert(p_name);
+ _change_notify(String(p_name).utf8().get_data());
+ }
return true;
}
@@ -63,13 +69,24 @@ public:
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
if (!importer->get_option_visibility(E->get().name, values))
continue;
- p_list->push_back(E->get());
+ PropertyInfo pi = E->get();
+ if (checking) {
+ pi.usage |= PROPERTY_USAGE_CHECKABLE;
+ if (checked.has(E->get().name)) {
+ pi.usage |= PROPERTY_USAGE_CHECKED;
+ }
+ }
+ p_list->push_back(pi);
}
}
void update() {
_change_notify();
}
+
+ ImportDockParameters() {
+ checking = false;
+ }
};
void ImportDock::set_edit_path(const String &p_path) {
@@ -125,6 +142,8 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
params->properties.clear();
params->values.clear();
+ params->checking = false;
+ params->checked.clear();
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
@@ -205,6 +224,8 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
params->properties.clear();
params->values.clear();
+ params->checking = true;
+ params->checked.clear();
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
@@ -360,11 +381,21 @@ void ImportDock::_reimport() {
Error err = config->load(params->paths[i] + ".import");
ERR_CONTINUE(err != OK);
- config->set_value("remap", "importer", params->importer->get_importer_name());
- config->erase_section("params");
+ if (params->checking) {
+ //update only what edited (checkboxes)
+ for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) {
+ if (params->checked.has(E->get().name)) {
+ config->set_value("params", E->get().name, params->values[E->get().name]);
+ }
+ }
+ } else {
+ //override entirely
+ config->set_value("remap", "importer", params->importer->get_importer_name());
+ config->erase_section("params");
- for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) {
- config->set_value("params", E->get().name, params->values[E->get().name]);
+ for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) {
+ config->set_value("params", E->get().name, params->values[E->get().name]);
+ }
}
config->save(params->paths[i] + ".import");
@@ -388,11 +419,20 @@ void ImportDock::_notification(int p_what) {
} break;
}
}
+
+void ImportDock::_property_toggled(const StringName &p_prop, bool p_checked) {
+ if (p_checked) {
+ params->checked.insert(p_prop);
+ } else {
+ params->checked.erase(p_prop);
+ }
+}
void ImportDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport);
ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected);
ClassDB::bind_method(D_METHOD("_importer_selected"), &ImportDock::_importer_selected);
+ ClassDB::bind_method(D_METHOD("_property_toggled"), &ImportDock::_property_toggled);
}
void ImportDock::initialize_import_options() const {
@@ -423,6 +463,7 @@ ImportDock::ImportDock() {
import_opts = memnew(EditorInspector);
add_child(import_opts);
import_opts->set_v_size_flags(SIZE_EXPAND_FILL);
+ import_opts->connect("property_toggled", this, "_property_toggled");
hb = memnew(HBoxContainer);
add_child(hb);
diff --git a/editor/import_dock.h b/editor/import_dock.h
index 41c7298d9a..632fd39700 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -60,6 +60,7 @@ class ImportDock : public VBoxContainer {
void _importer_selected(int i_idx);
void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
+ void _property_toggled(const StringName &p_prop, bool p_checked);
void _reimport();
enum {