diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-06 22:47:20 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-06 22:47:20 +0200 |
commit | ed90a4cec86f4e8beb38c69fc2aaa0c7bfa84b7b (patch) | |
tree | 5a224daf40d3d6585580bb639dc23ce14f2430bf /serialize/tile.cpp | |
parent | 9107e0ff64fc5788d90c0b44da3f7148cba4f966 (diff) |
a
Diffstat (limited to 'serialize/tile.cpp')
-rw-r--r-- | serialize/tile.cpp | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/serialize/tile.cpp b/serialize/tile.cpp index 2f414e62..df49a465 100644 --- a/serialize/tile.cpp +++ b/serialize/tile.cpp @@ -9,6 +9,7 @@ namespace Magnum::Examples { NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile_image, atlas, variant) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile, ground_image, wall_north, wall_west, passability) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(local_coords, x, y) } // namespace Magnum::Examples @@ -16,35 +17,16 @@ namespace nlohmann { using namespace Magnum::Examples; -void adl_serializer<tile_image>::to_json(json& j, const tile_image& val) { - using nlohmann::to_json; - to_json(j, val); -} - -void adl_serializer<tile_image>::from_json(const json& j, tile_image& val) { - using nlohmann::from_json; - from_json(j, val); -} - -void adl_serializer<tile>::to_json(json& j, const tile& val) { - using nlohmann::to_json; - to_json(j, val); -} - -void adl_serializer<tile>::from_json(const json& j, tile& val) { - using nlohmann::from_json; - from_json(j, val); -} - -void adl_serializer<chunk>::to_json(json& j, const chunk& val) { - using nlohmann::to_json; - to_json(j, val.tiles()); -} - -void adl_serializer<chunk>::from_json(const json& j, chunk& val) { - using nlohmann::from_json; - std::remove_cvref_t<decltype(val.tiles())> tiles = {}; - tiles = j; -} +void adl_serializer<tile_image>::to_json(json& j, const tile_image& val) { j = val; } +void adl_serializer<tile_image>::from_json(const json& j, tile_image& val) { val = j; } + +void adl_serializer<tile>::to_json(json& j, const tile& val) { j = val; } +void adl_serializer<tile>::from_json(const json& j, tile& val) { val = j; } + +void adl_serializer<chunk>::to_json(json& j, const chunk& val) { j = val.tiles(); } +void adl_serializer<chunk>::from_json(const json& j, chunk& val) { val.tiles() = j; } + +void adl_serializer<local_coords>::to_json(json& j, const local_coords& val) { j = val; } +void adl_serializer<local_coords>::from_json(const json& j, local_coords& val) { val = j; } } // namespace nlohmann |