aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2011-02-10 16:48:29 +0000
committerFilippos Karapetis2011-02-10 16:48:29 +0000
commite4b46bd159419c96c683a6a19b63416fb368e6d8 (patch)
tree96bd7fae76e66185fa8a3e05cdc7ad3c83b45796 /engines
parent80347e96303ff707d394759297547b3392fdb64b (diff)
downloadscummvm-rg350-e4b46bd159419c96c683a6a19b63416fb368e6d8.tar.gz
scummvm-rg350-e4b46bd159419c96c683a6a19b63416fb368e6d8.tar.bz2
scummvm-rg350-e4b46bd159419c96c683a6a19b63416fb368e6d8.zip
SCI: Added resource manager support for changing the audio directory dynamically. Also,
moved some audio-specific resource code inside resource_audio.cpp This functionality is used by kSetLanguage(), called when switching the language in MUMG Deluxe from the game's main menu. svn-id: r55872
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/ksound.cpp8
-rw-r--r--engines/sci/resource.cpp24
-rw-r--r--engines/sci/resource.h1
-rw-r--r--engines/sci/resource_audio.cpp63
4 files changed, 69 insertions, 27 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index e006e22482..911713d0bd 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -284,10 +284,10 @@ reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv) {
// the audio language between English and Spanish.
// Basically, it instructs the interpreter to switch the audio resources
// (resource.aud and associated map files) and load them from the "Spanish"
- // subdirectory instead. Therefore, this is only needed for the Spanish
- // version, and it needs support at the resource manager level.
- Common::String languageFolder = s->_segMan->getString(argv[0]);
- warning("SetLanguage: set audio resource folder to '%s'", languageFolder.c_str());
+ // subdirectory instead.
+ Common::String audioDirectory = s->_segMan->getString(argv[0]);
+ //warning("SetLanguage: set audio resource directory to '%s'", audioDirectory.c_str());
+ g_sci->getResMan()->changeAudioDirectory(audioDirectory);
return s->r_acc;
}
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index f98a875f7f..d1bf869836 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -318,7 +318,7 @@ bool Resource::loadPatch(Common::SeekableReadStream *file) {
bool Resource::loadFromPatchFile() {
Common::File file;
const Common::String &filename = _source->getLocationName();
- if (file.open(filename) == false) {
+ if (!file.open(filename)) {
warning("Failed to open patch file %s", filename.c_str());
unalloc();
return false;
@@ -739,28 +739,6 @@ int ResourceManager::addAppropriateSources(const Common::FSList &fslist) {
return 1;
}
-bool ResourceManager::addAudioSources() {
- Common::List<ResourceId> *resources = listResources(kResourceTypeMap);
- Common::List<ResourceId>::iterator itr = resources->begin();
-
- while (itr != resources->end()) {
- ResourceSource *src = addSource(new IntMapResourceSource("MAP", itr->getNumber()));
-
- if ((itr->getNumber() == 65535) && Common::File::exists("RESOURCE.SFX"))
- addSource(new AudioVolumeResourceSource(this, "RESOURCE.SFX", src, 0));
- else if (Common::File::exists("RESOURCE.AUD"))
- addSource(new AudioVolumeResourceSource(this, "RESOURCE.AUD", src, 0));
- else
- return false;
-
- ++itr;
- }
-
- delete resources;
-
- return true;
-}
-
void ResourceManager::addScriptChunkSources() {
#ifdef ENABLE_SCI32
if (_mapVersion >= kResVersionSci2) {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 15cc823b30..92749ba162 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -328,6 +328,7 @@ public:
void setAudioLanguage(int language);
int getAudioLanguage() const;
+ void changeAudioDirectory(Common::String path);
bool isGMTrackIncluded();
bool isVGA() const { return (_viewType == kViewVga) || (_viewType == kViewVga11); }
bool isAmiga32color() const { return _viewType == kViewAmiga; }
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 183e200e9d..386bfb37f5 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -893,4 +893,67 @@ void AudioVolumeResourceSource::loadResource(ResourceManager *resMan, Resource *
delete fileStream;
}
+bool ResourceManager::addAudioSources() {
+ Common::List<ResourceId> *resources = listResources(kResourceTypeMap);
+ Common::List<ResourceId>::iterator itr = resources->begin();
+
+ while (itr != resources->end()) {
+ ResourceSource *src = addSource(new IntMapResourceSource("MAP", itr->getNumber()));
+
+ if ((itr->getNumber() == 65535) && Common::File::exists("RESOURCE.SFX"))
+ addSource(new AudioVolumeResourceSource(this, "RESOURCE.SFX", src, 0));
+ else if (Common::File::exists("RESOURCE.AUD"))
+ addSource(new AudioVolumeResourceSource(this, "RESOURCE.AUD", src, 0));
+ else
+ return false;
+
+ ++itr;
+ }
+
+ delete resources;
+
+ return true;
+}
+
+void ResourceManager::changeAudioDirectory(Common::String path) {
+ // Remove all of the audio map resource sources, as well as the audio resource sources
+ for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end(); ++it) {
+ ResourceSource *source = *it;
+ ResSourceType sourceType = source->getSourceType();
+
+ // Remove the resource source, if it's an audio map or an audio file
+ if (sourceType == kSourceIntMap || sourceType == kSourceAudioVolume) {
+ // Don't remove 65535.map (the SFX map) or resource.sfx
+ if (source->_volumeNumber == 65535 || source->getLocationName() == "RESOURCE.SFX")
+ continue;
+
+ it = _sources.erase(it);
+ delete source;
+ }
+ }
+
+ // Now, readd the audio resource sources
+ Common::String mapName = "MAP";
+ Common::String audioResourceName = "RESOURCE.AUD";
+ if (!path.empty()) {
+ mapName = Common::String::format("%s/MAP", path.c_str());
+ audioResourceName = Common::String::format("%s/RESOURCE.AUD", path.c_str());
+ }
+
+ Common::List<ResourceId> *resources = listResources(kResourceTypeMap);
+ for (Common::List<ResourceId>::iterator it = resources->begin(); it != resources->end(); ++it) {
+ // Don't readd 65535.map or resource.sfx
+ if ((it->getNumber() == 65535))
+ continue;
+
+ ResourceSource *src = addSource(new IntMapResourceSource(mapName, it->getNumber()));
+ addSource(new AudioVolumeResourceSource(this, audioResourceName, src, 0));
+ }
+
+ delete resources;
+
+ // Rescan the newly added resources
+ scanNewSources();
+}
+
} // End of namespace Sci