|
16 | 16 | import webbrowser |
17 | 17 | from datetime import datetime |
18 | 18 | from modules.MapExporter import exportMap |
| 19 | +import winreg |
| 20 | +from pathlib import Path |
| 21 | +from modules.vdfutils import parse_vdf |
19 | 22 |
|
20 | 23 | # global settings |
21 | 24 | settings = json.loads(open("res/settings.json").read()) |
22 | 25 | gameDef = json.loads(open("res/gameDef.json").read()) |
23 | 26 | gameDefCustom = json.loads(open("res/gameDef.json").read()) |
24 | 27 | version = open("res/version.txt").read().split("\n")[0] |
| 28 | +steamAppsDirs = [] |
25 | 29 |
|
26 | 30 | class App: |
27 | 31 | def __init__(self, root: tk.Tk): |
@@ -68,7 +72,7 @@ def __init__(self, root: tk.Tk): |
68 | 72 | helpMenu = tk.Menu(menuBar, tearoff=0) |
69 | 73 | helpMenu.add_command(label="Corvid on Github", command=lambda: webbrowser.open("https://github.com/KILLTUBE/corvid")) |
70 | 74 | helpMenu.add_command(label="Corvid wiki", command=lambda: webbrowser.open("https://github.com/KILLTUBE/corvid/wiki")) |
71 | | - helpMenu.add_command(label="Video tutorial", command=lambda: alert.showwarning(title="Warning", message="Video tutorial is not ready yet.")) |
| 75 | + helpMenu.add_command(label="Video tutorial", command=lambda: webbrowser.open("https://www.youtube.com/watch?v=izALMNZjgkA")) |
72 | 76 | #helpMenu.add_command(label="Check for new versions", command=lambda: print("Checking for new versions...")) |
73 | 77 | helpMenu.add_separator() |
74 | 78 | helpMenu.add_command(label="Support me on Patreon", command=lambda: webbrowser.open("https://www.patreon.com/johndoe_")) |
@@ -291,8 +295,12 @@ def __init__(self, root: tk.Tk): |
291 | 295 | for gameDir in settings["gameDirs"]: |
292 | 296 | self.gameDirList.insert(0, gameDir) |
293 | 297 |
|
294 | | - def setSteamDir(self): |
295 | | - dir = filedialog.askdirectory(title="Set your Steam directory") |
| 298 | + def setSteamDir(self, _dir=""): |
| 299 | + if _dir == "": |
| 300 | + dir = filedialog.askdirectory(title="Set your Steam directory") |
| 301 | + else: |
| 302 | + dir = _dir |
| 303 | + |
296 | 304 | if dir is not None: |
297 | 305 | settings["steamDir"] = dir |
298 | 306 | open("res/settings.json", "w").write(json.dumps(settings, indent=4)) |
@@ -361,10 +369,18 @@ def convertButton_command(self): |
361 | 369 |
|
362 | 370 | # add the vpk files and the directories of the current game in the list |
363 | 371 | for vpk in gameDef[self.currentGame.get()]["vpkFiles"]: |
364 | | - vpkFiles.append(settings["steamDir"] + "/steamapps/common/" + gameDef[self.currentGame.get()]["gameRoot"] + "/" + vpk) |
| 372 | + for appDir in steamAppsDirs: |
| 373 | + vpkPath = appDir + "/steamapps/common/" + gameDef[self.currentGame.get()]["gameRoot"] + "/" + vpk |
| 374 | + if os.path.isfile(vpkPath): |
| 375 | + vpkFiles.append(vpkPath) |
| 376 | + break |
365 | 377 |
|
366 | 378 | for dir in gameDef[self.currentGame.get()]["gameDirs"]: |
367 | | - gameDirs.append(settings["steamDir"] + "/steamapps/common/" + gameDef[self.currentGame.get()]["gameRoot"] + "/" + dir) |
| 379 | + for appDir in steamAppsDirs: |
| 380 | + dirPath = appDir + "/steamapps/common/" + gameDef[self.currentGame.get()]["gameRoot"] + "/" + dir |
| 381 | + if os.path.isdir(dirPath): |
| 382 | + gameDirs.append(dirPath) |
| 383 | + break |
368 | 384 |
|
369 | 385 | vmfPath = self.vmfPath.get() |
370 | 386 | # check if the selected file is a valid VMF file |
@@ -482,12 +498,30 @@ def write(self, str): |
482 | 498 | root = tk.Tk() |
483 | 499 | app = App(root) |
484 | 500 |
|
| 501 | + if settings["steamDir"] == "": |
| 502 | + try: |
| 503 | + hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\WOW6432Node\Valve\Steam") |
| 504 | + steamDir = winreg.QueryValueEx(hkey, "InstallPath")[0] |
| 505 | + steamDir = Path(steamDir).as_posix() |
| 506 | + app.setSteamDir(steamDir) |
| 507 | + except: |
| 508 | + pass |
| 509 | + |
485 | 510 | while settings["steamDir"] == "": |
486 | 511 | alert.showwarning( |
487 | 512 | "Warning", |
488 | 513 | message="It appears that this is your first time using Corvid.\n\n" |
489 | 514 | + "Please set your Steam directory in the next dialogue." |
490 | 515 | ) |
491 | 516 | app.setSteamDir() |
| 517 | + |
| 518 | + steamAppsDirs.append(settings["steamDir"]) |
| 519 | + |
| 520 | + try: |
| 521 | + libraryFolders = parse_vdf(open(f'{settings["steamDir"]}/steamapps/libraryfolders.vdf').read())["LibraryFolders"] |
| 522 | + for i in range(1, len(libraryFolders) - 1): |
| 523 | + steamAppsDirs.append(Path(libraryFolders[str(i)]).as_posix()); |
| 524 | + except: |
| 525 | + pass |
492 | 526 |
|
493 | 527 | root.mainloop() |
0 commit comments