extends Control

@onready var label_player_name = $HBoxContainer/PlayerName
#@onready var label_science = $HBoxContainer/LabelScience
@onready var ResLabel = $HBoxContainer/ResLabel
@onready var label_water = $HBoxContainer/WaterLabel
@onready var label_copper = $HBoxContainer/CopperLabel
@onready var label_since = $HBoxContainer/SinceLabel
#@onready var label_population = $HBoxContainer/LabelPopulation

func update_info():
	
	label_player_name.text = "Gracz: %s" % PlayerData.PlayerName
#label_science.text = "🔬 Nauka: %s" % player.science

	var text = ""
	
	for res_name in PlayerData.resources.keys():
		var amount = PlayerData.resources[res_name]
		# Pomiń surowce zerowe jeśli chcesz
		if amount == 0:
			continue
		text += "%s: %.2f  " % [tr(res_name.capitalize()), amount]
	
	# Dodaj też since_doc
	text += "\n%s: %.2f" % [tr("since"), PlayerData.since_doc]

	# Przypisz do jednego labelka
	ResLabel.text = text

	
	#label_population.text = "👥 Populacja: %s" % GameData.format_number(player.total_population)

func _ready():
	PlayerData.connect("stats_changed", Callable(self, "update_info"))
	update_info()

func _on_stats_changed():
	update_info()
