diff options
| author | Vicent Marti | 2008-08-13 16:50:50 +0000 | 
|---|---|---|
| committer | Vicent Marti | 2008-08-13 16:50:50 +0000 | 
| commit | 1d9f98d121e51943b4967cf6188062aae9195af4 (patch) | |
| tree | 12d431e7b0832c63507c3129a5954339c2b77980 | |
| parent | 0dcfb38d49e60881c5727ff8ec4d806f339ab696 (diff) | |
| download | scummvm-rg350-1d9f98d121e51943b4967cf6188062aae9195af4.tar.gz scummvm-rg350-1d9f98d121e51943b4967cf6188062aae9195af4.tar.bz2 scummvm-rg350-1d9f98d121e51943b4967cf6188062aae9195af4.zip  | |
Massive API cleanup (removed legacy code).
Improved theme loading support.
svn-id: r33832
| -rw-r--r-- | gui/ThemeRenderer.cpp | 4 | ||||
| -rw-r--r-- | gui/ThemeRenderer.h | 7 | ||||
| -rw-r--r-- | gui/module.mk | 5 | ||||
| -rw-r--r-- | gui/newgui.cpp | 14 | ||||
| -rw-r--r-- | gui/newgui.h | 3 | ||||
| -rw-r--r-- | gui/theme-config.cpp | 12 | ||||
| -rw-r--r-- | gui/theme.cpp | 124 | ||||
| -rw-r--r-- | gui/theme.h | 58 | ||||
| -rw-r--r-- | gui/themes/scummodern.zip | bin | 116190 -> 116164 bytes | 
9 files changed, 25 insertions, 202 deletions
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index 3cb7f13dbd..1632488b91 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -433,7 +433,7 @@ bool ThemeRenderer::loadThemeXML(Common::String themeName) {  				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 @@ bool ThemeRenderer::loadThemeXML(Common::String themeName) {  			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()) { diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h index 1c328430e7..d26dc21f48 100644 --- a/gui/ThemeRenderer.h +++ b/gui/ThemeRenderer.h @@ -453,11 +453,10 @@ public:  	 *	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; } diff --git a/gui/module.mk b/gui/module.mk index 0711f236a4..1cb9ecb30f 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -25,10 +25,7 @@ MODULE_OBJS := \  	widget.o \  	theme.o \  	ThemeEval.o \ -	ThemeClassic.o \ -	ThemeModern.o \ -	ThemeParser.o \ -	theme-config.o +	ThemeParser.o  # Include common rules  include $(srcdir)/rules.mk diff --git a/gui/newgui.cpp b/gui/newgui.cpp index f2e013bc0a..665d190e6f 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -93,16 +93,11 @@ NewGui::NewGui() : _redrawStatus(kRedrawDisabled),  	ConfMan.registerDefault("gui_theme", "default"); -	Common::String style(ConfMan.get("gui_theme")); -	if (style.compareToIgnoreCase("default") == 0) -		style = "builtin"; -		 -	//DEBUG: -//	style = "scummodern"; - -	loadNewTheme(style); +	Common::String themefile(ConfMan.get("gui_theme")); +	if (themefile.compareToIgnoreCase("default") == 0) +		themefile = "builtin"; -	_theme->resetDrawArea(); +	loadNewTheme(themefile);  	_themeChange = false;  } @@ -130,7 +125,6 @@ bool NewGui::loadNewTheme(const Common::String &filename) {  		return (!oldTheme.empty() ? loadNewTheme(oldTheme) : false);  	_theme->init(); -	_theme->resetDrawArea();  	if (!oldTheme.empty())  		screenChange(); diff --git a/gui/newgui.h b/gui/newgui.h index 5fabe4ea1f..b7ef589f07 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -79,8 +79,7 @@ public:  	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); } diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp index 1f52567e3e..f70696e8d5 100644 --- a/gui/theme-config.cpp +++ b/gui/theme-config.cpp @@ -666,18 +666,6 @@ void Theme::setSpecialAlias(const String &alias, const String &name) {  	}  } -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; diff --git a/gui/theme.cpp b/gui/theme.cpp index 5355894c85..6e05ce086c 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -29,32 +29,9 @@  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() { -	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); -} +Theme::~Theme() {}  const Graphics::Font *Theme::loadFont(const char *filename) {  	const Graphics::NewFont *font = 0; @@ -146,51 +123,19 @@ Common::String Theme::genCacheFilename(const char *filename) {  	return "";  } -bool Theme::loadConfigFile(const Common::String &stylefile) { -	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")); +bool Theme::isThemeLoadingRequired() { +	int x = g_system->getOverlayWidth(), y = g_system->getOverlayHeight(); -	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,58 +146,7 @@ bool Theme::themeConfigUseable(const Common::String &stylefile, const Common::St  	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;  } diff --git a/gui/theme.h b/gui/theme.h index 2a0b908330..067603d562 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -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 @@ public:  	 *          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 @@ public:  	 */  	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 @@ public:  		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 @@ public:  	 */  	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())); } diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip Binary files differindex 3f23dde775..c240b0080c 100644 --- a/gui/themes/scummodern.zip +++ b/gui/themes/scummodern.zip  | 
