summaryrefslogtreecommitdiffhomepage
path: root/src/tile-image.hpp
blob: 475b62518f2b76c59578f2e4854504b5d642a40e (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
#pragma once
#include "tile-defs.hpp"
#include "compat/borrowed-ptr.hpp"

namespace floormat {

class ground_atlas;
class wall_atlas;

template<typename Atlas>
struct image_proto_
{
    bptr<Atlas> atlas;
    variant_t variant = 0;

    bool operator==(const image_proto_<Atlas>& b) const noexcept;
    explicit operator bool() const noexcept;
};

template<typename Atlas, typename Proto>
struct image_ref_ final
{
    bptr<Atlas>& atlas;
    variant_t& variant;

    image_ref_(bptr<Atlas>& atlas, variant_t& variant) noexcept;
    image_ref_(const image_ref_&) noexcept;
    image_ref_& operator=(const Proto& proto) noexcept;
    operator Proto() const noexcept;
    explicit operator bool() const noexcept;
};

using tile_image_proto = image_proto_<ground_atlas>;
using tile_image_ref = image_ref_<ground_atlas, tile_image_proto>;
extern template struct image_proto_<ground_atlas>;
extern template struct image_ref_<ground_atlas, tile_image_proto>;

using wall_image_proto = image_proto_<wall_atlas>;
using wall_image_ref = image_ref_<wall_atlas, wall_image_proto>;
extern template struct image_proto_<wall_atlas>;
extern template struct image_ref_<wall_atlas, wall_image_proto>;

} // namespace floormat