diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-27 21:39:41 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-27 21:39:41 +0100 |
commit | efecf0ab20304b5d76b3072a66b36b50d8522082 (patch) | |
tree | 5afa6fb96ee863864c52c1a52ede96649c71278a /serialize/scenery.cpp | |
parent | beb6685f605b89ce4b2dd99f87b9319e4f7f4d94 (diff) |
scenery wip
Diffstat (limited to 'serialize/scenery.cpp')
-rw-r--r-- | serialize/scenery.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/serialize/scenery.cpp b/serialize/scenery.cpp index 8bff3d69..984b11bc 100644 --- a/serialize/scenery.cpp +++ b/serialize/scenery.cpp @@ -3,6 +3,7 @@ #include "compat/assert.hpp" #include "loader/loader.hpp" #include "serialize/corrade-string.hpp" +#include "serialize/json-helper.hpp" #include <array> #include <Corrade/Containers/StringStlView.h> #include <nlohmann/json.hpp> @@ -10,6 +11,7 @@ namespace { using namespace floormat; +using namespace floormat::Serialize; constexpr struct { scenery_type value = scenery_type::none; @@ -55,10 +57,6 @@ StringView foo_to_string(auto type, const T(&map)[N], const char* desc) } // namespace -namespace floormat { - -} // namespace floormat - namespace nlohmann { void adl_serializer<scenery_type>::to_json(json& j, const scenery_type val) @@ -131,6 +129,22 @@ void adl_serializer<scenery_proto>::from_json(const json& j, scenery_proto& val) } } +void adl_serializer<serialized_scenery>::to_json(json& j, const serialized_scenery& val) +{ + fm_assert(val.proto.atlas); + j = val.proto; + const auto name = !val.name.isEmpty() ? StringView{val.name} : val.proto.atlas->name(); + j["name"] = name; + j["description"] = val.descr; +} +void adl_serializer<serialized_scenery>::from_json(const json& j, serialized_scenery& val) +{ + val = {}; + val.proto = j; + val.name = j["name"]; + if (j.contains("description")) + val.descr = j["description"]; +} } // namespace nlohmann |