From 18b5dc91a173663cfbfa472c3b63f2ff5fa8b79f Mon Sep 17 00:00:00 2001 From: Jaap Marsman Date: Sun, 28 Aug 2022 13:38:17 +0800 Subject: [PATCH] added functioning date pickers and ini saving for optional birthdate info --- godot/birthday_selector.gd | 31 +++++++++++++++++++++++-------- godot/button_user_save.gd | 3 +++ godot/project.godot | 2 ++ godot/user_values.gd | 2 ++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/godot/birthday_selector.gd b/godot/birthday_selector.gd index d3f923d..75efd17 100644 --- a/godot/birthday_selector.gd +++ b/godot/birthday_selector.gd @@ -1,16 +1,31 @@ extends GridContainer -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" +onready var user_values = get_node("/root/UserValues") -# Called when the node enters the scene tree for the first time. 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 _process(delta): -# pass +func _on_month_selected( id ): + print(id) + 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)) diff --git a/godot/button_user_save.gd b/godot/button_user_save.gd index a0e3b79..2369315 100644 --- a/godot/button_user_save.gd +++ b/godot/button_user_save.gd @@ -20,6 +20,9 @@ func _on_button_user_save_pressed(): # Stores values in ini file user_values.config.set_value("User", "user_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) #onfig.set_value("Player2", "player_name", "V3geta") #config.set_value("Player2", "best_score", 9001) diff --git a/godot/project.godot b/godot/project.godot index 3ba669a..d78ff10 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -26,6 +26,8 @@ NodeVariables="*res://node_variables.gd" window/size/width=1280 window/size/height=720 +window/size/test_width=2560 +window/size/test_height=1440 window/energy_saving/keep_screen_on=false window/stretch/mode="2d" window/stretch/aspect="keep_width" diff --git a/godot/user_values.gd b/godot/user_values.gd index 1296cdb..f224638 100644 --- a/godot/user_values.gd +++ b/godot/user_values.gd @@ -20,6 +20,8 @@ func _ready(): # define variables from ini file if err == OK: 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: pass