Skip to content

Commit

Permalink
JADE: Add support for Aspyr's Android port of Jade Empire
Browse files Browse the repository at this point in the history
The OBB files need to be extracted first, though, using the unobb tool
in xoreos-tools.
  • Loading branch information
DrMcCoy committed Jul 29, 2018
1 parent 18c9efe commit 2a69fc9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
47 changes: 42 additions & 5 deletions src/engines/jade/jade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,26 @@ void JadeEngine::declareLanguages() {
LangMan.addLanguages(kLanguageDeclarations, ARRAYSIZE(kLanguageDeclarations));
}

/** Figure out which localization in an Android installation contains the voices. */
static Common::UString findAndroidVOLanguageDir(const Common::UString &target) {
/* Look into all subdirectories of the directory localized (which are all named after
* a language). In each, see if there's a sound/vo subdirectory. If there is, return
* the subdirectory (i.e the language name). */

const Common::UString loc = Common::FilePath::findSubDirectory(target, "localized", true);
if (loc.empty())
return "";

std::list<Common::UString> langs;
Common::FilePath::getSubDirectories(loc, langs);

for (std::list<Common::UString>::const_iterator l = langs.begin(); l != langs.end(); ++l)
if (!Common::FilePath::findSubDirectory(*l, "sound/vo", true).empty())
return Common::FilePath::relativize(loc, *l);

return "";
}

void JadeEngine::initResources(LoadProgress &progress) {
// Some new file types with the same function as old ones re-use the type ID
ResMan.addTypeAlias(Aurora::kFileTypeBTC, Aurora::kFileTypeCRE);
Expand Down Expand Up @@ -254,25 +274,42 @@ void JadeEngine::initResources(LoadProgress &progress) {
progress.step("Indexing extra sound resources");
indexMandatoryDirectory("sound" , 0, -1, 101);
progress.step("Indexing extra movie resources");
indexMandatoryDirectory("movies" , 0, -1, 102);
indexMandatoryDirectory("movies" , 0, -1, 103);

if (_platform == Aurora::kPlatformWindows) {
progress.step("Indexing extra shader resources");
indexMandatoryDirectory("shaderpc", 0, -1, 103);
indexMandatoryDirectory("shaderpc", 0, -1, 104);
}

progress.step("Indexing override files");
indexOptionalDirectory("override", 0, 0, 150);

progress.step("Indexing extra language files");

/* If we're running an Android version, see which language the voices are in.
* This should only ever be one language, the native language of the installation.
*
* If this is the language we want to play the game in, we're indexing the
* resources below. If it isn't, index them with a lower priority, as a fallback. */
const Common::UString androidVO = findAndroidVOLanguageDir(_target);
const Aurora::Language androidVOLang = LangMan.parseLanguage(androidVO);
if ((androidVOLang != Aurora::kLanguageInvalid) && (androidVOLang != LangMan.getCurrentLanguageText())) {
const Common::UString locDir = Common::UString("localized/") + androidVO;

indexOptionalDirectory(locDir + "/data", 0, -1, 3);
indexOptionalDirectory(locDir + "/sound", 0, -1, 102);
}

const Common::UString langDir = getTLKDirectory(_target, LangMan.getCurrentLanguageText());
if (!langDir.empty()) {
indexMandatoryDirectory(langDir, 0, 0, 160);

indexOptionalDirectory(langDir + "/fonts" , 0, -1, 161);
indexOptionalDirectory(langDir + "/movies", 0, -1, 162);
indexOptionalDirectory(langDir + "/data" , 0, -1, 161);
indexOptionalDirectory(langDir + "/fonts" , 0, -1, 162);
indexOptionalDirectory(langDir + "/sound" , 0, -1, 163);
indexOptionalDirectory(langDir + "/movies", 0, -1, 164);

indexOptionalDirectory(langDir + "/override", 0, 0, 163);
indexOptionalDirectory(langDir + "/override", 0, 0, 170);
}

if (EventMan.quitRequested())
Expand Down
20 changes: 19 additions & 1 deletion src/engines/jade/probes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,29 @@ class EngineProbeXbox : public EngineProbe {

};

class EngineProbeAndroid : public EngineProbe {
public:
EngineProbeAndroid() {}
~EngineProbeAndroid() {}

Aurora::Platform getPlatform() const { return Aurora::kPlatformAndroid; }

bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
// TODO: Detect the unextracted OBBs? Doesn't work with how we index directories, though.

if (rootFiles.contains("/jadeempire.par", true))
return true;

return false;
}

};


void createEngineProbes(std::list<const ::Engines::EngineProbe *> &probes) {
probes.push_back(new EngineProbeWindows);
probes.push_back(new EngineProbeXbox);

probes.push_back(new EngineProbeAndroid);
}

} // End of namespace Jade
Expand Down

0 comments on commit 2a69fc9

Please sign in to comment.