################################################################################# # This file is part of Mana Launcher. # Copyright (C) 2021 Jesusalva # # Distributed under the MIT license. ################################################################################# image TMW2 = "images/TMW2.png" screen loading(): zorder 100 fixed: frame: xfill True yfill True background Frame("images/default.png", 0, 0) bar: value progress range 100 xalign 0.5 yalign 0.45 xmaximum 0.75 label "[statusmsg]": xalign 0.5 yalign 0.55 # The game starts here. label start: scene black show screen loading call before_main_menu # Run updater $ renpy.invoke_in_thread(CONFIGURE_LAUNCHER) # Estabilish the connection to server python: # Block the main thread until the socket connection is done while progress < 100: if responsive: sdelay() else: 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 if not responsive: jump die $ stdout("Connection established!") # Open game hide screen loading scene black show TMW2 at truecenter with Dissolve(0.5) pause 1.0 hide TMW2 with dissolve #centered "Error" #if config.developer: # "User ID: [vaultId]" while True: $ renpy.block_rollback() call screen mirrorlake #if config.developer: # "Selected: [_return]" if _return is None or _return == "QUIT": $ stdout("Good bye!") $ renpy.quit() return scene black show TMW2 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"]} 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) PWD="" else: auth2=r.json() PWD=" -U %s -P %s" % (auth2["user"], auth2["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 execute("%s %s%s" % (CMD, OPT, PWD), shell=True) # 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") return