Skip to content

Commit

Permalink
v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazon Wilson committed Jul 16, 2020
1 parent 0f3c6c0 commit 0a34613
Show file tree
Hide file tree
Showing 20 changed files with 8,629 additions and 152 deletions.
136 changes: 7 additions & 129 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,130 +1,8 @@
# 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:
node_modules
*.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
.next
app
dist
mods.copy.json
configurations.json
.vscode/
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
# DoW Mod Installer

A python script created to automate the installation of mods for Dawn of War Soulstorm.
DoW Mod Installer is a desktop application designed to automate the process of installing mods mods for Dawn of War Soulstorm.

## Getting Started
## About

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.
I personally use this app to ease the set up process for the 7+ group of friends that I play with. Before using this app, the process of ensuring that all of my friends installed each mod one-by-one and in the exact order specified caused a lot of issues that took an extremly long time to troubleshoot. Because of this, I developed Dow Mod Installer to make the installation process as painless as possible.

## Configuring the script
## Usage

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.
1. Download the latest version of Dow Mod Installer from the [releases page](https://github.com/kwilson21/DoW_Mod_Installer/releases)
2. Extract `DoW Mod Installer-1.0.0-win.zip` into a folder
3. Run `DoW Mod Installer.exe` as administrator
4. Make sure your DoW directory is correct, if not search for the correct directory
5. Download and search for each individual mod file
6. Click 'save' to backup your mod configurations
7. Click install to begin installing all of the mods

Mods will be installed in descending order.

## Advanced

### Editing mods.json

Users are free to modify the `mods.json` with their own mods, which they can then pass on to others. Users must have a `mods.json` file in the same directory as `DoW Mod Installer.exe` in order for the mods to load.

| Key | Type | Description |
| :------------------ | :--------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `file_name` | `string` | The file name for the mod e.g. `example.zip` |
| `download_link` | `string` | A downlink link to the mod |
| `extract_locations` | `list of string` | A list of locations in the DoW Directory to extract to |
| `modifiers` | `list of string` | A list of values to be passed directly to 7zip as a command line argument when extracting the mod see the [7zip command line documentation](https://sevenzip.osdn.jp/chm/cmdline/index.htm) for more info. |

## Authors

Expand Down
4 changes: 4 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
DEFAULT_DOW_DIRECTORY:
"C:/Program Files (x86)/Steam/steamapps/common/Dawn of War Soulstorm",
};
21 changes: 21 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
appId: com.example.nextron
productName: DoW Mod Installer
copyright: Copyright © 2020 Kazon Wilson
directories:
output: dist
buildResources: resources
files:
- from: .
filter:
- package.json
- mods.json
- configurations.json
- mods.copy.json
- app

extraFiles: mods.json

win:
target:
- target: zip
publish: null
46 changes: 46 additions & 0 deletions main/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { app } from "electron";
import serve from "electron-serve";
import { createWindow } from "./helpers";
const unhandled = require("electron-unhandled");
const shell = require("electron").shell;

const isProd = process.env.NODE_ENV === "production";

unhandled();

if (isProd) {
serve({ directory: "app" });
} else {
app.setPath("userData", `${app.getPath("userData")} (development)`);
}

(async () => {
await app.whenReady();

const mainWindow = createWindow("main", {
width: 1000,
height: 600,
webPreferences: {
nodeIntegration: true,
preload: __dirname + "\\preload.js",
enableRemoteModule: true,
},
});

mainWindow.webContents.on("will-navigate", (event, url) => {
event.preventDefault();
shell.openExternal(url);
});

if (isProd) {
await mainWindow.loadURL("app://./home.html");
} else {
const port = process.argv[2];
await mainWindow.loadURL(`http://localhost:${port}/home`);
mainWindow.webContents.openDevTools();
}
})();

app.on("window-all-closed", () => {
app.quit();
});
81 changes: 81 additions & 0 deletions main/helpers/create-window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {
screen,
BrowserWindow,
} from 'electron';
import * as Store from 'electron-store';

export default function createWindow(windowName, options) {
const key = 'window-state';
const name = `window-state-${windowName}`;
const store = new Store({ name });
const defaultSize = {
width: options.width,
height: options.height,
};
let state = {};
let win;

const restore = () => store.get(key, defaultSize);

const getCurrentPosition = () => {
const position = win.getPosition();
const size = win.getSize();
return {
x: position[0],
y: position[1],
width: size[0],
height: size[1],
};
};

const windowWithinBounds = (windowState, bounds) => {
return (
windowState.x >= bounds.x &&
windowState.y >= bounds.y &&
windowState.x + windowState.width <= bounds.x + bounds.width &&
windowState.y + windowState.height <= bounds.y + bounds.height
);
};

const resetToDefaults = () => {
const bounds = screen.getPrimaryDisplay().bounds;
return Object.assign({}, defaultSize, {
x: (bounds.width - defaultSize.width) / 2,
y: (bounds.height - defaultSize.height) / 2
});
};

const ensureVisibleOnSomeDisplay = (windowState) => {
const visible = screen.getAllDisplays().some(display => {
return windowWithinBounds(windowState, display.bounds)
});
if (!visible) {
// Window is partially or fully not visible now.
// Reset it to safe defaults.
return resetToDefaults();
}
return windowState;
};

const saveState = () => {
if (!win.isMinimized() && !win.isMaximized()) {
Object.assign(state, getCurrentPosition());
}
store.set(key, state);
};

state = ensureVisibleOnSomeDisplay(restore());

win = new BrowserWindow({
...options,
...state,
webPreferences: {
nodeIntegration: true,
...options.webPreferences,
},
});

win.on('close', saveState);

return win;
};
5 changes: 5 additions & 0 deletions main/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import createWindow from './create-window';

export {
createWindow,
};
3 changes: 3 additions & 0 deletions main/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { dialog } = require("electron").remote;
window.electron = {};
window.electron.dialog = dialog;
Loading

0 comments on commit 0a34613

Please sign in to comment.