[Scummvm-cvs-logs] SF.net SVN: scummvm:[33728] scummvm/branches/gsoc2008-gui/gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Sun Aug 10 00:40:09 CEST 2008
Revision: 33728
http://scummvm.svn.sourceforge.net/scummvm/?rev=33728&view=rev
Author: Tanoku
Date: 2008-08-09 22:40:05 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
Finished support for theme loading.
Fixed several bugs regarding theme loading.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
scummvm/branches/gsoc2008-gui/gui/newgui.cpp
scummvm/branches/gsoc2008-gui/gui/options.cpp
scummvm/branches/gsoc2008-gui/gui/theme.h
scummvm/branches/gsoc2008-gui/gui/themebrowser.cpp
scummvm/branches/gsoc2008-gui/gui/themebrowser.h
Modified: scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp 2008-08-09 22:40:05 UTC (rev 33728)
@@ -510,6 +510,8 @@
_entriesPerPage += (1 << 16);
_entriesPerPage >>= 16;
+
+ assert(_entriesPerPage > 0);
delete[] _textWidth;
_textWidth = new int[_entriesPerPage];
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-09 22:40:05 UTC (rev 33728)
@@ -377,7 +377,7 @@
}
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
- _layouts["Dialog.Launcher"]->debugDraw(screen, font);
+ _layouts["Dialog.Browser"]->debugDraw(screen, font);
// _layouts["Dialog.GameOptions_Graphics"]->debugDraw(screen, font);
}
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-09 22:40:05 UTC (rev 33728)
@@ -95,7 +95,7 @@
};
-ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
+ThemeRenderer::ThemeRenderer(Common::String fileName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false),
_themeOk(false), _enabled(false), _buffering(false) {
@@ -119,11 +119,9 @@
} else {
_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
}
-
- ImageMan.addArchive(themeName + ".zip");
+ _themeFileName = fileName;
_initOk = true;
- _themeName = themeName;
}
ThemeRenderer::~ThemeRenderer() {
@@ -134,12 +132,8 @@
delete _parser;
delete _themeEval;
- for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
-// delete i->_value;
+ for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
ImageMan.unregisterSurface(i->_key);
- }
-
- ImageMan.remArchive(_stylefile + ".zip");
}
bool ThemeRenderer::init() {
@@ -154,7 +148,7 @@
}
if (isThemeLoadingRequired() || !_themeOk) {
- loadTheme(_themeName);
+ loadTheme(_themeFileName);
}
return true;
@@ -170,6 +164,30 @@
}
}
+void ThemeRenderer::unloadTheme() {
+ if (!_themeOk)
+ return;
+
+ for (int i = 0; i < kDrawDataMAX; ++i) {
+ delete _widgets[i];
+ _widgets[i] = 0;
+ }
+
+ for (int i = 0; i < kTextDataMAX; ++i) {
+ delete _texts[i];
+ _texts[i] = 0;
+ }
+
+ for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
+ ImageMan.unregisterSurface(i->_key);
+
+ ImageMan.remArchive(_themeFileName + ".zip");
+
+ _themeName.clear();
+ _themeFileName.clear();
+ _themeOk = false;
+}
+
void ThemeRenderer::clearAll() {
if (!_initOk)
return;
@@ -281,7 +299,6 @@
bool ThemeRenderer::addBitmap(const Common::String &filename) {
if (_bitmaps.contains(filename)) {
- delete _bitmaps[filename];
ImageMan.unregisterSurface(filename);
}
@@ -309,15 +326,29 @@
return true;
}
-bool ThemeRenderer::loadTheme(Common::String themeName) {
+bool ThemeRenderer::loadTheme(Common::String fileName) {
unloadTheme();
- if (themeName == "builtin" && !loadDefaultXML())
- error("Could not load default embeded theme.");
+ if (fileName != "builtin") {
+ if (ConfMan.hasKey("themepath"))
+ Common::File::addDefaultDirectory(ConfMan.get("themepath"));
- if (!loadThemeXML(themeName)) {
- warning("Could not parse custom theme '%s'.\nFalling back to default theme", themeName.c_str());
+#ifdef DATA_PATH
+ Common::File::addDefaultDirectoryRecursive(DATA_PATH);
+#endif
+ if (ConfMan.hasKey("extrapath"))
+ Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
+ ImageMan.addArchive(fileName + ".zip");
+ }
+
+ if (fileName == "builtin") {
+ if (!loadDefaultXML())
+ error("Could not load default embeded theme");
+ }
+ else if (!loadThemeXML(fileName)) {
+ warning("Could not parse custom theme '%s'.\nFalling back to default theme", fileName.c_str());
+
if (!loadDefaultXML()) // if we can't load the embeded theme, this is a complete failure
error("Could not load default embeded theme");
}
@@ -333,9 +364,7 @@
}
}
- // Debug print all the parsed variables. remove
- _themeEval->debugPrint();
-
+ _themeName = "DEBUG - A Theme name";
_themeOk = true;
return true;
}
@@ -346,6 +375,8 @@
// file inside the themes directory.
// Use the Python script "makedeftheme.py" to convert a normal XML theme
// into the "default.inc" file, which is ready to be included in the code.
+
+#ifdef GUI_ENABLE_BUILTIN_THEME
const char *defaultXML =
#include "themes/default.inc"
;
@@ -354,20 +385,14 @@
return false;
return parser()->parse();
+#else
+ warning("The built-in theme is not enabled in the current build. Please load an external theme");
+ return false;
+#endif
}
bool ThemeRenderer::loadThemeXML(Common::String themeName) {
assert(_parser);
-
- if (ConfMan.hasKey("themepath"))
- Common::File::addDefaultDirectory(ConfMan.get("themepath"));
-
-#ifdef DATA_PATH
- Common::File::addDefaultDirectoryRecursive(DATA_PATH);
-#endif
-
- if (ConfMan.hasKey("extrapath"))
- Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
if (!parser()->loadFile(themeName + ".stx")){
#ifdef USE_ZLIB
@@ -821,9 +846,9 @@
renderDirtyScreen();
-// _vectorRenderer->fillSurface();
-// themeEval()->debugDraw(_screen, _font);
-// _vectorRenderer->copyWholeFrame(_system);
+ // _vectorRenderer->fillSurface();
+ // themeEval()->debugDraw(_screen, _font);
+ // _vectorRenderer->copyWholeFrame(_system);
}
void ThemeRenderer::renderDirtyScreen() {
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h 2008-08-09 22:40:05 UTC (rev 33728)
@@ -216,7 +216,7 @@
};
/** Default constructor */
- ThemeRenderer(Common::String themeName, GraphicsMode mode);
+ ThemeRenderer(Common::String fileName, GraphicsMode mode);
/** Default destructor */
~ThemeRenderer();
@@ -470,10 +470,11 @@
return 0;
}
-
- const Common::String &getThemeName() { return _themeName; }
protected:
+
+ const Common::String &getThemeName() const { return _themeName; }
+ const Common::String &getThemeFileName() const { return _themeFileName; }
/**
* Initializes the drawing screen surfaces, _screen and _backBuffer.
@@ -505,23 +506,8 @@
* Unloads the currently loaded theme so another one can
* be loaded.
*/
- void unloadTheme() {
- if (!_themeOk)
- return;
+ void unloadTheme();
- for (int i = 0; i < kDrawDataMAX; ++i) {
- delete _widgets[i];
- _widgets[i] = 0;
- }
-
- for (int i = 0; i < kTextDataMAX; ++i) {
- delete _texts[i];
- _texts[i] = 0;
- }
-
- _themeOk = false;
- }
-
/**
* Not implemented yet.
* TODO: reload themes, reload the renderer, recheck everything
@@ -710,6 +696,7 @@
bool _enabled; /** Whether the Theme is currently shown on the overlay */
Common::String _themeName; /** Name of the currently loaded theme */
+ Common::String _themeFileName;
};
} // end of namespace GUI.
Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp 2008-08-09 22:40:05 UTC (rev 33728)
@@ -98,7 +98,7 @@
style = "builtin";
//DEBUG:
- style = "scummodern";
+// style = "scummodern";
loadNewTheme(style);
@@ -110,12 +110,9 @@
delete _theme;
}
-bool NewGui::loadNewTheme(const Common::String &style) {
- Common::String styleType;
- Common::ConfigFile cfg;
+bool NewGui::loadNewTheme(const Common::String &filename) {
+ Common::String oldTheme = (_theme != 0) ? _theme->getThemeFileName() : "";
- Common::String oldTheme = (_theme != 0) ? _theme->getThemeName() : "";
-
if (_theme)
_theme->disable();
@@ -127,7 +124,7 @@
delete _theme;
_theme = 0;
- _theme = new ThemeRenderer(style, GUI::ThemeRenderer::kGfxAntialias16bit);
+ _theme = new ThemeRenderer(filename, GUI::ThemeRenderer::kGfxAntialias16bit);
if (!_theme)
return (!oldTheme.empty() ? loadNewTheme(oldTheme) : false);
Modified: scummvm/branches/gsoc2008-gui/gui/options.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/options.cpp 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/options.cpp 2008-08-09 22:40:05 UTC (rev 33728)
@@ -907,7 +907,7 @@
if (browser.runModal() > 0) {
// User made his choice...
const Common::String &theme = browser.selected();
- if (0 != theme.compareToIgnoreCase(g_gui.theme()->getStylefileName()))
+ if (0 != theme.compareToIgnoreCase(g_gui.theme()->getThemeFileName()))
if (g_gui.loadNewTheme(theme)) {
_curTheme->setLabel(g_gui.theme()->getThemeName());
ConfMan.set("gui_theme", theme);
Modified: scummvm/branches/gsoc2008-gui/gui/theme.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.h 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/theme.h 2008-08-09 22:40:05 UTC (rev 33728)
@@ -370,13 +370,9 @@
static bool themeConfigUseable(const Common::String &file, const Common::String &style="", Common::String *cStyle=0, Common::ConfigFile *cfg=0);
- const Common::String &getStylefileName() const { return _stylefile; }
- virtual const Common::String &getThemeName() const { return _stylename; }
+ virtual const Common::String &getThemeFileName() const = 0;
+ virtual const Common::String &getThemeName() const = 0;
- virtual bool isDynamic() {
- return false;
- }
-
/**
* Checks if the theme renderer supports drawing of images.
*
Modified: scummvm/branches/gsoc2008-gui/gui/themebrowser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themebrowser.cpp 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/themebrowser.cpp 2008-08-09 22:40:05 UTC (rev 33728)
@@ -43,21 +43,21 @@
// but for now this simple browser works,
// also it will get its own theme config values
// and not use 'browser_' anymore
-ThemeBrowser::ThemeBrowser() : Dialog("browser") {
+ThemeBrowser::ThemeBrowser() : Dialog("Browser") {
_fileList = 0;
- new StaticTextWidget(this, "browser_headline", "Select a Theme");
+ new StaticTextWidget(this, "Browser.Headline", "Select a Theme");
// Add file list
- _fileList = new ListWidget(this, "browser_list");
+ _fileList = new ListWidget(this, "Browser.List");
_fileList->setNumberingMode(kListNumberingOff);
_fileList->setEditable(false);
_fileList->setHints(THEME_HINT_PLAIN_COLOR);
// Buttons
- new ButtonWidget(this, "browser_cancel", "Cancel", kCloseCmd, 0);
- new ButtonWidget(this, "browser_choose", "Choose", kChooseCmd, 0);
+ new ButtonWidget(this, "Browser.Cancel", "Cancel", kCloseCmd, 0);
+ new ButtonWidget(this, "Browser.Choose", "Choose", kChooseCmd, 0);
}
void ThemeBrowser::open() {
@@ -91,9 +91,8 @@
// classic is always build in
Entry th;
- th.name = "Classic (Builtin)";
- th.type = "Classic";
- th.file = "Classic (Builtin)";
+ th.name = "Modern Development Theme (Builtin) - WIP";
+ th.file = "builtin";
_themes.push_back(th);
// we are using only the paths 'themepath', 'extrapath', DATA_PATH and '.'
@@ -172,10 +171,11 @@
}
bool ThemeBrowser::isTheme(const FilesystemNode &node, Entry &out) {
- Common::ConfigFile cfg;
- Common::String type;
-
out.file = node.getName();
+
+ if (!out.file.hasSuffix(".zip") && !out.file.hasSuffix(".stx"))
+ return false;
+
for (int i = out.file.size()-1; out.file[i] != '.' && i > 0; --i) {
out.file.deleteLastChar();
}
@@ -184,14 +184,13 @@
if (out.file.empty())
return false;
- if (!Theme::themeConfigUseable(out.file, "", &type, &cfg))
- return false;
+// TODO: Check if theme is usable.
+// if (!Theme::themeConfigUseable(out.file, "", &type, &cfg))
+// return false;
- out.type = type;
-
- if (cfg.hasKey("name", "theme"))
- cfg.getKey("name", "theme", out.name);
- else
+// if (cfg.hasKey("name", "theme"))
+// cfg.getKey("name", "theme", out.name);
+// else
out.name = out.file;
return true;
Modified: scummvm/branches/gsoc2008-gui/gui/themebrowser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themebrowser.h 2008-08-09 22:38:03 UTC (rev 33727)
+++ scummvm/branches/gsoc2008-gui/gui/themebrowser.h 2008-08-09 22:40:05 UTC (rev 33728)
@@ -46,7 +46,6 @@
private:
struct Entry {
Common::String name;
- Common::String type;
Common::String file;
};
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