summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-12-19 02:27:40 -0300
committerJesusaves <cpntb1@ymail.com>2021-12-19 02:27:40 -0300
commit95dd7cf5ed2281088642c003faa24c6e7d664072 (patch)
tree208a938c448884bfbafc5d765b73964f6c769cff
parent69f216aa55bf873ec519ef77f80c9c90129b3b8d (diff)
downloadrenpy-95dd7cf5ed2281088642c003faa24c6e7d664072.tar.gz
renpy-95dd7cf5ed2281088642c003faa24c6e7d664072.tar.bz2
renpy-95dd7cf5ed2281088642c003faa24c6e7d664072.tar.xz
renpy-95dd7cf5ed2281088642c003faa24c6e7d664072.zip
We're now doing a sprint to have everything the old launcher had.
This implements support to online lists. The trick is a background thread fetching online list data every 60 seconds. And ignoring errors, of course.
-rw-r--r--game/core.rpy1
-rw-r--r--game/mirrorlake.rpy8
-rw-r--r--game/renpy.rpy4
-rw-r--r--game/update.rpy39
4 files changed, 50 insertions, 2 deletions
diff --git a/game/core.rpy b/game/core.rpy
index 26e2b1b..10718c1 100644
--- a/game/core.rpy
+++ b/game/core.rpy
@@ -240,6 +240,7 @@ default has_steam = False
default SCR_PROMPT = None
default SCR_RESULT = None
default MLP_DEST = None
+default running = False
## Command Line Interface
init -4 python:
diff --git a/game/mirrorlake.rpy b/game/mirrorlake.rpy
index f9fcba1..b5662b9 100644
--- a/game/mirrorlake.rpy
+++ b/game/mirrorlake.rpy
@@ -87,10 +87,16 @@ screen mirrorlake():
text _("{a=%s}Terms of Use{/a}" % persistent.serverlist[server]["Policy"])
null height 40
text _("%s" % persistent.serverlist[server]["Desc"]):
- size 24
+ size 23
color "#FFF"
null height 40
# TODO: Handle Online List
+ text _("Online: %s players" % (onl_cnt(persistent.serverlist[server]))):
+ size 18
+ color "#F77"
+ text _(onl_list(persistent.serverlist[server])):
+ size 14
+ color "#F77"
hbox:
yalign 0.9
xalign 0.9
diff --git a/game/renpy.rpy b/game/renpy.rpy
index 1c56755..a58ce4e 100644
--- a/game/renpy.rpy
+++ b/game/renpy.rpy
@@ -99,6 +99,10 @@ label start:
if not responsive:
jump die
+ # We're running, keep online lists up-to-date in background
+ $ running = True
+ $ renpy.invoke_in_thread(ONLINE_LISTING)
+
# Do we have a Vault ID?
if not vaultId:
call register
diff --git a/game/update.rpy b/game/update.rpy
index 0e285b8..e1d1c76 100644
--- a/game/update.rpy
+++ b/game/update.rpy
@@ -38,8 +38,10 @@ init python:
stdout("Validation for server \"%s\" FAILED!" % name)
## Fetch server background (optional) if successful
- """
if (ok):
+ srv["onlcnt"] = -1
+ srv["onlist"] = []
+ """
bgname="bg_%s.png" % (name.replace(" ", ""))
if os.path.exists(get_path(bgname)):
return ok
@@ -265,6 +267,41 @@ init python:
status_update(pc=100)
return
+ def ONLINE_LISTING():
+ global running, responsive
+ while (running and responsive):
+ for s in persistent.serverlist:
+ try:
+ r=requests.get("%s" % s["Online"], timeout=5.0)
+
+ if (r.status_code != 200):
+ raise AssertionError("Online list for %s is down!\nReturned error %03d\n" % (s["Name"], r.status_code))
+
+ j=json.loads(r.text)
+ s["onlcnt"]=len(j)
+ s["onlist"]=list(j)
+ except:
+ s["onlcnt"]=-1
+ s["onlist"]=[]
+ pass
+ time.sleep(60)
+ return
+
+ def onl_cnt(ent):
+ if ent["onlcnt"] < 0:
+ return "?"
+ else:
+ return "%d" % ent["onlcnt"]
+
+
+ def onl_list(ent):
+ s=""; i=0; l=len(ent["onlist"])
+ while i < l:
+ s+=str(ent["onlist"][i])
+ i+=1
+ if (i < l):
+ s+=", "
+ return s
#################################################################################
screen register_method():