pir-serious-game-ethics/scenes/end-screen/ChoiceCircle.gd

57 lines
1.7 KiB
GDScript3
Raw Permalink Normal View History

2021-04-23 23:25:32 +02:00
extends Control
2021-04-29 15:25:21 +02:00
export(Texture) var texture
2021-04-23 23:25:32 +02:00
export(String) var dilemma_name = ""
export(Array, String) var choices_names = []
export(Array, String, MULTILINE) var choices_descriptions = []
var choice : int = 0 setget set_choice
2021-04-26 17:41:28 +02:00
export(float) var info_panel_height := 500.0
2021-04-23 23:25:32 +02:00
onready var tween = $Tween
2021-04-24 22:42:12 +02:00
onready var hover_control = $HoverControl
2021-04-23 23:25:32 +02:00
onready var container = $VBoxContainer
onready var choice_label = $VBoxContainer/ChoiceLabel
onready var dilemma_label = $VBoxContainer/DilemmaLabel
2021-04-29 15:25:21 +02:00
onready var texture_rect = $VBoxContainer/TextureRect
2021-04-23 23:25:32 +02:00
func _ready():
container.hide()
dilemma_label.text = dilemma_name
choice_label.text = ""
2021-04-29 15:25:21 +02:00
texture_rect.texture = texture
hover_control.selection_object = texture_rect
2021-04-24 22:42:12 +02:00
hover_control.infobox_position = "top"
hover_control.info_panel.title = ""
hover_control.info_panel.content = ""
2021-04-26 17:41:28 +02:00
hover_control.info_panel_height = info_panel_height
2021-04-23 23:25:32 +02:00
func start_anim():
tween.interpolate_property(container, "rect_scale", Vector2(0, 0), Vector2(1, 1), 1, Tween.TRANS_ELASTIC, Tween.EASE_IN_OUT)
tween.interpolate_property(container, "rect_position", Vector2(75, 75), Vector2(0, 0), 1, Tween.TRANS_ELASTIC, Tween.EASE_IN_OUT)
2021-04-23 23:25:32 +02:00
container.rect_scale = Vector2(0, 0)
container.rect_position = Vector2(75, 75)
container.show()
tween.start()
2021-04-24 22:42:12 +02:00
func _set_description():
if choice < choices_names.size() and choice < choices_descriptions.size():
hover_control.info_panel.title = choices_names[choice]
hover_control.info_panel.content = choices_descriptions[choice]
choice_label.text = choices_names[choice]
else:
hover_control.info_panel.title = ""
hover_control.info_panel.content = ""
choice_label.text = ""
2021-04-23 23:25:32 +02:00
func set_choice(new_value: int):
choice = new_value
_set_description()
start_anim()