diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-19 18:55:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-20 13:55:42 +0300 |
commit | 45210c4fd718e75ba47171fc6b28da04df668ef9 (patch) | |
tree | 6ceebd880d7a1186e617e062b516134c98943907 /src/gui/theme.cpp | |
parent | df5cd98862d5328c6765b992a3a6e1b3458a1d8a (diff) | |
download | manaplus-45210c4fd718e75ba47171fc6b28da04df668ef9.tar.gz manaplus-45210c4fd718e75ba47171fc6b28da04df668ef9.tar.bz2 manaplus-45210c4fd718e75ba47171fc6b28da04df668ef9.tar.xz manaplus-45210c4fd718e75ba47171fc6b28da04df668ef9.zip |
Add support for loading different color palettes.
colors.xml converted to new format
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r-- | src/gui/theme.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 9ecac247c..71c864c0f 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -47,6 +47,8 @@ std::string Theme::mThemePath; std::string Theme::mThemeName; Theme *Theme::mInstance = nullptr; +static const int THEME_PALETTES = 5; + // Set the theme path... static void initDefaultThemePath() { @@ -172,7 +174,7 @@ int Skin::getMinHeight() const } Theme::Theme(): - Palette(THEME_COLORS_END), + Palette(THEME_COLORS_END * THEME_PALETTES), mMinimumOpacity(-1.0f), mProgressColors(ProgressColors(THEME_PROG_END)) { @@ -908,31 +910,43 @@ void Theme::loadColors(std::string file) gcn::Color color; GradientType grad; - for_each_xml_child_node(node, root) + for_each_xml_child_node(paletteNode, root) { - if (xmlNameEqual(node, "color")) + if (xmlNameEqual(paletteNode, "progressbar")) { - type = readColorType(XML::getProperty(node, "id", "")); + type = readProgressType(XML::getProperty(paletteNode, "id", "")); if (type < 0) // invalid or no type given continue; - temp = XML::getProperty(node, "color", ""); - if (temp.empty()) // no color set, so move on - continue; + mProgressColors[type] = new DyePalette(XML::getProperty( + paletteNode, "color", ""), 6); + } + else if (!xmlNameEqual(paletteNode, "palette")) + { + continue; + } - color = readColor(temp); - grad = readColorGradient(XML::getProperty(node, "effect", "")); + int paletteId = XML::getProperty(paletteNode, "id", 1); + if (paletteId < 1 || paletteId > THEME_PALETTES) + continue; - mColors[type].set(type, color, grad, 10); - } - else if (xmlNameEqual(node, "progressbar")) + for_each_xml_child_node(node, paletteNode) { - type = readProgressType(XML::getProperty(node, "id", "")); - if (type < 0) // invalid or no type given - continue; + if (xmlNameEqual(node, "color")) + { + type = readColorType(XML::getProperty(node, "id", "")); + if (type < 0) // invalid or no type given + continue; - mProgressColors[type] = new DyePalette(XML::getProperty(node, - "color", ""), 6); + temp = XML::getProperty(node, "color", ""); + if (temp.empty()) // no color set, so move on + continue; + + color = readColor(temp); + grad = readColorGradient(XML::getProperty(node, "effect", "")); + + mColors[type * paletteId].set(type, color, grad, 10); + } } } } |