diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-04 22:08:26 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-05 01:04:43 +0100 |
commit | 921e0f47a826e88183ba7c328893826e41d36c6c (patch) | |
tree | 73ab796b168ebe308f27c72290d1c14733e3afe7 /serialize/anim.cpp | |
parent | 3c7cfbc50ce21589b192e1e6d121b2e6df60a7f3 (diff) |
serialize: use c++14 std::string literals
Diffstat (limited to 'serialize/anim.cpp')
-rw-r--r-- | serialize/anim.cpp | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/serialize/anim.cpp b/serialize/anim.cpp index 8d8bc2bb..bea7f3ce 100644 --- a/serialize/anim.cpp +++ b/serialize/anim.cpp @@ -7,6 +7,8 @@ namespace floormat { +using namespace std::string_literals; + //NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim_frame, ground, offset, size) //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) @@ -16,106 +18,106 @@ static void to_json(nlohmann::json& j, const anim_frame& val) constexpr anim_frame def; if (val.ground != def.ground) - j["ground"] = val.ground; + j["ground"s] = val.ground; if (val.offset != def.offset) - j["offset"] = val.offset; + j["offset"s] = val.offset; if (val.size != def.size) - j["size"] = val.size; + j["size"s] = val.size; } static void from_json(const nlohmann::json& j, anim_frame& val) { val = {}; - if (j.contains("ground")) - val.ground = j["ground"]; - if (j.contains("offset")) - val.offset = j["offset"]; - if (j.contains("size")) - val.size = j["size"]; + if (j.contains("ground"s)) + val.ground = j["ground"s]; + if (j.contains("offset"s)) + val.offset = j["offset"s]; + if (j.contains("size"s)) + val.size = j["size"s]; } static void to_json(nlohmann::json& j, const anim_group& val) { const anim_group def{}; - j["name"] = val.name; + j["name"s] = val.name; if (val.mirror_from) - j["mirror-from"] = val.mirror_from; + j["mirror-from"s] = val.mirror_from; else - j["frames"] = val.frames; + j["frames"s] = val.frames; if (val.ground != def.ground) - j["ground"] = val.ground; + j["ground"s] = val.ground; if (val.offset != def.offset) - j["offset"] = val.offset; + j["offset"s] = val.offset; if (val.z_offset != def.z_offset) - j["z-offset"] = val.z_offset; + j["z-offset"s] = val.z_offset; if (val.depth_offset != def.depth_offset) - j["depth-offset"] = val.depth_offset; + j["depth-offset"s] = val.depth_offset; } static void from_json(const nlohmann::json& j, anim_group& val) { val = {}; - val.name = j["name"]; + val.name = j["name"s]; fm_soft_assert(!val.name.isEmpty()); - if (j.contains("mirror-from")) + if (j.contains("mirror-from"s)) { - fm_soft_assert(!j.contains("frames")); - val.mirror_from = j["mirror-from"]; + fm_soft_assert(!j.contains("frames"s)); + val.mirror_from = j["mirror-from"s]; } else - val.frames = j["frames"]; - if (j.contains("ground")) - val.ground = j["ground"]; - if (j.contains("offset")) - val.offset = j["offset"]; - if (j.contains("z-offset")) - val.z_offset = j["z-offset"]; - if (j.contains("depth-offset")) - val.depth_offset = j["depth-offset"]; + val.frames = j["frames"s]; + if (j.contains("ground"s)) + val.ground = j["ground"s]; + if (j.contains("offset"s)) + val.offset = j["offset"s]; + if (j.contains("z-offset"s)) + val.z_offset = j["z-offset"s]; + if (j.contains("depth-offset"s)) + val.depth_offset = j["depth-offset"s]; } static void to_json(nlohmann::json& j, const anim_def& val) { const anim_def def{}; - j["object_name"] = val.object_name; + j["object_name"s] = val.object_name; if (val.anim_name != def.anim_name) - j["anim_name"] = val.anim_name; + j["anim_name"s] = val.anim_name; if (val.pixel_size != def.pixel_size) - j["pixel_size"] = val.pixel_size; + j["pixel_size"s] = val.pixel_size; if (val.nframes != def.nframes) - j["nframes"] = val.nframes; + j["nframes"s] = val.nframes; if (val.action_frame != def.action_frame) - j["action-frame"] = val.action_frame; + j["action-frame"s] = val.action_frame; if (val.action_frame2 != def.action_frame2) - j["action-frame-2"] = val.action_frame2; + j["action-frame-2"s] = val.action_frame2; if (val.fps != def.fps) - j["fps"] = val.fps; - j["groups"] = val.groups; - j["scale"] = val.scale; + j["fps"s] = val.fps; + j["groups"s] = val.groups; + j["scale"s] = val.scale; } static void from_json(const nlohmann::json& j, anim_def& val) { val = {}; - val.object_name = j["object_name"]; + val.object_name = j["object_name"s]; fm_soft_assert(!val.object_name.isEmpty()); - if (j.contains("anim_name")) // todo underscore to hyphen - val.anim_name = j["anim_name"]; - if (j.contains("pixel_size")) - val.pixel_size = j["pixel_size"]; - if (j.contains("nframes")) - val.nframes = j["nframes"]; - if (j.contains("action-frame")) - val.action_frame = j["action-frame"]; - if (j.contains("action-frame-2")) - val.action_frame2 = j["action-frame-2"]; - if (j.contains("fps")) - val.fps = j["fps"]; - val.groups = j["groups"]; + if (j.contains("anim_name"s)) // todo underscore to hyphen + val.anim_name = j["anim_name"s]; + if (j.contains("pixel_size"s)) + val.pixel_size = j["pixel_size"s]; + if (j.contains("nframes"s)) + val.nframes = j["nframes"s]; + if (j.contains("action-frame"s)) + val.action_frame = j["action-frame"s]; + if (j.contains("action-frame-2"s)) + val.action_frame2 = j["action-frame-2"s]; + if (j.contains("fps"s)) + val.fps = j["fps"s]; + val.groups = j["groups"s]; fm_soft_assert(!val.groups.empty()); - val.scale = j["scale"]; + val.scale = j["scale"s]; fm_soft_assert(val.scale.type != anim_scale_type::invalid); } |