21
24
#include <sigc++/signal.h>
27
#include "shieldstyle.h"
29
* Description of a single shield type
31
* This class is the atom of every shield. It contains all data related to
32
* a single shield type of a shieldset.
36
class Shield : public sigc::trackable
33
//! A single set of shields for a player
37
class Shield : public std::list<ShieldStyle*>, public sigc::trackable
41
//! The notional player that the Shield goes with.
40
42
enum ShieldColour {WHITE = 0, GREEN = 1, YELLOW = 2, LIGHT_BLUE = 3,
41
43
RED = 4, DARK_BLUE = 5, ORANGE = 6, BLACK = 7, NEUTRAL = 8};
42
enum ShieldType {SMALL = 0, MEDIUM = 1, LARGE = 2};
43
/** Loading constructor. See XML_Helper for more details.
45
* @param helper the XML_Helper instance of the shieldset xml
45
//! Loading constructor.
47
* Make a new Shield object by reading it in from an opened shieldset
50
* @param helper The opened shieldset configuration file to read the
47
53
Shield(XML_Helper* helper);
54
//! Set the basic image of the unit type
55
void setPixmap(SDL_Surface* pixmap);
57
//! Set the mask of the unit type (for player colors)
58
void setMask(SDL_Surface* mask);
60
//! Set the shieldset of the shield
61
void setShieldset(std::string shieldset) {d_shieldset = shieldset;};
63
//! Get the shieldset of the shield
64
std::string getShieldset() const {return d_shieldset;}
69
//! Get the type of this shield
70
Uint32 getType() const {return d_type;}
71
//! Get the colour of this shield
72
Uint32 getColour() const {return d_colour;}
74
//! Get the image of the shield. Internally, this refers to GraphicsCache.
75
SDL_Surface* getPixmap() const;
77
//! Returns the mask (read-only!!) for player colors
78
SDL_Surface* getMask() const {return d_mask;}
80
//! Returns the basename of the picture's filename
81
std::string getImageName() const {return d_image;}
82
void setImageName(std::string image) {d_image = image;}
58
//! Get the player that this shield will belong to.
59
Uint32 getOwner() const {return d_owner;}
61
//! Returns the colour of the player.
62
SDL_Color getColor() const {return d_color;}
64
SDL_Color getMaskColor() const;
66
void instantiatePixmaps(Shieldset *sh);
69
* Get the default colour for the Player with the given Id.
71
* @note This colour is used to graphically shade Army, Shield, Flags,
72
* and selector pictures.
74
* @note This is not used to obtain the Neutral player's colour.
76
* @param player_no The player's Id for which we want the colour.
78
* @return The default colour associated with the player.
80
//! Get standard colour for a player.
81
static SDL_Color get_default_color_for_no(int player_no);
83
//! Get standard colour for the neutral player.
84
static SDL_Color get_default_color_for_neutral();
88
SDL_Surface* d_pixmap;
91
std::string d_shieldset;
87
//! The player of the shield.
89
* Equates to the shieldset.shield.d_colour XML entities in the
90
* shieldset configuration file.
91
* Equates to the Shield::ShieldColour enumeration.
95
//! The player's colour.
97
* Mask portions of images are shaded in this colour.
94
102
#endif // SHIELD_H