45 lines
1.0 KiB
GDScript
45 lines
1.0 KiB
GDScript
extends Label
|
|
|
|
|
|
signal fresh
|
|
@export var type:int=0
|
|
@export var texture:TextureRect
|
|
var is_mouse_enter:bool=false
|
|
var item_data
|
|
#当前使用的页面
|
|
var page:int=0
|
|
@export var index:int=0
|
|
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
|
|
if data.has("type") and data["type"]==type:
|
|
return true
|
|
else:
|
|
return false
|
|
func _drop_data(at_position: Vector2, data: Variant) -> void:
|
|
Global.replace_equip_with_data(page,index,data)
|
|
Global.decrease_item_num_index(data["ind"])
|
|
item_data=data
|
|
fresh.emit()
|
|
|
|
func set_data(_data):
|
|
if _data==null:
|
|
texture.texture=null
|
|
item_data=null
|
|
return
|
|
item_data=_data
|
|
texture.texture=Database.get_texture(_data["texture"])
|
|
func _on_mouse_entered():
|
|
is_mouse_enter=true
|
|
|
|
pass
|
|
func _on_mouse_exit():
|
|
is_mouse_enter=false
|
|
func _ready() -> void:
|
|
mouse_entered.connect(_on_mouse_entered)
|
|
mouse_exited.connect(_on_mouse_exit)
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("mouse_left") and is_mouse_enter:
|
|
#print("xxx")
|
|
Global.replace_equip_with_data(page,index,null)
|
|
fresh.emit()
|