1 | // Aseprite |
---|---|
2 | // Copyright (C) 2020 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/set_tileset_base_index.h" |
12 | |
13 | #include "app/doc.h" |
14 | #include "app/doc_event.h" |
15 | #include "doc/tileset.h" |
16 | |
17 | namespace app { |
18 | namespace cmd { |
19 | |
20 | SetTilesetBaseIndex::SetTilesetBaseIndex(Tileset* tileset, int baseIndex) |
21 | : WithTileset(tileset) |
22 | , m_oldBaseIndex(tileset->baseIndex()) |
23 | , m_newBaseIndex(baseIndex) |
24 | { |
25 | } |
26 | |
27 | void SetTilesetBaseIndex::onExecute() |
28 | { |
29 | auto ts = tileset(); |
30 | ts->setBaseIndex(m_newBaseIndex); |
31 | ts->incrementVersion(); |
32 | ts->sprite()->incrementVersion(); |
33 | } |
34 | |
35 | void SetTilesetBaseIndex::onUndo() |
36 | { |
37 | auto ts = tileset(); |
38 | ts->setBaseIndex(m_oldBaseIndex); |
39 | ts->incrementVersion(); |
40 | ts->sprite()->incrementVersion(); |
41 | } |
42 | |
43 | } // namespace cmd |
44 | } // namespace app |
45 |