summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
Diffstat (limited to 'serialize')
-rw-r--r--serialize/anim.cpp14
-rw-r--r--serialize/tile.cpp10
-rw-r--r--serialize/wall-atlas.cpp2
3 files changed, 15 insertions, 11 deletions
diff --git a/serialize/anim.cpp b/serialize/anim.cpp
index 8d8bc2bb..8cf074c8 100644
--- a/serialize/anim.cpp
+++ b/serialize/anim.cpp
@@ -11,7 +11,9 @@ namespace floormat {
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim_group, name, frames, ground, offset)
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim_def, object_name, anim_name, pixel_size, nframes, actionframe, fps, groups, scale)
-static void to_json(nlohmann::json& j, const anim_frame& val)
+using nlohmann::json;
+
+static void to_json(json& j, const anim_frame& val)
{
constexpr anim_frame def;
@@ -23,7 +25,7 @@ static void to_json(nlohmann::json& j, const anim_frame& val)
j["size"] = val.size;
}
-static void from_json(const nlohmann::json& j, anim_frame& val)
+static void from_json(const json& j, anim_frame& val)
{
val = {};
if (j.contains("ground"))
@@ -34,7 +36,7 @@ static void from_json(const nlohmann::json& j, anim_frame& val)
val.size = j["size"];
}
-static void to_json(nlohmann::json& j, const anim_group& val)
+static void to_json(json& j, const anim_group& val)
{
const anim_group def{};
@@ -53,7 +55,7 @@ static void to_json(nlohmann::json& j, const anim_group& val)
j["depth-offset"] = val.depth_offset;
}
-static void from_json(const nlohmann::json& j, anim_group& val)
+static void from_json(const json& j, anim_group& val)
{
val = {};
val.name = j["name"];
@@ -75,7 +77,7 @@ static void from_json(const nlohmann::json& j, anim_group& val)
val.depth_offset = j["depth-offset"];
}
-static void to_json(nlohmann::json& j, const anim_def& val)
+static void to_json(json& j, const anim_def& val)
{
const anim_def def{};
@@ -96,7 +98,7 @@ static void to_json(nlohmann::json& j, const anim_def& val)
j["scale"] = val.scale;
}
-static void from_json(const nlohmann::json& j, anim_def& val)
+static void from_json(const json& j, anim_def& val)
{
val = {};
val.object_name = j["object_name"];
diff --git a/serialize/tile.cpp b/serialize/tile.cpp
index 783a9853..7a0b1bed 100644
--- a/serialize/tile.cpp
+++ b/serialize/tile.cpp
@@ -7,10 +7,12 @@
namespace floormat {
+using nlohmann::json;
+
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); }
+inline void to_json(json& j, const tile_image_ref& val) { j = tile_image_proto(val); }
+inline void from_json(const json& j, tile_image_ref& val) { val = tile_image_proto(j); }
struct local_coords_ final {
uint8_t x, y;
@@ -20,8 +22,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(local_coords_, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords_, x, y, z)
-inline void to_json(nlohmann::json& j, global_coords coord) { j = std::tuple<chunk_coords, local_coords, int8_t>{ coord.chunk(), coord.local(), coord.z() }; }
-inline void from_json(const nlohmann::json& j, global_coords& coord) { std::tuple<chunk_coords, local_coords, int8_t> t = j; auto [ch, pos, z] = t; coord = { ch, pos, z }; }
+inline void to_json(json& j, global_coords coord) { j = std::tuple<chunk_coords, local_coords, int8_t>{ coord.chunk(), coord.local(), coord.z() }; }
+inline void from_json(const json& j, global_coords& coord) { std::tuple<chunk_coords, local_coords, int8_t> t = j; auto [ch, pos, z] = t; coord = { ch, pos, z }; }
} // namespace floormat
diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp
index b8c2eb7a..82210f57 100644
--- a/serialize/wall-atlas.cpp
+++ b/serialize/wall-atlas.cpp
@@ -309,7 +309,7 @@ namespace nlohmann {
using floormat::Wall::Frame;
-void adl_serializer<Frame>::to_json(nlohmann::json& j, const Frame& x) { using nlohmann::to_json; to_json(j, x); }
+void adl_serializer<Frame>::to_json(json& j, const Frame& x) { using nlohmann::to_json; to_json(j, x); }
void adl_serializer<Frame>::from_json(const json& j, Frame& x) { using nlohmann::from_json; from_json(j, x); }
} // namespace nlohmann