Files
autgame/games/juggling_gym/scripts/gym_tool.gd
T

40 lines
1.2 KiB
GDScript

class_name GymTool
extends Button
## Area interattiva trasparente sopra un attrezzo della barra P3B.
var tool_id := ""
var tool_texture: Texture2D
var available := true
func configure(id: String, texture: Texture2D, is_available: bool) -> void:
tool_id = id
tool_texture = texture
available = is_available
disabled = not available
mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND if available else Control.CURSOR_ARROW
func _ready() -> void:
flat = true
focus_mode = Control.FOCUS_NONE
mouse_filter = Control.MOUSE_FILTER_STOP
# L'attrezzo è già disegnato nel mockup: questo Button resta invisibile.
modulate.a = 0.01
func _get_drag_data(_at_position: Vector2) -> Variant:
if not available or tool_texture == null:
return null
var preview := TextureRect.new()
preview.texture = tool_texture
preview.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
preview.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
preview.custom_minimum_size = Vector2(180.0, 120.0)
preview.size = Vector2(180.0, 120.0)
preview.mouse_filter = Control.MOUSE_FILTER_IGNORE
preview.modulate = Color(1.0, 1.0, 1.0, 0.92)
set_drag_preview(preview)
return {"tool_id": tool_id}