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_MAPIMAGES_H
4#define GAME_CLIENT_COMPONENTS_MAPIMAGES_H
5
6#include <engine/graphics.h>
7
8#include <game/client/component.h>
9#include <game/mapitems.h>
10
11enum EMapImageEntityLayerType
12{
13 MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH = 0,
14 MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH,
15
16 MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT,
17};
18
19enum EMapImageModType
20{
21 MAP_IMAGE_MOD_TYPE_DDNET = 0,
22 MAP_IMAGE_MOD_TYPE_DDRACE,
23 MAP_IMAGE_MOD_TYPE_RACE,
24 MAP_IMAGE_MOD_TYPE_BLOCKWORLDS,
25 MAP_IMAGE_MOD_TYPE_FNG,
26 MAP_IMAGE_MOD_TYPE_VANILLA,
27 MAP_IMAGE_MOD_TYPE_FDDRACE,
28
29 MAP_IMAGE_MOD_TYPE_COUNT,
30};
31
32extern const char *const gs_apModEntitiesNames[];
33
34class CMapImages : public CComponent
35{
36 friend class CBackground;
37 friend class CMenuBackground;
38
39 IGraphics::CTextureHandle m_aTextures[MAX_MAPIMAGES];
40 int m_aTextureUsedByTileOrQuadLayerFlag[MAX_MAPIMAGES]; // 0: nothing, 1(as flag): tile layer, 2(as flag): quad layer
41 int m_Count;
42
43 char m_aEntitiesPath[IO_MAX_PATH_LENGTH];
44
45public:
46 CMapImages();
47 CMapImages(int TextureSize);
48 virtual int Sizeof() const override { return sizeof(*this); }
49
50 IGraphics::CTextureHandle Get(int Index) const { return m_aTextures[Index]; }
51 int Num() const { return m_Count; }
52
53 void OnMapLoadImpl(class CLayers *pLayers, class IMap *pMap);
54 virtual void OnMapLoad() override;
55 virtual void OnInit() override;
56 void LoadBackground(class CLayers *pLayers, class IMap *pMap);
57
58 // DDRace
59 IGraphics::CTextureHandle GetEntities(EMapImageEntityLayerType EntityLayerType);
60 IGraphics::CTextureHandle GetSpeedupArrow();
61
62 IGraphics::CTextureHandle GetOverlayBottom();
63 IGraphics::CTextureHandle GetOverlayTop();
64 IGraphics::CTextureHandle GetOverlayCenter();
65
66 void SetTextureScale(int Scale);
67 int GetTextureScale() const;
68
69 void ChangeEntitiesPath(const char *pPath);
70
71private:
72 bool m_aEntitiesIsLoaded[MAP_IMAGE_MOD_TYPE_COUNT * 2];
73 bool m_SpeedupArrowIsLoaded;
74 IGraphics::CTextureHandle m_aaEntitiesTextures[MAP_IMAGE_MOD_TYPE_COUNT * 2][MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT];
75 IGraphics::CTextureHandle m_SpeedupArrowTexture;
76 IGraphics::CTextureHandle m_OverlayBottomTexture;
77 IGraphics::CTextureHandle m_OverlayTopTexture;
78 IGraphics::CTextureHandle m_OverlayCenterTexture;
79 int m_TextureScale;
80
81 void InitOverlayTextures();
82 IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int MaxWidth, int YOffset);
83 void UpdateEntityLayerText(CImageInfo &TextImage, int TextureSize, int MaxWidth, int YOffset, int NumbersPower, int MaxNumber = -1);
84};
85
86#endif
87