Repository navigation
Expand file tree
/
Copy pathwidgets.py
More file actions
3069 lines (2578 loc) · 120 KB
/
Copy pathwidgets.py
File metadata and controls
3069 lines (2578 loc) · 120 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
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
# yep it's literally all the widgets every textbox, menu, window, dropdown menu, everything bro
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import json
import subprocess
import webbrowser
from pathlib import Path
import fflags
import fonts
import fps
import cursors
import themes
import emoji
import emote_wheel
import mods
import sound_mods
import updater
import envvars
import bootstrapper
import backup
import log
import sober
import setup
import sys
BG = "#1e1e1e"
BG_SIDEBAR = "#161616"
BG_ACTIVE = "#2a2a2a"
FG = "#e0e0e0"
FG_DIM = "#888888"
ACCENT = "#8D7EDC"
ERROR = "#e06c75"
BODY_FONT = ("TkDefaultFont", 13)
BASE = Path(getattr(sys, "_MEIPASS", Path(__file__).parent))
USER_PRESETS_FILE = Path.home() / ".local/Lution/fflag_user_presets.json"
def _auto_resize(win):
try:
win.update_idletasks()
rw, rh = win.winfo_reqwidth(), win.winfo_reqheight()
win.minsize(min(rw, 380), min(rh, 320))
win.resizable(True, True)
except tk.TclError:
pass
def _fit(win, w, h, ratio=0.85):
sw, sh = win.winfo_screenwidth(), win.winfo_screenheight()
w = max(260, min(w, sw))
h = max(120, min(h, int(sh * ratio)))
x = max(0, (sw - w) // 2)
y = max(0, (sh - h) // 3)
win.geometry(f"{w}x{h}+{x}+{y}")
win.after(20, lambda: _auto_resize(win))
def _clear_all_fflags(app, reload_fn, status):
win = tk.Toplevel(app, bg=BG)
win.title("Delete all FFlags")
_fit(win, 400, 120)
win.configure(bg=BG)
win.resizable(False, False)
tk.Label(win, text="remove all your fflags?", bg=BG, fg=FG,
font=BODY_FONT).pack(pady=(20, 14))
btn_row = tk.Frame(win, bg=BG)
btn_row.pack()
def confirm():
fflags.save_fflags({})
reload_fn()
status.configure(text="All fflags deleted", fg=FG_DIM)
win.destroy()
app.make_button(btn_row, "yes clear all", command=confirm,
bg=ERROR, fg="#0a0a0a", padx=12, pady=6
).pack(side="left", padx=(0, 8))
app.make_button(btn_row, "cancel", command=win.destroy,
padx=12, pady=6).pack(side="left")
def _export_fflags_json(app, status):
path = filedialog.asksaveasfilename(
title="Export FFlags",
defaultextension=".json",
filetypes=[("JSON files", "*.json")],
initialfile="fflags.json"
)
if path:
try:
current = fflags.get_fflags()
Path(path).write_text(json.dumps(current, indent=4) + "\n")
status.configure(text=f"Exported to {Path(path).name}", fg=FG_DIM)
except Exception as e:
status.configure(text=str(e), fg=ERROR)
def _clean_disallowed(app, reload_fn, status):
_ok, bad = fflags.validate(fflags.get_fflags())
if not bad:
status.configure(text="every fflag is on the allowlist :D", fg=FG_DIM)
return
win = tk.Toplevel(app, bg=BG)
win.title("Remove non-working fflags")
_fit(win, 500, 240)
win.configure(bg=BG)
win.resizable(False, False)
shown = ", ".join(bad[:8])
more = f"\nand {len(bad) - 8} more" if len(bad) > 8 else ""
tk.Label(win,
text=(f"Remove {len(bad)} flag(s) that are not on Roblox's "
f"allowlist?\n\n{shown}{more}"),
bg=BG, fg=FG, font=BODY_FONT, justify="left",
wraplength=460).pack(anchor="w", padx=16, pady=(16, 14))
btn_row2 = tk.Frame(win, bg=BG)
btn_row2.pack(pady=(0, 16))
def confirm():
kept, removed = fflags.clean(fflags.get_fflags())
fflags.save_fflags(kept)
win.destroy()
reload_fn()
status.configure(text=f"Removed {len(removed)} flag(s) not on the "
f"allowlist.", fg=FG_DIM)
app.make_button(btn_row2, "remove them", command=confirm,
bg=ERROR, fg="#0a0a0a", padx=12, pady=6
).pack(side="left", padx=(0, 8))
app.make_button(btn_row2, "cancel", command=win.destroy,
padx=12, pady=6).pack(side="left")
def _update_allowlist(app, reload_fn, status):
import threading
status.configure(text="Updating fflag allowlist...", fg=FG_DIM)
def worker():
ok, msg = fflags.refresh_allowlist()
def done():
if ok:
status.configure(text=f"Allowlist updated: {msg}.", fg=FG_DIM)
else:
status.configure(text=f"Allowlist update failed: {msg}",
fg=ERROR)
reload_fn()
app.after(0, done)
threading.Thread(target=worker, daemon=True).start()
def _load_fflag_presets():
builtins = {}
path = BASE / "fflag_presets.json"
if path.exists():
try:
builtins = json.loads(path.read_text())
except Exception:
pass
user = {}
if USER_PRESETS_FILE.exists():
try:
user = json.loads(USER_PRESETS_FILE.read_text())
except Exception:
pass
return builtins, user
def _save_user_presets(presets):
USER_PRESETS_FILE.parent.mkdir(parents=True, exist_ok=True)
USER_PRESETS_FILE.write_text(json.dumps(presets, indent=2) + "\n")
def build_flaglist(app, parent, pad):
search_row = tk.Frame(parent, bg=parent["bg"])
search_row.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
tk.Label(search_row, text="Search", bg=parent["bg"], fg=FG,
font=BODY_FONT).pack(side="left", padx=(0, 8))
search_var = tk.StringVar()
search_entry = tk.Entry(search_row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT,
textvariable=search_var)
search_entry.pack(side="left", fill="x", expand=True, ipady=6)
count_label = tk.Label(search_row, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10))
count_label.pack(side="left", padx=(8, 0))
list_frame = tk.Frame(parent, bg=parent["bg"])
list_frame.columnconfigure(0, weight=1)
list_frame.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
status = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
status.pack(anchor="w", padx=pad, pady=(0, 6))
allow_label = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
allow_label.pack(anchor="w", padx=pad, pady=(0, 6))
btn_row = tk.Frame(parent, bg=parent["bg"])
btn_row.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
allow_row = tk.Frame(parent, bg=parent["bg"])
allow_row.pack(anchor="w", fill="x", padx=pad, pady=(0, 14))
def apply_filter():
query = search_var.get().strip().lower()
shown = 0
for key_entry, _, row in app.fflag_rows:
matches = not query or query in key_entry.get().strip().lower()
if matches:
row.grid()
shown += 1
else:
row.grid_remove()
total = len(app.fflag_rows)
count_label.configure(
text=f"{shown}/{total} flags" if query else f"{total} flags")
search_var.trace_add("write", lambda *_: apply_filter())
def _update_warning(key_entry):
warn = getattr(key_entry, "_warn_lbl", None)
if warn is None:
return
name = key_entry.get().strip()
denied = bool(name) and name not in fflags.allowlist()
if denied:
warn.pack(side="left", padx=(0, 6))
else:
warn.pack_forget()
def refresh_warnings():
denied = []
for key_entry, _, _row in app.fflag_rows:
name = key_entry.get().strip()
if name and name not in fflags.allowlist():
denied.append(name)
_update_warning(key_entry)
if not app.fflag_rows:
allow_label.configure(text="", fg=FG_DIM)
elif denied:
shown = ", ".join(denied[:3])
more = f" (+{len(denied) - 3} more)" if len(denied) > 3 else ""
allow_label.configure(
text=f"{len(denied)} flag(s) not on Roblox's allowlist and will "
f"be ignored: {shown}{more}",
fg=ERROR)
else:
data = fflags.allowlist_file()
updated = data.get("updated") or "bundled copy"
allow_label.configure(
text=f"All flags are on Roblox's allowlist "
f"({len(fflags.allowlist())} allowed, updated {updated}).",
fg=FG_DIM)
def add_row(key="", value=""):
list_frame.pack(anchor="w", fill="x", padx=pad, pady=(0, 6),
before=status)
row_index = len(app.fflag_rows)
row = tk.Frame(list_frame, bg=parent["bg"])
row.grid(row=row_index, column=0, sticky="ew", pady=3)
key_entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", width=32,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
key_entry.insert(0, key)
key_entry.pack(side="left", padx=(0, 6), ipady=6)
value_entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", width=16,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
value_entry.insert(0, value)
value_entry.pack(side="left", padx=(0, 6), ipady=6)
warn_lbl = tk.Label(row, text="not on allowlist", bg=parent["bg"],
fg=ERROR, font=("TkDefaultFont", 9))
key_entry._warn_lbl = warn_lbl
key_entry.bind("<KeyRelease>",
lambda e, ke=key_entry: _update_warning(ke))
remove_btn = app.make_button(row, "x", command=lambda: remove_row(row),
bg=BG_SIDEBAR, fg=FG_DIM,
padx=10, pady=4)
warn_lbl.pack(side="left", padx=(0, 6))
remove_btn.pack(side="left")
app.fflag_rows.append((key_entry, value_entry, row))
apply_filter()
def open_add_flag():
win = tk.Toplevel(app, bg=BG)
win.title("Add FFlag")
_fit(win, 500, 300)
win.configure(bg=BG)
win.resizable(False, False)
tk.Label(win, text="Flag name:", bg=BG, fg=FG,
font=BODY_FONT).pack(anchor="w", padx=16, pady=(16, 2))
key_entry = tk.Entry(win, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", width=40,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
key_entry.pack(anchor="w", padx=16, ipady=6)
key_entry.focus()
tk.Label(win, text="Value:", bg=BG, fg=FG,
font=BODY_FONT).pack(anchor="w", padx=16, pady=(8, 2))
val_entry = tk.Entry(win, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", width=40,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
val_entry.pack(anchor="w", padx=16, ipady=6)
def do_add():
key = key_entry.get().strip()
val = val_entry.get().strip()
if key:
add_row(key, val)
win.destroy()
key_entry.bind("<Return>", lambda e: do_add())
val_entry.bind("<Return>", lambda e: do_add())
app.make_button(win, "Add", command=do_add, padx=12, pady=6
).pack(anchor="w", padx=16, pady=(12, 16))
def remove_row(row):
app.fflag_rows = [r for r in app.fflag_rows if r[2] is not row]
row.destroy()
for i, (_, _, r) in enumerate(app.fflag_rows):
was_hidden = not r.winfo_manager()
r.grid_configure(row=i)
if was_hidden:
r.grid_remove()
apply_filter()
def reload_rows():
for w in list_frame.winfo_children():
w.destroy()
app.fflag_rows = []
for key, value in fflags.get_fflags().items():
add_row(key, str(value))
if app.fflag_rows:
list_frame.pack(anchor="w", fill="x", padx=pad, pady=(0, 6),
before=status)
else:
list_frame.pack_forget()
apply_filter()
refresh_warnings()
parent.event_generate("<Configure>")
def _confirm_disallowed(new_fflags, proceed):
_ok, bad = fflags.validate(new_fflags)
if not bad:
proceed(list(bad))
return
win = tk.Toplevel(app, bg=BG)
win.title("Flags not on the allowlist")
_fit(win, 500, 240)
win.configure(bg=BG)
win.resizable(False, False)
shown = ", ".join(bad[:8])
more = f"\nand {len(bad) - 8} more" if len(bad) > 8 else ""
tk.Label(
win,
text=(f"{len(bad)} of these flags are not on Roblox's allowlist "
f"and will be ignored by the client:\n\n{shown}{more}"),
bg=BG, fg=FG, font=BODY_FONT, justify="left",
wraplength=460).pack(anchor="w", padx=16, pady=(16, 14))
btn_row2 = tk.Frame(win, bg=BG)
btn_row2.pack(pady=(0, 16))
def save_without_bad():
kept, _removed = fflags.clean(new_fflags)
win.destroy()
proceed(list(_removed), saved=kept)
app.make_button(btn_row2, "remove them & save",
command=save_without_bad, padx=12, pady=6
).pack(side="left", padx=(0, 8))
app.make_button(btn_row2, "save anyway",
command=lambda: (win.destroy(), proceed(list(bad))),
padx=12, pady=6).pack(side="left", padx=(0, 8))
app.make_button(btn_row2, "cancel", command=win.destroy,
padx=12, pady=6).pack(side="left")
def save_rows():
new_fflags = {}
for key_entry, value_entry, _ in app.fflag_rows:
key = key_entry.get().strip()
if not key:
continue
new_fflags[key] = fflags.parse_value(value_entry.get())
def proceed(bad, saved=None):
to_save = saved if saved is not None else new_fflags
fflags.save_fflags(to_save)
reload_rows()
if saved is not None and bad:
status.configure(
text=f"Flags saved — dropped {len(bad)} not on the "
f"allowlist.", fg=FG_DIM)
elif bad:
status.configure(
text=f"Flags saved — {len(bad)} of them will be ignored "
f"by roblox.", fg=ERROR)
else:
status.configure(text="Flags saved.", fg=FG_DIM)
_confirm_disallowed(new_fflags, proceed)
app.reload_fflags_ui = reload_rows
app.make_button(btn_row, "Add Flag", command=open_add_flag
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Save Flags", command=save_rows
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Paste JSON",
command=lambda: _open_paste_json(app)
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Export JSON",
command=lambda: _export_fflags_json(app, status)
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Presets",
command=lambda: _open_presets_window(app, reload_rows, status)
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Clear All", command=lambda: _clear_all_fflags(app, reload_rows, status),
bg=ERROR, fg="#0a0a0a", padx=12
).pack(side="left")
app.make_button(allow_row, "Remove non-working fflags",
command=lambda: _clean_disallowed(app, reload_rows, status)
).pack(side="left", padx=(0, 6))
app.make_button(allow_row, "Update fflag allowlist",
command=lambda: _update_allowlist(app, reload_rows, status)
).pack(side="left", padx=(0, 6))
reload_rows()
def _open_presets_window(app, reload_fn, status):
win = tk.Toplevel(app, bg=BG)
win.title("FFlag Presets")
_fit(win, 600, 500)
win.configure(bg=BG)
win.resizable(True, True)
builtins, user_presets = _load_fflag_presets()
def apply_preset(name, flags, replace=False):
current = {} if replace else fflags.get_fflags()
current.update(flags)
fflags.save_fflags(current)
reload_fn()
_ok, bad = fflags.validate(flags)
note = (f" ({len(bad)} not on the allowlist)" if bad else "")
verb = "Loaded profile" if replace else "Applied preset"
status.configure(text=f"{verb}: {name}{note}",
fg=ERROR if bad else FG_DIM)
canvas = tk.Canvas(win, bg=BG, highlightthickness=0)
scrollbar = tk.Scrollbar(win, orient="vertical",
command=canvas.yview,
bg=BG_SIDEBAR, troughcolor=BG_SIDEBAR,
activebackground=FG_DIM, width=10)
body = tk.Frame(canvas, bg=BG)
body_window = canvas.create_window((0, 0), window=body, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
def on_body_configure(e):
canvas.configure(scrollregion=canvas.bbox("all"))
body.bind("<Configure>", on_body_configure)
def on_canvas_configure(e):
canvas.itemconfigure(body_window, width=e.width)
canvas.bind("<Configure>", on_canvas_configure)
def on_mousewheel(e):
steps = int(-1 * (e.delta / 120))
if steps == 0 and e.delta:
steps = -1 if e.delta > 0 else 1
canvas.yview_scroll(steps, "units")
def on_scroll_up(e):
canvas.yview_scroll(-1, "units")
def on_scroll_down(e):
canvas.yview_scroll(1, "units")
win.bind("<MouseWheel>", on_mousewheel)
win.bind("<Button-4>", on_scroll_up)
win.bind("<Button-5>", on_scroll_down)
canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")
if builtins:
tk.Label(body, text="Built-in Presets", bg=BG, fg=FG,
font=("TkDefaultFont", 13, "bold"),
anchor="w").pack(anchor="w", padx=16, pady=(16, 6))
bi_frame = tk.Frame(body, bg=BG_ACTIVE, highlightthickness=1,
highlightbackground=BG_SIDEBAR)
bi_frame.pack(anchor="w", fill="x", padx=16, pady=(0, 12))
for name, data in builtins.items():
row = tk.Frame(bi_frame, bg=BG_ACTIVE)
row.pack(anchor="w", fill="x", padx=8, pady=4)
info = tk.Frame(row, bg=BG_ACTIVE)
info.pack(side="left", fill="x", expand=True)
tk.Label(info, text=name, bg=BG_ACTIVE, fg=FG,
font=("TkDefaultFont", 11, "bold"),
anchor="w").pack(anchor="w")
desc = data.get("description", "")
if desc:
tk.Label(info, text=desc, bg=BG_ACTIVE, fg=FG_DIM,
font=("TkDefaultFont", 9),
anchor="w").pack(anchor="w")
app.make_button(row, "Replace",
command=lambda n=name, f=data["flags"]: apply_preset(n, f, replace=True),
padx=10, pady=4
).pack(side="right")
app.make_button(row, "Apply", command=lambda n=name, f=data["flags"]: apply_preset(n, f),
padx=10, pady=4
).pack(side="right")
tk.Label(body, text="Your fflag presets", bg=BG, fg=FG,
font=("TkDefaultFont", 13, "bold"),
anchor="w").pack(anchor="w", padx=16, pady=(6, 6))
user_frame = tk.Frame(body, bg=BG_ACTIVE, highlightthickness=1,
highlightbackground=BG_SIDEBAR)
user_frame.pack(anchor="w", fill="x", padx=16, pady=(0, 12))
def refresh_user():
for w in user_frame.winfo_children():
w.destroy()
_, up = _load_fflag_presets()
if not up:
tk.Label(user_frame, text="no custom presets", bg=BG_ACTIVE, fg=FG_DIM,
font=("TkDefaultFont", 10)).pack(anchor="w", padx=8, pady=8)
return
for name, data in up.items():
row = tk.Frame(user_frame, bg=BG_ACTIVE)
row.pack(anchor="w", fill="x", padx=8, pady=4)
app.make_button(row, name,
command=lambda n=name, f=data["flags"]: apply_preset(n, f),
padx=10, pady=4
).pack(side="left")
app.make_button(row, "Replace",
command=lambda n=name, f=data["flags"]: apply_preset(n, f, replace=True),
padx=10, pady=4
).pack(side="left", padx=(6, 0))
def delete_preset(n=name):
d = {}
if USER_PRESETS_FILE.exists():
try:
d = json.loads(USER_PRESETS_FILE.read_text())
except Exception:
pass
d.pop(n, None)
_save_user_presets(d)
refresh_user()
del_btn = tk.Label(row, text="x", bg=BG_ACTIVE, fg=ERROR,
font=("TkDefaultFont", 9), cursor="hand2", padx=4)
del_btn.pack(side="right")
del_btn.bind("<Button-1>", lambda e, n=name: delete_preset(n))
refresh_user()
def save_as_preset():
save_win = tk.Toplevel(app, bg=BG)
save_win.title("Save Preset")
_fit(save_win, 400, 160)
save_win.configure(bg=BG)
save_win.resizable(False, False)
tk.Label(save_win, text="Preset name:", bg=BG, fg=FG,
font=BODY_FONT).pack(anchor="w", padx=16, pady=(16, 4))
name_entry = tk.Entry(save_win, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
name_entry.pack(fill="x", padx=16, pady=(0, 8), ipady=6)
name_entry.focus()
def save():
name = name_entry.get().strip()
if not name:
return
current = fflags.get_fflags()
if not current:
return
d = {}
if USER_PRESETS_FILE.exists():
try:
d = json.loads(USER_PRESETS_FILE.read_text())
except Exception:
pass
d[name] = {"description": "", "flags": current}
_save_user_presets(d)
save_win.destroy()
refresh_user()
status.configure(text=f"Saved preset: {name}", fg=FG_DIM)
name_entry.bind("<Return>", lambda e: save())
app.make_button(save_win, "Save", command=save, padx=12, pady=6
).pack(anchor="w", padx=16, pady=(0, 16))
app.make_button(body, "save current as a preset", command=save_as_preset,
padx=12, pady=6
).pack(anchor="w", padx=16, pady=(0, 16))
def _open_paste_json(app):
win = tk.Toplevel(app, bg=BG)
win.title("Paste FFlags JSON")
win.configure(bg=BG)
_fit(win, 600, 820)
def apply_json():
raw = text.get("1.0", "end").strip()
try:
parsed = json.loads(raw)
except json.JSONDecodeError as e:
status.configure(text=f"Invalid JSON: {e}", fg=ERROR)
return
if not isinstance(parsed, dict):
status.configure(text="JSON must be an object of flag: value pairs",
fg=ERROR)
return
current = fflags.get_fflags()
current.update(parsed)
fflags.save_fflags(current)
app.reload_fflags_ui()
win.destroy()
btn_row = tk.Frame(win, bg=BG)
btn_row.pack(side="bottom", fill="x", anchor="w", padx=16, pady=(0, 16))
app.make_button(btn_row, "Apply", command=apply_json).pack(side="left")
status = tk.Label(win, text="", bg=BG, fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w")
status.pack(side="bottom", anchor="w", fill="x", padx=16, pady=(0, 8))
tk.Label(win, text="Paste FFlags JSON", bg=BG, fg=FG,
font=("TkDefaultFont", 14, "bold"), anchor="w"
).pack(anchor="w", padx=16, pady=(16, 8))
text_frame = tk.Frame(win, bg=BG_ACTIVE)
text_frame.pack(fill="both", expand=True, padx=16, pady=(0, 8))
text = tk.Text(text_frame, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", wrap="word",
highlightthickness=1, highlightbackground=BG_SIDEBAR,
height=12)
text_scroll = tk.Scrollbar(text_frame, orient="vertical",
command=text.yview,
bg=BG_SIDEBAR, troughcolor=BG_SIDEBAR,
activebackground=FG_DIM, width=10)
text.configure(yscrollcommand=text_scroll.set)
text_scroll.pack(side="right", fill="y")
text.pack(side="left", fill="both", expand=True)
text.focus_set()
text.bind("<Return>", lambda e: apply_json())
text.bind("<KP_Enter>", lambda e: apply_json())
def build_fpsinput(app, parent, pad):
tk.Label(parent, text="Framerate cap", bg=parent["bg"], fg=FG,
font=BODY_FONT).pack(anchor="w", padx=pad, pady=(0, 2))
vcmd = (app.register(fps.validate_digits), "%P")
entry = tk.Entry(parent, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT,
validate="key", validatecommand=vcmd)
current = fps.load_framerate_cap()
if current:
entry.insert(0, current)
entry.pack(anchor="w", fill="x", padx=pad, pady=(0, 6), ipady=8)
tk.Label(parent,
text=("Only applies after you open Roblox, set in-game cap to "
"default (60), close Roblox, then set it here and "
"relaunch. and yes this is true, Roblox is probably gonna be patching this so don't be surprised when this doesn't work anymore"),
bg=parent["bg"], fg=FG_DIM, font=("TkDefaultFont", 10),
anchor="w", wraplength=500, justify="left"
).pack(anchor="w", padx=pad, pady=(0, 6))
def save():
value = entry.get().strip()
if not value:
return
try:
fps.save_framerate_cap(value)
except Exception as e:
fps_status.configure(text=str(e), fg=ERROR)
else:
fps_status.configure(text=f"saved, cap is now {value}", fg=FG_DIM)
app.make_button(parent, "Save FPS Limit", command=save
).pack(anchor="w", padx=pad, pady=(0, 4))
fps_status = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
fps_status.pack(anchor="w", padx=pad, pady=(0, 14))
def build_fontpicker(app, parent, pad):
tk.Label(parent, text="Font file (.ttf / .otf)", bg=parent["bg"],
fg=FG, font=BODY_FONT).pack(anchor="w", padx=pad, pady=(0, 2))
row = tk.Frame(parent, bg=parent["bg"])
row.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
path_entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
path_entry.pack(side="left", fill="x", expand=True, ipady=8,
padx=(0, 6))
def browse():
chosen = filedialog.askopenfilename(
title="Choose a font file",
filetypes=[("Font files", "*.ttf *.otf"), ("All files", "*.*")]
)
if chosen:
path_entry.delete(0, "end")
path_entry.insert(0, chosen)
app.make_button(row, "browse", command=browse, padx=14, pady=8
).pack(side="left")
status = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
status.pack(anchor="w", padx=pad, pady=(0, 6))
def apply_font():
source = path_entry.get().strip()
if not source:
status.configure(text="js pick a font file first", fg=ERROR)
return
try:
replaced = fonts.apply_font(source)
fonts.save_installed_font(source)
except FileNotFoundError as e:
status.configure(text=str(e), fg=ERROR)
return
if not replaced:
status.configure(
text="no font files to replace",
fg=ERROR)
return
status.configure(
text=f"Replaced {len(replaced)} font file(s).", fg=FG_DIM)
app.make_button(parent, "Apply font", command=apply_font
).pack(anchor="w", padx=pad, pady=(0, 6))
def restore_default():
removed = fonts.restore_fonts()
if removed:
status.configure(text="default fonts restored", fg=FG_DIM)
else:
status.configure(text="no custom font to restore", fg=ERROR)
app.make_button(parent, "Restore default fonts", command=restore_default,
bg=ERROR, fg="#0a0a0a"
).pack(anchor="w", padx=pad, pady=(0, 6))
tk.Label(parent,
text=("NOTE: If Sober updates and removes your font, reopen Lution and we'll reapply it automatically"),
bg=parent["bg"], fg=FG_DIM, font=("TkDefaultFont", 10),
anchor="w", wraplength=500, justify="left"
).pack(anchor="w", padx=pad, pady=(0, 14))
def build_envvars(app, parent, pad):
status = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
status.pack(anchor="w", padx=pad, pady=(0, 6))
list_frame = tk.Frame(parent, bg=parent["bg"])
list_frame.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
rows = []
def add_row(key="", value=""):
row = tk.Frame(list_frame, bg=parent["bg"])
row.pack(anchor="w", fill="x", pady=3)
key_entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat", width=22,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
key_entry.insert(0, key)
key_entry.pack(side="left", padx=(0, 6), ipady=6)
eq_label = tk.Label(row, text="=", bg=parent["bg"], fg=FG_DIM,
font=BODY_FONT)
eq_label.pack(side="left", padx=(0, 6))
value_entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
value_entry.insert(0, value)
value_entry.pack(side="left", fill="x", expand=True, ipady=6,
padx=(0, 6))
def remove():
row.destroy()
for item in rows:
if item[0] is key_entry:
rows.remove(item)
break
app.make_button(row, "x", command=remove,
bg=BG_SIDEBAR, fg=FG_DIM, padx=10, pady=4
).pack(side="left")
rows.append((key_entry, value_entry))
def open_add_var():
win = tk.Toplevel(app, bg=BG)
win.title("Add environment variable")
_fit(win, 500, 300)
win.configure(bg=BG)
win.resizable(False, False)
tk.Label(win, text="Variable name:", bg=BG, fg=FG,
font=BODY_FONT).pack(anchor="w", padx=16, pady=(16, 2))
key_entry = tk.Entry(win, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, width=40,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
key_entry.pack(anchor="w", padx=16, ipady=6)
key_entry.focus()
tk.Label(win, text="Value:", bg=BG, fg=FG,
font=BODY_FONT).pack(anchor="w", padx=16, pady=(8, 2))
val_entry = tk.Entry(win, bg=BG_ACTIVE, fg=FG, insertbackground=FG,
font=BODY_FONT, width=40,
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
val_entry.pack(anchor="w", padx=16, ipady=6)
hint = tk.Label(win, text="", bg=BG, fg=ERROR,
font=("TkDefaultFont", 10), anchor="w")
hint.pack(anchor="w", padx=16, pady=(6, 0))
def do_add():
key = key_entry.get().strip()
if not envvars.valid_key(key):
hint.configure(
text="name cannot be empty or have spaces / '='.")
return
add_row(key, val_entry.get().strip())
win.destroy()
key_entry.bind("<Return>", lambda e: do_add())
val_entry.bind("<Return>", lambda e: do_add())
app.make_button(win, "Add", command=do_add, padx=12, pady=6
).pack(anchor="w", padx=16, pady=(12, 16))
btn_row = tk.Frame(parent, bg=parent["bg"])
btn_row.pack(anchor="w", fill="x", padx=pad, pady=(0, 14))
def save_vars_action():
data = {}
skipped = False
for key_entry, value_entry in rows:
key = key_entry.get().strip()
if not envvars.valid_key(key):
skipped = True
continue
data[key] = value_entry.get().strip()
saved = envvars.save_vars(data)
note = "Invalid names were skipped." if skipped else \
"'Sober with Lution' shortcut is ready."
status.configure(text=f"Saved {len(saved)} variable(s). {note}",
fg=ERROR if skipped else FG_DIM)
for key, value in envvars.load_vars().items():
add_row(str(key), str(value))
app.make_button(btn_row, "Add variable", command=open_add_var
).pack(side="left", padx=(0, 6))
app.make_button(btn_row, "Save variable", command=save_vars_action
).pack(side="left")
def build_cursorpicker(app, parent, pad):
status = tk.Label(parent, text="", bg=parent["bg"], fg=FG_DIM,
font=("TkDefaultFont", 10), anchor="w",
wraplength=500, justify="left")
status.pack(anchor="w", padx=pad, pady=(0, 6))
preset_names = cursors.list_presets()
cursor_entries = {}
if preset_names:
tk.Label(parent, text="Preset", bg=parent["bg"], fg=FG,
font=BODY_FONT).pack(anchor="w", padx=pad, pady=(6, 2))
preset_combo = ttk.Combobox(parent, values=["Custom"] + preset_names,
font=BODY_FONT, state="readonly")
preset_combo.set("Custom")
preset_combo.pack(anchor="w", padx=pad, pady=(0, 10), ipady=4)
def on_preset_change(event=None):
selection = preset_combo.get()
if selection == "Custom":
return
preset_cursors = cursors.get_preset_cursors(selection)
for name, entry in cursor_entries.items():
entry.delete(0, "end")
if name in preset_cursors:
entry.insert(0, preset_cursors[name])
preset_combo.bind("<<ComboboxSelected>>", on_preset_change)
for state_name in cursors.CURSOR_STATES:
label_text = state_name + ".png"
tk.Label(parent, text=label_text, bg=parent["bg"], fg=FG,
font=BODY_FONT).pack(anchor="w", padx=pad, pady=(6, 2))
row = tk.Frame(parent, bg=parent["bg"])
row.pack(anchor="w", fill="x", padx=pad, pady=(0, 6))
entry = tk.Entry(row, bg=BG, fg=FG, insertbackground=FG,
font=BODY_FONT, relief="flat",
highlightthickness=1,
highlightbackground=BG_SIDEBAR,
highlightcolor=ACCENT)
entry.pack(side="left", fill="x", expand=True, ipady=8,
padx=(0, 6))
cursor_entries[state_name] = entry
def browse_cursor(e=entry, s=state_name):
chosen = filedialog.askopenfilename(
title=f"Choose {s} cursor",
filetypes=[("PNG images", "*.png"), ("All files", "*.*")]
)
if chosen:
e.delete(0, "end")
e.insert(0, chosen)
if preset_combo.get() != "Custom":
preset_combo.set("Custom")
app.make_button(row, "browse", command=browse_cursor,
padx=14, pady=8).pack(side="left")
def apply_cursors_action():
cursors_dict = {}
for name, entry in cursor_entries.items():
path = entry.get().strip()
if path:
cursors_dict[name] = path
if not cursors_dict:
status.configure(text="select atleast one cursor file first", fg=ERROR)
return
applied = cursors.apply_cursors(cursors_dict)
cursors.save_installed_cursors(cursors_dict)