From 9ae215ba24e9fa5dae0cb83504e1b17f52fe9d91 Mon Sep 17 00:00:00 2001 From: Jaap Marsman Date: Sun, 6 Nov 2022 16:30:17 +0800 Subject: [PATCH] continued work on version checker --- godot/global_ints.gd | 3 +++ godot/main_screen.gd | 12 +++++++++++- godot/main_screen.tscn | 4 ++++ version_info.csv | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 version_info.csv diff --git a/godot/global_ints.gd b/godot/global_ints.gd index 1b087e0..55828e2 100644 --- a/godot/global_ints.gd +++ b/godot/global_ints.gd @@ -3,6 +3,9 @@ extends Node var date var ddmmyyyy +var web_release_version = 0 +var release_version = 1 + var total_observed_time : int var timer_duration : int = 6 diff --git a/godot/main_screen.gd b/godot/main_screen.gd index ce6e1f4..9dabda8 100644 --- a/godot/main_screen.gd +++ b/godot/main_screen.gd @@ -6,6 +6,7 @@ var check_time_var : int var ddmmyyyy : String var date +var csv_url = "https://raw.githubusercontent.com/hobbesjaap/wellbeingapp/main/version_info.csv" onready var date_time_display = $"%CurrentTime" onready var global_ints = $"/root/GlobalInts" @@ -15,8 +16,17 @@ func check_for_updates(): var os_check : String os_check = OS.get_name() print(os_check) - if os_check == "X11" and "Windows" and "Mac": + if os_check == "X11" and "Windows" and "OSX": print("We're on desktop. So let's check for updates!") + $"%HTTPRequest".request(csv_url) + +func _on_HTTPRequest_request_completed(_result, _response_code, _headers, body): + var json = JSON.parse(body.get_string_from_utf8()) + global_ints.web_release_version = json.result + if global_ints.web_release_version > global_ints.release_version: + print("There's an update!") + elif global_ints.web_release_version == global_ints.release_version: + print("There is no update!") func refresh_descriptors(): $"%1Acronym".text = global_ints.one_acronym diff --git a/godot/main_screen.tscn b/godot/main_screen.tscn index ae584aa..4e69f53 100644 --- a/godot/main_screen.tscn +++ b/godot/main_screen.tscn @@ -66,6 +66,9 @@ __meta__ = { "_edit_lock_": true } +[node name="HTTPRequest" type="HTTPRequest" parent="."] +unique_name_in_owner = true + [node name="ClassroomPhoto" type="Sprite" parent="."] position = Vector2( 639.9, 201.694 ) scale = Vector2( 0.665729, 0.665729 ) @@ -1192,6 +1195,7 @@ margin_bottom = 146.0 custom_fonts/font = SubResource( 12 ) text = "Item5" +[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] [connection signal="button_down" from="StartScreen/InstructionPanel/MinuteBox/MinuteMinus" to="." method="_on_MinuteMinus_button_down"] [connection signal="pressed" from="StartScreen/InstructionPanel/MinuteBox/MinuteMinus" to="." method="_on_MinuteMinus_pressed"] [connection signal="pressed" from="StartScreen/InstructionPanel/MinuteBox/MinutePlus" to="." method="_on_MinutePlus_pressed"] diff --git a/version_info.csv b/version_info.csv new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/version_info.csv @@ -0,0 +1 @@ +1 \ No newline at end of file