scummvm/engines/grim/resource.cpp

680 lines
20 KiB
C++
Raw Normal View History

2020-10-09 17:04:07 +00:00
/* ScummVM - Graphic Adventure Engine
*
2020-10-09 17:04:07 +00:00
* ScummVM is the legal property of its developers, whose names
2021-12-26 20:19:38 +00:00
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
2006-04-02 14:20:45 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2014-04-05 16:18:42 +00:00
*
* This program is distributed in the hope that it will be useful,
2006-04-02 14:20:45 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2014-04-05 16:18:42 +00:00
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2006-04-02 14:20:45 +00:00
*
*/
2003-08-15 18:00:22 +00:00
2012-08-08 16:13:46 +00:00
#include "gui/error.h"
#include "engines/grim/resource.h"
#include "engines/grim/colormap.h"
#include "engines/grim/costume.h"
#include "engines/grim/keyframe.h"
#include "engines/grim/material.h"
#include "engines/grim/grim.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/savegame.h"
2011-05-14 00:55:14 +00:00
#include "engines/grim/lab.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
2011-07-22 20:40:49 +00:00
#include "engines/grim/model.h"
2013-07-08 00:18:30 +00:00
#include "engines/grim/sprite.h"
#include "engines/grim/inputdialog.h"
#include "engines/grim/debug.h"
#include "engines/grim/emi/animationemi.h"
#include "engines/grim/emi/costumeemi.h"
#include "engines/grim/emi/modelemi.h"
#include "engines/grim/emi/skeleton.h"
#include "engines/grim/remastered/overlay.h"
#include "engines/grim/patchr.h"
#include "engines/grim/md5check.h"
#include "engines/grim/update/update.h"
#include "common/algorithm.h"
#include "common/compression/deflate.h"
#include "common/memstream.h"
#include "common/file.h"
#include "common/config-manager.h"
2015-08-26 18:42:31 +00:00
#include "common/translation.h"
2005-01-01 12:27:57 +00:00
2009-05-25 06:49:57 +00:00
namespace Grim {
2014-05-29 22:35:46 +00:00
ResourceLoader *g_resourceloader = nullptr;
2003-08-15 18:00:22 +00:00
class LabListComperator {
const Common::String _labName;
public:
LabListComperator() {}
LabListComperator(const Common::String &ln) : _labName(ln) {}
bool operator()(const Common::ArchiveMemberPtr &l) {
return _labName.compareToIgnoreCase(l->getName()) == 0;
}
bool operator()(const Common::ArchiveMemberPtr &l, const Common::ArchiveMemberPtr &r) {
return (l->getName().compareToIgnoreCase(r->getName()) > 0);
}
};
2003-08-15 18:00:22 +00:00
ResourceLoader::ResourceLoader() {
2009-05-12 14:31:48 +00:00
_cacheDirty = false;
2009-06-27 06:08:44 +00:00
_cacheMemorySize = 0;
2009-05-12 14:31:48 +00:00
Lab *l;
Common::ArchiveMemberList files, updFiles;
2008-08-01 18:27:11 +00:00
2022-06-07 23:12:00 +00:00
// Load the update from the executable, if needed
2020-10-07 17:50:27 +00:00
const char *updateFilename = nullptr;
if ((g_grim->getGameType() == GType_GRIM && !g_grim->isRemastered())
|| g_grim->getGameType() == GType_MONKEY4) {
2020-10-07 17:50:27 +00:00
updateFilename = g_grim->getUpdateFilename();
}
if (updateFilename) {
Common::File *updStream = new Common::File();
if (updStream && updStream->open(updateFilename)) {
Common::Archive *update = loadUpdateArchive(updStream);
if (update)
SearchMan.add("update", update, 1);
} else
delete updStream;
// Check if the update has been correctly loaded
if (!SearchMan.hasArchive("update")) {
Common::U32String errorMessage;
Common::String urlForPatchDownload = Common::String::format("https://downloads.scummvm.org/frs/extras/patches/%s",
(g_grim->getGameType() == GType_GRIM)? "gfupd101.exe" : "");
if (g_grim->getGameType() == GType_GRIM) {
errorMessage = Common::U32String::format(_("The original patch of Grim Fandango\n"
"is missing. Please download it from\n"
"%s\n"
"and put it in the game data files directory"), urlForPatchDownload.c_str());
} else if (g_grim->getGameType() == GType_MONKEY4) {
errorMessage = Common::U32String::format(_("The original patch of Escape from Monkey Island is missing. \n"
"Please download it from %s\n"
"and put it in the game data files directory.\n"
"Pay attention to download the correct version according to the game's language!"), urlForPatchDownload.c_str());
}
GUIErrorMessageWithURL(errorMessage, urlForPatchDownload.c_str());
error("%s not found", updateFilename);
}
}
if (g_grim->getGameType() == GType_GRIM) {
if (g_grim->getGameFlags() & ADGF_DEMO) {
SearchMan.listMatchingMembers(files, "gfdemo01.lab");
SearchMan.listMatchingMembers(files, "gdemo001.lab"); // For the english demo with video.
SearchMan.listMatchingMembers(files, "grimdemo.mus");
SearchMan.listMatchingMembers(files, "sound001.lab");
SearchMan.listMatchingMembers(files, "voice001.lab");
} else {
2020-11-01 13:10:09 +00:00
if (!SearchMan.hasFile("grim-patch.lab"))
error("%s", "grim-patch.lab not found");
2020-11-01 13:10:09 +00:00
SearchMan.listMatchingMembers(files, "grim-patch.lab");
SearchMan.listMatchingMembers(files, "data005.lab");
SearchMan.listMatchingMembers(files, "data004.lab");
SearchMan.listMatchingMembers(files, "data003.lab");
SearchMan.listMatchingMembers(files, "data002.lab");
SearchMan.listMatchingMembers(files, "data001.lab");
SearchMan.listMatchingMembers(files, "data000.lab");
SearchMan.listMatchingMembers(files, "movie??.lab");
SearchMan.listMatchingMembers(files, "vox????.lab");
SearchMan.listMatchingMembers(files, "year?mus.lab");
SearchMan.listMatchingMembers(files, "local.lab");
SearchMan.listMatchingMembers(files, "credits.lab");
SearchMan.listMatchingMembers(files, "rus_font.lab");
if (g_grim->isRemastered()) {
SearchMan.listMatchingMembers(files, "commentary.lab");
2015-02-05 04:53:33 +00:00
SearchMan.listMatchingMembers(files, "images.lab");
}
2022-06-07 23:12:00 +00:00
// Sort the archives in order to ensure that they are loaded with the correct order
Common::sort(files.begin(), files.end(), LabListComperator());
2022-06-07 23:12:00 +00:00
// Check the presence of datausr.lab and if the user wants to load it.
// In this case put it in the top of the list
2012-08-01 14:30:15 +00:00
const char *datausr_name = "datausr.lab";
if (SearchMan.hasFile(datausr_name) && ConfMan.getBool("datausr_load")) {
2020-10-09 17:04:07 +00:00
warning("%s", "Loading datausr.lab. Please note that the ScummVM team doesn't provide support for using such patches");
2012-08-01 14:30:15 +00:00
files.push_front(SearchMan.getMember(datausr_name));
}
}
} else if (g_grim->getGameType() == GType_MONKEY4) {
2020-11-01 13:10:09 +00:00
const char *emi_patches_filename = "monkey4-patch.m4b";
if (!SearchMan.hasFile(emi_patches_filename))
error("%s not found", emi_patches_filename);
SearchMan.listMatchingMembers(files, emi_patches_filename);
if (g_grim->getGameFlags() & ADGF_DEMO) {
SearchMan.listMatchingMembers(files, "lip.lab");
SearchMan.listMatchingMembers(files, "MagDemo.lab");
SearchMan.listMatchingMembers(files, "tile.lab");
SearchMan.listMatchingMembers(files, "voice.lab");
} else {
2022-06-07 23:12:00 +00:00
// Keep i9n.m4b before patch.m4b for a better efficiency
// in decompressing from Monkey Update.exe
SearchMan.listMatchingMembers(files, "i9n.m4b");
SearchMan.listMatchingMembers(files, "patch.m4b");
SearchMan.listMatchingMembers(files, "art???.m4b");
SearchMan.listMatchingMembers(files, "lip.m4b");
SearchMan.listMatchingMembers(files, "local.m4b");
SearchMan.listMatchingMembers(files, "sfx.m4b");
SearchMan.listMatchingMembers(files, "voice???.m4b");
SearchMan.listMatchingMembers(files, "music?.m4b");
if (g_grim->getGamePlatform() == Common::kPlatformPS2) {
SearchMan.listMatchingMembers(files, "???.m4b");
}
2022-06-07 23:12:00 +00:00
// Check the presence of datausr.m4b and if the user wants to load it.
// In this case put it in the top of the list
const char *datausr_name = "datausr.m4b";
if (SearchMan.hasFile(datausr_name) && ConfMan.getBool("datausr_load")) {
2020-10-09 17:04:07 +00:00
warning("%s", "Loading datausr.m4b. Please note that the ScummVM team doesn't provide support for using such patches");
files.push_front(SearchMan.getMember(datausr_name));
}
}
2008-08-01 18:27:11 +00:00
}
if (files.empty())
error("%s", "Cannot find game data - check configuration file");
2022-06-07 23:12:00 +00:00
// Load labs
int priority = -1;
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
Common::String filename = (*x)->getName();
filename.toLowercase();
2022-06-07 23:12:00 +00:00
// Avoid duplicates
if (SearchMan.hasArchive(filename))
continue;
l = new Lab();
// Caching "local.m4b" to speed up the launch of the mac version,
// we _COULD_ protect this with a platform check, but the file isn't
// really big anyhow...
bool useCache = (filename == "local.m4b");
if (l->open(filename, useCache))
SearchMan.add(filename, l, priority--, true);
else
delete l;
}
files.clear();
2003-08-15 18:00:22 +00:00
}
template<typename T>
void clearList(Common::List<T> &list) {
while (!list.empty()) {
T p = list.front();
list.erase(list.begin());
delete p;
}
}
ResourceLoader::~ResourceLoader() {
for (Common::Array<ResourceCache>::iterator i = _cache.begin(); i != _cache.end(); ++i) {
ResourceCache &r = *i;
delete[] r.fname;
delete[] r.resPtr;
}
clearList(_models);
clearList(_colormaps);
clearList(_keyframeAnims);
clearList(_lipsyncs);
MD5Check::clear();
}
2009-05-12 14:31:48 +00:00
static int sortCallback(const void *entry1, const void *entry2) {
2012-04-03 23:58:04 +00:00
return scumm_stricmp(((const ResourceLoader::ResourceCache *)entry1)->fname, ((const ResourceLoader::ResourceCache *)entry2)->fname);
2009-05-12 14:31:48 +00:00
}
Common::SeekableReadStream *ResourceLoader::getFileFromCache(const Common::String &filename) const {
2009-05-12 14:31:48 +00:00
ResourceLoader::ResourceCache *entry = getEntryFromCache(filename);
if (!entry)
2014-05-29 22:35:46 +00:00
return nullptr;
return new Common::MemoryReadStream(entry->resPtr, entry->len);
2009-05-12 14:31:48 +00:00
}
ResourceLoader::ResourceCache *ResourceLoader::getEntryFromCache(const Common::String &filename) const {
if (_cache.empty())
2014-05-29 22:35:46 +00:00
return nullptr;
2009-05-12 14:31:48 +00:00
if (_cacheDirty) {
qsort(_cache.begin(), _cache.size(), sizeof(ResourceCache), sortCallback);
_cacheDirty = false;
}
ResourceCache key;
key.fname = const_cast<char *>(filename.c_str());
2009-05-12 14:31:48 +00:00
return (ResourceLoader::ResourceCache *)bsearch(&key, _cache.begin(), _cache.size(), sizeof(ResourceCache), sortCallback);
}
Common::SeekableReadStream *ResourceLoader::loadFile(const Common::String &filename) const {
2014-05-29 22:35:46 +00:00
Common::SeekableReadStream *rs = nullptr;
if (SearchMan.hasFile(filename))
rs = SearchMan.createReadStreamForMember(filename);
else
2014-05-29 22:35:46 +00:00
return nullptr;
rs = wrapPatchedFile(rs, filename);
return rs;
}
Common::SeekableReadStream *ResourceLoader::openNewStreamFile(Common::String fname, bool cache) const {
Common::SeekableReadStream *s;
fname.toLowercase();
if (cache) {
s = getFileFromCache(fname);
if (!s) {
s = loadFile(fname);
if (!s)
2014-05-29 22:35:46 +00:00
return nullptr;
uint32 size = s->size();
byte *buf = new byte[size];
s->read(buf, size);
putIntoCache(fname, buf, size);
delete s;
s = new Common::MemoryReadStream(buf, size);
}
} else {
s = loadFile(fname);
}
// This will only have an effect if the stream is actually compressed.
return Common::wrapCompressedReadStream(s);
2003-08-15 18:00:22 +00:00
}
void ResourceLoader::putIntoCache(const Common::String &fname, byte *res, uint32 len) const {
2009-05-12 18:45:14 +00:00
ResourceCache entry;
entry.resPtr = res;
entry.len = len;
2009-05-12 18:45:14 +00:00
entry.fname = new char[fname.size() + 1];
Common::strcpy_s(entry.fname, fname.size() + 1, fname.c_str());
_cacheMemorySize += len;
2009-05-12 18:45:14 +00:00
_cache.push_back(entry);
_cacheDirty = true;
}
CMap *ResourceLoader::loadColormap(const Common::String &filename) {
Common::SeekableReadStream *stream = openNewStreamFile(filename.c_str());
if (!stream) {
error("Could not find colormap %s", filename.c_str());
2009-06-27 06:47:18 +00:00
}
2003-08-15 18:00:22 +00:00
CMap *result = new CMap(filename, stream);
_colormaps.push_back(result);
delete stream;
2009-05-12 14:31:48 +00:00
return result;
2003-08-15 18:00:22 +00:00
}
Common::String ResourceLoader::fixFilename(const Common::String &filename, bool append) {
Common::String fname(filename);
if (g_grim->getGameType() == GType_MONKEY4) {
int len = fname.size();
for (int i = 0; i < len; i++) {
if (fname[i] == '\\') {
fname.setChar('/', i);
}
}
// Append b to end of filename for EMI
if (append)
fname += "b";
}
return fname;
}
Costume *ResourceLoader::loadCostume(const Common::String &filename, Actor *owner, Costume *prevCost) {
Common::String fname = fixFilename(filename);
fname.toLowercase();
Common::SeekableReadStream *stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
error("Could not find costume \"%s\"", filename.c_str());
2009-06-27 06:47:18 +00:00
}
Costume *result;
if (g_grim->getGameType() == GType_MONKEY4) {
result = new EMICostume(filename, owner, prevCost);
} else {
result = new Costume(filename, owner, prevCost);
}
result->load(stream);
delete stream;
return result;
2003-08-15 18:00:22 +00:00
}
Font *ResourceLoader::loadFont(const Common::String &filename) {
Common::SeekableReadStream *stream;
if (g_grim->_overrideFont)
return g_grim->_overrideFont;
if (g_grim->getGameType() == GType_GRIM && g_grim->isRemastered()) {
2020-10-07 17:50:27 +00:00
Common::String name = "FontsHD/" + filename + ".txt";
stream = openNewStreamFile(name, true);
if (stream) {
Common::String line = stream->readLine();
Common::String font;
Common::String size;
for (uint i = 0; i < line.size(); ++i) {
2020-10-07 17:50:27 +00:00
if (line[i] == ' ') {
font = "FontsHD/" + Common::String(line.c_str(), i);
size = Common::String(line.c_str() + i + 1, line.size() - i - 2);
}
2015-02-01 23:36:56 +00:00
}
2020-10-07 17:50:27 +00:00
int s = atoi(size.c_str());
delete stream;
stream = openNewStreamFile(font.c_str(), true);
FontTTF *result = new FontTTF();
result->loadTTF(font, stream, s);
return result;
}
2015-02-01 23:36:56 +00:00
}
stream = openNewStreamFile(filename.c_str(), true);
if (!stream)
error("Could not find font file %s", filename.c_str());
BitmapFont *result = new BitmapFont();
2013-10-26 20:13:07 +00:00
result->load(filename, stream);
delete stream;
2009-05-12 14:31:48 +00:00
return result;
}
KeyframeAnim *ResourceLoader::loadKeyframe(const Common::String &filename) {
Common::SeekableReadStream *stream;
stream = openNewStreamFile(filename.c_str());
if (!stream)
error("Could not find keyframe file %s", filename.c_str());
2003-08-15 18:00:22 +00:00
KeyframeAnim *result = new KeyframeAnim(filename, stream);
_keyframeAnims.push_back(result);
delete stream;
2009-05-12 14:31:48 +00:00
return result;
2003-08-15 18:00:22 +00:00
}
LipSync *ResourceLoader::loadLipSync(const Common::String &filename) {
2009-04-21 18:04:24 +00:00
LipSync *result;
Common::SeekableReadStream *stream;
stream = openNewStreamFile(filename.c_str());
if (!stream)
2014-05-29 22:35:46 +00:00
return nullptr;
2009-05-09 17:47:28 +00:00
result = new LipSync(filename, stream);
2009-06-27 06:47:18 +00:00
// Some lipsync files have no data
if (result->isValid())
_lipsyncs.push_back(result);
else {
2009-06-27 06:47:18 +00:00
delete result;
2014-05-29 22:35:46 +00:00
result = nullptr;
2009-05-09 17:47:28 +00:00
}
delete stream;
return result;
}
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c, bool clamp) {
Common::String fname = fixFilename(filename, false);
fname.toLowercase();
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str(), true);
if (!stream && !filename.hasPrefix("specialty")) {
// FIXME: EMI demo references files that aren't included. Return a known material.
// This should be fixed in the data files instead.
if (g_grim->getGameType() == GType_MONKEY4 && g_grim->getGameFlags() & ADGF_DEMO) {
const Common::String replacement("fx/candle.sprb");
warning("Could not find material %s, using %s instead", filename.c_str(), replacement.c_str());
return loadMaterial(replacement, nullptr, clamp);
} else {
error("Could not find material %s", filename.c_str());
}
}
if (!stream) {
// Specialty materials are not loaded from files.
if (!filename.hasPrefix("specialty")) {
error("Couldn't open %s", fname.c_str());
}
}
2003-08-15 18:00:22 +00:00
Material *result = new Material(fname, stream, c, clamp);
delete stream;
2011-05-16 17:07:34 +00:00
return result;
2003-08-15 18:00:22 +00:00
}
Model *ResourceLoader::loadModel(const Common::String &filename, CMap *c, Model *parent) {
Common::String fname = fixFilename(filename);
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str());
if (!stream)
error("Could not find model %s", filename.c_str());
2003-08-15 18:00:22 +00:00
Model *result = new Model(filename, stream, c, parent);
_models.push_back(result);
delete stream;
2011-05-16 17:07:34 +00:00
2009-05-12 14:31:48 +00:00
return result;
}
EMIModel *ResourceLoader::loadModelEMI(const Common::String &filename, EMICostume *costume) {
Common::String fname = fixFilename(filename);
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str());
if (!stream) {
warning("Could not find model %s", filename.c_str());
2014-05-29 22:35:46 +00:00
return nullptr;
}
EMIModel *result = new EMIModel(filename, stream, costume);
_emiModels.push_back(result);
delete stream;
return result;
}
2011-12-30 14:10:32 +00:00
Skeleton *ResourceLoader::loadSkeleton(const Common::String &filename) {
Common::String fname = fixFilename(filename);
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
warning("Could not find skeleton %s", filename.c_str());
2014-05-29 22:35:46 +00:00
return nullptr;
2011-12-30 14:10:32 +00:00
}
Skeleton *result = new Skeleton(filename, stream);
delete stream;
2011-12-30 14:10:32 +00:00
return result;
}
Sprite *ResourceLoader::loadSprite(const Common::String &filename, EMICostume *costume) {
assert(g_grim->getGameType() == GType_MONKEY4);
Common::SeekableReadStream *stream;
const Common::String fname = fixFilename(filename, true);
stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
warning("Could not find sprite %s", fname.c_str());
2014-05-29 22:35:46 +00:00
return nullptr;
}
Sprite *result = new Sprite();
result->loadBinary(stream, costume);
delete stream;
return result;
}
AnimationEmi *ResourceLoader::loadAnimationEmi(const Common::String &filename) {
Common::String fname = fixFilename(filename);
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
warning("Could not find animation %s", filename.c_str());
2014-05-29 22:35:46 +00:00
return nullptr;
}
AnimationEmi *result = new AnimationEmi(filename, stream);
_emiAnims.push_back(result);
delete stream;
return result;
}
Overlay *ResourceLoader::loadOverlay(const Common::String &filename) {
Common::String fname = fixFilename(filename);
Common::SeekableReadStream *stream;
stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
warning("Could not find overlay %s", filename.c_str());
return nullptr;
}
Overlay *result = new Overlay(filename, stream);
delete stream;
return result;
}
void ResourceLoader::uncache(const char *filename) const {
2009-05-10 16:43:41 +00:00
Common::String fname = filename;
fname.toLowercase();
2009-05-12 14:31:48 +00:00
2009-05-12 18:47:34 +00:00
if (_cacheDirty) {
2009-05-12 14:31:48 +00:00
qsort(_cache.begin(), _cache.size(), sizeof(ResourceCache), sortCallback);
2009-05-12 18:47:34 +00:00
_cacheDirty = false;
}
2009-05-12 14:31:48 +00:00
for (unsigned int i = 0; i < _cache.size(); i++) {
if (fname.compareTo(_cache[i].fname) == 0) {
delete[] _cache[i].fname;
_cacheMemorySize -= _cache[i].len;
delete[] _cache[i].resPtr;
2009-05-12 14:31:48 +00:00
_cache.remove_at(i);
_cacheDirty = true;
}
}
2003-08-15 18:00:22 +00:00
}
2009-05-25 06:49:57 +00:00
void ResourceLoader::uncacheModel(Model *m) {
_models.remove(m);
}
void ResourceLoader::uncacheColormap(CMap *c) {
_colormaps.remove(c);
}
void ResourceLoader::uncacheKeyframe(KeyframeAnim *k) {
_keyframeAnims.remove(k);
}
void ResourceLoader::uncacheLipSync(LipSync *s) {
_lipsyncs.remove(s);
}
void ResourceLoader::uncacheAnimationEmi(AnimationEmi *a) {
_emiAnims.remove(a);
}
ModelPtr ResourceLoader::getModel(const Common::String &fname, CMap *c) {
Common::String filename = fname;
filename.toLowercase();
for (Common::List<Model *>::const_iterator i = _models.begin(); i != _models.end(); ++i) {
Model *m = *i;
2012-04-25 00:21:18 +00:00
if (filename == m->getFilename() && *m->getCMap() == *c) {
return m;
}
}
return loadModel(fname, c);
}
CMapPtr ResourceLoader::getColormap(const Common::String &fname) {
Common::String filename = fname;
filename.toLowercase();
for (Common::List<CMap *>::const_iterator i = _colormaps.begin(); i != _colormaps.end(); ++i) {
CMap *c = *i;
if (filename.equals(c->_fname)) {
return c;
}
}
return loadColormap(fname);
}
KeyframeAnimPtr ResourceLoader::getKeyframe(const Common::String &fname) {
Common::String filename = fname;
filename.toLowercase();
for (Common::List<KeyframeAnim *>::const_iterator i = _keyframeAnims.begin(); i != _keyframeAnims.end(); ++i) {
KeyframeAnim *k = *i;
if (filename == k->getFilename()) {
return k;
}
}
return loadKeyframe(fname);
}
LipSyncPtr ResourceLoader::getLipSync(const Common::String &fname) {
Common::String filename = fname;
filename.toLowercase();
for (Common::List<LipSync *>::const_iterator i = _lipsyncs.begin(); i != _lipsyncs.end(); ++i) {
LipSync *l = *i;
if (filename == l->getFilename()) {
return l;
}
}
return loadLipSync(fname);
}
AnimationEmiPtr ResourceLoader::getAnimationEmi(const Common::String &fname) {
Common::String filename = fname;
filename.toLowercase();
for (Common::List<AnimationEmi *>::const_iterator i = _emiAnims.begin(); i != _emiAnims.end(); ++i) {
AnimationEmi *a = *i;
if (filename == a->getFilename()) {
return a;
}
}
return loadAnimationEmi(fname);
}
2009-05-25 06:49:57 +00:00
} // end of namespace Grim