-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgui.py
More file actions
1238 lines (992 loc) · 44.3 KB
/
gui.py
File metadata and controls
1238 lines (992 loc) · 44.3 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
import tkinter as tk
import asyncio
import inspect
from customtkinter import *
from tkinter import filedialog,messagebox
import os
import sys
from tkinter import font as tkFont
import threading
import json
import requests
import webbrowser
from theme import *
from cleanup import *
from games_mods_config import game_mods_config, game_config, addons_presets
from installer import ModInstaller
from helpers import runReg, bind_tooltip
from guide import FsrGuide
from upscaler_updater import games_to_update_upscalers
from helpers import load_or_create_json, hide_and_protect, make_writable
from update import Update
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1) # Per-monitor DPI aware
UPDATE_STATE_FILE = os.path.join(os.getenv('LOCALAPPDATA'), "FSR-Mod-Utility", "update_state.json")
GITHUB_API_URL = "https://api.github.com/repos/P4TOLINO06/FSR3.0-Mod-Setup-Utility/releases/latest"
CURRENT_VERSION = "5.0v"
class Gui:
def __init__(self):
self.root = CTk()
icon = tk.PhotoImage(file="images/Hat.gif")
self.root.wm_iconphoto(True, icon)
self.root.title("FSR3.0 Mod Setup Utility - 5.0v")
self.root.configure(bg='')
self.font = get_font()
self.root.geometry("450x360")
self.root.resizable(0,0)
self.root.configure(bg="#222223")
self.utility_update_available = False
self.mods_update_available = False
self.mods_updated_name = []
self.mods_update_count = 0
self.update_version = None
self.update_state = self.load_update_state()
self.check_for_utility_update()
self.check_for_mods_update()
self.game_selected = None
self.dest_folder = None
self.addons_dest_folder = None
self.mod_options = ['FSR4/DLSS FG (Only Optiscaler)','FSR4/DLSSG FG (Only Optiscaler)']
self.mod_selected = None
self.addons_listbox_visible = False
self.selected_addon = None
self.game_options_listbox_visible = False
self.disable_sigover_var = IntVar(value=0)
self.enable_sigover_var = IntVar(value=0)
self.enable_dlss_overlay_var = IntVar(value=0)
self._active_dropdown = None
self._active_menu_btn = None
self.gpu_name = get_active_gpu()
self.total_steps_progress = 0
self.completed_steps_progress = 0
self.progress_finished = False
self.build_ui()
def build_ui(self):
self.game_selection()
self.folder_selection()
self.mod_selection()
self.addons_selection()
self.enable_signature_override()
self.disable_signature_override()
self.enable_dlss_overlay()
self.guide()
self.toopTip()
self.install_gui()
self.exit()
self.cleanup_mod()
self.root.iconbitmap("images\\Hat.ico")
def run(self):
self.root.mainloop()
def load_update_state(self):
os.makedirs(os.path.dirname(UPDATE_STATE_FILE), exist_ok=True)
return load_or_create_json(UPDATE_STATE_FILE, { "hidden_mods": False, "hidden_utility": False, "last_update_mods_count": self.mods_update_count, "last_utility_update_available": self.utility_update_available})
def save_update_state(self):
try:
if os.path.exists(UPDATE_STATE_FILE):
make_writable(UPDATE_STATE_FILE)
with open(UPDATE_STATE_FILE, "w", encoding="utf-8") as f:
json.dump(self.update_state, f, indent=4),
hide_and_protect(UPDATE_STATE_FILE)
except Exception as e:
print("Error saving update_state:", e)
def restore_update_btn(self):
# If there is a Utility update and it has not been hidden by clicking the "X"
if self.utility_update_available and not self.update_state.get("hidden_utility", False):
return True
# If there are mods and the hidden_mods flag is False (because there was a change or it was never hidden)
if self.mods_update_count > 0 and not self.update_state.get("hidden_mods", False):
return True
return False
def check_for_utility_update(self):
def fetch_latest():
try:
response = requests.get(GITHUB_API_URL, timeout=5)
if response.status_code == 200:
data = response.json()
tag = data.get("tag_name") or data.get("name") or ""
if tag and tag.replace("v", "") > CURRENT_VERSION.replace("v", ""):
self.utility_update_available = True
self.update_version = tag
self.root.after(0, lambda: (
self.update_button() if self.restore_update_btn()
else (self.show_discreet_update_icon() if self.utility_update_available else None)
))
except Exception as e:
print("Error checking for update:", e)
threading.Thread(target=fetch_latest, daemon=True).start()
def check_for_mods_update(self):
try:
self.start_mod_update()
except Exception as e:
print("Error checking mods update:", e)
def start_mod_update(self):
threading.Thread(target=self._run_mod_update,args=(False,),daemon=True).start()
def _finish_mod_update(self, count):
last_saved_count = self.update_state.get("last_update_mods_count", 0)
if count != last_saved_count:
# Show update_btn again if count is different from "last_update_mods_count" in the JSON (even if update_btn was closed by clicking the "X")
self.update_state["hidden_mods"] = False
self.update_state["last_update_mods_count"] = count
self.save_update_state()
if self.utility_update_available or self.mods_update_available:
if self.restore_update_btn():
self.update_button()
else:
self.show_discreet_update_icon()
else:
if hasattr(self, "update_icon_btn") and self.update_icon_btn:
self.update_icon_btn.place_forget()
self.update_icon_btn = None
def _run_mod_update(self, apply=False):
updater = Update()
has_update, count, mods = updater.check_updates()
self.mods_update_available = has_update
self.mods_update_count = count
for mod in mods:
self.mods_updated_name.append(mod)
self.mod_info = [
mod["remote"].get("display_name") or mod["name"]
for mod in mods
]
self.total_mods = self.mod_info
self.lines = []
for i in range(0, len(self.total_mods), 5):
self.lines.append(", ".join(self.total_mods[i:i + 5]))
self.display_mod_name = "\n".join(self.lines)
if apply:
if getattr(self, "update_btn", None) and self.update_btn.winfo_exists():
self.update_btn.configure(state="disabled", width=80,text="Updating...")
self.close_update_btn.configure(state="disabled", cursor="arrow")
self.close_update_btn.place(x=255, y=228)
if getattr(self, "update_icon_btn", None) and self.update_icon_btn.winfo_exists():
self.update_icon_btn.configure(state="disabled", width=30)
self.update_progress_bar(count)
updater.run_updater(progress_callback=self.update_update_progress)
return
self.root.after(0,lambda: self._finish_mod_update(count))
def update_progress_bar(self, count):
self.update_total_steps = count
self.update_completed_steps = 0
self.update_progress = CTkProgressBar(
self.root,
width=153,
height=15,
corner_radius=8
)
self.update_progress.set(0)
if hasattr(self, "progress") and self.progress.winfo_ismapped():
self.update_progress.place(x=275, y=232)
elif not self.update_progress.winfo_ismapped():
self.update_progress.place(x=0, y=285)
def update_update_progress(self):
self.update_completed_steps += 1
value = min(self.update_completed_steps / self.update_total_steps, 1.0)
self.update_progress.set(value)
if self.update_completed_steps >= self.update_total_steps:
self.root.after(0, self._finish_update)
def _finish_update(self):
if hasattr(self, "update_progress"):
self.update_progress.place_forget()
self.update_progress = None
if hasattr(self, "update_btn"):
self.update_btn.place_forget()
self.update_btn = None
if hasattr(self, "close_update_btn"):
self.close_update_btn.place_forget()
self.close_update_btn = None
if hasattr(self, "update_icon_btn"):
self.update_icon_btn.place_forget()
self.update_icon_btn = None
self.mods_update_available = False
self.mods_update_count = 0
self.update_success_label = CTkLabel(
self.root,
text="Mods updated successfully!",
font=(self.font[0], 15, "bold"),
fg_color="#222223",
text_color="#A8B0C0"
)
if hasattr(self, "sucess") and self.sucess.winfo_ismapped():
self.update_success_label.place(x=170, y=227)
else:
self.update_success_label.place(x=0, y=275)
# Reset the JSON after updating the mods
self.update_state["hidden_mods"] = False
self.update_state["last_update_mods_count"] = 0
self.update_state["last_utility_update_available"] = self.utility_update_available
self.save_update_state()
self.root.after(3000, self.update_success_label.destroy)
def update_button(self):
if self.utility_update_available:
if self.update_state.get("hidden_utility"):
self.show_discreet_update_icon()
return
elif self.mods_update_available:
if self.update_state.get("hidden_mods"):
self.show_discreet_update_icon()
return
if not hasattr(self, "update_btn"):
self.update_btn = CTkButton(
self.root,
width=70,
height=25,
corner_radius=8,
text_color="white",
command=self.on_update
)
self.update_btn.place(x=170, y=227)
self.close_update_btn = CTkButton(
self.root,
text="X",
width=25,
height=25,
corner_radius=8,
fg_color="#555a64",
hover_color="#777",
text_color="white",
command=self.hide_update_button
)
self.close_update_btn.place(x=250, y=227)
bind_tooltip(self.close_update_btn, "Close", 0)
if self.utility_update_available:
self.update_btn.configure(
text= "Update",
fg_color= "#ff6633",
hover_color= "#ff8566",
)
bind_tooltip(self.update_btn,f"Update Utility available ({self.update_version})",0)
elif self.mods_update_available:
self.update_btn.configure(
text= "Update",
fg_color="#9966cc",
hover_color="#b38cd9"
)
bind_tooltip(self.update_btn,f"Update Mods available ({self.mods_update_count}):\n{self.display_mod_name}",0)
def on_update(self):
if self.utility_update_available:
self.open_latest_release()
elif self.mods_update_available:
threading.Thread(target=self._run_mod_update,args=(True,),daemon=True).start()
def hide_update_button(self):
if hasattr(self, "update_btn"):
self.update_btn.place_forget()
self.update_btn = None
if hasattr(self, "close_update_btn"):
self.close_update_btn.place_forget()
self.close_update_btn = None
if self.utility_update_available:
self.update_state["hidden_utility"] = True
self.update_state["last_utility_update_available"] = self.utility_update_available
elif self.mods_update_available:
self.update_state["hidden_mods"] = True
self.update_state["last_update_mods_count"] = self.mods_update_count
print(self.mods_update_count)
self.save_update_state()
self.show_discreet_update_icon()
def show_discreet_update_icon(self):
if hasattr(self, "update_icon_btn"):
return
self.update_icon_btn = CTkButton(
self.root,
text="⬇",
width=30,
height=25,
corner_radius=50,
fg_color="#3a3f4b",
hover_color="#5b6373",
text_color="white",
command=self.on_update
)
self.update_icon_btn.place(x=415, y=330)
bind_tooltip(self.update_icon_btn, f"Utility Update available ({self.update_version})" if self.utility_update_available else f"Update Mods available ({self.mods_update_count}):\n{self.display_mod_name}" if self.mods_update_available else "", 0)
def open_latest_release(self):
self.update_state["hidden_utility"] = False
self.update_state["last_utility_update_available"] = True
self.save_update_state()
webbrowser.open("https://github.com/P4TOLINO06/FSR3.0-Mod-Setup-Utility/releases/latest")
def main_screen(self):
# ICON
icon_image = tk.PhotoImage(file="images\\Hat.gif")
self.root.iconphoto(True, icon_image)
# FONT
self.change_text = False
try:
self.font_selected = (self.font, 11, 'bold')
self.var_font = tk.Label(self.root,text=".", font=self.font,fg=COLORS['fg'], bg=COLORS['bg'])
except tk.TclError:
self.font_selected = tkFont.Font(family="Arial",size=10)
self.change_text = True
second_tittle = tk.Label(self.root, text="FSR4/DLSS FG Mods", font=("Arial", 11, "bold"), fg="#778899", bg=COLORS['bg'])
second_tittle.pack(anchor='w',pady=0)
# GAME SELECTION
def game_selection(self):
self.game_selected_label = CTkLabel(
self.root, text="Game Select -",
font=(self.font[0], 17, 'bold'),
text_color=COLORS["text"]
)
self.game_selected_label.place(x=0,y=1)
self.game_selected, self.game_options_menu = self._Combobox(self.root,game_config,115,4)
self.game_selected.trace_add("write", self.on_game_selected)
def on_game_selected(self, *_):
game = self.game_selected.get()
if game:
self.update_mod_list(game, game_mods_config)
if hasattr(self, "sub_addons"):
self.update_addons_for_game()
print(game)
# FOLDER SELECTION
def folder_selection(self):
self.selected_folder = None
self.game_folder_label = CTkLabel(
self.root, text="Game folder -",
font=(self.font[0], 17, 'bold'),
text_color=COLORS["text"]
)
self.game_folder_label.place(x=0,y=35)
self.text_selected_game_folder,self.selected_game_folder_canvas = self._CanvasLabel(self.root, self.dest_folder, 115,38, text_color="white")
self.btn_selected_folder = self._Button(
self.root,
"Browser",
359, 39,
lambda: self.open_explorer("dest_folder", self.text_selected_game_folder, self.selected_game_folder_canvas),
fg_color="#555a64",
hover_color="#6b7180"
)
# OPEN EXPLORER
def open_explorer(self, attr_name, text_var=None, widget=None, limited_text=29):
folder = filedialog.askdirectory()
setattr(self, attr_name, folder if folder else "")
if folder:
if text_var:
text_var.set(folder if len (folder) <= limited_text else folder[:limited_text] + "…")
if widget:
bind_tooltip(widget, folder, 0)
else:
if text_var:
text_var.set("")
if widget:
bind_tooltip(widget, "", 0)
# MOD SELECTION
def mod_selection(self):
self.mod_version_label = CTkLabel(
self.root, text="Mod version -",
font=(self.font[0], 17, 'bold'),
text_color=COLORS["text"]
)
self.mod_version_label.place(x=0,y=69)
self.mod_selected, self.mod_version_menu = self._Combobox(self.root, self.mod_options, 115, 72, max_visible_items=4)
def update_mod_list(self, game_selected, game_mods_config):
if game_selected in game_mods_config:
self.mod_options = game_mods_config[game_selected]
else:
self.mod_options = ['FSR4/DLSS FG (Only Optiscaler)','FSR4/DLSSG FG (Only Optiscaler)']
self.mod_selected, self.mod_version_menu = self._Combobox(self.root, self.mod_options, 115, 72, max_visible_items=4)
print(self.mod_selected.get())
def on_mod_selected(self, event=None):
self.mod_selected = self.mod_version_menu.get()
self.mod_version_menu.place_forget()
# ADDONS
def addons_selection(self):
# Addons Cbox
self.addons_var = IntVar()
self.addons_cbox = CTkCheckBox(
self.root, text="Addons",
font=self.font,
fg_color=COLORS["accent"],
hover_color="#66b2ff",
text_color=COLORS["text"],
variable=self.addons_var,
corner_radius=7,
checkbox_width=20,
checkbox_height=20,
command=self.on_addons_toggle
)
self.addons_cbox.place(x=3, y=108)
# Addons Btn
self.addons_selected = tk.StringVar(value="")
self.addons_canvas_btn = CTkButton(
self.root,
textvariable=self.addons_selected,
width=238,
height=25,
corner_radius=6,
fg_color="#2e3a5a",
hover_color="#6a5aff",
text_color="white",
font=self.font,
command=self.toggle_addons_menu
)
self.addons_canvas_btn.place(x=115, y=108)
# Browser
self.addons_selected_btn = self._Button(
self.root,
"Browser",
359, 109,
command=lambda: self.open_explorer("addons_dest_folder", None, self.addons_selected_btn, 0),
fg_color="#555a64",
hover_color="#6b7180"
)
addons_opt = ["FSR4", "FSR3", "DLSS", "DLSS 4.5","DLSSG", "DLSSD", "XESS"]
self.sub_addons = {n: IntVar() for n in addons_opt}
self._addons_dropdown = None
def on_addons_toggle(self):
if not self.addons_var.get():
if self._addons_dropdown and self._addons_dropdown.winfo_exists():
self._addons_dropdown.destroy()
self._addons_dropdown = None
self.addons_selected.set("")
[v.set(0) for v in self.sub_addons.values()]
bind_tooltip(self.addons_canvas_btn, "")
else:
self.update_addons_for_game()
def toggle_addons_menu(self):
if not self.addons_var.get():
return
if self._addons_dropdown and self._addons_dropdown.winfo_exists():
self._addons_dropdown.destroy()
self._addons_dropdown = None
self.root.unbind_all("<MouseWheel>")
return
dropdown = tk.Toplevel(self.root)
dropdown.wm_overrideredirect(True)
dropdown.configure(bg="#353535")
dropdown.pack_propagate(False)
self._addons_dropdown = dropdown
x = self.addons_canvas_btn.winfo_rootx()
y = self.addons_canvas_btn.winfo_rooty() + self.addons_canvas_btn.winfo_height()
# DPI/Height
dpi_scale = self.root.winfo_fpixels('1i') / 96
item_height = int(30 * dpi_scale)
visible_count = len(self.sub_addons)
# Submenu limit
min_items = 2
max_items = 3
dropdown_items = max(min_items, min(visible_count, max_items))
height = dropdown_items * item_height
# Width
self.addons_canvas_btn.update_idletasks()
button_width = self.addons_canvas_btn.winfo_width()
scroll_width = 25
canvas_width = button_width - scroll_width
width_total = button_width
self.root.bind(
"<Configure>",
lambda e, w=dropdown, b=self.addons_canvas_btn, wt=width_total, ht=height:
self.follow_root(w, b, wt, ht),
add="+"
)
dropdown.geometry(f"{width_total}x{height}+{x}+{y}")
# Canvas
canvas = tk.Canvas(dropdown, bg="#353535", highlightthickness=0, bd=0,
width=canvas_width, height=height)
canvas.pack(side="left", fill="y")
# Scrollbar
scroll = tk.Scrollbar(dropdown, command=canvas.yview)
scroll.pack(side="right", fill="y")
canvas.configure(yscrollcommand=scroll.set)
# Frame Cboxes
inner = tk.Frame(canvas, bg="#353535")
canvas.create_window((0, 0), window=inner, anchor="nw", width=canvas_width)
canvas.bind("<Enter>", lambda e, c=canvas:
self.root.bind_all("<MouseWheel>", lambda ev: self.on_mouse_wheel(ev, c)))
canvas.bind("<Leave>", lambda e: self.root.unbind_all("<MouseWheel>"))
# Upscalers cbox
for name, var in self.sub_addons.items():
CTkCheckBox(inner, text=name, variable=var, font=self.font,
text_color="white", fg_color="#555a64", hover_color="#6b7180",
corner_radius=5, checkbox_width=18, checkbox_height=18,
command=self.update_addons_button_text).pack(anchor="w", padx=10, pady=3)
inner.configure(bg="#353535")
inner.update_idletasks()
canvas.configure(scrollregion=canvas.bbox("all"))
self.root.bind("<Button-1>", lambda e: (
dropdown.destroy(),
setattr(self, "_addons_dropdown", None),
self.root.unbind_all("<MouseWheel>"),
self.root.unbind("<Button-1>")
) if dropdown and not dropdown.winfo_containing(e.x_root, e.y_root) else None, add="+")
def update_addons_button_text(self):
selected = [name for name, var in self.sub_addons.items() if var.get()]
text = ", ".join(selected) if selected else ""
self.addons_selected.set(text[:33])
bind_tooltip(self.addons_canvas_btn, text)
def update_addons_for_game(self):
# Marks the upscaler preset according to the selected game
game = self.game_selected.get() if self.game_selected else None
if not game:
return
for v in self.sub_addons.values():
v.set(0)
for combo, games in addons_presets.items():
if game in games:
for name in combo.split("_"):
if name in self.sub_addons:
self.sub_addons[name].set(1)
if self.addons_var.get() == 1:
self.update_addons_button_text()
def get_selected_upscalers(self):
return {k: v.get() for k, v in self.sub_addons.items()}
# ENABLE SIGNATURE OVERRIDE
def enable_signature_override(self):
self._Checkbox(
"Enable Signature", 3, 147, "enable_sigover_var",
command=lambda: runReg("mods\\Temp\\enable signature override\\EnableSignatureOverride.reg")
if self.enable_sigover_var.get() == 1 else None
)
# DISABLE SIGNATURE OVERRIDE
def disable_signature_override(self):
self._Checkbox(
"Disable Signature", 163, 147, "disable_sigover_var",
command=lambda: runReg("mods\\Temp\\disable signature override\\DisableSignatureOverride.reg")
if self.disable_sigover_var.get() == 1 else None
)
# DLSS Overlay (Only RTX)
def enable_dlss_overlay(self):
visible = 'rtx' in self.gpu_name
self.dlss_overlay_cbox = self._Checkbox(
"DLSS Overlay", 323, 147, "enable_dlss_overlay_var",
command=lambda: runReg(
"mods\\Addons_mods\\DLSS Preset Overlay\\Enable Overlay.reg"
if self.enable_dlss_overlay_var.get() == 1 else
"mods\\Addons_mods\\DLSS Preset Overlay\\Disable Overlay.reg"
),
visible=visible
)
def guide(self):
self.fsr_guide = FsrGuide(self.root, self._Combobox)
self.guide_cbox = self._Checkbox(
"GUIDE", 163, 186, "fsr_guide_var", command=self.fsr_guide.toggle_guide, variable=self.fsr_guide.fsr_guide_var
)
# Cleanup Mods
def cleanup_mod(self):
self.cleanup_var = IntVar()
self.cleanup_cbox = self._Checkbox(
"Cleanup Mod", 3, 186, "cleanup_var", command=self.cbox_cleanup
)
def cbox_cleanup(self):
if self.cleanup_var.get() == 1:
try:
if self.dest_folder is None:
messagebox.showinfo('Select Folder','Please select the destination folder')
self.cleanup_cbox.deselect()
return
if not messagebox.askyesno('Uninstall','Would you like to proceed with the uninstallation of the mod?'):
self.cleanup_cbox.deselect()
return
total = count_cleanup_items(self.dest_folder, self.game_selected.get() if self.game_selected else None, self.mod_selected.get() if self.mod_selected else None)
self.cleanup_total_steps = total
self.cleanup_completed_steps = 0
self.cleanup_finished = False
self.cleanup_progress.set(0)
if total == 0:
messagebox.showinfo('Info','No files were found for removal.')
self.cleanup_cbox.after(400, self.cleanup_cbox.deselect)
return
threading.Thread(target=self._run_cleanup_thread, daemon=True).start()
except Exception as e:
print(e)
def toopTip(self):
# Game selection tooltip
bind_tooltip(self.game_selected_label, "Select a game to install the mod.", 0)
# Game folder tooltip
bind_tooltip(self.game_folder_label, "Select the game folder where you want to install the mod.", 0)
# Mod version tooltip
bind_tooltip(self.mod_version_label, "Select the version of the mod you want to install\n(it is recommended to check the FSR Guide before installing any mod).", 0)
# Guide tooltip
bind_tooltip(self.guide_cbox, "It includes installation guides for most games\n(it is highly recommended to check the guides before performing any installation).", 0)
# DLSS Overlay tooltip
bind_tooltip(self.dlss_overlay_cbox, "Displays the version and preset of DLSS being used,\nas well as the version of DLSSG currently active\n(Check or uncheck the box to enable/disable)", 0)
# INSTALL
def install_gui(self, event=None):
self.install_button = CTkButton(
self.root, text="Install",
fg_color=COLORS["accent"],
text_color="white",
corner_radius=8,
hover_color="#66b2ff",
width=70,
height=25,
command=self.start_install_thread
)
self.install_button.place(x=90, y=227)
# Installation progress
self.progress = CTkProgressBar(
self.root,
width=153,
height=15,
corner_radius=8
)
self.progress.set(0)
# Cleanup progress
self.cleanup_progress = CTkProgressBar(
self.root,
width=153,
height=15,
corner_radius=8
)
self.cleanup_progress.set(0)
self.cleanup_total_steps = 0
self.cleanup_completed_steps = 0
self.cleanup_finished = False
def install(self, event=None):
self.progress_finished = False
fields = {
"Game": self.game_selected.get() if self.game_selected else "",
"Destination Folder": self.dest_folder.strip() if self.dest_folder else "",
"Mod": self.mod_selected.get() if self.mod_selected else ""
}
self.total_steps_progress = 0
self.completed_steps_progress = 0
self.progress.set(0)
# Total Files
selected_upscalers = self.get_selected_upscalers()
self.total_steps_progress = self.files_to_install_progress(self.dest_folder, selected_upscalers)
print(f"Total mods files to install: {self.total_steps_progress}")
try:
installer = ModInstaller(
dest_path=self.dest_folder,
game_selected=self.game_selected.get() if self.game_selected else None,
mod_selected=self.mod_selected.get() if self.mod_selected else None,
progress_callback=self.update_progress_install
)
if self.missing_fields(fields, True):
handler = installer.game_handlers.get(self.game_selected.get())
mod_handler = installer.mods_handlers.get(self.mod_selected.get())
def install_mod():
if handler:
self.run_handler(handler)
if mod_handler:
self.run_handler(mod_handler)
mod_thread = threading.Thread(target=install_mod)
mod_thread.start()
mod_thread.join()
if self.addons_var.get():
def install_addons():
try:
dest_path = self.addons_dest_folder or self.dest_folder
games_to_update_upscalers(
dest_path,
self.game_selected.get(),
copy_dlss=bool(selected_upscalers["DLSS"]),
copy_dlss_45=bool(selected_upscalers["DLSS 4.5"]),
copy_dlss_dlssg=bool(selected_upscalers["DLSSG"]),
copy_dlss_dlssd=bool(selected_upscalers["DLSSD"]),
copy_dlss_xess=bool(selected_upscalers["XESS"]),
copy_dlss_fsr3=bool(selected_upscalers["FSR3"]),
copy_dlss_fsr4=bool(selected_upscalers["FSR4"]),
progress_callback=self.update_progress_install,
absolute_path = True if dest_path == self.addons_dest_folder else False
)
print(dest_path)
except Exception as e:
print(e)
finally:
self.root.after(200, self.finish_progress)
addons_thread = threading.Thread(target=install_addons)
addons_thread.start()
addons_thread.join()
else:
self.root.after(200, self.finish_progress)
except Exception as e:
messagebox.showwarning('Error', f'Installation error {self.addons_selected.get()}')
print(f"Error: {e}")
def files_to_install_progress(self, dest_path, selected_upscalers):
total = 0
# Mods
mod_dirs = []
if dest_path and os.path.exists(dest_path):
mod_dirs.append(dest_path)
# Addons
upscaler_paths = {
"DLSS": r'mods\Temp\Upscalers\Nvidia\Dlss',
"DLSS 4.5": r"mods\Temp\Upscalers\Nvidia\Dlss 4.5",
"DLSSG": r'mods\Temp\Upscalers\Nvidia\Dlssg',
"DLSSD": r'mods\Temp\Upscalers\Nvidia\Dlssd',
"XESS": r'mods\Temp\Upscalers\Intel',
"FSR3": r'mods\Temp\Upscalers\AMD\FSR3',
"FSR4": r'mods\Temp\Upscalers\AMD\FSR4'
}
# Only marked addons
if selected_upscalers.get("DLSS"):
mod_dirs.append(upscaler_paths["DLSS"])
if selected_upscalers.get("DLSS 4.5"):
mod_dirs.append(upscaler_paths["DLSS 4.5"])
if selected_upscalers.get("DLSSG"):
mod_dirs.append(upscaler_paths["DLSSG"])
if selected_upscalers.get("DLSSD"):
mod_dirs.append(upscaler_paths["DLSSD"])
if selected_upscalers.get("XESS"):
mod_dirs.append(upscaler_paths["XESS"])
if selected_upscalers.get("FSR3"):
mod_dirs.append(upscaler_paths["FSR3"])
if selected_upscalers.get("FSR4"):
mod_dirs.append(upscaler_paths["FSR4"])
# Total Files
for path in mod_dirs:
if os.path.isfile(path):
total += 1
elif os.path.isdir(path):
for _, _, files in os.walk(path):
total += len(files)
return total
def start_install_thread(self):
threading.Thread(target=self.install, daemon=True).start()
def finish_progress(self):
if self.progress_finished:
return
self.progress_finished = True
self.progress.place_forget()
self.sucess = CTkLabel(
self.root, text="Successful installation!",
font=(self.font[0], 15, 'bold'),
fg_color="#222223",
text_color="#A8B0C0"
)
self.sucess.place(x=5, y=260)
self.root.after(3000, self.sucess.destroy)
def update_progress_install(self):
if self.progress_finished or not self.total_steps_progress:
return
def safe_update():
if self.progress_finished:
return
self.completed_steps_progress += 1
value = min(self.completed_steps_progress / self.total_steps_progress, 1.0)
self.progress.set(value)
if not self.progress.winfo_ismapped():
self.progress.place(x=5, y=265)
self.root.after(0, safe_update)
def _run_cleanup_thread(self):
try:
if not self.cleanup_progress.winfo_ismapped():
self.cleanup_progress.place(x=0, y=300)
setup_cleanup(
self.dest_folder,
self.game_selected.get() if self.game_selected else None,
self.mod_selected.get() if self.mod_selected else None,
progress_callback=self.update_cleanup_progress
)
self.root.after(200, self._finish_cleanup)
except Exception as e:
print("Cleanup error:", e)
self.root.after(200, lambda: messagebox.showwarning('Error', f'Cleanup error, please try again'))
self.root.after(400, self.cleanup_cbox.deselect)
def update_cleanup_progress(self):
def safe_update():
if self.cleanup_finished or not self.cleanup_total_steps:
return
self.cleanup_completed_steps += 1
value = min(self.cleanup_completed_steps / self.cleanup_total_steps, 1.0)
self.cleanup_progress.set(value)
self.root.after(0, safe_update)
def _finish_cleanup(self):
if self.cleanup_finished:
return
self.cleanup_finished = True
self.cleanup_progress.place_forget()
self.cleanup_success = CTkLabel(
self.root, text="Successful cleanup!",
font=(self.font[0], 15, 'bold'),
fg_color="#222223",
text_color="#A8B0C0"
)
self.cleanup_success.place(x=5, y=300)
self.root.after(3000, self.cleanup_success.destroy)
self.cleanup_cbox.after(400, self.cleanup_cbox.deselect)
# EXIT
def exit(self):
self._Button(self.root, "Exit", 3, 227, sys.exit, width=70, height=25, fg_color=COLORS["accent"], hover_color="#66b2ff")
def run_handler(self,handler):
if inspect.iscoroutinefunction(handler):
asyncio.run(handler())
else:
handler()
def missing_fields(self, fields: dict, message = False):
missing = [name for name, value in fields.items() if not value]
if missing: