1 | // Aseprite |
---|---|
2 | // Copyright (C) 2019 Igara Studio S.A. |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/cmd/remap_tileset.h" |
12 | |
13 | #include "doc/cel.h" |
14 | #include "doc/cels_range.h" |
15 | #include "doc/image.h" |
16 | #include "doc/layer.h" |
17 | #include "doc/layer_tilemap.h" |
18 | #include "doc/remap.h" |
19 | #include "doc/sprite.h" |
20 | #include "doc/tileset.h" |
21 | |
22 | namespace app { |
23 | namespace cmd { |
24 | |
25 | using namespace doc; |
26 | |
27 | RemapTileset::RemapTileset(Tileset* tileset, |
28 | const Remap& remap) |
29 | : WithTileset(tileset) |
30 | , m_remap(remap) |
31 | { |
32 | } |
33 | |
34 | void RemapTileset::onExecute() |
35 | { |
36 | Tileset* tileset = this->tileset(); |
37 | applyRemap(tileset, m_remap); |
38 | } |
39 | |
40 | void RemapTileset::onUndo() |
41 | { |
42 | Tileset* tileset = this->tileset(); |
43 | applyRemap(tileset, m_remap.invert()); |
44 | } |
45 | |
46 | void RemapTileset::applyRemap(Tileset* tileset, const Remap& remap) |
47 | { |
48 | tileset->remap(remap); |
49 | tileset->incrementVersion(); |
50 | tileset->sprite()->incrementVersion(); |
51 | } |
52 | |
53 | } // namespace cmd |
54 | } // namespace app |
55 |