continued work on version checker

This commit is contained in:
Jaap Marsman 2022-11-06 16:30:17 +08:00
parent bbf9742334
commit 9ae215ba24
4 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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"]

1
version_info.csv Normal file
View File

@ -0,0 +1 @@
1
1 1