[Scummvm-cvs-logs] SF.net SVN: scummvm:[35636] scummvm/trunk/gui
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Dec 31 16:07:31 CET 2008
Revision: 35636
http://scummvm.svn.sourceforge.net/scummvm/?rev=35636&view=rev
Author: fingolfin
Date: 2008-12-31 15:07:30 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
ThemeEngine:
* more cleanup, esp. of Doxygen comments
* completely got rid of ImageMan, instead use the same Common::Archive to load bitmaps and XML data from
Modified Paths:
--------------
scummvm/trunk/gui/ThemeEngine.cpp
scummvm/trunk/gui/ThemeEngine.h
Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp 2008-12-31 15:03:17 UTC (rev 35635)
+++ scummvm/trunk/gui/ThemeEngine.cpp 2008-12-31 15:07:30 UTC (rev 35636)
@@ -33,7 +33,7 @@
#include "graphics/surface.h"
#include "graphics/colormasks.h"
-#include "graphics/imageman.h"
+#include "graphics/imagedec.h"
#include "graphics/cursorman.h"
#include "graphics/VectorRenderer.h"
@@ -72,6 +72,7 @@
_graphicsMode = mode;
_themeFileName = fileName;
+ _themeArchive = 0;
_initOk = false;
}
@@ -81,17 +82,10 @@
delete _parser;
delete _themeEval;
delete[] _cursor;
-
- for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
- ImageMan.unregisterSurface(i->_key);
-
- ImageMan.removeArchive(_themeFileName);
}
-
-
/**********************************************************
* Rendering mode management
*********************************************************/
@@ -192,11 +186,19 @@
_texts[i] = 0;
}
- for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
- ImageMan.unregisterSurface(i->_key);
+ // Release all graphics surfaces
+ for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
+ Graphics::Surface *surf = i->_value;
+ if (surf) {
+ surf->free();
+ delete surf;
+ }
+ }
+ _bitmaps.clear();
+
+ delete _themeArchive;
+ _themeArchive = 0;
- ImageMan.removeArchive(_themeFileName);
-
_themeEval->reset();
_themeOk = false;
}
@@ -387,13 +389,27 @@
}
bool ThemeEngine::addBitmap(const Common::String &filename) {
- if (_bitmaps.contains(filename))
- ImageMan.unregisterSurface(filename);
+ // Release any existing surface with that name.
+ Graphics::Surface *surf = _bitmaps[filename];
+ if (surf) {
+ surf->free();
+ delete surf;
+ }
+
+ // Now try to load the bitmap via the ImageDecoder class.
+ surf = Graphics::ImageDecoder::loadFile(filename);
+ if (!surf && _themeArchive) {
+ Common::SeekableReadStream *stream = _themeArchive->openFile(filename);
+ if (stream) {
+ surf = Graphics::ImageDecoder::loadFile(*stream);
+ delete stream;
+ }
+ }
- ImageMan.registerSurface(filename, 0);
- _bitmaps[filename] = ImageMan.getSurface(filename);
-
- return _bitmaps[filename] != 0;
+ // Store the surface into our hashmap (attention, may store NULL entries!)
+ _bitmaps[filename] = surf;
+
+ return surf != 0;
}
bool ThemeEngine::addDrawData(const Common::String &data, bool cached) {
@@ -423,7 +439,7 @@
bool tryAgain = false;
if (fileName != "builtin") {
- ImageMan.addArchive(fileName);
+ // Load the archive containing image and XML data
if (!loadThemeXML(fileName)) {
warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str());
tryAgain = true; // Fall back to default builtin theme
@@ -530,11 +546,14 @@
return false;
}
+ _themeArchive = archive;
+
// Loop over all STX files
for (Common::ArchiveMemberList::iterator i = members.begin(); i != members.end(); ++i) {
assert((*i)->getName().hasSuffix(".stx"));
if (_parser->loadStream((*i)->open()) == false) {
+ _themeArchive = 0;
delete archive;
warning("Failed to load STX file '%s'", (*i)->getDisplayName().c_str());
_parser->close();
@@ -542,6 +561,7 @@
}
if (_parser->parse() == false) {
+ _themeArchive = 0;
delete archive;
warning("Failed to parse STX file '%s'", (*i)->getDisplayName().c_str());
_parser->close();
@@ -551,7 +571,6 @@
_parser->close();
}
- delete archive;
assert(!_themeName.empty());
return true;
}
Modified: scummvm/trunk/gui/ThemeEngine.h
===================================================================
--- scummvm/trunk/gui/ThemeEngine.h 2008-12-31 15:03:17 UTC (rev 35635)
+++ scummvm/trunk/gui/ThemeEngine.h 2008-12-31 15:07:30 UTC (rev 35636)
@@ -135,10 +135,12 @@
kTextDataMAX
};
- static const struct TextDataInfo {
+ struct TextDataInfo {
TextData id;
const char *name;
- } kTextDataDefaults[];
+ };
+
+ static const TextDataInfo kTextDataDefaults[];
public:
//! Vertical alignment of the text.
@@ -268,9 +270,8 @@
void updateScreen();
- /**
- * FONT MANAGEMENT METHODS
- */
+ /** @name FONT MANAGEMENT METHODS */
+ //@{
TextData fontStyleToData(FontStyle font) const {
if (font == kFontStyleNormal)
@@ -286,10 +287,12 @@
int getCharWidth(byte c, FontStyle font = kFontStyleBold) const;
+ //@}
- /**
- * WIDGET DRAWING METHODS
- */
+
+ /** @name WIDGET DRAWING METHODS */
+ //@{
+
void drawWidgetBackground(const Common::Rect &r, uint16 hints,
WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
@@ -326,6 +329,10 @@
void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled);
+ //@}
+
+
+
/**
* Actual implementation of a Dirty Rect drawing routine.
* Dirty rectangles are queued on a list and are later merged/calculated
@@ -657,6 +664,7 @@
Common::String _themeName; //!< Name of the currently loaded theme
Common::String _themeFileName;
+ Common::Archive *_themeArchive;
/** Custom Cursor Management */
void setUpCursor();
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