extends TextureRect signal clicked @export var key: String = "production" @export var text: String = "Resource" @export var width: float = 66 @onready var rich_text_label: RichTextLabel = $RichTextLabel @onready var collision_shape_2d: CollisionShape2D = $MouseHandler/CollisionShape2D var text_tween func _ready() -> void: rich_text_label.text = "[center]%s" % [text] custom_minimum_size.x = width collision_shape_2d.shape = RectangleShape2D.new() collision_shape_2d.shape.size = Vector2(width - 20, 10) collision_shape_2d.position.x = 33 - ((66 - width) / 2) func _on_mouse_handler_clicked() -> void: clicked.emit() if text_tween: text_tween.kill() text_tween = create_tween() text_tween.set_ease(Tween.EASE_OUT) text_tween.set_trans(Tween.TRANS_BACK) text_tween.tween_property(rich_text_label, "scale", Vector2.ONE * 0.95, 0.25) text_tween.set_trans(Tween.TRANS_QUAD) text_tween.tween_property(rich_text_label, "scale", Vector2.ONE, 0.05) func select(): rich_text_label.self_modulate = Color(1, 1, 1, 1) self_modulate = Color(1, 1, 1, 0.784) func unselect(): rich_text_label.self_modulate = Color(1, 1, 1, 0.4) self_modulate = Color(1, 1, 1, 0.4) func _on_mouse_handler_hovered() -> void: if text_tween: text_tween.kill() text_tween = create_tween() text_tween.set_ease(Tween.EASE_OUT) text_tween.set_trans(Tween.TRANS_BACK) text_tween.tween_property(rich_text_label, "scale", Vector2.ONE * 1.02, 0.25) func _on_mouse_handler_unhovered() -> void: if text_tween: text_tween.kill() text_tween = create_tween() text_tween.set_ease(Tween.EASE_OUT) text_tween.set_trans(Tween.TRANS_QUAD) text_tween.tween_property(rich_text_label, "scale", Vector2.ONE, 0.05)