diff --git a/src/editor_plugin/docks/tag/tag_docks.cpp b/src/editor_plugin/docks/tag/tag_docks.cpp index 143b278..df8c879 100644 --- a/src/editor_plugin/docks/tag/tag_docks.cpp +++ b/src/editor_plugin/docks/tag/tag_docks.cpp @@ -5,6 +5,7 @@ #include #include "tag_docks.h" +#include "system/attribute/attribute_manager.h" #include "system/tag/tag_tree.h" #include "system/tag/tag_manager.h" @@ -53,8 +54,10 @@ void GGSTagDocks::render() TypedArray selected_nodes = EditorInterface::get_singleton()->get_selection()->get_selected_nodes(); TagDictionary *all_tags = memnew(TagDictionary); + AttributeManager *attribute_manager = AttributeManager::get_singleton(); all_tags->from_many(TagManager::get_singleton()->dictionaries); + all_tags->remove_tags(attribute_manager->get_attributes()); for (int i = 0; i < selected_nodes.size(); i++) { @@ -107,7 +110,7 @@ void GGSTagDocks::_on_selection_changed() void GGSTagDocks::_set_tags_selected(PackedStringArray p_tags, bool selected) { TypedArray selected_nodes = EditorInterface::get_singleton()->get_selection()->get_selected_nodes(); - EditorInterface* editor_interface = EditorInterface::get_singleton(); + EditorInterface *editor_interface = EditorInterface::get_singleton(); for (int i = 0; i < selected_nodes.size(); i++) { diff --git a/src/system/tag/tag_dictionary.cpp b/src/system/tag/tag_dictionary.cpp index fd5460c..189aba0 100644 --- a/src/system/tag/tag_dictionary.cpp +++ b/src/system/tag/tag_dictionary.cpp @@ -15,7 +15,9 @@ void TagDictionary::_bind_methods() ClassDB::bind_method(D_METHOD("get_tags"), &TagDictionary::get_tags); ClassDB::bind_method(D_METHOD("has_tag_path", "tag_path"), &TagDictionary::has_tag_path); ClassDB::bind_method(D_METHOD("has_tag", "tag"), &TagDictionary::has_tag); + ClassDB::bind_method(D_METHOD("remove_tag_path", "tag_path"), &TagDictionary::remove_tag_path); ClassDB::bind_method(D_METHOD("remove_tag", "tag"), &TagDictionary::remove_tag); + ClassDB::bind_method(D_METHOD("remove_tags", "tags"), &TagDictionary::remove_tags); ClassDB::bind_method(D_METHOD("replace_tag_at_index", "index", "tag"), &TagDictionary::replace_tag_at_index); ClassDB::bind_method(D_METHOD("replace_tag", "old_tag", "new_tag"), &TagDictionary::replace_tag); ClassDB::bind_method(D_METHOD("set_tags", "tags"), &TagDictionary::set_tags); @@ -224,6 +226,29 @@ void TagDictionary::remove_tag(const StringName &tag) } } +void TagDictionary::remove_tags(const PackedStringArray &p_tags) +{ + PackedStringArray removed_tags = PackedStringArray(); + PackedStringArray copy = PackedStringArray(tags); + + for (StringName tag : p_tags) + { + int index = tags.find(tag); + + if (index >= 0) + { + tags.remove_at(index); + removed_tags.push_back(tag); + } + } + + if (removed_tags.size() > 0) + { + emit_signal("tags_removed", removed_tags, copy); + emit_changed(); + } +} + void TagDictionary::remove_tag_path(const StringName &tag_path) { PackedStringArray copy = PackedStringArray(tags); diff --git a/src/system/tag/tag_dictionary.h b/src/system/tag/tag_dictionary.h index dc57669..f77bf25 100644 --- a/src/system/tag/tag_dictionary.h +++ b/src/system/tag/tag_dictionary.h @@ -73,6 +73,9 @@ namespace ggs /// @brief Removes a tag from the tag dictionary. /// @param tag The tag to remove. void remove_tag(const StringName &tag); + /// @brief Removes as many tags as possible from the tag dictionary. + /// @param p_tags The tags to remove. + void remove_tags(const PackedStringArray &p_tags); /// @brief Removes all tags which include the tag path. /// @param tag_path The tag path to remove. void remove_tag_path(const StringName &tag_path);