From a4522b93d1bf86a6d37a81afc1c59ddfe299f0eb Mon Sep 17 00:00:00 2001 From: Jaap Marsman Date: Sun, 6 Nov 2022 20:14:59 +0800 Subject: [PATCH] Added basic updater info --- godot/main_screen.gd | 20 ++++++++++++++++---- godot/main_screen.tscn | 9 +++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/godot/main_screen.gd b/godot/main_screen.gd index ff0b13a..152db31 100644 --- a/godot/main_screen.gd +++ b/godot/main_screen.gd @@ -3,17 +3,18 @@ extends CanvasLayer var date_time var check_time_var : int - var ddmmyyyy : String var date var csv_url = "https://raw.githubusercontent.com/hobbesjaap/time-sampling-form/main/version_info.csv" var update_text_url = "https://raw.githubusercontent.com/hobbesjaap/time-sampling-form/main/updater/update_text.md" var update_text : String + onready var date_time_display = $"%CurrentTime" onready var global_ints = $"/root/GlobalInts" onready var minute_label = $"StartScreen/InstructionPanel/MinuteBox/MinuteLabel" + func check_for_updates(): var os_check : String os_check = OS.get_name() @@ -23,6 +24,7 @@ func check_for_updates(): $"%HTTPRequest".request(csv_url) $"%HTTPRequest2".request(update_text_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 @@ -30,12 +32,14 @@ func _on_HTTPRequest_request_completed(_result, _response_code, _headers, body): print("There's an update!") $"%UpdatePanel".visible = true $"%UpdateText".text = str(update_text) + $"%UpdateIntro".text = str("You are currently using version ",global_ints.release_version,". The latest version available is ",global_ints.web_release_version,".") func _on_HTTPRequest2_request_completed(_result, _response_code, _headers, body): - var json = JSON.parse(body.get_string_from_utf8()) - update_text = str(json.result) - +# Need to find a way to load .txt file contents from a URL into a label. This to show what the update changes are. +# var json = JSON.parse(body.get_string_from_utf8()) +# update_text = str(json.result) + pass func refresh_descriptors(): @@ -171,3 +175,11 @@ func _on_MinuteMinus_button_down(): # global_ints.observation_minutes -= 1 # minute_label.text = str(global_ints.observation_minutes) pass + + +func _on_GoToUpdate_pressed(): + var _error = OS.shell_open("https://github.com/hobbesjaap/time-sampling-form/releases") + + +func _on_IgnoreUpdate_pressed(): + $"%UpdatePanel".visible = false diff --git a/godot/main_screen.tscn b/godot/main_screen.tscn index 2639076..05343aa 100644 --- a/godot/main_screen.tscn +++ b/godot/main_screen.tscn @@ -578,7 +578,6 @@ text = "OK" [node name="UpdatePanel" type="Panel" parent="StartScreen"] unique_name_in_owner = true -visible = false anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 @@ -621,9 +620,10 @@ margin_right = 498.0 margin_bottom = 60.0 size_flags_horizontal = 3 theme = ExtResource( 1 ) -text = "Download Update" +text = "Go to Download Page" [node name="IgnoreUpdate" type="Button" parent="StartScreen/UpdatePanel/BottomButtons"] +unique_name_in_owner = true margin_left = 502.0 margin_right = 1000.0 margin_bottom = 60.0 @@ -632,6 +632,7 @@ theme = ExtResource( 1 ) text = "Ignore Update" [node name="UpdateIntro" type="Label" parent="StartScreen/UpdatePanel"] +unique_name_in_owner = true margin_left = 33.0 margin_top = 107.0 margin_right = 1249.0 @@ -1283,8 +1284,8 @@ text = "Item5" [connection signal="pressed" from="StartScreen/InstructionPanel/BottomButtons/Start" to="." method="_on_Start_pressed"] [connection signal="pressed" from="StartScreen/NameChangePanel/NameContainer/OkButton" to="StartScreen/NameChangePanel" method="_on_OkButton_pressed"] [connection signal="pressed" from="StartScreen/InstructionScreen/InstructionContainer/InsOkButton" to="." method="_on_InsOkButton_pressed"] -[connection signal="pressed" from="StartScreen/UpdatePanel/BottomButtons/GoToUpdate" to="." method="_on_PupilName_pressed"] -[connection signal="pressed" from="StartScreen/UpdatePanel/BottomButtons/IgnoreUpdate" to="." method="_on_Start_pressed"] +[connection signal="pressed" from="StartScreen/UpdatePanel/BottomButtons/GoToUpdate" to="." method="_on_GoToUpdate_pressed"] +[connection signal="pressed" from="StartScreen/UpdatePanel/BottomButtons/IgnoreUpdate" to="." method="_on_IgnoreUpdate_pressed"] [connection signal="pressed" from="EditScreen/Panel/CancelButton" to="EditScreen" method="_on_CancelButton_pressed"] [connection signal="pressed" from="EditScreen/Panel/OKButton" to="EditScreen" method="_on_OKButton_pressed"] [connection signal="pressed" from="EditScreen/Panel/ClearAll" to="EditScreen" method="_on_ClearAll_pressed"]