improved UI and created UI-related functions in separate singleton script

This commit is contained in:
Jaap Marsman 2022-08-09 15:17:54 +08:00
parent adf1875029
commit c510de61da
11 changed files with 123 additions and 40 deletions

View File

@ -0,0 +1,3 @@
[
{"id": "", "category": "", "title": "", "description": "", "picture_id": "", "audio_id": "", "language": ""}
]

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 100 100" x="0px" y="0px"><title>icons_animals_3</title><path d="M98.74,27.17a1,1,0,0,0-1.2-.91c-.06,0-6.49,1.31-8.32-1.94a8.4,8.4,0,0,0-4.74-3.61c-.69-3.77-5.93-8.35-6.57-8.89a1,1,0,0,0-1.63.57l-.41,2.08c-.59-.61-1-1-1.18-1.19A1,1,0,0,0,73,14v7.53a32.71,32.71,0,0,0-7.81,10.41c-6.79,1.57-33,7.1-33.26,7.16S10.38,44.75,3.41,66.29a1,1,0,0,0-.1.32A46.18,46.18,0,0,0,1.26,78.93a1,1,0,0,0,.82,1A5.92,5.92,0,0,0,3.14,80c4.63,0,11.51-4.76,17.36-11.38a1,1,0,0,0,0,.48L23.1,83.79a1,1,0,0,0,1,.82h7.58a1,1,0,0,0,1-1,6.66,6.66,0,0,0-3.5-5.28,32.76,32.76,0,0,1-2.05-6.55c.46-.41,1.08-1,1.64-1.56a77.7,77.7,0,0,0,4,8.12c1.22,1.83,1.15,5.25,1.15,5.28a1,1,0,0,0,1,1h7.78a1,1,0,0,0,1-1,5.06,5.06,0,0,0-3.91-5.52L36,71.83a10.64,10.64,0,0,1,1.23-2.47A25.71,25.71,0,0,0,48.85,60c3.47.4,7.37.58,9.21.65-.32,3.89-1.22,16-.49,18.67C58.38,82.28,59,83.9,59,84a1,1,0,0,0,.94.65h6.77a1,1,0,0,0,1-.86,5.07,5.07,0,0,0-3.06-5.48,32,32,0,0,1,.39-6l3.24,11.57a1,1,0,0,0,1,.73h8a1,1,0,0,0,1-1,5.16,5.16,0,0,0-3.09-4.79c-1.6-.64-2.24-2.95-2.76-4.8-.14-.49-.26-.95-.4-1.36-.45-1.36.26-7.35.83-10.91C75.93,55,85,37.48,90.8,36.09c3.8-.91,5.78-2.84,6.81-4.68a1,1,0,0,0,.15-.28A8.53,8.53,0,0,0,98.74,27.17Zm-2.4,2.32a3,3,0,0,1-.46-1l.76-.07A6.45,6.45,0,0,1,96.34,29.49Zm-18.45-15a20.46,20.46,0,0,1,4.32,5.6,16.78,16.78,0,0,0-2-.24,29.16,29.16,0,0,0-2.7-3.58ZM4.52,69.65l.57,1.25a1,1,0,0,0,1.23.53L10.55,70v2.6a1,1,0,0,0,.77,1l.86.2C8.78,76.4,5.57,78,3.3,78A45.94,45.94,0,0,1,4.52,69.65Zm31.61-2a1,1,0,0,0-.45.38,9.64,9.64,0,0,0-1.77,3.89,1,1,0,0,0,.14.61l4.24,7A1,1,0,0,0,39,80a3,3,0,0,1,2.61,2.58H35.87a11.58,11.58,0,0,0-1.46-5.42,80.77,80.77,0,0,1-4-8.09c3.49-.86,11.27-4.09,14-9.85.63.16,1.37.3,2.16.42A24.83,24.83,0,0,1,36.12,67.64Zm29.61,15H60.66c-.24-.72-.66-2-1.16-3.83-.56-2,.08-12.5.64-19a1,1,0,0,0-1-1.09c-.08,0-6.1-.17-10.76-.75h0a23.36,23.36,0,0,1-4.2-.81,1,1,0,0,0-1.26.6c-2.39,6.44-12.67,9.66-13.72,9.67H29a1,1,0,0,0-.27.05l-.08,0,0,0a1,1,0,0,0-.27.19l-.09.11a1,1,0,0,0-.09.11,26.48,26.48,0,0,1-2.83,2.78,1,1,0,0,0-.32.95c0,.23,1.16,5.65,2.55,8a1,1,0,0,0,.41.38,4.87,4.87,0,0,1,2.45,2.68h-5.5L22.53,69.29l3.39-3.57a1,1,0,0,0,.18-.26c.32-.66,2.64-5.62,2.82-9.59h0a7.45,7.45,0,0,0-.24-2.44c-.81-2.73,1.27-7.45,2.14-9a1,1,0,0,0-1.75-1c-.14.26-3.52,6.48-2.31,10.57a5.2,5.2,0,0,1,.16,1.58,53.41,53.41,0,0,1-12.79,16.6l-1.58-.37v-3.2a1,1,0,0,0-1.32-.95l-4.7,1.58L5.36,66.68c6.55-20.23,26.07-25.4,27-25.63.28-.06,27.87-5.88,33.77-7.28a1,1,0,0,0,.7-.6,29.42,29.42,0,0,1,6.63-9.34A1,1,0,0,0,74,24a1,1,0,0,0,1-1V16.46c1.87,2,4.25,4.94,4.55,6.7a1,1,0,0,0,1,.84h.17a1,1,0,0,0,.82-1.15,5.22,5.22,0,0,0-.22-.83c1.89.26,4.9,1,6.18,3.3s4,3,6.28,3.19L81,32a1,1,0,0,0-.67.61l-6,15.56a1,1,0,0,0,1.44,1.22l1.7-1c-1.73,3-3.25,5.86-4.4,8.16a3.63,3.63,0,0,1-1.9,1.35,10.48,10.48,0,0,0-3.83,2.3c-1.49,1.25-2.62,4-3.39,7a1,1,0,0,0-.17.69c-1.17,4.9-1.45,10.36-1,11.55a1,1,0,0,0,.68.59A2.82,2.82,0,0,1,65.73,82.62Zm-43.9-15.5c1.15-1.39,2.24-2.85,3.25-4.35-.27.67-.52,1.25-.73,1.69Zm52.6,13.59a2.84,2.84,0,0,1,1.68,1.91H70L65.88,67.89c.66-2.7,1.58-5.12,2.8-6.14A9.3,9.3,0,0,1,71.48,60L71,61.08a1,1,0,0,0-.08.25c-.26,1.61-1.52,9.75-.77,12,.13.38.25.81.37,1.26C71.09,76.74,71.92,79.7,74.43,80.71Zm15.9-46.56C87,35,83.14,39.56,79.77,44.76l-2.5,1.48L82,33.83l12.49-3.47a3.33,3.33,0,0,0,.8.92A8.74,8.74,0,0,1,90.33,34.15Z"></path><circle cx="83.55" cy="26.69" r="1.08"></circle></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 97 97" x="0px" y="0px"><title>Artboard 14</title><path d="M3.55,63.13l3.82-1a6.74,6.74,0,0,1,2.1-.23l8.65.38A8.92,8.92,0,0,0,22,61.53l4.75-2.05a9.94,9.94,0,0,1,4-.86,28.49,28.49,0,0,0,9.78-1.95,10.62,10.62,0,0,1,7.68.32,22,22,0,0,0,7.37,2,14.05,14.05,0,0,1,5.25,1.45,21.52,21.52,0,0,1,3.65,2.64c3.09,2.56,6.93,5.73,14.16,6.59l.23,0a2,2,0,0,0,.78-3.9c-2.58-1.09-6.17-2.77-7.64-4.83a25.84,25.84,0,0,1-2.34-3.58,13.9,13.9,0,0,0-4.47-5.33L65.11,52c-1.32-.56-2.36-1.86-3.27-4.11a11.84,11.84,0,0,0,8-.89,39.92,39.92,0,0,1,11.07-3.63,23.31,23.31,0,0,0,8.5-3,22.46,22.46,0,0,0,2.74-2l0,0a17.64,17.64,0,0,0,4-4.79,2.85,2.85,0,0,0-.09-3,3,3,0,0,0-2.79-1.36c-3.64.32-8.21-.17-14.42-1.54-9-1.44-14.93.57-18.74,6.34l-.06.1A26.73,26.73,0,0,1,57.72,38a10,10,0,0,1-8.3,4l-5-.11a10.25,10.25,0,0,1-4.54-1.18c-4.81-2.52-8.57-3.81-11.83-4a6.67,6.67,0,0,1-3.44-1.19A31.64,31.64,0,0,1,20,31.13a1.84,1.84,0,0,0-3.21,1.33l.09,2.06A2.09,2.09,0,0,1,16,36.35,16.71,16.71,0,0,0,12.29,40a12.5,12.5,0,0,1-3.17,3,2.48,2.48,0,0,0,.21,4.36c2.4,1.13,5.7,1,8.91.75a2.68,2.68,0,0,1,2.49,1.13,3,3,0,0,1-.06,3.09,6.7,6.7,0,0,1-6,3.5H9.88a8.88,8.88,0,0,0-3.76.83l-4.23,2a2.42,2.42,0,0,0,1.66,4.52ZM93.41,31.26a1,1,0,0,1,.94.46.86.86,0,0,1,0,.92,15.45,15.45,0,0,1-3.06,3.82l-1.69-.6.76-1.26a1,1,0,0,0,.07-.9,1,1,0,0,0-.69-.59l-1.63-.41.62-1.4A31,31,0,0,0,93.41,31.26ZM2.74,60.42l4.22-2a7,7,0,0,1,2.92-.64h4.79a8.69,8.69,0,0,0,7.78-4.6,4.9,4.9,0,0,0,0-5.07,4.63,4.63,0,0,0-4.35-2c-2.78.25-5.9.37-7.87-.56a.44.44,0,0,1-.26-.4.49.49,0,0,1,.23-.44,14.22,14.22,0,0,0,3.67-3.45A14.83,14.83,0,0,1,17.15,38a4.1,4.1,0,0,0,1.76-3.58l-.08-1.64a30.4,30.4,0,0,0,4.66,4.39,8.79,8.79,0,0,0,4.45,1.56c3,.22,6.49,1.43,11.05,3.83A12.23,12.23,0,0,0,44.41,44l5,.11a12,12,0,0,0,9.95-4.86,28.65,28.65,0,0,0,2.45-4.1c3.37-5.06,8.53-6.73,16.67-5.42a76.29,76.29,0,0,0,8.21,1.41L85.83,33a1,1,0,0,0,0,.84,1,1,0,0,0,.66.54l1.47.36-.69,1.15a1,1,0,0,0,.52,1.46l1.68.6q-.56.39-1.14.75a21.53,21.53,0,0,1-7.86,2.72,41.53,41.53,0,0,0-11.55,3.8,10,10,0,0,1-8.31.18,1,1,0,0,0-1.07.18,1,1,0,0,0-.28,1c.83,2.7,2.15,5.94,5,7.2A12.11,12.11,0,0,1,68,58.4a28.59,28.59,0,0,0,2.48,3.8c1.34,1.87,4,3.56,8.46,5.52-6.64-.79-10.08-3.64-13.12-6.15a23,23,0,0,0-4-2.89A16.17,16.17,0,0,0,55.88,57a19.69,19.69,0,0,1-6.79-1.88,12.75,12.75,0,0,0-5.06-1,12.33,12.33,0,0,0-4.07.68,27.05,27.05,0,0,1-9.11,1.84,11.84,11.84,0,0,0-4.86,1l-4.75,2a7,7,0,0,1-3,.56l-8.65-.38a9,9,0,0,0-2.72.3L3,61.2a.41.41,0,0,1-.41-.11.39.39,0,0,1-.11-.36A.4.4,0,0,1,2.74,60.42Z"></path><path d="M19,39h0a1.86,1.86,0,0,0-1.32.55A1,1,0,0,0,19,41a1,1,0,0,0,1.31-1.5A1.86,1.86,0,0,0,19,39Z"></path></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,12 +1,9 @@
extends Node2D
extends CanvasLayer
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 ui_control = get_node("/root/UiControl")
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")
@ -17,16 +14,12 @@ func _ready():
# otherwise set up new user data
if err != OK:
start_menu.visible = false
user_menu.visible = true
ui_control.show_user_menu()
else:
# Set starting state visibility
main_screen.visible = true
start_menu.visible = true
user_menu.visible = false
ui_control.show_start_menu()
# define variables from ini file
user_info.user_first_name = config.get_value("User", "user_name")

View File

@ -9,6 +9,10 @@ extends Node
var release_version = 1
var web_release_version = 0
var current_version = "Version 0.1"
func check_update():
pass
func _ready():
pass

View File

@ -12,12 +12,22 @@ config_version=4
config/name="Wellbeing App"
run/main_scene="res://start_screen.tscn"
run/low_processor_mode=true
config/icon="res://icon.png"
[autoload]
UserValues="*res://user_values.gd"
ProgramValues="*res://program_values.gd"
UiControl="*res://ui_control.gd"
[display]
window/size/width=1280
window/size/height=720
window/energy_saving/keep_screen_on=false
window/stretch/mode="2d"
window/stretch/aspect="keep_height"
[gui]

View File

@ -1,11 +1,13 @@
extends Node2D
extends CanvasLayer
onready var user_info = get_node("/root/UserValues")
onready var program_info = get_node("/root/ProgramValues")
func _ready():
$HTTPRequest.connect("request_completed", self, "_on_request_completed")
$version_label.text = str(program_info.current_version)
func _process(_delta):
@ -17,8 +19,9 @@ func _on_button_update_check_pressed():
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
#func _on_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:
print("There's an update!")
elif program_info.web_release_version == program_info.release_version:
print("There is no update!")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=9 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]
@ -6,37 +6,68 @@
[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]
[node name="main_screen" type="Node2D"]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.862745, 0.435294, 0.329412, 1 )
corner_radius_bottom_right = 45
[node name="main_screen" type="CanvasLayer"]
script = ExtResource( 1 )
__meta__ = {
"_edit_horizontal_guides_": [ ]
}
[node name="start_menu" type="Node2D" parent="."]
[node name="UI" type="CanvasLayer" parent="."]
[node name="background_light" type="ColorRect" parent="UI"]
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"]
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"]
margin_left = 51.0
margin_top = 75.0
margin_right = 140.0
margin_bottom = 95.0
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"]
margin_left = 19.0
margin_top = 22.0
margin_right = 1007.0
margin_bottom = 53.0
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"]
margin_left = 98.0
margin_top = 195.0
margin_right = 135.0
margin_bottom = 215.0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -100.0
margin_top = -37.0
text = "GitHub"
script = ExtResource( 2 )
@ -49,23 +80,34 @@ text = "Feedback"
script = ExtResource( 3 )
[node name="button_name" type="Button" parent="start_menu"]
margin_left = 905.0
margin_top = 19.0
margin_right = 995.0
margin_bottom = 56.0
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="HTTPRequest" type="HTTPRequest" parent="start_menu"]
[node name="button_update_check" type="Button" parent="start_menu"]
margin_left = 658.0
margin_top = 354.0
margin_right = 880.0
margin_bottom = 391.0
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="user_details" type="Node2D" parent="."]
[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"]
@ -82,6 +124,8 @@ 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

24
godot/ui_control.gd Normal file
View File

@ -0,0 +1,24 @@
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")
# 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
func show_user_menu():
main_screen.visible = true
start_menu.visible = false
user_menu.visible = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

BIN
notes/colour_scheme.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B