mirror of
https://github.com/hobbesjaap/wellbeingapp.git
synced 2024-11-22 18:42:58 +00:00
username saving implemented
This commit is contained in:
parent
29e28ac115
commit
67050fc322
@ -17,4 +17,5 @@ func _ready():
|
|||||||
|
|
||||||
|
|
||||||
func _on_button_email_feedback_pressed():
|
func _on_button_email_feedback_pressed():
|
||||||
|
# warning-ignore:return_value_discarded
|
||||||
OS.shell_open("mailto:feedback@jaapmarsman.com")
|
OS.shell_open("mailto:feedback@jaapmarsman.com")
|
||||||
|
@ -16,4 +16,4 @@ extends Button
|
|||||||
|
|
||||||
|
|
||||||
func _on_button_open_github_pressed():
|
func _on_button_open_github_pressed():
|
||||||
OS.shell_open("https://godotengine.org")
|
OS.shell_open("https://github.com/hobbesjaap/wellbeingapp")
|
||||||
|
@ -2,8 +2,11 @@ extends Button
|
|||||||
|
|
||||||
var config = ConfigFile.new()
|
var config = ConfigFile.new()
|
||||||
|
|
||||||
onready var user_name = get_node("textbox_user_name")
|
onready var user_name = get_node("%textbox_user_name")
|
||||||
onready var user_info = get_node("/root/UserValues")
|
onready var user_info = get_node("/root/UserValues")
|
||||||
|
onready var main_screen = get_node("/root/main_screen")
|
||||||
|
onready var start_menu = get_node("/root/main_screen/start_menu")
|
||||||
|
onready var user_menu = get_node("/root/main_screen/user_details")
|
||||||
|
|
||||||
# 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():
|
||||||
@ -17,10 +20,15 @@ func _ready():
|
|||||||
func _on_button_user_save_pressed():
|
func _on_button_user_save_pressed():
|
||||||
|
|
||||||
# Store some values.
|
# Store some values.
|
||||||
config.set_value("User", "player_name", user_name)
|
config.set_value("User", "user_name", user_name.text)
|
||||||
config.set_value("Player1", "best_score", 10)
|
user_info.user_first_name = user_name.text
|
||||||
config.set_value("Player2", "player_name", "V3geta")
|
#config.set_value("Player1", "best_score", 10)
|
||||||
config.set_value("Player2", "best_score", 9001)
|
#onfig.set_value("Player2", "player_name", "V3geta")
|
||||||
|
#config.set_value("Player2", "best_score", 9001)
|
||||||
|
|
||||||
# Save it to a file (overwrite if already exists).
|
# Save it to a file (overwrite if already exists).
|
||||||
config.save("user://user.ini")
|
config.save("user://user.ini")
|
||||||
|
|
||||||
|
main_screen.visible = true
|
||||||
|
start_menu.visible = true
|
||||||
|
user_menu.visible = false
|
||||||
|
@ -1,21 +1,42 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
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/start_menu")
|
onready var start_menu = get_node("/root/main_screen/start_menu")
|
||||||
onready var user_menu = get_node("/root/main_screen/user_details")
|
onready var user_menu = get_node("/root/main_screen/user_details")
|
||||||
|
onready var user_name = get_node("%textbox_user_name")
|
||||||
|
|
||||||
|
onready var user_info = get_node("/root/UserValues")
|
||||||
|
onready var program_info = get_node("/root/ProgramValues")
|
||||||
|
|
||||||
|
var config = ConfigFile.new()
|
||||||
|
var err = config.load("user://user.ini")
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
# Read config file if it exists
|
||||||
|
# otherwise set up new user data
|
||||||
|
|
||||||
|
if err != OK:
|
||||||
|
start_menu.visible = false
|
||||||
|
user_menu.visible = true
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
# Set starting state visibility
|
# Set starting state visibility
|
||||||
|
|
||||||
main_screen.visible = true
|
main_screen.visible = true
|
||||||
start_menu.visible = true
|
start_menu.visible = true
|
||||||
user_menu.visible = false
|
user_menu.visible = false
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# define variables from ini file
|
||||||
|
user_info.user_first_name = config.get_value("User", "user_name")
|
||||||
|
user_name.text = user_info.user_first_name
|
||||||
|
|
||||||
|
# Iterate over all sections.
|
||||||
|
# for player in config.get_sections():
|
||||||
|
# # Fetch the data for each section.
|
||||||
|
# var player_name = config.get_value(player, "player_name")
|
||||||
|
# var player_score = config.get_value(player, "best_score")
|
||||||
|
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
# pass
|
# pass
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
onready var user_info = get_node("/root/UserValues")
|
onready var user_info = get_node("/root/UserValues")
|
||||||
onready var program_info = get_node("/root/ProgramValues")
|
onready var program_info = get_node("/root/ProgramValues")
|
||||||
|
|
||||||
@ -13,5 +10,6 @@ func _ready():
|
|||||||
|
|
||||||
|
|
||||||
# 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):
|
||||||
|
$welcome_title.text = "Good morning " + user_info.user_first_name + "!"
|
||||||
# pass
|
# pass
|
||||||
|
@ -14,7 +14,6 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="start_menu" type="Node2D" parent="."]
|
[node name="start_menu" type="Node2D" parent="."]
|
||||||
visible = false
|
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="button_daily_action" type="Button" parent="start_menu"]
|
[node name="button_daily_action" type="Button" parent="start_menu"]
|
||||||
@ -38,7 +37,7 @@ margin_left = 98.0
|
|||||||
margin_top = 195.0
|
margin_top = 195.0
|
||||||
margin_right = 135.0
|
margin_right = 135.0
|
||||||
margin_bottom = 215.0
|
margin_bottom = 215.0
|
||||||
text = "URL"
|
text = "GitHub"
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="button_email_feedback" type="Button" parent="start_menu"]
|
[node name="button_email_feedback" type="Button" parent="start_menu"]
|
||||||
@ -58,23 +57,18 @@ text = "Name"
|
|||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="user_details" type="Node2D" parent="."]
|
[node name="user_details" type="Node2D" parent="."]
|
||||||
|
visible = false
|
||||||
[node name="button_user_ok" type="Button" parent="user_details"]
|
|
||||||
margin_left = 444.0
|
|
||||||
margin_top = 279.0
|
|
||||||
margin_right = 500.0
|
|
||||||
margin_bottom = 316.0
|
|
||||||
text = "OK"
|
|
||||||
|
|
||||||
[node name="button_user_save" type="Button" parent="user_details"]
|
[node name="button_user_save" type="Button" parent="user_details"]
|
||||||
margin_left = 540.0
|
margin_left = 540.0
|
||||||
margin_top = 280.0
|
margin_top = 280.0
|
||||||
margin_right = 615.0
|
margin_right = 615.0
|
||||||
margin_bottom = 317.0
|
margin_bottom = 317.0
|
||||||
text = "Save"
|
text = "OK"
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="textbox_user_name" type="LineEdit" parent="user_details"]
|
[node name="textbox_user_name" type="LineEdit" parent="user_details"]
|
||||||
|
unique_name_in_owner = true
|
||||||
margin_left = 244.0
|
margin_left = 244.0
|
||||||
margin_top = 205.0
|
margin_top = 205.0
|
||||||
margin_right = 794.0
|
margin_right = 794.0
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
var user_first_name = "Not defined"
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
var user_first_name = "No name"
|
|
||||||
|
|
||||||
# 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():
|
||||||
|
1
release_version.csv
Normal file
1
release_version.csv
Normal file
@ -0,0 +1 @@
|
|||||||
|
2
|
|
Loading…
Reference in New Issue
Block a user