extends Control

@onready var time_label: Label = $TimeLabel
@onready var faster = $faster
@onready var slower = $slower
@onready var pause = $pause

func _ready():
	faster.pressed.connect(_on_faster_pressed)
	slower.pressed.connect(_on_slower_pressed)
	pause.pressed.connect(_on_pause_pressed)
	#$MenuButton.pressed.connect(_on_menu_button_pressed)
	
func _process(delta):
	var total_days = int(GameData.game_time)
	var numer_roku = 2980 + total_days / 365
	var day_of_year = total_days % 365
	var dzien_cykliczny: int
	
	if day_of_year == 0:
		dzien_cykliczny = 0
		if total_days > 0:
			numer_roku -= 1
	else:
		dzien_cykliczny = day_of_year
	var full_date = tr("time_display") + ": " + str(numer_roku) + "." + str(dzien_cykliczny)
	time_label.text = full_date

func _on_faster_pressed():
	if Engine.time_scale < 20:
		Engine.time_scale +=1
func _on_slower_pressed():
	if Engine.time_scale > 0:
		Engine.time_scale -=1
func _on_pause_pressed():
	Engine.time_scale = 0
	
#func _on_menu_button_pressed():
	#get_tree().change_scene_to_file("res://scenes/menu.tscn")
