07th-mod / python-patcher

Mod Installer for the Higurashi and Umineko Games
150 stars 12 forks source link

Python Patcher

If you just want to install the mod, click here for the installer download page.

This repository contains the mod installer, used for installing all 07th-mod mods. The installer is cross-platform and written in python.

The below information is for developers only.

Common Installer tasks HOWTO

Updating landing page and mod page "update" banners

The HTML for the landing page and update banners for each mod is dynamically fetched from this github repo https://github.com/07th-mod/python-patcher-updates.

To update the html:

Currently only the landing page and Hou+ implement this updateable html function.

More detail is available in the Readme.md page on that repo.

Python Development Environment Setup

If you have no preference for IDE, I would recommend Pycharm as it will help reduce mistakes while you're writing your code. Please conform to the follwing guidelines:

Please note that pycharm will attempt to index files in the project folder - this may cause problems when you run the installer from pycharm, as the installer may try to move a file Pycharm is currently reading, causing it to fail (I have only seen this happen once).

Known issues with python dev environment

If the installer is stopped using the "Quit Installer" button while a download is in progress, aria2c will keep downloading in the background (at least on Windows). Normally when running the installer on Windows, the launcher will terminate the aria2c process using a Windows Job Object, but when running through an IDE this won't happen.

Force closing the script via the IDE does seem to kill the aria2c process, however.

JSON Mod Definition

The patcher reads the file installData.json to figure out what mods are available. The spec for this file is defined as a Codable Swift struct in JSONValidator.swift

The validator will run automatically on every push, to check the installData.json is correctly formatted. Because the validator is quite strict, the validator will need to be updated if the installData.json format is changed.

Developer Mode

The installer has a global variable called DEVELOPER_MODE, which controls how it behaves. Developer mode will be activated if an installData.json is found on disk adjacent to the install script. This will be the case if you clone the git repository, then run the script.

In developer mode, the installer will prefer local files (on disk) if they are present, instead of remote files (from github). This mode will Specifically:

Cached Download Sizes

The Github repository contains a file called cachedDownloadSizes.json to allow the installer to calculate the size of a mod without having to query each download link. When the installer runs in normal mode, it downloads this file from Github each time the installer is run.

When the installer is run in developer mode, it checks that all URLs in installData.json are present in cachedDownloadSizes.json - if not the cachedDownloadSizes.json file is automatically regenerated. Please commit this cachedDownloadSizes.json to the git repository each time it changes.

HTTPGUI / Web Interface

The web interface component is located in the httpGUI folder.

It is setup as a npm package with eslint, such that you can install the eslint plugin in Visual Studio Code and have code style checks/syntax checks etc. applied.

To setup the development environment:

To use the plugin:

Safe Mode / Interactive Text Mode

The installer contains an interactive text mode installer, which can be used by the end user if the graphical installer fails (this is different from the "command line interface").

Command line interface

The installer also ships with an alternative command line interface for advanced users. For instructions, please refer to this section of the wiki.

Github Actions Setup

It is HIGHLY recommended to use a linter when editing Github Actions .yml files - pycharm provides this functionality.

Please read the comments in the .github/workflows/test_and_deploy.yml file for more information.

Compiling the Windows Loader

The windows loader is not well documented. Please contact one of the dev team members if you have trouble building - it is more than likely there is an error in the instructions below, rather than somethign wrong on your end.

The installer is mostly setup to build on travis - if you want to build locally, you'll need to do the following (WINDOWS ONLY):

The built exe will be located in the travis_installer_output folder