~ubuntu-branches/ubuntu/precise/lordsawar/precise

« back to all changes in this revision

Viewing changes to src/armysetlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2007-10-29 15:38:06 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071029153806-z2j47adhmdjc7wae
Tags: 0.0.4-1
* New upstream release
* Add desktop file and simple manpage for new binary lordsawar-army-editor
* Syntax fixes on manpages
* Move manpages to correct section (6)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "xmlhelper.h"
24
24
#include "army.h"
 
25
#include "armyset.h"
25
26
 
26
27
 
27
28
/** List of all available armysets
39
40
  * Since several classes access this class, it is implemented as a singleton.
40
41
  */
41
42
 
42
 
class Armysetlist : public sigc::trackable
 
43
class Armysetlist : public std::list<Armyset*>, public sigc::trackable
43
44
{
44
45
    public:
45
46
        //! return the singleton instance of this class
46
47
        static Armysetlist* getInstance();
47
48
 
48
 
        //! Explicitely delete the singleton instance of this class
 
49
        //! Explicitly delete the singleton instance of this class
49
50
        static void deleteInstance();
50
51
 
51
 
 
52
52
        /** Returns an army prototype
53
53
          *
54
54
          * @param id       the id of the armyset
55
55
          * @param index    the index of the army within the set
56
56
          * @return the requested army or 0 on error
57
57
          */
58
 
        const Army* getArmy(Uint32 id, Uint32 index) const;
 
58
        Army* getArmy(Uint32 id, Uint32 index) const;
 
59
 
 
60
        SDL_Surface * getShipPic (Uint32 id);
 
61
        SDL_Surface * getShipMask (Uint32 id);
 
62
        SDL_Surface * getStandardPic (Uint32 id);
 
63
        SDL_Surface * getStandardMask (Uint32 id);
 
64
        Uint32 getTileSize(Uint32 id);
59
65
 
60
66
        /** Returns the size of a specific armyset
61
67
          * 
72
78
          */
73
79
        std::string getName(Uint32 id) const;
74
80
 
 
81
        //! Returns the names of all armysets
 
82
        std::list<std::string> getNames();
 
83
 
 
84
        /** Returns the Id of a specific armyset by name
 
85
          * 
 
86
          * @param armyset       the name of the armyset
 
87
          * @return the id of the armyset (0 on error)
 
88
          */
 
89
        Uint32 getArmysetId(std::string armyset) {return d_ids[armyset];}
 
90
 
75
91
        /** Returns a list of all existing army sets
76
92
          */
77
93
        std::vector<Uint32> getArmysets() const;
78
94
 
79
 
        // FIXME: quick hack
80
 
        typedef std::map<std::string, Uint32> FileNameMap;
81
 
        FileNameMap file_names;
82
 
        
 
95
        /* Reads in the pixmap and mask for every army of every armyset.
 
96
         * This can only be done after SDL is initialized.
 
97
         */
 
98
        void instantiatePixmaps();
 
99
 
83
100
    private:
84
101
        //! Constructor; loads all armysets it can find
85
102
        Armysetlist();
87
104
        //! Destructor; mainly clears the lists
88
105
        ~Armysetlist();
89
106
 
 
107
        //! Callback for loading. See XML_Helper for details.
 
108
        bool load(std::string tag, XML_Helper *helper);
90
109
 
91
110
        //! Loads a specific armyset
92
111
        bool loadArmyset (std::string name);
93
112
        
94
 
        //! Callback function for the armyset tag (see XML_Helper)
95
 
        bool loadGlobalStuff(std::string tag, XML_Helper* helper);
96
 
 
97
 
        //! Callback function for the army tag (see XML_Helper)
98
 
        bool loadArmy(std::string tag, XML_Helper* helper);
99
 
 
100
 
        
101
113
        typedef std::map<Uint32, std::vector<Army*> > ArmyMap;
102
114
        typedef std::map<Uint32, std::string> NameMap;
 
115
        typedef std::map<std::string, Uint32> IdMap;
103
116
        
104
117
        ArmyMap d_armies;
105
118
        NameMap d_names;
106
 
 
107
 
        // temporary variables for game loading
108
 
        Uint32 d_loading;
109
 
        std::string d_file;
 
119
        IdMap d_ids;
110
120
 
111
121
        static Armysetlist* s_instance;
112
122
};