improve text node xml

This commit is contained in:
2019-11-29 02:17:54 +01:00
parent c6173987af
commit 26257e5a37
5 changed files with 59 additions and 28 deletions

View File

@@ -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");