Skip to content

Commit

Permalink
Merge branch 'main' into addon
Browse files Browse the repository at this point in the history
# Conflicts:
#	plugin.cfg
  • Loading branch information
scriptsengineer committed Sep 18, 2023
2 parents 5706195 + 5204600 commit 68ee966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
19 changes: 7 additions & 12 deletions addons/inventory-system/editor/items/inventory_item_list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
11 changes: 1 addition & 10 deletions addons/inventory-system/editor/items/inventory_item_list.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit 68ee966

Please sign in to comment.