2024-09-12 02:04:24 +00:00
|
|
|
extends Control
|
|
|
|
|
2024-09-14 00:09:38 +00:00
|
|
|
var window_tween
|
|
|
|
|
2024-09-14 01:02:26 +00:00
|
|
|
@onready var icon: TextureRect = $Icon
|
|
|
|
@onready var title: RichTextLabel = $Title
|
|
|
|
@onready var subtitle: RichTextLabel = $Subtitle
|
|
|
|
@onready var description: RichTextLabel = $Description
|
|
|
|
|
2024-09-12 02:04:24 +00:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2024-09-14 00:09:38 +00:00
|
|
|
Triggerer.listen("show_info", _show_info_window)
|
|
|
|
Triggerer.listen("hide_info", _hide_info_window)
|
2024-09-14 00:20:51 +00:00
|
|
|
scale = Vector2.ZERO
|
2024-09-14 00:09:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _show_info_window(data):
|
|
|
|
visible = true
|
|
|
|
|
2024-09-14 22:01:46 +00:00
|
|
|
var building_data = Data.data.buildings[data.key]
|
2024-09-14 01:02:26 +00:00
|
|
|
|
|
|
|
|
2024-09-14 00:09:38 +00:00
|
|
|
if window_tween:
|
|
|
|
window_tween.kill()
|
|
|
|
|
|
|
|
window_tween = create_tween()
|
2024-09-14 01:02:26 +00:00
|
|
|
window_tween.set_ease(Tween.EASE_IN)
|
|
|
|
window_tween.set_trans(Tween.TRANS_QUAD)
|
|
|
|
window_tween.tween_property(self, "scale", Vector2.ZERO, 0.25)
|
|
|
|
window_tween.tween_callback(func():
|
|
|
|
title.text = "[center]%s" % [building_data.name]
|
|
|
|
)
|
2024-09-14 00:09:38 +00:00
|
|
|
window_tween.set_ease(Tween.EASE_OUT)
|
|
|
|
window_tween.set_trans(Tween.TRANS_BACK)
|
2024-09-14 00:20:51 +00:00
|
|
|
window_tween.tween_property(self, "scale", Vector2.ONE, 0.5)
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
if Input.is_action_just_pressed("rclick"):
|
|
|
|
_hide_info_window({})
|
2024-09-12 02:04:24 +00:00
|
|
|
|
|
|
|
|
2024-09-14 00:09:38 +00:00
|
|
|
func _hide_info_window(_data):
|
|
|
|
if window_tween:
|
|
|
|
window_tween.kill()
|
|
|
|
|
|
|
|
window_tween = create_tween()
|
2024-09-14 00:20:51 +00:00
|
|
|
window_tween.set_ease(Tween.EASE_IN)
|
|
|
|
window_tween.set_trans(Tween.TRANS_QUAD)
|
|
|
|
window_tween.tween_property(self, "scale", Vector2.ZERO, 0.25)
|