From 45210c4fd718e75ba47171fc6b28da04df668ef9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 19 Oct 2012 18:55:08 +0300 Subject: Add support for loading different color palettes. colors.xml converted to new format --- src/gui/theme.cpp | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'src') 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); + } } } } -- cgit v1.2.3-60-g2f50