1 // Copyright (C) 2008, 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include <sigc++/trackable.h>
24 #include <sigc++/signal.h>
26 #include "shieldstyle.h"
32 //! A single set of shields for a player
36 class Shield : public std::list<ShieldStyle*>, public sigc::trackable
40 //! The xml tag of this object in a shieldset configuration file.
41 static std::string d_tag;
43 //! The notional player that the Shield goes with.
44 enum Colour {WHITE = 0, GREEN = 1, YELLOW = 2, LIGHT_BLUE = 3, RED = 4,
45 DARK_BLUE = 5, ORANGE = 6, BLACK = 7, NEUTRAL = 8};
47 //! Loading constructor.
49 * Make a new Shield object by reading it in from an opened shieldset
52 * @param helper The opened shieldset configuration file to read the
55 Shield(XML_Helper* helper);
57 //! Default constructor.
58 Shield(Shield::Colour owner, Gdk::Color color);
66 //! Returns the player that this shield will belong to.
67 guint32 getOwner() const {return d_owner;}
69 //! Returns the colour of the player shield.
70 Gdk::Color getColor() const {return d_color;}
75 //! Sets the colour of the player shield.
76 void setColor(Gdk::Color c) {d_color = c;}
79 // Methods that operate on class data and do not modify the class.
81 //! Save the shield to an opened shieldset configuration file.
82 bool save(XML_Helper *helper) const;
84 //! Get the first shieldstyle in the shield with the given type.
85 ShieldStyle *getFirstShieldstyle(ShieldStyle::Type type);
88 // Methods that operate on class data and modify the class.
90 //! Load the images associated with this shield.
91 void instantiateImages(Shieldset *s);
93 //! Destroy the images associated with this shield.
94 void uninstantiateImages();
100 * Get the default colour for the Player with the given Id.
102 * @note This colour is used to graphically shade Army, Shield, Flags,
103 * and selector pictures.
105 * @note This is not used to obtain the Neutral player's colour.
107 * @param player_no The player's Id for which we want the colour.
109 * @return The default colour associated with the player.
111 //! Get standard colour for a player.
112 static Gdk::Color get_default_color_for_no(int player_no);
114 //! Get standard colour for the neutral player.
115 static Gdk::Color get_default_color_for_neutral();
117 //! Convert the Shield::Colour enumerated value to a string.
118 static std::string colourToString(const Shield::Colour c);
121 //! The player of the shield.
123 * Equates to the shieldset.shield.d_colour XML entities in the
124 * shieldset configuration file.
125 * Equates to the Shield::Colour enumeration.
129 //! The player's colour.
131 * Mask portions of images are shaded in this colour.