Update the game from inside it (#13)
Build / test (push) Successful in 1m53s
Build / build (push) Successful in 1m15s

"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:
SansanandClaude Opus 5.5 committed 2026-10-15 21:23:26 +02:00
1 parent c03c0e4efe
commit f39865fffc
30 files changed
+2363 -354

No files matched your search

+27 -9
View File
@@ -10,7 +10,7 @@ func before_test() -> void:
func test_no_message_when_this_is_the_newest_version() -> void:
assert_bool(_top_bar.update_label.visible).is_false()
assert_bool(_top_bar.update_box.visible).is_false()
assert_int(_server.count("/download")).is_equal(1)
@@ -19,9 +19,9 @@ func test_newer_release_shows_a_message() -> void:
_top_bar.check_for_update()
assert_bool(_top_bar.update_label.is_visible_in_tree()).is_true()
assert_str(_top_bar.update_label.text).is_equal("Version 99.0.0 is available")
assert_str(_top_bar.update_label.tooltip_text).contains(Settings.version)
assert_bool(_top_bar.update_button.is_visible_in_tree()).is_true()
assert_str(_top_bar.update_button.text).is_equal("Version 99.0.0 is available")
assert_str(_top_bar.update_button.tooltip_text).contains(Settings.version)
func test_message_fits_between_the_tabs_and_the_buttons() -> void:
@@ -29,8 +29,10 @@ func test_message_fits_between_the_tabs_and_the_buttons() -> void:
_top_bar.check_for_update()
await _runner.simulate_frames(1)
var label: Rect2 = _top_bar.update_label.get_global_rect()
var text_width: float = _top_bar.update_label.get_minimum_size().x
var label: Rect2 = _top_bar.update_box.get_global_rect()
var button: Button = _top_bar.update_button
var text_width: float = button.get_theme_font(&"font").get_string_size(button.text,
HORIZONTAL_ALIGNMENT_LEFT, -1, button.get_theme_font_size(&"font_size")).x
assert_float(text_width).is_less_equal(label.size.x)
assert_float(label.position.x).is_greater(
(_top_bar.get_node("%StatisticsTab") as Control).get_global_rect().end.x)
@@ -44,7 +46,7 @@ func test_message_stays_on_the_statistics_tab() -> void:
_window.show_tab(&"statistics")
assert_bool(_top_bar.update_label.is_visible_in_tree()).is_true()
assert_bool(_top_bar.update_button.is_visible_in_tree()).is_true()
func test_server_change_checks_again() -> void:
@@ -52,7 +54,7 @@ func test_server_change_checks_again() -> void:
_quiz.on_server_changed()
assert_bool(_top_bar.update_label.visible).is_true()
assert_bool(_top_bar.update_box.visible).is_true()
func test_failed_check_shows_nothing() -> void:
@@ -60,7 +62,7 @@ func test_failed_check_shows_nothing() -> void:
_top_bar.check_for_update()
assert_bool(_top_bar.update_label.visible).is_false()
assert_bool(_top_bar.update_box.visible).is_false()
func test_version_comparison() -> void:
@@ -72,3 +74,19 @@ func test_version_comparison() -> void:
assert_bool(TopBar.is_newer_version("2.0", "2.0.0")).is_false()
assert_bool(TopBar.is_newer_version("1.9.0", "2.0.0")).is_false()
assert_bool(TopBar.is_newer_version("1.9.9", "1.10.0")).is_false()
@warning_ignore("unused_parameter")
func test_message_stays_clear_of_the_buttons_in_every_theme(theme_id: String,
test_parameters: Array = [["classic"], ["original_web"], ["nord"], ["christmas"]]) -> void:
Settings.apply_theme(theme_id)
_server.respond_json("/download", "99.10.10")
_top_bar.check_for_update()
await _runner.simulate_frames(2)
var message: Rect2 = _top_bar.update_box.get_global_rect()
assert_float(message.end.x).is_less(
(_top_bar.get_node("%SyncButton") as Control).get_global_rect().position.x)
assert_float(message.position.x).is_greater(
(_top_bar.get_node("%StatisticsTab") as Control).get_global_rect().end.x)
Settings.apply_theme("classic")