Profile creating/loading in menu adjustments

This commit is contained in:
gotfishmakesticks 2023-11-13 08:57:14 +03:00
commit ff19560f0b
4 changed files with 36 additions and 4 deletions

View file

@ -16,7 +16,9 @@ func _ready():
if profile_meta != {} and profile_meta['meta'].has('last_profile'):
profile_meta = Game.profile_load(profile_meta['meta']['last_profile'])
Game.profile = Profile.create(profile_meta)
change_menu(0)
change_menu(0)
else:
change_menu(5)
profile_status.text = "Current profile: [{profile}]".format({"profile": Game.profile.profile_meta['meta']['profile_name']})
func change_menu(id):
@ -42,6 +44,7 @@ func change_menu(id):
b5.id = "Null"
input.visible = true
input.text = ""
input.placeholder_text = "Enter your profile name here!"
3: # Load Profile
b1.id = "Null"
b2.id = "LoadProfileConfirm"
@ -50,12 +53,21 @@ func change_menu(id):
b5.id = "Null"
input.visible = true
input.text = ""
input.placeholder_text = "Enter your profile name here!"
4: # Play Menu
b1.id = "LoadGame"
b2.id = "NewGame"
b3.id = "Back"
b4.id = "Null"
b5.id = "Null"
5: # First-timer Create Profile
b1.id = "Null"
b2.id = "FirstCreateProfileConfirm"
b3.id = "Null"
b4.id = "Null"
b5.id = "Null"
input.visible = true
input.text = ""
b1.change_name()
b2.change_name()
b3.change_name()

View file

@ -16,6 +16,7 @@ var texts = {
"Back" : "Back",
"Play" : "Play",
"LoadGame" : "Load from Profile",
"FirstCreateProfileConfirm" : "Confirm",
"Null" : Game.gameversion
}
@ -34,17 +35,35 @@ func _on_button_up():
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)
"DeleteProfile":
Game.profile_delete("1")
"ExitGame":
get_tree().quit()
"Profiles":