-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.py
152 lines (131 loc) · 5.39 KB
/
install.py
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
149
150
151
152
import sys
import glob
import shutil
import os
from os.path import *
import Tkinter
import tkFileDialog
import tkMessageBox
from asmutils import *
import ASMTick
import ASMVillageMarker
import ASMEventMarker
import ASMStructMarker
util = None
top = Tkinter.Tk()
top.wm_title("ASM Installer")
installTick = IntVar()
installVM = IntVar()
installEM = IntVar()
installSM = IntVar()
jarpath = StringVar()
instver = StringVar()
installTick.set(1)
installVM.set(1)
installEM.set(1)
installSM.set(1)
def getJarpath():
global jarpath
appdata = os.getenv('APPDATA')
homedir = expanduser("~")
initdir = None
if appdata is not None:
initdir = join(appdata,'.minecraft','versions')
if not isdir(initdir):
initdir = None
if homedir is not None and initdir is None:
initdir = join(homedir,'.minecraft','versions')
if not isdir(initdir):
initdir = join(homedir,'Library','Application Support','minecraft','versions')
if not isdir(initdir):
initdir = None
if initdir is None:
initdir = curdir
jarpath.set(tkFileDialog.askopenfilename(
filetypes=[('jar files','.jar'),('all files', '*')],
initialdir=initdir,
title='Installer'))
if jarpath.get():
util = Util(jarpath.get())
instver.set(util.vernam+'-ASM')
def startInstall():
if not jarpath.get():
tkMessageBox.showinfo("Info", "Please specify a Minecraft version.")
return
if not isfile(jarpath.get()):
tkMessageBox.showwarning("Warning", "File '"+jarpath.get()+"' does not exist.")
return
try:
util = Util(jarpath.get())
util.setup()
except Exception as e:
tkMessageBox.showerror("Error", "Something went wrong while setting up the directory tree:\n" + str(e))
return
if installTick.get() == 1:
try:
ASMTick.create_mod(util)
except Exception as e:
tkMessageBox.showerror("Error", "Mod 'ASMTick' could not be created.\nView stdout for more information.\n\n" + str(e))
return
if installVM.get() == 1:
try:
ASMVillageMarker.create_mod(util)
except Exception as e:
tkMessageBox.showerror("Error", "Mod 'ASMVillageMarker' could not be created.\nView stdout for more information.\n\n" + str(e))
return
if installEM.get() == 1:
try:
ASMEventMarker.create_mod(util)
except Exception as e:
tkMessageBox.showerror("Error", "Mod 'ASMEventMarker' could not be created.\nView stdout for more information.\n\n" + str(e))
return
if installSM.get() == 1:
try:
ASMStructMarker.create_mod(util)
except Exception as e:
tkMessageBox.showerror("Error", "Mod 'ASMStructMarker' could not be created.\nView stdout for more information.\n\n" + str(e))
return
try:
mkrls = False
fixMCL8475 = False
if not util.isrelease():
mkrls = tkMessageBox.askyesno(
'Jar is a Snapshot',
'The original Mincraft version appears to be a SNAPSHOT. '+
'Snapshots may be atomatically deleted by the Minecraft Launcher.\n\n'+
'Would you like to change the modded version to a RELEASE?')
if util.usesnewjson():
fixMCL8475 = tkMessageBox.askyesno(
'MCL-8475',
'The version.json file uses the new argument format. '+
'Minecraft Launcher 1.6.84j does not work well with this '+
'because of MCL-8475.\n\n'+
'Would you like to use the legacy argument format?')
util.install(instver.get(), mkrls, fixMCL8475)
except Exception as e:
tkMessageBox.showerror("Error", "Something went wrong while creating the modded version:\n" + str(e))
return
tkMessageBox.showinfo("Done!", "Mods installed.")
L1 = Label(top,text="Minecraft version-jar:")\
.grid(row=0, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
E1 = Entry(top,bd=4,textvariable=jarpath,width=42)\
.grid(row=1, column=0, pady=4, padx=8, sticky=Tkinter.N)
B1 = Button(top,text="Browse",command=getJarpath)\
.grid(row=1, column=1, pady=4, padx=8, sticky=Tkinter.E)
L2 = Label(top,text="Mods to install:")\
.grid(row=2, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
C1 = Checkbutton(top,text="ASM Tick",variable=installTick,onvalue=1,offvalue=0)\
.grid(row=3, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
C2 = Checkbutton(top,text="ASM Village Marker",variable=installVM,onvalue=1,offvalue=0)\
.grid(row=4, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
C3 = Checkbutton(top,text="ASM Event Marker",variable=installEM,onvalue=1,offvalue=0)\
.grid(row=5, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
C3 = Checkbutton(top,text="ASM Structure Marker",variable=installSM,onvalue=1,offvalue=0)\
.grid(row=6, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
L3 = Label(top,text="Name of modded version:")\
.grid(row=7, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
E2 = Entry(top,bd=4,textvariable=instver,width=20)\
.grid(row=8, column=0, pady=4, padx=8, sticky=Tkinter.N+Tkinter.W)
B2 = Button(top,text="Install",command=startInstall)\
.grid(row=9, column=1, pady=4, padx=8, sticky=Tkinter.N+Tkinter.E)
top.mainloop()