1#ifndef GAME_EDITOR_MAPITEMS_LAYER_H
2#define GAME_EDITOR_MAPITEMS_LAYER_H
3
4#include <base/system.h>
5#include <game/client/ui.h>
6#include <game/client/ui_rect.h>
7#include <game/mapitems.h>
8
9#include <memory>
10
11using FIndexModifyFunction = std::function<void(int *pIndex)>;
12
13class CLayerGroup;
14
15class CLayer
16{
17public:
18 class CEditor *m_pEditor;
19 class IGraphics *Graphics();
20 class ITextRender *TextRender();
21
22 explicit CLayer(CEditor *pEditor)
23 {
24 m_Type = LAYERTYPE_INVALID;
25 str_copy(dst&: m_aName, src: "(invalid)");
26 m_Visible = true;
27 m_Readonly = false;
28 m_Flags = 0;
29 m_pEditor = pEditor;
30 }
31
32 CLayer(const CLayer &Other)
33 {
34 str_copy(dst&: m_aName, src: Other.m_aName);
35 m_Flags = Other.m_Flags;
36 m_pEditor = Other.m_pEditor;
37 m_Type = Other.m_Type;
38 m_Visible = true;
39 m_Readonly = false;
40 }
41
42 virtual ~CLayer()
43 {
44 }
45
46 virtual void BrushSelecting(CUIRect Rect) {}
47 virtual int BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect) { return 0; }
48 virtual void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) {}
49 virtual void BrushDraw(std::shared_ptr<CLayer> pBrush, float x, float y) {}
50 virtual void BrushPlace(std::shared_ptr<CLayer> pBrush, float x, float y) {}
51 virtual void BrushFlipX() {}
52 virtual void BrushFlipY() {}
53 virtual void BrushRotate(float Amount) {}
54
55 virtual bool IsEntitiesLayer() const { return false; }
56
57 virtual void Render(bool Tileset = false) {}
58 virtual CUi::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) { return CUi::POPUP_KEEP_OPEN; }
59
60 virtual void ModifyImageIndex(FIndexModifyFunction pfnFunc) {}
61 virtual void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) {}
62 virtual void ModifySoundIndex(FIndexModifyFunction pfnFunc) {}
63
64 virtual std::shared_ptr<CLayer> Duplicate() const = 0;
65 virtual const char *TypeName() const = 0;
66
67 virtual void GetSize(float *pWidth, float *pHeight)
68 {
69 *pWidth = 0;
70 *pHeight = 0;
71 }
72
73 char m_aName[12];
74 int m_Type;
75 int m_Flags;
76
77 bool m_Readonly;
78 bool m_Visible;
79};
80
81#endif
82