[Scummvm-cvs-logs] SF.net SVN: scummvm:[33832] scummvm/branches/gsoc2008-gui/gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Wed Aug 13 18:50:52 CEST 2008
Revision: 33832
http://scummvm.svn.sourceforge.net/scummvm/?rev=33832&view=rev
Author: Tanoku
Date: 2008-08-13 16:50:50 +0000 (Wed, 13 Aug 2008)
Log Message:
-----------
Massive API cleanup (removed legacy code).
Improved theme loading support.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
scummvm/branches/gsoc2008-gui/gui/module.mk
scummvm/branches/gsoc2008-gui/gui/newgui.cpp
scummvm/branches/gsoc2008-gui/gui/newgui.h
scummvm/branches/gsoc2008-gui/gui/theme-config.cpp
scummvm/branches/gsoc2008-gui/gui/theme.cpp
scummvm/branches/gsoc2008-gui/gui/theme.h
scummvm/branches/gsoc2008-gui/gui/themes/scummodern.zip
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-13 16:50:50 UTC (rev 33832)
@@ -433,7 +433,7 @@
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);
+ warning("Failed to load stream for zipped file '%s'", fileNameBuffer);
unzClose(zipFile);
delete stream;
return false;
@@ -444,7 +444,7 @@
unzCloseCurrentFile(zipFile);
- if (unzGoToNextFile(zipFile) == UNZ_END_OF_LIST_OF_FILE)
+ if (unzGoToNextFile(zipFile) != UNZ_OK)
break;
}
} else if (parser()->loadFile(themeName + ".stx") && parser()->parse()) {
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h 2008-08-13 16:50:50 UTC (rev 33832)
@@ -453,11 +453,10 @@
* Finishes buffering: widgets from there one will be drawn straight on the screen
* without drawing queues.
*/
- void finishBuffering() {
- _buffering = false;
- }
+ void finishBuffering() { _buffering = false; }
+ void startBuffering() { _buffering = true; }
- void *evaluator() { return _themeEval; }
+ ThemeEval *evaluator() { return _themeEval; }
bool supportsImages() const { return true; }
bool ownCursor() const { return _useCursor; }
Modified: scummvm/branches/gsoc2008-gui/gui/module.mk
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/module.mk 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/module.mk 2008-08-13 16:50:50 UTC (rev 33832)
@@ -25,10 +25,7 @@
widget.o \
theme.o \
ThemeEval.o \
- ThemeClassic.o \
- ThemeModern.o \
- ThemeParser.o \
- theme-config.o
+ ThemeParser.o
# Include common rules
include $(srcdir)/rules.mk
Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp 2008-08-13 16:50:50 UTC (rev 33832)
@@ -93,16 +93,11 @@
ConfMan.registerDefault("gui_theme", "default");
- Common::String style(ConfMan.get("gui_theme"));
- if (style.compareToIgnoreCase("default") == 0)
- style = "builtin";
-
- //DEBUG:
-// style = "scummodern";
+ Common::String themefile(ConfMan.get("gui_theme"));
+ if (themefile.compareToIgnoreCase("default") == 0)
+ themefile = "builtin";
- loadNewTheme(style);
-
- _theme->resetDrawArea();
+ loadNewTheme(themefile);
_themeChange = false;
}
@@ -130,7 +125,6 @@
return (!oldTheme.empty() ? loadNewTheme(oldTheme) : false);
_theme->init();
- _theme->resetDrawArea();
if (!oldTheme.empty())
screenChange();
Modified: scummvm/branches/gsoc2008-gui/gui/newgui.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.h 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.h 2008-08-13 16:50:50 UTC (rev 33832)
@@ -79,8 +79,7 @@
bool loadNewTheme(const Common::String &file);
Theme *theme() { return _theme; }
- Eval *evaluator() { return _theme->_evaluator; }
- ThemeEval *xmlEval() { return (ThemeEval*)_theme->evaluator(); }
+ ThemeEval *xmlEval() { return _theme->evaluator(); }
const Graphics::Font &getFont(Theme::FontStyle style = Theme::kFontStyleBold) const { return *(_theme->getFont(style)); }
int getFontHeight(Theme::FontStyle style = Theme::kFontStyleBold) const { return _theme->getFontHeight(style); }
Modified: scummvm/branches/gsoc2008-gui/gui/theme-config.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme-config.cpp 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/theme-config.cpp 2008-08-13 16:50:50 UTC (rev 33832)
@@ -666,18 +666,6 @@
}
}
-bool Theme::isThemeLoadingRequired() {
- int x = g_system->getOverlayWidth(), y = g_system->getOverlayHeight();
-
- if (_loadedThemeX == x && _loadedThemeY == y)
- return false;
-
- _loadedThemeX = x;
- _loadedThemeY = y;
-
- return true;
-}
-
bool Theme::sectionIsSkipped(Common::ConfigFile &config, const char *name, int w, int h) {
if (!config.hasKey("skipFor", name))
return false;
Modified: scummvm/branches/gsoc2008-gui/gui/theme.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.cpp 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/theme.cpp 2008-08-13 16:50:50 UTC (rev 33832)
@@ -29,33 +29,10 @@
namespace GUI {
-Theme::Theme() : _drawArea(), _stylefile(""), _configFile(), _loadedThemeX(0), _loadedThemeY(0) {
- Common::MemoryReadStream s((const byte *)_defaultConfigINI, strlen(_defaultConfigINI));
- _defaultConfig.loadFromStream(s);
+Theme::Theme() : _loadedThemeX(0), _loadedThemeY(0) {}
- _evaluator = new Eval();
-}
+Theme::~Theme() {}
-Theme::~Theme() {
- delete _evaluator;
-}
-
-void Theme::getColorFromConfig(const Common::String &value, OverlayColor &color) {
- const char *postfixes[] = {".r", ".g", ".b"};
- int rgb[3];
-
- for (int cnt = 0; cnt < 3; cnt++)
- rgb[cnt] = _evaluator->getVar(value + postfixes[cnt], 0);
-
- color = g_system->RGBToColor(rgb[0], rgb[1], rgb[2]);
-}
-
-void Theme::getColorFromConfig(const Common::String &value, uint8 &r, uint8 &g, uint8 &b) {
- r = _evaluator->getVar(value + ".r", 0);
- g = _evaluator->getVar(value + ".g", 0);
- b = _evaluator->getVar(value + ".b", 0);
-}
-
const Graphics::Font *Theme::loadFont(const char *filename) {
const Graphics::NewFont *font = 0;
Common::String cacheFilename = genCacheFilename(filename);
@@ -146,51 +123,19 @@
return "";
}
-bool Theme::loadConfigFile(const Common::String &stylefile) {
- if (ConfMan.hasKey("themepath"))
- Common::File::addDefaultDirectory(ConfMan.get("themepath"));
+bool Theme::isThemeLoadingRequired() {
+ int x = g_system->getOverlayWidth(), y = g_system->getOverlayHeight();
-#ifdef DATA_PATH
- Common::File::addDefaultDirectoryRecursive(DATA_PATH);
-#endif
-
- if (ConfMan.hasKey("extrapath"))
- Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
-
- if (!_configFile.loadFromFile(stylefile + ".ini")) {
-#ifdef USE_ZLIB
- // Maybe find a nicer solution to this
- unzFile zipFile = unzOpen((stylefile + ".zip").c_str());
- if (zipFile && unzLocateFile(zipFile, (stylefile + ".ini").c_str(), 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);
- if (!_configFile.loadFromStream(stream)) {
- unzClose(zipFile);
- return false;
- }
- delete[] buffer;
- buffer = 0;
- } else {
- unzClose(zipFile);
- return false;
- }
- unzClose(zipFile);
-#else
+ if (_loadedThemeX == x && _loadedThemeY == y)
return false;
-#endif
- }
+ _loadedThemeX = x;
+ _loadedThemeY = y;
+
return true;
}
-bool Theme::themeConfigUseable(const Common::String &stylefile, const Common::String &style, Common::String *cStyle, Common::ConfigFile *cfg) {
+bool Theme::themeConfigUseable(const Common::String &filename) {
if (ConfMan.hasKey("themepath"))
Common::File::addDefaultDirectory(ConfMan.get("themepath"));
@@ -201,59 +146,8 @@
if (ConfMan.hasKey("extrapath"))
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
- Common::File file;
- Common::ConfigFile configFile;
- if (!cfg && (cStyle || !style.empty()))
- cfg = &configFile;
- if (!file.open(stylefile + ".ini")) {
-#ifdef USE_ZLIB
- // Maybe find a nicer solution to this
- unzFile zipFile = unzOpen((stylefile + ".zip").c_str());
- if (zipFile && unzLocateFile(zipFile, (stylefile + ".ini").c_str(), 2) == UNZ_OK) {
- if (!style.empty() || cStyle || cfg) {
- 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);
- if (!cfg->loadFromStream(stream)) {
- unzClose(zipFile);
- return false;
- }
- delete[] buffer;
- buffer = 0;
- }
- } else {
- unzClose(zipFile);
- return false;
- }
- unzClose(zipFile);
-#else
- return false;
-#endif
- }
- if (!style.empty() || cStyle || cfg) {
- if (file.isOpen()) {
- if (!cfg->loadFromStream(file))
- return false;
- file.close();
- }
-
- Common::String temp;
- if (!cfg->getKey("type", "theme", temp))
- return false;
- if (cStyle)
- *cStyle = temp;
- if (0 != temp.compareToIgnoreCase(style) && !style.empty())
- return false;
- }
-
return true;
}
Modified: scummvm/branches/gsoc2008-gui/gui/theme.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.h 2008-08-13 15:17:51 UTC (rev 33831)
+++ scummvm/branches/gsoc2008-gui/gui/theme.h 2008-08-13 16:50:50 UTC (rev 33832)
@@ -38,7 +38,7 @@
namespace GUI {
-class Eval;
+class ThemeEval;
//! Hint to the theme engine that the widget is used in a non-standard way.
enum ThemeHint {
@@ -250,9 +250,8 @@
* the dialog, we return false, which means we need to redraw
* the dialog stack from scratch.
*/
- virtual bool closeDialog() { return false; }
- virtual void startBuffering() {}
- virtual void finishBuffering() {}
+ virtual void startBuffering() = 0;
+ virtual void finishBuffering() = 0;
/**
* Clear the complete GUI screen.
@@ -267,36 +266,6 @@
*/
virtual void updateScreen() = 0;
- /**
- * Set the active screen area, in which the renderer is able to
- * draw.
- *
- * This does not affect the coordinates for the draw* functions,
- * it just marks the screen rect given in param r as writeable.
- *
- * This is for example used in the credits dialog, which, if not
- * just a part of the screen would be marked as writeable, would
- * draw parts of the scrolling text outside the dialog box and
- * thus would look strange.
- *
- * The active area defaults to the whole screen, so there is just
- * need to use this function if you want to limit it.
- *
- * @param r rect of the screen, which should be writeable
- *
- * @see resetDrawArea
- */
- virtual void setDrawArea(const Common::Rect &r) { _drawArea = r; }
-
- /**
- * Resets the draw area to the whole screen.
- *
- * @see setDrawArea
- */
- virtual void resetDrawArea() = 0;
-
- virtual const Common::ConfigFile &getConfigFile() const { return _configFile; }
-
virtual const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const = 0;
virtual int getFontHeight(FontStyle font = kFontStyleBold) const = 0;
virtual int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const = 0;
@@ -356,19 +325,11 @@
return kTextAlignCenter;
}
- void processResSection(Common::ConfigFile &config, const Common::String &name, bool skipDefs = false, const Common::String &prefix = "");
- void processSingleLine(const Common::String §ion, const Common::String &prefix, const Common::String &name, const Common::String &str);
- void setSpecialAlias(const Common::String &alias, const Common::String &name);
bool isThemeLoadingRequired();
- bool sectionIsSkipped(Common::ConfigFile &config, const char *name, int w, int h);
- void loadTheme(Common::ConfigFile &config, bool reset = true);
- void loadTheme(Common::ConfigFile &config, bool reset, bool doBackendSpecificPostProcessing);
- Eval *_evaluator;
-
- virtual void *evaluator() { return (void*)_evaluator; }
+ virtual ThemeEval *evaluator() = 0;
- static bool themeConfigUseable(const Common::String &file, const Common::String &style="", Common::String *cStyle=0, Common::ConfigFile *cfg=0);
+ static bool themeConfigUseable(const Common::String &file);
virtual const Common::String &getThemeFileName() const = 0;
virtual const Common::String &getThemeName() const = 0;
@@ -395,19 +356,10 @@
*/
virtual const Graphics::Surface *getImageSurface(const kThemeImages n) const { return 0; }
protected:
- bool loadConfigFile(const Common::String &file);
- void getColorFromConfig(const Common::String &name, OverlayColor &col);
- void getColorFromConfig(const Common::String &value, uint8 &r, uint8 &g, uint8 &b);
const Graphics::Font *loadFont(const char *filename);
Common::String genCacheFilename(const char *filename);
- Common::String _stylefile, _stylename;
-
- Common::Rect _drawArea;
- Common::ConfigFile _configFile;
- Common::ConfigFile _defaultConfig;
-
public:
bool needThemeReload() { return ((_loadedThemeX != g_system->getOverlayWidth()) ||
(_loadedThemeY != g_system->getOverlayHeight())); }
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