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

54 lines
1.6 KiB
GDScript3
Raw Permalink Normal View History

2021-04-23 23:25:32 +02:00
extends MarginContainer
export(String) var gauge_name := ""
export(Color) var gauge_color := Color.white
export(String, MULTILINE) var description_bad: = ""
export(String, MULTILINE) var description_neutral := ""
export(String, MULTILINE) var description_good := ""
var DESCRIPTION_THRESHOLDS = [40, 60]
2021-04-23 23:25:32 +02:00
var progress : float = 0 setget set_progress
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 progress_bar = $VBoxContainer/ProgressBar
onready var label = $VBoxContainer/Label
2021-04-24 22:42:12 +02:00
func _ready():
2021-04-23 23:25:32 +02:00
container.hide()
2021-04-24 22:42:12 +02:00
hover_control.selection_object = progress_bar
hover_control.infobox_position = "left"
hover_control.info_panel.title = gauge_name
hover_control.info_panel.content = ""
2021-04-23 23:25:32 +02:00
label.text = gauge_name
progress_bar.tint_progress = gauge_color
container.modulate = Color(1, 1, 1, 0)
func start_anim():
tween.start()
container.show()
func _set_description():
if progress < DESCRIPTION_THRESHOLDS[0]:
hover_control.info_panel.content = description_bad
elif progress > DESCRIPTION_THRESHOLDS[1]:
hover_control.info_panel.content = description_good
else:
hover_control.info_panel.content = description_neutral
2021-04-23 23:25:32 +02:00
func set_progress(new_value: float):
2021-04-24 22:42:12 +02:00
progress = new_value
_set_description()
# hover_control.info_panel.content = variable_descriptions[]
2021-04-23 23:25:32 +02:00
tween.interpolate_property(progress_bar, "value", 0, progress, 1.5, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
tween.interpolate_property(container, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), 1, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
start_anim()