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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Wed Jul 23 19:57:11 CEST 2008


Revision: 33251
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33251&view=rev
Author:   Tanoku
Date:     2008-07-23 17:57:11 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Text renderin overhaul finished.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-23 17:01:42 UTC (rev 33250)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-23 17:57:11 UTC (rev 33251)
@@ -48,13 +48,13 @@
 		"<font id = 'text_default' type = 'default' color = '0, 0, 0' />"
 		"<font id = 'text_hover' type = 'default' color = '255, 255, 255' />"
 		"<font id = 'text_disabled' type = 'default' color = '128, 128, 128' />"
-		"<font id = 'text_inverted' type = 'default' color = '255, 0, 0' />"
+		"<font id = 'text_inverted' type = 'default' color = '173, 40, 8' />"
 	"</fonts>"
 
 	"<defaults fill = 'gradient' fg_color = '255, 255, 255' />"
 	
 	"<drawdata id = 'text_selection' cache = false>"
-		"<drawstep func = 'square' fill = 'foreground' fg_color = '0, 255, 0' />"
+		"<drawstep func = 'square' fill = 'foreground' fg_color = '255, 255, 255' />"
 	"</drawdata>"
 
 	"<drawdata id = 'mainmenu_bg' cache = false>"
@@ -90,7 +90,7 @@
 	"<drawdata id = 'popup_idle' cache = false>"
 		"<drawstep func = 'square' stroke = 0 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' shadow = 3 />"
 		"<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' width = '12' height = '12' xpos = '-16' ypos = 'center' orientation = 'bottom' />"
-		"<text vertical_align = 'center' horizontal_align = 'right' color = '0, 0, 0' />"
+		"<text font = 'text_default' vertical_align = 'center' horizontal_align = 'right'/>"
 	"</drawdata>"
 	
 	

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-23 17:01:42 UTC (rev 33250)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-23 17:57:11 UTC (rev 33251)
@@ -204,6 +204,9 @@
 	
 	if (tNode->values.contains("horizontal_align") == false || tNode->values.contains("vertical_align") == false)
 		return parserError("Text inside widgets requires proper alignment keys.");
+
+	if (tNode->values.contains("font") == false)
+		return parserError("Text definitions must include a valid Font identifier.");
 		
 	if (tNode->values["horizontal_align"] == "left")
 		alignH = GUI::Theme::kTextAlignLeft;
@@ -221,7 +224,10 @@
 		alignV = GUI::Theme::kTextAlignVBottom;
 	else return parserError("Invalid value for text alignment.");
 	
-	return _theme->addTextData(parentNode->values["id"], tNode->values["font"], alignH, alignV);
+	if (!_theme->addTextData(parentNode->values["id"], tNode->values["font"], alignH, alignV))
+		return parserError("Error when adding Text Data for '%s'.", parentNode->values["id"].c_str());
+
+	return true;
 }
 
 bool ThemeParser::parserCallback_renderInfo() {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-23 17:01:42 UTC (rev 33250)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-23 17:57:11 UTC (rev 33251)
@@ -101,6 +101,12 @@
 
 	loadConfigFile("classic");
 
+	if (_screen->w >= 400 && _screen->h >= 300) {
+		_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+	} else {
+		_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+	}
+
 	_initOk = true;
 	_themeName = themeName;
 }
@@ -225,11 +231,7 @@
 	_texts[textId] = new TextDrawData;
 	
 	// TODO: Allow the user to specify the font he wants, instead of choosing based on resolution
-	if (_screen->w >= 400 && _screen->h >= 300) {
-		_texts[textId]->_fontPtr = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
-	} else {
-		_texts[textId]->_fontPtr = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
-	}
+	_texts[textId]->_fontPtr = _font;
 	
 	_texts[textId]->_color.r = r;
 	_texts[textId]->_color.g = g;
@@ -338,7 +340,7 @@
 	}
 }
 
-void ThemeRenderer::queueDDText(TextData type, const Common::Rect &r, const Common::String &text,
+void ThemeRenderer::queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg,
 	bool elipsis, TextAlign alignH, TextAlignVertical alignV) {
 		
 	if (_texts[type] == 0)
@@ -351,6 +353,7 @@
 	q.text = text;
 	q.alignH = alignH;
 	q.alignV = alignV;
+	q.restoreBg = restoreBg;
 	
 	if (_buffering) {		
 		_textQueue.push_back(q);
@@ -382,7 +385,7 @@
 }
 
 void ThemeRenderer::drawDDText(const DrawQueueText &q) {	
-	if (q.type != kTextDataInverted)
+	if (q.restoreBg)
 		restoreBackground(q.area);
 	
 	_vectorRenderer->setFgColor(_texts[q.type]->_color.r, _texts[q.type]->_color.g, _texts[q.type]->_color.b);
@@ -420,7 +423,7 @@
 		dd = kDDButtonDisabled;
 
 	queueDD(dd, r);
-	queueDDText(getTextData(dd), r, str, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+	queueDDText(getTextData(dd), r, str, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
 }
 
 void ThemeRenderer::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
@@ -446,7 +449,7 @@
 	r2.left = r2.right + checkBoxSize;
 	r2.right = r.right;
 	
-	queueDDText(getTextData(dd), r2, str, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+	queueDDText(getTextData(dd), r2, str, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
 }
 
 void ThemeRenderer::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
@@ -500,7 +503,7 @@
 	
 	if (!sel.empty()) {
 		Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
-		queueDDText(getTextData(dd), text, sel, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+		queueDDText(getTextData(dd), text, sel, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
 	}
 }
 
@@ -546,7 +549,7 @@
 
 		Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight);
 		queueDD(kDDTabInactive, tabRect);
-		queueDDText(getTextData(kDDTabInactive), tabRect, tabs[i], false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
+		queueDDText(getTextData(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
 	}
 	
 	if (active >= 0) {
@@ -554,28 +557,31 @@
 		const uint16 tabLeft = active * (tabWidth + tabOffset);
 		const uint16 tabRight =  MAX(r.right - tabRect.right, 0);
 		queueDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
-		queueDDText(getTextData(kDDTabActive), tabRect, tabs[active], false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
+		queueDDText(getTextData(kDDTabActive), tabRect, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
 	}
 }
 
 void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
-	if (!_initOk)
+	if (!ready())
 		return;
 		
-	if (inverted)
+	if (inverted) {
 		queueDD(kDDTextSelectionBackground, r);
-		
+		queueDDText(kTextDataInverted, r, str, false, useEllipsis);
+		return;
+	}
+
 	switch (state) {
 		case kStateDisabled:
-			queueDDText(inverted ? kTextDataInverted : kTextDataDisabled, r, str, useEllipsis);
+			queueDDText(kTextDataDisabled, r, str, true, useEllipsis);
 			break;
 			
 		case kStateHighlight:
-			queueDDText(inverted ? kTextDataInverted : kTextDataHover, r, str, useEllipsis);
+			queueDDText(kTextDataHover, r, str, true, useEllipsis);
 			break;
 		
 		case kStateEnabled:
-			queueDDText(inverted ? kTextDataInverted : kTextDataDefault, r, str, useEllipsis);
+			queueDDText(kTextDataDefault, r, str, true, useEllipsis);
 			break;
 	}
 }

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-23 17:01:42 UTC (rev 33250)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-23 17:57:11 UTC (rev 33251)
@@ -180,6 +180,7 @@
 		GUI::Theme::TextAlign alignH;
 		GUI::Theme::TextAlignVertical alignV;
 		bool elipsis;
+		bool restoreBg;
 	};
 	
 public:
@@ -548,7 +549,7 @@
 	 *	This function is called from all the Widget Drawing methods.
 	 */
 	inline void queueDD(DrawData type,  const Common::Rect &r, uint32 dynamic = 0);
-	inline void queueDDText(TextData type, const Common::Rect &r, const Common::String &text,
+	inline void queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg,
 		bool elipsis, TextAlign alignH = kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop);
 	
 	/**


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