diff options
author | Vicent Marti | 2008-06-28 00:02:54 +0000 |
---|---|---|
committer | Vicent Marti | 2008-06-28 00:02:54 +0000 |
commit | 3f0f7fa08bea272fa61b0fde5d7783aa44b1ff25 (patch) | |
tree | 4f9f5520000b96bfa8a6e3d32727ac8248befacf /gui | |
parent | 8d696760b37e1dd36191a7403d44d4de105bd7de (diff) | |
download | scummvm-rg350-3f0f7fa08bea272fa61b0fde5d7783aa44b1ff25.tar.gz scummvm-rg350-3f0f7fa08bea272fa61b0fde5d7783aa44b1ff25.tar.bz2 scummvm-rg350-3f0f7fa08bea272fa61b0fde5d7783aa44b1ff25.zip |
Improved support for parsing integers in the XML parser.
Bug fixes.
svn-id: r32818
Diffstat (limited to 'gui')
-rw-r--r-- | gui/InterfaceManager.cpp | 2 | ||||
-rw-r--r-- | gui/ThemeDefaultXML.cpp | 2 | ||||
-rw-r--r-- | gui/ThemeParser.cpp | 10 | ||||
-rw-r--r-- | gui/ThemeParser.h | 19 |
4 files changed, 7 insertions, 26 deletions
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index cbaf1bbf5b..7a779df593 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -137,7 +137,7 @@ bool InterfaceManager::loadTheme(Common::String themeName) { warning("Could not parse custom theme '%s'.\nFalling back to default theme", themeName.c_str()); if (!loadDefaultXML()) // if we can't load the embeded theme, this is a complete failure - error("Could not load default embeded theme."); + error("Could not load default embeded theme"); } for (int i = 0; i < kDrawDataMAX; ++i) { diff --git a/gui/ThemeDefaultXML.cpp b/gui/ThemeDefaultXML.cpp index 0d9faf0768..cd571e680e 100644 --- a/gui/ThemeDefaultXML.cpp +++ b/gui/ThemeDefaultXML.cpp @@ -51,7 +51,7 @@ bool InterfaceManager::loadDefaultXML() { "</drawdata>" "<drawdata id = 'button_idle' cache = false>" - "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' />" + "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />" "</drawdata>" "</render_info>" diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 671a4a543e..8dc02297b7 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -175,7 +175,7 @@ bool ThemeParser::parserCallback_color() { int red, green, blue; - if (sscanf(colorNode->values["rgb"].c_str(), "%d, %d, %d", &red, &green, &blue) != 3 || + if (parseIntegerKey(colorNode->values["rgb"].c_str(), 3, &red, &green, &blue) == false || red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) return parserError("Error when parsing RGB values for palette color '%s'", name.c_str());\ @@ -263,7 +263,7 @@ bool ThemeParser::parserCallback_DRAWDATA() { } bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific) { - int red, green, blue, w, h; + int red, green, blue, w, h, x; Common::String val; /** @@ -278,10 +278,10 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst */ #define __PARSER_ASSIGN_INT(struct_name, key_name, force) \ if (stepNode->values.contains(key_name)) { \ - if (!validateKeyInt(stepNode->values[key_name].c_str()))\ + if (!parseIntegerKey(stepNode->values[key_name].c_str(), 1, &x)) \ return parserError("Error when parsing key value for '%s'.", key_name); \ \ - drawstep->struct_name = atoi(stepNode->values[key_name].c_str()); \ + drawstep->struct_name = x; \ } else if (force) { \ return parserError("Missing necessary key '%s'.", key_name); \ } @@ -304,7 +304,7 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst red = _palette[val].r; \ green = _palette[val].g; \ blue = _palette[val].b; \ - } else if (sscanf(val.c_str(), "%d, %d, %d", &red, &green, &blue) != 3 || \ + } else if (parseIntegerKey(val.c_str(), 3, &red, &green, &blue) == false || \ red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) \ return parserError("Error when parsing color struct '%s'", val.c_str());\ \ diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h index 2a7e0999d5..55f39d8a44 100644 --- a/gui/ThemeParser.h +++ b/gui/ThemeParser.h @@ -325,25 +325,6 @@ protected: bool parserCallback_renderInfo(); bool parserCallback_layoutInfo(); bool parserCallback_defaultSet(); - - - bool validateKeyIntSigned(const char *key) { - if (!isdigit(*key) && *key != '+' && *key != '-') - return false; - - return validateKeyInt(key + 1); - } - - bool validateKeyInt(const char *key) { - if (*key == 0) - return false; - - while (*key) - if (!isdigit(*key++)) - return false; - - return true; - } Graphics::DrawStep *newDrawStep(); Graphics::DrawStep *defaultDrawStep(); |