DDraceNetwork Docs
maplayers.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_MAPLAYERS_H
4#define GAME_CLIENT_COMPONENTS_MAPLAYERS_H
6
7#include <cstdint>
8#include <vector>
9
10#define INDEX_BUFFER_GROUP_WIDTH 12
11#define INDEX_BUFFER_GROUP_HEIGHT 9
12#define INDEX_BORDER_BUFFER_GROUP_SIZE 20
13
14typedef char *offset_ptr_size;
15typedef uintptr_t offset_ptr;
16typedef unsigned int offset_ptr32;
17
18class CCamera;
19class CLayers;
20class CMapImages;
21class ColorRGBA;
22struct CMapItemGroup;
25
26class CMapLayers : public CComponent
27{
28 friend class CBackground;
29 friend class CMenuBackground;
30
33
34 int m_Type;
36
38 {
40 m_pTilesOfLayer(nullptr)
41 {
42 m_Width = 0;
43 m_Height = 0;
45 m_IsTextured = false;
46 }
47
48 bool Init(unsigned int Width, unsigned int Height);
49
51
53 {
56
57 private:
59
60 public:
61 bool DoDraw()
62 {
63 return (m_IndexBufferByteOffset & 0x10000000) != 0;
64 }
65
66 void Draw(bool SetDraw)
67 {
68 m_IndexBufferByteOffset = (SetDraw ? 0x10000000 : (offset_ptr32)0) | (m_IndexBufferByteOffset & 0xEFFFFFFF);
69 }
70
72 {
73 return ((offset_ptr)(m_IndexBufferByteOffset & 0xEFFFFFFF) * 6 * sizeof(uint32_t));
74 }
75
76 void SetIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
77 {
78 m_IndexBufferByteOffset = IndexBufferByteOff | (m_IndexBufferByteOffset & 0x10000000);
79 }
80
81 void AddIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
82 {
83 m_IndexBufferByteOffset = ((m_IndexBufferByteOffset & 0xEFFFFFFF) + IndexBufferByteOff) | (m_IndexBufferByteOffset & 0x10000000);
84 }
85 };
87
92
93 STileVisual m_BorderKillTile; //end of map kill tile -- game layer only
94
95 std::vector<STileVisual> m_vBorderTop;
96 std::vector<STileVisual> m_vBorderLeft;
97 std::vector<STileVisual> m_vBorderRight;
98 std::vector<STileVisual> m_vBorderBottom;
99
100 unsigned int m_Width;
101 unsigned int m_Height;
104 };
105 std::vector<STileLayerVisuals *> m_vpTileLayerVisuals;
106
108 {
111
113 {
116
118 };
119
122
125 };
126 std::vector<SQuadLayerVisuals *> m_vpQuadLayerVisuals;
127
128 virtual CCamera *GetCurCamera();
129
130 void LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer);
131
132protected:
133 virtual bool CanRenderMenuBackground() { return true; }
134
135public:
136 enum
137 {
143 };
144
145 CMapLayers(int Type, bool OnlineOnly = true);
146 virtual ~CMapLayers();
147 virtual int Sizeof() const override { return sizeof(*this); }
148 virtual void OnInit() override;
149 virtual void OnRender() override;
150 virtual void OnMapLoad() override;
151
152 static void EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Result, size_t Channels, void *pUser);
153
154private:
155 void RenderTileLayer(int LayerIndex, const ColorRGBA &Color);
156 void RenderTileBorder(int LayerIndex, const ColorRGBA &Color, int BorderX0, int BorderY0, int BorderX1, int BorderY1);
157 void RenderKillTileBorder(int LayerIndex, const ColorRGBA &Color);
158 void RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer, bool ForceRender = false);
159};
160
161#endif
Definition: background.h:22
Definition: camera.h:14
Definition: component.h:20
Definition: layers.h:13
Definition: mapimages.h:36
Definition: maplayers.h:27
void RenderTileBorder(int LayerIndex, const ColorRGBA &Color, int BorderX0, int BorderY0, int BorderX1, int BorderY1)
Definition: maplayers.cpp:930
CLayers * m_pLayers
Definition: maplayers.h:31
@ TYPE_ALL
Definition: maplayers.h:142
@ TYPE_FULL_DESIGN
Definition: maplayers.h:141
@ TYPE_BACKGROUND_FORCE
Definition: maplayers.h:139
@ TYPE_FOREGROUND
Definition: maplayers.h:140
@ TYPE_BACKGROUND
Definition: maplayers.h:138
void RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer, bool ForceRender=false)
Definition: maplayers.cpp:1186
CMapImages * m_pImages
Definition: maplayers.h:32
virtual ~CMapLayers()
Definition: maplayers.cpp:253
void RenderKillTileBorder(int LayerIndex, const ColorRGBA &Color)
Definition: maplayers.cpp:1084
virtual void OnInit() override
Definition: maplayers.cpp:33
int m_Type
Definition: maplayers.h:34
void RenderTileLayer(int LayerIndex, const ColorRGBA &Color)
Definition: maplayers.cpp:841
virtual bool CanRenderMenuBackground()
Definition: maplayers.h:133
bool m_OnlineOnly
Definition: maplayers.h:35
std::vector< SQuadLayerVisuals * > m_vpQuadLayerVisuals
Definition: maplayers.h:126
void LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer)
Definition: maplayers.cpp:1240
virtual void OnRender() override
Definition: maplayers.cpp:1343
CMapLayers(int Type, bool OnlineOnly=true)
Definition: maplayers.cpp:27
virtual void OnMapLoad() override
Definition: maplayers.cpp:274
virtual CCamera * GetCurCamera()
Definition: maplayers.cpp:39
static void EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Result, size_t Channels, void *pUser)
Definition: maplayers.cpp:44
virtual int Sizeof() const override
Definition: maplayers.h:147
std::vector< STileLayerVisuals * > m_vpTileLayerVisuals
Definition: maplayers.h:105
Definition: menu_background.h:33
Definition: color.h:210
char * offset_ptr_size
Definition: maplayers.h:14
uintptr_t offset_ptr
Definition: maplayers.h:15
unsigned int offset_ptr32
Definition: maplayers.h:16
Definition: mapitems.h:298
Definition: mapitems.h:354
Definition: mapitems.h:321
offset_ptr m_IndexBufferByteOffset
Definition: maplayers.h:117
SQuadVisual()
Definition: maplayers.h:114
Definition: maplayers.h:108
bool m_IsTextured
Definition: maplayers.h:124
int m_BufferContainerIndex
Definition: maplayers.h:123
int m_QuadNum
Definition: maplayers.h:120
SQuadVisual * m_pQuadsOfLayer
Definition: maplayers.h:121
SQuadLayerVisuals()
Definition: maplayers.h:109
offset_ptr IndexBufferByteOffset()
Definition: maplayers.h:71
void SetIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
Definition: maplayers.h:76
STileVisual()
Definition: maplayers.h:54
bool DoDraw()
Definition: maplayers.h:61
void Draw(bool SetDraw)
Definition: maplayers.h:66
void AddIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
Definition: maplayers.h:81
offset_ptr32 m_IndexBufferByteOffset
Definition: maplayers.h:58
Definition: maplayers.h:38
STileVisual m_BorderKillTile
Definition: maplayers.h:93
STileVisual m_BorderTopLeft
Definition: maplayers.h:88
bool Init(unsigned int Width, unsigned int Height)
Definition: maplayers.cpp:170
std::vector< STileVisual > m_vBorderTop
Definition: maplayers.h:95
unsigned int m_Height
Definition: maplayers.h:101
~STileLayerVisuals()
Definition: maplayers.cpp:190
bool m_IsTextured
Definition: maplayers.h:103
std::vector< STileVisual > m_vBorderBottom
Definition: maplayers.h:98
STileVisual m_BorderBottomLeft
Definition: maplayers.h:91
STileVisual * m_pTilesOfLayer
Definition: maplayers.h:86
std::vector< STileVisual > m_vBorderLeft
Definition: maplayers.h:96
int m_BufferContainerIndex
Definition: maplayers.h:102
STileVisual m_BorderBottomRight
Definition: maplayers.h:90
std::vector< STileVisual > m_vBorderRight
Definition: maplayers.h:97
STileLayerVisuals()
Definition: maplayers.h:39
unsigned int m_Width
Definition: maplayers.h:100
STileVisual m_BorderTopRight
Definition: maplayers.h:89