extends MarginContainer

export var auto_sleep :float = 60*2
export var prevent_sleep := false setget set_prevent_sleep
#export var auto_sleep :float = 6

onready var sleep_timer = $sleep_timer


func _ready():
	sleep_timer.start(auto_sleep)

func set_prevent_sleep(new:bool):
	if new or Config.flags.prevent_sleep_mode:
		hide()
		sleep_timer.stop()
	else:
		sleep_timer.start(auto_sleep)
	prevent_sleep = new

func _input(event):
	if not visible and not (prevent_sleep or Config.flags.prevent_sleep_mode):
		sleep_timer.start(auto_sleep)

func _on_sleep_timer_timeout():
	if !prevent_sleep and !Config.flags.prevent_sleep_mode:
		show()

func minute_timer_update(time):
	$"%time".text = '{0}:{1}'.format([str(time['hour']).pad_zeros(2), str(time['minute']).pad_zeros(2)])
