From 21ff02a69331fbcd53dc93a1af9a93618225b4bf Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 18 Feb 2015 14:35:00 -0600 Subject: GUI: Support styles in xml to reduce xml file size Also allow sliders to have their own text label instead of requiring a whole separate text object for the label in the xml. Change-Id: I6e314efb4bb454d496555ff7e003d743063a1308 --- gui/animation.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'gui/animation.cpp') diff --git a/gui/animation.cpp b/gui/animation.cpp index 1e9a87d3f..888b4ab08 100644 --- a/gui/animation.cpp +++ b/gui/animation.cpp @@ -29,7 +29,6 @@ extern "C" { GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) { xml_node<>* child; - xml_attribute<>* attr; mAnimation = NULL; mFrame = 1; @@ -40,36 +39,26 @@ GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) if (!node) return; - child = node->first_node("resource"); - if (child) - { - mAnimation = LoadAttrAnimation(child, "name"); - } + mAnimation = LoadAttrAnimation(FindNode(node, "resource"), "name"); // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); - child = node->first_node("speed"); + child = FindNode(node, "speed"); if (child) { - attr = child->first_attribute("fps"); - if (attr) - mFPS = atoi(attr->value()); - attr = child->first_attribute("render"); - if (attr) - mRender = atoi(attr->value()); + mFPS = LoadAttrInt(child, "fps", mFPS); + mRender = LoadAttrInt(child, "render", mRender); } if (mFPS > 30) mFPS = 30; - child = node->first_node("loop"); + child = FindNode(node, "loop"); if (child) { - attr = child->first_attribute("frame"); + xml_attribute<>* attr = child->first_attribute("frame"); if (attr) mLoop = atoi(attr->value()) - 1; - attr = child->first_attribute("start"); - if (attr) - mFrame = atoi(attr->value()); + mFrame = LoadAttrInt(child, "start", mFrame); } // Fetch the render sizes -- cgit v1.2.3