-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlego_dlc.py
98 lines (87 loc) · 4.97 KB
/
lego_dlc.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
import dearpygui.dearpygui as gui
import os
def on_unlock(sender, app_data):
added_number = 0
gui.set_value("error_message", "")
gui.set_value("end_message", "")
path = gui.get_value("game_path")
collection_file = os.path.join(path, "CHARS", "COLLECTION.txt")
if path != "D:\SteamLibrary\steamapps\common\LEGO Batman2":
if os.path.isdir(os.path.join(path, "__DLC1__")):
if not "// Characters added by Lego DLC Character Unlocker" in open(collection_file).read():
for root, dirs, files in os.walk(path):
for directory in dirs:
if directory.startswith("__DLC"):
chars_dir = os.path.join(root, directory, "Chars")
if os.path.exists(chars_dir):
for file in os.listdir(chars_dir):
if file.startswith("DLCCOLLECTION"):
file_path = os.path.join(chars_dir, file)
with open(file_path, "r") as f:
lines = f.readlines()
with open(collection_file, "a") as collection:
if not "// Characters added by Lego DLC Character Unlocker" in open(collection_file).read():
collection.write("\n// Characters added by Lego DLC Character Unlocker\n")
for line in lines:
if line.startswith("collect"):
line = line.replace("dlc_only", "")
collection.write("\n"+line)
added_number = added_number + 1
gui.set_value("end_message", f"{added_number} Characters has been added !")
else:
gui.set_value("error_message", "Error: DLC Characters are already unlocked")
else:
gui.set_value("error_message", "Error: Invalid game path or the game\nis not extracted with Quickbms\n(or the game has no DLC)")
else:
gui.set_value("error_message", "Error: Please enter the correct game path")
def on_reset(sender, app_data):
gui.set_value("error_message", "")
gui.set_value("end_message", "")
path = gui.get_value("game_path")
collection_file = os.path.join(path, "CHARS", "COLLECTION.txt")
if path != "D:\SteamLibrary\steamapps\common\LEGO Batman2":
if os.path.isdir(os.path.join(path, "__DLC1__")):
with open(collection_file, "r") as file:
lines = file.readlines()
with open(collection_file, "w") as file:
found_marker = False
for line in lines:
if not found_marker and line.strip() == "// Characters added by Lego DLC Character Unlocker":
found_marker = True
elif found_marker:
continue
else:
file.write(line)
if found_marker:
gui.set_value("end_message", "Unlocked DLC characters have been removed!")
else:
gui.set_value("error_message", "Error: Nothing to reset")
else:
gui.set_value("error_message", "Error: Invalid game path")
else:
gui.set_value("error_message", "Error: Please enter the correct game path")
gui.create_context()
gui.create_viewport(title='Lego DLC Character Unlocker', decorated=True, width=380, height=280)
gui.set_viewport_resizable(False)
gui.setup_dearpygui()
gui.set_viewport_always_top(True)
with gui.window(label='Nexus', width=380, height=280, no_title_bar=True, no_resize=True, no_move=True):
with gui.tab_bar(label='Tabs'):
with gui.tab(label='Game Selection'):
gui.add_text("Enter the game directory :")
gui.add_input_text(tag="game_path", width=350, default_value="D:\SteamLibrary\steamapps\common\LEGO Batman2")
gui.add_text("")
gui.add_button(label="Unlock DLC Characters", callback=on_unlock)
gui.add_button(label="Reset DLC Characters", callback=on_reset)
error_message = gui.add_text("", tag="error_message", color=(255, 0, 0))
end_message = gui.add_text("", tag="end_message", color=(0, 255, 0))
with gui.tab(label="About"):
gui.add_text("Version : 1.0.3")
#
gui.add_text("GitHub Page : github.com/Calvineries\n/Lego-DLC-Character-Unlocker")
gui.add_text("")
gui.add_text("Author : Calvineries")
gui.add_text("Contributors: ...")
gui.show_viewport()
gui.start_dearpygui()
gui.destroy_context()