[Scummvm-cvs-logs] SF.net SVN: scummvm:[34772] scummvm/trunk/gui
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Oct 11 23:39:24 CEST 2008
Revision: 34772
http://scummvm.svn.sourceforge.net/scummvm/?rev=34772&view=rev
Author: fingolfin
Date: 2008-10-11 21:39:24 +0000 (Sat, 11 Oct 2008)
Log Message:
-----------
Some cleanup (in particular: do not convert String -> char * -> String needlessly) & code unification (thanks to Common::Archive, regular files and those in .zip files can both be accessed via Common::File)
Modified Paths:
--------------
scummvm/trunk/gui/ThemeEngine.cpp
scummvm/trunk/gui/theme.cpp
scummvm/trunk/gui/theme.h
Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp 2008-10-11 21:37:15 UTC (rev 34771)
+++ scummvm/trunk/gui/ThemeEngine.cpp 2008-10-11 21:39:24 UTC (rev 34772)
@@ -411,7 +411,7 @@
_texts[textId]->_fontPtr = FontMan.getFontByName(file);
if (!_texts[textId]->_fontPtr) {
- _texts[textId]->_fontPtr = loadFont(file.c_str());
+ _texts[textId]->_fontPtr = loadFont(file);
if (!_texts[textId]->_fontPtr)
error("Couldn't load %s font '%s'", fontId.c_str(), file.c_str());
@@ -473,8 +473,7 @@
if (fileName == "builtin") {
if (!loadDefaultXML())
error("Could not load default embeded theme");
- }
- else if (!loadThemeXML(fileName)) {
+ } else if (!loadThemeXML(fileName)) {
warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str());
if (!loadDefaultXML()) // if we can't load the embeded theme, this is a complete failure
@@ -545,7 +544,7 @@
if (zipFile.isOpen() && zipFile.listMembers(zipContents)) {
for (Common::ArchiveMemberList::iterator za = zipContents.begin(); za != zipContents.end(); ++za) {
- if (!failed && matchString((*za)->getName().c_str(), "*.stx")) {
+ if (!failed && (*za)->getName().hasSuffix(".stx")) {
if (parser()->loadStream((*za)->open()) == false) {
warning("Failed to load stream for zipped file '%s'", fileNameBuffer);
failed = true;
@@ -562,7 +561,7 @@
Common::SeekableReadStream *stream = (*za)->open();
stxHeader = stream->readLine();
- if (!themeConfigParseHeader(stxHeader.c_str(), _themeName)) {
+ if (!themeConfigParseHeader(stxHeader, _themeName)) {
warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
failed = true;
}
@@ -601,7 +600,7 @@
f.open(*i);
stxHeader = f.readLine();
- if (!themeConfigParseHeader(stxHeader.c_str(), _themeName)) {
+ if (!themeConfigParseHeader(stxHeader, _themeName)) {
warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
failed = true;
}
Modified: scummvm/trunk/gui/theme.cpp
===================================================================
--- scummvm/trunk/gui/theme.cpp 2008-10-11 21:37:15 UTC (rev 34771)
+++ scummvm/trunk/gui/theme.cpp 2008-10-11 21:39:24 UTC (rev 34772)
@@ -33,9 +33,9 @@
Theme::~Theme() {}
-const Graphics::Font *Theme::loadFont(const char *filename) {
+const Graphics::Font *Theme::loadFont(const Common::String &filename) {
const Graphics::NewFont *font = 0;
- Common::String cacheFilename = genCacheFilename(filename);
+ Common::String cacheFilename = genCacheFilename(filename.c_str());
Common::File fontFile;
if (!cacheFilename.empty()) {
@@ -45,7 +45,7 @@
return font;
#ifdef USE_ZLIB
- Common::ZipArchive zipArchive(getThemeFileName().c_str());
+ Common::ZipArchive zipArchive(getThemeFileName());
Common::SeekableReadStream *stream(zipArchive.openFile(cacheFilename));
if (stream) {
font = Graphics::NewFont::loadFromCache(*stream);
@@ -63,7 +63,7 @@
#ifdef USE_ZLIB
if (!font) {
- Common::ZipArchive zipArchive(getThemeFileName().c_str());
+ Common::ZipArchive zipArchive(getThemeFileName());
Common::SeekableReadStream *stream(zipArchive.openFile(filename));
if (stream) {
@@ -76,7 +76,7 @@
if (font) {
if (!cacheFilename.empty()) {
if (!Graphics::NewFont::cacheFontData(*font, cacheFilename)) {
- warning("Couldn't create cache file for font '%s'", filename);
+ warning("Couldn't create cache file for font '%s'", filename.c_str());
}
}
}
@@ -133,36 +133,27 @@
}
bool Theme::themeConfigUseable(const Common::FSNode &node, Common::String &themeName) {
- Common::String stxHeader;
+ Common::File stream;
bool foundHeader = false;
if (node.getName().hasSuffix(".zip")) {
#ifdef USE_ZLIB
Common::ZipArchive zipArchive(node);
if (zipArchive.hasFile("THEMERC")) {
- Common::File stream;
stream.open("THEMERC", zipArchive);
- stxHeader = stream.readLine();
- // TODO: Read first line of file. How?
- if (themeConfigParseHeader(stxHeader.c_str(), themeName))
- foundHeader = true;
}
-#else
- return false;
#endif
-
} else if (node.isDirectory()) {
Common::FSNode headerfile = node.getChild("THEMERC");
if (!headerfile.exists() || !headerfile.isReadable() || headerfile.isDirectory())
return false;
-
- // TODO: File or FilePtr?
- Common::File f;
- f.open(headerfile);
- stxHeader = f.readLine();
- if (themeConfigParseHeader(stxHeader.c_str(), themeName))
- foundHeader = true;
+ stream.open(headerfile);
}
+
+ if (stream.isOpen()) {
+ Common::String stxHeader = stream.readLine();
+ foundHeader = themeConfigParseHeader(stxHeader, themeName);
+ }
return foundHeader;
}
Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h 2008-10-11 21:37:15 UTC (rev 34771)
+++ scummvm/trunk/gui/theme.h 2008-10-11 21:39:24 UTC (rev 34772)
@@ -334,9 +334,9 @@
* @see kThemeImages
*/
virtual const Graphics::Surface *getImageSurface(const kThemeImages n) const { return 0; }
-protected:
- const Graphics::Font *loadFont(const char *filename);
+protected:
+ const Graphics::Font *loadFont(const Common::String &filename);
Common::String genCacheFilename(const char *filename);
public:
@@ -344,7 +344,6 @@
(_loadedThemeY != g_system->getOverlayHeight())); }
private:
- static const char *_defaultConfigINI;
int _loadedThemeX, _loadedThemeY;
};
} // end of namespace GUI
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list