Game data save/load, profile autoload
This commit is contained in:
parent
11ea0f0d51
commit
cf4687350d
7 changed files with 48 additions and 4 deletions
|
|
@ -12,6 +12,10 @@ var menu_id = 0
|
|||
@onready var input = $Control/Input
|
||||
|
||||
func _ready():
|
||||
var profile_meta = Game.profile_load("")
|
||||
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)
|
||||
profile_status.text = "Current profile: [{profile}]".format({"profile": Game.profile.profile_meta['meta']['profile_name']})
|
||||
|
||||
|
|
@ -19,7 +23,7 @@ func change_menu(id):
|
|||
input.visible = false
|
||||
match id:
|
||||
0: # Main
|
||||
b1.id = "NewGame"
|
||||
b1.id = "Play"
|
||||
b2.id = "Profiles"
|
||||
b3.id = "Settings"
|
||||
b4.id = "Credits"
|
||||
|
|
@ -46,6 +50,12 @@ func change_menu(id):
|
|||
b5.id = "Null"
|
||||
input.visible = true
|
||||
input.text = ""
|
||||
4: # Play Menu
|
||||
b1.id = "LoadGame"
|
||||
b2.id = "NewGame"
|
||||
b3.id = "Back"
|
||||
b4.id = "Null"
|
||||
b5.id = "Null"
|
||||
b1.change_name()
|
||||
b2.change_name()
|
||||
b3.change_name()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ var texts = {
|
|||
"Profiles" : "Profiles",
|
||||
"Credits" : "Credits",
|
||||
"Back" : "Back",
|
||||
"Play" : "Play",
|
||||
"LoadGame" : "Load from Profile",
|
||||
"Null" : Game.gameversion
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +37,10 @@ func _on_button_up():
|
|||
"LoadProfileConfirm":
|
||||
var profile_name = controller.input.text
|
||||
var profile_meta = Game.profile_legit_check(Game.profile_load(profile_name))
|
||||
Game.profile = Profile.create(profile_meta)
|
||||
if profile_meta != {}:
|
||||
Game.profile.profile_meta['meta']['last_profile'] = 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)
|
||||
"DeleteProfile":
|
||||
|
|
@ -56,6 +61,12 @@ func _on_button_up():
|
|||
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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue