2022-08-03 01:01:10 +00:00
|
|
|
extends Button
|
|
|
|
|
2022-08-16 09:42:32 +00:00
|
|
|
|
2023-03-07 12:26:52 +00:00
|
|
|
@onready var node_variables = get_node("/root/NodeVariables")
|
|
|
|
@onready var ui_control = get_node("/root/UiControl")
|
|
|
|
@onready var user_values = get_node("/root/UserValues")
|
|
|
|
@onready var user_name = get_node("%textbox_user_name")
|
2022-08-03 01:01:10 +00:00
|
|
|
|
2022-08-16 09:42:32 +00:00
|
|
|
|
2022-08-03 01:01:10 +00:00
|
|
|
func _on_button_user_save_pressed():
|
|
|
|
|
2022-08-16 09:30:28 +00:00
|
|
|
if user_name.text == "":
|
|
|
|
# Prettify this later with a friendly user prompt
|
|
|
|
print("Won't continue. Put in name.")
|
|
|
|
|
|
|
|
else:
|
|
|
|
# First time label turns off - this is done every time - no harm in that?
|
|
|
|
node_variables.first_time_label.visible = false
|
|
|
|
|
|
|
|
# Stores values in ini file
|
|
|
|
user_values.config.set_value("User", "user_name", user_name.text)
|
|
|
|
user_values.user_first_name = user_name.text
|
2022-08-28 05:38:17 +00:00
|
|
|
user_values.config.set_value("User", "user_birth_month", user_values.user_birth_month)
|
|
|
|
user_values.config.set_value("User", "user_birth_day", user_values.user_birth_day)
|
|
|
|
|
2022-08-16 09:30:28 +00:00
|
|
|
#config.set_value("Player1", "best_score", 10)
|
|
|
|
#onfig.set_value("Player2", "player_name", "V3geta")
|
|
|
|
#config.set_value("Player2", "best_score", 9001)
|
|
|
|
|
|
|
|
# Save it to a file (overwrite if already exists).
|
|
|
|
# Need to make sure I never lose any values I add.
|
|
|
|
# This seems to be a manual thing to program.
|
|
|
|
# So per value, make sure to read it upon load.
|
|
|
|
# And write it out again as well.
|
|
|
|
|
|
|
|
user_values.config.save("user://user.ini")
|
|
|
|
|
2022-08-28 06:03:39 +00:00
|
|
|
node_variables.welcome_label.text = user_values.welcome_day_part + user_values.user_first_name + "!"
|
2022-08-16 09:30:28 +00:00
|
|
|
ui_control.show_start_menu()
|