mirror of
https://github.com/hobbesjaap/wellbeingapp.git
synced 2024-11-08 11:42:59 +00:00
refactoring node control into separate script + cleared out warnings and errors
This commit is contained in:
parent
a523b71515
commit
daa2fcaa70
@ -18,4 +18,4 @@ func _ready():
|
||||
|
||||
func _on_button_email_feedback_pressed():
|
||||
# warning-ignore:return_value_discarded
|
||||
OS.shell_open("mailto:feedback@jaapmarsman.com")
|
||||
var _error = OS.shell_open("mailto:feedback@jaapmarsman.com")
|
||||
|
@ -5,9 +5,8 @@ extends Button
|
||||
|
||||
# referencing nodes for menu switching
|
||||
|
||||
onready var start_menu = get_node("/root/main_screen/start_menu")
|
||||
onready var user_details = get_node("/root/main_screen/user_details")
|
||||
|
||||
onready var node_variables = get_node("/root/NodeVariables")
|
||||
onready var ui_control = get_node("/root/UiControl")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@ -21,6 +20,5 @@ func _ready():
|
||||
# makes the start menu disappear and the user menu appear
|
||||
|
||||
func _on_button_name_pressed():
|
||||
start_menu.visible = false
|
||||
user_details.visible = true
|
||||
ui_control.show_user_menu()
|
||||
|
||||
|
@ -5,7 +5,6 @@ extends Button
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
#func _ready():
|
||||
# pass
|
||||
@ -16,4 +15,4 @@ extends Button
|
||||
|
||||
|
||||
func _on_button_open_github_pressed():
|
||||
OS.shell_open("https://github.com/hobbesjaap/wellbeingapp")
|
||||
var _error = OS.shell_open("https://github.com/hobbesjaap/wellbeingapp")
|
||||
|
@ -2,11 +2,9 @@ extends Button
|
||||
|
||||
var config = ConfigFile.new()
|
||||
|
||||
onready var user_name = get_node("%textbox_user_name")
|
||||
onready var node_variables = get_node("/root/NodeVariables")
|
||||
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")
|
||||
onready var user_name = get_node("%textbox_user_name")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@ -35,9 +33,9 @@ func _on_button_user_save_pressed():
|
||||
|
||||
config.save("user://user.ini")
|
||||
|
||||
main_screen.visible = true
|
||||
start_menu.visible = true
|
||||
user_menu.visible = false
|
||||
node_variables.main_screen.visible = true
|
||||
node_variables.start_menu.visible = true
|
||||
node_variables.user_menu.visible = false
|
||||
|
||||
# Need to do a "This thing can't be empty" code
|
||||
# Most likely here. A if .text = null, then,
|
||||
|
@ -1,8 +1,8 @@
|
||||
extends CanvasLayer
|
||||
|
||||
onready var ui_control = get_node("/root/UiControl")
|
||||
onready var user_name = get_node("%textbox_user_name")
|
||||
|
||||
onready var node_variables = get_node("/root/NodeVariables")
|
||||
onready var ui_control = get_node("/root/UiControl")
|
||||
onready var user_info = get_node("/root/UserValues")
|
||||
|
||||
var config = ConfigFile.new()
|
||||
@ -23,7 +23,7 @@ func _ready():
|
||||
|
||||
# define variables from ini file
|
||||
user_info.user_first_name = config.get_value("User", "user_name")
|
||||
user_name.text = user_info.user_first_name
|
||||
node_variables.user_name.text = user_info.user_first_name
|
||||
|
||||
# Iterate over all sections.
|
||||
# for player in config.get_sections():
|
||||
|
17
godot/node_variables.gd
Normal file
17
godot/node_variables.gd
Normal file
@ -0,0 +1,17 @@
|
||||
extends Node
|
||||
|
||||
|
||||
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 user_menu = get_node("/root/main_screen/UI/top_container/menus_container/user_details")
|
||||
onready var user_name = get_node("/root/main_screen/UI/top_container/menus_container/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
|
@ -20,6 +20,7 @@ config/icon="res://icon.png"
|
||||
UserValues="*res://user_values.gd"
|
||||
ProgramValues="*res://program_values.gd"
|
||||
UiControl="*res://ui_control.gd"
|
||||
NodeVariables="*res://node_variables.gd"
|
||||
|
||||
[display]
|
||||
|
||||
@ -27,7 +28,7 @@ window/size/width=1280
|
||||
window/size/height=720
|
||||
window/energy_saving/keep_screen_on=false
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep_height"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[gui]
|
||||
|
||||
|
@ -6,7 +6,7 @@ onready var program_info = get_node("/root/ProgramValues")
|
||||
|
||||
|
||||
func _ready():
|
||||
$HTTPRequest.connect("request_completed", self, "_on_request_completed")
|
||||
# $HTTPRequest.connect("request_completed", self, "_on_request_completed")
|
||||
$version_label.text = str(program_info.current_version)
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ func _on_button_update_check_pressed():
|
||||
$HTTPRequest.request("https://raw.githubusercontent.com/hobbesjaap/wellbeingapp/main/version_info.csv")
|
||||
|
||||
|
||||
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())
|
||||
program_info.web_release_version = json.result
|
||||
if program_info.web_release_version > program_info.release_version:
|
||||
|
102
godot/start_menu.tscn
Normal file
102
godot/start_menu.tscn
Normal file
@ -0,0 +1,102 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://start_menu.gd" type="Script" id=1]
|
||||
[ext_resource path="res://button_name.gd" type="Script" id=2]
|
||||
[ext_resource path="res://button_email_feedback.gd" type="Script" id=3]
|
||||
[ext_resource path="res://button_open_github.gd" type="Script" id=4]
|
||||
|
||||
[node name="start_menu" type="CanvasLayer"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = 53.0
|
||||
margin_right = -943.0
|
||||
margin_bottom = -540.0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="MarginContainer"]
|
||||
margin_right = 332.0
|
||||
margin_bottom = 127.0
|
||||
columns = 2
|
||||
|
||||
[node name="button_daily_action" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_right = 222.0
|
||||
margin_bottom = 37.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Daily Action"
|
||||
|
||||
[node name="button_open_github" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_left = 230.0
|
||||
margin_right = 332.0
|
||||
margin_bottom = 37.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "GitHub"
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="button_email_feedback" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_top = 45.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 82.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Feedback"
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="button_name" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_left = 230.0
|
||||
margin_top = 45.0
|
||||
margin_right = 332.0
|
||||
margin_bottom = 82.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Name"
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="button_update_check" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_top = 90.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 127.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Check for Updates"
|
||||
|
||||
[node name="button_journal" type="Button" parent="MarginContainer/GridContainer"]
|
||||
margin_left = 230.0
|
||||
margin_top = 90.0
|
||||
margin_right = 332.0
|
||||
margin_bottom = 127.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Journal"
|
||||
|
||||
[node name="welcome_title" type="RichTextLabel" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -185.0
|
||||
margin_top = 11.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 42.0
|
||||
text = "Good morning, Jaap!
|
||||
"
|
||||
scroll_active = false
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||
|
||||
[node name="version_label" type="Label" parent="."]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = -25.0
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 5.0
|
||||
text = "Version"
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/GridContainer/button_open_github" to="MarginContainer/GridContainer/button_open_github" method="_on_button_open_github_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/GridContainer/button_email_feedback" to="MarginContainer/GridContainer/button_email_feedback" method="_on_button_email_feedback_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/GridContainer/button_name" to="MarginContainer/GridContainer/button_name" method="_on_button_name_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/GridContainer/button_update_check" to="." method="_on_button_update_check_pressed"]
|
||||
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
|
@ -1,17 +1,16 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[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://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]
|
||||
[ext_resource path="res://icons/noun-running-fox-4332379.svg" type="Texture" id=7]
|
||||
[ext_resource path="res://user_details.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://start_menu.tscn" type="PackedScene" id=3]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.862745, 0.435294, 0.329412, 1 )
|
||||
corner_radius_bottom_right = 45
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.462745, 0.662745, 0.560784, 1 )
|
||||
|
||||
[node name="main_screen" type="CanvasLayer"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
@ -22,121 +21,27 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0.94902, 0.937255, 0.85098, 1 )
|
||||
|
||||
[node name="top_container" type="VBoxContainer" parent="UI"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="top_bar" type="Panel" parent="UI/top_container"]
|
||||
[node name="top_bar" type="Panel" parent="UI"]
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 50.0
|
||||
rect_min_size = Vector2( 0, 50 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
|
||||
[node name="Noun-running-fox-4332380" type="Sprite" parent="UI/top_container"]
|
||||
position = Vector2( 54, 25 )
|
||||
texture = ExtResource( 7 )
|
||||
|
||||
[node name="start_menu" type="CanvasLayer" parent="."]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="button_daily_action" type="Button" parent="start_menu"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -75.5
|
||||
margin_top = -48.0
|
||||
margin_right = 75.5
|
||||
margin_bottom = -11.0
|
||||
text = "Daily Action"
|
||||
|
||||
[node name="welcome_title" type="RichTextLabel" parent="start_menu"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -185.0
|
||||
margin_top = 11.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 42.0
|
||||
text = "Good morning, Jaap!
|
||||
"
|
||||
scroll_active = false
|
||||
|
||||
[node name="button_open_github" type="Button" parent="start_menu"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
[node name="top_container" type="VBoxContainer" parent="UI"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -100.0
|
||||
margin_top = -37.0
|
||||
text = "GitHub"
|
||||
script = ExtResource( 2 )
|
||||
margin_top = 52.0
|
||||
margin_bottom = -41.0
|
||||
|
||||
[node name="button_email_feedback" type="Button" parent="start_menu"]
|
||||
margin_left = 169.0
|
||||
margin_top = 137.0
|
||||
margin_right = 241.0
|
||||
margin_bottom = 157.0
|
||||
text = "Feedback"
|
||||
script = ExtResource( 3 )
|
||||
[node name="menus_container" type="VBoxContainer" parent="UI/top_container"]
|
||||
margin_right = 1280.0
|
||||
|
||||
[node name="button_name" type="Button" parent="start_menu"]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -138.0
|
||||
margin_top = 6.0
|
||||
margin_right = -48.0
|
||||
margin_bottom = 43.0
|
||||
text = "Name"
|
||||
script = ExtResource( 5 )
|
||||
[node name="start_menu" parent="UI/top_container/menus_container" instance=ExtResource( 3 )]
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="start_menu"]
|
||||
[node name="user_details" parent="UI/top_container/menus_container" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="button_update_check" type="Button" parent="start_menu"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -222.0
|
||||
margin_top = -37.0
|
||||
text = "Check for Updates"
|
||||
|
||||
[node name="version_label" type="Label" parent="start_menu"]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -25.0
|
||||
margin_right = 82.0
|
||||
text = "Version"
|
||||
|
||||
[node name="user_details" type="CanvasLayer" parent="."]
|
||||
visible = false
|
||||
|
||||
[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 = "OK"
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="textbox_user_name" type="LineEdit" parent="user_details"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 244.0
|
||||
margin_top = 205.0
|
||||
margin_right = 794.0
|
||||
margin_bottom = 250.0
|
||||
caret_blink = true
|
||||
caret_blink_speed = 0.5
|
||||
|
||||
[node name="button_birth_day" type="MenuButton" parent="user_details"]
|
||||
margin_left = 311.0
|
||||
margin_top = 367.0
|
||||
margin_right = 376.0
|
||||
margin_bottom = 404.0
|
||||
text = "Day"
|
||||
|
||||
[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="request_completed" from="start_menu/HTTPRequest" to="start_menu" method="_on_HTTPRequest_request_completed"]
|
||||
[connection signal="pressed" from="start_menu/button_update_check" to="start_menu" method="_on_button_update_check_pressed"]
|
||||
[connection signal="pressed" from="user_details/button_user_save" to="user_details/button_user_save" method="_on_button_user_save_pressed"]
|
||||
[node name="bottom_bar" type="Panel" parent="UI"]
|
||||
margin_top = 680.0
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 720.0
|
||||
custom_styles/panel = SubResource( 2 )
|
||||
|
@ -1,23 +1,21 @@
|
||||
extends Node
|
||||
|
||||
|
||||
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")
|
||||
onready var node_variables = get_node("/root/NodeVariables")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func show_start_menu():
|
||||
main_screen.visible = true
|
||||
start_menu.visible = true
|
||||
user_menu.visible = false
|
||||
node_variables.main_screen.visible = true
|
||||
node_variables.start_menu.visible = true
|
||||
node_variables.user_menu.visible = false
|
||||
|
||||
func show_user_menu():
|
||||
main_screen.visible = true
|
||||
start_menu.visible = false
|
||||
user_menu.visible = true
|
||||
node_variables.main_screen.visible = true
|
||||
node_variables.start_menu.visible = false
|
||||
node_variables.user_menu.visible = true
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
|
32
godot/user_details.tscn
Normal file
32
godot/user_details.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://button_user_save.gd" type="Script" id=1]
|
||||
|
||||
[node name="user_details" type="CanvasLayer"]
|
||||
|
||||
[node name="button_user_save" type="Button" parent="."]
|
||||
margin_left = 540.0
|
||||
margin_top = 280.0
|
||||
margin_right = 615.0
|
||||
margin_bottom = 317.0
|
||||
text = "OK"
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="textbox_user_name" type="LineEdit" parent="."]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 244.0
|
||||
margin_top = 205.0
|
||||
margin_right = 794.0
|
||||
margin_bottom = 250.0
|
||||
caret_blink = true
|
||||
caret_blink_speed = 0.5
|
||||
|
||||
[node name="button_birth_day" type="MenuButton" parent="."]
|
||||
margin_left = 311.0
|
||||
margin_top = 367.0
|
||||
margin_right = 376.0
|
||||
margin_bottom = 404.0
|
||||
focus_mode = 2
|
||||
text = "Day"
|
||||
|
||||
[connection signal="pressed" from="button_user_save" to="button_user_save" method="_on_button_user_save_pressed"]
|
Loading…
Reference in New Issue
Block a user