# Hurry Curry! - a game about cooking
# Copyright 2025 nokoe
#
# 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 .
#
extends Menu
var authors := ["metamuffin", "nokoe", "tpart"]
var contributors := ["sofviic", "BigBrotherNii", "Miner34"]
const cc_by_4 := "CC-BY 4.0"
const cc_by_3 := "CC-BY 3.0"
const cc0 := "CC0"
const AGPL_NOTICE := """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 ."""
const SOURCE_CODE := "https://codeberg.org/hurrycurry/hurrycurry"
func _ready() -> void:
	$side/margin/options/first/source.tooltip_text = SOURCE_CODE
var credits := [
	[tr("c.credits.models"), [
		["kenney.nl", "Various Models", cc0],
		["Kay Lousberg", "Kitchen tiles", cc0],
		["Poly by Google", "Strawberry", cc_by_3],
		["Poly by Google", "Fish", cc_by_3],
		["jeremy", "Propeller hat", cc_by_3]
	]],
	[tr("c.credits.sounds"), [
		["Dryoma", "Footstep sounds", cc_by_4],
		["Koops", "Page_Turn_24.wav", cc_by_4],
		["InspectorJ", "Pencil, Writing, Close, A.wav", cc_by_4],
		["Dillon Becker", "Super Dialogue Audio Pack", cc_by_4],
		["Ellr", "Universal UI/Menu Soundpack", cc_by_4],
		["toyoto", "Woosh Fleuret Escrime B.wav", cc_by_4],
		["deleted_user_877451", "Game_over.wav", cc_by_3],
		["Quaternius", "Someting, dont remember...", cc0],
		["Dillon Becker", "Super Dialogue Audio Pack V1", cc_by_4]
	]],
	[tr("c.credits.translations"), {
		tr("c.settings.ui.language.zh_Hans"): ["Outbreak2096"],
		tr("c.settings.ui.language.zh_Hant"): ["hugoalh"],
		tr("c.settings.ui.language.nl"): ["Vistaus"],
		tr("c.settings.ui.language.it"): ["Miner34", "solemden"],
		tr("c.settings.ui.language.eu"): ["josuigoa"],
		tr("c.settings.ui.language.fr"): ["fnetX", "lejun"],
		tr("c.settings.ui.language.pl"): ["tranzystorekk"],
		tr("c.settings.ui.language.he"): ["RustyStriker"],
		tr("c.settings.ui.language.el"): ["n0toose"],
		tr("c.settings.ui.language.ja"): ["BigBrotherNii"],
		tr("c.settings.ui.language.ar"): ["sofviic"],
		tr("c.settings.ui.language.tr"): ["furkanunsalan", "tekrei"],
		tr("c.settings.ui.language.ru"): ["0ko"],
	}]
]
func _menu_cover(state):
	$side.visible = not state
func credits_text() -> String:
	var text = "[center]"
	authors.shuffle()
	contributors.shuffle()
	
	text += "\n\n\n[b]%s[/b]\n\n%s\n\n[b]%s[/b]\n\n%s\n\n[b]%s[/b]\n\n\n" % [
		tr("c.credits.title"),
		tr("c.credits.developed_by"),
		"\n".join(authors),
		tr("c.credits.contributors"),
		",  ".join(contributors),
	]
	for section in credits:
		text += "[b]%s[/b]\n\n" % section[0]
		if typeof(section[1]) == TYPE_DICTIONARY:
			text += "[table=2]"
			for key in section[1]:
				text += "[cell][right]%s[/right][/cell]" % key
				text += "[cell][left]%s[/left][/cell]" % ", ".join(section[1][key])
			text += "[/table]"
		else:
			text += "[table=3]"
			for entry in section[1]:
				text += "[cell][right]%s[/right][/cell]" % entry[0]
				text += "[cell][left]%s[/left][/cell]" % entry[1]
				text += "[cell][left]%s[/left][/cell]" % entry[2]
			text += "[/table]"
		text += "\n\n\n"
	text += "\n[b]%s[/b]\n\n\n[/center]" % tr("c.credits.thanks")
	return text
func legal_text() -> String:
	var all: Array[String] = []
	authors.shuffle()
	contributors.shuffle()
	all.append_array(authors)
	all.append_array(contributors)
	var translators: Array[String] = []
	for c in credits[2][1].values():
		translators.append_array(c)
	translators.shuffle()
	all.append_array(translators)
	var text := "Hurry Curry! - a game about cooking\n"
	text += "[code]Copyright 2024, 2025 %s\n\n" % ", ".join(all)
	text += "%s[/code]\n\n" % AGPL_NOTICE
	text += tr("c.legal.using_godot")
	text += "\n\n[code]%s[/code]" % Engine.get_license_text()
	return text
func _on_credits_pressed() -> void:
	submenu("res://menu/credits.tscn", credits_text())
func _on_legal_pressed() -> void:
	submenu("res://menu/credits.tscn", legal_text())
func _on_back_pressed() -> void:
	exit()
func _on_source_pressed() -> void:
	OS.shell_open(SOURCE_CODE)