diff options
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 19 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 4 | ||||
-rw-r--r-- | scene/resources/resource_format_text.cpp | 9 |
3 files changed, 25 insertions, 7 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 28ac85457b..5742becf3a 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -910,7 +910,11 @@ void EditorAssetLibrary::_search(int p_page) { _api_request("asset", REQUESTING_SEARCH, args); } -void EditorAssetLibrary::_search_text_entered(const String &p_text) { +void EditorAssetLibrary::_search_text_changed(const String &p_text) { + filter_debounce_timer->start(); +} + +void EditorAssetLibrary::_filter_debounce_timer_timeout() { _search(); } @@ -1299,10 +1303,15 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { filter = memnew(LineEdit); search_hb->add_child(filter); filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); - filter->connect("text_entered", callable_mp(this, &EditorAssetLibrary::_search_text_entered)); - search = memnew(Button(TTR("Search"))); - search->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), make_binds(0)); - search_hb->add_child(search); + filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed)); + + // Perform a search automatically if the user hasn't entered any text for a certain duration. + // This way, the user doesn't need to press Enter to initiate their search. + filter_debounce_timer = memnew(Timer); + filter_debounce_timer->set_one_shot(true); + filter_debounce_timer->set_wait_time(0.25); + filter_debounce_timer->connect("timeout", callable_mp(this, &EditorAssetLibrary::_filter_debounce_timer_timeout)); + search_hb->add_child(filter_debounce_timer); if (!p_templates_only) { search_hb->add_child(memnew(VSeparator)); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 3fca8a1084..f7ad53f87b 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -183,10 +183,10 @@ class EditorAssetLibrary : public PanelContainer { Label *library_loading; Label *library_error; LineEdit *filter; + Timer *filter_debounce_timer; OptionButton *categories; OptionButton *repository; OptionButton *sort; - Button *search; HBoxContainer *error_hb; TextureRect *error_tr; Label *error_label; @@ -280,10 +280,12 @@ class EditorAssetLibrary : public PanelContainer { void _search(int p_page = 0); void _rerun_search(int p_ignore); + void _search_text_changed(const String &p_text = ""); void _search_text_entered(const String &p_text = ""); void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = ""); void _http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data); void _http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data); + void _filter_debounce_timer_timeout(); void _repository_changed(int p_repository_id); void _support_toggled(int p_support); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index d4d8018d43..ba39593690 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1763,6 +1763,10 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r } for (int i = 0; i < state->get_connection_count(); i++) { + if (i == 0) { + f->store_line(""); + } + String connstr = "[connection"; connstr += " signal=\"" + String(state->get_connection_signal(i)) + "\""; connstr += " from=\"" + String(state->get_connection_source(i).simplified()) + "\""; @@ -1786,7 +1790,10 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r Vector<NodePath> editable_instances = state->get_editable_instances(); for (int i = 0; i < editable_instances.size(); i++) { - f->store_line("\n[editable path=\"" + editable_instances[i].operator String() + "\"]"); + if (i == 0) { + f->store_line(""); + } + f->store_line("[editable path=\"" + editable_instances[i].operator String() + "\"]"); } } |