summaryrefslogtreecommitdiffhomepage
path: root/serialize/tile.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-01 16:35:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-01 16:35:03 +0100
commit704e9bd3ac58484a5209e186798076f1cbd432ef (patch)
tree511479ebd088d5c9524803c6f3fe4641009b58bc /serialize/tile.cpp
parent7ff1f0911e0b0c314d6e639887b705d6fc0d78aa (diff)
wip
Diffstat (limited to 'serialize/tile.cpp')
-rw-r--r--serialize/tile.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/serialize/tile.cpp b/serialize/tile.cpp
index 68def2d8..abce91e1 100644
--- a/serialize/tile.cpp
+++ b/serialize/tile.cpp
@@ -6,7 +6,11 @@
namespace floormat {
-NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile_image, atlas, variant)
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile_image_proto, atlas, variant)
+
+inline void to_json(nlohmann::json& j, const tile_image_ref& val) { j = tile_image_proto(val); }
+inline void from_json(const nlohmann::json& j, tile_image_ref& val) { val = tile_image_proto(j); }
+
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(local_coords, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords, x, y)
@@ -23,8 +27,8 @@ using namespace floormat;
namespace nlohmann {
-void adl_serializer<tile_image>::to_json(json& j, const tile_image& val) { using nlohmann::to_json; if (val.atlas) to_json(j, val); else j = nullptr; }
-void adl_serializer<tile_image>::from_json(const json& j, tile_image& val) { using nlohmann::from_json; if (j.is_null()) val = {}; else from_json(j, val); }
+void adl_serializer<tile_image_ref>::to_json(json& j, const tile_image_ref& val) { using nlohmann::to_json; if (val.atlas) to_json(j, val); else j = nullptr; }
+void adl_serializer<tile_image_ref>::from_json(const json& j, tile_image_ref& val) { using nlohmann::from_json; if (j.is_null()) val = {}; else from_json(j, val); }
void adl_serializer<local_coords>::to_json(json& j, const local_coords& val) { using nlohmann::to_json; to_json(j, val); }
void adl_serializer<local_coords>::from_json(const json& j, local_coords& val) { using nlohmann::from_json; from_json(j, val); }