1 | // Aseprite Document Library |
---|---|
2 | // Copyright (c) 2019-2021 Igara Studio S.A. |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "doc/layer_tilemap.h" |
12 | |
13 | #include "doc/primitives.h" |
14 | #include "doc/sprite.h" |
15 | #include "doc/tilesets.h" |
16 | |
17 | namespace doc { |
18 | |
19 | LayerTilemap::LayerTilemap(Sprite* sprite, const tileset_index tsi) |
20 | : LayerImage(ObjectType::LayerTilemap, sprite) |
21 | , m_tileset(sprite->tilesets()->get(tsi)) |
22 | , m_tilesetIndex(tsi) |
23 | { |
24 | ASSERT(m_tileset); |
25 | } |
26 | |
27 | LayerTilemap::~LayerTilemap() |
28 | { |
29 | } |
30 | |
31 | Grid LayerTilemap::grid() const |
32 | { |
33 | if (m_tileset) |
34 | return m_tileset->grid(); |
35 | else |
36 | return Layer::grid(); |
37 | } |
38 | |
39 | void LayerTilemap::setTilesetIndex(tileset_index tsi) |
40 | { |
41 | // "m_tilesetIndex" could be already equal to "tsi", but this |
42 | // function is used by Sprite::replaceTilemap() to update the |
43 | // m_tileset pointer even in that case. |
44 | |
45 | m_tilesetIndex = tsi; |
46 | m_tileset = sprite()->tilesets()->get(tsi); |
47 | } |
48 | |
49 | } // namespace doc |
50 |