added functioning date pickers and ini saving for optional birthdate info

This commit is contained in:
Jaap Marsman 2022-08-28 13:38:17 +08:00
parent 6287420f21
commit 18b5dc91a1
4 changed files with 30 additions and 8 deletions

View File

@ -1,16 +1,31 @@
extends GridContainer extends GridContainer
# Declare member variables here. Examples: onready var user_values = get_node("/root/UserValues")
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. # Access the "country_menu" PopupMenu through this.
var birth_month_popup_menu: PopupMenu = $button_birth_month.get_popup()
var birth_day_popup_menu: PopupMenu = $button_birth_day.get_popup()
# Signal for when the user selects an PopupMenu item.
var _error = birth_month_popup_menu.connect("id_pressed", self, "_on_month_selected")
var _error2 = birth_day_popup_menu.connect("id_pressed", self, "_on_day_selected")
if user_values.user_birth_month != 0:
$button_birth_month.text = str("Month " + str(user_values.user_birth_month))
if user_values.user_birth_day != 0:
$button_birth_day.text = str("Day " + str(user_values.user_birth_day))
# Called every frame. 'delta' is the elapsed time since the previous frame. func _on_month_selected( id ):
#func _process(delta): print(id)
# pass user_values.user_birth_month = id
$button_birth_month.text = str("Month " + str(id))
func _on_day_selected( id ):
print(id)
user_values.user_birth_day = id
$button_birth_day.text = str("Day " + str(id))

View File

@ -20,6 +20,9 @@ func _on_button_user_save_pressed():
# Stores values in ini file # Stores values in ini file
user_values.config.set_value("User", "user_name", user_name.text) user_values.config.set_value("User", "user_name", user_name.text)
user_values.user_first_name = user_name.text user_values.user_first_name = user_name.text
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)
#config.set_value("Player1", "best_score", 10) #config.set_value("Player1", "best_score", 10)
#onfig.set_value("Player2", "player_name", "V3geta") #onfig.set_value("Player2", "player_name", "V3geta")
#config.set_value("Player2", "best_score", 9001) #config.set_value("Player2", "best_score", 9001)

View File

@ -26,6 +26,8 @@ NodeVariables="*res://node_variables.gd"
window/size/width=1280 window/size/width=1280
window/size/height=720 window/size/height=720
window/size/test_width=2560
window/size/test_height=1440
window/energy_saving/keep_screen_on=false window/energy_saving/keep_screen_on=false
window/stretch/mode="2d" window/stretch/mode="2d"
window/stretch/aspect="keep_width" window/stretch/aspect="keep_width"

View File

@ -20,6 +20,8 @@ func _ready():
# define variables from ini file # define variables from ini file
if err == OK: if err == OK:
user_first_name = config.get_value("User", "user_name") user_first_name = config.get_value("User", "user_name")
user_birth_month = config.get_value("User", "user_birth_month")
user_birth_day = config.get_value("User", "user_birth_day")
else: else:
pass pass