From f6ed8fc1f51e368bb76905d9f1d2d3735e70a644 Mon Sep 17 00:00:00 2001 From: that Date: Sat, 14 Feb 2015 20:23:16 +0100 Subject: gui: make resources type safe - add string, int, color and resource loading helpers - use typed resource classes, and some cleanup in loading code - remove abstract GetResource() to enforce type safe access - add height and width query methods to resources and use them - minor cleanup - simplify LoadPlacement Change-Id: I9b81785109a80b3806ad6b50cba4d893b87b0db1 --- gui/slider.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'gui/slider.cpp') diff --git a/gui/slider.cpp b/gui/slider.cpp index 98d2ddea3..c53dabc28 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -47,31 +47,20 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) child = node->first_node("resource"); if (child) { - attr = child->first_attribute("base"); - if (attr) - sSlider = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("used"); - if (attr) - sSliderUsed = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("touch"); - if (attr) - sTouch = PageManager::FindResource(attr->value()); + sSlider = LoadAttrImage(child, "base"); + sSliderUsed = LoadAttrImage(child, "used"); + sTouch = LoadAttrImage(child, "touch"); } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY); - if (sSlider && sSlider->GetResource()) - { - mRenderW = gr_get_width(sSlider->GetResource()); - mRenderH = gr_get_height(sSlider->GetResource()); - } + mRenderW = sSlider->GetWidth(); + mRenderH = sSlider->GetHeight(); if (sTouch && sTouch->GetResource()) { - sTouchW = gr_get_width(sTouch->GetResource()); // Width of the "touch image" that follows the touch (arrow) - sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow) + sTouchW = sTouch->GetWidth(); // Width of the "touch image" that follows the touch (arrow) + sTouchH = sTouch->GetHeight(); // Height of the "touch image" that follows the touch (arrow) } //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW); -- cgit v1.2.3