~ubuntu-branches/ubuntu/trusty/lordsawar/trusty

« back to all changes in this revision

Viewing changes to src/shield.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2008-06-17 16:07:00 UTC
  • mto: (5.1.1 lenny) (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20080617160700-6d8ofoz0qkasxlnw
ImportĀ upstreamĀ versionĀ 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  Copyright (C) 2008, Ben Asselstine
 
2
//
1
3
//  This program is free software; you can redistribute it and/or modify
2
4
//  it under the terms of the GNU General Public License as published by
3
5
//  the Free Software Foundation; either version 2 of the License, or
10
12
//
11
13
//  You should have received a copy of the GNU General Public License
12
14
//  along with this program; if not, write to the Free Software
13
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
16
//  02110-1301, USA.
14
17
 
15
18
#ifndef SHIELD_H
16
19
#define SHIELD_H
21
24
#include <sigc++/signal.h>
22
25
 
23
26
#include "defs.h"
 
27
#include "shieldstyle.h"
24
28
 
25
29
class Player;
26
30
class XML_Helper;
27
 
 
28
 
 /*
29
 
  * Description of a single shield type
30
 
  * 
31
 
  * This class is the atom of every shield. It contains all data related to
32
 
  * a single shield type of a shieldset.
33
 
  *
34
 
  */
35
 
 
36
 
class Shield : public sigc::trackable
 
31
class Shieldset;
 
32
 
 
33
//! A single set of shields for a player
 
34
/**
 
35
 *
 
36
 */
 
37
class Shield : public std::list<ShieldStyle*>, public sigc::trackable
37
38
{
38
39
    public:
39
40
 
 
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.
44
 
          *
45
 
          * @param helper       the XML_Helper instance of the shieldset xml
46
 
          */
 
44
 
 
45
        //! Loading constructor.
 
46
        /**
 
47
         * Make a new Shield object by reading it in from an opened shieldset
 
48
         * configuration file.
 
49
         *
 
50
         * @param helper  The opened shieldset configuration file to read the
 
51
         *                shield object from.
 
52
         */
47
53
        Shield(XML_Helper* helper);
48
54
        
 
55
        //! Destructor.
49
56
        virtual ~Shield();
50
57
 
51
 
 
52
 
        // Set functions:
53
 
        
54
 
        //! Set the basic image of the unit type
55
 
        void setPixmap(SDL_Surface* pixmap);
56
 
 
57
 
        //! Set the mask of the unit type (for player colors)
58
 
        void setMask(SDL_Surface* mask);
59
 
 
60
 
        //! Set the shieldset of the shield
61
 
        void setShieldset(std::string shieldset) {d_shieldset = shieldset;};
62
 
 
63
 
        //! Get the shieldset of the shield
64
 
        std::string getShieldset() const {return d_shieldset;}
65
 
 
66
 
        
67
 
        // Get functions
68
 
        
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;}
73
 
 
74
 
        //! Get the image of the shield. Internally, this refers to GraphicsCache.
75
 
        SDL_Surface* getPixmap() const;
76
 
 
77
 
        //! Returns the mask (read-only!!) for player colors
78
 
        SDL_Surface* getMask() const {return d_mask;}
79
 
 
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;}
83
 
 
 
58
        //! Get the player that this shield will belong to.
 
59
        Uint32 getOwner() const {return d_owner;}
 
60
 
 
61
        //! Returns the colour of the player.
 
62
        SDL_Color getColor() const {return d_color;}
 
63
 
 
64
        SDL_Color getMaskColor() const;
 
65
 
 
66
        void instantiatePixmaps(Shieldset *sh);
 
67
 
 
68
        /**
 
69
         * Get the default colour for the Player with the given Id.
 
70
         *
 
71
         * @note This colour is used to graphically shade Army, Shield, Flags,
 
72
         * and selector pictures.
 
73
         *
 
74
         * @note This is not used to obtain the Neutral player's colour.
 
75
         *
 
76
         * @param player_no  The player's Id for which we want the colour.
 
77
         *
 
78
         * @return The default colour associated with the player.
 
79
         */
 
80
        //! Get standard colour for a player.
 
81
        static SDL_Color get_default_color_for_no(int player_no);
 
82
 
 
83
        //! Get standard colour for the neutral player.
 
84
        static SDL_Color get_default_color_for_neutral();
84
85
    protected:
85
86
 
86
 
        Uint32 d_type;
87
 
        Uint32 d_colour;
88
 
        SDL_Surface* d_pixmap;
89
 
        SDL_Surface* d_mask;
90
 
        std::string d_image;
91
 
        std::string d_shieldset;
 
87
        //! The player of the shield.
 
88
        /**
 
89
         * Equates to the shieldset.shield.d_colour XML entities in the 
 
90
         * shieldset configuration file.
 
91
         * Equates to the Shield::ShieldColour enumeration.
 
92
         */
 
93
        Uint32 d_owner;
 
94
 
 
95
        //! The player's colour.
 
96
        /**
 
97
         * Mask portions of images are shaded in this colour.
 
98
         */
 
99
        SDL_Color d_color;
92
100
};
93
101
 
94
102
#endif // SHIELD_H