1#ifndef GAME_EDITOR_MAPITEMS_LAYER_SWITCH_H
2#define GAME_EDITOR_MAPITEMS_LAYER_SWITCH_H
3
4#include "layer_tiles.h"
5
6struct SSwitchTileStateChange
7{
8 bool m_Changed;
9 struct SData
10 {
11 int m_Number;
12 int m_Type;
13 int m_Flags;
14 int m_Delay;
15 int m_Index;
16 } m_Previous, m_Current;
17};
18
19class CLayerSwitch : public CLayerTiles
20{
21public:
22 CLayerSwitch(CEditor *pEditor, int w, int h);
23 CLayerSwitch(const CLayerSwitch &Other);
24 ~CLayerSwitch();
25
26 CSwitchTile *m_pSwitchTile;
27 unsigned char m_SwitchNumber;
28 unsigned char m_SwitchDelay;
29
30 void Resize(int NewW, int NewH) override;
31 void Shift(int Direction) override;
32 bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer) override;
33 void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
34 void BrushFlipX() override;
35 void BrushFlipY() override;
36 void BrushRotate(float Amount) override;
37 void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
38 virtual bool ContainsElementWithId(int Id);
39 virtual void GetPos(int Number, int Offset, ivec2 &SwitchPos);
40
41 int m_GotoSwitchOffset;
42 ivec2 m_GotoSwitchLastPos;
43
44 EditorTileStateChangeHistory<SSwitchTileStateChange> m_History;
45 inline void ClearHistory() override
46 {
47 CLayerTiles::ClearHistory();
48 m_History.clear();
49 }
50
51 std::shared_ptr<CLayer> Duplicate() const override;
52 const char *TypeName() const override;
53
54private:
55 void RecordStateChange(int x, int y, SSwitchTileStateChange::SData Previous, SSwitchTileStateChange::SData Current);
56};
57
58#endif
59