forked from bombsquad-community/plugin-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_theme.py
2075 lines (1913 loc) · 78.4 KB
/
menu_theme.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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ba_meta require api 8
"""
Working for v1.7.20+ only
———————————————————————————————————————
• Menu Theme v1.0.10
• discord: riyukiiyan
I appreciate any kind of modification. So feel free to share, edit and change credit string... no problem
Credits are unnecessary but are a much-appreciated gesture to show support to others :D
[CHANGELOG]:
~ Support for BombSquad v1.7.26
~ Fixed "Show Logo Text" checkmark not updating on imports and reset
~ Music changes:
>> Turn off music by selecting 'None'
>> Removed dupes, renamed some and added 2 new musics
Special thanks to:
snowee, rikko, & unknown
———————————————————————————————————————
"""
from __future__ import annotations
from typing import List, Sequence, Callable, Any, cast
from baenv import TARGET_BALLISTICA_BUILD
from bascenev1lib.mainmenu import MainMenuActivity, NewsDisplay, _preload1
from bauiv1lib.mainmenu import MainMenuWindow
from bauiv1lib.account.settings import AccountSettingsWindow
from bauiv1lib.colorpicker import ColorPicker, ColorPickerExact
from bauiv1lib.fileselector import FileSelectorWindow
from bauiv1lib.popup import PopupMenuWindow
import _bauiv1 as _bui
import _bascenev1 as _bs
import _babase as _ba
import babase as ba
import bascenev1 as bs
import bauiv1 as bui
import bascenev1lib.mainmenu as menu
import json
import os
import shutil
import random
import weakref
# defined version and author
__author__ = "Yann"
__version__ = "1.0.10"
if TARGET_BALLISTICA_BUILD < 21282:
# These attributes have been deprecated as of 1.7.27. For more info see:
# https://github.com/efroemling/ballistica/blob/master/CHANGELOG.md#1727-build-21282-api-8-2023-08-30
# Adding a compatibility layer here so older builds still work fine.
class Dummy:
pass
babase = ba
babase.app.env = Dummy()
babase.app.env.build_number = babase.app.build_number
babase.app.env.device_name = babase.app.device_name
babase.app.env.config_file_path = babase.app.config_file_path
babase.app.env.version = babase.app.version
babase.app.env.debug = babase.app.debug_build
babase.app.env.test = babase.app.test_build
babase.app.env.data_directory = babase.app.data_directory
babase.app.env.python_directory_user = babase.app.python_directory_user
babase.app.env.python_directory_app = babase.app.python_directory_app
babase.app.env.python_directory_app_site = babase.app.python_directory_app_site
babase.app.env.api_version = babase.app.api_version
babase.app.env.tv = babase.app.on_tv
babase.app.env.vr = babase.app.vr_mode
babase.app.env.arcade = babase.app.arcade_mode
babase.app.env.headless = babase.app.arcade_mode
babase.app.env.demo = babase.app.demo_mode
protocol_version = babase.app.protocol_version
toolbar_test = babase.app.toolbar_test
else:
protocol_version = _bs.protocol_version
toolbar_test = _bui.toolbar_test()
# frequently used variables references
config = bs.app.config
ui_type = bs.app.ui_v1.uiscale
ui_small = bs.UIScale.SMALL
ui_medium = bs.UIScale.MEDIUM
ui_large = bs.UIScale.LARGE
# method references
original_unlocked_pro = bs.app.classic.accounts.have_pro
original_account_init = AccountSettingsWindow.__init__
# define globals
GLOBALS_REFLECTION = {
'Powerup': 'powerup',
'Character': 'char',
'Soft': 'soft',
'None': 'none'
}
GLOBALS_MUSIC = {
'Menu': bs.MusicType.MENU,
'Epic': bs.MusicType.EPIC,
'Flag Catcher': bs.MusicType.FLAG_CATCHER,
'Flying': bs.MusicType.FLYING,
'Grand Romp': bs.MusicType.GRAND_ROMP,
'Lobby': bs.MusicType.CHAR_SELECT,
'Lobby Epic': bs.MusicType.SCORES,
'Marching Forward': bs.MusicType.FORWARD_MARCH,
'Marching Home': bs.MusicType.MARCHING,
'Run Away': bs.MusicType.RUN_AWAY,
'Scary': bs.MusicType.SCARY,
'Sports': bs.MusicType.SPORTS,
'Survival': bs.MusicType.SURVIVAL,
'To The Death': bs.MusicType.TO_THE_DEATH,
'None': None,
}
GLOBALS_MAPDATA = {
"The Pad (with trees)": {
"Camera Bounds": (0.3544110667, 4.493562578, -2.518391331, 16.64754831, 8.06138989, 18.5029888),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.3,
"Ambient": (1.14, 1.1, 1.0),
"Tint": (1.06, 1.04, 1.03),
"Vignette Outer": (0.45, 0.55, 0.54),
"Vignette Inner": (0.99, 0.98, 0.98)
},
"The Pad": {
"Camera Bounds": (0.3544110667, 4.493562578, -2.518391331, 16.64754831, 8.06138989, 18.5029888),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.3,
"Ambient": (1.1, 1.1, 1.0),
"Tint": (1.1, 1.1, 1.0),
"Vignette Outer": (0.7, 0.65, 0.75),
"Vignette Inner": (0.95, 0.95, 0.93)
},
"Big G": {
"Camera Bounds": (-0.4011866709, 2.331310176, -0.5426286416, 19.11746262, 10.19675564, 23.50119277),
"Map Color": (0.7, 0.7, 0.7),
"Map Reflection Scale": 0.0,
"Ambient": (1.1, 1.2, 1.3),
"Tint": (1.1, 1.2, 1.3),
"Vignette Outer": (0.65, 0.6, 0.55),
"Vignette Inner": (0.9, 0.9, 0.93)
},
"Bridgit": {
"Camera Bounds": (-0.2457963347, 3.828181068, -1.528362695, 19.14849937, 7.312788846, 8.436232726),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.1, 1.2, 1.3),
"Tint": (1.1, 1.2, 1.3),
"Vignette Outer": (0.65, 0.6, 0.55),
"Vignette Inner": (0.9, 0.9, 0.93)
},
"Courtyard": {
"Camera Bounds": (0.3544110667, 3.958431362, -2.175025358, 16.37702017, 7.755670126, 13.38680645),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.2, 1.17, 1.1),
"Tint": (1.2, 1.17, 1.1),
"Vignette Outer": (0.6, 0.6, 0.64),
"Vignette Inner": (0.95, 0.95, 0.93)
},
"Crag Castle": {
"Camera Bounds": (0.7033834902, 6.55869393, -3.153439808, 16.73648528, 14.94789935, 11.60063102),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.15, 1.05, 0.75),
"Tint": (1.15, 1.05, 0.75),
"Vignette Outer": (0.6, 0.65, 0.6),
"Vignette Inner": (0.95, 0.95, 0.95)
},
"Doom Shroom": {
"Camera Bounds": (0.4687647786, 2.320345088, -3.219423694, 21.34898078, 10.25529817, 14.67298352),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (0.9, 1.3, 1.1),
"Tint": (0.82, 1.10, 1.15),
"Vignette Outer": (0.76, 0.76, 0.76),
"Vignette Inner": (0.95, 0.95, 0.99)
},
"Happy Thoughts": {
"Camera Bounds": (-1.045859963, 12.67722855, -5.401537075, 34.46156851, 20.94044653, 0.6931564611),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.3, 1.23, 1.0),
"Tint": (1.3, 1.23, 1.0),
"Vignette Outer": (0.64, 0.59, 0.69),
"Vignette Inner": (0.95, 0.95, 0.93)
},
"Football Stadium": {
"Camera Bounds": (0.0, 1.185751251, 0.4326226188, 29.8180273, 11.57249038, 18.89134176),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.3, 1.2, 1.0),
"Tint": (1.3, 1.2, 1.0),
"Vignette Outer": (0.57, 0.57, 0.57),
"Vignette Inner": (0.9, 0.9, 0.9)
},
"Hockey Stadium": {
"Camera Bounds": (0.0, 0.7956858119, 0.0, 30.80223883, 0.5961646365, 13.88431707),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.3,
"Ambient": (1.15, 1.25, 1.6),
"Tint": (1.2, 1.3, 1.33),
"Vignette Outer": (0.66, 0.67, 0.73),
"Vignette Inner": (0.93, 0.93, 0.95)
},
"Lake Frigid": {
"Camera Bounds": (0.622753268, 3.958431362, -2.48708008, 20.62310543, 7.755670126, 12.33155049),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1, 1, 1),
"Tint": (1, 1, 1),
"Vignette Outer": (0.86, 0.86, 0.86),
"Vignette Inner": (0.95, 0.95, 0.99)
},
"Monkey Face": {
"Camera Bounds": (-1.657177611, 4.132574186, -1.580485661, 17.36258946, 10.49020453, 12.31460338),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.1, 1.2, 1.2),
"Tint": (1.1, 1.2, 1.2),
"Vignette Outer": (0.60, 0.62, 0.66),
"Vignette Inner": (0.97, 0.95, 0.93)
},
"Rampage": {
"Camera Bounds": (0.3544110667, 5.616383286, -4.066055072, 19.90053969, 10.34051135, 8.16221072),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.3, 1.2, 1.03),
"Tint": (1.2, 1.1, 0.97),
"Vignette Outer": (0.62, 0.64, 0.69),
"Vignette Inner": (0.97, 0.95, 0.93)
},
"Roundabout": {
"Camera Bounds": (-1.552280404, 3.189001207, -2.40908495, 11.96255385, 8.857531648, 9.531689995),
"Map Color": (0.7, 0.7, 0.7),
"Map Reflection Scale": 0.0,
"Ambient": (1.0, 1.05, 1.1),
"Tint": (1.0, 1.05, 1.1),
"Vignette Outer": (0.63, 0.65, 0.7),
"Vignette Inner": (0.97, 0.95, 0.93)
},
"Step Right Up": {
"Camera Bounds": (0.3544110667, 6.07676405, -2.271833016, 22.55121262, 10.14644532, 14.66087273),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.2, 1.1, 1.0),
"Tint": (1.2, 1.1, 1.0),
"Vignette Outer": (1.2, 1.1, 1.0),
"Vignette Inner": (0.95, 0.95, 0.93)
},
"Tower D": {
"Camera Bounds": (-0.4714933293, 2.887077774, -1.505479919, 17.90145968, 6.188484831, 15.96149117),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.2, 1.1, 1.0),
"Tint": (1.15, 1.11, 1.03),
"Vignette Outer": (1.2, 1.1, 1.0),
"Vignette Inner": (0.95, 0.95, 0.95)
},
"Tip Top": {
"Camera Bounds": (0.004375512593, 7.141135803, -0.01745294675, 21.12506141, 4.959977313, 16.6885592),
"Map Color": (0.7, 0.7, 0.7),
"Map Reflection Scale": 0.0,
"Ambient": (0.8, 0.9, 1.3),
"Tint": (0.8, 0.9, 1.3),
"Vignette Outer": (0.79, 0.79, 0.69),
"Vignette Inner": (0.97, 0.97, 0.99)
},
"Zig Zag": {
"Camera Bounds": (-1.807378035, 3.943412768, -1.61304303, 23.01413538, 13.27980464, 10.0098376),
"Map Color": (1.0, 1.0, 1.0),
"Map Reflection Scale": 0.0,
"Ambient": (1.0, 1.15, 1.15),
"Tint": (1.0, 1.15, 1.15),
"Vignette Outer": (0.57, 0.59, 0.63),
"Vignette Inner": (0.97, 0.95, 0.93)
}
}
class CustomColorPicker(ColorPicker):
def _select_other(self):
from bauiv1lib import purchase
CustomColorPickerExact(parent=self._parent,
position=self._position,
initial_color=self._initial_color,
delegate=self._delegate,
scale=self._scale,
offset=self._offset,
tag=self._tag)
self._delegate = None
self._transition_out()
class CustomColorPickerExact(ColorPickerExact):
def _color_change_press(self, color_name: str, increasing: bool):
current_time = bui.apptime()
since_last = current_time - self._last_press_time
if (
since_last < 0.2
and self._last_press_color_name == color_name
and self._last_press_increasing == increasing
):
self._change_speed += 0.25
else:
self._change_speed = 1.0
self._last_press_time = current_time
self._last_press_color_name = color_name
self._last_press_increasing = increasing
color_index = ('r', 'g', 'b').index(color_name)
offs = int(self._change_speed) * (0.01 if increasing else -0.01)
self._color[color_index] = max(
-1.0, min(2.55, self._color[color_index] + offs)
)
self._update_for_color()
class ConfigCheckBox:
widget: bui.Widget
def __init__(
self,
parent: bui.Widget,
configkey: str,
position: tuple[float, float],
size: tuple[float, float],
displayname: str | bs.Lstr | None = None,
scale: float | None = None,
maxwidth: float | None = None,
autoselect: bool = True,
value_change_call: Callable[[Any], Any] | None = None):
if displayname is None:
displayname = configkey
self._value_change_call = value_change_call
self._configkey = configkey
self.widget = bui.checkboxwidget(
parent=parent,
autoselect=autoselect,
position=position,
size=size,
text=displayname,
textcolor=(0.8, 0.8, 0.8),
value=bs.app.config[configkey],
on_value_change_call=self._value_changed,
scale=scale,
maxwidth=maxwidth,
)
# complain if we outlive our checkbox
bui.uicleanupcheck(self, self.widget)
def _value_changed(self, val: bool):
cfg = bs.app.config
cfg[self._configkey] = val
if self._value_change_call is not None:
self._value_change_call(val)
cfg.apply_and_commit()
class FreeEditWindow(bui.Window):
def _do_enter(self):
def _error() -> None:
bui.getsound('error').play(volume=2.0)
bui.screenmessage('error ' + u'😑😑', color=(1.0, 0.0, 0.0))
try:
if self.name_only:
value = bui.textwidget(query=self._text_field)
if not value.strip():
return _error()
self.delegate._export(self, txt=value)
else:
value = round(float(bui.textwidget(query=self._text_field)), 4)
self.delegate.free_edit_enter(self, c=self.config_name, txt=value)
except ValueError:
return _error()
bui.containerwidget(edit=self._root_widget, transition=self._transition_out)
def _activate_enter_button(self):
self._enter_button.activate()
def _do_back(self):
bui.containerwidget(edit=self._root_widget, transition=self._transition_out)
def __init__(self, delegate: Any = None, config_name: str = 'Menu Map', whitelist: List = [], name_only: bool = False, origin_widget: bui.widget = None):
self._transition_out = 'out_scale' if origin_widget else 'out_right'
scale_origin = origin_widget.get_screen_space_center() if origin_widget else None
transition = 'in_scale' if origin_widget else 'in_right'
width, height = 450, 230
uiscale = bs.app.ui_v1.uiscale
super().__init__(root_widget=bui.containerwidget(
size=(width, height),
transition=transition,
toolbar_visibility='menu_minimal_no_back',
scale_origin_stack_offset=scale_origin,
scale=(2.0 if uiscale is bs.UIScale.SMALL else
1.5 if uiscale is bs.UIScale.MEDIUM else 1.0)))
btn = bui.buttonwidget(parent=self._root_widget,
scale=0.5,
position=(40, height - 40),
size=(60, 60),
label='',
on_activate_call=self._do_back,
autoselect=True,
color=(0.55, 0.5, 0.6),
icon=bui.gettexture('crossOut'),
iconscale=1.2)
self.config_name, self.delegate, self.name_only = config_name, delegate, name_only
self._text_field = bui.textwidget(
parent=self._root_widget,
position=(125, height - 121),
size=(280, 46),
text='',
h_align='left',
v_align='center',
color=(0.9, 0.9, 0.9, 1.0),
description='',
editable=True,
padding=4,
max_chars=20 if name_only else 5,
on_return_press_call=self._activate_enter_button)
bui.textwidget(parent=self._root_widget,
text='Current: ' + str(config[config_name]) if not name_only else 'Save as',
position=(220, height - 44),
color=(0.5, 0.5, 0.5, 1.0),
size=(90, 30),
h_align='right')
bui.widget(edit=btn, down_widget=self._text_field)
b_width = 200
self._enter_button = btn2 = bui.buttonwidget(
parent=self._root_widget,
position=(width * 0.5 - b_width * 0.5, height - 200),
size=(b_width, 60),
scale=1.0,
label='Enter',
on_activate_call=self._do_enter)
bui.containerwidget(edit=self._root_widget,
cancel_button=btn,
start_button=btn2,
selected_child=self._text_field)
class MenuThemeWindow:
def __init__(self, origin_widget: bui.widget = None, accounts_window=None):
if origin_widget is not None:
self._transition_out = 'out_scale'
scale_origin = origin_widget.get_screen_space_center()
transition = 'in_scale'
else:
self._transition_out = 'out_right'
scale_origin = None
transition = 'in_right'
self._choice_page: str = None
self._accounts_window = accounts_window
height = 500 if ui_type is ui_small else 772
self._root_widget = bui.containerwidget(
size=(445, 365) if ui_type is ui_small else (799, 576),
transition=transition,
toolbar_visibility='menu_minimal',
scale_origin_stack_offset=scale_origin,
scale=2.23 if ui_type is ui_small else 1.0,
stack_offset=(0, -35) if ui_type is ui_small else (0, 0)
)
self._scroll_border_parent = bui.scrollwidget(
parent=self._root_widget,
position=(39, 58) if ui_type is ui_small else (86, 39),
size=(375, 240) if ui_type is ui_small else (645, 463),
color=(0.52, 0.48, 0.63)
)
self._scroll_parent = bui.containerwidget(
parent=self._scroll_border_parent,
size=(450, height),
background=False,
claims_left_right=False,
claims_tab=False
)
self._back_button = bui.buttonwidget(
parent=self._root_widget,
position=(23, 310) if ui_type is ui_small else (80, 511),
size=(35, 35) if ui_type is ui_small else (55, 55),
color=(0.76, 0.42, 0.38),
button_type="backSmall",
textcolor=(1, 1, 1),
text_scale=0.8 if ui_type is ui_small else 1.0,
label="",
autoselect=True,
on_activate_call=bs.Call(self.close)
)
self._home_button = bui.buttonwidget(
parent=self._root_widget,
position=(383, 308) if ui_type is ui_small else (688, 511),
size=(60, 60) if ui_type is ui_small else (55, 55),
color=(0.76, 0.42, 0.38),
icon=bui.gettexture('crossOut'),
iconscale=1.2,
scale=0.59 if ui_type is ui_small else 0.92,
label="",
autoselect=True,
on_activate_call=bs.Call(self.close_all)
)
# menutheme title
bui.textwidget(
parent=self._root_widget,
position=(225, 327) if ui_type is ui_small else (415, 547),
size=(0, 0),
text="Menu Theme",
color=(0.8, 0.8, 0.8, 0.76),
maxwidth=290,
scale=0.95 if ui_type is ui_small else 1.25,
h_align='center',
v_align='center'
)
bui.textwidget(
parent=self._root_widget,
position=(225, 309) if ui_type is ui_small else (415, 517),
size=(0, 0),
text=f"version: {__version__}",
color=(0.6, 0.6, 0.6, 0.8),
maxwidth=290,
scale=0.454 if ui_type is ui_small else 0.653,
h_align='center',
v_align='center'
)
# settings txt
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 27) if ui_type is ui_small else (30, height - 47),
size=(0, 0),
text="Map Type:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 65) if ui_type is ui_small else (30, height - 104),
size=(0, 0),
text="Music:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(25, height - 147) if ui_type is ui_small else (45, height - 239),
size=(0, 0),
text="tint",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.5 if ui_type is ui_small else 1.0,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(81, height - 147) if ui_type is ui_small else (140, height - 239),
size=(0, 0),
text="ambient",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.5 if ui_type is ui_small else 1.0,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(147, height - 156) if ui_type is ui_small else (262, height - 258),
size=(0, 0),
text="vignette\n outer",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.5 if ui_type is ui_small else 1.0,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(213, height - 156) if ui_type is ui_small else (382, height - 258),
size=(0, 0),
text="vignette\n inner",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.5 if ui_type is ui_small else 1.0,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(279, height - 156) if ui_type is ui_small else (500, height - 258),
size=(0, 0),
text="reflection\n color",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.5 if ui_type is ui_small else 1.0,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 193) if ui_type is ui_small else (30, height - 320),
size=(0, 0),
text="Reflection Type:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 227) if ui_type is ui_small else (30, height - 373),
size=(0, 0),
text="Reflection Scale:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 260) if ui_type is ui_small else (30, height - 423),
size=(0, 0),
text="Camera Mode:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
bui.textwidget(
parent=self._scroll_parent,
position=(10, height - 294) if ui_type is ui_small else (30, height - 480),
size=(0, 0),
text="Show Logo Text:",
color=(1, 1, 1, 0.8),
maxwidth=290,
scale=0.7 if ui_type is ui_small else 1.3,
h_align='left',
v_align='center'
)
# prioritize this first for:
# >> handling config-errors
# >> debugging
self._menu_configreset_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(5, height - 486) if ui_type is ui_small else (12, height - 765),
size=(329, 50) if ui_type is ui_small else (600, 80),
color=(0.0, 0.67, 0.85),
textcolor=(0.8, 0.8, 0.8),
button_type="regular",
label="Reset to Default Settings",
text_scale=0.7 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.reset_config)
)
# settings buttons
self._menu_map_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(112, height - 38) if ui_type is ui_small else (206, height - 67),
size=(87, 24) if ui_type is ui_small else (149, 40),
button_type="regular",
label=config["Menu Map"],
on_activate_call=bs.Call(self.choice_window, 'Map')
)
self._menu_music_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(85, height - 75) if ui_type is ui_small else (149, height - 123),
size=(87, 24) if ui_type is ui_small else (149, 40),
button_type="regular",
label=config["Menu Music"],
text_scale=0.6 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.choice_window, 'Music')
)
self._menu_tint_button = bui.buttonwidget(
parent=self._scroll_parent,
color=config["Menu Tint"],
position=(15, height - 136) if ui_type is ui_small else (30, height - 220),
size=(40, 40) if ui_type is ui_small else (70, 70),
button_type="square",
label="",
on_activate_call=bs.WeakCall(self.color_picker_popup, "Menu Tint")
)
self._menu_ambient_button = bui.buttonwidget(
parent=self._scroll_parent,
color=config["Menu Ambient"],
position=(81, height - 136) if ui_type is ui_small else (150, height - 220),
size=(40, 40) if ui_type is ui_small else (70, 70),
button_type="square",
label="",
on_activate_call=bs.WeakCall(self.color_picker_popup, "Menu Ambient")
)
self._menu_vignetteO_button = bui.buttonwidget(
parent=self._scroll_parent,
color=config["Menu Vignette Outer"],
position=(147, height - 136) if ui_type is ui_small else (270, height - 220),
size=(40, 40) if ui_type is ui_small else (70, 70),
button_type="square",
label="",
on_activate_call=bs.WeakCall(self.color_picker_popup, "Menu Vignette Outer")
)
self._menu_vignetteI_button = bui.buttonwidget(
parent=self._scroll_parent,
color=config["Menu Vignette Inner"],
position=(213, height - 136) if ui_type is ui_small else (390, height - 220),
size=(40, 40) if ui_type is ui_small else (70, 70),
button_type="square",
label="",
on_activate_call=bs.WeakCall(self.color_picker_popup, "Menu Vignette Inner")
)
self._menu_rcolor_button = bui.buttonwidget(
parent=self._scroll_parent,
color=config["Menu Map Color"],
position=(279, height - 136) if ui_type is ui_small else (510, height - 220),
size=(40, 40) if ui_type is ui_small else (70, 70),
button_type="square",
label="",
on_activate_call=bs.WeakCall(self.color_picker_popup, "Menu Map Color")
)
self._menu_reflectiont_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(148, height - 204) if ui_type is ui_small else (287, height - 339),
size=(87, 24) if ui_type is ui_small else (149, 40),
button_type="regular",
label=config["Menu Reflection Type"],
text_scale=0.6 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.choice_window, 'Reflection Type')
)
self._menu_reflections_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(153, height - 237) if ui_type is ui_small else (289, height - 392),
size=(87, 24) if ui_type is ui_small else (149, 40),
button_type="regular",
label=str(config["Menu Reflection Scale"]),
text_scale=0.6 if ui_type is ui_small else 1.0,
on_activate_call=lambda: FreeEditWindow(
delegate=self, whitelist=['num'], config_name='Menu Reflection Scale')
)
self._menu_cameramode_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(138, height - 272) if ui_type is ui_small else (265, height - 444),
size=(87, 24) if ui_type is ui_small else (149, 40),
button_type="regular",
label=str(config["Menu Camera Mode"]),
text_scale=0.6 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.choice_window, 'Camera Mode')
)
self._menu_logotext_button = ConfigCheckBox(
parent=self._scroll_parent,
configkey="Menu Logo Text",
position=(151, height - 308) if ui_type is ui_small else (287, height - 520),
size=(40, 40) if ui_type is ui_small else (56, 56),
scale=0.62 if ui_type is ui_small else 1.4,
displayname=""
)
self._menu_load_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(11, height - 365) if ui_type is ui_small else (22, height - 590),
size=(155, 45) if ui_type is ui_small else (280, 75),
textcolor=(0.8, 0.8, 0.8),
button_type="regular",
label="Load Theme",
text_scale=0.7 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.popup_fileselector)
)
self._menu_save_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(178, height - 365) if ui_type is ui_small else (312, height - 590),
size=(155, 45) if ui_type is ui_small else (280, 75),
textcolor=(0.8, 0.8, 0.8),
button_type="regular",
label="Save Theme",
text_scale=0.7 if ui_type is ui_small else 1.0,
on_activate_call=lambda: FreeEditWindow(delegate=self, name_only=True)
)
self._menu_mapdata_button = bui.buttonwidget(
parent=self._scroll_parent,
position=(5, height - 425) if ui_type is ui_small else (12, height - 677),
size=(329, 50) if ui_type is ui_small else (600, 80),
color=(0.23, 0.27, 0.55),
textcolor=(0.8, 0.8, 0.8),
button_type="regular",
label="Map Data Overrides",
text_scale=0.7 if ui_type is ui_small else 1.0,
on_activate_call=bs.Call(self.checkbox_window)
)
def checkbox_window(self):
self._root_widget_checkbox = bui.containerwidget(
size=(800, 740),
transition='in_scale',
toolbar_visibility='menu_minimal',
scale_origin_stack_offset=(0, 0),
scale=0.6 if ui_type is ui_large else 0.88 if ui_type is ui_small else 0.76,
color=(0.17, 0.2, 0.25),
on_outside_click_call=bs.Call(self.checkbox_window_out),
claim_outside_clicks=True,
stack_offset=(0, -35) if ui_type is ui_small else (0, 0)
)
self._button_tint = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="tint",
position=(88, 600),
size=(380, 40),
scale=1.9,
displayname='Tint'
)
self._button_ambient = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="ambient_color",
position=(88, 510),
size=(380, 40),
scale=1.9,
displayname='Ambient Color'
)
self._button_vignette_outer = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="vignette_outer",
position=(88, 420),
size=(380, 40),
scale=1.9,
displayname='Vignette Outer'
)
self._button_vignette_inner = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="vignette_inner",
position=(88, 330),
size=(380, 40),
scale=1.9,
displayname='Vignette Inner'
)
self._button_map_color = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="map_color",
position=(88, 240),
size=(380, 40),
scale=1.9,
displayname='Map Color'
)
self._button_map_reflection_scale = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="map_reflection_scale",
position=(88, 150),
size=(380, 40),
scale=1.9,
displayname='Map Reflection Scale'
)
self._button_map_reflection_type = ConfigCheckBox(
parent=self._root_widget_checkbox,
configkey="map_reflection_type",
position=(88, 60),
size=(380, 40),
scale=1.9,
displayname='Map Reflection Type'
)
def checkbox_window_out(self):
# Memory-leak prevention
bui.containerwidget(edit=self._root_widget_checkbox, transition='out_scale')
del self._button_tint
del self._button_ambient
del self._button_vignette_outer
del self._button_vignette_inner
del self._button_map_color
del self._button_map_reflection_scale
del self._button_map_reflection_type
def choice_window(self, category: str):
choices_map = {
'Map': [
'Big G',
'Bridgit',
'Courtyard',
'Crag Castle',
'Doom Shroom',
'Football Stadium',
'Happy Thoughts',
'Hockey Stadium',
'Lake Frigid',
'Monkey Face',
'Rampage',
'Roundabout',
'Step Right Up',
'The Pad',
'The Pad (with trees)',
'Tower D',
'Tip Top',
'Zig Zag'
],
'Camera Mode': [
'rotate',
'static'
],
'Reflection Type': [
'Soft',
'None',
'Powerup',
'Character'
],
'Music': [
'Menu',
'Epic',
'Flag Catcher',
'Flying',
'Grand Romp',
'Lobby',
'Lobby Epic',
'Marching Forward',
'Marching Home',
'Run Away',
'Scary',
'Sports',
'Survival',
'To The Death',
'None'
]
}
if category in choices_map:
PopupMenuWindow(
position=(0, 0),
scale=2.0 if ui_type is ui_small else 1.0,
delegate=self,
current_choice=bs.app.config[f"Menu {category}"],
choices=choices_map[category]
)
self._choice_page = category
def popup_menu_selected_choice(self, window: PopupMenuWindow, choice: str):
if self._choice_page == 'Map':
bs.app.config['Menu Map'] = choice
if config["tint"]:
bs.app.config["Menu Tint"] = GLOBALS_MAPDATA.get(config["Menu Map"]).get("Tint")
if config["ambient_color"]:
bs.app.config["Menu Ambient"] = GLOBALS_MAPDATA.get(
config["Menu Map"]).get("Ambient")
if config["vignette_outer"]:
bs.app.config["Menu Vignette Outer"] = GLOBALS_MAPDATA.get(
config["Menu Map"]).get("Vignette Outer")
if config["vignette_inner"]:
bs.app.config["Menu Vignette Inner"] = GLOBALS_MAPDATA.get(
config["Menu Map"]).get("Vignette Inner")
if config["map_color"]:
bs.app.config["Menu Map Color"] = GLOBALS_MAPDATA.get(