works with yaml 2.6

This commit is contained in:
Eduardo Bart 2011-05-13 23:21:25 -03:00
parent 3cea0cb7c6
commit 35fc76f0a6
6 changed files with 21 additions and 15 deletions

View File

@ -123,6 +123,8 @@ ENDIF(WIN32)
ADD_EXECUTABLE(otclient ${SOURCES})
# target link libraries
MESSAGE(
${YAMLCPP_LIBRARY})
TARGET_LINK_LIBRARIES(otclient
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}

View File

@ -7,7 +7,6 @@
FIND_PATH(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
HINTS
$ENV{PHYSFSDIR}
PATH_SUFFIXES include/yaml-cpp include
PATHS
~/Library/Frameworks
@ -22,8 +21,6 @@ PATHS
FIND_LIBRARY(YAMLCPP_LIBRARY
NAMES yaml-cpp
HINTS
$ENV{PHYSFSDIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks

View File

@ -134,3 +134,4 @@ line decorations:
bordered image:
source: lightness/window.png
top border: [2,254,252,2]

View File

@ -155,7 +155,7 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
foreach(const UIElementPtr& element, container->getChildren()) {
for(auto it = node.begin(); it != node.end(); ++it) {
// node found, load it
if(boost::ends_with(it.first().Read<std::string>(), "#" + element->getId())) {
if(boost::ends_with(yamlRead<std::string>(it.first()), "#" + element->getId())) {
loadElements(element, it.second());
break;
}
@ -169,8 +169,8 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
// set element skin
if(yamlHasValue(node, "skin")) {
const YAML::Node& cnode = node["skin"];
if(cnode.GetType() == YAML::CT_SCALAR) {
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), cnode));
if(cnode.Type() == YAML::NodeType::Scalar) {
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), yamlRead<std::string>(cnode)));
} else {
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin());
skin->load(cnode);
@ -268,7 +268,7 @@ void UILoader::loadElementAnchor(const UIElementPtr& anchoredElement, UI::Anchor
void UILoader::loadButton(const UIButtonPtr& button, const YAML::Node& node)
{
button->setText(node["text"].Read<std::string>());
button->setText(yamlRead<std::string>(node["text"]));
// set on click event
if(yamlHasValue(node, "onClick")) {

View File

@ -66,7 +66,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UIButtonSkin(name));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
@ -78,7 +79,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::Panel));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
@ -90,7 +92,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UIWindowSkin(name));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
@ -102,7 +105,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UILabelSkin(name));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
@ -115,7 +119,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UITextEditSkin(name));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
@ -128,7 +133,8 @@ void UISkins::load(const std::string& skinsFile)
it.first() >> name;
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::LineDecoration));
skin->load(it.second());
if(it.second().Type() == YAML::NodeType::Map)
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}

View File

@ -68,7 +68,7 @@ inline void operator>>(const YAML::Node& node, TSize<T>& size)
template<class T>
inline T yamlRead(const YAML::Node& node)
{
return node.Read<T>();
return node.to<T>();
}
template<class T>