From 881d1984cf9ecd6057b3aeb3600b6fa2e3236491 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Wed, 24 Feb 2021 16:05:43 -0300 Subject: [PATCH] Fix import selector resetting in Import Defaults Editor --- editor/import_defaults_editor.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index ad084114034..28c595614f6 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -75,6 +75,7 @@ void ImportDefaultsEditor::_reset() { settings->notify_property_list_changed(); } } + void ImportDefaultsEditor::_save() { if (settings->importer.is_valid()) { Dictionary modified; @@ -140,12 +141,22 @@ void ImportDefaultsEditor::_update_importer() { inspector->edit(settings); } + void ImportDefaultsEditor::_importer_selected(int p_index) { _update_importer(); } + void ImportDefaultsEditor::clear() { + String last_selected; + if (importers->get_selected() > 0) { + last_selected = importers->get_item_text(importers->get_selected()); + } + importers->clear(); + importers->add_item("<" + TTR("Select Importer") + ">"); + importers->set_item_disabled(0, true); + List> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Vector names; @@ -157,11 +168,17 @@ void ImportDefaultsEditor::clear() { for (int i = 0; i < names.size(); i++) { importers->add_item(names[i]); + + if (names[i] == last_selected) { + importers->select(i + 1); + } } } + void ImportDefaultsEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("project_settings_changed")); } + ImportDefaultsEditor::ImportDefaultsEditor() { HBoxContainer *hb = memnew(HBoxContainer); hb->add_child(memnew(Label(TTR("Importer:"))));