diff --git a/godot/button_user_save.gd b/godot/button_user_save.gd index 2369315..c3c1d70 100644 --- a/godot/button_user_save.gd +++ b/godot/button_user_save.gd @@ -35,5 +35,5 @@ func _on_button_user_save_pressed(): user_values.config.save("user://user.ini") - node_variables.welcome_label.text = "Good morning, " + user_values.user_first_name + "!" + node_variables.welcome_label.text = user_values.welcome_day_part + user_values.user_first_name + "!" ui_control.show_start_menu() diff --git a/godot/start_menu.gd b/godot/start_menu.gd index 58aa4ad..f521d84 100644 --- a/godot/start_menu.gd +++ b/godot/start_menu.gd @@ -6,10 +6,18 @@ onready var program_values = get_node("/root/ProgramValues") var csv_url = "https://raw.githubusercontent.com/hobbesjaap/wellbeingapp/main/version_info.csv" +var welcome_day_part = " " func _ready(): $version_label.text = "Version " + str(program_values.current_version) - $welcome_title.text = "Good morning, " + user_values.user_first_name + "!" + + user_values.get_device_time() + user_values.set_welcome_day_part() + + $welcome_title.text = user_values.welcome_day_part + user_values.user_first_name + "!" + + + #func _process(_delta): diff --git a/godot/user_values.gd b/godot/user_values.gd index f224638..cb964b2 100644 --- a/godot/user_values.gd +++ b/godot/user_values.gd @@ -1,9 +1,22 @@ extends Node +# User values + var user_first_name = " " var user_birth_month = 0 var user_birth_day = 0 +# System time values + +var date +var date_month +var date_day + +var date_time +var date_time_hour + +var welcome_day_part = " " + # For the login-streak thing #var user_login_streak @@ -15,7 +28,29 @@ var user_birth_day = 0 var config = ConfigFile.new() var err = config.load("user://user.ini") +# This function can be triggered to update the known system time. +func get_device_time(): + date = OS.get_date() + date_time = OS.get_time() + date_time_hour = date_time.hour + date_month = date.month + date_day = date.day + print(date_month) + print(date_day) + print(date_time_hour) + +func set_welcome_day_part(): + if date_time_hour < 24: + welcome_day_part = "Good evening, " + if date_time_hour < 18: + welcome_day_part = "Good afternoon, " + if date_time_hour < 12: + welcome_day_part = "Good morning, " + if date_time_hour < 6: + welcome_day_part = "Good night, " + func _ready(): + get_device_time() # Read config file if it exists # define variables from ini file if err == OK: