| 1 | #ifndef GAME_CLIENT_COMPONENTS_BACKGROUND_H |
|---|---|
| 2 | #define GAME_CLIENT_COMPONENTS_BACKGROUND_H |
| 3 | |
| 4 | #include <engine/shared/map.h> |
| 5 | |
| 6 | #include <game/client/components/maplayers.h> |
| 7 | |
| 8 | #include <cstdint> |
| 9 | |
| 10 | class CLayers; |
| 11 | class CMapImages; |
| 12 | |
| 13 | // Special value to use background of current map |
| 14 | #define CURRENT_MAP "%current%" |
| 15 | |
| 16 | class CBackgroundEngineMap : public CMap |
| 17 | { |
| 18 | MACRO_INTERFACE("background_enginemap") |
| 19 | }; |
| 20 | |
| 21 | class CBackground : public CMapLayers |
| 22 | { |
| 23 | protected: |
| 24 | IEngineMap *m_pMap; |
| 25 | bool m_Loaded; |
| 26 | char m_aMapName[MAX_MAP_LENGTH]; |
| 27 | |
| 28 | //to avoid memory leak when switching to %current% |
| 29 | CBackgroundEngineMap *m_pBackgroundMap; |
| 30 | CLayers *m_pBackgroundLayers; |
| 31 | CMapImages *m_pBackgroundImages; |
| 32 | |
| 33 | virtual CBackgroundEngineMap *CreateBGMap(); |
| 34 | |
| 35 | public: |
| 36 | CBackground(ERenderType MapType = ERenderType::RENDERTYPE_BACKGROUND_FORCE, bool OnlineOnly = true); |
| 37 | ~CBackground() override; |
| 38 | int Sizeof() const override { return sizeof(*this); } |
| 39 | |
| 40 | void OnInit() override; |
| 41 | void OnMapLoad() override; |
| 42 | void OnRender() override; |
| 43 | |
| 44 | void LoadBackground(); |
| 45 | const char *MapName() const { return m_aMapName; } |
| 46 | }; |
| 47 | |
| 48 | #endif |
| 49 |