blob: 4edc390009e3f2173a132703dc36267dc18ec988 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "wall-traits.hpp"
#include "compat/exception.hpp"
#include "compat/vector-wrapper.hpp"
#include "atlas-loader-storage.hpp"
#include "wall-cell.hpp"
#include "loader.hpp"
#include "src/wall-atlas.hpp"
#include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/Pointer.h>
namespace floormat::loader_detail {
StringView atlas_loader_traits<wall_atlas>::loader_name() { return "wall_atlas"_s; }
auto atlas_loader_traits<wall_atlas>::atlas_of(const Cell& x) -> const std::shared_ptr<Atlas>& { return x.atlas; }
auto atlas_loader_traits<wall_atlas>::atlas_of(Cell& x) -> std::shared_ptr<Atlas>& { return x.atlas; }
StringView atlas_loader_traits<wall_atlas>::name_of(const Cell& x) { return x.name; }
StringView atlas_loader_traits<wall_atlas>::name_of(const Atlas& x) { return x.name(); }
using traits = atlas_loader_traits<wall_atlas>;
void traits::ensure_atlases_loaded(Storage& st)
{
if (!st.cell_array.empty()) [[likely]]
return;
fm_assert(st.name_map.empty());
st.cell_array = wall_cell::load_atlases_from_json().vec;
st.name_map.reserve(st.cell_array.size());
for (auto& x : st.cell_array)
{
fm_soft_assert(x.name != "<invalid>"_s);
fm_soft_assert(loader.check_atlas_name(x.name));
StringView name = x.name;
st.name_map[name] = &x;
}
fm_assert(!st.cell_array.empty());
}
auto traits::make_invalid_atlas(Storage& st) -> const Cell&
{
fm_assert("todo" && false);
}
auto traits::make_atlas(StringView name, const Cell& c) -> std::shared_ptr<Atlas>
{
fm_assert("todo" && false);
}
} // namespace floormat::loader_detail
|