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