nodes: implementing saving/loading node positions from project file

This commit is contained in:
itsmattkc
2020-04-28 03:43:35 +10:00
parent 3c01b14a14
commit d74d6a1542
5 changed files with 20 additions and 5 deletions
+12 -1
View File
@@ -26,15 +26,25 @@
OLIVE_NAMESPACE_ENTER
Node* XMLLoadNode(QXmlStreamReader* reader) {
Node* XMLLoadNode(QXmlStreamReader* reader)
{
QString node_id;
quintptr node_ptr = 0;
QPointF node_pos;
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
node_id = attr.value().toString();
} else if (attr.name() == QStringLiteral("ptr")) {
node_ptr = attr.value().toULongLong();
} else if (attr.name() == QStringLiteral("pos")) {
QStringList pos = attr.value().toString().split(':');
// Protection in case this file has been messed with
if (pos.size() == 2) {
node_pos.setX(pos.at(0).toDouble());
node_pos.setY(pos.at(1).toDouble());
}
}
}
@@ -47,6 +57,7 @@ Node* XMLLoadNode(QXmlStreamReader* reader) {
if (node) {
node->setProperty("xml_ptr", node_ptr);
node->SetPosition(node_pos);
} else {
qWarning() << "Failed to load" << node_id << "- no node with that ID is installed";
}