-
Notifications
You must be signed in to change notification settings - Fork 2
/
ymu.py
2406 lines (2039 loc) · 76.6 KB
/
ymu.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
import logging
import logging.handlers
import os
import platform
import sys
import win32gui
from functools import cache
from requests_cache import install_cache
install_cache(
"./ymu/cache",
backend="sqlite",
cache_control=True,
urls_expire_after={"*.github.com": 60},
)
@cache
def executable_path():
return os.path.dirname(os.path.abspath(sys.argv[0]))
@cache
def resource_path(relative_path):
base_path = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
LOCAL_VER = "v1.1.4"
userOS = platform.system()
userOSarch = platform.architecture()
userOSrel = platform.release()
userOSver = platform.version()
workDir = resource_path("")
exeDir = executable_path() + "\\"
if os.path.exists("./ymu"):
pass
else:
os.makedirs("./ymu")
logfile = open("./ymu/ymu.log", "a")
logfile.write("---Initializing YMU...\n\n")
logfile.write(f" ¤ YMU Version: {LOCAL_VER}\n")
logfile.write(
f" ¤ Operating System: {userOS} {userOSrel} x{userOSarch[0][:2]} v{userOSver}\n"
)
logfile.write(f" ¤ Working Directory: {workDir}\n")
logfile.write(f" ¤ Executable Directory: {exeDir}\n\n\n")
logfile.close()
logger = logging.getLogger("YMU")
log_handler = logging.handlers.RotatingFileHandler(
"./ymu/ymu.log", maxBytes=524288, backupCount=1 # 0.5MB max file size
)
logging.basicConfig(
encoding="utf-8",
level=logging.DEBUG,
format="%(asctime)s %(levelname)s %(name)s %(message)s",
datefmt="%H:%M:%S",
handlers=[log_handler],
)
# check if YMU is already running. If it is, bring it to foreground and exit (moving this above the rest of the imports makes it much faster).
ymu_window = win32gui.FindWindow(None, "YMU - YimMenuUpdater")
if ymu_window != 0:
logger.warning(
"\nYMU is aleady running! Only one instance can be launched at once.\n"
)
win32gui.SetForegroundWindow(ymu_window)
sys.exit(0)
if getattr(sys, "frozen", False):
import pyi_splash
# Libraries YMU depends on
import atexit
import customtkinter as ctk
import hashlib
import json
import psutil
import requests
import webbrowser
import winreg
from bs4 import BeautifulSoup
from configparser import ConfigParser
from customtkinter import CTkFont
from pyinjector import inject
from threading import Thread
from PIL import Image
from time import sleep
from win10toast import ToastNotifier
notif = ToastNotifier()
# YMU Appearance
CONFIGPATH = "ymu\\config.ini"
def create_or_read_config():
config = ConfigParser()
if os.path.isfile(CONFIGPATH):
logger.info(f"Found YMU config under {exeDir}{CONFIGPATH}")
config.read(CONFIGPATH)
logger.info("Reading YMU config...")
theme = config["ymu"]["theme"]
ctk.set_appearance_mode(theme)
logger.info("Setting YMU theme...")
else:
logger.info("Config file not found! Creating a new one...")
if os.path.exists("ymu"):
pass
else:
os.makedirs("ymu")
with open(CONFIGPATH, "w") as configfile:
config.add_section("ymu")
config.set("ymu", "theme", "dark")
config.write(configfile)
logger.info(f"Config created under {exeDir}{CONFIGPATH}")
Thread(target=create_or_read_config, daemon=True).start()
# Colors
BG_COLOR = ("#cccccc", "#333333")
BG_COLOR_D = ("#e4e4e4", "#272727") # BG_COLOR_D = "#2b2b2b"
GREEN = ("#16b145", "#45e876")
GREEN_D = ("#7dcb95", "#3c8e55") # GREEN_D = "#36543F"
GREEN_B = "#36543F"
WHITE = ("#272727", "#DCE4EE")
RED = ("#b11625", "#e84555")
RED_D = ("#cb7d85", "#8e3c44")
YELLOW = ("#b19216", "#e8c745")
# BLUE = "#4596e8"
folder_white = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\fo_normal.png")),
light_image=Image.open(resource_path("assets\\img\\fo_normal_l.png")),
size=(24, 24),
)
folder_hvr = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\fo_hover.png")),
light_image=Image.open(resource_path("assets\\img\\fo_hover_l.png")),
size=(24, 24),
)
report_bug_white = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\bug_report_normal.png")),
light_image=Image.open(resource_path("assets\\img\\bug_report_normal_l.png")),
size=(24, 24),
)
report_bug_hvr = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\bug_report_hover.png")),
light_image=Image.open(resource_path("assets\\img\\bug_report_hover_l.png")),
size=(24, 24),
)
request_feature_white = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\request_feature_normal.png")),
light_image=Image.open(resource_path("assets\\img\\request_feature_normal_l.png")),
size=(24, 24),
)
request_feature_hvr = ctk.CTkImage(
dark_image=Image.open(resource_path("assets\\img\\request_feature_hover.png")),
light_image=Image.open(resource_path("assets\\img\\request_feature_hover_l.png")),
size=(24, 24),
)
# YMU root - title - minsize - launch size - launch in center of sreen
root = ctk.CTk()
root.title("YMU - YimMenuUpdater [FSL]")
root.resizable(False, False)
root.iconbitmap(resource_path("assets\\icon\\ymu.ico"))
root.configure(fg_color=BG_COLOR_D)
width_of_window = 400
height_of_window = 440
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_coordinate = (screen_width / 2) - (width_of_window / 2)
y_coordinate = (screen_height / 2) - (height_of_window / 2)
root.geometry(
"%dx%d+%d+%d" % (width_of_window, height_of_window, x_coordinate, y_coordinate)
)
# Fonts
BIG_FONT = CTkFont(family="Manrope", size=16, weight="bold")
SMALL_FONT = CTkFont(family="Manrope", size=12)
SMALL_BOLD_FONT = CTkFont(family="Manrope", size=13, weight="bold")
SMALL_BOLD_FONT_U = CTkFont(family="Manrope", size=13, weight="bold", underline=True)
BOLD_FONT = CTkFont(family="Manrope", size=14, weight="bold")
TOOLTIP_FONT = CTkFont(family="Manrope", size=12, slant="italic")
CODE_FONT = CTkFont(family="JetBrains Mono", size=12)
CODE_FONT_U = CTkFont(family="JetBrains Mono", size=12, underline=True)
CODE_FONT_BIG = CTkFont(family="JetBrains Mono", size=16)
CODE_FONT_SMALL = CTkFont(family="JetBrains Mono", size=10)
# Url, Paths and Launchers
DLLURL = "https://github.com/Mr-X-GTA/YimMenu/releases/download/nightly/YimMenu.dll"
DLLDIR = ".\\ymu\\dll"
LOCALDLL = ".\\ymu\\dll\\YimMenu.dll"
LAUNCHERS = [
"▾ Select Launcher ▾", # placeholder
"Epic Games",
"Rockstar Games",
"Steam",
]
launcherVar = ctk.StringVar()
def set_launcher(launcher: str):
launcherVar.set(launcher)
# self update stuff
# delete the updater on init
if os.path.isfile("./ymu_self_updater.exe"):
logger.info("YMU self updater no longer needed. Deleting the file...")
os.remove("./ymu_self_updater.exe")
# get YMU's remote version:
ymu_update_message = ctk.StringVar()
def get_ymu_ver():
try:
r = requests.get("https://github.com/NiiV3AU/YMU/tags")
soup = BeautifulSoup(r.content, "html.parser")
result = soup.find(class_="Link--primary Link")
s = str(result)
result = s.replace("</a>", "")
charLength = len(result)
latest_version = result[charLength - 6 :]
logger.info(f"Latest YMU version on GitHub: {latest_version}")
return latest_version
except Exception as e:
logger.error(f"Failed to get the latest GitHub version! Traceback: {e}")
update_response.pack(pady=5, padx=0, expand=False, fill=None, anchor="s")
ymu_update_message.set(
"❌ Failed to get the latest GitHub version.\nCheck your Internet connection and try again."
)
update_response.configure(text_color=YELLOW)
sleep(5)
ymu_update_message.set("")
ymu_update_button.configure(state="normal")
def check_for_ymu_update():
ymu_update_button.configure(state="disabled")
YMU_VERSION = get_ymu_ver()
logger.info("Checking for YMU updates...")
try:
if LOCAL_VER < YMU_VERSION:
logger.info("Update available!")
update_response.pack(pady=5, padx=0, expand=False, fill=None, anchor="s")
ymu_update_message.set(f"Update {YMU_VERSION} is available.")
update_response.configure(text_color=GREEN)
ymu_update_button.configure(
state="normal", text="Update YMU", command=start_update_thread
)
sleep(3)
elif LOCAL_VER == YMU_VERSION:
logger.info(f"No updates found! YMU {LOCAL_VER} is the latest version.")
update_response.pack(pady=5, padx=0, expand=False, fill=None, anchor="s")
ymu_update_message.set("YMU is up-to-date ✅")
update_response.configure(text_color=WHITE)
sleep(3)
ymu_update_message.set("")
ymu_update_button.configure(state="normal")
elif LOCAL_VER > YMU_VERSION:
logger.error(
f"Local YMU version is {LOCAL_VER}. This is not a valid version! Are you a dev or a skid?"
)
update_response.pack(pady=5, padx=0, expand=False, fill=None, anchor="s")
ymu_update_message.set(
"⚠️ Invalid version detected ⚠️\nPlease download YMU from\nthe official Github repository."
)
update_response.configure(text_color=RED)
ymu_update_button.configure(
state="normal", text="Open Github", command=open_github_release
)
sleep(5)
except Exception as e:
logger.exception(f"An error occured! Traceback: {e}")
pass
def download_self_updater():
try:
response = requests.get(
"https://github.com/xesdoog/YMU-Updater/releases/download/latest/ymu_self_updater.exe"
)
if response.status_code == 200:
logger.info(
"Downloading self updater from https://github.com/xesdoog/YMU-Updater/releases/download/latest/ymu_self_updater.exe"
)
with open("ymu_self_updater.exe", "wb") as file:
file.write(response.content)
return "OK"
else:
logger.error(
f"an HTTP error occured while trying to access the self updater repository. Status Code: {response.status_code}"
)
return "Error"
except Exception as e:
logger.exception(f"An error occured! Traceback: {e}")
def launch_ymu_update():
global start_self_update
try:
ymu_update_message.set("Downloading self updater, please wait...")
update_response.configure(text_color=WHITE)
ymu_update_button.configure(state="disabled")
if download_self_updater() == "OK":
logger.info("Closing YMU to apply updates...")
ymu_update_message.set("YMU will now close to apply the updates")
sleep(3)
start_self_update = True
root.destroy()
else:
logger.error("Failed to apply updates!")
ymu_update_message.set("❌ Failed to download self updater!")
update_response.configure(text_color=RED)
sleep(5)
ymu_update_message.set("")
update_response.configure(text_color=WHITE)
ymu_update_button.configure(state="normal", text="Update YMU")
except Exception as e:
logger.exception(f"An error occured! Traceback: {e}")
pass
def start_update_thread():
Thread(target=launch_ymu_update, daemon=True).start()
def open_github_release():
webbrowser.open_new_tab("https://github.com/NiiV3AU/YMU/releases/latest")
def ymu_update_thread():
ymu_update_message.set("Please wait...")
Thread(target=check_for_ymu_update, daemon=True).start()
# reads/calculates the SHA256 of local (downloaded) version of YimMenu
def get_local_sha256():
if os.path.exists(LOCALDLL):
logger.info(f"Found local DLL under {exeDir}{LOCALDLL}")
sha256_hash = hashlib.sha256()
with open(LOCALDLL, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
logger.info(f"Local DLL checksum {sha256_hash.hexdigest()}")
return sha256_hash.hexdigest()
else:
logger.warning("Local DLL not found!")
return None
# scrapes the release/build SHA256 of the latest YimMenu release
def get_remote_sha256():
try:
logger.info(
'Checking the latest YimMenu release on "https://github.com/Mr-X-GTA/YimMenu/releases/latest"'
)
r = requests.get("https://github.com/Mr-X-GTA/YimMenu/releases/latest")
soup = BeautifulSoup(r.content, "html.parser")
list = soup.find(class_="notranslate")
l = list("code")
s = str(l)
tag = s.replace("[<code>", "")
sep = " "
head, sep, _ = tag.partition(sep)
REM_SHA = head
REM_SHA_LENG = len(REM_SHA)
if REM_SHA_LENG == 64:
logger.info(f"Latest YimMenu release checksum: {REM_SHA}")
return REM_SHA
except requests.exceptions.ConnectionError as e:
logger.exception(f"An error occured! Traceback: {e}")
progress_prcnt_label.configure(
text=f'Error while trying to\nconnect to "GitHub.com"\nERROR: {e}',
text_color=RED,
)
reset_progress_prcnt_label(5)
# self explanatory
def check_if_dll_is_downloaded():
if os.path.exists(DLLDIR):
if os.path.isfile(LOCALDLL):
LOCAL_SHA = get_local_sha256()
REM_SHA = get_remote_sha256()
if LOCAL_SHA == REM_SHA:
return "Update"
else:
return "Update"
else:
return "Download"
else:
return "Download"
# Find GTAV's process and update the 'inject' tab
def find_gta_process():
global PID # <- I know it's a bad habit but if it works why fix it? 😂 (true 🤙 - "never change a running system")
global is_running
try:
for p in psutil.process_iter(["name", "exe", "cmdline"]):
if (
"GTA5.exe" == p.info["name"]
or p.info["exe"]
and os.path.basename(p.info["exe"]) == "GTA5.exe"
or p.info["cmdline"]
and p.info["cmdline"][0] == "GTA5.exe"
):
pid = p.pid
break
else:
pid = 0
# move this outside of the for loop
if pid is not None and pid != 0:
# logger.info(f'Found GTA 5 process with PID: {pid}')
PID = pid
is_running = True
else:
# logger.warning('Process not found!')
PID = 0
is_running = False
except Exception as e:
logger.exception(
f"An error has occured while trying to find the game's process. Traceback: {e}"
)
def process_search_thread():
Thread(target=find_gta_process, daemon=True).start()
# run it once to initialize 'PID' and 'is_running'
# process_search_thread() <- disabled for now as there is no need for initializing them anymore.
def refresh_download_button():
if get_remote_sha256() == get_local_sha256():
download_button.configure(state="disabled")
progress_prcnt_label.configure(text="YimMenu is up to date.", text_color=WHITE)
progressbar.set(1.0)
else:
download_button.configure(state="normal")
progress_prcnt_label.configure(
text=f"{check_if_dll_is_downloaded()} available!", text_color=GREEN
)
progressbar.set(0)
try:
notif.show_toast(
"YMU",
f"A new YimMenu release is out! Get the latest version from the {check_if_dll_is_downloaded()} tab.",
duration=15,
icon_path=(resource_path("assets\\icon\\ymu.ico")),
)
except TypeError:
pass
# downloads the dll from github and displays progress in a progressbar
def download_dll():
reset_progress_prcnt_label(0)
if not os.path.exists(DLLDIR):
os.makedirs(DLLDIR)
try:
temporary_file_status = check_if_dll_is_downloaded()
progress_prcnt_label.configure(
text="Connecting to YimMenu's GitHub-Repo...", text_color=WHITE
)
with requests.get(DLLURL, stream=True) as r:
r.raise_for_status()
total_size = int(r.headers.get("content-length", 0))
progressbar.set(0)
downloaded_size = 0
logger.info(f"Requesting file from {DLLURL}")
logger.info(f'Total size: {"{:.2f}".format(total_size/1048576)}MB')
with open(LOCALDLL, "wb") as f:
logger.info("Downloading YimMenu Nightly...")
for chunk in r.iter_content(
chunk_size=256000
): # 256 KB chunks (in bytes)
f.write(chunk)
downloaded_size += len(chunk)
progress = downloaded_size / total_size
progressbar.set(progress)
progress_prcnt_label.configure(
text=f"Progress: {int(progress*100)}%"
)
# if download successful
if temporary_file_status == "Update":
progress_prcnt_label.configure(text="Update successful", text_color=GREEN)
elif temporary_file_status == "Download":
progress_prcnt_label.configure(text="Download successful", text_color=GREEN)
logger.info(f"Download finished. DLL location: {exeDir}{DLLDIR}")
sleep(5)
check_if_dll_is_downloaded()
if not os.path.exists(LOCALDLL):
progress_prcnt_label.configure(
text="File was removed!\nMake sure to either turn off your antivirus or add YMU folder to exceptions.",
text_color=RED,
)
logger.error(
"The dll was removed by antivirus. https://youtu.be/g8IwtDOgca0"
)
sleep(5)
Thread(target=refresh_download_button, daemon=True).start()
# if download failed
except requests.exceptions.RequestException as e:
logger.exception(
f"An exception occured while trying to download YimMenu. Traceback: {e}"
)
progress_prcnt_label.configure(
text=f"{check_if_dll_is_downloaded()} error.\nCheck the logs for the exact error message",
text_color=RED,
)
reset_progress_prcnt_label(3)
# starts the download in a thread to keep the gui responsive
def start_download():
download_button.configure(state="disabled")
Thread(target=download_dll, daemon=True).start()
# Injects YimMenu into GTA5.exe process
def inject_yimmenu():
try:
inject_button.configure(state="disabled")
inject_progress_label.configure(
text="🔍 Searching for GTA5 process...",
text_color=WHITE,
)
logger.info("Searching for GTA5 process...")
dummy_progress(injection_progressbar)
process_search_thread()
sleep(1) # give it time to update the values
injection_progressbar.set(0)
if PID != 0:
logger.info(f'Found process "GTA5.exe" with PID: "{PID}"')
if os.path.isfile(LOCALDLL):
inject_progress_label.configure(
text=f"Found process 'GTA5.exe' with PID: [{PID}]",
text_color=GREEN,
)
sleep(2)
inject_progress_label.configure(
text="💉 Injecting...", text_color=GREEN
)
dummy_progress(injection_progressbar)
libHanlde = inject(PID, LOCALDLL)
logger.info(f"Injecting {exeDir}{LOCALDLL} into GTA5.exe...")
logger.debug(f"Injected library handle: {libHanlde}")
sleep(2)
inject_progress_label.configure(
text=f"Successfully injected YimMenu.dll into GTA5.exe",
text_color=GREEN,
)
sleep(3)
injection_progressbar.set(0)
process_search_thread()
logger.debug("Checking if the game is still running after injection...")
sleep(5)
if is_running:
inject_progress_label.configure(
text="Have fun!",
text_color=GREEN,
)
logger.debug(
"Everything seems fine. YMU will automatically exit after 3 seconds to free up resources"
)
sleep(3)
logger.info("\nFarewell!\n")
root.destroy()
else:
logger.warning("The game seems to have crashed after injection!")
inject_progress_label.configure(
text="Uh Oh! Did your game crash?",
text_color=RED,
)
reset_inject_progress_label(10)
else:
logger.error("YimMenu.dll not found! Did the antivirus delete it?")
inject_progress_label.configure(
text="YimMenu.dll not found! Download the latest release\nand make sure your anti-virus is not interfering.",
text_color=RED,
)
reset_inject_progress_label(5)
else:
logger.warning("Process not found! Is the game running?")
inject_progress_label.configure(
text="GTA5.exe not found! Please start the game.", text_color=RED
)
reset_inject_progress_label(5)
inject_button.configure(state="normal")
except Exception as e:
logger.exception(f"An exception has occured! Traceback: {e}")
injection_progressbar.set(0)
inject_progress_label.configure(
text="Failed to inject YimMenu!",
text_color=RED,
)
reset_inject_progress_label(5)
inject_button.configure(state="normal")
def start_injection():
Thread(target=inject_yimmenu, daemon=True).start()
def dummy_progress(widget):
for i in range(0, 11):
i += 0.01
widget.set(i / 10)
sleep(0.05)
def reset_inject_progress_label(n):
sleep(n)
inject_progress_label.configure(text="Progress: N/A", text_color=WHITE)
injection_progressbar.set(0)
# opens github repo
def open_github(e):
webbrowser.open_new_tab("https://github.com/NiiV3AU/YMU")
def open_discord(e):
webbrowser.open_new_tab("https://discord.gg/S4PKmKr22k ")
# attention label
def al_hover(e):
attention_label.configure(text_color=RED)
def al_normal(e):
attention_label.configure(text_color=RED_D)
attention_label = ctk.CTkLabel(
master=root,
font=CODE_FONT_SMALL,
text_color=RED_D,
text="ATTENTION:\nOnly use YMU & YimMenu with BattlEye DISABLED!",
bg_color="transparent",
fg_color=BG_COLOR_D,
justify="center",
)
attention_label.pack(pady=5, fill=None, expand=False, anchor="n", side="top")
def attention_ani():
try:
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.1)
attention_label.configure(text_color=YELLOW)
sleep(0.1)
attention_label.configure(text_color=RED)
sleep(0.25)
attention_label.configure(text_color=RED_D)
sleep(0.25)
attention_label.configure(text_color=RED)
sleep(0.25)
attention_label.configure(text_color=RED_D)
sleep(0.25)
attention_label.configure(text_color=RED)
sleep(0.25)
attention_label.configure(text_color=RED_D)
sleep(0.25)
attention_label.configure(text_color=RED)
sleep(0.25)
attention_label.configure(text_color=RED_D)
attention_label.bind("<Enter>", al_hover)
attention_label.bind("<Leave>", al_normal)
except Exception:
pass
def hover_copyright(e):
copyright_label.configure(cursor="hand2")
def normal_copyright(e):
copyright_label.configure(cursor="arrow")
# label for github repo - author (NV3) - version
copyright_label = ctk.CTkLabel(
master=root,
font=CODE_FONT_SMALL,
text_color=BG_COLOR_D,
text="↣ Click here for GitHub Repo ↢\n⋉ © NV3 ⋊\n{" + f"{LOCAL_VER}-fsl" + "}",
bg_color="transparent",
fg_color=BG_COLOR_D,
justify="center",
)
copyright_label.pack(pady=5, fill=None, expand=False, anchor="n", side="top")
copyright_label.bind("<ButtonRelease-1>", open_github)
copyright_label.bind("<Enter>", hover_copyright)
copyright_label.bind("<Leave>", normal_copyright)
# basic ahh animation for copyright_label
def copyright_label_ani_master():
try:
while True:
if appearance_mode_optionemenu.get() == "Dark":
copyright_label.configure(text_color="#4D4D4D")
sleep(0.1)
copyright_label.configure(text_color="#666666")
sleep(0.1)
copyright_label.configure(text_color="#808080")
sleep(0.1)
copyright_label.configure(text_color="#999999")
sleep(0.1)
copyright_label.configure(text_color="#B3B3B3")
sleep(0.1)
copyright_label.configure(text_color="#CCCCCC")
sleep(0.2)
copyright_label.configure(text_color="#E6E6E6")
sleep(0.3)
copyright_label.configure(text_color="#FFFFFF")
sleep(0.4)
copyright_label.configure(text_color="#E6E6E6")
sleep(0.3)
copyright_label.configure(text_color="#CCCCCC")
sleep(0.2)
copyright_label.configure(text_color="#B3B3B3")
sleep(0.1)
copyright_label.configure(text_color="#999999")
sleep(0.1)
copyright_label.configure(text_color="#808080")
sleep(0.1)
copyright_label.configure(text_color="#666666")
sleep(0.1)
elif appearance_mode_optionemenu.get() == "Light":
# copyright_label.configure(text_color="#4D4D4D")
# sleep(0.1)
# copyright_label.configure(text_color="#ffffff")
# sleep(0.1)
# copyright_label.configure(text_color="#dbdbdb")
sleep(0.1)
copyright_label.configure(text_color="#b7b7b7")
sleep(0.1)
copyright_label.configure(text_color="#939393")
sleep(0.2)
copyright_label.configure(text_color="#6f6f6f")
sleep(0.2)
copyright_label.configure(text_color="#4b4b4b")
sleep(0.3)
copyright_label.configure(text_color="#272727")
sleep(0.4)
copyright_label.configure(text_color="#4b4b4b")
sleep(0.3)
copyright_label.configure(text_color="#6f6f6f")
sleep(0.2)
copyright_label.configure(text_color="#939393")
sleep(0.2)
copyright_label.configure(text_color="#b7b7b7")
sleep(0.1)
copyright_label.configure(text_color="#dbdbdb")
except Exception:
pass
# starts all animations - currently only copyright
def master_ani_start():
Thread(target=copyright_label_ani_master, daemon=True).start()
Thread(target=attention_ani, daemon=True).start()
root.after(1000, master_ani_start)
# Download and SHA256 tabs
tabview = ctk.CTkTabview(
master=root,
fg_color=BG_COLOR,
bg_color="transparent",
corner_radius=12,
segmented_button_fg_color=BG_COLOR,
segmented_button_selected_color=BG_COLOR_D,
segmented_button_selected_hover_color=BG_COLOR,
segmented_button_unselected_color=BG_COLOR,
segmented_button_unselected_hover_color=BG_COLOR_D,
text_color=GREEN,
border_color=GREEN_D,
border_width=2,
)
tabview.pack(pady=10, padx=10, expand=True, fill="both")
def refresh_download_tab():
if check_if_dll_is_downloaded() == "Download":
tabview.add("Download")
else:
tabview.add("Update")
refresh_download_tab()
tabview.add("Inject")
tabview.add("Settings Ξ")
# reset progress label
def reset_progress_prcnt_label(n):
sleep(n)
progress_prcnt_label.configure(text="Progress: N/A", text_color=WHITE)
progressbar.set(0)
progressbar = ctk.CTkProgressBar(
master=tabview.tab(check_if_dll_is_downloaded()),
orientation="horizontal",
height=8,
corner_radius=14,
fg_color=BG_COLOR_D,
progress_color=GREEN,
width=140,
)
progressbar.pack(pady=5, padx=5, expand=False, fill="x", side="bottom", anchor="s")
progressbar.set(0)
progress_prcnt_label = ctk.CTkLabel(
master=tabview.tab(check_if_dll_is_downloaded()),
text="",
font=CODE_FONT_SMALL,
height=10,
text_color=WHITE,
)
progress_prcnt_label.pack(
pady=5, padx=5, expand=False, fill=None, anchor="s", side="bottom"
)
def hover_download_button(e):
download_button.configure(text_color=GREEN, fg_color=GREEN_B)
tabview.configure(border_color=GREEN)
def nohover_download_button(e):
download_button.configure(text_color=BG_COLOR_D, fg_color=GREEN)
tabview.configure(border_color=GREEN_D)
# more info for Download
def open_download_info(e):
download_info = ctk.CTkToplevel(fg_color=BG_COLOR_D)
download_info.title(f"DLL & FSL info")
download_info.minsize(365, 220)
download_info.resizable(False, False)
width_of_window = 365
height_of_window = 220
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_coordinate = (screen_width / 2) - (width_of_window / 2)
y_coordinate = (screen_height / 2) - (height_of_window / 2)
download_info.geometry(
"%dx%d+%d+%d" % (width_of_window, height_of_window, x_coordinate, y_coordinate)
)
def di_frame_hover(e):
d_i_tabview.configure(border_color=GREEN)
def di_frame_normal(e):
d_i_tabview.configure(border_color=GREEN_D)
d_i_tabview = ctk.CTkTabview(
master=download_info,
fg_color=BG_COLOR,
corner_radius=12,
segmented_button_fg_color=BG_COLOR,
segmented_button_selected_color=BG_COLOR_D,
segmented_button_selected_hover_color=BG_COLOR,
segmented_button_unselected_color=BG_COLOR,
segmented_button_unselected_hover_color=BG_COLOR_D,
text_color=GREEN,
border_color=GREEN_D,
border_width=2,
)
d_i_tabview.pack(pady=10, padx=10, expand=True, fill="both")
d_i_tabview.add("⭐ DLL")
d_i_tabview.add("FSL ⭐")
dll_info_label = ctk.CTkLabel(
master=d_i_tabview.tab("⭐ DLL"),
text=f'How-To:\n↦ Click on ({check_if_dll_is_downloaded()})\n↪ Wait for the download to finish\n↪ file in "YMU/dll"-folder\n\nIf the file gets deleted,\nadd an exception in\nyour antivirus or\ndisable it.',
font=CODE_FONT,
justify="center",
text_color=GREEN,
)
dll_info_label.pack(pady=0, padx=0, expand=True, fill="both")
fsl_info_label = ctk.CTkLabel(
master=d_i_tabview.tab("FSL ⭐"),
text='How-To:\n↦ Download FSL (Link provided below)\n↦ Open GTAV Directory\n↦ Drop the version.dll in the folder\n(filename MUST be exactly "version.dll")\n↦ Disable BattlEye in Rockstars Game Launcher \n↪ Done! ✅',
font=CODE_FONT,
justify="center",
text_color=GREEN,
)
fsl_info_label.pack(pady=0, padx=0, expand=True, fill="both")
download_info.bind("<Enter>", di_frame_hover)
download_info.bind("<Leave>", di_frame_normal)
download_info.attributes("-topmost", "true")
def hover_download_mi(e):
download_more_info_label.configure(
text="Click here for more info",
cursor="hand2",
text_color=GREEN,
font=CODE_FONT_U,
)
tabview.configure(border_color=GREEN)
def normal_download_mi(e):
download_more_info_label.configure(
text="↣ Click here for more info ↢",
cursor="arrow",
text_color=WHITE,
font=CODE_FONT,
)
tabview.configure(border_color=GREEN_D)
download_more_info_label = ctk.CTkLabel(
master=tabview.tab(check_if_dll_is_downloaded()),
text="↣ Click here for more info ↢",
justify="center",
font=CODE_FONT,
)
download_more_info_label.pack(pady=10, padx=10, expand=False, fill=None)
download_more_info_label.bind("<ButtonRelease-1>", open_download_info)
download_more_info_label.bind("<Enter>", hover_download_mi)
download_more_info_label.bind("<Leave>", normal_download_mi)
def open_source_ib(e):
webbrowser.open_new_tab("https://github.com/Mr-X-GTA/YimMenu/releases/latest")
def oib_hover(e):
open_in_browser_button.configure(
text="Open YimMenu's GitHub-Repo [Browser] ↗",
font=CODE_FONT_U,
text_color=GREEN,