Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ void AbstractNodeGraph::loadGraphV11(const QDomElement &parent) {
list.push_back(it);
}
values[name] = list;
} else if(type == "Color") {
QVariantList list;
list.push_back(type);
for(auto &it : valueElement.text().split(", ")) {
list.push_back(it);
}
values[name] = list;
}

valueElement = valueElement.nextSiblingElement();
Expand Down Expand Up @@ -494,19 +501,27 @@ void AbstractNodeGraph::saveGraph(QDomElement parent, QDomDocument xml) const {
valueElement.setAttribute(gName, value);

QVariant v = values.value(value);
if(v.type() == QVariant::List) {
QVariantList list = v.toList();
valueElement.setAttribute(gType, list.front().toString());
list.pop_front();
QString pack;
for(auto &it : list) {
pack += it.toString() + ", ";
}
pack.resize(pack.size() - 2);
valueElement.appendChild(xml.createTextNode(pack));
} else {
valueElement.setAttribute(gType, v.typeName());
valueElement.appendChild(xml.createTextNode(v.toString()));
switch(v.type()) {
case QVariant::List: {
QVariantList list = v.toList();
QString type = list.front().toString();
valueElement.setAttribute(gType, type);
list.pop_front();
QString pack;
for(auto &it : list) {
pack += it.toString() + ", ";
}
pack.resize(pack.size() - 2);
valueElement.appendChild(xml.createTextNode(pack));
} break;
default: {
QString type = v.typeName();
if(type == "QString") {
type = "string";
}
valueElement.setAttribute(gType, type);
valueElement.appendChild(xml.createTextNode(v.toString()));
} break;
}

nodeElement.appendChild(valueElement);
Expand Down
46 changes: 21 additions & 25 deletions modules/editor/grapheditor/editor/graph/graphnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void GraphNode::saveUserData(QVariantMap &data) {
switch(value.userType()) {
case QMetaType::QColor: {
QVariantList v;
v.push_back(static_cast<int32_t>(QVariant::Color));
v.push_back("Color");
QColor col = value.value<QColor>();
v.push_back(col.red());
v.push_back(col.green());
Expand Down Expand Up @@ -140,30 +140,26 @@ void GraphNode::loadUserData(const QVariantMap &data) {
for(QString key : data.keys()) {
if(static_cast<QMetaType::Type>(data[key].type()) == QMetaType::QVariantList) {
QVariantList array = data[key].toList();
switch(array.first().toInt()) {
case QVariant::Color: {
setProperty(qPrintable(key), QColor(array.at(1).toInt(), array.at(2).toInt(),
array.at(3).toInt(), array.at(4).toInt()));
} break;
default: {
QString type = array.first().toString();
if(type == "Template") {
setProperty(qPrintable(key), QVariant::fromValue(Template(array.at(1).toString(),
array.at(2).toUInt())));
} else if(type == "Vector2") {
setProperty(qPrintable(key), QVariant::fromValue(Vector2(array.at(1).toFloat(),
array.at(2).toFloat())));
} else if(type == "Vector3") {
setProperty(qPrintable(key), QVariant::fromValue(Vector3(array.at(1).toFloat(),
array.at(2).toFloat(),
array.at(3).toFloat())));
} else if(type == "Vector4") {
setProperty(qPrintable(key), QVariant::fromValue(Vector4(array.at(1).toFloat(),
array.at(2).toFloat(),
array.at(3).toFloat(),
array.at(4).toFloat() )));
}
} break;

QString type = array.first().toString();
if(type == "Color") {
setProperty(qPrintable(key), QColor(array.at(1).toInt(), array.at(2).toInt(),
array.at(3).toInt(), array.at(4).toInt()));
} else if(type == "Template") {
setProperty(qPrintable(key), QVariant::fromValue(Template(array.at(1).toString(),
array.at(2).toUInt())));
} else if(type == "Vector2") {
setProperty(qPrintable(key), QVariant::fromValue(Vector2(array.at(1).toFloat(),
array.at(2).toFloat())));
} else if(type == "Vector3") {
setProperty(qPrintable(key), QVariant::fromValue(Vector3(array.at(1).toFloat(),
array.at(2).toFloat(),
array.at(3).toFloat())));
} else if(type == "Vector4") {
setProperty(qPrintable(key), QVariant::fromValue(Vector4(array.at(1).toFloat(),
array.at(2).toFloat(),
array.at(3).toFloat(),
array.at(4).toFloat() )));
}
} else {
setProperty(qPrintable(key), data[key]);
Expand Down