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.
This commit is contained in:
Bastien Bouclet 2019-01-20 17:50:43 +01:00
parent d21dc329d6
commit f95fadd25e
3 changed files with 48 additions and 0 deletions

View File

@ -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,

View File

@ -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) ||

View File

@ -79,6 +79,7 @@ private:
void updateDisplayScene();
void processEvents();
void onScreenChanged() const;
void addModsToSearchPath() const;
Gfx::FrameLimiter *_frameLimiter;
Console *_console;