aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorVicent Marti2008-08-16 14:06:26 +0000
committerVicent Marti2008-08-16 14:06:26 +0000
commit5201a46054a1390739b21532c45e0e9926b857bc (patch)
tree12c2981126b18c16a5acb430cb951ba6ef554621 /gui
parent146be8e16b0abd43f87274a305d9d65b594d1d7f (diff)
downloadscummvm-rg350-5201a46054a1390739b21532c45e0e9926b857bc.tar.gz
scummvm-rg350-5201a46054a1390739b21532c45e0e9926b857bc.tar.bz2
scummvm-rg350-5201a46054a1390739b21532c45e0e9926b857bc.zip
Added support for loading uncompressed/unpackaged themes.
svn-id: r33941
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeRenderer.cpp36
-rw-r--r--gui/newgui.cpp4
-rw-r--r--gui/theme.cpp61
-rw-r--r--gui/theme.h2
-rw-r--r--gui/themebrowser.cpp43
-rw-r--r--gui/themes/scummclassic.zipbin40158 -> 40158 bytes
-rw-r--r--gui/themes/scummodern.zipbin122840 -> 122841 bytes
7 files changed, 100 insertions, 46 deletions
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 5f12cf3fd4..c272de96f9 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -191,7 +191,10 @@ void ThemeRenderer::unloadTheme() {
for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
ImageMan.unregisterSurface(i->_key);
- ImageMan.remArchive(_themeFileName);
+ if (_themeFileName.hasSuffix(".zip"))
+ ImageMan.remArchive(_themeFileName);
+
+ Common::File::resetDefaultDirectories();
_themeEval->reset();
_themeOk = false;
@@ -370,7 +373,10 @@ bool ThemeRenderer::loadTheme(Common::String fileName) {
if (ConfMan.hasKey("extrapath"))
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
- ImageMan.addArchive(fileName);
+ if (fileName.hasSuffix(".zip"))
+ ImageMan.addArchive(fileName);
+ else
+ Common::File::addDefaultDirectory(fileName);
}
if (fileName == "builtin") {
@@ -429,10 +435,11 @@ bool ThemeRenderer::loadThemeXML(Common::String themeName) {
_themeName.clear();
char fileNameBuffer[32];
+ char stxHeader[128];
int parseCount = 0;
#ifdef USE_ZLIB
- unzFile zipFile = unzOpen(themeName.c_str());
+ unzFile zipFile = unzOpen((themeName).c_str());
if (zipFile && unzGoToFirstFile(zipFile) == UNZ_OK) {
while (true) {
@@ -449,11 +456,12 @@ bool ThemeRenderer::loadThemeXML(Common::String themeName) {
Common::MemoryReadStream *stream = new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true);
if (!strcmp(fileNameBuffer, "THEMERC")) {
- char stxHeader[128];
stream->readLine(stxHeader, 128);
- if (!themeConfigParseHeader(stxHeader, _themeName))
- error("Corrupted 'THEMERC' file");
+ if (!themeConfigParseHeader(stxHeader, _themeName)) {
+ warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
+ return false;
+ }
delete stream;
@@ -484,13 +492,23 @@ bool ThemeRenderer::loadThemeXML(Common::String themeName) {
for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
if (i->getName().hasSuffix(".stx")) {
+ parseCount++;
+ if (parser()->loadFile(*i) == false || parser()->parse() == false) {
+ warning("Failed to parse STX file '%s'", i->getName().c_str());
+ return false;
+ }
} else if (i->getName() == "THEMERC") {
-
+ Common::File f;
+ f.open(*i);
+ f.readLine(stxHeader, 128);
+
+ if (!themeConfigParseHeader(stxHeader, _themeName)) {
+ warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
+ return false;
+ }
}
-
}
-
}
#ifdef USE_ZLIB
}
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index fc781f731d..2291d9e3c1 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -92,8 +92,8 @@ NewGui::NewGui() : _redrawStatus(kRedrawDisabled),
if (themefile.compareToIgnoreCase("default") == 0)
themefile = "builtin";
- if (themefile != "builtin" && !themefile.hasSuffix(".zip"))
- themefile += ".zip";
+// if (themefile != "builtin" && !themefile.hasSuffix(".zip"))
+// themefile += ".zip";
ConfMan.registerDefault("gui_renderer", 2);
ThemeRenderer::GraphicsMode gfxMode = (ThemeRenderer::GraphicsMode)ConfMan.getInt("gui_renderer");
diff --git a/gui/theme.cpp b/gui/theme.cpp
index 45fc047c45..3a6280ab95 100644
--- a/gui/theme.cpp
+++ b/gui/theme.cpp
@@ -23,6 +23,7 @@
*/
#include "gui/theme.h"
+#include "common/fs.h"
#include "common/unzip.h"
namespace GUI {
@@ -153,7 +154,10 @@ bool Theme::themeConfigParseHeader(Common::String header, Common::String &themeN
return tok.empty();
}
-bool Theme::themeConfigUseable(const Common::String &filename, Common::String &themeName) {
+bool Theme::themeConfigUseable(const FilesystemNode &node, Common::String &themeName) {
+ char stxHeader[128];
+ bool foundHeader = false;
+
if (ConfMan.hasKey("themepath"))
Common::File::addDefaultDirectory(ConfMan.get("themepath"));
@@ -164,38 +168,47 @@ bool Theme::themeConfigUseable(const Common::String &filename, Common::String &t
if (ConfMan.hasKey("extrapath"))
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
+ if (node.getName().hasSuffix(".zip")) {
#ifdef USE_ZLIB
- unzFile zipFile = unzOpen(filename.c_str());
- char stxHeader[128];
- bool foundHeader = false;
+ unzFile zipFile = unzOpen(node.getPath().c_str());
- if (zipFile && unzLocateFile(zipFile, "THEMERC", 2) == UNZ_OK) {
- 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(buffer, fileInfo.uncompressed_size+1);
- stream.readLine(stxHeader, 128);
+ if (zipFile && unzLocateFile(zipFile, "THEMERC", 2) == UNZ_OK) {
+ 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(buffer, fileInfo.uncompressed_size+1);
+ stream.readLine(stxHeader, 128);
- if (themeConfigParseHeader(stxHeader, themeName))
- foundHeader = true;
+ if (themeConfigParseHeader(stxHeader, themeName))
+ foundHeader = true;
- delete[] buffer;
- buffer = 0;
- }
- unzClose(zipFile);
+ delete[] buffer;
+ buffer = 0;
+ }
+ unzClose(zipFile);
#else
- return false;
+ return false;
#endif
+ } else if (node.isDirectory()) {
+ FilesystemNode headerfile = node.getChild("THEMERC");
+ if (!headerfile.exists() || !headerfile.isReadable() || headerfile.isDirectory())
+ return false;
+
+ Common::File f;
+ f.open(headerfile);
+ f.readLine(stxHeader, 128);
+
+ if (themeConfigParseHeader(stxHeader, themeName))
+ foundHeader = true;
+ }
return foundHeader;
}
-
-
} // End of namespace GUI
diff --git a/gui/theme.h b/gui/theme.h
index f4709067ef..50b2951ae5 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -305,7 +305,7 @@ public:
bool isThemeLoadingRequired();
virtual ThemeEval *evaluator() = 0;
- static bool themeConfigUseable(const Common::String &file, Common::String &themeName);
+ static bool themeConfigUseable(const FilesystemNode &node, Common::String &themeName);
static bool themeConfigParseHeader(Common::String header, Common::String &themeName);
virtual const Common::String &getThemeFileName() const = 0;
diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp
index 490248619b..dd15742258 100644
--- a/gui/themebrowser.cpp
+++ b/gui/themebrowser.cpp
@@ -146,16 +146,34 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) {
return;
FSList fslist;
- if (!node.getChildren(fslist, FilesystemNode::kListAll))
- return;
-
- for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
- if (i->isDirectory()) {
- addDir(list, i->getPath(), level-1);
- } else {
+
+#ifdef USE_ZLIB
+ if (node.lookupFile(fslist, "*.zip", false, true, 0)) {
+ for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
Entry th;
if (isTheme(*i, th)) {
bool add = true;
+
+ for (ThList::const_iterator p = list.begin(); p != list.end(); ++p) {
+ if (p->name == th.name || p->file == th.file) {
+ add = false;
+ break;
+ }
+ }
+
+ if (add)
+ list.push_back(th);
+ }
+ }
+ }
+#endif
+
+ if (node.lookupFile(fslist, "THEMERC", false, true, 1)) {
+ for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
+ Entry th;
+ if (isTheme(i->getParent(), th)) {
+ bool add = true;
+
for (ThList::const_iterator p = list.begin(); p != list.end(); ++p) {
if (p->name == th.name || p->file == th.file) {
add = false;
@@ -171,12 +189,17 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) {
}
bool ThemeBrowser::isTheme(const FilesystemNode &node, Entry &out) {
- out.file = node.getName();
+ out.file = node.getName();
- if (!out.file.hasSuffix(".zip"))
+#ifdef USE_ZLIB
+ if (!out.file.hasSuffix(".zip") && !node.isDirectory())
return false;
+#else
+ if (!node.isDirectory())
+ return false;
+#endif
- if (!Theme::themeConfigUseable(out.file, out.name))
+ if (!Theme::themeConfigUseable(node, out.name))
return false;
return true;
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 3211ca2cd9..4015f24b93 100644
--- a/gui/themes/scummclassic.zip
+++ b/gui/themes/scummclassic.zip
Binary files differ
diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip
index ff08f25dd3..a6c3c31625 100644
--- a/gui/themes/scummodern.zip
+++ b/gui/themes/scummodern.zip
Binary files differ