fix inventory 10 per row bug

This commit is contained in:
2026-01-20 00:50:16 +01:00
parent e88da9a169
commit e44eeb6dea

View File

@@ -620,7 +620,8 @@ func _update_selection_from_navigation():
var row = inventory_rows_list[inventory_selection_row] var row = inventory_rows_list[inventory_selection_row]
print("InventoryUI: Checking item selection - row: ", inventory_selection_row, " col: ", inventory_selection_col, " row exists: ", row != null, " row child count: ", row.get_child_count() if row else 0) print("InventoryUI: Checking item selection - row: ", inventory_selection_row, " col: ", inventory_selection_col, " row exists: ", row != null, " row child count: ", row.get_child_count() if row else 0)
if row and inventory_selection_col >= 0 and inventory_selection_col < row.get_child_count(): if row and inventory_selection_col >= 0 and inventory_selection_col < row.get_child_count():
var item_index = inventory_selection_row * 10 + inventory_selection_col var items_per_row = 8 # Must match the items_per_row used when building rows
var item_index = inventory_selection_row * items_per_row + inventory_selection_col
print("InventoryUI: Calculated item_index: ", item_index, " inventory_items_list.size(): ", inventory_items_list.size()) print("InventoryUI: Calculated item_index: ", item_index, " inventory_items_list.size(): ", inventory_items_list.size())
if item_index >= 0 and item_index < inventory_items_list.size(): if item_index >= 0 and item_index < inventory_items_list.size():
selected_item = inventory_items_list[item_index] selected_item = inventory_items_list[item_index]