SCI: Convert code to use ResourceSource subclasses
svn-id: r49813
This commit is contained in:
parent
24a295f4a3
commit
17a5112162
4 changed files with 38 additions and 37 deletions
|
@ -210,25 +210,25 @@ ResourceSource *ResourceManager::addExternalMap(const Common::FSNode *mapFile, i
|
||||||
return newsrc;
|
return newsrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceSource *ResourceManager::addSource(ResourceSource *map, ResSourceType type, const Common::String &filename, int number) {
|
ResourceSource *ResourceManager::addSource(ResourceSource *map, ResourceSource *newsrc, int number) {
|
||||||
ResourceSource *newsrc = new ResourceSource(type, filename);
|
assert(newsrc);
|
||||||
|
|
||||||
newsrc->volume_number = number;
|
newsrc->volume_number = number;
|
||||||
newsrc->associated_map = map;
|
newsrc->associated_map = map;
|
||||||
if (type == kSourceAudioVolume)
|
if (newsrc->getSourceType() == kSourceAudioVolume)
|
||||||
checkIfAudioVolumeIsCompressed(newsrc);
|
checkIfAudioVolumeIsCompressed(newsrc);
|
||||||
|
|
||||||
_sources.push_back(newsrc);
|
_sources.push_back(newsrc);
|
||||||
return newsrc;
|
return newsrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceSource *ResourceManager::addSource(ResourceSource *map, ResSourceType type, const Common::FSNode *resFile, int number) {
|
ResourceSource *ResourceManager::addSource(ResourceSource *map, ResourceSource *newsrc, const Common::FSNode *resFile, int number) {
|
||||||
ResourceSource *newsrc = new ResourceSource(type, resFile->getName());
|
assert(newsrc);
|
||||||
|
|
||||||
newsrc->resourceFile = resFile;
|
newsrc->resourceFile = resFile;
|
||||||
newsrc->volume_number = number;
|
newsrc->volume_number = number;
|
||||||
newsrc->associated_map = map;
|
newsrc->associated_map = map;
|
||||||
if (type == kSourceAudioVolume)
|
if (newsrc->getSourceType() == kSourceAudioVolume)
|
||||||
checkIfAudioVolumeIsCompressed(newsrc);
|
checkIfAudioVolumeIsCompressed(newsrc);
|
||||||
|
|
||||||
_sources.push_back(newsrc);
|
_sources.push_back(newsrc);
|
||||||
|
@ -459,12 +459,12 @@ int ResourceManager::addAppropriateSources() {
|
||||||
const char *dot = strrchr(name.c_str(), '.');
|
const char *dot = strrchr(name.c_str(), '.');
|
||||||
int number = atoi(dot + 1);
|
int number = atoi(dot + 1);
|
||||||
|
|
||||||
addSource(map, kSourceVolume, name, number);
|
addSource(map, new VolumeResourceSource(name), number);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_SCI32
|
#ifdef ENABLE_SCI32
|
||||||
// GK1CD hires content
|
// GK1CD hires content
|
||||||
if (Common::File::exists("alt.map") && Common::File::exists("resource.alt"))
|
if (Common::File::exists("alt.map") && Common::File::exists("resource.alt"))
|
||||||
addSource(addExternalMap("alt.map", 10), kSourceVolume, "resource.alt", 10);
|
addSource(addExternalMap("alt.map", 10), new VolumeResourceSource("resource.alt"), 10);
|
||||||
#endif
|
#endif
|
||||||
} else if (Common::File::exists("Data1")) {
|
} else if (Common::File::exists("Data1")) {
|
||||||
// Mac SCI1.1+ file naming scheme
|
// Mac SCI1.1+ file naming scheme
|
||||||
|
@ -472,7 +472,7 @@ int ResourceManager::addAppropriateSources() {
|
||||||
|
|
||||||
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
|
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
|
||||||
Common::String filename = (*x)->getName();
|
Common::String filename = (*x)->getName();
|
||||||
addSource(0, kSourceMacResourceFork, filename, atoi(filename.c_str() + 4));
|
addSource(0, new MacResourceForkResourceSource(filename), atoi(filename.c_str() + 4));
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_SCI32
|
#ifdef ENABLE_SCI32
|
||||||
// Mac SCI32 games have extra folders for patches
|
// Mac SCI32 games have extra folders for patches
|
||||||
|
@ -484,7 +484,7 @@ int ResourceManager::addAppropriateSources() {
|
||||||
|
|
||||||
// There can also be a "Patches" resource fork with patches
|
// There can also be a "Patches" resource fork with patches
|
||||||
if (Common::File::exists("Patches"))
|
if (Common::File::exists("Patches"))
|
||||||
addSource(0, kSourceMacResourceFork, "Patches", 100);
|
addSource(0, new MacResourceForkResourceSource("Patches"), 100);
|
||||||
} else {
|
} else {
|
||||||
// SCI2.1-SCI3 file naming scheme
|
// SCI2.1-SCI3 file naming scheme
|
||||||
Common::ArchiveMemberList mapFiles;
|
Common::ArchiveMemberList mapFiles;
|
||||||
|
@ -504,7 +504,7 @@ int ResourceManager::addAppropriateSources() {
|
||||||
int resNumber = atoi(strrchr(resName.c_str(), '.') + 1);
|
int resNumber = atoi(strrchr(resName.c_str(), '.') + 1);
|
||||||
|
|
||||||
if (mapNumber == resNumber) {
|
if (mapNumber == resNumber) {
|
||||||
addSource(addExternalMap(mapName, mapNumber), kSourceVolume, resName, mapNumber);
|
addSource(addExternalMap(mapName, mapNumber), new VolumeResourceSource(resName), mapNumber);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ int ResourceManager::addAppropriateSources() {
|
||||||
// SCI2.1 resource patches
|
// SCI2.1 resource patches
|
||||||
if (Common::File::exists("resmap.pat") && Common::File::exists("ressci.pat")) {
|
if (Common::File::exists("resmap.pat") && Common::File::exists("ressci.pat")) {
|
||||||
// We add this resource with a map which surely won't exist
|
// We add this resource with a map which surely won't exist
|
||||||
addSource(addExternalMap("resmap.pat", 100), kSourceVolume, "ressci.pat", 100);
|
addSource(addExternalMap("resmap.pat", 100), new VolumeResourceSource("ressci.pat"), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -523,7 +523,7 @@ int ResourceManager::addAppropriateSources() {
|
||||||
|
|
||||||
addPatchDir(".");
|
addPatchDir(".");
|
||||||
if (Common::File::exists("message.map"))
|
if (Common::File::exists("message.map"))
|
||||||
addSource(addExternalMap("message.map"), kSourceVolume, "resource.msg", 0);
|
addSource(addExternalMap("message.map"), new VolumeResourceSource("resource.msg"), 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ int ResourceManager::addAppropriateSources(const Common::FSList &fslist) {
|
||||||
|
|
||||||
#ifdef ENABLE_SCI32
|
#ifdef ENABLE_SCI32
|
||||||
if (sci21PatchMap && sci21PatchRes)
|
if (sci21PatchMap && sci21PatchRes)
|
||||||
addSource(sci21PatchMap, kSourceVolume, sci21PatchRes, 100);
|
addSource(sci21PatchMap, new VolumeResourceSource(sci21PatchRes->getName()), sci21PatchRes, 100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Now find all the resource.0?? files
|
// Now find all the resource.0?? files
|
||||||
|
@ -582,7 +582,7 @@ int ResourceManager::addAppropriateSources(const Common::FSList &fslist) {
|
||||||
const char *dot = strrchr(filename.c_str(), '.');
|
const char *dot = strrchr(filename.c_str(), '.');
|
||||||
int number = atoi(dot + 1);
|
int number = atoi(dot + 1);
|
||||||
|
|
||||||
addSource(map, kSourceVolume, file, number);
|
addSource(map, new VolumeResourceSource(file->getName()), file, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,12 +597,12 @@ int ResourceManager::addInternalSources() {
|
||||||
Common::List<ResourceId>::iterator itr = resources->begin();
|
Common::List<ResourceId>::iterator itr = resources->begin();
|
||||||
|
|
||||||
while (itr != resources->end()) {
|
while (itr != resources->end()) {
|
||||||
ResourceSource *src = addSource(NULL, kSourceIntMap, "MAP", itr->number);
|
ResourceSource *src = addSource(NULL, new IntMapResourceSource("MAP"), itr->number);
|
||||||
|
|
||||||
if ((itr->number == 65535) && Common::File::exists("RESOURCE.SFX"))
|
if ((itr->number == 65535) && Common::File::exists("RESOURCE.SFX"))
|
||||||
addSource(src, kSourceAudioVolume, "RESOURCE.SFX", 0);
|
addSource(src, new AudioVolumeResourceSource("RESOURCE.SFX"), 0);
|
||||||
else if (Common::File::exists("RESOURCE.AUD"))
|
else if (Common::File::exists("RESOURCE.AUD"))
|
||||||
addSource(src, kSourceAudioVolume, "RESOURCE.AUD", 0);
|
addSource(src, new AudioVolumeResourceSource("RESOURCE.AUD"), 0);
|
||||||
|
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,18 +69,6 @@ enum {
|
||||||
MAX_OPENED_VOLUMES = 5 ///< Max number of simultaneously opened volumes
|
MAX_OPENED_VOLUMES = 5 ///< Max number of simultaneously opened volumes
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ResSourceType {
|
|
||||||
kSourceDirectory = 0,
|
|
||||||
kSourcePatch,
|
|
||||||
kSourceVolume,
|
|
||||||
kSourceExtMap,
|
|
||||||
kSourceIntMap,
|
|
||||||
kSourceAudioVolume,
|
|
||||||
kSourceExtAudioMap,
|
|
||||||
kSourceWave,
|
|
||||||
kSourceMacResourceFork
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ResourceType {
|
enum ResourceType {
|
||||||
kResourceTypeView = 0,
|
kResourceTypeView = 0,
|
||||||
kResourceTypePic,
|
kResourceTypePic,
|
||||||
|
@ -329,14 +317,13 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Adds a source to the resource manager's list of sources.
|
* Adds a source to the resource manager's list of sources.
|
||||||
* @param map The map associated with this source
|
* @param map The map associated with this source
|
||||||
* @param type The source type
|
* @param source The new source to add
|
||||||
* @param filename The name of the source to add
|
|
||||||
* @return A pointer to the added source structure, or NULL if an error occurred.
|
* @return A pointer to the added source structure, or NULL if an error occurred.
|
||||||
*/
|
*/
|
||||||
ResourceSource *addSource(ResourceSource *map, ResSourceType type, const Common::String &filename,
|
ResourceSource *addSource(ResourceSource *map, ResourceSource *source,
|
||||||
int number);
|
int number);
|
||||||
|
|
||||||
ResourceSource *addSource(ResourceSource *map, ResSourceType type,
|
ResourceSource *addSource(ResourceSource *map, ResourceSource *source,
|
||||||
const Common::FSNode *resFile, int number);
|
const Common::FSNode *resFile, int number);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -433,7 +433,7 @@ void ResourceManager::setAudioLanguage(int language) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_audioMapSCI1 = addSource(NULL, kSourceExtAudioMap, fullname, language);
|
_audioMapSCI1 = addSource(NULL, new ExtAudioMapResourceSource(fullname), language);
|
||||||
|
|
||||||
// Search for audio volumes for this language and add them to the source list
|
// Search for audio volumes for this language and add them to the source list
|
||||||
Common::ArchiveMemberList files;
|
Common::ArchiveMemberList files;
|
||||||
|
@ -443,7 +443,7 @@ void ResourceManager::setAudioLanguage(int language) {
|
||||||
const char *dot = strrchr(name.c_str(), '.');
|
const char *dot = strrchr(name.c_str(), '.');
|
||||||
int number = atoi(dot + 1);
|
int number = atoi(dot + 1);
|
||||||
|
|
||||||
addSource(_audioMapSCI1, kSourceAudioVolume, name, number);
|
addSource(_audioMapSCI1, new AudioVolumeResourceSource(name), number);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanNewSources();
|
scanNewSources();
|
||||||
|
|
|
@ -34,6 +34,19 @@ namespace Common {
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
|
enum ResSourceType {
|
||||||
|
kSourceDirectory = 0,
|
||||||
|
kSourcePatch,
|
||||||
|
kSourceVolume,
|
||||||
|
kSourceExtMap,
|
||||||
|
kSourceIntMap,
|
||||||
|
kSourceAudioVolume,
|
||||||
|
kSourceExtAudioMap,
|
||||||
|
kSourceWave,
|
||||||
|
kSourceMacResourceFork
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class ResourceSource {
|
class ResourceSource {
|
||||||
protected:
|
protected:
|
||||||
const ResSourceType _sourceType;
|
const ResSourceType _sourceType;
|
||||||
|
@ -48,8 +61,9 @@ public:
|
||||||
int32 *audioCompressionOffsetMapping;
|
int32 *audioCompressionOffsetMapping;
|
||||||
Common::MacResManager *_macResMan;
|
Common::MacResManager *_macResMan;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
ResourceSource(ResSourceType type, const Common::String &name);
|
ResourceSource(ResSourceType type, const Common::String &name);
|
||||||
|
public:
|
||||||
virtual ~ResourceSource();
|
virtual ~ResourceSource();
|
||||||
|
|
||||||
ResSourceType getSourceType() const { return _sourceType; }
|
ResSourceType getSourceType() const { return _sourceType; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue