extends MarginContainer

export(String) var gauge_name = ""
export(String) var gauge_description = ""
export(Color) var gauge_color = Color.white

var progress : float = 0 setget set_progress

onready var tween = $Tween
onready var hover_control = $HoverControl
onready var container = $VBoxContainer
onready var progress_bar = $VBoxContainer/ProgressBar
onready var label = $VBoxContainer/Label


func _ready():
	container.hide()
	hover_control.selection_object = progress_bar
	hover_control.infobox_position = "left"
	hover_control.info_panel.title = gauge_name
	hover_control.info_panel.content = gauge_description
	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_progress(new_value: float):
	progress = new_value
	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()
