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
|
|
|
|
|
2018-01-16 08:35:28 +00:00
|
|
|
typedef char* offset_ptr_size;
|
2018-01-16 09:18:14 +00:00
|
|
|
typedef uintptr_t offset_ptr;
|
|
|
|
typedef unsigned int offset_ptr32;
|
2018-01-16 08:35:28 +00:00
|
|
|
|
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);
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
struct STileLayerVisuals
|
|
|
|
{
|
2019-04-26 22:11:15 +00:00
|
|
|
STileLayerVisuals() : m_TilesOfLayer(NULL), m_BorderTop(NULL), m_BorderLeft(NULL), m_BorderRight(NULL), m_BorderBottom(NULL)
|
2017-09-27 10:20:23 +00:00
|
|
|
{
|
|
|
|
m_Width = 0;
|
|
|
|
m_Height = 0;
|
2018-03-13 20:57:46 +00:00
|
|
|
m_BufferContainerIndex = -1;
|
2017-09-27 10:20:23 +00:00
|
|
|
m_IsTextured = false;
|
2019-04-26 22:11:15 +00:00
|
|
|
}
|
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
bool Init(unsigned int Width, unsigned int Height);
|
2019-04-26 22:11:15 +00:00
|
|
|
|
|
|
|
~STileLayerVisuals();
|
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
struct STileVisual
|
|
|
|
{
|
2018-01-16 08:35:28 +00:00
|
|
|
STileVisual() : m_IndexBufferByteOffset(0) { }
|
|
|
|
private:
|
2018-01-16 09:18:14 +00:00
|
|
|
offset_ptr32 m_IndexBufferByteOffset;
|
2018-01-16 08:35:28 +00:00
|
|
|
public:
|
2019-04-26 22:11:15 +00:00
|
|
|
bool DoDraw()
|
2018-01-16 08:35:28 +00:00
|
|
|
{
|
2019-04-11 10:21:42 +00:00
|
|
|
return (m_IndexBufferByteOffset&0x00000001) != 0;
|
2018-01-16 08:35:28 +00:00
|
|
|
}
|
|
|
|
|
2019-04-26 22:11:15 +00:00
|
|
|
void Draw(bool SetDraw)
|
2018-01-16 08:35:28 +00:00
|
|
|
{
|
2018-03-13 20:57:46 +00:00
|
|
|
m_IndexBufferByteOffset = (SetDraw ? 0x00000001 : (offset_ptr32)0) | (m_IndexBufferByteOffset & 0xFFFFFFFE);
|
2018-01-16 08:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
offset_ptr IndexBufferByteOffset()
|
|
|
|
{
|
2018-03-13 20:57:46 +00:00
|
|
|
return ((offset_ptr)(m_IndexBufferByteOffset & 0xFFFFFFFE));
|
2018-01-16 08:35:28 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 09:18:14 +00:00
|
|
|
void SetIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
|
2018-01-16 08:35:28 +00:00
|
|
|
{
|
2018-03-13 20:57:46 +00:00
|
|
|
m_IndexBufferByteOffset = IndexBufferByteOff | (m_IndexBufferByteOffset & 0x00000001);
|
2018-01-16 08:35:28 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 09:18:14 +00:00
|
|
|
void AddIndexBufferByteOffset(offset_ptr32 IndexBufferByteOff)
|
2018-01-16 08:35:28 +00:00
|
|
|
{
|
2019-04-11 10:21:42 +00:00
|
|
|
m_IndexBufferByteOffset = ((m_IndexBufferByteOffset & 0xFFFFFFFE) + IndexBufferByteOff) | (m_IndexBufferByteOffset & 0x00000001);
|
2018-01-16 08:35:28 +00:00
|
|
|
}
|
2017-09-12 18:22:18 +00:00
|
|
|
};
|
2018-01-16 08:35:28 +00:00
|
|
|
STileVisual* m_TilesOfLayer;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual m_BorderTopLeft;
|
|
|
|
STileVisual m_BorderTopRight;
|
|
|
|
STileVisual m_BorderBottomRight;
|
|
|
|
STileVisual m_BorderBottomLeft;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual m_BorderKillTile; //end of map kill tile -- game layer only
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
STileVisual* m_BorderTop;
|
|
|
|
STileVisual* m_BorderLeft;
|
|
|
|
STileVisual* m_BorderRight;
|
|
|
|
STileVisual* m_BorderBottom;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:20:23 +00:00
|
|
|
unsigned int m_Width;
|
|
|
|
unsigned int m_Height;
|
2018-03-13 20:57:46 +00:00
|
|
|
int m_BufferContainerIndex;
|
2017-09-27 10:20:23 +00:00
|
|
|
bool m_IsTextured;
|
2017-09-12 18:22:18 +00:00
|
|
|
};
|
2017-09-27 10:20:23 +00:00
|
|
|
std::vector<STileLayerVisuals*> m_TileLayerVisuals;
|
2018-03-13 20:57:46 +00:00
|
|
|
|
|
|
|
struct SQuadLayerVisuals
|
|
|
|
{
|
|
|
|
SQuadLayerVisuals() : m_QuadNum(0), m_QuadsOfLayer(NULL), m_BufferContainerIndex(-1), m_IsTextured(false) {}
|
|
|
|
|
|
|
|
struct SQuadVisual
|
|
|
|
{
|
|
|
|
SQuadVisual() : m_IndexBufferByteOffset(0) {}
|
|
|
|
|
|
|
|
offset_ptr m_IndexBufferByteOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
int m_QuadNum;
|
|
|
|
SQuadVisual* m_QuadsOfLayer;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
bool m_IsTextured;
|
|
|
|
};
|
|
|
|
std::vector<SQuadLayerVisuals*> m_QuadLayerVisuals;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2018-03-13 20:57:46 +00:00
|
|
|
void LayersOfGroupCount(CMapItemGroup* pGroup, int& TileLayerCount, int& QuadLayerCount, bool& PassedGameLayer);
|
2018-10-29 07:44:55 +00:00
|
|
|
|
2018-10-29 08:00:47 +00:00
|
|
|
void RenderTileBorderCornerTiles(int WidthOffsetToOrigin, int HeightOffsetToOrigin, int TileCountWidth, int TileCountHeight, int BufferContainerIndex, float *pColor, offset_ptr_size IndexBufferOffset, float *pOffset, float *pDir);
|
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();
|
2019-04-26 22:11:15 +00:00
|
|
|
|
|
|
|
void RenderTileLayer(int LayerIndex, ColorRGBA* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup);
|
|
|
|
void RenderTileBorder(int LayerIndex, ColorRGBA* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup, int BorderX0, int BorderY0, int BorderX1, int BorderY1, int ScreenWidthTileCount, int ScreenHeightTileCount);
|
|
|
|
void RenderKillTileBorder(int LayerIndex, ColorRGBA* pColor, CMapItemLayerTilemap* pTileLayer, CMapItemGroup* pGroup);
|
2018-03-13 20:57:46 +00:00
|
|
|
void RenderQuadLayer(int LayerIndex, CMapItemLayerQuads* pQuadLayer, CMapItemGroup* pGroup, bool ForceRender = false);
|
|
|
|
|
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
|