# Hurry Curry! - a game about cooking
# Copyright (C) 2025 Hurry Curry! contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
extends Menu

@onready var table: GridContainer = $OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/Table
@onready var title: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/Title
@onready var play_count: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/PlayCount

@export var font: Font

func _ready() -> void:
	super()
	var i = 1
	title.text = tr("c.menu.scoreboard.title").format([data.map])
	play_count.text = tr("c.menu.scoreboard.finish_count").format([int(data.plays)])
	for entry in data.best:
		push_label("%d." % i)
		push_label("%d" % entry.score.points)
		push_label(", ".join(entry.players))
		i += 1

func push_label(text: String):
	var label = Label.new()
	label.add_theme_font_size_override("font_size", 21)
	label.add_theme_font_override("font", font)
	label.text = text
	table.add_child(label)

func _on_back_pressed() -> void:
	exit()
