-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGUI.py
351 lines (304 loc) · 14.8 KB
/
GUI.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
from tkinter.messagebox import showinfo
import os
clearConsole = lambda: os.system('cls' if os.name in ('nt', 'dos') else 'clear')
def enablegroup():
SeedNameEntry.configure(state="normal")
Random_button.configure(state="normal")
help_button.configure(state="normal")
dropdown.configure(state="normal")
DowngradePlants_c1.configure(state="normal")
PlantHealth_c1.configure(state="normal")
PlantDamage_c1.configure(state="normal")
PlantAction_c1.configure(state="normal")
AdventureModeSeedpackets_c1.configure(state="normal")
AdventureModeSeedpackets_matchseedpackets_c1.configure(state="normal")
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1.configure(state="normal")
def disablegroup():
SeedNameEntry.configure(state="disabled")
Random_button.configure(state="disabled")
help_button.configure(state="disabled")
dropdown.configure(state="disabled")
DowngradePlants_c1.configure(state="disabled")
PlantHealth_c1.configure(state="disabled")
PlantDamage_c1.configure(state="disabled")
PlantAction_c1.configure(state="disabled")
PlantAction_c1.configure(state="disabled")
AdventureModeSeedpackets_c1.configure(state="disabled")
AdventureModeSeedpackets_matchseedpackets_c1.configure(state="disabled")
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1.configure(state="disabled")
SummonedZombieAdventure_c1.configure(state="disabled")
ZombieAdventure_c1.configure(state="disabled")
ZoboantyAdventure_c1.configure(state="disabled")
GigaGargAdventure_c1.configure(state="disabled")
Converyor_c1.configure(state="disabled")
ConveryorAll_c1.configure(state="disabled")
DowngradePlants_c1.configure(state="disabled")
RandomizeBackground_c1.configure(state="disabled")
RandomizeCustomBackground_c1.configure(state="disabled")
Sunmeta_c1.configure(state="disabled")
MinWavesEntry.configure(state="disabled")
MaxWavesEntry.configure(state="disabled")
FixedWavesEntry.configure(state="disabled")
BalloonZombieCounterCheck_c1.configure(state="disabled")
StorePlants_c1.configure(state="disabled")
def Randomize():
clearConsole()
print("Seed name:", SeedNameEntry.get())
#
minwaves = MinWavesEntry.get()
maxwaves = MaxWavesEntry.get()
SeedNum = SeedNameEntry.get()
waveamount = FixedWavesEntry.get()
ZombieAdventurecheck = ZombieAdventure.get()
Sunmeta = Sunmeta50.get()
DontChangeSeedpacketIconOrder = AdventureModeSeedpackets_matchseedpackets.get()
RandomizeBackground = RandomizeBackgrounds.get()
EnableCustombackgrounds = RandomizeCustomBackground.get()
RandomizeUpgrades = DowngradePlants.get()
ConveryorRandomize = Converyor.get()
ConveryorRandomizeAll = ConveryorAll.get()
ZombieLevel = ZombieAdventure.get()
SummonedZombies = SummonedZombieAdventure.get()
Zombotany = ZoboantyAdventure.get()
Giga = GigaGargAdventure.get()
mode = Wavemode.get()
RandomizeActionRate = PlantAction.get()
RandomizePlantDamage = PlantDamage.get()
RandomizePlantHealth = PlantHealth.get()
Randomize = AdventureModeSeedpackets.get()
RandomizeStorePlants = StorePlants.get()
PuffinNight1 = AdventureModeSeedpackets_DontRandomizedPuffSeedpacket.get()
BalloonZombieCounter = BalloonZombieCounterCheck.get()
InstalledviaGUI = True
#
disablegroup()
exec(open("RandomizerInstaller.py").read())
showinfo(
title='Randomizer done',
message= ("Successfully randomized the game. Press ok to exit"))
exit()
def Help():
clearConsole()
print("Make sure you have the files from the windows phone version of Plants vs. Zombies")
print("Put the game's Content folder into the same folder as the installer, don't replace the files that are already in the randomizer's Content folder")
print("Put the game's LawnStrings .txt files (LawnStrings_XX.txt) and the .xml files into the randomizer's Content folder")
print("Now click on the Randomize button.")
print("Once it finishes randomizing, you can start setting up the game.")
print("Open up the sln file with Visual Studio 2019")
print("Build the PC port projects (Lawn_PCDX and Lawn_PCGL) (Android port is untested), build them again if a error occurs")
print("and now you're ready to play the randomizer, choose one of the exe files you had compiled to play")
my_w = tk.Tk()
my_w.geometry("905x620")
my_w.title("Plants Vs. Zombies Randomizer (PlantsVsZombies.net)")
#
SeedLabel = tk.Label(text="Seed Name")
SeedName = tk.Entry()
SeedNameEntry = tk.Entry(textvariable=SeedName)
SeedLabel.grid(row=4,column=2)
SeedNameEntry.grid(row=5,column=2)
#
Random_button = ttk.Button(
my_w,
text='Randomize',
command=Randomize
)
Random_button.grid(row=6,column=2)
#
help_button = ttk.Button(
my_w,
text='Help',
command=Help
)
help_button.grid(row=6,column=4)
#
ZombieLabel = tk.LabelFrame(my_w, text="Zombies")
ZombieLabel.grid(row=1,column=3, columnspan=5, pady=5)
#
WaveModes = ['vanilla', 'vanilla', 'randomized', 'randomized+', 'hard', 'fixed']
Wavemode = tk.StringVar()
Wavemode.set(WaveModes[0])
WaveModeLabel = tk.LabelFrame(ZombieLabel, text="Wave Mode:")
WaveModeLabel.grid(row=3,column=1)
dropdown = ttk.OptionMenu(
WaveModeLabel,
Wavemode,
*WaveModes
)
dropdown.grid(row=3,column=1)
WaveModeRandomizedplusLabel = tk.LabelFrame(WaveModeLabel, text="Randomized+ Wave Options")
WaveModeRandomizedplusLabel.grid(row=4,column=1)
MinWavesLabel = tk.Label(WaveModeRandomizedplusLabel, text="Min waves")
MinWavesLabel.grid(row=2,column=1)
MinWaves = tk.Entry()
MinWavesEntry = tk.Entry(WaveModeRandomizedplusLabel, textvariable=MinWaves)
MinWavesEntry.grid(row=3,column=1)
MaxWavesLabel = tk.Label(WaveModeRandomizedplusLabel, text="Max waves")
MaxWavesLabel.grid(row=2,column=2)
MaxWaves = tk.Entry()
MaxWavesEntry = tk.Entry(WaveModeRandomizedplusLabel, textvariable=MaxWaves)
MaxWavesEntry.grid(row=3,column=2)
WaveModeFixedLabel = tk.LabelFrame(WaveModeLabel, text="Fixed waves")
WaveModeFixedLabel.grid(row=5,column=1)
FixedWaves = tk.Entry()
FixedWavesEntry = tk.Entry(WaveModeFixedLabel, textvariable=FixedWaves)
FixedWavesEntry.grid(row=4,column=2)
#
def switchButtonState():
if (ZoboantyAdventure_c1['state'] == tk.NORMAL):
ZoboantyAdventure_c1['state'] = tk.DISABLED
ZoboantyAdventure.set('n')
SummonedZombieAdventure_c1['state'] = tk.DISABLED
SummonedZombieAdventure.set('n')
GigaGargAdventure_c1['state'] = tk.DISABLED
GigaGargAdventure.set('n')
BalloonZombieCounterCheck_c1['state'] = tk.DISABLED
BalloonZombieCounterCheck.set('n')
else:
SummonedZombieAdventure_c1['state'] = tk.NORMAL
GigaGargAdventure_c1['state'] = tk.NORMAL
ZoboantyAdventure_c1['state'] = tk.NORMAL
BalloonZombieCounterCheck_c1['state'] = tk.NORMAL
def switchButtonStateT():
if (AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1['state'] == tk.NORMAL):
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1['state'] = tk.DISABLED
AdventureModeSeedpackets_matchseedpackets_c1['state'] = tk.DISABLED
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket.set('n')
AdventureModeSeedpackets_matchseedpackets.set('n')
else:
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1['state'] = tk.NORMAL
AdventureModeSeedpackets_matchseedpackets_c1['state'] = tk.NORMAL
def switchButtonStateC():
if (RandomizeCustomBackground_c1['state'] == tk.NORMAL):
RandomizeCustomBackground_c1['state'] = tk.DISABLED
RandomizeCustomBackground.set('n')
else:
RandomizeCustomBackground_c1['state'] = tk.NORMAL
def switchButtonStateB():
if (ConveryorAll_c1['state'] == tk.NORMAL):
ConveryorAll_c1['state'] = tk.DISABLED
ConveryorAll.set('n')
else:
ConveryorAll_c1['state'] = tk.NORMAL
ZombieAdventure=tk.StringVar()
ZombieAdventure_c1 = tk.Checkbutton(ZombieLabel, text='Randomize zombie appearances in Adventure Mode', variable=ZombieAdventure,
onvalue='y',offvalue='n', command = switchButtonState, state = tk.NORMAL)
ZombieAdventure_c1.grid(row=1,column=1)
ZombieAdventure.set('n')
ZombieAdventureLabel = tk.LabelFrame(ZombieLabel, text="Zombie appearance Options")
ZombieAdventureLabel.grid(row=2,column=1, columnspan=4, pady=5)
ZoboantyAdventure=tk.StringVar()
ZoboantyAdventure_c1 = tk.Checkbutton(ZombieAdventureLabel, text='Include Zombotany zombies', variable=ZoboantyAdventure,
onvalue='y',offvalue='n', state = tk.DISABLED)
ZoboantyAdventure_c1.grid(row=5,column=8)
ZoboantyAdventure.set('n')
SummonedZombieAdventure=tk.StringVar()
SummonedZombieAdventure_c1 = tk.Checkbutton(ZombieAdventureLabel, text='Include Summoned zombies', variable=SummonedZombieAdventure,
onvalue='y',offvalue='n', state = tk.DISABLED)
SummonedZombieAdventure_c1.grid(row=6,column=8)
SummonedZombieAdventure.set('n')
GigaGargAdventure=tk.StringVar()
GigaGargAdventure_c1 = tk.Checkbutton(ZombieAdventureLabel, text='Include Giga Garguantuars', variable=GigaGargAdventure,
onvalue='y',offvalue='n', state = tk.DISABLED)
GigaGargAdventure_c1.grid(row=7,column=8)
GigaGargAdventure.set('n')
BalloonZombieCounterCheck=tk.StringVar()
BalloonZombieCounterCheck_c1 = tk.Checkbutton(ZombieAdventureLabel, text='Allow Balloon Zombie to spawn after his counter plant is unlocked.', variable=BalloonZombieCounterCheck,
onvalue='y',offvalue='n', state = tk.DISABLED)
BalloonZombieCounterCheck_c1.grid(row=5,column=9)
BalloonZombieCounterCheck.set('n')
CustomZombieAdventure=tk.StringVar()
CustomZombieAdventure_c1 = tk.Checkbutton(ZombieAdventureLabel, text='Include Custom Zombies', variable=CustomZombieAdventure,
onvalue='y',offvalue='n', state = tk.DISABLED)
CustomZombieAdventure_c1.grid(row=6,column=9)
CustomZombieAdventure.set('n')
PlantLabel = tk.LabelFrame(my_w, text="Plants")
PlantLabel.grid(row=1,column=1, columnspan=2, pady=5)
PlantSeedPacketLabel = tk.LabelFrame(PlantLabel, text="Randomize plant seedpackets")
PlantSeedPacketLabel.grid(row=1,column=1, columnspan=2, pady=5)
StorePlants=tk.StringVar()
StorePlants_c1 = tk.Checkbutton(PlantSeedPacketLabel, text='Shuffle the order of store plants', variable=StorePlants,
onvalue='y',offvalue='n', state = tk.NORMAL)
StorePlants_c1.grid(row=5,column=1)
StorePlants.set('n')
AdventureModeSeedpackets=tk.StringVar()
AdventureModeSeedpackets_c1 = tk.Checkbutton(PlantSeedPacketLabel, text='Randomize Adventure mode seedpacket awards', variable=AdventureModeSeedpackets,
onvalue='y',offvalue='n', command = switchButtonStateT, state = tk.NORMAL)
AdventureModeSeedpackets_c1.grid(row=1,column=1)
AdventureModeSeedpackets.set('n')
PlantAdventureSeedPacket = tk.LabelFrame(PlantSeedPacketLabel, text="Adventure mode seedpacket options")
PlantAdventureSeedPacket.grid(row=2,column=1, columnspan=2, pady=5)
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket=tk.StringVar()
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1 = tk.Checkbutton(PlantAdventureSeedPacket, text="Don't Randomize Puff-shroom's award seedpacket", variable=AdventureModeSeedpackets_DontRandomizedPuffSeedpacket,
onvalue='y',offvalue='n', state = tk.DISABLED)
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket_c1.grid(row=1,column=1)
AdventureModeSeedpackets_DontRandomizedPuffSeedpacket.set('n')
AdventureModeSeedpackets_matchseedpackets=tk.StringVar()
AdventureModeSeedpackets_matchseedpackets_c1 = tk.Checkbutton(PlantAdventureSeedPacket, text="Don't change the seedpacket icons", variable=AdventureModeSeedpackets_matchseedpackets,
onvalue='y',offvalue='n', state = tk.DISABLED)
AdventureModeSeedpackets_matchseedpackets_c1.grid(row=2,column=1)
AdventureModeSeedpackets_matchseedpackets.set('n')
AdventureModeCustomSeedpackets=tk.StringVar()
AdventureModeCustomSeedpackets_cl = tk.Checkbutton(PlantAdventureSeedPacket, text="Include custom plants", variable=AdventureModeCustomSeedpackets,
onvalue='y',offvalue='n', state = tk.DISABLED)
AdventureModeCustomSeedpackets_cl.grid(row=3,column=1)
AdventureModeCustomSeedpackets.set('n')
Converyor=tk.StringVar()
Converyor_c1 = tk.Checkbutton(PlantSeedPacketLabel, text='Randomize seedpackets in conveyorbelt levels', variable=Converyor,
onvalue='y',offvalue='n', command = switchButtonStateB, state = tk.NORMAL)
Converyor_c1.grid(row=3,column=1)
Converyor.set('n')
ConveryorAll=tk.StringVar()
ConveryorAll_c1 = tk.Checkbutton(PlantSeedPacketLabel, text='Have almost all seedpackets in every conveyorbelt level', variable=ConveryorAll,
onvalue='y',offvalue='n', state = tk.DISABLED)
ConveryorAll_c1.grid(row=4,column=1)
ConveryorAll.set('n')
PlantStatsLabel = tk.LabelFrame(PlantLabel, text="Randomize Plant Stats")
PlantStatsLabel.grid(row=2,column=1, columnspan=2, pady=5)
DowngradePlants=tk.StringVar()
DowngradePlants_c1 = tk.Checkbutton(PlantStatsLabel, text='Randomize downgrade plants of upgrade plants', variable=DowngradePlants,
onvalue='y',offvalue='n')
DowngradePlants_c1.grid(row=5,column=1)
DowngradePlants.set('n')
PlantHealth=tk.StringVar()
PlantHealth_c1 = tk.Checkbutton(PlantStatsLabel, text='Randomize defensive plant health', variable=PlantHealth,
onvalue='y',offvalue='n')
PlantHealth_c1.grid(row=6,column=1)
PlantHealth.set('n')
PlantDamage=tk.StringVar()
PlantDamage_c1 = tk.Checkbutton(PlantStatsLabel, text='Randomize plant attack damage', variable=PlantDamage,
onvalue='y',offvalue='n')
PlantDamage_c1.grid(row=7,column=1)
PlantDamage.set('n')
PlantAction=tk.StringVar()
PlantAction_c1 = tk.Checkbutton(PlantStatsLabel, text='Randomize plant action rate', variable=PlantAction,
onvalue='y',offvalue='n')
PlantAction_c1.grid(row=8,column=1)
PlantAction.set('n')
#
MISCLabel = tk.LabelFrame(my_w, text="MISC")
MISCLabel.grid(row=2,column=1, columnspan=9, pady=4)
RandomizeBackgroundlabele = tk.LabelFrame(MISCLabel, text="Background randomizer (BETA)")
RandomizeBackgroundlabele.grid(row=2,column=1, columnspan=9, pady=4)
RandomizeBackgrounds=tk.StringVar()
RandomizeBackground_c1 = tk.Checkbutton(RandomizeBackgroundlabele, text='Randomize backgrounds per world in adventure mode', variable=RandomizeBackgrounds,
onvalue='y',offvalue='n', command = switchButtonStateC, state = tk.NORMAL)
RandomizeBackground_c1.grid(row=1,column=1)
RandomizeBackgrounds.set('n')
Backgroundoptionslabel = tk.LabelFrame(RandomizeBackgroundlabele, text="Background randomizer Options")
Backgroundoptionslabel.grid(row=2,column=1, columnspan=2, pady=5)
RandomizeCustomBackground=tk.StringVar()
RandomizeCustomBackground_c1 = tk.Checkbutton(Backgroundoptionslabel, text='Include custom backgrounds', variable=RandomizeCustomBackground,
onvalue='y',offvalue='n', state = tk.DISABLED)
RandomizeCustomBackground_c1.grid(row=2,column=1)
RandomizeCustomBackground.set('n')
#
Sunmeta50=tk.StringVar()
Sunmeta_c1 = tk.Checkbutton(MISCLabel, text='50 sun meta', variable=Sunmeta50,
onvalue='y',offvalue='n', state = tk.NORMAL)
Sunmeta_c1.grid(row=3,column=1)
Sunmeta50.set('n')
#
my_w.mainloop()