~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/armysetlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2001, 2002, 2003 Michael Bartl
 
2
// Copyright (C) 2003, 2004, 2005  Ulf Lorenz
 
3
// Copyright (C) 2007, 2008 Ben Asselstine
 
4
//
1
5
//  This program is free software; you can redistribute it and/or modify
2
6
//  it under the terms of the GNU General Public License as published by
3
7
//  the Free Software Foundation; either version 2 of the License, or
10
14
//
11
15
//  You should have received a copy of the GNU General Public License
12
16
//  along with this program; if not, write to the Free Software
13
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
18
//  02110-1301, USA.
14
19
 
15
20
#ifndef ARMYSETLIST_H
16
21
#define ARMYSETLIST_H
25
30
#include "armyset.h"
26
31
 
27
32
 
28
 
/** List of all available armysets
29
 
  * 
30
 
  * This class contains a list of all armysetsused in the game. Each armyset has
31
 
  * a size, a name and a list of armies. The armysetlist shields all these from
32
 
  * the evil rest of the program. Armysets are in general referenced by their
33
 
  * id.
34
 
  *
35
 
  * @note Throughout this class, it is assumed that the standard armyset usable
36
 
  * by all playes ha sthe index 1, the heroes armyset index 2. However, to avoid
37
 
  * this assumption being spread over the whole code, we separate the access to
38
 
  * these two armysets from the rest via special functions.
39
 
  *
40
 
  * Since several classes access this class, it is implemented as a singleton.
41
 
  */
 
33
//! A list of all Armyset objects available to the game.
 
34
/** 
 
35
 * This class contains a list of all armyset objects available to the game. 
 
36
 * Each armyset has a size, a name and a list of armies. The armysetlist 
 
37
 * shields all these from the rest of the program.  Armysets are most often
 
38
 * referenced by their id.
 
39
 *
 
40
 * The Armysetlist is populated with Armyset objects that are loaded from the 
 
41
 * army/ directory.
 
42
 *
 
43
 * Since several classes access this class, it is implemented as a singleton.
 
44
 */
42
45
 
43
46
class Armysetlist : public std::list<Armyset*>, public sigc::trackable
44
47
{
45
48
    public:
46
 
        //! return the singleton instance of this class
 
49
        //! Return the singleton instance of this class.
47
50
        static Armysetlist* getInstance();
48
51
 
49
52
        //! Explicitly delete the singleton instance of this class
50
53
        static void deleteInstance();
51
54
 
52
 
        /** Returns an army prototype
53
 
          *
54
 
          * @param id       the id of the armyset
55
 
          * @param index    the index of the army within the set
56
 
          * @return the requested army or 0 on error
57
 
          */
 
55
        //! Returns an army prototype from a given armyset.
 
56
        /** 
 
57
         * @param id       The Id of the armyset.
 
58
         * @param index    The index of the army within the set.
 
59
         *                 This value becomes the Army object's type.
 
60
         *
 
61
         * @return The requested army or 0 on error.
 
62
         */
58
63
        Army* getArmy(Uint32 id, Uint32 index) const;
59
64
 
 
65
        //! Get the unshaded ship image for the given Armyset.
60
66
        SDL_Surface * getShipPic (Uint32 id);
 
67
 
 
68
        //! Get the ship mask picture for the given Armyset.
61
69
        SDL_Surface * getShipMask (Uint32 id);
 
70
 
 
71
        //! Get the unshaded planted standard picture for the given Armyset.
62
72
        SDL_Surface * getStandardPic (Uint32 id);
 
73
 
 
74
        //! Get the planted standard mask for the given Armyset.
63
75
        SDL_Surface * getStandardMask (Uint32 id);
64
76
        Uint32 getTileSize(Uint32 id);
65
77
 
66
 
        /** Returns the size of a specific armyset
67
 
          * 
68
 
          * @param id       the id of the armyset
69
 
          * @return size of the armyset or 0 on error (an armyset should never
70
 
          *         have a size of 0)
71
 
          */
 
78
        //! Returns the size of a specific armyset.
 
79
        /** 
 
80
         * @param id       The id of the armyset to get the size of.
 
81
         *
 
82
         * @return The number of Army prototype objects in the Armyset.
 
83
         *         Returns 0 on error. 
 
84
         */
72
85
        Uint32 getSize(Uint32 id) const;
73
86
 
74
 
        /** Returns the name of a specific armyset
75
 
          * 
76
 
          * @param id       the id of the armyset
77
 
          * @return the name or an empty string on error
78
 
          */
 
87
        //! Return the name of a given armyset.
 
88
        /** 
 
89
         * @param id       The id of the armyset to get the name of.
 
90
         *
 
91
         * @return The name of the Armyset or an empty string on error.
 
92
         */
79
93
        std::string getName(Uint32 id) const;
80
94
 
81
 
        //! Returns the names of all armysets
 
95
        //! Returns the names of all Armyset objects available to the game.
82
96
        std::list<std::string> getNames();
83
97
 
84
98
        /** Returns the Id of a specific armyset by name
88
102
          */
89
103
        Uint32 getArmysetId(std::string armyset) {return d_ids[armyset];}
90
104
 
91
 
        /** Returns a list of all existing army sets
92
 
          */
 
105
        //! Returns a list of all Armyset objects available to the game.
93
106
        std::vector<Uint32> getArmysets() const;
94
107
 
95
 
        /* Reads in the pixmap and mask for every army of every armyset.
96
 
         * This can only be done after SDL is initialized.
 
108
        //! Load the pictures for all Armyset objects available to the game.
 
109
        /**
 
110
         * Reads in the pixmap and mask for every army of every armyset.
 
111
         * @note This can only be done after SDL is initialized.
97
112
         */
98
113
        void instantiatePixmaps();
99
114
 
100
115
    private:
101
 
        //! Constructor; loads all armysets it can find
 
116
        //! Default Constructor.  Loads all armyset objects it can find.
 
117
        /**
 
118
         * The army/ directory is scanned for armyset directories.
 
119
         */
102
120
        Armysetlist();
103
121
        
104
 
        //! Destructor; mainly clears the lists
 
122
        //! Destructor.
105
123
        ~Armysetlist();
106
124
 
107
 
        //! Callback for loading. See XML_Helper for details.
 
125
        //! Callback for loading an armyset.  See XML_Helper for details.
108
126
        bool load(std::string tag, XML_Helper *helper);
109
127
 
110
 
        //! Loads a specific armyset
 
128
        //! Loads a specific armyset.
 
129
        /**
 
130
         * Load the armyset from an armyset configuration file and add it to 
 
131
         * this list of armysets.
 
132
         *
 
133
         * @param name  The subdirectory name that the Armyset resides in.
 
134
         *
 
135
         * @return True if the Armyset could be loaded.  False otherwise.
 
136
         */
111
137
        bool loadArmyset (std::string name);
112
138
        
113
 
        typedef std::map<Uint32, std::vector<Army*> > ArmyMap;
 
139
        typedef std::map<Uint32, std::vector<Army*> > ArmyPrototypeMap;
114
140
        typedef std::map<Uint32, std::string> NameMap;
115
141
        typedef std::map<std::string, Uint32> IdMap;
116
142
        
117
 
        ArmyMap d_armies;
 
143
        //! A map that provides Army objects by their index.
 
144
        ArmyPrototypeMap d_armies;
 
145
 
 
146
        //! A map that provides Armyset::d_name by supplying a Armyset::d_id.
118
147
        NameMap d_names;
 
148
 
 
149
        //! A map that provides Armyset:d_id by supplying a Armyset::d_name.
119
150
        IdMap d_ids;
120
151
 
 
152
        //! A static pointer for the singleton instance.
121
153
        static Armysetlist* s_instance;
122
154
};
123
155