-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdfa2ce
commit 2f0656e
Showing
2 changed files
with
30 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ bin | |
obj | ||
.vs | ||
PostBuild.bat | ||
releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os, json, zipfile | ||
import os, zipfile, shutil | ||
|
||
mods = [ | ||
"BetterLevelEditor", | ||
"Convinience", | ||
"D1CooperGun", | ||
"DevKillsList", | ||
"ExtendedCheats", | ||
"KingsmanEasterEgg", | ||
"ShowdownModePauseOnDesperadoDiff", | ||
] | ||
|
||
|
||
GAME_DIR = "/mnt/g/Steam/steamapps/common/Desperados III/Mods/" | ||
RELEASES_DIR = "releases" | ||
|
||
SCRIPT_DIR = os.path.dirname(__file__) | ||
RELEASES_DIR = os.path.join(SCRIPT_DIR, RELEASES_DIR) | ||
REPO_FILE = os.path.join(SCRIPT_DIR, "Repository.json") | ||
|
||
|
||
if not os.path.isfile(REPO_FILE): | ||
print("No 'Repository.json' file found") | ||
exit(-1) | ||
elif not os.path.isdir(GAME_DIR): | ||
print(f"No game direcotry found at '{GAME_DIR}'") | ||
exit(-1) | ||
|
||
|
||
with open(REPO_FILE) as f: | ||
repo = json.load(f) | ||
|
||
|
||
os.makedirs("releases", exist_ok=True) | ||
|
||
|
||
for mod in repo["Releases"]: | ||
name = mod["Id"] | ||
mod_dir = os.path.join(GAME_DIR, name) | ||
|
||
if not os.path.isdir(mod_dir): | ||
print(f"No mod directory found for '{name}' at '{mod_dir}'. Skipping.") | ||
continue | ||
|
||
dll = os.path.join(mod_dir, name + ".dll") | ||
info = os.path.join(SCRIPT_DIR, name, "Info.json") | ||
|
||
if not os.path.isfile(dll): | ||
print(f"No DLL found for '{name}' at '{dll}'. Skipping.") | ||
continue | ||
|
||
if not os.path.isfile(info): | ||
print(f"No 'Info.json' found for '{name}' at '{info}'. Skipping.") | ||
continue | ||
|
||
with zipfile.ZipFile( | ||
os.path.join(RELEASES_DIR, name + ".zip"), "w", zipfile.ZIP_DEFLATED | ||
) as zipf: | ||
zipf.write(dll, name + ".dll") | ||
zipf.write(info, "Info.json") | ||
for mod in mods: | ||
dll = os.path.join(mod, "bin", "Release" , mod + ".dll") | ||
if mod == "BetterLevelEditor": | ||
files = [] | ||
files.append((dll, mod + ".dll")) | ||
files.append((os.path.join(mod, "spawn_codes.txt"), "spawn_codes.txt")) | ||
|
||
for f, _ in files: | ||
if not os.path.isfile(f): | ||
print(f"{mod}: {f} not found. Skipping") | ||
break | ||
else: | ||
outfile = os.path.join(RELEASES_DIR, mod + ".zip") | ||
with zipfile.ZipFile(outfile, "w", zipfile.ZIP_DEFLATED) as zipf: | ||
for f, n in files: | ||
zipf.write(f, n) | ||
else: | ||
shutil.copy(dll, RELEASES_DIR) |