1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef ICON_HANDLER_H
#define ICON_HANDLER_H
#include <map>
#include <string>
#include <vector>
#include "Icon.h"
#include "System/float3.h"
namespace icon {
class CIconData {
public:
CIconData(); // for CIconHandler::safetyData
CIconData(const std::string& name, unsigned int texID,
float size, float distance, bool radiusAdjust,
bool ownTexture, int xsize, int ysize);
~CIconData();
void Ref();
void UnRef();
void CopyData(const CIconData* iconData);
void BindTexture() const;
void Draw(float x0, float y0, float x1, float y1) const;
void Draw(const float3& botLeft, const float3& botRight,
const float3& topLeft, const float3& topRight) const;
inline const std::string& GetName() const { return name; }
inline const float GetSize() const { return size; }
inline const float GetDistance() const { return distance; }
inline const float GetDistanceSqr() const { return distSqr; }
inline const bool GetRadiusAdjust() const { return radiusAdjust; }
inline const int GetSizeX() const { return xsize; }
inline const int GetSizeY() const { return ysize; }
private:
bool ownTexture;
int refCount;
std::string name;
unsigned int texID;
int xsize;
int ysize;
float size;
float distance;
float distSqr;
bool radiusAdjust;
};
class CIconHandler {
friend class CIcon;
public:
CIconHandler(void);
~CIconHandler(void);
bool AddIcon(const std::string& iconName,
const std::string& textureName,
float size, float distance,
bool radiusAdjust);
bool FreeIcon(const std::string& iconName);
CIcon GetIcon(const std::string& iconName) const;
CIcon GetDefaultIcon() const { return CIcon(defIconData); }
const CIconData* GetDefaultIconData() const { return defIconData; }
private:
bool LoadIcons(const std::string& filename);
unsigned int GetDefaultTexture();
private:
unsigned int defTexID;
CIconData* defIconData;
typedef std::map<std::string, CIcon> IconMap;
IconMap iconMap;
private:
static CIconData safetyData;
};
extern CIconHandler* iconHandler;
};
#endif // ICON_HANDLER_H
|