diff --git a/addons/inventory-system/editor/items/inventory_item_list.gd b/addons/inventory-system/editor/items/inventory_item_list.gd index 93e56b1d..8483514c 100644 --- a/addons/inventory-system/editor/items/inventory_item_list.gd +++ b/addons/inventory-system/editor/items/inventory_item_list.gd @@ -7,7 +7,6 @@ signal item_popup_menu_requested(at_position: Vector2) @onready var list : ItemList = %ItemList @onready var search_line_edit = $Control/SearchLineEdit -@onready var search_by_categories_button = $ItemListTools/SearchByCategoriesButton var item_map : Dictionary = {} var database : InventoryDatabase @@ -89,15 +88,14 @@ func apply_filter() -> void: var item = item_map[item_id] if item == null: continue - - if not search_by_categories_button.button_pressed: # search by item names - if filter == "" or item == null or filter.to_lower() in item.name.to_lower(): - item_list_handler.append(item) - elif search_by_categories_button.button_pressed: # search by category name + + if filter == "" or item == null or filter.to_lower() in item.name.to_lower(): # search by item name + item_list_handler.append(item) + + if item not in item_list_handler: # search by category name for item_category in item.categories: - if filter == "" or item == null or filter.to_lower() in item_category.name.to_lower(): - if item not in item_list_handler: - item_list_handler.append(item) + if item not in item_list_handler and filter.to_lower() in item_category.name.to_lower(): + item_list_handler.append(item) update_item_list(item_list_handler) @@ -120,6 +118,3 @@ func _on_item_list_item_clicked(index, at_position, mouse_button_index): func _on_search_line_edit_text_changed(new_text): filter = new_text - -func _on_search_by_categories_button_toggled(button_pressed): - filter = search_line_edit.text diff --git a/addons/inventory-system/editor/items/inventory_item_list.tscn b/addons/inventory-system/editor/items/inventory_item_list.tscn index 80a2a993..3bd9721f 100644 --- a/addons/inventory-system/editor/items/inventory_item_list.tscn +++ b/addons/inventory-system/editor/items/inventory_item_list.tscn @@ -6,17 +6,10 @@ clip_contents = true custom_minimum_size = Vector2(256, 0) offset_right = 256.0 -offset_bottom = 40.0 +offset_bottom = 36.0 alignment = 1 script = ExtResource("1_6fmx0") -[node name="ItemListTools" type="HBoxContainer" parent="."] -layout_mode = 2 - -[node name="SearchByCategoriesButton" type="CheckButton" parent="ItemListTools"] -layout_mode = 2 -text = "Search by Categories" - [node name="Control" type="Control" parent="."] custom_minimum_size = Vector2(0, 32) layout_mode = 2 @@ -56,7 +49,5 @@ layout_mode = 2 size_flags_vertical = 3 fixed_icon_size = Vector2i(16, 16) -[connection signal="button_up" from="ItemListTools/SearchByCategoriesButton" to="." method="_on_search_by_categories_button_button_up"] -[connection signal="toggled" from="ItemListTools/SearchByCategoriesButton" to="." method="_on_search_by_categories_button_toggled"] [connection signal="text_changed" from="Control/SearchLineEdit" to="." method="_on_search_line_edit_text_changed"] [connection signal="item_clicked" from="ItemList" to="." method="_on_item_list_item_clicked"]