2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_MAPLAYERS_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_MAPLAYERS_H
|
|
|
|
#include <game/client/component.h>
|
|
|
|
|
2017-09-12 18:22:18 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#define INDEX_BUFFER_GROUP_WIDTH 12
|
|
|
|
#define INDEX_BUFFER_GROUP_HEIGHT 9
|
|
|
|
#define INDEX_BORDER_BUFFER_GROUP_SIZE 20
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CMapLayers : public CComponent
|
2011-04-13 18:37:12 +00:00
|
|
|
{
|
2015-08-25 00:11:04 +00:00
|
|
|
friend class CBackground;
|
2017-02-21 16:10:08 +00:00
|
|
|
|
2017-09-12 18:22:18 +00:00
|
|
|
CLayers *m_pLayers;
|
|
|
|
class CMapImages *m_pImages;
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Type;
|
2011-12-04 13:04:12 +00:00
|
|
|
int m_CurrentLocalTick;
|
|
|
|
int m_LastLocalTick;
|
|
|
|
bool m_EnvelopeUpdate;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-10-17 08:43:27 +00:00
|
|
|
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom = 1.0f);
|
2017-09-12 18:22:18 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
struct STileLayerVisuals
|
|
|
|
{
|
|
|
|
STileLayerVisuals() : m_TilesOfLayer(NULL), m_BorderTop(NULL), m_BorderLeft(NULL), m_BorderRight(NULL), m_BorderBottom(NULL)
|
|
|
|
{
|
|
|
|
m_Width = 0;
|
|
|
|
m_Height = 0;
|
|
|
|
m_VisualObjectsIndex = -1;
|
|
|
|
m_IsTextured = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Init(unsigned int Width, unsigned int Height);
|
|
|
|
|
|
|
|
~STileLayerVisuals();
|
|
|
|
|
|
|
|
struct STileVisual
|
|
|
|
{
|
|
|
|
STileVisual() : m_IndexBufferByteOffset(0), m_TilesHandledCount(0), m_Draw(false) { }
|
|
|
|
char* m_IndexBufferByteOffset;
|
|
|
|
unsigned int m_TilesHandledCount; //number of tiles that were handled before this tile + this tile if added
|
|
|
|
bool m_Draw;
|
2017-09-12 18:22:18 +00:00
|
|
|
};
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual** m_TilesOfLayer;
|
|
|
|
|
|
|
|
STileVisual m_BorderTopLeft;
|
|
|
|
STileVisual m_BorderTopRight;
|
|
|
|
STileVisual m_BorderBottomRight;
|
|
|
|
STileVisual m_BorderBottomLeft;
|
2017-09-12 18:22:18 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual m_BorderKillTile; //end of map kill tile -- game layer only
|
2017-09-12 18:22:18 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual* m_BorderTop;
|
|
|
|
STileVisual* m_BorderLeft;
|
|
|
|
STileVisual* m_BorderRight;
|
|
|
|
STileVisual* m_BorderBottom;
|
|
|
|
|
|
|
|
unsigned int m_Width;
|
|
|
|
unsigned int m_Height;
|
|
|
|
int m_VisualObjectsIndex;
|
|
|
|
bool m_IsTextured;
|
2017-09-12 18:22:18 +00:00
|
|
|
};
|
2017-09-27 10:20:23 +00:00
|
|
|
std::vector<STileLayerVisuals*> m_TileLayerVisuals;
|
2017-09-12 18:22:18 +00:00
|
|
|
|
|
|
|
int TileLayersOfGroup(CMapItemGroup* pGroup);
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TYPE_BACKGROUND=0,
|
2017-09-12 18:22:18 +00:00
|
|
|
TYPE_BACKGROUND_FORCE,
|
2010-05-29 07:25:38 +00:00
|
|
|
TYPE_FOREGROUND,
|
|
|
|
};
|
|
|
|
|
|
|
|
CMapLayers(int Type);
|
|
|
|
virtual void OnInit();
|
|
|
|
virtual void OnRender();
|
2017-09-12 18:22:18 +00:00
|
|
|
virtual void OnMapLoad();
|
|
|
|
|
|
|
|
void RenderTileLayer(int LayerIndex, vec4* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup);
|
|
|
|
void DrawTileBorder(int LayerIndex, vec4* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1);
|
|
|
|
void DrawKillTileBorder(int LayerIndex, vec4* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup);
|
|
|
|
|
2011-12-04 13:04:12 +00:00
|
|
|
void EnvelopeUpdate();
|
2014-10-12 14:12:13 +00:00
|
|
|
|
|
|
|
static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|