1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#################################################################################
# This file is part of Mana Launcher.
# Copyright (C) 2021 Jesusalva <jesusalva@tmw2.org>
#
# Distributed under the MIT license.
# Warning: Third Party game clients
#################################################################################
####### Constants
define manaverseWin64 = "https://updates.tmw2.org/mana/windows/manaverse.zip"
define manaverseLinux = "https://updates.tmw2.org/mana/linux/ManaPlus-x86_64.AppImage"
####### Main Code
init 1 python:
#############################################################################
def download_manaverse(fname):
installdir=get_path("manaplus")
status_update("Downloading %s on RAM..." % fname, 62)
## TODO: use `stream=True`
if renpy.linux:
r=requests.get(manaverseLinux, timeout=60.0)
elif renpy.windows:
r=requests.get(manaverseWin64, timeout=60.0)
else:
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)
if not md5check_client(True):
status_update("MD5 Hash Error")
stdout("MD5 Mismatch: hashes diverged", True)
return False
return True
#######################
def install_manaverse():
status_update("Creating ManaPlus directory...", 61)
installdir=get_path("manaplus")
try:
os.mkdir(installdir)
except OSError:
pass
## Detect your plataform
#########################################################
if renpy.linux:
if not download_manaverse("ManaVerse.AppImage"):
return False
status_update("Marking as executable...", 72)
execute("chmod +x \"%s\"" % installdir+"/ManaVerse.AppImage", shell=True)
status_update("Installation successful!", 75)
#########################################################
elif renpy.windows:
"""
if not download_manaverse("ManaPlus.zip"):
return False
status_update("Unzipping file...", 72)
with zipfile.ZipFile(installdir+"/ManaPlus.zip", 'r') as zip_ref:
zip_ref.extractall(installdir)
"""
if not download_manaverse("manaverse.zip"):
return False
status_update("Unzipping file...", 72)
with zipfile.ZipFile(installdir+"/manaverse.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
try:
shutil.copytree(get_path('')+"Config", installdir+"/Config")
except OSError:
traceback.print_exc()
pass
return True
###############################
def cli_manaverse(launch=False, download=True, force=False):
global SCR_PROMPT, SCR_RESULT
## Check if ManaPlus or ManaVerse 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://git.themanaworld.org/mana/plus/-/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
## Actual download/installation (for updates)
if download and (force or not MANAPLUS):
try:
if not install_manaverse():
# 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")+"/ManaVerse.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
|