QcModLoader Class
Finds data-only mods (content packs) in a directory, orders them by their dependencies and loads them after the base game into one registry. More...
| Header: | #include <worlds/QcModLoader.h> |
Public Types
Static Public Members
| QString | defaultDirectory() |
| QStringList | disabledMods(const QString &modsDirectory) |
| QList<QcModStatus> | discover(const QString &modsDirectory) |
| QcModLoader::Loaded | load(const QString &modsDirectory) |
| const int | maxLoadedMods |
| const int | maxMods |
| QList<QcModStatus> | resolve(const QList<QcContentPackInfo> &candidates, const QStringList &disabled, const QList<QcPackReference> &available) |
| QcStatus | setModEnabled(const QString &modsDirectory, const QString &id, bool enabled) |
| const char *const | settingsFile |
| const QStringList & | warningsOf(const QcModLoader::Loaded &loaded) |
Detailed Description
Each mod is a sub-directory with a pack.json manifest; a mod that cannot be loaded is skipped together with every mod that depends on it, the rest of the game still starts.
Member Type Documentation
[alias] QcModLoader::Loaded
The outcome of load(): the result, or the failure.
Member Function Documentation
[static] QString QcModLoader::defaultDirectory()
Returns <data root>/mods (see QcWorldLibrary::dataRoot()).
[static] QStringList QcModLoader::disabledMods(const QString &modsDirectory)
Returns the ids on the disabled list in mods.json of modsDirectory; empty when the file is missing, unreadable or too large.
[static] QList<QcModStatus> QcModLoader::discover(const QString &modsDirectory)
Reads all manifests below modsDirectory and returns them in load order without loading content. An empty or missing directory gives an empty list.
[static] QcModLoader::Loaded QcModLoader::load(const QString &modsDirectory)
Returns the base game plus every loadable mod. Fails only when the base game cannot be loaded; an empty modsDirectory loads no mods.
[static] QList<QcModStatus> QcModLoader::resolve(const QList<QcContentPackInfo> &candidates, const QStringList &disabled, const QList<QcPackReference> &available)
Orders candidates so that every mod comes after its dependencies (ties by id, so the order is stable). Mods with unknown, failed, disabled or too old dependencies, duplicate ids, cycles or the base game's id fail; mods whose id is in disabled are disabled. available holds the packs loaded before (base). Returns the state of every candidate.
[static] QcStatus QcModLoader::setModEnabled(const QString &modsDirectory, const QString &id, bool enabled)
Takes the mod id off the disabled list in modsDirectory when enabled is true, else puts it on, and writes the list (creating the directory); takes effect the next time content is loaded. Returns an error when the directory or file cannot be written.
[static] const QStringList &QcModLoader::warningsOf(const QcModLoader::Loaded &loaded)
Returns the warnings of loaded, whether it succeeded or not (callers report them before the outcome).
Member Variable Documentation
const int QcModLoader::maxLoadedMods
Upper bound for the number of mods loaded (each costs a full check, whether accepted or not).
const int QcModLoader::maxMods
Upper bound for the number of mod directories looked at.
const char *const QcModLoader::settingsFile
Optional file in the mods directory: {"disabled": ["mod_id", ...]}.