forked from SilverStudioGames/WTS
Web Updater
* Separated updater server code * Fixed update logo fetch crash * Added logo fetch var
This commit is contained in:
parent
1812481b33
commit
9bcbdba53b
@ -243,11 +243,11 @@ screen navigation(title=None):
|
|||||||
|
|
||||||
if main_menu:
|
if main_menu:
|
||||||
if not title:
|
if not title:
|
||||||
if (updater.can_update() or config.developer):
|
if (updater.can_update() or config.developer) and getattr(store, "UPDATE_URL", None):
|
||||||
if new_version:
|
if new_version:
|
||||||
textbutton "Update available" action updater.Update(UPDATE_URL, simulate="available", patch=True) style_prefix "update_available"
|
textbutton "Update available" action install_updates() style_prefix "update_available"
|
||||||
else:
|
else:
|
||||||
textbutton "Check for updates" action Function(check_for_updates, 300)
|
textbutton "Check for updates" action Function(check_updates, 300)
|
||||||
|
|
||||||
if show_quick_start:
|
if show_quick_start:
|
||||||
textbutton _("Quick Start") action Start("start_quick")
|
textbutton _("Quick Start") action Start("start_quick")
|
||||||
|
54
game/scripts/utility/server.rpy
Normal file
54
game/scripts/utility/server.rpy
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# This file can be safely deleted to permanently disable update checks.
|
||||||
|
|
||||||
|
init python:
|
||||||
|
import requests
|
||||||
|
import binascii
|
||||||
|
|
||||||
|
UPDATE_URL = ""
|
||||||
|
LOGO_URL = ""
|
||||||
|
|
||||||
|
new_version = None
|
||||||
|
|
||||||
|
def check_updates(interval=3600*6):
|
||||||
|
if not UPDATE_URL:
|
||||||
|
return
|
||||||
|
|
||||||
|
global new_version
|
||||||
|
new_version = updater.UpdateVersion(binascii.unhexlify(UPDATE_URL), check_interval=interval)
|
||||||
|
|
||||||
|
def install_updates():
|
||||||
|
if not UPDATE_URL:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return updater.Update(binascii.unhexlify(UPDATE_URL), patch=True)
|
||||||
|
|
||||||
|
def fetch_update_logo(url):
|
||||||
|
if not (updater.can_update() or config.developer) or new_version is None or not LOGO_URL:
|
||||||
|
return Null()
|
||||||
|
|
||||||
|
filename = "logo_{}.png".format(new_version)
|
||||||
|
path = os.path.join(config.basedir, "updates/{}".format(filename))
|
||||||
|
|
||||||
|
# Read file if exists
|
||||||
|
if os.path.isfile(path):
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
data = f.read()
|
||||||
|
return im.Data(data, path)
|
||||||
|
|
||||||
|
# Fetch file if doesn't exist
|
||||||
|
try:
|
||||||
|
url = binascii.unhexlify(url)
|
||||||
|
response = requests.get(url, timeout=5)
|
||||||
|
data = response.content
|
||||||
|
except:
|
||||||
|
return Null()
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
return Null()
|
||||||
|
|
||||||
|
with open(path, "wb") as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
return im.Data(data, path)
|
||||||
|
|
||||||
|
check_updates()
|
@ -67,49 +67,12 @@ define update_message_list = [
|
|||||||
"Insert disc 2",
|
"Insert disc 2",
|
||||||
]
|
]
|
||||||
|
|
||||||
init python:
|
|
||||||
import requests
|
|
||||||
|
|
||||||
UPDATE_URL = "http://update.silverstudiogames.org/updates.json"
|
|
||||||
new_version = None
|
|
||||||
|
|
||||||
def check_for_updates(interval=3600*6):
|
|
||||||
global new_version
|
|
||||||
new_version = updater.UpdateVersion(UPDATE_URL, simulate="available", check_interval=interval)
|
|
||||||
|
|
||||||
def fetch_update_logo(url):
|
|
||||||
if not (updater.can_update() or config.developer) or new_version is None:
|
|
||||||
return Null()
|
|
||||||
|
|
||||||
filename = "logo_{}.png".format(new_version)
|
|
||||||
path = os.path.join(config.basedir, "updates/{}".format(filename))
|
|
||||||
|
|
||||||
# Read file if exists
|
|
||||||
if os.path.isfile(path):
|
|
||||||
with open(path, "rb") as f:
|
|
||||||
data = f.read()
|
|
||||||
return im.Data(data, path)
|
|
||||||
|
|
||||||
# Fetch file if doesn't exist
|
|
||||||
response = requests.get(url, timeout=5)
|
|
||||||
data = response.content
|
|
||||||
|
|
||||||
if not data:
|
|
||||||
return Null()
|
|
||||||
|
|
||||||
with open(path, "wb") as f:
|
|
||||||
f.write(data)
|
|
||||||
|
|
||||||
return im.Data(data, path)
|
|
||||||
|
|
||||||
# check_for_updates()
|
|
||||||
|
|
||||||
screen updater:
|
screen updater:
|
||||||
|
|
||||||
tag menu
|
tag menu
|
||||||
|
|
||||||
default msg = renpy.random.choice(update_message_list)
|
default msg = renpy.random.choice(update_message_list)
|
||||||
default logo = fetch_update_logo("https://cdn.discordapp.com/attachments/535709194876354571/957762605735354378/discord.png") # http://update.silverstudiogames.org/logo.webp
|
default logo = fetch_update_logo(LOGO_URL) # http://update.silverstudiogames.org/logo.webp
|
||||||
|
|
||||||
use game_menu(_("Updater"), scroll="viewport"):
|
use game_menu(_("Updater"), scroll="viewport"):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user