diff --git a/src/editor/search/search_dialog.cpp b/src/editor/search/search_dialog.cpp index 2b760089..abd4276b 100644 --- a/src/editor/search/search_dialog.cpp +++ b/src/editor/search/search_dialog.cpp @@ -186,6 +186,11 @@ void OrchestratorEditorSearchDialog::_notification(int p_what) disconnect("confirmed", callable_mp(this, &OrchestratorEditorSearchDialog::_on_confirmed)); disconnect("canceled", callable_mp(this, &OrchestratorEditorSearchDialog::_on_canceled)); } + else if (p_what == NOTIFICATION_READY) + { + if (_filters) + _filters->select(_get_default_filter()); + } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible()) @@ -467,9 +472,6 @@ void OrchestratorEditorSearchDialog::popup_create(bool p_dont_clear, bool p_repl { _search_items = _get_search_items(); - if (_filters) - _filters->select(0); - Ref initial_item = _get_search_item_by_name(p_current_type); String search_value = initial_item.is_valid() ? initial_item->text : p_current_type; @@ -632,5 +634,6 @@ void OrchestratorEditorSearchDialog::_on_item_selected() void OrchestratorEditorSearchDialog::_on_filter_selected(int p_index) { + _filter_type_changed(p_index); _update_search(); } \ No newline at end of file diff --git a/src/editor/search/search_dialog.h b/src/editor/search/search_dialog.h index 5dffc4a1..8eb451f8 100644 --- a/src/editor/search/search_dialog.h +++ b/src/editor/search/search_dialog.h @@ -124,6 +124,14 @@ class OrchestratorEditorSearchDialog : public ConfirmationDialog /// @return the possible filters virtual Vector _get_filters() const { return {}; } + /// Get the default filter choice, defaults to first item + /// @return the default filter choice + virtual int _get_default_filter() const { return 0; } + + /// Called when the user changes the filter type + /// @param p_index the selected item index + virtual void _filter_type_changed(int p_index) { } + /// Check whether the search item is to be filtered beyond the normal score calculation. /// @param p_item the search item /// @param p_text the search text diff --git a/src/editor/search/variable_classification_dialog.cpp b/src/editor/search/variable_classification_dialog.cpp index 56c18abf..8dcfedd7 100644 --- a/src/editor/search/variable_classification_dialog.cpp +++ b/src/editor/search/variable_classification_dialog.cpp @@ -21,6 +21,7 @@ #include "common/scene_utils.h" #include "common/string_utils.h" #include "common/variant_utils.h" +#include "plugin/plugin.h" #include #include @@ -383,6 +384,19 @@ bool OrchestratorVariableTypeSearchDialog::_is_filtered(const Ref& p return true; } +int OrchestratorVariableTypeSearchDialog::_get_default_filter() const +{ + Ref metadata = OrchestratorPlugin::get_singleton()->get_metadata(); + return metadata->get_value("variable_type_search", "filter", 0); +} + +void OrchestratorVariableTypeSearchDialog::_filter_type_changed(int p_index) +{ + Ref metadata = OrchestratorPlugin::get_singleton()->get_metadata(); + metadata->set_value("variable_type_search", "filter", p_index); + OrchestratorPlugin::get_singleton()->save_metadata(metadata); +} + String OrchestratorVariableTypeSearchDialog::get_selected_type() const { TreeItem* selected = _search_options->get_selected(); diff --git a/src/editor/search/variable_classification_dialog.h b/src/editor/search/variable_classification_dialog.h index f9ef276c..29a9b8f5 100644 --- a/src/editor/search/variable_classification_dialog.h +++ b/src/editor/search/variable_classification_dialog.h @@ -61,6 +61,8 @@ class OrchestratorVariableTypeSearchDialog : public OrchestratorEditorSearchDial void _save_favorite_items(const Vector>& p_favorites) override; Vector _get_filters() const override; bool _is_filtered(const Ref& p_item, const String& p_text) const override; + int _get_default_filter() const override; + void _filter_type_changed(int p_index) override; //~ End OrchestratorEditorSearchDialog Interface /// Creates the class hieararchy path, i.e. "Parent/Child/GrandChild"