diff options
author | Vicent Marti | 2008-08-13 12:08:14 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-13 12:08:14 +0000 |
commit | 0dcfb38d49e60881c5727ff8ec4d806f339ab696 (patch) | |
tree | 678d92a53a76a7cc4fadac7ebb9895f852716f3c | |
parent | 0bf21870392dfb15ed11613409445c8ec64f3ffa (diff) | |
download | scummvm-rg350-0dcfb38d49e60881c5727ff8ec4d806f339ab696.tar.gz scummvm-rg350-0dcfb38d49e60881c5727ff8ec4d806f339ab696.tar.bz2 scummvm-rg350-0dcfb38d49e60881c5727ff8ec4d806f339ab696.zip |
Improved theme loading.
Added support for multiple STX files.
svn-id: r33824
-rw-r--r-- | gui/ThemeRenderer.cpp | 67 | ||||
-rw-r--r-- | gui/themes/scummodern.zip | bin | 137193 -> 116190 bytes |
2 files changed, 38 insertions, 29 deletions
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index 9f517abd2d..3cb7f13dbd 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -412,43 +412,52 @@ bool ThemeRenderer::loadDefaultXML() { bool ThemeRenderer::loadThemeXML(Common::String themeName) { assert(_parser); - - if (!parser()->loadFile(themeName + ".stx")){ + #ifdef USE_ZLIB - unzFile zipFile = unzOpen((themeName + ".zip").c_str()); - - if (zipFile && unzLocateFile(zipFile, (themeName + ".stx").c_str(), 2) == UNZ_OK) { - + unzFile zipFile = unzOpen((themeName + ".zip").c_str()); + char fileNameBuffer[32]; + int parseCount = 0; + + if (zipFile && unzGoToFirstFile(zipFile) == UNZ_OK) { + while (true) { unz_file_info fileInfo; unzOpenCurrentFile(zipFile); - unzGetCurrentFileInfo(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0); - uint8 *buffer = new uint8[fileInfo.uncompressed_size+1]; - assert(buffer); - memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8)); - unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size); - unzCloseCurrentFile(zipFile); - - Common::MemoryReadStream *stream = new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true); + unzGetCurrentFileInfo(zipFile, &fileInfo, fileNameBuffer, 32, NULL, 0, NULL, 0); + + if (matchString(fileNameBuffer, "*.stx")) { + uint8 *buffer = new uint8[fileInfo.uncompressed_size+1]; + assert(buffer); + memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8)); + unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size); - if (!parser()->loadStream(stream)) { - unzClose(zipFile); - delete stream; - return false; + Common::MemoryReadStream *stream = new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true); + + if (parser()->loadStream(stream) == false || parser()->parse() == false) { + warning("Failed to load stream for %s", fileNameBuffer); + unzClose(zipFile); + delete stream; + return false; + } + + parseCount++; } - -// delete[] buffer; - buffer = 0; - } else { - unzClose(zipFile); - return false; + + unzCloseCurrentFile(zipFile); + + if (unzGoToNextFile(zipFile) == UNZ_END_OF_LIST_OF_FILE) + break; } - unzClose(zipFile); -#else - return false; -#endif + } else if (parser()->loadFile(themeName + ".stx") && parser()->parse()) { + parseCount++; + } else { + warning("No theme files for '%s' found.", themeName.c_str()); } - return parser()->parse(); + unzClose(zipFile); + return (parseCount > 0); +#else + return (parser()->loadFile(themeName + ".stx") && parser()->parse()); +#endif } bool ThemeRenderer::isWidgetCached(DrawData type, const Common::Rect &r) { diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip Binary files differindex a607166b47..3f23dde775 100644 --- a/gui/themes/scummodern.zip +++ b/gui/themes/scummodern.zip |