Make decor occupy individual inventory slots
This commit is contained in:
parent
f2239d248a
commit
4196cda1d5
9 changed files with 516 additions and 79 deletions
|
|
@ -21,6 +21,7 @@ var slot_index: int = -1
|
|||
var container: int = -1
|
||||
var entry_kind: int = -1
|
||||
var entry_identity: StringName
|
||||
var entry_key: String = ""
|
||||
var _locked: bool = false
|
||||
|
||||
var _layout: PlayerInventoryLayout
|
||||
|
|
@ -107,6 +108,7 @@ func refresh() -> void:
|
|||
call_deferred("_update_context_presence")
|
||||
entry_kind = -1
|
||||
entry_identity = StringName()
|
||||
entry_key = ""
|
||||
_context_text = ""
|
||||
_quality_tier = -1
|
||||
_icon.texture = null
|
||||
|
|
@ -142,6 +144,7 @@ func refresh() -> void:
|
|||
return
|
||||
entry_kind = int(entry.get("kind", -1))
|
||||
entry_identity = StringName(str(entry.get("identity", "")))
|
||||
entry_key = str(entry.get("key", ""))
|
||||
if entry_kind == PlayerInventoryLayout.EntryKind.ITEM:
|
||||
var item: ItemDataType = (
|
||||
_item_catalog.get_item_by_id(entry_identity)
|
||||
|
|
@ -150,7 +153,11 @@ func refresh() -> void:
|
|||
if item == null:
|
||||
return
|
||||
_icon.texture = item.icon
|
||||
var quantity := _bag.get_quantity(entry_identity) if _bag != null else 0
|
||||
var quantity := (
|
||||
1
|
||||
if int(entry.get("unit", -1)) >= 0
|
||||
else _bag.get_quantity(entry_identity) if _bag != null else 0
|
||||
)
|
||||
_quantity.text = "×%d" % quantity if quantity > 1 else ""
|
||||
_context_text = _item_context_text(item, quantity)
|
||||
accessibility_name = "%s, slot %d" % [item.display_name, slot_index + 1]
|
||||
|
|
@ -273,6 +280,7 @@ func _get_drag_data(_at_position: Vector2) -> Variant:
|
|||
return {
|
||||
"kind": "bag_item",
|
||||
"item_id": String(entry_identity),
|
||||
"entry_key": entry_key,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -310,7 +318,12 @@ func _drop_data(_at_position: Vector2, data: Variant) -> void:
|
|||
"",
|
||||
)
|
||||
))
|
||||
moved = _layout.move_entry(kind, identity, container, slot_index)
|
||||
var source_key: String = str(payload.get("entry_key", ""))
|
||||
moved = (
|
||||
_layout.move_entry_by_key(source_key, container, slot_index)
|
||||
if not source_key.is_empty()
|
||||
else _layout.move_entry(kind, identity, container, slot_index)
|
||||
)
|
||||
if moved:
|
||||
entry_moved.emit()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue