63 lines
1.7 KiB
GDScript
63 lines
1.7 KiB
GDScript
extends Control
|
|
|
|
signal on_new_game_started
|
|
signal on_game_continued
|
|
|
|
@onready var continue_game_button: Button = %ContinueGameButton
|
|
@onready var new_game_button: Button = %NewGameButton
|
|
@onready var license_container: VBoxContainer = %LicenseContainer
|
|
|
|
const LICENSE_FOLDER: String = "res://resources/asset_info/"
|
|
@onready var license_entry: PackedScene = preload("res://ui/license_list/license_entry.tscn")
|
|
|
|
|
|
# On ready, check which buttons to show
|
|
func _ready() -> void:
|
|
SoundManager.play_background_music("Unexplored Fields")
|
|
list_licenses()
|
|
|
|
if SaveManager.save_exists():
|
|
continue_game_button.visible = true
|
|
new_game_button.visible = false
|
|
else:
|
|
continue_game_button.visible = false
|
|
new_game_button.visible = true
|
|
|
|
func _on_new_game_button_pressed() -> void:
|
|
# Hide the main menu
|
|
self.visible = false
|
|
|
|
# emit the new game signal
|
|
on_new_game_started.emit()
|
|
|
|
func _on_continue_game_button_pressed() -> void:
|
|
# Hide the main menu
|
|
self.visible = false
|
|
|
|
# emit the continue game signal
|
|
on_game_continued.emit()
|
|
|
|
func _on_options_button_pressed() -> void:
|
|
print("TODO")
|
|
|
|
func _on_licenses_button_pressed() -> void:
|
|
%LicensesScreen.visible = true
|
|
|
|
func _on_exit_button_pressed() -> void:
|
|
get_tree().quit()
|
|
|
|
func list_licenses() -> void:
|
|
var dir: DirAccess = DirAccess.open(LICENSE_FOLDER)
|
|
for file: String in dir.get_files():
|
|
add_license(file)
|
|
|
|
func add_license(license_path: String) -> void:
|
|
var asset_info: AssetInfo = load(LICENSE_FOLDER + license_path)
|
|
var new_license_entry: Node = license_entry.instantiate()
|
|
license_container.add_child(new_license_entry)
|
|
new_license_entry.populate(asset_info)
|
|
|
|
|
|
func _on_licenses_close_button_pressed() -> void:
|
|
%LicensesScreen.visible = false
|
|
pass # Replace with function body.
|