Bug fixes and updater improvements

* Added feedback hints when clicking 'check for updates' button in the main menu
* Updated methods to reflect the new changes
* Fixed updater crashing with `u` parameter due to explicit no-parameter screen definition, while renpy expects the (lax) implicit definition
* Fixed server url
This commit is contained in:
LoafyLemon 2023-07-06 00:23:00 +01:00
parent c42306f320
commit 3a853c8e60
2 changed files with 30 additions and 11 deletions

View File

@ -249,16 +249,17 @@ screen navigation(title=None):
transclude transclude
null height 14 # Half button height null height 28 # Half button height
if main_menu: if main_menu:
if not title: if not title:
if not renpy.mobile: if not renpy.mobile:
if UPDATE_VER: if version_float(UPDATE_VER) < version_float():
textbutton "Install updates" action InstallUpdates() style_prefix "update_available" sensitive (not prerelease) textbutton "Install updates" action InstallUpdates() style_prefix "update_available" sensitive (not prerelease)
else: else:
textbutton "Check for updates" action CheckUpdates(300) sensitive (not prerelease) textbutton "Check for updates" action CheckUpdates(300) sensitive (not prerelease)
text "[UPDATE_HINT]" size 8 color "#fff" xalign 0.5
if show_quick_start: if show_quick_start:
textbutton _("Quick Start") action Start("start_quick") sensitive is_sensitive textbutton _("Quick Start") action Start("start_quick") sensitive is_sensitive

View File

@ -1,8 +1,9 @@
init python: init python:
import requests import requests
UPDATE_URL = bytes.fromhex("687474703a2f2f757064617465732e73696c76657273747564696f67616d65732e6f72672f757064617465732e6a736f6e").decode() UPDATE_URL = bytes.fromhex("687474703a2f2f757064617465732e73696c76657273747564696f67616d65732e6f72672f6173736574732f757064617465732e6a736f6e").decode()
UPDATE_VER = "" UPDATE_VER = None
UPDATE_HINT = ""
@renpy.pure @renpy.pure
class CheckUpdates(Action): class CheckUpdates(Action):
@ -19,12 +20,18 @@ init python:
# we need to forbid updater from affecting # we need to forbid updater from affecting
# GIT-supplied versions of the game to avoid bugs. # GIT-supplied versions of the game to avoid bugs.
global UPDATE_VER, UPDATE_HINT
if (not updater.can_update() or config.developer) and not self.simulate: if (not updater.can_update() or config.developer) and not self.simulate:
return return
check = True check = True
url = self.url url = self.url
if not self.onetime:
UPDATE_HINT = "Checking for updates..."
renpy.restart_interaction()
if self.onetime and url in updater.checked: if self.onetime and url in updater.checked:
check = False check = False
@ -36,11 +43,19 @@ init python:
persistent._update_last_checked[url] = time.time() persistent._update_last_checked[url] = time.time()
updater.Updater(url, check_only=True, simulate=self.simulate, **self.kwargs) updater.Updater(url, check_only=True, simulate=self.simulate, **self.kwargs)
global UPDATE_VER UPDATE_VER = persistent._update_version.get(url, None)
UPDATE_VER = persistent._update_version.get(url, "")
if self.autostart: if version_float(UPDATE_VER) < version_float():
renpy.invoke_in_new_context(updater.update, self.url, simulate=self.simulate, **self.kwargs) if not self.onetime:
UPDATE_HINT = "New game version available!"
renpy.restart_interaction()
if self.autostart:
renpy.invoke_in_new_context(updater.update, self.url, simulate=self.simulate, **self.kwargs)
elif not UPDATE_VER:
ui.timer(2.0, SetVariable("UPDATE_HINT", "Server is not responding."))
elif not self.onetime:
ui.timer(2.0, SetVariable("UPDATE_HINT", "You are already up-to-date."))
@renpy.pure @renpy.pure
class InstallUpdates(Action): class InstallUpdates(Action):
@ -62,8 +77,10 @@ init python:
renpy.set_return_stack(("main_room",)) renpy.set_return_stack(("main_room",))
def version_float(): def version_float(version=None):
control, major, *minor = config.version.split(" ")[0].split(".") version = version or config.version
control, major, *minor = version.split(" ")[0].split(".")
return float("{}.{}{}".format(control, major, "".join(minor))) return float("{}.{}{}".format(control, major, "".join(minor)))
def version_patch(): def version_patch():
@ -208,7 +225,8 @@ define update_message_list = [
"Insert disc 2", "Insert disc 2",
] ]
screen updater(): # Do not add parenthesis to the updater screen, otherwise it will break screen parameter interpolation.
screen updater:
tag menu tag menu