From f95fadd25e1c7689dfee76d56abc678c9d4a29d3 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 20 Jan 2019 17:50:43 +0100 Subject: [PATCH] STARK: Load replacement files from the mods directory Each mod should be its own directory in the mods subdirectory of the game data path. Mods are loaded in alphabetical order. --- README.md | 25 +++++++++++++++++++++++++ engines/stark/stark.cpp | 22 ++++++++++++++++++++++ engines/stark/stark.h | 1 + 3 files changed, 48 insertions(+) diff --git a/README.md b/README.md index 64be69667c8..e9f849275b8 100644 --- a/README.md +++ b/README.md @@ -448,6 +448,31 @@ Command | Description `location` | Display the current location `testDecompiler` | Test decompilation of all the scripts in game +### 8.5. Modding The Longest Journey ### + +ResidualVM can load replacement assets instead of the original files for +some of the asset types. By leveraging this capability, users can create +mods for the game. These are the currently supported modding features: + + * Load mods from the `mods` directory inside the game data path. + Each mod should be its own directory in the `mods` subdirectory. + Mods are loaded in alphabetical order. + + * Load external PNG files instead of the XMG files inside the game + archives. + The replacement PNG files can have larger dimensions when compared to + the original XMG images, enabling the creation of a high resolution mod. + The game looks for the replacement files in a mod directory and then + in the `xarc` subdirectory of the directory containing the archive in + which the XMG picture to be replaced is located. For instance: + `mods/[my_mod]/1e/00/xarc/fountain_layercenter.png` needs to be used for + the Venice park background. + ResidualVM expects PNGs to be in pre-multiplied alpha format for improved + load times. However the `replacement_png_premultiply_alpha` `residualvm.ini` + setting allows to load regular transparency PNGs when set to `true` for + convenience when testing. + +Contact us if you need further capabilities for your mod. ## 9. Bug reports ResidualVM still has a few bugs, many might already have been reported, diff --git a/engines/stark/stark.cpp b/engines/stark/stark.cpp index c6e139964be..a17d26385c8 100644 --- a/engines/stark/stark.cpp +++ b/engines/stark/stark.cpp @@ -48,6 +48,7 @@ #include "common/config-manager.h" #include "common/debug-channels.h" #include "common/events.h" +#include "common/fs.h" #include "common/random.h" #include "common/savefile.h" #include "common/system.h" @@ -67,6 +68,8 @@ StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : DebugMan.addDebugChannel(kDebugXRC, "XRC", "Debug the loading of XRC resource trees"); DebugMan.addDebugChannel(kDebugModding, "Modding", "Debug the loading of modded assets"); DebugMan.addDebugChannel(kDebugUnknown, "Unknown", "Debug unknown values on the data"); + + addModsToSearchPath(); } StarkEngine::~StarkEngine() { @@ -259,6 +262,25 @@ void StarkEngine::updateDisplayScene() { StarkUserInterface->render(); } +static bool modsCompare(const Common::FSNode &a, const Common::FSNode &b) { + return a.getName() < b.getName(); +} + +void StarkEngine::addModsToSearchPath() const { + const Common::FSNode gameDataDir(ConfMan.get("path")); + const Common::FSNode modsDir = gameDataDir.getChild("mods"); + if (modsDir.exists()) { + Common::FSList list; + modsDir.getChildren(list); + + Common::sort(list.begin(), list.end(), modsCompare); + + for (uint i = 0; i < list.size(); i++) { + SearchMan.addDirectory("mod_" + list[i].getName(), list[i], 0, 4); + } + } +} + bool StarkEngine::hasFeature(EngineFeature f) const { return (f == kSupportsLoadingDuringRuntime) || diff --git a/engines/stark/stark.h b/engines/stark/stark.h index 9c51f6512f1..da57aac12d6 100644 --- a/engines/stark/stark.h +++ b/engines/stark/stark.h @@ -79,6 +79,7 @@ private: void updateDisplayScene(); void processEvents(); void onScreenChanged() const; + void addModsToSearchPath() const; Gfx::FrameLimiter *_frameLimiter; Console *_console;