diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp
index 3b5afab6694..244d296c809 100644
--- a/gui/EditTextWidget.cpp
+++ b/gui/EditTextWidget.cpp
@@ -27,6 +27,8 @@
#include "gui/eval.h"
#include "gui/newgui.h"
+#include "gui/ThemeEval.h"
+
namespace GUI {
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
@@ -52,10 +54,10 @@ void EditTextWidget::setEditString(const String &str) {
}
void EditTextWidget::reflowLayout() {
- _leftPadding = g_gui.evaluator()->getVar("EditTextWidget.leftPadding", 0);
- _rightPadding = g_gui.evaluator()->getVar("EditTextWidget.rightPadding", 0);
+ _leftPadding = g_gui.xmlEval()->getVar("Globals.EditTextWidget.Padding.Left", 0);
+ _rightPadding = g_gui.xmlEval()->getVar("Globals.EditTextWidget.Padding.Right", 0);
- _font = (Theme::FontStyle)g_gui.evaluator()->getVar("EditTextWidget.font", Theme::kFontStyleNormal);
+ _font = (Theme::FontStyle)g_gui.xmlEval()->getVar("EditTextWidget.Font", Theme::kFontStyleNormal);
EditableWidget::reflowLayout();
}
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index 91b7c406874..921647e0386 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -30,6 +30,8 @@
#include "gui/PopUpWidget.h"
#include "engines/engine.h"
+#include "gui/ThemeEval.h"
+
namespace GUI {
//
@@ -380,9 +382,9 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
void PopUpWidget::reflowLayout() {
- _leftPadding = g_gui.evaluator()->getVar("PopUpWidget.leftPadding", 0);
- _rightPadding = g_gui.evaluator()->getVar("PopUpWidget.rightPadding", 0);
- _labelSpacing = g_gui.evaluator()->getVar("PopUpWidget.labelSpacing", 0);
+ _leftPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Left", 0);
+ _rightPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Right", 0);
+ _labelSpacing = g_gui.xmlEval()->getVar("Globals.PopUpWidget.labelSpacing", 10);
Widget::reflowLayout();
}
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index eec0826a8f6..4d74750b398 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -135,7 +135,7 @@ bool ThemeParser::parserCallback_font(ParserNode *node) {
else if (!parseIntegerKey(node->values["color"].c_str(), 3, &red, &green, &blue))
return parserError("Error when parsing color value for font definition.");
- if (!_theme->addFont(node->values["id"], red, green, blue))
+ if (!_theme->addFont(node->values["id"], node->values["file"], red, green, blue))
return parserError("Error when loading Font in theme engine.");
return true;
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index 999828e5db8..ad7f2b36be3 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -343,7 +343,7 @@ protected:
XML_KEY(fonts)
XML_KEY(font)
XML_PROP(id, true)
- XML_PROP(type, true)
+ XML_PROP(file, true)
XML_PROP(color, true)
KEY_END()
KEY_END()
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 084e1496ec1..454015d3381 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -89,7 +89,8 @@ const ThemeRenderer::TextDataInfo ThemeRenderer::kTextDataDefaults[] = {
{kTextDataDisabled, "text_disabled"},
{kTextDataInverted, "text_inverted"},
{kTextDataButton, "text_button"},
- {kTextDataButtonHover, "text_button_hover"}
+ {kTextDataButtonHover, "text_button_hover"},
+ {kTextDataNormalFont, "text_normal"}
};
@@ -232,7 +233,7 @@ bool ThemeRenderer::addTextData(const Common::String &drawDataId, const Common::
return true;
}
-bool ThemeRenderer::addFont(const Common::String &fontId, int r, int g, int b) {
+bool ThemeRenderer::addFont(const Common::String &fontId, const Common::String &file, int r, int g, int b) {
TextData textId = getTextDataId(fontId);
if (textId == -1)
@@ -243,8 +244,22 @@ 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
- _texts[textId]->_fontPtr = _font;
+// _texts[textId]->_fontPtr = _font;
+
+ if (file == "default") {
+ _texts[textId]->_fontPtr = _font;
+ } else {
+ _texts[textId]->_fontPtr = FontMan.getFontByName(file);
+
+ if (!_texts[textId]->_fontPtr) {
+ _texts[textId]->_fontPtr = loadFont(file.c_str());
+
+ if (!_texts[textId]->_fontPtr)
+ error("Couldn't load %s font '%s'", fontId.c_str(), file.c_str());
+
+ FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
+ }
+ }
_texts[textId]->_color.r = r;
_texts[textId]->_color.g = g;
@@ -552,8 +567,12 @@ void ThemeRenderer::drawDialogBackground(const Common::Rect &r, uint16 hints, Wi
void ThemeRenderer::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
if (!ready())
return;
-
- debugWidgetPosition("Caret", r);
+
+ if (erase) {
+ restoreBackground(r);
+ addDirtyRect(r);
+ } else
+ queueDD(kDDCaret, r);
}
void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
@@ -636,19 +655,28 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W
queueDDText(kTextDataInverted, r, str, false, useEllipsis, align);
return;
}
+
+ switch (font) {
+ case kFontStyleNormal:
+ queueDDText(kTextDataNormalFont, r, str, true, useEllipsis, align);
+ return;
+
+ default:
+ break;
+ }
switch (state) {
case kStateDisabled:
queueDDText(kTextDataDisabled, r, str, true, useEllipsis, align);
- break;
+ return;
case kStateHighlight:
queueDDText(kTextDataHover, r, str, true, useEllipsis, align);
- break;
+ return;
case kStateEnabled:
queueDDText(kTextDataDefault, r, str, true, useEllipsis, align);
- break;
+ return;
}
}
diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h
index 35d2f31d405..39fa6910d1d 100644
--- a/gui/ThemeRenderer.h
+++ b/gui/ThemeRenderer.h
@@ -174,6 +174,7 @@ protected:
kTextDataInverted,
kTextDataButton,
kTextDataButtonHover,
+ kTextDataNormalFont,
kTextDataMAX
};
@@ -264,10 +265,30 @@ public:
/**
* FONT MANAGEMENT METHODS
*/
- const Graphics::Font *getFont(FontStyle font) const { return _font; }
- int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; }
- int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; }
- int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; }
+
+ TextData fontStyleToData(FontStyle font) const {
+ switch (font) {
+ case kFontStyleNormal:
+ return kTextDataNormalFont;
+
+ default:
+ return kTextDataDefault;
+ }
+ }
+
+ const Graphics::Font *getFont(FontStyle font) const { return _texts[fontStyleToData(font)]->_fontPtr; }
+
+ int getFontHeight(FontStyle font = kFontStyleBold) const {
+ return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getFontHeight() : 0;
+ }
+
+ int getStringWidth(const Common::String &str, FontStyle font) const {
+ return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getStringWidth(str) : 0;
+ }
+
+ int getCharWidth(byte c, FontStyle font) const {
+ return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getCharWidth(c) : 0;
+ }
/**
@@ -372,7 +393,7 @@ public:
* @param cached Whether this DD set will be cached beforehand.
*/
bool addDrawData(const Common::String &data, bool cached);
- bool addFont(const Common::String &fontName, int r, int g, int b);
+ bool addFont(const Common::String &fontName, const Common::String &file, int r, int g, int b);
/**
* Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the
@@ -391,7 +412,7 @@ public:
* this checks if the renderer is initialized AND if the theme
* is loaded.
*/
- bool ready() {
+ bool ready() const {
return _initOk && _themeOk;
}
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index eb6747923be..fa7f3b52364 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1 +1 @@
-" "
+" "
diff --git a/gui/themes/modern.stx b/gui/themes/modern.stx
index f182f6a2d59..be557498061 100644
--- a/gui/themes/modern.stx
+++ b/gui/themes/modern.stx
@@ -59,29 +59,33 @@
+
@@ -298,10 +302,24 @@
horizontal_align = 'right'
/>
+
+
+
+
-/* Tanoku-TODO: text editing width + CARET!
-/*
-
+
+
+