summaryrefslogtreecommitdiffhomepage
path: root/serialize/anim.cpp
blob: dffe24493aa6b16223b0ddf4b3f2917492bc5527 (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
36
#include "serialize/magnum-vector2i.hpp"
#include "serialize/json-helper.hpp"
#include "serialize/anim.hpp"

#include <tuple>
#include <filesystem>
#include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/DebugStl.h>

namespace Magnum::Examples::Serialize {

#if defined __clang__ || defined __CLION_IDE__
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wweak-vtables"
#   pragma clang diagnostic ignored "-Wcovered-switch-default"
#endif

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim_frame, ground, offset, size)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim_group, name, frames, ground)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(anim, name, nframes, actionframe, fps, groups, width, height)

#if defined __clang__ || defined __CLION_IDE__
#   pragma clang diagnostic pop
#endif

std::tuple<anim, bool> anim::from_json(const std::filesystem::path& pathname)
{
    return json_helper::from_json<anim>(pathname);
}

bool anim::to_json(const std::filesystem::path& pathname) const
{
    return json_helper::to_json(*this, pathname);
}

} // namespace Magnum::Examples::Serialize