basic inventory system ready
This commit is contained in:
parent
3f22eeaf9d
commit
aee93b8d10
20 changed files with 513 additions and 16 deletions
41
inv_system/item_slot.gd
Normal file
41
inv_system/item_slot.gd
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
extends Panel
|
||||
|
||||
@export var icon : TextureRect
|
||||
@export var item: ItemData
|
||||
|
||||
func _ready() -> void:
|
||||
update_ui()
|
||||
|
||||
func update_ui():
|
||||
if not item:
|
||||
icon.texture = null
|
||||
return
|
||||
|
||||
icon.texture = item.icon
|
||||
tooltip_text = item.item_name
|
||||
|
||||
func _get_drag_data(at_position: Vector2) -> Variant:
|
||||
if not item:
|
||||
return
|
||||
|
||||
var preview = duplicate()
|
||||
var c = Control.new()
|
||||
c.add_child(preview)
|
||||
preview.position -= Vector2(32,32)
|
||||
preview.self_modulate = Color.TRANSPARENT
|
||||
c.modulate = Color(c.modulate,0.5)
|
||||
set_drag_preview(c)
|
||||
icon.hide()
|
||||
return self
|
||||
|
||||
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
|
||||
return true
|
||||
|
||||
func _drop_data(at_position: Vector2, data: Variant) -> void:
|
||||
var temp = item
|
||||
item = data.item
|
||||
data.item = temp
|
||||
icon.show()
|
||||
data.icon.show()
|
||||
update_ui()
|
||||
data.update_ui()
|
||||
Loading…
Add table
Add a link
Reference in a new issue