summaryrefslogtreecommitdiff
path: root/game/renpy.rpy
diff options
context:
space:
mode:
Diffstat (limited to 'game/renpy.rpy')
-rw-r--r--game/renpy.rpy67
1 files changed, 22 insertions, 45 deletions
diff --git a/game/renpy.rpy b/game/renpy.rpy
index b32be46..6b3bafc 100644
--- a/game/renpy.rpy
+++ b/game/renpy.rpy
@@ -77,54 +77,31 @@ label start:
$ renpy.quit()
return
scene black
- show TMW2 at truecenter
+ show expression Text("{color=#FFF}"+_("Game in session:\n%s" % (persistent.serverlist[_return]["Name"]))+"{/color}") at truecenter
with None
pause 0.01
python:
- # TODO: use the proper discord RPC image
- RPCUpdate(persistent.serverlist[_return]["Name"], "tmw2")
- HOST=persistent.serverlist[_return]["Host"]
- PORT=persistent.serverlist[_return]["Port"]
- CMD=handle_client(launch=True)
- OPT="-s %s -y evol2 -p %s" % (HOST, PORT)
- stdout("%s %s" % (CMD, OPT))
-
- ## Obtain access token from vault
- ## TODO: Only skip failure if not dev
- auth = {"vaultId": vaultId,
- "token": vaultToken,
- "world": persistent.serverlist[_return]["UUID"]}
- PWD=""
- try:
- r=requests.post(VAULT_HOST+"/world_pass", json=auth, timeout=15.0)
- if r.status_code != 200:
- stdout("Get World Auth - Returned error code %d" % r.status_code)
+ renpy.invoke_in_thread(launch_game, _return)
+ progress = 0
+ # Block the main thread until the socket connection is done
+ while progress < 100:
+ if responsive:
+ sdelay()
else:
- auth2=r.json()
- PWD=" -U %s -P %s" % (auth2["user"], auth2["pass"])
- except:
- pass
-
- ## Minimize to tray if set
- if not renpy.mobile and persistent.iconify:
- renpy.iconify()
-
- ## Launch your prefered game client, wait for it to finish
- if renpy.windows:
- app=execute("\"%s\" %s%s" % (CMD, OPT, PWD), shell=True)
- else:
- app=execute("%s %s%s" % (CMD, OPT, PWD), shell=True)
- if app:
- traceback.print_exc()
- stdout("An error happened: %d" % app)
-
- # NOTE: Now we would like to un-minimize ourselves
- # But we cannot =/
- # There's a few tricks but not very nice...
- # https://stackoverflow.com/questions/45426203/minimize-window-with-python (Linux)
- # https://stackoverflow.com/questions/2791489/how-do-i-take-out-the-focus-or-minimize-a-window-with-python/2792059 (Windows)
-
- # Clean discord RPC and go back to main menu
- RPCUpdate("Main Menu", "tmw2")
+ break
+
+ # Maybe we are waiting some prompt
+ if SCR_PROMPT is not None:
+ SCR_RESULT = renpy.call_screen("confirm", SCR_PROMPT,
+ Return(True), Return(False))
+ SCR_PROMPT = None
+
+ # Kill the program instead of looping back
+ if not responsive:
+ centered "{color=#FFF}An error happened.{/color}"
+ jump die
+
+ # Automatically loop back
+ # Will never reach this line
return