blob: a92dfc283365d7d5ccb7c9a8724175a7485c3fc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include "src/tile-atlas.hpp"
#include "serialize/tile-atlas.hpp"
#include "serialize/corrade-string.hpp"
#include "serialize/magnum-vector2i.hpp"
#include "loader/loader.hpp"
#include <tuple>
#include <nlohmann/json.hpp>
using namespace floormat;
namespace nlohmann {
void adl_serializer<std::shared_ptr<tile_atlas>>::to_json(json& j, const std::shared_ptr<const tile_atlas>& x)
{
using nlohmann::to_json;
if (!x)
j = nullptr;
else
to_json(j, std::tuple<StringView, Vector2ub>{x->name(), x->num_tiles2()});
}
void adl_serializer<std::shared_ptr<tile_atlas>>::from_json(const json& j, std::shared_ptr<tile_atlas>& x)
{
if (j.is_null())
x = nullptr;
else
{
std::tuple<String, Vector2ub> proxy = j;
const auto& [name, num_tiles] = proxy;
x = loader.tile_atlas(name, num_tiles);
}
}
} // namespace nlohmann
|