simpler yaml read

This commit is contained in:
Eduardo Bart 2011-04-13 22:32:50 -03:00
parent 0f7f7827f5
commit 5616259feb
4 changed files with 8 additions and 20 deletions

View File

@ -30,8 +30,6 @@ void UIButtonSkin::load(const YAML::Node& node)
{ {
UIElementSkin::load(node); UIElementSkin::load(node);
std::string tmp;
m_buttonDownImage = loadImage(node["down state"]); m_buttonDownImage = loadImage(node["down state"]);
if(node["down state"].FindValue("text translate")) if(node["down state"].FindValue("text translate"))
@ -40,8 +38,7 @@ void UIButtonSkin::load(const YAML::Node& node)
if(node.FindValue("mouse over state")) if(node.FindValue("mouse over state"))
m_buttonHoverImage = loadImage(node["mouse over state"]); m_buttonHoverImage = loadImage(node["mouse over state"]);
node["font"] >> tmp; m_font = g_fonts.get(node["font"].Read<std::string>());
m_font = g_fonts.get(tmp);
node["text color"] >> m_textColor; node["text color"] >> m_textColor;
} }

View File

@ -29,12 +29,10 @@
void UILabelSkin::load(const YAML::Node& node) void UILabelSkin::load(const YAML::Node& node)
{ {
UIElementSkin::load(node); UIElementSkin::load(node);
std::string tmp;
if(node.FindValue("font")) { if(node.FindValue("font"))
node["font"] >> tmp; m_font = g_fonts.get(node["font"].Read<std::string>());
m_font = g_fonts.get(tmp); else
} else
m_font = g_fonts.getDefaultFont(); m_font = g_fonts.getDefaultFont();
if(node.FindValue("text color")) if(node.FindValue("text color"))

View File

@ -142,8 +142,6 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node) void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
{ {
std::string tmp;
if(node.FindValue("skin")) if(node.FindValue("skin"))
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), node["skin"])); element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), node["skin"]));
@ -195,18 +193,15 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
// load specific element type // load specific element type
if(element->getElementType() == UI::Button) { if(element->getElementType() == UI::Button) {
UIButtonPtr button = boost::static_pointer_cast<UIButton>(element); UIButtonPtr button = boost::static_pointer_cast<UIButton>(element);
node["text"] >> tmp; button->setText(node["text"].Read<std::string>());
button->setText(tmp);
} }
else if(element->getElementType() == UI::Window) { else if(element->getElementType() == UI::Window) {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element); UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
node["title"] >> tmp; window->setTitle(node["title"].Read<std::string>());
window->setTitle(tmp);
} }
else if(element->getElementType() == UI::Label) { else if(element->getElementType() == UI::Label) {
UILabelPtr label = boost::static_pointer_cast<UILabel>(element); UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
node["text"] >> tmp; label->setText(node["text"].Read<std::string>());
label->setText(tmp);
} }
} }

View File

@ -29,11 +29,9 @@
void UITextEditSkin::load(const YAML::Node& node) void UITextEditSkin::load(const YAML::Node& node)
{ {
UIElementSkin::load(node); UIElementSkin::load(node);
std::string tmp;
if(node.FindValue("font")) { if(node.FindValue("font")) {
node["font"] >> tmp; m_font = g_fonts.get(node["font"].Read<std::string>());
m_font = g_fonts.get(tmp);
} else } else
m_font = g_fonts.getDefaultFont(); m_font = g_fonts.getDefaultFont();