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
This commit is contained in:
that
2015-02-15 20:36:40 +01:00
parent cfd6509027
commit f6ed8fc1f5
21 changed files with 254 additions and 407 deletions
+4 -10
View File
@@ -40,12 +40,8 @@ GUIImage::GUIImage(xml_node<>* node) : GUIObject(node)
child = node->first_node("image");
if (child)
{
attr = child->first_attribute("resource");
if (attr)
mImage = PageManager::FindResource(attr->value());
attr = child->first_attribute("highlightresource");
if (attr)
mHighlightImage = PageManager::FindResource(attr->value());
mImage = LoadAttrImage(child, "resource");
mHighlightImage = LoadAttrImage(child, "highlightresource");
}
// Load the placement
@@ -53,8 +49,8 @@ GUIImage::GUIImage(xml_node<>* node) : GUIObject(node)
if (mImage && mImage->GetResource())
{
mRenderW = gr_get_width(mImage->GetResource());
mRenderH = gr_get_height(mImage->GetResource());
mRenderW = mImage->GetWidth();
mRenderH = mImage->GetHeight();
// Adjust for placement
if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
@@ -73,8 +69,6 @@ GUIImage::GUIImage(xml_node<>* node) : GUIObject(node)
}
SetPlacement(TOP_LEFT);
}
return;
}
int GUIImage::Render(void)