improve text node xml
This commit is contained in:
25
src/node.cpp
25
src/node.cpp
@@ -1404,7 +1404,6 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::Image, NodeImage);
|
||||
CASE(kWidget::ImageTexture, NodeImageTexture);
|
||||
CASE(kWidget::Icon, NodeIcon);
|
||||
CASE(kWidget::Text, NodeText);
|
||||
CASE(kWidget::TextInput, NodeTextInput);
|
||||
CASE(kWidget::Button, NodeButton);
|
||||
CASE(kWidget::ButtonCustom, NodeButtonCustom);
|
||||
@@ -1439,6 +1438,30 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::Timeline, NodeAnimationTimeline);
|
||||
CASE(kWidget::Metadata, NodeMetadata);
|
||||
#undef CASE
|
||||
case kWidget::Text:
|
||||
{
|
||||
auto n = new NodeText();
|
||||
add_child(n);
|
||||
n->load_internal(x_child);
|
||||
std::string text;
|
||||
auto node = x_child->FirstChild();
|
||||
while (node)
|
||||
{
|
||||
if (auto e = node->ToElement())
|
||||
{
|
||||
if (strcmp(e->Name(), "br") == 0)
|
||||
text.append("\n");
|
||||
}
|
||||
else if (auto t = node->ToText())
|
||||
{
|
||||
text.append(t->Value());
|
||||
}
|
||||
node = node->NextSibling();
|
||||
}
|
||||
if (!text.empty())
|
||||
n->set_text(text);
|
||||
break;
|
||||
}
|
||||
case kWidget::Ref:
|
||||
{
|
||||
auto ids = x_child->Attribute("id");
|
||||
|
||||
Reference in New Issue
Block a user