From 76014b5f10701ba1588124a26cadc03cbcadac26 Mon Sep 17 00:00:00 2001 From: Jaap Marsman Date: Wed, 3 Aug 2022 09:01:10 +0800 Subject: [PATCH] started work on user screen --- godot/Wellbeing App.csproj | 6 ------ godot/Wellbeing App.sln | 19 ----------------- godot/button_user_save.gd | 25 ++++++++++++++++++++++ godot/main_screen.gd | 21 ++++++++++++++++++ godot/project.godot | 4 ++++ godot/start_menu.gd | 16 ++++++++++++++ godot/start_screen.cs | 21 ------------------ godot/start_screen.tscn | 26 ++++++++++++++++++----- godot/{initialising.gd => user_values.gd} | 5 ++--- 9 files changed, 89 insertions(+), 54 deletions(-) delete mode 100644 godot/Wellbeing App.csproj delete mode 100644 godot/Wellbeing App.sln create mode 100644 godot/button_user_save.gd create mode 100644 godot/main_screen.gd create mode 100644 godot/start_menu.gd delete mode 100644 godot/start_screen.cs rename godot/{initialising.gd => user_values.gd} (78%) diff --git a/godot/Wellbeing App.csproj b/godot/Wellbeing App.csproj deleted file mode 100644 index cfa7992..0000000 --- a/godot/Wellbeing App.csproj +++ /dev/null @@ -1,6 +0,0 @@ - - - net472 - WellbeingApp - - \ No newline at end of file diff --git a/godot/Wellbeing App.sln b/godot/Wellbeing App.sln deleted file mode 100644 index 1c8d276..0000000 --- a/godot/Wellbeing App.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wellbeing App", "Wellbeing App.csproj", "{D7C38C84-2B97-4842-B86C-55CA66888418}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - ExportDebug|Any CPU = ExportDebug|Any CPU - ExportRelease|Any CPU = ExportRelease|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D7C38C84-2B97-4842-B86C-55CA66888418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7C38C84-2B97-4842-B86C-55CA66888418}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7C38C84-2B97-4842-B86C-55CA66888418}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU - {D7C38C84-2B97-4842-B86C-55CA66888418}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU - {D7C38C84-2B97-4842-B86C-55CA66888418}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU - {D7C38C84-2B97-4842-B86C-55CA66888418}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU - EndGlobalSection -EndGlobal diff --git a/godot/button_user_save.gd b/godot/button_user_save.gd new file mode 100644 index 0000000..ef5fe3b --- /dev/null +++ b/godot/button_user_save.gd @@ -0,0 +1,25 @@ +extends Button + +var config = ConfigFile.new() + +onready var user_name = get_node("user_details/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(): + +# Store some values. + config.set_value("User", "player_name", "Steve") + config.set_value("Player1", "best_score", 10) + config.set_value("Player2", "player_name", "V3geta") + config.set_value("Player2", "best_score", 9001) + +# Save it to a file (overwrite if already exists). + config.save("user://user.ini") diff --git a/godot/main_screen.gd b/godot/main_screen.gd new file mode 100644 index 0000000..290d741 --- /dev/null +++ b/godot/main_screen.gd @@ -0,0 +1,21 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +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. +func _ready(): + # Set starting state visibility + + main_screen.visible = true + start_menu.visible = true + user_menu.visible = false + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/godot/project.godot b/godot/project.godot index ef35eaa..bf158fb 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -14,6 +14,10 @@ config/name="Wellbeing App" run/main_scene="res://start_screen.tscn" config/icon="res://icon.png" +[autoload] + +UserValues="*res://user_values.gd" + [gui] theme/use_hidpi=true diff --git a/godot/start_menu.gd b/godot/start_menu.gd new file mode 100644 index 0000000..196556a --- /dev/null +++ b/godot/start_menu.gd @@ -0,0 +1,16 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +onready var user_info = get_node("/root/UserValues") + +# Called when the node enters the scene tree for the first time. +func _ready(): + $welcome_title.text = "Good morning " + user_info.user_first_name + "!" + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/godot/start_screen.cs b/godot/start_screen.cs deleted file mode 100644 index b5adc9e..0000000 --- a/godot/start_screen.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Godot; -using System; - -public class start_screen : Node2D -{ - // Declare member variables here. Examples: - // private int a = 2; - // private string b = "text"; - - // Called when the node enters the scene tree for the first time. - public override void _Ready() - { - - } - -// // Called every frame. 'delta' is the elapsed time since the previous frame. -// public override void _Process(float delta) -// { -// -// } -} diff --git a/godot/start_screen.tscn b/godot/start_screen.tscn index 65dc469..75755d6 100644 --- a/godot/start_screen.tscn +++ b/godot/start_screen.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] -[ext_resource path="res://start_screen.cs" type="Script" id=1] +[ext_resource path="res://main_screen.gd" type="Script" id=1] [ext_resource path="res://button_open_github.gd" type="Script" id=2] [ext_resource path="res://button_email_feedback.gd" type="Script" id=3] -[ext_resource path="res://initialising.gd" type="Script" id=4] +[ext_resource path="res://start_menu.gd" type="Script" id=4] [ext_resource path="res://button_name.gd" type="Script" id=5] +[ext_resource path="res://button_user_save.gd" type="Script" id=6] [node name="main_screen" type="Node2D"] script = ExtResource( 1 ) @@ -13,6 +14,7 @@ __meta__ = { } [node name="start_menu" type="Node2D" parent="."] +visible = false script = ExtResource( 4 ) [node name="button_daily_action" type="Button" parent="start_menu"] @@ -56,15 +58,29 @@ text = "Name" script = ExtResource( 5 ) [node name="user_details" type="Node2D" parent="."] -visible = false -[node name="Button" type="Button" parent="user_details"] +[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"] +margin_left = 540.0 +margin_top = 280.0 +margin_right = 615.0 +margin_bottom = 317.0 +text = "Save" +script = ExtResource( 6 ) + +[node name="textbox_user_name" type="LineEdit" parent="user_details"] +margin_left = 244.0 +margin_top = 205.0 +margin_right = 794.0 +margin_bottom = 250.0 + [connection signal="pressed" from="start_menu/button_open_github" to="start_menu/button_open_github" method="_on_button_open_github_pressed"] [connection signal="pressed" from="start_menu/button_email_feedback" to="start_menu/button_email_feedback" method="_on_button_email_feedback_pressed"] [connection signal="pressed" from="start_menu/button_name" to="start_menu/button_name" method="_on_button_name_pressed"] +[connection signal="pressed" from="user_details/button_user_save" to="user_details/button_user_save" method="_on_button_user_save_pressed"] diff --git a/godot/initialising.gd b/godot/user_values.gd similarity index 78% rename from godot/initialising.gd rename to godot/user_values.gd index 9f8f6cb..db11be9 100644 --- a/godot/initialising.gd +++ b/godot/user_values.gd @@ -1,4 +1,4 @@ -extends Node2D +extends Node # Declare member variables here. Examples: @@ -6,10 +6,9 @@ extends Node2D # var b = "text" var user_first_name = "No name" - # Called when the node enters the scene tree for the first time. func _ready(): - $welcome_title.text = "Good morning " + user_first_name + "!" + pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame.