diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..749e29e --- /dev/null +++ b/.gitignore @@ -0,0 +1,130 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ +.vscode/settings.json +*.7z +*.exe +*.rar +DoW-Mod-Installer/ +test.py +*.zip diff --git a/DoW_Mod_Installer.py b/DoW_Mod_Installer.py new file mode 100644 index 0000000..0aeecd4 --- /dev/null +++ b/DoW_Mod_Installer.py @@ -0,0 +1,119 @@ +import json +import os +import wget +import sys +from string import ascii_uppercase + +FILEPATH = os.path.dirname(os.path.realpath(__file__)) + + +def find(name, path): + for root, _, files in os.walk(path): + if name in files: + return os.path.join(root, name) + return '' + + +try: + mod_info = json.load(open('mods.json')) +except FileNotFoundError: + input("mods.json file missing, please replace the file in your directory!") + sys.exit(1) + +DoW_Directory_found = False + +print("Searching for DoW directory...") + +for c in ascii_uppercase: + DoW_Directory = find("Soulstorm.exe", f"{c}:\\")[:-14] + DoW_Directory_found = os.path.exists(DoW_Directory) + if DoW_Directory_found: + break + +if not DoW_Directory_found: + print("Unable to find DoW directory") + +while not DoW_Directory_found: + DoW_Directory = input( + "Please enter your Dawn of War Soulstorm folder path. i.e. 'C:/Program Files (x86)/Steam/steamapps/common/Dawn of War Soulstorm': ") + + if DoW_Directory == "": + DoW_Directory = "C:/Program Files (x86)/Steam/steamapps/common/Dawn of War Soulstorm" + + DoW_Directory_found = os.path.exists(DoW_Directory) + + if not DoW_Directory_found: + print("Directory specified does not exist") + +loc_7z_found = False + +print("Searching for 7z directory...") + +for c in ascii_uppercase: + loc_7z = find("7z.exe", f"{c}:\\") + loc_7z_found = os.path.exists(loc_7z) + if loc_7z_found: + break + +if not loc_7z_found: + print("Unable to find DoW directory") + +while not loc_7z_found: + loc_7z = input( + "Please enter your 7zip installation directory. i.e. 'C:/Program Files/7-Zip/7z.exe': ") + + if loc_7z == "": + loc_7z = "C:/Program Files/7-Zip/7z.exe" + + loc_7z_found = os.path.exists(loc_7z) + + if not loc_7z_found: + print("Directory specified does not exist") + +if "Program Files" in loc_7z: + loc_7z = str.replace(loc_7z, 'Program Files', '"Program Files"') +elif "Program Files (x86)" in loc_7z: + loc_7z.replace("Program Files (x86)", '"Program Files (x86)"') + + +def download_mods(): + for mod in mod_info: + if not os.path.exists(f'{FILEPATH}/{mod["file_name"]}'): + print(f"Downloading the following mod: {mod['file_name']}") + wget.download(mod['download_link']) + + +def extract_mods(): + for mod in mod_info: + print(f"Installing {mod['file_name']}...") + if ".exe" in mod['file_name']: + pass + elif mod['file_name'] == "UA_THB_v1.88.71_FULL.zip": + os.system( + f'{loc_7z} x UA_THB_v1.88.71_FULL.zip -aos') + + os.system( + f'{loc_7z} x UA_THB_v1.88.71_FULL.7z -aoa -o"{DoW_Directory}"') + + elif mod['file_name'] == "Red_I_Map_Compilation_Revision_III.rar" or mod['file_name'] == "Red_III_Map_Compilation_Revision_II.rar": + for loc in mod["extract_locations"]: + os.system( + f'{loc_7z} x "{mod["file_name"]}" -aoa -o"{DoW_Directory}/{loc}" Data') + elif "extract_locations" in mod: + for loc in mod["extract_locations"]: + os.system( + f'{loc_7z} x "{mod["file_name"]}" -aoa -o"{DoW_Directory}/{loc}"') + else: + os.system( + f'{loc_7z} x "{mod["file_name"]}" -aoa -o"{DoW_Directory}"') + # if mod['file_name'] == "1.22.7z": + # os.system( + # f'{loc_7z} x UA_THB_v1.88.71_FULL.7z -aos -o"{DoW_Directory}/UltimateApocalypse_Salcol" "UltimateApocalypse_THB/data" -r') + + print("Mods extracted. Make sure to install the Tyranids mod and do the 4GB patch before playing.") + + +if __name__ == "__main__": + download_mods() + extract_mods() + input("") diff --git a/README.md b/README.md new file mode 100644 index 0000000..76cf37b --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# DoW Mod Installer + +A python script created to automate the installation of mods for Dawn of War Soulstorm. + +## Getting Started + +This script is designed for the laziest/least computer savy, all the script requires you to have is Dawn of War Soulstorm and 7zip installed. Installing Python is optional as the release version of this script is compiled into an .exe using pyinstaller. When running the script, it will search for your soulstorm and 7zip directories, if it cannot find the directories, you will have the option to manually input the directories. Upon completion of all the extractions, you must manually install the tyranids mod and apply the 4gb patch to your soulstorm.exe and graphicsconfig.exe. + +## Configuring the script + +To add/remove mods to the script, simply edit the mods.json file. I suggest logging into gofile.com and re-uploading your mods there as the auto download function will only work with direct download links. The mods.json file supplies the following keys: filename, download_link and extraction_locations. Fill in the fields as needed and you should be good to go, if your script requires more complex extractions, you will need to modify the extract_mods function in the script. + +## Authors + +- **Kazon Wilson** diff --git a/mods.json b/mods.json new file mode 100644 index 0000000..636a619 --- /dev/null +++ b/mods.json @@ -0,0 +1,67 @@ +[ + { + "file_name": "UA_THB_v1.88.71_FULL.zip", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/UA_THB_v1.88.71_FULL.zip" + }, + { + "file_name": "UA_THB_1.88.71_minipatch.7z", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/UA_THB_1.88.71_minipatch.7z" + }, + { + "file_name": "UA Patch - Version 1.88.72.zip", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/UA Patch - Version 1.88.72.zip" + }, + { + "file_name": "Tyranid_Mod_0.5b2_Installer.exe", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Tyranid_Mod_0.5b2_Installer.exe" + }, + { + "file_name": "DoW_Mod_Manager_v1.4.7z", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/DoW_Mod_Manager_v1.4.7z" + }, + { + "file_name": "4gb_patch.exe", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/4gb_patch.exe" + }, + { + "file_name": "Salcols 1.21.7z", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Salcols%201.21.7z" + }, + { + "file_name": "1.22.7z", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/1.22.7z" + }, + { + "file_name": "Red_I_Map_Compilation_Revision_III.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Red_I_Map_Compilation_Revision_III.rar", + "extract_locations": ["DXP2"] + }, + { + "file_name": "Red_II_Map_Compilation.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Red_II_Map_Compilation.rar", + "extract_locations": [ + "UltimateApocalypse_THB/data/scenarios/mp", + "DXP2/data/scenarios/mp" + ] + }, + { + "file_name": "Red_III_Map_Compilation_Revision_II.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Red_III_Map_Compilation_Revision_II.rar", + "extract_locations": ["DXP2"] + }, + { + "file_name": "Niels_Dutka_Map_Compilation.1.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Niels_Dutka_Map_Compilation.1.rar", + "extract_locations": ["DXP2/data/scenarios/mp"] + }, + { + "file_name": "Art_Repository.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/Art_Repository.rar", + "extract_locations": ["DXP2/data"] + }, + { + "file_name": "dawn_of_war_maps.rar", + "download_link": "https://srv-file6.gofile.io/download/kEKVA8/dawn_of_war_maps.rar", + "extract_locations": ["DXP2/data"] + } +]