New profiles system + auto version label

This commit is contained in:
gotfishmakesticks 2023-11-11 01:08:43 +03:00
commit 6ffa6e643b
7 changed files with 128 additions and 49 deletions

View file

@ -8,30 +8,44 @@ var menu_id = 0
@onready var b3 = $Control/MenuButton3
@onready var b4 = $Control/MenuButton4
@onready var b5 = $Control/MenuButton5
@onready var profile_status = $Control/ProfileStatus
@onready var input = $Control/Input
func _ready():
change_menu(0)
profile_status.text = "Current profile: [{profile}]".format({"profile": Game.profile.profile_meta['meta']['profile_name']})
func change_menu(id):
input.visible = false
match id:
0:
0: # Main
b1.id = "NewGame"
b2.id = "Profiles"
b3.id = "Settings"
b4.id = "Credits"
b5.id = "ExitGame"
1:
1: # Profiles
b1.id = "CreateProfile"
b2.id = "LoadProfile"
b3.id = "DeleteProfile"
b4.id = "Back"
b3.id = "Back"
b4.id = "Null"
b5.id = "Null"
2:
b1.id = ""
b2.id = ""
b3.id = ""
b4.id = ""
b5.id = ""
2: # Create Profile
b1.id = "Null"
b2.id = "CreateProfileConfirm"
b3.id = "Back"
b4.id = "Null"
b5.id = "Null"
input.visible = true
input.text = ""
3: # Load Profile
b1.id = "Null"
b2.id = "LoadProfileConfirm"
b3.id = "Back"
b4.id = "Null"
b5.id = "Null"
input.visible = true
input.text = ""
b1.change_name()
b2.change_name()
b3.change_name()

View file

@ -1,9 +1,25 @@
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",
"Null" : Game.gameversion
}
@export var id = "Null"
@onready var controller = $"../.."
func _ready():
button_up.connect(_on_button_up)
change_name()
@ -12,10 +28,16 @@ func _on_button_up():
match id:
"NewGame":
get_tree().change_scene_to_file("res://scenes/Space.tscn")
"CreateProfile":
Game.profile_create("1")
"LoadProfile":
Game.profile_legit_check(Game.profile_load("1"))
"CreateProfileConfirm":
var profile_name = controller.input.text
Game.profile_create(profile_name)
Game.profile_load(profile_name)
"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)
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":
@ -24,31 +46,17 @@ func _on_button_up():
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)
func change_name():
visible = true
match id:
"NewGame":
text = "New Game"
"CreateProfile":
text = "Create Profile"
"LoadProfile":
text = "Load Profile"
"DeleteProfile":
text = "Delete Profile"
"ExitGame":
text = "Exit Game"
"Settings":
text = "Settings (WIP)"
"AudioSettings":
text = "Audio (WIP)"
"VideoSettings":
text = "Video (WIP)"
"Profiles":
text = "Profiles (WIP)"
"Back":
text = "Back"
"Null":
text = Game.gameversion
visible = false
visible = id != "Null"
text = texts[id]