1 | // Aseprite |
2 | // Copyright (C) 2021 Igara Studio S.A. |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifndef APP_CMD_REPLACE_TILESET_H_INCLUDED |
8 | #define APP_CMD_REPLACE_TILESET_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "app/cmd.h" |
12 | #include "app/cmd/with_sprite.h" |
13 | #include "doc/tileset.h" |
14 | |
15 | #include <sstream> |
16 | |
17 | namespace app { |
18 | namespace cmd { |
19 | |
20 | class ReplaceTileset : public Cmd |
21 | , public WithSprite { |
22 | public: |
23 | ReplaceTileset(doc::Sprite* sprite, |
24 | const doc::tileset_index tsi, |
25 | doc::Tileset* newTileset); |
26 | |
27 | protected: |
28 | void onExecute() override; |
29 | void onUndo() override { onExecute(); } |
30 | void onRedo() override { onExecute(); } |
31 | size_t onMemSize() const override { |
32 | return sizeof(*this) + m_size; |
33 | } |
34 | |
35 | private: |
36 | void replaceTileset(doc::Tileset* newTileset); |
37 | |
38 | doc::tileset_index m_tsi; |
39 | doc::Tileset* m_newTileset; |
40 | std::stringstream m_stream; |
41 | size_t m_size = 0; |
42 | }; |
43 | |
44 | } // namespace cmd |
45 | } // namespace app |
46 | |
47 | #endif |
48 | |