-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.py
More file actions
751 lines (667 loc) · 23.5 KB
/
GUI.py
File metadata and controls
751 lines (667 loc) · 23.5 KB
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
import json
from tkinter import *
from tkinter.filedialog import askopenfilename, askdirectory
from tkinter import font
import os
from os.path import *
import importlib.machinery
import importlib.util
from pathlib import Path
# OH MY GOD MARIO REFERENCE!!?!
import webbrowser as browser
import sys
from urllib.request import urlopen
from helpers import *
from menus import *
import jsonc
import certifi
import ssl
from am_i_connected import CheckThereIsConnection
selected_scr = ''
scr_dat = ''
class Flags:
def __init__(self):
# Enables Developer mode, which disables automatic updates and enables extra logging
self.devMode = False
# Flag specifically for Snark, scripts are currently not implemented yet and is a copy of the scripting system from SMD Tools v1.1
# This will allow me to disable the functionality for it until I come up with a proper implementation
self.allowScripts = True
# Another flag for Snark, it disables booting to the "games" menu and makes the menu show a "This menu will be completed soon" message
# instead of showing the menu
self.allowGames = True
class Interp:
def __init__(self, scr_ref):
self.err = False
self.scr_ref = "scripts/" + scr_ref + '.txt'
if not os.path.exists(self.scr_ref):
print("How did we get here?")
self.err = True
else:
self.interp()
def nl_clean(self, smd):
count = -1
for l in smd:
count += 1
smd[count] = l[:-l.count("\n")]
return smd
def interp(self):
global scr_dat
global guii
scr_f = open(self.scr_ref, 'r')
scr = self.nl_clean(scr_f.readlines())
self.mode = ''
if scr[0] == 'mode dupe':
self.mode = 'd'
elif scr[0] == 'mode mat':
self.mode = 'm'
elif scr[0] == 'mode bmp':
self.mode = 'b'
else:
self.mode = None
print("Before: "+ str(scr))
scr.pop(0)
scr.pop(len(scr) - 1)
print("After: "+ str(scr))
print(scr)
scr_dat = [self.mode, scr]
guii.exec_script(scr_dat)
class OptWin:
def __init__(self):
self.nroot = Tk()
self.win()
self.nroot.mainloop()
def win(self):
self.nroot.title("Options")
frame = Frame(self.nroot, borderwidth=2, relief="sunken")
frame.grid(column=1, row=1, sticky=(N, E, S, W))
self.nroot.columnconfigure(1, weight=1)
self.nroot.rowconfigure(1, weight=1)
jsf = open('save/options.json', 'r')
js = jsf.read()
self.options = json.loads(js)
self.b_smd_val = BooleanVar(frame, value=self.options["backup_smd"])
print(self.b_smd_val.get())
b_smd = Checkbutton(frame, text="Backup SMDs", variable=self.b_smd_val, command=self.set_backup_smd)
b_smd.grid(column=1, row=1, sticky=(S), padx=50, pady=40)
"""self.s_vals_val = BooleanVar(frame, value=self.options["save_paths"])
s_vals = Checkbutton(frame, text="Save User Inputs", variable=self.s_vals_val, command=self.set_save_values)
s_vals.grid(column=1, row=1, sticky=(S), padx=50, pady=60)"""
select_scr = Button(frame, text="Confirm", command=self.confirm_opts)
select_scr.grid(column=1, row=6, sticky=(S))
def set_backup_smd(self):
self.options["backup_smd"] = self.b_smd_val.get()
print(self.options["backup_smd"])
def set_save_values(self):
self.options["save_paths"] = self.s_vals_val.get()
print(self.options["backup_smd"])
def confirm_opts(self):
newjson = json.dumps(self.options, sort_keys=True, indent=5)
opts = open('save/options.json', 'w')
opts.write(newjson)
opts.close()
self.nroot.destroy()
class GetNewVersion:
def __init__(self, version, theme):
self.thme = theme
self.nroot = Tk()
v = version.split("-")[0]
self.win(v)
self.nroot.mainloop()
def win(self, ver):
self.nroot.title(f"Version {ver} is out!")
frame = Frame(self.nroot, borderwidth=2, relief="sunken", bg=self.thme["bg"])
frame.grid(column=1, row=1, sticky=(N, E, S, W))
self.nroot.columnconfigure(1, weight=1)
self.nroot.rowconfigure(1, weight=1)
buttons = Frame(frame, borderwidth=2)
buttons.grid(column=1, row=1, sticky=(S), columnspan=10)
text = Label(frame, text="A new version of Snark has been released,\n do you want to update to the new version?")
text.grid(column=1, row=0, padx=50, pady=40)
self.dlButton = Button(buttons, text="Yes", command=self.releasesPage)
self.dlButton.grid(column=0, row=1, sticky=(S))
self.noButton = Button(buttons, text="No", command=self.closeWin)
self.noButton.grid(column=1, row=1, sticky=(S))
self.applyTheme(frame)
self.applyTheme(buttons)
def applyTheme(self, master):
style=ttk.Style()
style.theme_use('clam')
style.configure("TCombobox", fieldbackground=self.thme["ent"])
for w in master.winfo_children():
if w.winfo_class() == "Button":
w.configure(bg=self.thme["btn"][0])
w.configure(highlightbackground=self.thme["btn"][1])
w.configure(activebackground=self.thme["btn"][2])
w.configure(fg=self.thme["txt"])
elif w.winfo_class() == "Entry":
w.configure(bg=self.thme["ent"])
w.configure(fg=self.thme["txt"])
elif isinstance(w, ttk.Combobox):
pass
w.configure(foreground='white')
# w["menu"].config(bg=self.thme["btn"][1])
elif isinstance(w, Text):
w.configure(bg=self.thme["ent"])
w.configure(fg=self.thme["txt"])
elif w.winfo_class() == "Checkbutton":
w.configure(bg=self.thme["bg"])
w.configure(highlightbackground=self.thme["bg"])
w.configure(activebackground=self.thme["bg"])
w.configure(fg=self.thme["txt"])
w.configure(selectcolor=self.thme["ent"])
else:
w.configure(bg=self.thme["bg"])
try:
w.configure(fg=self.thme["txt"])
except:
pass
def releasesPage(self):
browser.open_new("https://github.com/PostScriptReal/Snark_Compiler/releases/latest")
self.nroot.destroy()
def closeWin(self):
self.nroot.destroy()
def confirm_opts(self):
newjson = json.dumps(self.options, sort_keys=True, indent=5)
opts = open('save/options.json', 'w')
opts.write(newjson)
opts.close()
self.nroot.destroy()
class GUI(Tk):
def get_options(self):
jsf = open('save/options.json', 'r')
js = jsf.read()
jsf.close()
self.options = json.loads(js)
def save_options(self):
newjson = json.dumps(self.options, sort_keys=True, indent=5)
opts = open('save/options.json', 'w')
opts.write(newjson)
opts.close()
def check_version(self):
url = "https://github.com/PostScriptReal/Snark_Compiler/raw/refs/heads/main/version.txt"
if CheckThereIsConnection():
webVer = urlopen(url, context=ssl.create_default_context(cafile=certifi.where())).read().decode('utf-8')
print(webVer)
# Don't you dare make a Fortnite joke
vFile = open("version.txt", "r")
curVer = vFile.read()
if curVer != webVer:
a = GetNewVersion(webVer, self.chkVerTheme)
def __init__(self):
super().__init__()
self.flags = Flags()
# Set Window title
self.title("Snark")
if sys.platform == 'linux':
self.fixGUI = True
else:
self.fixGUI = False
# Get Options
self.get_options()
self.selTheme = self.options["theme"]
winSizeFile = False
winSizeVer = 3
if sys.platform == "linux" and os.path.exists(f"WinSize{winSizeVer}.txt"):
wsFile = open(f"WinSize{winSizeVer}.txt", "r")
ws = wsFile.readlines()
wsFile.close()
winSizeFile = True
# Loading in window icon
ico = PhotoImage(file="icon-linux.png")
self.iconphoto(True, ico)
thCol = {}
# Defining colours for the theme
if self.selTheme == "Freeman":
thCol = {
"bg": "#ff862d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb6524", "#ed763c", "#ee8d5e"],
"ent": "#e3573d",
"txt": "white",
"tt": "#dc5200"
}
elif self.selTheme == "Shephard":
thCol = {
"bg": "#11da00",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#27be07", "#2ad008", "#31e50c"],
"ent": "#4dc011",
"txt": "white",
"tt": "#14a000"
}
elif self.selTheme == "Calhoun":
thCol = {
"bg": "#4741ff",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#1f2deb", "#333fec", "#4f5aed"],
"ent": "#5074e6",
"txt": "white",
"tt": "#0006f8"
}
elif self.selTheme == "Cross":
thCol = {
"bg": "#ff362d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb242f", "#ed3c46", "#ee5e66"],
"ent": "#e33d63",
"txt": "white",
"tt": "#dc0002"
}
else:
if os.path.exists(f'themes/{self.selTheme}.jsonc'):
fp = open(f'themes/{self.selTheme}.jsonc', 'r')
thCol = jsonc.load(fp)
elif os.path.exists(f'themes/{self.selTheme}.json'):
fp = open(f'themes/{self.selTheme}.json', 'r')
thCol = json.loads(fp.read())
else:
print('Cannot find the theme, is it a .json or .jsonc file?')
print('Defaulting to the Freeman theme.')
thCol = {
"bg": "#ff862d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb6524", "#ed763c", "#ee8d5e"],
"ent": "#e3573d",
"txt": "white",
"tt": "#dc5200"
}
"""if self.options["save_paths"]:
self.save_paths = True
js = open("save/paths.json", 'r')
self.sPaths = json.loads(js.read())
self.bonez = self.sPaths["bonez"]
self.matfix = self.sPaths["matFix"]
else:
self.save_paths = False"""
self.chkVerTheme = thCol
widgets = []
buttons = []
# Create Window
self.frame = Frame(self, borderwidth=2, relief="sunken", bg=thCol["bg"])
self.frame.grid(column=6, row=2, sticky=(N, E, S, W))
self.header = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.header.grid(column=0, row=1, sticky=(N, W, E), columnspan=69)
menu = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
menu.grid(column=0, row=2, sticky=(W, S), columnspan=69)
"""
For whatever reason, I can't get the menus past the Decompile menu
to show up, so I have to make separate Frame objects in order to get
them to work properly.
Tkinter is really starting to hold me hostage here.
"""
self.dumbFixMenu = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.dumbFixMenu2 = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.dumbFixMenu3 = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.dumbFixMenu4 = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.dumbFixMenu5 = Frame(self.frame, borderwidth=2, bg=thCol["bg"])
self.columnconfigure(6, weight=1)
self.rowconfigure(2, weight=1)
buttonPad = 0
if not self.fixGUI:
buttonPad = 5
# Create Header Buttons
self.dupe_button = Button(self.header, text="Games", command=self.bd_menu, bg=thCol["btn"][0], cursor="hand2")
self.dupe_button.grid(column=0, row=0, sticky="nw", ipadx=buttonPad)
self.cmpiler_button = Button(self.header, text="Compilers", command=self.cmpSetupMenu, bg=thCol["btn"][0], cursor="hand2")
self.cmpiler_button.grid(column=1, row=0, sticky="nw", ipadx=buttonPad)
self.mat_button = Button(self.header, text="Decompile", command=self.mnc_menu, bg=thCol["btn"][0], cursor="hand2")
self.mat_button.grid(column=2, row=0, sticky="nw", ipadx=buttonPad)
self.comp_button = Button(self.header, text="Compile", command=self.cmp_menu, bg=thCol["btn"][0], cursor="hand2")
self.comp_button.grid(column=3, row=0, sticky="nw", ipadx=buttonPad)
self.scripts = Button(self.header, text="Batch Manager", command=self.scripts, bg=thCol["btn"][0], cursor="hand2")
self.scripts.grid(column=4, row=0, sticky="nw", ipadx=buttonPad)
self.options = Button(self.header, text="Options", command=self.optionsMenu, bg=thCol["btn"][0], cursor="hand2")
self.options.grid(column=6, row=0, sticky="nw", ipadx=buttonPad)
self.help = Button(self.header, text="Help", command=self.help, bg=thCol["btn"][0], cursor="hand2")
self.help.grid(column=7, row=0, sticky="nw", ipadx=buttonPad)
self.aboutB = Button(self.header, text="About", command=self.about, cursor="hand2")
self.aboutB.grid(column=5, row=0, sticky="nw", ipadx=buttonPad)
# Getting the width of the window before adding in the menus so I can fix the width of the window on different OSs/distros
if winSizeFile and not ws[0] == "":
self.goodWidth = int(ws[0].replace("\n", ""))
else:
self.update()
self.goodWidth = self.winfo_width()
print(self.goodWidth)
self.mTemplate = MenuTemp(thCol, self.goodWidth)
self.dumbFixMenu3.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.optMenu = OptionsMenu(self.mTemplate, self.dumbFixMenu3, self.changeTheme, self.updateOpt, True)
self.dumbFixMenu3.grid_remove()
self.setupMenu = SetupMenu(self.mTemplate, menu, self.updateGames)
self.dumbFixMenu4.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.compSetMenu = CompSetupMenu(self.mTemplate, self.dumbFixMenu4, self.updateComps, self.flags.allowGames)
self.dumbFixMenu4.grid_remove()
if self.flags.allowScripts:
self.dumbFixMenu5.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.batchMenu = BatchManagerM(self.mTemplate, self.dumbFixMenu5, True)
self.dumbFixMenu5.grid_remove()
self.decMenu = DecompMenu(self.mTemplate, menu, self.batchMenu, True)
self.dumbFixMenu.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.cmpMenu = CompMenu(self.mTemplate, self.dumbFixMenu, self.batchMenu, False)
if winSizeFile:
self.dumbFixMenu.grid_remove()
self.cmpMenu.hidden = True
self.dumbFixMenu2.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.abtMenu = AboutMenu(self.mTemplate, self.dumbFixMenu2, True)
self.dumbFixMenu2.grid_remove()
# Getting the maximum height
if not self.cmpMenu.hidden or winSizeFile:
if winSizeFile and not ws[1] == "":
self.goodHeight = int(ws[1].replace("\n", ""))
else:
self.update()
self.goodHeight = self.winfo_reqheight()
# Switching back to the setup menu
self.cmpMenu.hide()
self.dumbFixMenu.grid_remove()
self.setupMenu.show()
self.update()
print(self.goodHeight)
if sys.platform == 'linux':
self.geometry(f"{self.goodWidth+1}x{self.goodHeight}")
else:
self.geometry("501x443")
if not os.path.exists(f"WinSize{winSizeVer}.txt"):
wsf = open(f"WinSize{winSizeVer}.txt", "w")
wsf.write(f"{self.goodWidth}\n{self.goodHeight}")
wsf.close()
# Applying theme
for w in self.header.winfo_children():
w.configure(bg=thCol["btn"][0])
w.configure(highlightbackground=thCol["btn"][1])
w.configure(activebackground=thCol["btn"][2])
try:
w.configure(fg=thCol["txt"])
except:
pass
if not self.flags.devMode:
print("Attempting to connect to update server...")
try:
self.check_version()
except:
print("Unable to check latest version, are you connected to the internet?")
def help(self):
if not self.compSetMenu.hidden:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki/Getting-around-the-limitations-of-the-Snark-GUI#adding-compilers')
elif not self.cmpMenu.hidden:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki/How-to-use-Snark#compiling')
elif not self.decMenu.hidden:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki/How-to-use-Snark#decompiling')
elif not self.optMenu.hidden and self.optMenu.curPage == 1:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki/How-to-use-Snark#setting-up-hlamhlmv-for-snark')
elif not self.batchMenu.hidden:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki/How-to-use-Snark#batch-decompiling-and-compiling')
else:
browser.open_new('https://github.com/PostScriptReal/Snark_Compiler/wiki')
def changeTheme(self, a):
self.selTheme = self.optMenu.themeCBox.get()
# Refreshing options because for some reason not doing this causes errors.
# Computers are so dumb man.
self.get_options()
self.options["theme"] = self.optMenu.themeCBox.get()
self.save_options()
thCol = {}
# Defining colours for the theme
if self.selTheme == "Freeman":
thCol = {
"bg": "#ff862d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb6524", "#ed763c", "#ee8d5e"],
"ent": "#e3573d",
"txt": "white",
"tt": "#dc5200"
}
elif self.selTheme == "Shephard":
thCol = {
"bg": "#11da00",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#27be07", "#2ad008", "#31e50c"],
"ent": "#4dc011",
"txt": "white",
"tt": "#14a000"
}
elif self.selTheme == "Calhoun":
thCol = {
"bg": "#4741ff",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#1f2deb", "#333fec", "#4f5aed"],
"ent": "#5074e6",
"txt": "white",
"tt": "#0006f8"
}
elif self.selTheme == "Cross":
thCol = {
"bg": "#ff362d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb242f", "#ed3c46", "#ee5e66"],
"ent": "#e33d63",
"txt": "white",
"tt": "#dc0002"
}
else:
if os.path.exists(f'themes/{self.selTheme}.jsonc'):
f = open(f'themes/{self.selTheme}.jsonc', 'r')
thCol = jsonc.load(f)
elif os.path.exists(f'themes/{self.selTheme}.json'):
f = open(f'themes/{self.selTheme}.json', 'r')
thCol = json.loads(f.read())
else:
print('Cannot find the theme, is it a .json or .jsonc file?')
print('Defaulting to the Freeman theme.')
thCol = {
"bg": "#ff862d",
# First value is inactive colour, 2nd hover and 3rd being the active colour
"btn": ["#eb6524", "#ed763c", "#ee8d5e"],
"ent": "#e3573d",
"txt": "white",
"tt": "#dc5200"
}
self.setupMenu.changeTheme(thCol)
self.abtMenu.changeTheme(thCol)
self.cmpMenu.changeTheme(thCol)
self.decMenu.changeTheme(thCol)
self.optMenu.changeTheme(thCol)
self.compSetMenu.changeTheme(thCol)
self.batchMenu.changeTheme(thCol)
self.setupMenu.master.config(bg=thCol["bg"])
self.cmpMenu.master.config(bg=thCol["bg"])
self.abtMenu.master.config(bg=thCol["bg"])
self.optMenu.master.config(bg=thCol["bg"])
self.compSetMenu.master.config(bg=thCol["bg"])
self.batchMenu.master.config(bg=thCol["bg"])
self.frame.config(bg=thCol["bg"])
self.header.config(bg=thCol["bg"])
for w in self.header.winfo_children():
w.configure(bg=thCol["btn"][0])
w.configure(highlightbackground=thCol["btn"][1])
w.configure(activebackground=thCol["btn"][2])
try:
w.configure(fg=thCol["txt"])
except:
pass
def about(self):
if self.abtMenu.hidden:
self.setupMenu.hide()
self.compSetMenu.hide()
self.dumbFixMenu2.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.dumbFixMenu.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid_remove()
self.abtMenu.show()
self.cmpMenu.hide()
self.decMenu.hide()
self.optMenu.hide()
if self.flags.allowScripts:
self.batchMenu.hide()
def updateOpt(self, key, val):
self.setupMenu.updateOpt(key, val)
self.compSetMenu.updateOpt(key, val)
self.abtMenu.updateOpt(key, val)
self.cmpMenu.updateOpt(key, val)
self.decMenu.updateOpt(key, val)
self.optMenu.updateOpt(key, val)
self.batchMenu.updateOpt(key, val)
def updateGames(self, comp):
self.cmpMenu.updateGames(comp)
def updateComps(self, comp, val):
self.cmpMenu.updateComp(comp, val)
def optionsMenu(self):
if self.optMenu.hidden:
self.setupMenu.hide()
self.compSetMenu.hide()
self.dumbFixMenu3.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid_remove()
self.dumbFixMenu.grid_remove()
self.dumbFixMenu2.grid_remove()
self.abtMenu.hide()
self.cmpMenu.hide()
self.decMenu.hide()
self.optMenu.show()
if self.flags.allowScripts:
self.batchMenu.hide()
def openfile(self):
startDir = self.options["startFolder"]
if startDir.startswith("~"):
startDir = os.path.expanduser(startDir)
fileTypes = [("Quake Compile Files", "*.qc"), ("All Files", "*.*")]
self.path.set(askopenfilename(title="Select QC", initialdir=startDir, filetypes=fileTypes))
self.qcDATA = QCHandler(self.path.get())
self.qcDATA.get_bodygroups()
self.qcDATA.getAnimFolder()
self.mdls = self.qcDATA.bodies
self.anims = self.qcDATA.animPath
def opendir(self):
# startdir = self.options["startFolder"]
startDir = os.path.expanduser("~/Documents")
self.path.set(askdirectory(title="Select Anims Folder", initialdir=startDir))
def dupe_scr(self, base, new, parent, qc):
# Alternate bone duping function for scripts
qc.startScript(batch=qc.batch, values=[base, new, parent])
""" Switches menu to the Game Setup Menu """
def bd_menu(self):
if self.setupMenu.hidden:
self.dumbFixMenu.grid_remove()
self.dumbFixMenu2.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid_remove()
self.decMenu.hide()
self.cmpMenu.hide()
self.setupMenu.show()
self.compSetMenu.hide()
self.abtMenu.hide()
self.optMenu.hide()
if self.flags.allowScripts:
self.batchMenu.hide()
def cmpSetupMenu(self):
if self.compSetMenu.hidden:
self.dumbFixMenu.grid_remove()
self.dumbFixMenu2.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.dumbFixMenu5.grid_remove()
self.decMenu.hide()
self.cmpMenu.hide()
self.compSetMenu.show()
self.setupMenu.hide()
self.abtMenu.hide()
self.optMenu.hide()
if self.flags.allowScripts:
self.batchMenu.hide()
""" Switches menu to Decompile Menu """
def mnc_menu(self):
if self.decMenu.hidden:
self.dumbFixMenu.grid_remove()
self.dumbFixMenu2.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid_remove()
self.setupMenu.hide()
self.cmpMenu.hide()
self.decMenu.show()
self.abtMenu.hide()
self.optMenu.hide()
self.compSetMenu.hide()
if self.flags.allowScripts:
self.batchMenu.hide()
""" Switches menu to Compile Menu """
def cmp_menu(self):
if self.cmpMenu.hidden:
self.setupMenu.hide()
self.compSetMenu.hide()
self.dumbFixMenu.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.dumbFixMenu2.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid_remove()
self.cmpMenu.show()
self.decMenu.hide()
self.abtMenu.hide()
self.optMenu.hide()
if self.flags.allowScripts:
self.batchMenu.hide()
# print(f"width: {self.winfo_width()} height: {self.winfo_height()}")
def scripts(self):
if self.flags.allowScripts:
if self.batchMenu.hidden:
self.setupMenu.hide()
self.compSetMenu.hide()
self.dumbFixMenu.grid_remove()
self.dumbFixMenu2.grid_remove()
self.dumbFixMenu3.grid_remove()
self.dumbFixMenu4.grid_remove()
self.dumbFixMenu5.grid(column=0, row=2, sticky="nsew", columnspan=10)
self.cmpMenu.hide()
self.decMenu.hide()
self.abtMenu.hide()
self.optMenu.hide()
self.batchMenu.show()
else:
a = ScriptWin()
def exec_script(self, script):
# Script parsing and execution function
print('Executing script')
values = []
mode = script[0]
inst = None
if mode == 'm' or mode == 'b':
inst = PointerFix()
else:
inst = Dupe()
qcSelect = QCWin(self.qcDATA, inst, mode, [], True, script[1])
"""# If in duping mode
if mode == 'd':
for d in script[1]:
if d == '-':
self.dupe_scr(values[0], values[1], values[2], qcSelect)
values = []
continue
else:
values.append(d)
# If in pointer fix mode
elif mode == 'm':
for d in script[1]:
if d == '-':
self.matrename_scr(values[0], values[1], values[2], qcSelect)
values = []
continue
else:
values.append(d)
# If in bitmap ext mode
elif mode == 'b':
for d in script[1]:
if d == '-':
self.bmp_scr(values[0], qcSelect)
values = []
continue
else:
values.append(d)
# If in plugin initialising mode
elif mode == 'p':
print(script)
filename = script[1][0]
w = PluginWarning(filename)"""
guii = GUI()
guii.mainloop()