works with yaml 2.6
This commit is contained in:
parent
3cea0cb7c6
commit
35fc76f0a6
|
@ -123,6 +123,8 @@ ENDIF(WIN32)
|
||||||
ADD_EXECUTABLE(otclient ${SOURCES})
|
ADD_EXECUTABLE(otclient ${SOURCES})
|
||||||
|
|
||||||
# target link libraries
|
# target link libraries
|
||||||
|
MESSAGE(
|
||||||
|
${YAMLCPP_LIBRARY})
|
||||||
TARGET_LINK_LIBRARIES(otclient
|
TARGET_LINK_LIBRARIES(otclient
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
FIND_PATH(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
|
FIND_PATH(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
|
||||||
HINTS
|
HINTS
|
||||||
$ENV{PHYSFSDIR}
|
|
||||||
PATH_SUFFIXES include/yaml-cpp include
|
PATH_SUFFIXES include/yaml-cpp include
|
||||||
PATHS
|
PATHS
|
||||||
~/Library/Frameworks
|
~/Library/Frameworks
|
||||||
|
@ -22,8 +21,6 @@ PATHS
|
||||||
|
|
||||||
FIND_LIBRARY(YAMLCPP_LIBRARY
|
FIND_LIBRARY(YAMLCPP_LIBRARY
|
||||||
NAMES yaml-cpp
|
NAMES yaml-cpp
|
||||||
HINTS
|
|
||||||
$ENV{PHYSFSDIR}
|
|
||||||
PATH_SUFFIXES lib64 lib
|
PATH_SUFFIXES lib64 lib
|
||||||
PATHS
|
PATHS
|
||||||
~/Library/Frameworks
|
~/Library/Frameworks
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
default font: sans-11px-bold
|
default font: sans-11px-bold
|
||||||
default font color: [51, 51, 51, 255]
|
default font color: [51, 51, 51, 255]
|
||||||
|
|
||||||
buttons:
|
buttons:
|
||||||
default:
|
default:
|
||||||
default size: [96, 22]
|
default size: [96, 22]
|
||||||
|
@ -134,3 +134,4 @@ line decorations:
|
||||||
bordered image:
|
bordered image:
|
||||||
source: lightness/window.png
|
source: lightness/window.png
|
||||||
top border: [2,254,252,2]
|
top border: [2,254,252,2]
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
|
||||||
foreach(const UIElementPtr& element, container->getChildren()) {
|
foreach(const UIElementPtr& element, container->getChildren()) {
|
||||||
for(auto it = node.begin(); it != node.end(); ++it) {
|
for(auto it = node.begin(); it != node.end(); ++it) {
|
||||||
// node found, load 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());
|
loadElements(element, it.second());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
|
||||||
// set element skin
|
// set element skin
|
||||||
if(yamlHasValue(node, "skin")) {
|
if(yamlHasValue(node, "skin")) {
|
||||||
const YAML::Node& cnode = node["skin"];
|
const YAML::Node& cnode = node["skin"];
|
||||||
if(cnode.GetType() == YAML::CT_SCALAR) {
|
if(cnode.Type() == YAML::NodeType::Scalar) {
|
||||||
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), cnode));
|
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), yamlRead<std::string>(cnode)));
|
||||||
} else {
|
} else {
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin());
|
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin());
|
||||||
skin->load(cnode);
|
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)
|
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
|
// set on click event
|
||||||
if(yamlHasValue(node, "onClick")) {
|
if(yamlHasValue(node, "onClick")) {
|
||||||
|
|
|
@ -66,7 +66,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UIButtonSkin(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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::Panel));
|
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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +92,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UIWindowSkin(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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +105,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UILabelSkin(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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +119,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UITextEditSkin(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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +133,8 @@ void UISkins::load(const std::string& skinsFile)
|
||||||
it.first() >> name;
|
it.first() >> name;
|
||||||
|
|
||||||
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::LineDecoration));
|
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);
|
m_elementSkins.push_back(skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ inline void operator>>(const YAML::Node& node, TSize<T>& size)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T yamlRead(const YAML::Node& node)
|
inline T yamlRead(const YAML::Node& node)
|
||||||
{
|
{
|
||||||
return node.Read<T>();
|
return node.to<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
Loading…
Reference in New Issue