SCI32: Implement Mac kSetLanguage

This commit is contained in:
sluicebox 2020-05-05 12:14:18 -07:00
parent e7da80dddf
commit 85e27b0caf
4 changed files with 54 additions and 3 deletions

View File

@ -469,9 +469,14 @@ reg_t kDoAudioPanOff(EngineState *s, int argc, reg_t *argv) {
reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv) {
// Used by script 90 of MUMG Deluxe from the main menu to toggle between
// English and Spanish.
// English and Spanish in some versions and English and Spanish and
// French and German in others.
const Common::String audioDirectory = s->_segMan->getString(argv[0]);
g_sci->getResMan()->changeAudioDirectory(audioDirectory);
if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
g_sci->getResMan()->changeMacAudioDirectory(audioDirectory);
} else {
g_sci->getResMan()->changeAudioDirectory(audioDirectory);
}
return s->r_acc;
}

View File

@ -1654,7 +1654,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource
debugC(1, kDebugLevelResMan, "Patching %s - OK", source->getLocationName().c_str());
}
static ResourceId convertPatchNameBase36(ResourceType type, const Common::String &filename) {
ResourceId convertPatchNameBase36(ResourceType type, const Common::String &filename) {
// The base36 encoded resource contains the following:
// uint16 resourceId, byte noun, byte verb, byte cond, byte seq

View File

@ -399,6 +399,7 @@ public:
void setAudioLanguage(int language);
int getAudioLanguage() const;
void changeAudioDirectory(Common::String path);
void changeMacAudioDirectory(Common::String path);
bool isGMTrackIncluded();
bool isSci11Mac() const { return _volVersion == kResVersionSci11Mac; }
ViewType getViewType() const { return _viewType; }
@ -699,6 +700,8 @@ private:
byte _soundPriority;
};
ResourceId convertPatchNameBase36(ResourceType type, const Common::String &filename);
} // End of namespace Sci
#endif // SCI_RESOURCE_H

View File

@ -1148,4 +1148,47 @@ void ResourceManager::changeAudioDirectory(Common::String path) {
scanNewSources();
}
void ResourceManager::changeMacAudioDirectory(Common::String path) {
// delete all Audio36 resources so that they can be replaced with
// different patch files from the new directory.
for (ResourceMap::iterator it = _resMap.begin(); it != _resMap.end(); ++it) {
const ResourceType type = it->_key.getType();
if (type == kResourceTypeAudio36) {
Resource *resource = it->_value;
if (resource) {
// If one of these resources ends up being locked here, it
// probably means Audio32 is using it and we need to stop
// playback of audio before switching directories
assert(!resource->isLocked());
if (resource->_status == kResStatusEnqueued) {
removeFromLRU(resource);
}
delete resource;
}
_resMap.erase(it);
}
}
if (path.empty()) {
path = "english";
}
path = "voices/" + path + "/";
// add all Audio36 wave patch files from language directory
Common::ArchiveMemberList audio36Files;
SearchMan.listMatchingMembers(audio36Files, path + "A???????.???");
for (Common::ArchiveMemberList::const_iterator it = audio36Files.begin(); it != audio36Files.end(); ++it) {
const Common::ArchiveMemberPtr &file = *it;
assert(file);
const Common::String fileName = file->getName();
ResourceId resource36 = convertPatchNameBase36(kResourceTypeAudio36, fileName);
processWavePatch(resource36, path + fileName);
}
}
} // End of namespace Sci