aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeParser.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2009-08-10 13:46:17 +0000
committerJohannes Schickel2009-08-10 13:46:17 +0000
commitf812d0e7b744910e9df5525f71238078794a8fab (patch)
tree3e8e4687ed4180853b913f15de33aaef62e136f9 /gui/ThemeParser.cpp
parent44cfd9d615216c479293187b6ad1fcae3c851fba (diff)
downloadscummvm-rg350-f812d0e7b744910e9df5525f71238078794a8fab.tar.gz
scummvm-rg350-f812d0e7b744910e9df5525f71238078794a8fab.tar.bz2
scummvm-rg350-f812d0e7b744910e9df5525f71238078794a8fab.zip
Made font color configuration independend from font style configuration.
svn-id: r43205
Diffstat (limited to 'gui/ThemeParser.cpp')
-rw-r--r--gui/ThemeParser.cpp63
1 files changed, 49 insertions, 14 deletions
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 8897eef9d7..85ae052f36 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -38,13 +38,9 @@ struct TextDataInfo {
};
static const TextDataInfo kTextDataDefaults[] = {
- {kTextDataDefault, "text_default"},
- {kTextDataHover, "text_hover"},
- {kTextDataDisabled, "text_disabled"},
- {kTextDataInverted, "text_inverted"},
- {kTextDataButton, "text_button"},
- {kTextDataButtonHover, "text_button_hover"},
- {kTextDataNormalFont, "text_normal"}
+ { kTextDataDefault, "text_default" },
+ { kTextDataButton, "text_button" },
+ { kTextDataNormalFont, "text_normal" }
};
@@ -56,6 +52,33 @@ static TextData parseTextDataId(const Common::String &name) {
return kTextDataNone;
}
+struct TextColorDataInfo {
+ TextColor id;
+ const char *name;
+};
+
+static const TextColorDataInfo kTextColorDefaults[] = {
+ { kTextColorNormal, "color_normal" },
+ { kTextColorNormalInverted, "color_normal_inverted" },
+ { kTextColorNormalHover, "color_normal_hover" },
+ { kTextColorNormalDisabled, "color_normal_disabled" },
+ { kTextColorAlternative, "color_alternative" },
+ { kTextColorAlternativeInverted, "color_alternative_inverted" },
+ { kTextColorAlternativeHover, "color_alternative_hover" },
+ { kTextColorAlternativeDisabled, "color_alternative_disabled" },
+ { kTextColorButton, "color_button" },
+ { kTextColorButtonHover, "color_button_hover" },
+ { kTextColorButtonDisabled, "color_button_disabled" }
+};
+
+static TextColor parseTextColorId(const Common::String &name) {
+ for (int i = 0; i < kTextColorMAX; ++i)
+ if (name.compareToIgnoreCase(kTextColorDefaults[i].name) == 0)
+ return kTextColorDefaults[i].id;
+
+ return kTextColorMAX;
+}
+
static Graphics::TextAlign parseTextHAlign(const Common::String &val) {
if (val == "left")
return Graphics::kTextAlignLeft;
@@ -148,21 +171,32 @@ bool ThemeParser::parserCallback_defaults(ParserNode *node) {
}
bool ThemeParser::parserCallback_font(ParserNode *node) {
- int red, green, blue;
-
if (resolutionCheck(node->values["resolution"]) == false) {
node->ignore = true;
return true;
}
+ TextData textDataId = parseTextDataId(node->values["id"]);
+ if (!_theme->addFont(textDataId, node->values["file"]))
+ return parserError("Error loading Font in theme engine.");
+
+ return true;
+}
+
+bool ThemeParser::parserCallback_text_color(ParserNode *node) {
+ int red, green, blue;
+
+ TextColor colorId = parseTextColorId(node->values["id"]);
+ if (colorId == kTextColorMAX)
+ return parserError("Error text color is not defined.");
+
if (_palette.contains(node->values["color"]))
getPaletteColor(node->values["color"], red, green, blue);
else if (!parseIntegerKey(node->values["color"].c_str(), 3, &red, &green, &blue))
- return parserError("Error parsing color value for font definition.");
+ return parserError("Error parsing color value for text color definition.");
- TextData textDataId = parseTextDataId(node->values["id"]);
- if (!_theme->addFont(textDataId, node->values["file"], red, green, blue))
- return parserError("Error loading Font in theme engine.");
+ if (!_theme->addTextColor(colorId, red, green, blue))
+ return parserError("Error while adding text color information.");
return true;
}
@@ -215,8 +249,9 @@ bool ThemeParser::parserCallback_text(ParserNode *node) {
Common::String id = getParentNode(node)->values["id"];
TextData textDataId = parseTextDataId(node->values["font"]);
+ TextColor textColorId = parseTextColorId(node->values["font_color"]);
- if (!_theme->addTextData(id, textDataId, alignH, alignV))
+ if (!_theme->addTextData(id, textDataId, textColorId, alignH, alignV))
return parserError("Error adding Text Data for '%s'.", id.c_str());
return true;