Make decor occupy individual inventory slots

This commit is contained in:
Alexander Sellite 2026-09-01 17:29:57 -04:00
parent f2239d248a
commit 4196cda1d5
9 changed files with 516 additions and 79 deletions

View file

@ -59,13 +59,13 @@ func setup(
item_catalog,
PlayerInventoryLayout.InventoryContainer.STORAGE,
)
_inventory_grid.entry_selected.connect(
_on_entry_selected.bind(
_inventory_grid.slot_activated.connect(
_on_slot_activated.bind(
PlayerInventoryLayout.InventoryContainer.STORAGE
)
)
_storage_grid.entry_selected.connect(
_on_entry_selected.bind(
_storage_grid.slot_activated.connect(
_on_slot_activated.bind(
PlayerInventoryLayout.InventoryContainer.INVENTORY
)
)
@ -170,20 +170,24 @@ func consume_escape() -> bool:
func _unhandled_input(event: InputEvent) -> void:
if not visible or not event.is_action_pressed("ui_cancel"):
if not visible:
return
var close_requested: bool = event.is_action_pressed("ui_cancel") or (
_home_access and event.is_action_pressed("interact")
)
if not close_requested or (event is InputEventKey and event.echo):
return
close_storage()
get_viewport().set_input_as_handled()
func _on_entry_selected(
kind: int,
identity: StringName,
func _on_slot_activated(
slot: GeneralInventorySlot,
target_container: int,
) -> void:
if kind < 0 or identity.is_empty() or _layout == null:
if slot == null or slot.entry_key.is_empty() or _layout == null:
return
if _layout.move_entry_to_first_free(kind, identity, target_container):
if _layout.move_entry_key_to_first_free(slot.entry_key, target_container):
_feedback.text = (
"moved to storage"
if target_container == PlayerInventoryLayout.InventoryContainer.STORAGE