92 lines
2.9 KiB
GDScript
92 lines
2.9 KiB
GDScript
extends Button
|
|
|
|
var texts = {
|
|
"NewGame" : "New Game",
|
|
"CreateProfile" : "Create Profile",
|
|
"CreateProfileConfirm" : "Confirm",
|
|
"LoadProfile" : "Load Profile",
|
|
"LoadProfileConfirm" : "Confirm",
|
|
"DeleteProfile" : "Delete Profile",
|
|
"ExitGame" : "Exit Game",
|
|
"Settings" : "Settings",
|
|
"AudioSettings" : "Audio",
|
|
"VideoSettings" : "Video",
|
|
"Profiles" : "Profiles",
|
|
"Credits" : "Credits",
|
|
"Back" : "Back",
|
|
"Play" : "Play",
|
|
"LoadGame" : "Load from Profile",
|
|
"FirstCreateProfileConfirm" : "Confirm",
|
|
"Null" : Game.gameversion
|
|
}
|
|
|
|
@export var id = "Null"
|
|
|
|
@onready var controller = $"../.."
|
|
func _ready():
|
|
button_up.connect(_on_button_up)
|
|
change_name()
|
|
|
|
func _on_button_up():
|
|
match id:
|
|
"NewGame":
|
|
get_tree().change_scene_to_file("res://scenes/Space.tscn")
|
|
"CreateProfileConfirm":
|
|
var profile_name = controller.input.text
|
|
Game.profile_create(profile_name)
|
|
Game.profile_load(profile_name)
|
|
controller.input.text = ""
|
|
"FirstCreateProfileConfirm":
|
|
Game.profile_create("")
|
|
Game.profile = Profile.create(Game.profile_load(""))
|
|
var profile_name = controller.input.text
|
|
Game.profile.profile_meta['meta']['last_profile'] = profile_name
|
|
Game.profile_save(get_tree().current_scene)
|
|
Game.profile_create(profile_name)
|
|
var profile_meta = Game.profile_load(profile_name)
|
|
Game.profile_save(get_tree().current_scene)
|
|
Game.profile = Profile.create(profile_meta)
|
|
var format = {"profile": Game.profile.profile_meta['meta']['profile_name']}
|
|
controller.profile_status.text = "Current profile: [{profile}]".format(format)
|
|
controller.change_menu(0)
|
|
"LoadProfileConfirm":
|
|
var profile_name = controller.input.text
|
|
var profile_meta = Game.profile_legit_check(Game.profile_load(profile_name))
|
|
controller.input.text = ""
|
|
if profile_meta != {}:
|
|
if !Game.profile.is_root:
|
|
Game.profile = Profile.create(Game.profile_load(""))
|
|
Game.profile.profile_meta['meta']['last_profile'] = profile_name
|
|
controller.input.placeholder_text = "Loaded profile {profile}.".format({"profile": profile_name})
|
|
Game.profile_save(get_tree().current_scene)
|
|
Game.profile = Profile.create(profile_meta)
|
|
else:
|
|
controller.input.placeholder_text = "Could not load the given profile."
|
|
var format = {"profile": Game.profile.profile_meta['meta']['profile_name']}
|
|
controller.profile_status.text = "Current profile: [{profile}]".format(format)
|
|
"ExitGame":
|
|
get_tree().quit()
|
|
"Profiles":
|
|
controller.change_menu(1)
|
|
"Back":
|
|
var new_menu_id = 0
|
|
match controller.menu_id:
|
|
2:
|
|
new_menu_id = 1
|
|
3:
|
|
new_menu_id = 1
|
|
controller.change_menu(new_menu_id)
|
|
"CreateProfile":
|
|
controller.change_menu(2)
|
|
"LoadProfile":
|
|
controller.change_menu(3)
|
|
"Play":
|
|
controller.change_menu(4)
|
|
"LoadGame":
|
|
if Game.profile.profile_meta.has('game'):
|
|
Game.profile.profile_meta['game_load'] = true
|
|
get_tree().change_scene_to_file("res://scenes/Space.tscn")
|
|
|
|
func change_name():
|
|
visible = id != "Null"
|
|
text = texts[id]
|