class_name ItemSlot extends Control


@onready var item_sprite : TextureRect = $Item

var dragging : bool = false
var last_click : int = 0
var item : Item

signal display_item(itm)
func assign(itm : Item) -> void:
	item = itm
	if item.image != null:
		item_sprite.texture = item.image

func swap(item_slot : ItemSlot) -> void:
	var itm = item
	assign(itm)
	item_slot.assign(itm)

func update(itm : Item) -> void:
	if itm == null:
		clear()
	elif itm != item:
		assign(itm)

func clear() -> void:
	item = null
	item_sprite.texture = null

func _on_gui_input(event: InputEvent) -> void:
	var mmevt = event as InputEventMouseMotion
	var mbevt = event as InputEventMouseButton
	if mbevt != null:
		if mbevt.pressed and mbevt.button_index == MOUSE_BUTTON_LEFT and item != null:
			display_item.emit(item)
	#if mbevt and mbevt.button_index == MOUSE_BUTTON_MASK_LEFT:
		#if !mbevt.pressed:
			#if dragging and 
	#Press, drag, double click
	pass # Replace with function body.
