| 538 | } |
| 539 | |
| 540 | static Own<Value> getProperties(const std::vector<tmx::Property>& props, const tmx::Map& map) { |
| 541 | Dictionary* properties = Dictionary::create(); |
| 542 | for (const auto& prop : props) { |
| 543 | switch (prop.getType()) { |
| 544 | case tmx::Property::Type::Boolean: |
| 545 | properties->set(prop.getName(), Value::alloc(prop.getBoolValue())); |
| 546 | break; |
| 547 | case tmx::Property::Type::Float: |
| 548 | properties->set(prop.getName(), Value::alloc(prop.getFloatValue())); |
| 549 | break; |
| 550 | case tmx::Property::Type::Int: |
| 551 | properties->set(prop.getName(), Value::alloc(prop.getIntValue())); |
| 552 | break; |
| 553 | case tmx::Property::Type::String: |
| 554 | properties->set(prop.getName(), Value::alloc(prop.getStringValue())); |
| 555 | break; |
| 556 | case tmx::Property::Type::Colour: { |
| 557 | auto colour = prop.getColourValue(); |
| 558 | properties->set(prop.getName(), Value::alloc(Color{colour.r, colour.g, colour.b, colour.a}.toARGB())); |
| 559 | break; |
| 560 | } |
| 561 | case tmx::Property::Type::File: |
| 562 | properties->set(prop.getName(), Value::alloc(Path::concat({map.getWorkingDirectory(), prop.getFileValue()}))); |
| 563 | break; |
| 564 | case tmx::Property::Type::Object: |
| 565 | properties->set(prop.getName(), Value::alloc(prop.getObjectValue())); |
| 566 | break; |
| 567 | case tmx::Property::Type::Class: |
| 568 | properties->set(prop.getName(), getProperties(prop.getClassValue(), map)); |
| 569 | break; |
| 570 | case tmx::Property::Type::Undef: |
| 571 | break; |
| 572 | } |
| 573 | } |
| 574 | return Value::alloc(properties); |
| 575 | } |
| 576 | |
| 577 | static Dictionary* getLayerDict(tmx::Layer* target, const tmx::Map& map) { |
| 578 | Dictionary* data = Dictionary::create(); |