challenge-editor/scene/basic_mes_item_drop_data.gd

45 lines
1.0 KiB
GDScript3
Raw Normal View History

2024-09-28 12:04:15 +08:00
extends Label
2024-09-28 18:46:15 +08:00
signal fresh
2024-09-28 12:04:15 +08:00
@export var type:int=0
@export var texture:TextureRect
2024-09-29 11:46:15 +08:00
var is_mouse_enter:bool=false
2024-09-28 18:46:15 +08:00
var item_data
#当前使用的页面
var page:int=0
@export var index:int=0
2024-09-28 12:04:15 +08:00
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:
2024-09-28 18:46:15 +08:00
Global.replace_equip_with_data(page,index,data)
Global.decrease_item_num_index(data["ind"])
2024-09-28 12:04:15 +08:00
item_data=data
2024-09-28 18:46:15 +08:00
fresh.emit()
2024-09-28 12:04:15 +08:00
2024-09-28 18:46:15 +08:00
func set_data(_data):
if _data==null:
texture.texture=null
item_data=null
return
item_data=_data
2024-10-04 18:08:33 +08:00
texture.texture=Database.get_texture(_data["texture"])
2024-09-29 11:46:15 +08:00
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:
2024-10-04 18:08:33 +08:00
#print("xxx")
2024-09-29 11:46:15 +08:00
Global.replace_equip_with_data(page,index,null)
fresh.emit()