Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Update Checker #724

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ui_parts/display.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ unique_name_in_owner = true
disable_3d = true
handle_input_locally = false
gui_snap_controls_to_pixels = false
size = Vector2i(450, 2)
size = Vector2i(1024, 609)
size_2d_override_stretch = true
render_target_update_mode = 4
script = ExtResource("9_4xrk7")
Expand Down
12 changes: 7 additions & 5 deletions src/ui_parts/update_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ extends PanelContainer


func _ready() -> void:
status_label.text = "Current Version: " + ProjectSettings.get_setting("application/config/version")
status_label.text = "[center]Current Version: " + ProjectSettings.get_setting("application/config/version")

func _on_check_pressed() -> void:
check_button.disabled = true
status_label.text = "Checking..."
status_label.text = "[center]Checking..."

var err := http.request(
"https://api.github.com/repos/MewPurPur/GodSVG/releases",
Expand Down Expand Up @@ -54,11 +54,13 @@ _headers: PackedStringArray, body: PackedByteArray) -> void:
latest_url = release["html_url"]

var current_ver := ProjectSettings.get_setting("application/config/version") as String



if latest_ver == current_ver:
status_label.text = "No new version available."
status_label.text = "[center]No new version available."
else:
status_label.parse_bbcode("New version available! %s\n[url=%s]Open GitHub page[/url]" % [latest_ver, latest_url])
status_label.parse_bbcode("[center][url=%s]New version available![/url] %s" % [latest_ver, latest_url])
print(status_label.text)

check_button.disabled = false

Expand Down
66 changes: 35 additions & 31 deletions src/ui_parts/update_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
[gd_scene load_steps=4 format=3 uid="uid://dtyn8imbyo2rg"]
[gd_scene load_steps=5 format=3 uid="uid://dtyn8imbyo2rg"]

[ext_resource type="Script" path="res://src/ui_parts/update_menu.gd" id="1_up0ed"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xqary"]

[sub_resource type="LabelSettings" id="LabelSettings_h3pgq"]
font_size = 12
font_color = Color(0.6875, 0.6875, 0.6875, 1)

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_nqy1r"]

[node name="UpdateMenu" type="PanelContainer"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -2.0
offset_top = -2.0
offset_right = 2.0
offset_bottom = 2.0
anchors_preset = -1
anchor_left = 0.408203
anchor_top = 0.424219
anchor_right = 0.591797
anchor_bottom = 0.575781
offset_bottom = 1.52588e-05
grow_horizontal = 2
grow_vertical = 2
theme_type_variation = &"OverlayPanel"
theme_override_styles/panel = SubResource("StyleBoxEmpty_xqary")
script = ExtResource("1_up0ed")
metadata/_edit_use_anchors_ = true

[node name="HTTPRequest" type="HTTPRequest" parent="."]
unique_name_in_owner = true
Expand All @@ -32,53 +33,56 @@ timeout = 10.0
layout_mode = 2
theme_override_constants/separation = 12

[node name="Label" type="Label" parent="VBoxContainer"]
[node name="UpdateCheckPanelContainer" type="PanelContainer" parent="VBoxContainer"]
layout_mode = 2
theme_type_variation = &"OverlayPanel"

[node name="UpdateCheckVBox" type="VBoxContainer" parent="VBoxContainer/UpdateCheckPanelContainer"]
layout_mode = 2
theme_override_constants/separation = 8

[node name="Label" type="Label" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
layout_mode = 2
text = "Update Menu"
horizontal_alignment = 1

[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
layout_mode = 2
theme_type_variation = &"OverlayPanel"

[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer"]
[node name="Status" type="RichTextLabel" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 8
bbcode_enabled = true
fit_content = true
scroll_active = false
autowrap_mode = 0

[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
layout_mode = 2
theme_override_constants/separation = 2

[node name="Check" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer/VBoxContainer"]
[node name="Check" type="Button" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_mode = 0
mouse_default_cursor_shape = 2
text = "Check for Updates"

[node name="Hint" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/VBoxContainer"]
[node name="Hint" type="Label" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox/VBoxContainer"]
layout_mode = 2
text = "This will connect to the Internet."
label_settings = SubResource("LabelSettings_h3pgq")
horizontal_alignment = 1

[node name="IncludePrereleases" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer"]
[node name="IncludePrereleases" type="CheckBox" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxEmpty_nqy1r")
button_pressed = true
text = "Include Prereleases"

[node name="Status" type="RichTextLabel" parent="VBoxContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
fit_content = true
scroll_active = false
autowrap_mode = 0

[node name="Close" type="Button" parent="VBoxContainer"]
[node name="Close" type="Button" parent="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
Expand All @@ -87,6 +91,6 @@ mouse_default_cursor_shape = 2
text = "Close"

[connection signal="request_completed" from="HTTPRequest" to="." method="_on_request_completed"]
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/VBoxContainer/Check" to="." method="_on_check_pressed"]
[connection signal="meta_clicked" from="VBoxContainer/PanelContainer/VBoxContainer/Status" to="." method="_on_status_label_link_clicked"]
[connection signal="pressed" from="VBoxContainer/Close" to="." method="_on_close_pressed"]
[connection signal="meta_clicked" from="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox/Status" to="." method="_on_status_label_link_clicked"]
[connection signal="pressed" from="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox/VBoxContainer/Check" to="." method="_on_check_pressed"]
[connection signal="pressed" from="VBoxContainer/UpdateCheckPanelContainer/UpdateCheckVBox/Close" to="." method="_on_close_pressed"]