diff options
author | Vicent Marti | 2008-10-18 01:27:33 +0000 |
---|---|---|
committer | Vicent Marti | 2008-10-18 01:27:33 +0000 |
commit | 46b036ab6aea23319ac4a3fdfb0faa13bc3cc3dd (patch) | |
tree | c1951b62b6f2a455ef06a4b5e0e72eb823fbdcd4 /graphics | |
parent | 3644910f0d7d0ccf09b9453e8a9d8898c668b870 (diff) | |
download | scummvm-rg350-46b036ab6aea23319ac4a3fdfb0faa13bc3cc3dd.tar.gz scummvm-rg350-46b036ab6aea23319ac4a3fdfb0faa13bc3cc3dd.tar.bz2 scummvm-rg350-46b036ab6aea23319ac4a3fdfb0faa13bc3cc3dd.zip |
ImageManager: Added support for generic archives (zips and folders).
Theme Font Loading: Added support for generic archives.
ThemeEngine: Removed dependency on Common::File and File::AddDefaultPath for image and font loading.
svn-id: r34815
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/imageman.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/graphics/imageman.cpp b/graphics/imageman.cpp index 44ac7c9e75..1a7bcdefd1 100644 --- a/graphics/imageman.cpp +++ b/graphics/imageman.cpp @@ -46,19 +46,33 @@ ImageManager::~ImageManager() { } bool ImageManager::addArchive(const Common::String &name) { + Common::Archive *arch = 0; + + if (name.hasSuffix(".zip")) { #ifdef USE_ZLIB - Common::ZipArchive *arch = new Common::ZipArchive(name); - if (!arch || !arch->isOpen()) + Common::ZipArchive *zip = new Common::ZipArchive(name); + if (!zip || !zip->isOpen()) + return false; + + arch = zip; +#else return false; - _archives.add(name, Common::ArchivePtr(arch)); #endif + } else { + Common::FSDirectory *dir = new Common::FSDirectory(name); + if (!dir || !dir->getFSNode().isDirectory()) + return false; + + arch = dir; + } + + _archives.add(name, Common::ArchivePtr(arch)); return true; } void ImageManager::removeArchive(const Common::String &name) { -#ifdef USE_ZLIB - _archives.remove(name); -#endif + if (_archives.hasArchive(name)) + _archives.remove(name); } bool ImageManager::registerSurface(const Common::String &name, Surface *surf) { @@ -73,7 +87,6 @@ bool ImageManager::registerSurface(const Common::String &name, Surface *surf) { if (!surf) surf = ImageDecoder::loadFile(name); -#ifdef USE_ZLIB if (!surf) { Common::SeekableReadStream *stream = _archives.openFile(name); if (stream) { @@ -81,7 +94,6 @@ bool ImageManager::registerSurface(const Common::String &name, Surface *surf) { delete stream; } } -#endif if (!surf) return false; |