Skip to content

Commit

Permalink
fix: do not list tags used for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
OctoD committed Jan 12, 2024
1 parent 6b42b98 commit 0650762
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/editor_plugin/docks/tag/tag_docks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <godot_cpp/classes/v_box_container.hpp>

#include "tag_docks.h"
#include "system/attribute/attribute_manager.h"
#include "system/tag/tag_tree.h"
#include "system/tag/tag_manager.h"

Expand Down Expand Up @@ -53,8 +54,10 @@ void GGSTagDocks::render()

TypedArray<Node> 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++)
{
Expand Down Expand Up @@ -107,7 +110,7 @@ void GGSTagDocks::_on_selection_changed()
void GGSTagDocks::_set_tags_selected(PackedStringArray p_tags, bool selected)
{
TypedArray<Node> 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++)
{
Expand Down
25 changes: 25 additions & 0 deletions src/system/tag/tag_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/system/tag/tag_dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0650762

Please sign in to comment.