ddnet/src/game/client/components/background.h
Robert Müller 6633e9af1d Add button to reload entities background, improve DDNet menu layout
Add a button to manually reload the entities background map instead of automatically reloading it when it's changed. As the background map was only reloaded every 10 seconds, sometimes changing the background map quickly had no effect.

Improve the layout of the DDNet settings menu. Align labels and UI elements and reduce unused empty space.
2023-08-19 17:44:58 +02:00

49 lines
1.1 KiB
C++

#ifndef GAME_CLIENT_COMPONENTS_BACKGROUND_H
#define GAME_CLIENT_COMPONENTS_BACKGROUND_H
#include <engine/shared/map.h>
#include <game/client/components/maplayers.h>
#include <cstdint>
class CLayers;
class CMapImages;
// Special value to use background of current map
#define CURRENT_MAP "%current%"
class CBackgroundEngineMap : public CMap
{
MACRO_INTERFACE("background_enginemap", 0)
};
class CBackground : public CMapLayers
{
protected:
IEngineMap *m_pMap;
bool m_Loaded;
char m_aMapName[MAX_MAP_LENGTH];
//to avoid memory leak when switching to %current%
CBackgroundEngineMap *m_pBackgroundMap;
CLayers *m_pBackgroundLayers;
CMapImages *m_pBackgroundImages;
virtual CBackgroundEngineMap *CreateBGMap();
public:
CBackground(int MapType = CMapLayers::TYPE_BACKGROUND_FORCE, bool OnlineOnly = true);
virtual ~CBackground();
virtual int Sizeof() const override { return sizeof(*this); }
virtual void OnInit() override;
virtual void OnMapLoad() override;
virtual void OnRender() override;
void LoadBackground();
const char *MapName() const { return m_aMapName; }
};
#endif