summaryrefslogtreecommitdiffhomepage
path: root/tile
diff options
context:
space:
mode:
Diffstat (limited to 'tile')
-rw-r--r--tile/CMakeLists.txt12
-rw-r--r--tile/serialize.cpp17
-rw-r--r--tile/serialize.hpp23
3 files changed, 52 insertions, 0 deletions
diff --git a/tile/CMakeLists.txt b/tile/CMakeLists.txt
new file mode 100644
index 00000000..73cb2b58
--- /dev/null
+++ b/tile/CMakeLists.txt
@@ -0,0 +1,12 @@
+find_package(OpenCV QUIET REQUIRED COMPONENTS core imgcodecs imgproc)
+find_package(nlohmann_json QUIET REQUIRED)
+
+set(self "${PROJECT_NAME}-tile")
+
+include_directories(SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS})
+link_libraries(opencv_imgproc opencv_imgcodecs opencv_core)
+link_libraries(Magnum::Magnum nlohmann_json::nlohmann_json)
+
+file(GLOB sources "*.cpp" CONFIGURE_ARGS)
+add_library(${self} STATIC ${sources})
+
diff --git a/tile/serialize.cpp b/tile/serialize.cpp
new file mode 100644
index 00000000..4043c8de
--- /dev/null
+++ b/tile/serialize.cpp
@@ -0,0 +1,17 @@
+#include "serialize.hpp"
+#include <nlohmann/json.hpp>
+#include "json-magnum.hpp"
+
+std::tuple<big_atlas, bool> big_atlas::from_json(const std::filesystem::path& pathname) noexcept
+{
+
+}
+
+bool big_atlas::to_json(const std::filesystem::path& pathname) noexcept
+{
+
+}
+
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(big_atlas_tile, position)
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(big_atlas_entry, tiles)
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(big_atlas, entries)
diff --git a/tile/serialize.hpp b/tile/serialize.hpp
new file mode 100644
index 00000000..c28aa934
--- /dev/null
+++ b/tile/serialize.hpp
@@ -0,0 +1,23 @@
+#include <string>
+#include <vector>
+#include <tuple>
+#include <unordered_map>
+#include <Magnum/Magnum.h>
+#include <Magnum/Math/Vector2.h>
+
+namespace std::filesystem { class path; }
+
+struct big_atlas_tile final {
+ Magnum::Vector2i position;
+};
+
+struct big_atlas_entry final {
+ std::vector<big_atlas_tile> tiles;
+};
+
+struct big_atlas final {
+ static std::tuple<big_atlas, bool> from_json(const std::filesystem::path& pathname) noexcept;
+ [[nodiscard]] bool to_json(const std::filesystem::path& pathname) noexcept;
+
+ std::unordered_map<std::string, big_atlas_entry> entries;
+};