| 38 | constexpr int indentation = 2; |
| 39 | |
| 40 | void NodeSerializer::to_json(ordered_json& j, const ax::Node* p) |
| 41 | { |
| 42 | j = ordered_json{ |
| 43 | {"type", getNodeName(p)}, |
| 44 | {"pos", { |
| 45 | {"x", p->getPositionX()}, |
| 46 | {"y", p->getPositionY()} |
| 47 | }}, |
| 48 | {"scale", { |
| 49 | {"x", p->getScaleX()}, |
| 50 | {"y", p->getScaleY()} |
| 51 | }}, |
| 52 | {"rot", { |
| 53 | {"x", p->getRotationSkewX()}, |
| 54 | {"y", p->getRotationSkewY()} |
| 55 | }}, |
| 56 | {"anchor", { |
| 57 | {"x", p->getAnchorPoint().x}, |
| 58 | {"y", p->getAnchorPoint().y} |
| 59 | }}, |
| 60 | {"contentSize", { |
| 61 | {"width", p->getContentSize().width}, |
| 62 | {"height", p->getContentSize().height} |
| 63 | }}, |
| 64 | {"color", { |
| 65 | {"r", p->getColor().r}, |
| 66 | {"g", p->getColor().g}, |
| 67 | {"b", p->getColor().b} |
| 68 | }}, |
| 69 | {"zOrder", p->getGlobalZOrder()}, |
| 70 | {"visible", p->isVisible()} |
| 71 | }; |
| 72 | |
| 73 | const auto& children = p->getChildren(); |
| 74 | if (!children.empty()) { |
| 75 | ordered_json childrenJson; |
| 76 | for (const auto& child : children) { |
| 77 | ordered_json childJson; |
| 78 | to_json(childJson, child); |
| 79 | childrenJson.push_back(childJson); |
| 80 | } |
| 81 | j["children"] = childrenJson; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | //untested |
| 86 | void NodeSerializer::from_json(const ordered_json& j, ax::Node* p) |
nothing calls this directly
no test coverage detected