diff options
Diffstat (limited to 'src/level.cpp')
| -rw-r--r-- | src/level.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/level.cpp b/src/level.cpp index 39ac4e9..fb11881 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -93,6 +93,32 @@ namespace silly::editor { return count; } + const std::vector<TileLayer> &TileFloor::get_layers() const { + return this->layers; + } + + std::string TileFloor::export_to_string() const { + std::ostringstream oss; + + oss << "[[floor]]\n" + << "# width;height\n" + << this->width << ";" << this->height << "\n"; + + for (auto it = this->layers.begin(); it != this->layers.end(); ++it) { + oss << "[[[layer]]]\n" + << "# type\n" + << it->type << "\n" + << "# tileset_tile_id;x;y;rotation\n"; + + for (auto tt = it->tiles.begin(); tt != it->tiles.end(); ++tt) { + oss << tt->tile->id << ";" << tt->position.x << ";" << tt->position.y + << ";" << tt->rotation << "\n"; + } + } + + return oss.str(); + } + void TileLevel::add_floor(TileFloor floor) { this->floors.push_back(floor); } void TileLevel::move_to_floor(int floor_id) { @@ -112,4 +138,18 @@ namespace silly::editor { } const std::string &TileLevel::get_name() const { return this->name; } + + std::string TileLevel::export_to_string() const { + std::ostringstream oss; + + oss << "[level]\n" + << "# name\n" + << this->name << "\n"; + + for (auto it = this->floors.begin(); it != this->floors.end(); ++it) { + oss << it->export_to_string() << "\n"; + } + + return oss.str(); + } }
\ No newline at end of file |
