-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathProgression_GUI.py
748 lines (714 loc) · 38.5 KB
/
Progression_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
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
'''
Created on Aug 23, 2021
@author: Cyrus
##################
### GUI LAYOUT ###
##################
#################################################
# #
# VARIABLE_TEXT #
# #
# |-----------------------------------------| #
# |////////////////////// | #
# |-----------------------------------------| #
# #
#################################################
####################
### GUI FUNCTION ###
####################
VARIABLE TEXT:
1) Setup
2) Decompressing
3) Randomizing Worlds
4) Miscellaneous Options
5) Compressing
6) CRC Tool
7) Clean Up
8) Done, Close Window
###########################
### GUI ERRORS/WARNINGS ###
###########################
* Closing the progress bar window prematurely does not stop the process from attempting to finish.
* Closing the user gui will close this window, causing a crash. Process does not finish.
* If error occurs, progress bar remains frozen. Needs to be updated to alert the user a crash occured.
#########################
### USER GUI OVERVIEW ###
#########################
########## ################# ############################## #####################
# # # # # # 8 DONE # #
# USER GUI # -----> # PROGRESSION GUI # ----------> # PROGRESS BAR WINDOW # --------> # YOU CAN CLOSE NOW #
# # # # # # # #
########## ################# ############################## #####################
| ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | |
| ################### | | | | | | | |
| # # | | | | | | | |
1 |-> # SETUP FUNCTIONS #--| | | | | | | |
| # # | | | | | | |
| ################### | | | | | | |
| | | | | | | |
| ################# | | | | | | |
| # # | | | | | | |
2 |-----> # DECOMPRESSING # | | | | | | |
| # FUNCTIONS #----| | | | | | |
| # # | | | | | |
| ################# | | | | | |
| | | | | | |
| ############### | | | | | |
| # # | | | | | |
| # RANDOMIZING # | | | | | |
3 |---------> # WORLDS #-----| | | | | |
| # # | | | | |
| ############### | | | | |
| | | | | |
| ################# | | | | |
| # # | | | | |
4 |-------------> # MISCELLANEOUS #--| | | | |
| # OPTIONS # | | | |
| # # | | | |
| ################# | | | |
| | | | |
| ############### | | | |
| # # | | | |
5 |-----------------> # RECALCULATE #----| | | |
| # CHECKSUM # | | |
| # # | | |
| ############### | | |
| | | |
| ############### | | |
| # # | | |
| # COMPRESSING # | | |
6 |--------------------> # FUNCTIONS #-----| | |
| # # | |
| ############### | |
| | |
| ############ | |
| # # | |
7 |------------------------> # CRC TOOL #--------| |
| # # |
| ############ |
| |
| ############ |
| # # |
8 |---------------------------> # CLEAN UP #---------|
# #
############
'''
######################
### PYTHON IMPORTS ###
######################
from random import seed, randint, choice
import tkinter as tk
from tkinter import ttk
from tkinter import HORIZONTAL
import threading
import gc
####################
### FILE IMPORTS ###
####################
from Randomization_Processes.Setup_Functions import setup_tmp_folder, set_seed, make_copy_of_rom
from Randomization_Processes.Decompress_Functions import Decompressor
from Randomization_Processes.Compress_Functions import Compressor
from Randomization_Processes.World_Manipulation.World_Manipulation_Main import World_Manipulation_Class
from Randomization_Processes.Misc_Manipulation.Misc_Manipulation_Main import Misc_Manipulation_Class
# from Randomization_Processes.CRC_Tool import run_crc_calc
from Randomization_Processes.CRC_Tool import CRC_Calc_Class
from Randomization_Processes.Clean_Up import CleanUp
from Randomization_Processes.BK_Checksum import BK_Checksum_Class
#################
### GUI CLASS ###
#################
class Progression_GUI_Class():
'''Progression GUI class'''
def __init__(self, master):
'''Initializes the Progress GUI'''
self.master = master
self.rom_path = self.master.rom_file_entry.get()
if(master.app_window):
self.progress_bar_window = tk.Toplevel(master.app_window)
else:
self.progress_bar_window = tk.Tk()
self.progress_bar_window.winfo_toplevel().title("Banjo-Kazooie Randomizer Progress Bar")
# self.progress_bar_window.geometry("400x50")
self.progress_bar_window.config(background="#F3E5AB")
self.progress_bar_value = 0
self._mumbo_error_message = "Please Check The ReadMe Under 'GUI Errors/Warnings' For Instructions"
self.transform_cost_dict = {
"Termite": 5,
"Crocodile": 10,
"Walrus": 15,
"Pumpkin": 20,
"Bee": 25
}
class App_Variable_Label():
'''A text box that can altered after creation'''
def __init__(self, window, label_text):
'''Initializes variable label'''
self.text = tk.StringVar()
self.text.set(label_text)
self.label = tk.Label(window, textvariable=self.text, background="#F3E5AB", font=("Arial", 12), padx=5, pady=5)
def set_text(self, new_text):
'''Changes the text'''
self.text.set(new_text)
def pack_label(self):
'''Displays label'''
self.label.pack()
class App_ProgressBar():
'''A progress bar'''
def __init__(self, window, bar_length=390, bar_mode='determinate'):
'''Initializes progress bar'''
self.progressbar = ttk.Progressbar(window, style="bk.Horizontal.TProgressbar", orient=HORIZONTAL, length=bar_length, mode=bar_mode)
self.progressbar.config(maximum=100)
def update_bar(self, percentage):
'''Updates progress bar percentage'''
self.progressbar['value'] = percentage
def pack_bar(self):
'''Displays progress bar'''
self.progressbar.pack(padx=5, pady=5)
def _hidden_random_values(self):
'''Calculates hidden values'''
self.master.logger.info("Hidden Random Values")
cheat_sheet = ""
# Final Note Door
if(self.master.final_note_door_value.get() == "?"):
seed(a=(self.master.seed_value.get()))
increment = 1
if(self.master.struct_var.get() == "All Notes"):
seed(a=(self.seed_val + increment))
final_note_door_str = str(randint(0, 1))
while(len(final_note_door_str) < 4):
increment += 1
seed(a=(self.seed_val + increment))
final_note_door_str += str(randint(0, 8))
self.master.final_note_door_val = int(final_note_door_str)
else:
final_note_door_str = ""
while(len(final_note_door_str) < 3):
seed(a=(self.seed_val + increment))
final_note_door_str += str(randint(0, 8))
increment += 1
self.master.final_note_door_val = int(final_note_door_str)
cheat_sheet += f"Final Note Door Val: {self.master.final_note_door_val}\n"
else:
self.master.final_note_door_val = int(self.master.final_note_door_value.get())
self.master.logger.debug(f"Final Note Door Val: {self.master.final_note_door_val}")
# Final Puzzle
if(self.master.final_puzzle_value.get() == "?"):
seed(a=(self.master.seed_value.get()))
if(self.master.remove_floating_jiggies_var.get() == 1):
seed(a=(self.seed_val + 3))
self.master.final_puzzle_val = randint(0, 50)
else:
seed(a=(self.seed_val + 4))
self.master.final_puzzle_val = randint(0, 99)
cheat_sheet += f"Final Puzzle Val: {self.master.final_puzzle_val}\n"
else:
self.master.final_puzzle_val = int(self.master.final_puzzle_value.get())
self.master.logger.debug(f"Final Puzzle Val: {self.master.final_puzzle_val}")
### CAPACITIES
# Blue Egg Capacity
if(self.master.before_blue_egg_carry_value.get() == "?"):
seed(a=(self.seed_val + 5))
self.master.before_blue_egg = randint(0, 255)
cheat_sheet += f"Before Cheato Blue Egg: {self.master.before_blue_egg}\n"
else:
self.master.before_blue_egg = int(self.master.before_blue_egg_carry_value.get())
self.master.logger.debug(f"Before Cheato Blue Egg: {self.master.before_blue_egg}")
if(self.master.after_blue_egg_carry_value.get() == "?"):
seed(a=(self.seed_val + 6))
self.master.after_blue_egg = randint(self.master.before_blue_egg, 255)
cheat_sheet += f"After Cheato Blue Egg: {self.master.after_blue_egg}\n"
else:
self.master.after_blue_egg = int(self.master.after_blue_egg_carry_value.get())
self.master.logger.debug(f"After Cheato Blue Egg: {self.master.after_blue_egg}")
# Red Feather Capacity
if(self.master.before_red_feather_carry_value.get() == "?"):
seed(a=(self.seed_val + 7))
self.master.before_red_feather = randint(0, 255)
cheat_sheet += f"Before Cheato Red Feather: {self.master.before_red_feather}\n"
else:
self.master.before_red_feather = int(self.master.before_red_feather_carry_value.get())
self.master.logger.debug(f"Before Cheato Red Feather: {self.master.before_red_feather}")
if(self.master.after_red_feather_carry_value.get() == "?"):
seed(a=(self.seed_val + 8))
self.master.after_red_feather = randint(self.master.before_red_feather, 255)
cheat_sheet += f"After Cheato Red Feather: {self.master.after_red_feather}\n"
else:
self.master.after_red_feather = int(self.master.after_red_feather_carry_value.get())
self.master.logger.debug(f"After Cheato Red Feather: {self.master.after_red_feather}")
# Gold Feather Capacity
if(self.master.before_gold_feather_carry_value.get() == "?"):
seed(a=(self.seed_val + 9))
self.master.before_gold_feather = randint(0, 255)
cheat_sheet += f"Before Cheato Gold Feather: {self.master.before_gold_feather}\n"
else:
self.master.before_gold_feather = int(self.master.before_gold_feather_carry_value.get())
self.master.logger.debug(f"Before Cheato Gold Feather: {self.master.before_gold_feather}")
if(self.master.after_gold_feather_carry_value.get() == "?"):
seed(a=(self.seed_val + 10))
self.master.after_gold_feather = randint(self.master.before_gold_feather, 255)
cheat_sheet += f"After Cheato Gold Feather: {self.master.after_gold_feather}\n"
else:
self.master.after_gold_feather = int(self.master.after_gold_feather_carry_value.get())
self.master.logger.debug(f"After Cheato Gold Feather: {self.master.after_gold_feather}")
# Max Health
if(self.master.max_health_banjo_var.get() == "Random Health Option"):
seed(a=(self.seed_val + 11))
self.master.health_val = choice(["Normal Health", "Four Health Only", "Two Health Only", "One Health Only"])
else:
self.master.health_val = self.master.max_health_banjo_var.get()
self.master.logger.debug(f"Max Health: {self.master.health_val}")
# Cheat Sheet
with open(f"{self.master.cwd}Randomized_ROM/HIDDEN_VALUES_CHEAT_SHEET_{self.seed_val}.txt", "w+") as f:
f.write(cheat_sheet)
def _setup(self):
'''Creates the randomized ROM folder with a copy of the original ROM file'''
self.master.logger.info("Randomization Setup")
setup_tmp_folder(self.master.cwd)
self.seed_val = set_seed(self.master.seed_value.get())
self._hidden_random_values()
self.randomized_rom_path = make_copy_of_rom(self.seed_val, self.master.cwd, self.rom_path)
gc.enable()
def _decompress_main(self):
'''Runs the decompression functions'''
self.master.logger.info("Decompress Main")
decompressor = Decompressor(self.master.cwd, self.randomized_rom_path)
decompressor._decompress_main()
del decompressor
def _randomize_world(self):
'''Runs the world manipulation functions, including world specific functions'''
self.master.logger.info("Start Of Randomize World")
try:
self.pb_label.set_text("Mumbo Creating Worlds...")
world_manip = World_Manipulation_Class(self.master, self.seed_val)
world_manip._create_worlds()
except Exception:
self.master.logger.info("Creating Worlds Error")
self.pb_label.set_text(f"Error Generating Worlds...\n{self._mumbo_error_message}")
raise
# Specificly needs to go first
if(self.master.world_entrance_var.get() == "Bottles Shuffle"):
try:
self.pb_label.set_text("Bear And Bird Need Extra Lives...")
world_manip._bottles_to_1_ups()
except Exception:
self.master.logger.info("Bottles To 1-Ups Error")
self.pb_label.set_text(f"Error Preparing Bottles Shuffle...\n{self._mumbo_error_message}")
raise
# Dropdown Boxes
try:
self.pb_label.set_text("Mumbo Hut Filled With Notes, Eggs, & Feathers...")
world_manip._structs_main()
except Exception:
self.master.logger.info("Structs Error")
self.pb_label.set_text(f"Error Swapping Notes/Eggs/Feathers...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Jinjos Are Good Friends Of Mumbo...")
world_manip._non_flag_objects_main()
except Exception:
self.master.logger.info("Non-Flag Objects Error")
self.pb_label.set_text(f"Error Moving Jinjos & Extra Lives...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Me Summon Gold Statue To Kick Baddie Butt!...")
world_manip._enemies_main()
except Exception:
self.master.logger.info("Enemies Error")
self.pb_label.set_text(f"Error Moving Enemies...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Keep Token Or Two...")
world_manip._flagged_objects_main()
except Exception:
self.master.logger.info("Flagged Objects Error")
self.pb_label.set_text(f"Error Moving Jiggies/Tokens/Honeycombs...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Has Stronger Magic Than Note Door...")
world_manip._note_doors_main(self.master.final_note_door_val)
except Exception:
self.master.logger.info("Note Doors Error")
self.pb_label.set_text(f"Error Changing Note Doors...\n{self._mumbo_error_message}")
raise
# Checkboxes
if(self.master.remove_magic_barriers_var.get() == 1):
try:
self.pb_label.set_text("Mumbo Make Good Transformation Spells...")
world_manip._magic_barrier_main()
except Exception:
self.master.logger.info("Remove Magic Barriers Error")
self.pb_label.set_text(f"Error Removing Magic Barriers...\n{self._mumbo_error_message}")
raise
if(self.master.skip_furnace_fun_var.get() == 1):
try:
self.pb_label.set_text("Furnace Fun No Fun...")
world_manip._skip_furnace_fun()
except Exception:
self.master.logger.info("Skip Furnace Fun Error")
self.pb_label.set_text(f"Error Skipping Furnace Fun...\n{self._mumbo_error_message}")
raise
if(self.master.hard_rings_var.get() == 1):
try:
self.pb_label.set_text("Mumbo Use Clanker For Parts...")
world_manip._shuffle_clanker_rings()
except Exception:
self.master.logger.info("Shuffle Clanker's Rings Error")
self.pb_label.set_text(f"Error Shuffling Clanker's Rings...\n{self._mumbo_error_message}")
raise
if(self.master.croctus_var.get() == 1):
try:
self.pb_label.set_text("Mumbo Need New Boots! Only Kidding...")
world_manip._shuffle_croctus()
except Exception:
self.master.logger.info("Shuffle Croctus Error")
self.pb_label.set_text(f"Error Shuffling Croctus...\n{self._mumbo_error_message}")
raise
if(self.master.mr_vile_var.get() == 1):
try:
self.pb_label.set_text("Mumbo Use Enlarge Spell...")
world_manip._bigger_badder_mr_vile_main()
except Exception:
self.master.logger.info("Mr. Vile Error")
self.pb_label.set_text(f"Error Changing Mr. Vile...\n{self._mumbo_error_message}")
raise
if(self.master.tiptup_choir_var.get() == 1):
try:
self.pb_label.set_text("Mumbo Sing Good, Too...")
world_manip._tiptup_choir_main()
except Exception:
self.master.logger.info("Tiptup Choir Error")
self.pb_label.set_text(f"Error Moving Tiptup Choir...\n{self._mumbo_error_message}")
raise
if(self.master.hard_races_var.get() == 1):
try:
self.pb_label.set_text("WAHAY!...")
world_manip._boggy_race_flags_main()
except Exception:
self.master.logger.info("Boggy Race Error")
self.pb_label.set_text(f"Error Adjusting Boggy Race...\n{self._mumbo_error_message}")
raise
if(self.master.ancient_ones_var.get() == 1):
try:
self.pb_label.set_text("Me Thought Ancient Ones Already Random?...")
world_manip._shuffle_ancient_ones()
except Exception:
self.master.logger.info("Shuffle Ancient Ones Error")
self.pb_label.set_text(f"Error Shuffling Ancient Ones...\n{self._mumbo_error_message}")
raise
if(self.master.maze_jinxy_heads_var.get() == 1):
try:
self.pb_label.set_text("Dum Dum Give Gum Gum...")
world_manip._shuffle_jinxy_heads()
except Exception:
self.pb_label.set_text(f"Error Moving Jinxy Heads...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Lost Way Back To Mountain...")
self.transform_cost_dict = world_manip._world_order_warps_main()
except Exception:
self.master.logger.info("World Order Warps Error")
self.pb_label.set_text(f"Error Shuffling World Order...\n{self._mumbo_error_message}")
raise
if(self.master.within_world_warps_var.get() != "No Shuffle"):
try:
self.pb_label.set_text("Mumbo Lost Way Back To Skull...")
world_manip._within_world_warps_main()
except Exception:
self.master.logger.info("Within World Warps Error")
self.pb_label.set_text(f"Error Shuffling World Warps...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Make Cheat Sheet Hehe...")
world_manip._generate_cheat_sheet()
except Exception:
self.master.logger.info("Cheat Sheet Error")
self.pb_label.set_text(f"Error Making Cheat Sheet...\n{self._mumbo_error_message}")
raise
if(self.master.gruntilda_difficulty_var.get() > 0):
try:
self.pb_label.set_text("If Bear And Bird Lose, Mumbo Go Get Flower...")
world_manip._harder_final_battle_main(self.master.gruntilda_difficulty_var.get())
# world_manip._return_of_furnace_fun()
except Exception:
self.master.logger.info("Harder Final Battle Error")
self.pb_label.set_text(f"Error Adjusting Final Battle...\n{self._mumbo_error_message}")
raise
if(self.master.final_puzzle_var.get() == 1):
try:
self.pb_label.set_text(f"Mumbo Make Traveling Easier...")
world_manip._final_world_puzzle(self.master.final_puzzle_val)
except Exception:
self.master.logger.info("Final World Puzzle Error")
self.pb_label.set_text(f"Error Making Worlds Open...\n{self._mumbo_error_message}")
raise
if(self.master.scattered_structs_var.get() != "No Scatter"):
try:
self.pb_label.set_text(f"Mumbo Better Shaman Than SM64 Modders...")
world_manip._scattered_structs_main()
except Exception:
self.master.logger.info("Scattered Struct Error")
self.pb_label.set_text(f"Error Scattering Notes...\n{self._mumbo_error_message}")
raise
if(self.master.ccw_open_var.get() == 1):
try:
self.pb_label.set_text(f"Be Vewy Vewy Quiet...")
if(self.master.ccw_var.get() == "Season"):
world_manip._ccw_open_seasons_by_season()
elif(self.master.ccw_var.get() == "Within World"):
world_manip._ccw_open_seasons_within_world()
except Exception:
self.master.logger.info("CCW Open Seasons Error")
self.pb_label.set_text(f"Error CCW Open Seasons...\n{self._mumbo_error_message}")
if(self.master.skip_intro_cutscenes_var.get() == 1):
try:
self.pb_label.set_text(f"Mumbo Work Hard To Make This House A Home...")
world_manip._skip_lair_cutscene()
except Exception:
self.master.logger.info("Skip Intro Cutscenes Error")
self.pb_label.set_text(f"Error Skip Intro Cutscenes...\n{self._mumbo_error_message}")
del world_manip
self.master.logger.info("End of Randomize World")
def _misc_options(self):
'''Runs all non-world functions, such as overlays, models, and speeches'''
self.master.logger.info("Start of Misc Options")
try:
self.pb_label.set_text(f"Mumbo Want To Edit Other Things...")
misc_manip = Misc_Manipulation_Class(self.master, self.seed_val)
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Making Manipulation Class...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Make Bottles Say Silly Words...")
misc_manip._bottles_requirements_text(self.master.final_note_door_var.get(), self.master.final_note_door_val,
self.master.final_puzzle_var.get(), self.master.final_puzzle_val)
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Adjusting Note & Jiggy Requirement...\n{self._mumbo_error_message}")
raise
if(self.master.buttons_var.get() == 1):
try:
self.pb_label.set_text("Uh, Mumbo Forgot Code...")
misc_manip._rbb_buttons_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Randomizing RBB Code...\n{self._mumbo_error_message}")
raise
if(self.master.motzand_keys_var.get() == 1):
try:
self.pb_label.set_text("Magic To Mumbo's Ears...")
misc_manip._motzand_keys_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Randomizing Motzand's Song...\n{self._mumbo_error_message}")
raise
if(self.master.matching_puzzle_var.get() == 1):
try:
self.pb_label.set_text("Mumbo No So Good At Puzzles...")
misc_manip._gv_puzzle_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Shuffling Matching Puzzle...\n{self._mumbo_error_message}")
raise
if(self.master.bk_model_var.get() != "Default"):
try:
self.pb_label.set_text("Stand On Skull And Press B To See Mighty Mumbo Magic...")
misc_manip._bk_model()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Adjusting BK's Colors...\n{self._mumbo_error_message}")
raise
if(self.master.jinjo_color_var.get() != "Default Jinjo Colors"):
try:
self.pb_label.set_text("Is Mumbo A Jinjo? Mumbo Never Tell...")
misc_manip._jinjo_model()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Adjusting Jinjos' Colors...\n{self._mumbo_error_message}")
raise
customization_option = False
for custom_count, custom_name in enumerate(self.master.map_config_checkbox_dict):
if(self.master.map_config_checkbox_dict[custom_name].get() == 2):
seed(a=(self.seed_val + custom_count))
self.master.map_config_checkbox_dict[custom_name].set(randint(0, 1))
if(self.master.map_config_checkbox_dict[custom_name].get() == 1):
customization_option = True
try:
self.pb_label.set_text("Hut Music Best Music...")
misc_manip._shuffle_music(self.seed_val, self.master.cwd, self.rom_path)
except Exception:
self.pb_label.set_text(f"Error Shuffling Sounds/Jingles/Music...\n{self._mumbo_error_message}")
raise
if(customization_option):
try:
self.pb_label.set_text("Banjo Must Stand Still Or Spell Go All Funny...\n(Takes Longer The More Options You Selected)")
misc_manip._models_animations_properties(self.seed_val, self.master.cwd, self.rom_path)
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Swapping Models/Animations/Properties...\n{self._mumbo_error_message}")
raise
if((self.master.before_blue_egg_carry_value.get() != 100) or (self.master.after_blue_egg_carry_value.get() != 200) or
(self.master.before_red_feather_carry_value.get() != 50) or (self.master.after_red_feather_carry_value.get() != 100) or
(self.master.before_gold_feather_carry_value.get() != 10) or (self.master.after_gold_feather_carry_value.get() != 20)):
try:
self.pb_label.set_text("Mumbo Adjusting Powerful Spells...")
misc_manip._adjust_sandcastle_speeches()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Adjusting Carrying Capacity...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo Hide Easter Egg...")
misc_manip._edit_cutscenes_text_main()
if(self.master.skip_furnace_fun_var.get() == 1):
misc_manip._gruntildas_lair_speeches_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Placing Easter Eggs...\n{self._mumbo_error_message}")
raise
if(self.master.skip_furnace_fun_var.get() == 1):
try:
self.pb_label.set_text("Uh-Oh, Need Room In ROM...")
misc_manip._edit_world_order_related_text_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Removing Furnace Fun...\n{self._mumbo_error_message}")
raise
try:
self.pb_label.set_text("Mumbo's Motors Now In Business...")
misc_manip._setup_game_engine_manip(self.transform_cost_dict)
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Adjusting Game Engine...\n{self._mumbo_error_message}")
raise
del misc_manip
self.master.logger.info("End of Misc Options")
def _perform_checksum(self):
'''Runs the checksum functions'''
self.master.logger.info("Performing Checksum")
bk_checksum_obj = BK_Checksum_Class(self.master.cwd, self.seed_val)
bk_checksum_obj._main()
del bk_checksum_obj
self.master.logger.info("Checksum Complete")
def _compress_main(self):
'''Runs the compression functions'''
self.master.logger.info("Compressing Main Start")
compressor = Compressor(self.master, self.seed_val, self.master.cwd)
compressor._main()
del compressor
self.master.logger.info("Compression Main End")
def _crc_calc(self):
'''Runs the CRC functions'''
self.master.logger.info("Running CRC Functions")
crc_calc_obj = CRC_Calc_Class(self.master.cwd, self.seed_val)
crc_calc_obj.calculate_crc()
crc_calc_obj.set_crc()
del crc_calc_obj
self.master.logger.info("CRC Functions Complete")
def _clean_up(self):
'''Runs the cleanup functions, if enabled'''
self.master.logger.info("Cleaning Up")
if(self.master.remove_files_var.get() == 1):
clean_up = CleanUp(self.master.cwd)
clean_up._remove_bin_files()
del clean_up
gc.collect()
self.master.logger.info("Cleaning Up Complete")
def _randomization_process(self):
'''
Runs through the setup, decompression, world manipulation, misc settings, compression, crc tool, and clean up functions in that order.
Updates the progress bar after every function runs. Update values are arbitrary.
'''
self.master.logger.info("Setting Up...")
self.pb_label.set_text("Setting up...")
self._setup()
self.progress_bar.update_bar(5)
try:
self.pb_label.set_text("Mumbo Extracting Parts Of Game...")
self._decompress_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Decompressing ROM...\n{self._mumbo_error_message}")
raise
self.progress_bar.update_bar(20)
self.pb_label.set_text("Worlds Need Some Work...")
self._randomize_world()
self.progress_bar.update_bar(40)
self.pb_label.set_text("Mumbo Adding These Too...")
self._misc_options()
self.progress_bar.update_bar(60)
self.pb_label.set_text("Bear And Bird No Need This...")
try:
self._perform_checksum()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Correcting Checksums...\n{self._mumbo_error_message}")
raise
self.progress_bar.update_bar(65)
try:
self.pb_label.set_text("Hope This Works... *Eekum Bookum Eekum Bookum*\n(May Take A Minute Or Two)")
self._compress_main()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Compressing Files...\n{self._mumbo_error_message}")
raise
self.progress_bar.update_bar(85)
try:
self.pb_label.set_text("Mumbo Turn Bear Into Dinosaur...")
self._crc_calc()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Recalculating CRC...\n{self._mumbo_error_message}")
raise
self.progress_bar.update_bar(95)
try:
self.pb_label.set_text("Changed Mind! T-Rex Spell Too Good For This Playthrough!")
self._clean_up()
except Exception:
self.warning_label.set_text("Uh-Oh...")
self.pb_label.set_text(f"Error Cleaning Up...\n{self._mumbo_error_message}")
raise
self.progress_bar.update_bar(100)
self.warning_label.set_text("Oomenacka!")
self.pb_label.set_text(f"Mumbo Spell Done! Let Player Close Window!")
self.master.logger.info("##### Randomized ROM Creation Complete! #####")
def update_mumbo_gif(self, ind):
'''Updates The Gif Frame'''
frame = self.frames[ind]
ind += 1
if ind == self.frame_count:
ind = 0
self.mumbo_talking_label.configure(image=frame)
self.mumbo_talking_label.after(60, self.update_mumbo_gif, ind)
def _main(self):
'''Creates the progress bar gui and runs the main functions with threading'''
########################
### PROGRESS BAR GUI ###
########################
# Label
self.warning_label = self.App_Variable_Label(window=self.progress_bar_window, label_text="Bear And Bird Cannot Close Window.\nMust Complete ROM Transformation.\nHope This Works...")
self.warning_label.pack_label()
# Mumbo Jumbo Talking
self.frame_count = 10
self.frames = [tk.PhotoImage(master=self.progress_bar_window, file=(f"{self.master.cwd}Pictures/Mumbo_Jumbo_Speaking.gif"), format = 'gif -index %i' %(i)) for i in range(self.frame_count)]
self.mumbo_talking_label = tk.Label(self.progress_bar_window, background="#F3E5AB")
self.mumbo_talking_label.pack()
# Variable Label
self.pb_label = self.App_Variable_Label(window=self.progress_bar_window, label_text="Progress Bar")
self.pb_label.pack_label()
# Progress Bar
self.progress_bar = self.App_ProgressBar(self.progress_bar_window)
self.progress_bar.pack_bar()
# Threading
x = threading.Thread(target=self._randomization_process)
x.start()
##########################
### GUI WINDOW OPTIONS ###
##########################
### Close Window ##
self.progress_bar_window.protocol("WM_DELETE_WINDOW", self.progress_bar_window.destroy)
### Update Window ###
self.progress_bar_window.after(0, self.update_mumbo_gif, 0)
### Main Loop ###
self.progress_bar_window.mainloop()