challenge-editor/scene/bag_side_card.gd

57 lines
1.6 KiB
GDScript3
Raw Permalink Normal View History

2024-09-19 17:56:05 +08:00
extends TextureRect
2024-09-29 11:46:15 +08:00
2024-09-28 18:46:15 +08:00
class_name BagSideCard
2024-09-29 11:46:15 +08:00
const BAG_SIDE_CARD_INTRODUCTION = preload("res://scene/bag_side_card_introduction.tscn")
2024-09-19 17:56:05 +08:00
var is_mouse_enter:bool=false
2024-09-28 18:46:15 +08:00
var equip_index:int=0
2024-09-19 17:56:05 +08:00
signal click(data:Dictionary)
var data:Dictionary={
2024-09-27 17:51:20 +08:00
"texture":"test_character_tsubaki"
2024-09-19 17:56:05 +08:00
}
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _input(event: InputEvent) -> void:
if event.is_action_pressed("mouse_left") and is_mouse_enter:
click.emit(data)
func _get_drag_data(at_position: Vector2) -> Variant:
var texture_rect=TextureRect.new()
2024-10-04 18:08:33 +08:00
texture_rect.texture=Database.get_texture(data["texture"])
2024-09-28 18:46:15 +08:00
texture_rect.expand_mode=TextureRect.EXPAND_IGNORE_SIZE
texture_rect.stretch_mode=TextureRect.STRETCH_KEEP_ASPECT_CENTERED
texture_rect.size=self.size
2024-09-19 17:56:05 +08:00
set_drag_preview(texture_rect)
2024-09-28 18:46:15 +08:00
var new_data=data.duplicate(true)
new_data["ind"]=equip_index
return new_data
func set_data(_data:Dictionary):
data=_data
2024-10-04 18:08:33 +08:00
%face.texture=Database.get_texture(data["texture"])
2024-09-28 18:46:15 +08:00
pass
2024-09-19 17:56:05 +08:00
func _on_mouse_entered() -> void:
is_mouse_enter=true
2024-09-28 18:46:15 +08:00
click.emit(data)
2024-09-19 17:56:05 +08:00
pass # Replace with function body.
func _on_mouse_exited() -> void:
is_mouse_enter=false
pass # Replace with function body.
2024-09-29 11:46:15 +08:00
func _get_tooltip(at_position: Vector2) -> String:
return JSON.stringify(data)
pass
func _make_custom_tooltip(for_text: String) -> Object:
var new_card=BAG_SIDE_CARD_INTRODUCTION.instantiate()
new_card.data=JSON.parse_string(for_text)
return new_card
pass