Update the game from inside it (#13)
"Version X is available" in the top bar is now a button that opens an Update popup: - Update and restart gets the download link from the server (the redirect is not followed, as the Gitea link needs no token), downloads the new game next to the running one with a progress bar, checks it (complete, and an MZ or ELF file), swaps it in and restarts. The quiz is saved first and continues. On Windows the running .exe is renamed to .old, put back if the swap fails, and deleted at the next start. - Download in browser opens the .exe, the Linux package, or the release page on other platforms. - From the editor, an unwritable folder or another platform, only the browser download is offered, with the reason. The message now fits between the tabs and the buttons in every theme; in Nord and Christmas it ran into Sync. The macOS export preset is removed, and the unused download_client_* functions are replaced by fetch_client_download_url. Closes #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c03c0e4efe
commit
f39865fffc
30 files changed
+2363
-354
No files matched your search
@@ -12,6 +12,7 @@
|
||||
[ext_resource type="PackedScene" path="res://statistics/StatisticsView.tscn" id="statistics_view_scene"]
|
||||
[ext_resource type="PackedScene" path="res://popups/SoundtrackStatsPopup.tscn" id="soundtrack_stats_popup_scene"]
|
||||
[ext_resource type="PackedScene" uid="uid://dldpeo5y3l5hq" path="res://popups/SettingsPopup.tscn" id="settings_popup_scene"]
|
||||
[ext_resource type="PackedScene" path="res://popups/UpdatePopup.tscn" id="update_popup_scene"]
|
||||
|
||||
[node name="MainWindow" type="Control" unique_id=407149696]
|
||||
layout_mode = 3
|
||||
@@ -109,3 +110,12 @@ offset_left = 610.0
|
||||
offset_top = 140.0
|
||||
offset_right = 610.0
|
||||
offset_bottom = 140.0
|
||||
|
||||
[node name="UpdatePopup" parent="." instance=ExtResource("update_popup_scene")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
offset_left = 640.0
|
||||
offset_top = 390.0
|
||||
offset_right = 640.0
|
||||
offset_bottom = 390.0
|
||||
+13
-5
@@ -40,19 +40,27 @@ theme_type_variation = &"HighlightLarge"
|
||||
text = "DEBUG"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="UpdateLabel" type="Label" parent="." unique_id=1959221258]
|
||||
[node name="UpdateBox" type="HBoxContainer" parent="." unique_id=1959221258]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_left = 1096.0
|
||||
offset_top = 12.0
|
||||
offset_right = 1432.0
|
||||
offset_bottom = 50.0
|
||||
mouse_filter = 1
|
||||
theme_type_variation = &"HighlightMedium"
|
||||
mouse_filter = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="UpdateButton" type="Button" parent="UpdateBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_type_variation = &"UpdateButton"
|
||||
text = "Version 0.0.0 is available"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
text_overrun_behavior = 3
|
||||
clip_text = true
|
||||
alignment = 2
|
||||
|
||||
[node name="OfflineLabel" type="Label" parent="." unique_id=1959221259]
|
||||
visible = false
|
||||
|
||||
+7
-1
@@ -20,6 +20,7 @@ var popup_backdrop: PopupBackdrop
|
||||
@onready var about_popup: AboutPopup = %AboutPopup
|
||||
@onready var log_popup: LogPopup = %LogPopup
|
||||
@onready var settings_popup: SettingsPopup = %SettingsPopup
|
||||
@onready var update_popup: UpdatePopup = %UpdatePopup
|
||||
@onready var statistics_view: StatisticsView = $StatisticsView
|
||||
@onready var soundtrack_stats_popup: SoundtrackStatsPopup = $SoundtrackStatsPopup
|
||||
|
||||
@@ -37,6 +38,8 @@ func _ready() -> void:
|
||||
top_bar.about_pressed.connect(show_about)
|
||||
top_bar.qr_pressed.connect(show_qr)
|
||||
top_bar.settings_pressed.connect(settings_popup.open)
|
||||
top_bar.update_pressed.connect(update_popup.show_update)
|
||||
update_popup.restarting.connect(quiz.save_now)
|
||||
settings_popup.server_changed.connect(quiz.on_server_changed)
|
||||
settings_popup.characters_changed.connect(quiz.character_select_popup.load_characters)
|
||||
settings_popup.clear_cache_requested.connect(clear_cache)
|
||||
@@ -58,6 +61,9 @@ func _ready() -> void:
|
||||
func(_soundtrack: Soundtrack) -> void: search_popup.get_list_of_soundtracks())
|
||||
soundtrack_stats_popup.cover_changed.connect(statistics_view.update_cover)
|
||||
|
||||
# An update leaves the old version next to the game, to delete once the new one runs
|
||||
if !OS.has_feature("editor"):
|
||||
Updater.remove_old_files(OS.get_executable_path())
|
||||
# A saved quiz may have been played from a music folder
|
||||
top_bar.update_offline_state()
|
||||
search_popup.get_list_of_soundtracks()
|
||||
@@ -110,7 +116,7 @@ func _input(event: InputEvent) -> void:
|
||||
|
||||
func _popups() -> Array[BasePopup]:
|
||||
return [search_popup, sync_popup, qr_popup, shortcuts_popup, about_popup, log_popup,
|
||||
soundtrack_stats_popup, settings_popup]
|
||||
soundtrack_stats_popup, settings_popup, update_popup]
|
||||
|
||||
|
||||
# How many songs to download ahead can be changed in the settings. Waiting until the
|
||||
|
||||
+30
-6
@@ -16,10 +16,19 @@ signal about_pressed
|
||||
signal qr_pressed
|
||||
## Emitted when a tab is chosen: [code]&"quiz"[/code] or [code]&"statistics"[/code].
|
||||
signal tab_selected(tab: StringName)
|
||||
## Emitted when "Version X is available" is clicked, with the newest version.
|
||||
signal update_pressed(latest_version: String)
|
||||
|
||||
## Space between the message in the middle and the tabs and buttons around it.
|
||||
const MIDDLE_GAP: float = 16.0
|
||||
|
||||
## The newest release the server knows of, once asked, or empty.
|
||||
var latest_version: String = ""
|
||||
|
||||
@onready var sync_button: Button = %SyncButton
|
||||
@onready var debug_label: Label = $DebugLabel
|
||||
@onready var update_label: Label = $UpdateLabel
|
||||
@onready var update_box: HBoxContainer = $UpdateBox
|
||||
@onready var update_button: Button = %UpdateButton
|
||||
@onready var offline_label: Label = $OfflineLabel
|
||||
@onready var qr_button: Button = %QRButton
|
||||
@onready var quiz_tab: Button = %QuizTab
|
||||
@@ -36,6 +45,11 @@ func _ready() -> void:
|
||||
qr_button.pressed.connect(qr_pressed.emit)
|
||||
quiz_tab.pressed.connect(tab_selected.emit.bind(&"quiz"))
|
||||
statistics_tab.pressed.connect(tab_selected.emit.bind(&"statistics"))
|
||||
update_button.pressed.connect(func() -> void: update_pressed.emit(latest_version))
|
||||
# The buttons are as wide as the theme makes them, so the message fits between
|
||||
statistics_tab.item_rect_changed.connect(_fit_middle)
|
||||
sync_button.item_rect_changed.connect(_fit_middle)
|
||||
_fit_middle()
|
||||
update_offline_state()
|
||||
check_for_update()
|
||||
|
||||
@@ -51,14 +65,14 @@ func update_offline_state() -> void:
|
||||
if offline:
|
||||
offline_label.text = "Offline: " + Settings.music_folder.display_name()
|
||||
offline_label.tooltip_text = Settings.music_folder.path
|
||||
update_label.visible = false
|
||||
update_box.visible = false
|
||||
|
||||
|
||||
## Asks the server for the newest MusicPlayer release and tells the user when it is newer
|
||||
## than this one. Not asked while a music folder is used.
|
||||
func check_for_update() -> void:
|
||||
if Settings.is_offline():
|
||||
update_label.visible = false
|
||||
update_box.visible = false
|
||||
return
|
||||
MusicServerClient.fetch_latest_client_version(show_latest_version)
|
||||
|
||||
@@ -68,10 +82,20 @@ func check_for_update() -> void:
|
||||
func show_latest_version(latest: Variant) -> void:
|
||||
var newer: bool = latest is String && is_newer_version(latest, Settings.version) \
|
||||
&& !Settings.is_offline()
|
||||
update_label.visible = newer
|
||||
update_box.visible = newer
|
||||
if newer:
|
||||
update_label.text = "Version %s is available" % latest
|
||||
update_label.tooltip_text = "You have %s" % Settings.version
|
||||
latest_version = latest
|
||||
update_button.text = "Version %s is available" % latest
|
||||
update_button.tooltip_text = "You have %s. Click to update." % Settings.version
|
||||
|
||||
|
||||
# Fits "Version X is available" and the offline label between the tabs and the buttons
|
||||
func _fit_middle() -> void:
|
||||
var left: float = statistics_tab.position.x + statistics_tab.size.x + MIDDLE_GAP
|
||||
var right: float = sync_button.global_position.x - global_position.x - MIDDLE_GAP
|
||||
for middle: Control in [update_box, offline_label]:
|
||||
middle.position.x = left
|
||||
middle.size.x = maxf(right - left, 0.0)
|
||||
|
||||
|
||||
## Whether version [param latest] is newer than [param current], comparing numbers such as
|
||||
|
||||
Reference in new issue
Block a user