mirror of
https://github.com/hobbesjaap/wellbeingapp.git
synced 2024-11-22 10:32:58 +00:00
fixed welcome label to no longer depend on process delta script
This commit is contained in:
parent
daa2fcaa70
commit
c19f81c7ec
3
godot/apps/daily_prompts.tscn
Normal file
3
godot/apps/daily_prompts.tscn
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="daily_prompts" type="CanvasLayer"]
|
@ -1,42 +1,34 @@
|
|||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
var config = ConfigFile.new()
|
|
||||||
|
|
||||||
onready var node_variables = get_node("/root/NodeVariables")
|
onready var node_variables = get_node("/root/NodeVariables")
|
||||||
onready var user_info = get_node("/root/UserValues")
|
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")
|
onready var user_name = get_node("%textbox_user_name")
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
||||||
|
|
||||||
|
|
||||||
func _on_button_user_save_pressed():
|
func _on_button_user_save_pressed():
|
||||||
|
|
||||||
# Store some values.
|
if user_name.text == "":
|
||||||
# Maybe this one only runs if there is no ini
|
# Prettify this later with a friendly user prompt
|
||||||
config.set_value("User", "user_name", user_name.text)
|
print("Won't continue. Put in name.")
|
||||||
user_info.user_first_name = user_name.text
|
|
||||||
#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).
|
else:
|
||||||
# Need to make sure I never lose any values I add.
|
# First time label turns off - this is done every time - no harm in that?
|
||||||
# This seems to be a manual thing to program.
|
node_variables.first_time_label.visible = false
|
||||||
# So per value, make sure to read it upon load.
|
|
||||||
# And write it out again as well.
|
|
||||||
|
|
||||||
config.save("user://user.ini")
|
# Stores values in ini file
|
||||||
|
user_values.config.set_value("User", "user_name", user_name.text)
|
||||||
|
user_values.user_first_name = user_name.text
|
||||||
|
#config.set_value("Player1", "best_score", 10)
|
||||||
|
#onfig.set_value("Player2", "player_name", "V3geta")
|
||||||
|
#config.set_value("Player2", "best_score", 9001)
|
||||||
|
|
||||||
node_variables.main_screen.visible = true
|
# Save it to a file (overwrite if already exists).
|
||||||
node_variables.start_menu.visible = true
|
# Need to make sure I never lose any values I add.
|
||||||
node_variables.user_menu.visible = false
|
# 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.
|
||||||
|
|
||||||
# Need to do a "This thing can't be empty" code
|
user_values.config.save("user://user.ini")
|
||||||
# Most likely here. A if .text = null, then,
|
|
||||||
# don't proceed.
|
node_variables.welcome_label.text = "Good morning, " + user_values.user_first_name + "!"
|
||||||
|
ui_control.show_start_menu()
|
||||||
|
@ -5,16 +5,13 @@ onready var node_variables = get_node("/root/NodeVariables")
|
|||||||
onready var ui_control = get_node("/root/UiControl")
|
onready var ui_control = get_node("/root/UiControl")
|
||||||
onready var user_info = get_node("/root/UserValues")
|
onready var user_info = get_node("/root/UserValues")
|
||||||
|
|
||||||
var config = ConfigFile.new()
|
|
||||||
var err = config.load("user://user.ini")
|
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Read config file if it exists
|
# Read config file if it exists
|
||||||
# otherwise set up new user data
|
# otherwise set up new user data
|
||||||
|
|
||||||
if err != OK:
|
if user_info.err != OK:
|
||||||
ui_control.show_user_menu()
|
ui_control.show_user_menu()
|
||||||
|
node_variables.first_time_label.visible = true
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
@ -22,7 +19,6 @@ func _ready():
|
|||||||
ui_control.show_start_menu()
|
ui_control.show_start_menu()
|
||||||
|
|
||||||
# define variables from ini file
|
# define variables from ini file
|
||||||
user_info.user_first_name = config.get_value("User", "user_name")
|
|
||||||
node_variables.user_name.text = user_info.user_first_name
|
node_variables.user_name.text = user_info.user_first_name
|
||||||
|
|
||||||
# Iterate over all sections.
|
# Iterate over all sections.
|
||||||
|
@ -4,7 +4,12 @@ extends Node
|
|||||||
onready var main_screen = get_node("/root/main_screen")
|
onready var main_screen = get_node("/root/main_screen")
|
||||||
onready var start_menu = get_node("/root/main_screen/UI/top_container/menus_container/start_menu")
|
onready var start_menu = get_node("/root/main_screen/UI/top_container/menus_container/start_menu")
|
||||||
onready var user_menu = get_node("/root/main_screen/UI/top_container/menus_container/user_details")
|
onready var user_menu = get_node("/root/main_screen/UI/top_container/menus_container/user_details")
|
||||||
|
onready var daily_prompts = get_node("/root/main_screen/UI/top_container/menus_container/daily_prompts")
|
||||||
|
|
||||||
|
|
||||||
onready var user_name = get_node("/root/main_screen/UI/top_container/menus_container/user_details/textbox_user_name")
|
onready var user_name = get_node("/root/main_screen/UI/top_container/menus_container/user_details/textbox_user_name")
|
||||||
|
onready var first_time_label = get_node("/root/main_screen/UI/top_container/menus_container/user_details/label_first_time")
|
||||||
|
onready var welcome_label = get_node("/root/main_screen/UI/top_container/menus_container/start_menu/welcome_title")
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
@ -1,27 +1,31 @@
|
|||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
onready var user_info = get_node("/root/UserValues")
|
onready var user_values = get_node("/root/UserValues")
|
||||||
onready var program_info = get_node("/root/ProgramValues")
|
onready var program_values = get_node("/root/ProgramValues")
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# $HTTPRequest.connect("request_completed", self, "_on_request_completed")
|
$version_label.text = str(program_values.current_version)
|
||||||
$version_label.text = str(program_info.current_version)
|
$welcome_title.text = "Good morning, " + user_values.user_first_name + "!"
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
#func _process(_delta):
|
||||||
$welcome_title.text = "Good morning " + user_info.user_first_name + "!"
|
# Currently the only working way to show the user name. NOT desirable, continuously running the same line of code for no reason than me not figuring it out.
|
||||||
|
# $welcome_title.text = "Good morning, " + user_info.user_first_name + "!"
|
||||||
|
|
||||||
|
|
||||||
func _on_button_update_check_pressed():
|
func _on_button_update_check_pressed():
|
||||||
$HTTPRequest.request("https://raw.githubusercontent.com/hobbesjaap/wellbeingapp/main/version_info.csv")
|
$HTTPRequest.request("https://raw.githubusercontent.com/hobbesjaap/wellbeingapp/main/version_info.csv")
|
||||||
|
|
||||||
|
func update_user_name_label():
|
||||||
|
$welcome_title.text = "Good morning, " + user_values.user_first_name + "!"
|
||||||
|
|
||||||
|
|
||||||
func _on_HTTPRequest_request_completed(_result, _response_code, _headers, body):
|
func _on_HTTPRequest_request_completed(_result, _response_code, _headers, body):
|
||||||
var json = JSON.parse(body.get_string_from_utf8())
|
var json = JSON.parse(body.get_string_from_utf8())
|
||||||
program_info.web_release_version = json.result
|
program_values.web_release_version = json.result
|
||||||
if program_info.web_release_version > program_info.release_version:
|
if program_values.web_release_version > program_values.release_version:
|
||||||
print("There's an update!")
|
print("There's an update!")
|
||||||
elif program_info.web_release_version == program_info.release_version:
|
elif program_values.web_release_version == program_values.release_version:
|
||||||
print("There is no update!")
|
print("There is no update!")
|
||||||
|
@ -73,16 +73,15 @@ size_flags_horizontal = 3
|
|||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
text = "Journal"
|
text = "Journal"
|
||||||
|
|
||||||
[node name="welcome_title" type="RichTextLabel" parent="."]
|
[node name="welcome_title" type="Label" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
margin_left = -185.0
|
margin_left = -185.0
|
||||||
margin_top = 11.0
|
margin_top = 11.0
|
||||||
margin_right = 185.0
|
margin_right = 185.0
|
||||||
margin_bottom = 42.0
|
margin_bottom = 42.0
|
||||||
text = "Good morning, Jaap!
|
text = "Poofaces are cool"
|
||||||
"
|
|
||||||
scroll_active = false
|
|
||||||
|
|
||||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://main_screen.gd" type="Script" id=1]
|
[ext_resource path="res://main_screen.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://user_details.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://user_details.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://start_menu.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://start_menu.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://apps/daily_prompts.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=1]
|
[sub_resource type="StyleBoxFlat" id=1]
|
||||||
bg_color = Color( 0.862745, 0.435294, 0.329412, 1 )
|
bg_color = Color( 0.862745, 0.435294, 0.329412, 1 )
|
||||||
@ -40,6 +41,8 @@ margin_right = 1280.0
|
|||||||
|
|
||||||
[node name="user_details" parent="UI/top_container/menus_container" instance=ExtResource( 2 )]
|
[node name="user_details" parent="UI/top_container/menus_container" instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="daily_prompts" parent="UI/top_container/menus_container" instance=ExtResource( 4 )]
|
||||||
|
|
||||||
[node name="bottom_bar" type="Panel" parent="UI"]
|
[node name="bottom_bar" type="Panel" parent="UI"]
|
||||||
margin_top = 680.0
|
margin_top = 680.0
|
||||||
margin_right = 1280.0
|
margin_right = 1280.0
|
||||||
|
@ -2,6 +2,7 @@ extends Node
|
|||||||
|
|
||||||
|
|
||||||
onready var node_variables = get_node("/root/NodeVariables")
|
onready var node_variables = get_node("/root/NodeVariables")
|
||||||
|
onready var user_values = get_node("/root/UserValues")
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -11,11 +12,19 @@ func show_start_menu():
|
|||||||
node_variables.main_screen.visible = true
|
node_variables.main_screen.visible = true
|
||||||
node_variables.start_menu.visible = true
|
node_variables.start_menu.visible = true
|
||||||
node_variables.user_menu.visible = false
|
node_variables.user_menu.visible = false
|
||||||
|
node_variables.daily_prompts.visible = false
|
||||||
|
|
||||||
func show_user_menu():
|
func show_user_menu():
|
||||||
node_variables.main_screen.visible = true
|
node_variables.main_screen.visible = true
|
||||||
node_variables.start_menu.visible = false
|
node_variables.start_menu.visible = false
|
||||||
node_variables.user_menu.visible = true
|
node_variables.user_menu.visible = true
|
||||||
|
node_variables.daily_prompts.visible = false
|
||||||
|
|
||||||
|
func show_daily_prompts():
|
||||||
|
node_variables.main_screen.visible = true
|
||||||
|
node_variables.start_menu.visible = false
|
||||||
|
node_variables.user_menu.visible = false
|
||||||
|
node_variables.daily_prompts.visible = true
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
|
@ -29,4 +29,13 @@ margin_bottom = 404.0
|
|||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
text = "Day"
|
text = "Day"
|
||||||
|
|
||||||
|
[node name="label_first_time" type="Label" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
margin_left = 211.0
|
||||||
|
margin_top = 168.0
|
||||||
|
margin_right = 832.0
|
||||||
|
margin_bottom = 193.0
|
||||||
|
text = "First time user: Please fill in your FIRST NAME only below."
|
||||||
|
|
||||||
[connection signal="pressed" from="button_user_save" to="button_user_save" method="_on_button_user_save_pressed"]
|
[connection signal="pressed" from="button_user_save" to="button_user_save" method="_on_button_user_save_pressed"]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var user_first_name = "Not defined"
|
var user_first_name = " "
|
||||||
var user_birth_month
|
var user_birth_month = 0
|
||||||
var user_birth_date
|
var user_birth_day = 0
|
||||||
|
|
||||||
# For the login-streak thing
|
# For the login-streak thing
|
||||||
|
|
||||||
@ -11,9 +11,18 @@ var user_birth_date
|
|||||||
#var user_last_login_month
|
#var user_last_login_month
|
||||||
#var user_last_login_day
|
#var user_last_login_day
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
|
var config = ConfigFile.new()
|
||||||
|
var err = config.load("user://user.ini")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
# Read config file if it exists
|
||||||
|
# define variables from ini file
|
||||||
|
if err == OK:
|
||||||
|
user_first_name = config.get_value("User", "user_name")
|
||||||
|
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
Loading…
Reference in New Issue
Block a user