diff options
-rw-r--r-- | game/3rdparty/manaplus.rpy (renamed from game/3rdparty.rpy) | 30 | ||||
-rw-r--r-- | game/3rdparty/manaverse.rpy | 125 | ||||
-rw-r--r-- | game/client.rpy | 10 | ||||
-rw-r--r-- | game/core.rpy | 7 | ||||
-rw-r--r-- | game/screens.rpy | 12 | ||||
-rw-r--r-- | game/update.rpy | 2 |
6 files changed, 144 insertions, 42 deletions
diff --git a/game/3rdparty.rpy b/game/3rdparty/manaplus.rpy index 163915d..f3aea16 100644 --- a/game/3rdparty.rpy +++ b/game/3rdparty/manaplus.rpy @@ -87,7 +87,7 @@ init 1 python: ## Installer if not MANAPLUS and download: SCR_PROMPT=("Selected client \"%s\" is not installed.\nDo you wish to install it now?\n\n{size=14}By installing you agree with its {a=%s}Terms of Use and Conditions{/a}.%s{/size}" % - ("ManaPlus", "https://gitlab.com/themanaworld/manaplus/manaplus/-/raw/master/COPYING", + ("ManaPlus", "https://gitlab.com/manaplus/manaplus/-/raw/master/COPYING", ifte(renpy.linux, "\n{i}libfuse2{/i} is required to run AppImages.", ""))) while SCR_RESULT is None: time.sleep(0.02) @@ -123,31 +123,3 @@ init 1 python: return False return True - ############################################################################# - def cli_mana(launch=False, download=True): - stdout("ERROR, Mana Client is not implemented!") - return False - - ## Check for Mana - try: - MANA=os.path.exists(get_path("mana")) - except: - traceback.printexc() - MANA=False - - ## Installer - if not MANA and download: - SCR_PROMPT=("Selected client \"%s\" is not installed.\nDo you wish to install it now?\n\n{size=14}By installing you agree with its {a=%s}Terms of Use and Conditions{/a}.{/size}" % - ("Mana", "https://gitlab.com/themanaworld/tmw-client/????/-/raw/master/COPYING")) - while SCR_RESULT is None: - time.sleep(0.02) - ret=copy.copy(SCR_RESULT) - SCR_RESULT=None - if (not ret): - return False - elif not MANA: - return False - return True - - - diff --git a/game/3rdparty/manaverse.rpy b/game/3rdparty/manaverse.rpy new file mode 100644 index 0000000..a71704f --- /dev/null +++ b/game/3rdparty/manaverse.rpy @@ -0,0 +1,125 @@ +################################################################################# +# This file is part of Mana Launcher. +# Copyright (C) 2021 Jesusalva <jesusalva@tmw2.org> +# +# Distributed under the MIT license. +# Warning: Third Party game clients +################################################################################# + +init 1 python: + ############################################################################# + def download_manaverse(fname): + installdir=get_path("manaplus") + status_update("Downloading %s on RAM..." % fname, 62) + r=requests.get(persistent.host+"/%s" % fname, timeout=60.0) + if (r.status_code != 200): + status_update("Failure retrieving M+: ERROR %d" % r.status_code) + return False + + status_update("Saving %s..." %fname, 64) + msize = int(r.headers.get('content-length', 0)) + bsize = 4096 + csize = msize / 7 + cstep = 0 + with open(installdir+"/%s" % fname, 'wb') as fd: + for chunk in r.iter_content(bsize): + fd.write(chunk) + cstep += bsize + status_update(pc=64+(cstep / csize)) + + status_update("Verifying MD5 hash...", 70) + r=requests.get(persistent.host+"/%s.md5" % fname, timeout=10.0) + md5up=r.text.replace("\n", "") + + status_update("Verifying MD5 hash...", 71) + md5us=md5sum(installdir+"/%s" % fname) + if md5up != md5us: + status_update("MD5 Hash Error") + stdout("MD5 Mismatch: hashes differ", True) + stdout("Ours: %s" % md5us, True) + stdout("Them: %s" % md5up, True) + return False + return True + + ####################### + def install_manaverse(): + status_update("Creating ManaPlus directory...", 61) + installdir=get_path("manaplus") + os.mkdir(installdir) + ## Detect your plataform + ######################################################### + if renpy.linux: + if not download_manaplus("ManaPlus.AppImage"): + return False + + status_update("Marking as executable...", 72) + execute("chmod +x \"%s\"" % installdir+"/ManaPlus.AppImage", shell=True) + status_update("Installation successful!", 75) + ######################################################### + elif renpy.windows: + if not download_manaplus("ManaPlus.zip"): + return False + + status_update("Unzipping file...", 72) + with zipfile.ZipFile(installdir+"/ManaPlus.zip", 'r') as zip_ref: + zip_ref.extractall(installdir) + status_update("Installation successful!", 75) + ######################################################### + #elif renpy.android: + #elif renpy.macintosh: + #elif renpy.emscripten: # web + ######################################################### + else: + status_update("ERROR: Unsupported Plataform") + return False + return True + + ############################### + def cli_manaverse(launch=False, download=True): + global SCR_PROMPT, SCR_RESULT + ## Check if ManaPlus is already installed + try: + MANAPLUS=os.path.exists(get_path("manaplus")) + except: + traceback.print_exc() + MANAPLUS=False + + ## Installer + if not MANAPLUS and download: + SCR_PROMPT=("Selected client \"%s\" is not installed.\nDo you wish to install it now?\n\n{size=14}By installing you agree with its {a=%s}Terms of Use and Conditions{/a}.%s{/size}" % + ("ManaVerse", "https://gitlab.com/themanaworld/manaplus/manaplus/-/raw/master/COPYING", + ifte(renpy.linux, "\n{i}libfuse2{/i} is required to run AppImages.", ""))) + while SCR_RESULT is None: + time.sleep(0.02) + ret=copy.copy(SCR_RESULT) + SCR_RESULT=None + if (not ret): + return False + + try: + if not install_manaplus(): + # Delete the failed attempt before raising the exception + shutil.rmtree(get_path("manaplus")) + #os.rmdir(get_path("manaplus")) + raise Exception("Installation failed!") + except: + traceback.print_exc() + stdout("Installation failed!", True) + return False + elif not MANAPLUS: + return False + + ########## + if launch: + if renpy.linux: + os.environ["APPIMAGELAUNCHER_DISABLE"]="1" + pathy=get_path("manaplus")+"/ManaPlus.AppImage" + return pathy.replace(" ", "\\ ") + elif renpy.windows: + pathy=get_path("manaplus")+"/Mana/manaplus.exe" + return pathy.replace("/", "\\") + else: + stdout("Invalid Plataform!") + return False + return True + diff --git a/game/client.rpy b/game/client.rpy index 1f69b49..461c7a8 100644 --- a/game/client.rpy +++ b/game/client.rpy @@ -9,13 +9,13 @@ init 2 python: ## Local variables f=False if (CLIENT_NAME == ""): - CLIENT_NAME=persistent.client + CLIENT_NAME=persistent.evol2cli ## Main loop if (CLIENT_NAME == "manaplus"): f=cli_manaplus(launch, download) - elif (CLIENT_NAME == "mana"): - f=cli_mana(launch, download) + elif (CLIENT_NAME == "manaverse"): + f=cli_manaverse(launch, download) else: status_update("ERROR, unrecognized client: %s" % CLIENT_NAME) @@ -156,7 +156,7 @@ init 2 python: def md5check_client(silent=False): renpy.notify("Checking md5sum...") try: - installdir=get_path(persistent.client) + installdir=get_path(persistent.evol2cli) fname=handle_client(launch=True, download=False).split("/").pop() r=requests.get(persistent.host+"/%s.md5" % fname, timeout=10.0) md5up=r.text.replace("\n", "") @@ -166,7 +166,7 @@ init 2 python: stdout("MD5 Mismatch: hashes differ", True) stdout("Ours: %s" % md5us, True) stdout("Them: %s" % md5up, True) - shutil.rmtree(get_path(persistent.client)) + shutil.rmtree(get_path(persistent.evol2cli)) if not silent: renpy.notify("Files are outdated!") else: diff --git a/game/core.rpy b/game/core.rpy index 4b2b77d..723c283 100644 --- a/game/core.rpy +++ b/game/core.rpy @@ -135,8 +135,8 @@ init -3 python: persistent.discord = True if (persistent.steam is None): persistent.steam = False - if (persistent.client is None): - persistent.client = "manaplus" + if (persistent.evol2cli is None): + persistent.evol2cli = "manaverse" if (persistent.iconify is None): persistent.iconify = ifte(renpy.windows, False, True) @@ -194,7 +194,7 @@ init 10 python: ## Force Update if persistent.version != config.version: persistent.version = config.version - if (persistent.client is not None and + if (persistent.evol2cli is not None and persistent.host is not None and handle_client(launch=True, download=False)): md5check_client(silent=True) @@ -237,6 +237,7 @@ init -4 python: AUTOLAUNCH = False def parse_command(): global USE_DUMMY_DATA, AUTOLAUNCH + global vault, VAULT_HOST, VAULT_CERT parser = renpy.arguments.ArgumentParser() ## Collect args diff --git a/game/screens.rpy b/game/screens.rpy index 5613ea1..b7dc2be 100644 --- a/game/screens.rpy +++ b/game/screens.rpy @@ -678,10 +678,14 @@ screen preferences(): action ToggleVariable("persistent.steam") null height 10 label _("Plugins") + null height 7 + text _("Evol2 Game Servers"): + size 16 + null height 5 + textbutton _("ManaVerse"): + action SetVariable("persistent.evol2cli", "manaverse") textbutton _("ManaPlus"): - action SetVariable("persistent.client", "manaplus") - textbutton _("Mana"): - action SetVariable("persistent.client", "mana") + action SetVariable("persistent.evol2cli", "manaplus") vbox: @@ -705,7 +709,7 @@ screen preferences(): persistent.vmethod is not None, _("ON"), _("OFF"))): action Function(renpy.call_in_new_context, "savevm") textbutton _("Check Updates"): - action ifte(persistent.client is not None and + action ifte(persistent.evol2cli is not None and persistent.host is not None and handle_client(launch=True, download=False), Function(md5check_client), diff --git a/game/update.rpy b/game/update.rpy index fc44046..8708790 100644 --- a/game/update.rpy +++ b/game/update.rpy @@ -172,7 +172,7 @@ init python: time.sleep(0.4) responsive = False time.sleep(2.6) - status_update(_("{color=#F00}ERROR: \"%s\" client is NOT supported!{/color}" % persistent.client), 70) + status_update(_("{color=#F00}ERROR: \"%s\" client is NOT supported!{/color}" % persistent.evol2cli), 70) return |