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:
+8
-27
@@ -129,32 +129,15 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node)
|
||||
child = node->first_node("font");
|
||||
if (child)
|
||||
{
|
||||
attr = child->first_attribute("resource");
|
||||
if (attr)
|
||||
mFont = PageManager::FindResource(attr->value());
|
||||
mFont = LoadAttrFont(child, "resource");
|
||||
}
|
||||
|
||||
child = node->first_node("color");
|
||||
if (child)
|
||||
{
|
||||
attr = child->first_attribute("foreground");
|
||||
if (attr)
|
||||
{
|
||||
std::string color = attr->value();
|
||||
ConvertStrToColor(color, &mForegroundColor);
|
||||
}
|
||||
attr = child->first_attribute("background");
|
||||
if (attr)
|
||||
{
|
||||
std::string color = attr->value();
|
||||
ConvertStrToColor(color, &mBackgroundColor);
|
||||
}
|
||||
attr = child->first_attribute("scroll");
|
||||
if (attr)
|
||||
{
|
||||
std::string color = attr->value();
|
||||
ConvertStrToColor(color, &mScrollColor);
|
||||
}
|
||||
mForegroundColor = LoadAttrColor(child, "foreground", mForegroundColor);
|
||||
mBackgroundColor = LoadAttrColor(child, "background", mBackgroundColor);
|
||||
mScrollColor = LoadAttrColor(child, "scroll", mScrollColor);
|
||||
}
|
||||
|
||||
// Load the placement
|
||||
@@ -166,21 +149,19 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node)
|
||||
mSlideout = 1;
|
||||
LoadPlacement(child, &mSlideoutX, &mSlideoutY);
|
||||
|
||||
attr = child->first_attribute("resource");
|
||||
if (attr) mSlideoutImage = PageManager::FindResource(attr->value());
|
||||
mSlideoutImage = LoadAttrImage(child, "resource");
|
||||
|
||||
if (mSlideoutImage && mSlideoutImage->GetResource())
|
||||
{
|
||||
mSlideoutW = gr_get_width(mSlideoutImage->GetResource());
|
||||
mSlideoutH = gr_get_height(mSlideoutImage->GetResource());
|
||||
mSlideoutW = mSlideoutImage->GetWidth();
|
||||
mSlideoutH = mSlideoutImage->GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mFontHeight = gr_getMaxFontHeight(mFont ? mFont->GetResource() : NULL);
|
||||
mFontHeight = mFont->GetHeight();
|
||||
SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
|
||||
SetRenderPos(mConsoleX, mConsoleY);
|
||||
return;
|
||||
}
|
||||
|
||||
int GUIConsole::RenderSlideout(void)
|
||||
|
||||
Reference in New Issue
Block a user