From 1e8d16fe10917664f9520008f224f19692c3a668 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 15 Oct 2022 21:51:33 +0200 Subject: a --- main/editor.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main/editor.cpp (limited to 'main/editor.cpp') diff --git a/main/editor.cpp b/main/editor.cpp new file mode 100644 index 00000000..4b291ea6 --- /dev/null +++ b/main/editor.cpp @@ -0,0 +1,33 @@ +#include "editor.hpp" +#include "serialize/json-helper.hpp" +#include "serialize/tile-atlas.hpp" +#include "src/loader.hpp" +#include +#include + +namespace floormat { + +static const std::filesystem::path image_path{IMAGE_PATH, std::filesystem::path::generic_format}; + +tile_type::tile_type(Containers::StringView name) : _name{name} +{ + load_atlases(); +} + +void tile_type::load_atlases() +{ + using atlas_array = std::vector>; + for (auto& atlas : json_helper::from_json(image_path/(_name + ".json"))) + { + Containers::StringView name = atlas->name(); + if (auto x = name.findLast('.'); x) + name = name.prefix(x.data()); + _atlases[name] = std::move(atlas); + } +} + +editor_state::editor_state() +{ +} + +} // namespace floormat -- cgit v1.2.3