untested
| 84 | |
| 85 | //untested |
| 86 | void NodeSerializer::from_json(const ordered_json& j, ax::Node* p) |
| 87 | { |
| 88 | p->setPosition({ j["pos"]["x"], j["pos"]["y"] }); |
| 89 | p->setScaleX(j["scale"]["x"]); |
| 90 | p->setScaleY(j["scale"]["y"]); |
| 91 | p->setRotationSkewX(j["rot"]["x"]); |
| 92 | p->setRotationSkewY(j["rot"]["y"]); |
| 93 | p->setAnchorPoint({ j["anchor"]["x"], j["anchor"]["y"] }); |
| 94 | p->setContentSize({ j["contentSize"]["width"], j["contentSize"]["height"] }); |
| 95 | p->setColor({ j["color"]["r"], j["color"]["g"], j["color"]["b"] }); |
| 96 | p->setGlobalZOrder(j["zOrder"]); |
| 97 | p->setVisible(j["visible"]); |
| 98 | |
| 99 | const auto& childrenJson = j.find("children"); |
| 100 | if (childrenJson != j.end()) { |
| 101 | const auto& childrenArray = *childrenJson; |
| 102 | for (const auto& childJson : childrenArray) { |
| 103 | ax::Node* child = nullptr; |
| 104 | from_json(childJson, child); |
| 105 | if (child) { |
| 106 | p->addChild(child); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | void NodeSerializer::saveNodeToJsonFile(const std::string_view filename, ax::Node* rootNode) |
| 113 | { |