aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeDefaultXML.cpp6
-rw-r--r--gui/ThemeParser.cpp8
-rw-r--r--gui/ThemeRenderer.cpp42
-rw-r--r--gui/ThemeRenderer.h3
4 files changed, 36 insertions, 23 deletions
diff --git a/gui/ThemeDefaultXML.cpp b/gui/ThemeDefaultXML.cpp
index d294f6b708..ba7689567e 100644
--- a/gui/ThemeDefaultXML.cpp
+++ b/gui/ThemeDefaultXML.cpp
@@ -48,13 +48,13 @@ bool ThemeRenderer::loadDefaultXML() {
"<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 @@ bool ThemeRenderer::loadDefaultXML() {
"<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>"
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 89f0595c67..66750b8c1a 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -204,6 +204,9 @@ bool ThemeParser::parserCallback_text() {
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 @@ bool ThemeParser::parserCallback_text() {
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() {
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 1123bf1816..df21769b8b 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -101,6 +101,12 @@ ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
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 @@ bool ThemeRenderer::addFont(const Common::String &fontId, int r, int g, int b) {
_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::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic
}
}
-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 @@ void ThemeRenderer::queueDDText(TextData type, const Common::Rect &r, const Comm
q.text = text;
q.alignH = alignH;
q.alignV = alignV;
+ q.restoreBg = restoreBg;
if (_buffering) {
_textQueue.push_back(q);
@@ -382,7 +385,7 @@ void ThemeRenderer::drawDD(const DrawQueue &q, bool draw, bool restore) {
}
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 @@ void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str,
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 @@ void ThemeRenderer::drawCheckbox(const Common::Rect &r, const Common::String &st
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 @@ void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String
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 @@ void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
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 @@ void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
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;
}
}
diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h
index ab4f5cb890..6c4067e00f 100644
--- a/gui/ThemeRenderer.h
+++ b/gui/ThemeRenderer.h
@@ -180,6 +180,7 @@ protected:
GUI::Theme::TextAlign alignH;
GUI::Theme::TextAlignVertical alignV;
bool elipsis;
+ bool restoreBg;
};
public:
@@ -548,7 +549,7 @@ protected:
* 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);
/**