[Scummvm-cvs-logs] SF.net SVN: scummvm:[33898] scummvm/branches/gsoc2008-gui/gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Aug 15 13:05:26 CEST 2008


Revision: 33898
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33898&view=rev
Author:   Tanoku
Date:     2008-08-15 11:05:25 +0000 (Fri, 15 Aug 2008)

Log Message:
-----------
Added popup widget in Options menu to change GUI renderer on the fly.

Modified Paths:
--------------
    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/newgui.h
    scummvm/branches/gsoc2008-gui/gui/options.cpp
    scummvm/branches/gsoc2008-gui/gui/options.h
    scummvm/branches/gsoc2008-gui/gui/theme.h
    scummvm/branches/gsoc2008-gui/gui/themes/default.inc
    scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummclassic.zip
    scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummodern.zip
    scummvm/branches/gsoc2008-gui/gui/themes/scummtheme.py

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-08-15 11:05:25 UTC (rev 33898)
@@ -43,6 +43,12 @@
 
 using namespace Graphics;
 
+const char *ThemeRenderer::rendererModeLabels[] = {
+	"Disabled GFX",
+	"Stardard Renderer (16bpp)",
+	"Antialiased Renderer (16bpp)"
+};
+
 const ThemeRenderer::DrawDataInfo ThemeRenderer::kDrawDataDefaults[] = {
 	{kDDMainDialogBackground, "mainmenu_bg", true, kDDNone},
 	{kDDSpecialColorBackground, "special_bg", true, kDDNone},
@@ -256,7 +262,7 @@
 		break;
 
 	default:
-		return;
+		error("Invalid graphics mode");
 	}
 
 	freeRenderer();

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-08-15 11:05:25 UTC (rev 33898)
@@ -212,9 +212,12 @@
 	enum GraphicsMode {
 		kGfxDisabled = 0,	/** No GFX */
 		kGfxStandard16bit,	/** 2BPP with the standard (aliased) renderer. */
-		kGfxAntialias16bit	/** 2BPP with the optimized AA renderer. */
+		kGfxAntialias16bit,	/** 2BPP with the optimized AA renderer. */
+		kGfxMAX
 	};
 	
+	static const char *rendererModeLabels[];
+	
 	/** Default constructor */
 	ThemeRenderer(Common::String fileName, GraphicsMode mode);
 
@@ -487,6 +490,7 @@
 
 	const Common::String &getThemeName() const { return _themeName; }
 	const Common::String &getThemeFileName() const { return _themeFileName; }
+	int getThemeRenderer() const { return _graphicsMode; }
 	
 	/**
 	 *	Initializes the drawing screen surfaces, _screen and _backBuffer.

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-08-15 11:05:25 UTC (rev 33898)
@@ -58,8 +58,6 @@
 		if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) {
 			warning("Could not load widget position for '%s'", _name.c_str());
 		}
-		
-		return;
 
 		if (_x < 0)
 			error("Widget <%s> has x < 0: %d", _name.c_str(), _x);
@@ -96,8 +94,11 @@
 		
 	if (themefile != "builtin" && !themefile.hasSuffix(".zip"))
 		themefile += ".zip";
+		
+	ConfMan.registerDefault("gui_renderer", 2);
+	ThemeRenderer::GraphicsMode gfxMode = (ThemeRenderer::GraphicsMode)ConfMan.getInt("gui_renderer");
 
-	loadNewTheme(themefile);
+	loadNewTheme(themefile, gfxMode);
 	_themeChange = false;
 }
 
@@ -105,8 +106,14 @@
 	delete _theme;
 }
 
-bool NewGui::loadNewTheme(const Common::String &filename) {
+bool NewGui::loadNewTheme(const Common::String &filename, ThemeRenderer::GraphicsMode gfx) {
+	if (_theme && filename == _theme->getThemeFileName() && gfx == _theme->getThemeRenderer())
+		return true;
+	
 	Common::String oldTheme = (_theme != 0) ? _theme->getThemeFileName() : "";
+	
+	if (gfx == ThemeRenderer::kGfxDisabled)
+		gfx = (ThemeRenderer::GraphicsMode)ConfMan.getInt("gui_renderer");
 
 	if (_theme)
 		_theme->disable();
@@ -119,7 +126,7 @@
 	delete _theme;
 	_theme = 0;
 
-	_theme = new ThemeRenderer(filename, GUI::ThemeRenderer::kGfxAntialias16bit);
+	_theme = new ThemeRenderer(filename, gfx);
 
 	if (!_theme)
 		return (!oldTheme.empty() ? loadNewTheme(oldTheme) : false);

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.h	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.h	2008-08-15 11:05:25 UTC (rev 33898)
@@ -33,6 +33,8 @@
 #include "gui/theme.h"
 #include "gui/widget.h"
 
+#include "gui/ThemeRenderer.h"
+
 class OSystem;
 
 namespace GUI {
@@ -76,7 +78,7 @@
 
 	bool isActive() const	{ return ! _dialogStack.empty(); }
 
-	bool loadNewTheme(const Common::String &file);
+	bool loadNewTheme(const Common::String &file, ThemeRenderer::GraphicsMode gfx = ThemeRenderer::kGfxDisabled);
 	Theme *theme() { return _theme; }
 	
 	ThemeEval *xmlEval() { return _theme->evaluator(); }

Modified: scummvm/branches/gsoc2008-gui/gui/options.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/options.cpp	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/options.cpp	2008-08-15 11:05:25 UTC (rev 33898)
@@ -724,9 +724,16 @@
 
 	new ButtonWidget(tab, "GlobalOptions_Misc.ThemeButton", "Theme:", kChooseThemeCmd, 0);
 	_curTheme = new StaticTextWidget(tab, "GlobalOptions_Misc.CurTheme", g_gui.theme()->getThemeName());
+	
 
 	int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
-
+	
+	_rendererPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.Renderer", "GUI Renderer:", labelWidth);
+	
+	for (int i = 1; i < GUI::ThemeRenderer::kGfxMAX; ++i) {
+		_rendererPopUp->appendEntry(GUI::ThemeRenderer::rendererModeLabels[i], i);
+	}
+	
 	_autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriod", "Autosave:", labelWidth);
 
 	for (int i = 0; savePeriodLabels[i]; i++) {
@@ -799,6 +806,8 @@
 		if (value == savePeriodValues[i])
 			_autosavePeriodPopUp->setSelected(i);
 	}
+	
+	_rendererPopUp->setSelected(ConfMan.getInt("gui_renderer") - 1);
 }
 
 void GlobalOptionsDialog::close() {
@@ -828,6 +837,11 @@
 #endif
 
 		ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
+		
+		if ((int)_rendererPopUp->getSelectedTag() != ConfMan.getInt("gui_renderer")) {
+			g_gui.loadNewTheme(g_gui.theme()->getThemeFileName(), (GUI::ThemeRenderer::GraphicsMode)_rendererPopUp->getSelectedTag());
+			ConfMan.setInt("gui_renderer", _rendererPopUp->getSelectedTag(), _domain);
+		}
 	}
 	OptionsDialog::close();
 }

Modified: scummvm/branches/gsoc2008-gui/gui/options.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/options.h	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/options.h	2008-08-15 11:05:25 UTC (rev 33898)
@@ -170,7 +170,7 @@
 	// Misc controls
 	//
 	StaticTextWidget *_curTheme;
-
+	PopUpWidget *_rendererPopUp;
 	PopUpWidget *_autosavePeriodPopUp;
 };
 

Modified: scummvm/branches/gsoc2008-gui/gui/theme.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.h	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/theme.h	2008-08-15 11:05:25 UTC (rev 33898)
@@ -310,6 +310,7 @@
 
 	virtual const Common::String &getThemeFileName() const = 0;
 	virtual const Common::String &getThemeName() const = 0;
+	virtual int getThemeRenderer() const = 0;
 
 	/**
 	 * Checks if the theme renderer supports drawing of images.

Modified: scummvm/branches/gsoc2008-gui/gui/themes/default.inc
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-15 11:05:25 UTC (rev 33898)
@@ -704,6 +704,9 @@
 "height = 'Globals.Line.Height' "
 "/> "
 "</layout> "
+"<widget name = 'Renderer' "
+"type = 'PopUp' "
+"/> "
 "<widget name = 'AutosavePeriod' "
 "type = 'PopUp' "
 "/> "

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx	2008-08-15 11:05:25 UTC (rev 33898)
@@ -456,6 +456,9 @@
 						height = 'Globals.Line.Height'
 				/>
 			</layout>
+			<widget name = 'Renderer'
+					type = 'PopUp'
+			/>
 			<widget name = 'AutosavePeriod'
 					type = 'PopUp'
 			/>

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout.stx	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout.stx	2008-08-15 11:05:25 UTC (rev 33898)
@@ -343,6 +343,9 @@
 						height = 'Globals.Line.Height'
 				/>
 			</layout>
+			<widget name = 'Renderer'
+					type = 'PopUp'
+			/>
 			<widget name = 'AutosavePeriod'
 					type = 'PopUp'
 			/>

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx	2008-08-15 11:05:25 UTC (rev 33898)
@@ -325,6 +325,9 @@
 						height = 'Globals.Line.Height'
 				/>
 			</layout>
+			<widget name = 'Renderer'
+					type = 'PopUp'
+			/>
 			<widget name = 'AutosavePeriod'
 					type = 'PopUp'
 			/>

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummtheme.py
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummtheme.py	2008-08-15 10:48:08 UTC (rev 33897)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummtheme.py	2008-08-15 11:05:25 UTC (rev 33898)
@@ -6,7 +6,7 @@
 import zipfile
 
 def buildTheme(themeName):
-	if not os.path.isdir(themeName):
+	if not os.path.isdir(themeName) or not os.path.isfile(os.path.join(themeName, "THEMERC")):
 		print "Invalid theme name: " + themeName
 		return
 	


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