xoreos  0.0.5
campaign.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_DRAGONAGE_CAMPAIGN_H
26 #define ENGINES_DRAGONAGE_CAMPAIGN_H
27 
28 #include <vector>
29 #include <list>
30 #include <map>
31 
32 #include "src/common/scopedptr.h"
33 #include "src/common/ptrvector.h"
34 #include "src/common/ustring.h"
35 
36 #include "src/aurora/locstring.h"
37 #include "src/aurora/types.h"
38 
39 #include "src/events/types.h"
40 
42 
45 
46 namespace Engines {
47 
48 namespace DragonAge {
49 
50 class Game;
51 class Area;
52 class Creature;
53 
55 public:
56  // .--- Static information
58  const Common::UString &getUID() const;
59 
60  const Aurora::LocString &getName() const;
61  const Aurora::LocString &getDescription() const;
62 
64  const Common::UString &getExtendsUID() const;
65 
66  bool isEnabled() const;
67  bool isBioWare() const;
68  bool needsAuth() const;
69  // '---
70 
71  // .--- Areas
73  const Common::UString &getAreaRIM(const Common::UString &area) const;
74 
75  const std::vector<Common::UString> &getAreas() const;
76  // '---
77 
78  // .--- Elements of the current campaign
80  Area *getCurrentArea() const;
82  Creature *getPC() const;
83  // '---
84 
85  // .--- Campaign management
87  bool isLoaded() const;
88  // '---
89 
90  // .--- PC management
92  void movePC(const Common::UString &area);
94  void movePC(float x, float y, float z);
96  void movePC(const Common::UString &area, float x, float y, float z);
97  // '---
98 
99 private:
101  struct RIMNode {
103 
106 
109 
110  const RIMNode *parent;
112 
113  RIMNode(const RIMNode *p = 0);
114  };
116  typedef std::map<Common::UString, const RIMNode *> AreaMap;
117 
118  typedef std::list<Events::Event> EventQueue;
119 
120 
122 
124 
127 
130 
132 
133  bool _enabled;
134  bool _bioware;
136 
140 
145 
146  float _entryPosition[3];
148 
149  std::vector<Common::UString> _packages;
150 
153 
154  std::vector<Common::UString> _areas;
155 
156  bool _loaded;
157 
160 
163 
166 
168 
169 
170  Campaign(Game &game, const Common::UString &cifPath = "",
171  const Common::UString &manifestPath = "", const Common::UString &addinBase = "");
172  ~Campaign();
173 
174  // .--- Loader
175  void read(const Common::UString &cifPath, const Common::UString &manifestPath);
176  void readCIFStatic(const Common::UString &path);
177  RIMNode *readRIMs(const Aurora::GFF4Struct &node, const RIMNode *parent = 0);
178  void readManifest(const Common::UString &path);
179 
180  void addAreaName(const RIMNode &node);
181 
182  void readCIFDynamic(const Common::UString &path);
183  void loadResources();
184  // '---
185 
186  // .--- Methods called by the Campaigns context
188  void load();
190  void unload();
191 
193  void enter(Creature &pc);
195  void leave();
196 
198  void addEvent(const Events::Event &event);
200  void processEventQueue();
201 
202  void loadArea();
203  void unloadArea();
204  bool changeArea();
205 
206  void enterArea(bool startArea = false);
207  void leaveArea();
208 
209  void handleEvents();
210  // '---
211 
212  friend class Campaigns;
213 
214  template<typename T>
215  friend void Common::DeallocatorDefault::destroy(T *);
216 };
217 
218 } // End of namespace DragonAge
219 
220 } // End of namespace Engines
221 
222 #endif // ENGINES_DRAGONAGE_CAMPAIGN_H
Basic event types.
Generic Aurora engines resource utility functions.
std::map< Common::UString, const RIMNode * > AreaMap
Map of area RIMNodes indexed by the area resref.
Definition: campaign.h:116
A class holding an UTF-8 string.
Definition: ustring.h:48
A localized string.
Definition: locstring.h:43
std::vector< Common::UString > _packages
Definition: campaign.h:149
Area * getCurrentArea() const
Return the area the PC is currently in.
Definition: campaign.cpp:291
bool isLoaded() const
Is this campaign currently loaded?
Definition: campaign.cpp:299
Common::UString _entryClientScript
Definition: campaign.h:144
virtual void enter()
The cursor entered the object.
Definition: object.cpp:161
void readCIFStatic(const Common::UString &path)
Definition: campaign.cpp:139
void unload()
Unload the campaign after playing.
Definition: campaign.cpp:356
void enterArea(bool startArea=false)
Definition: campaign.cpp:375
A container of Dragon Age: Origins objects.
void readCIFDynamic(const Common::UString &path)
Definition: campaign.cpp:326
Common::UString _addinBase
Definition: campaign.h:126
const std::vector< Common::UString > & getAreas() const
Definition: campaign.cpp:287
Common::UString tag
Name of the node itself, not unique.
Definition: campaign.h:104
bool isEnabled() const
Is this Campaign enabled?
Definition: campaign.cpp:265
std::vector< Common::UString > _areas
Definition: campaign.h:154
const Aurora::LocString & getDescription() const
Definition: campaign.cpp:94
RIMNode * readRIMs(const Aurora::GFF4Struct &node, const RIMNode *parent=0)
A simple scoped smart pointer template.
std::list< Common::ChangeID > ChangeList
Definition: resources.h:41
SDL_Event Event
Definition: types.h:42
const Aurora::LocString & getName() const
Definition: campaign.cpp:90
Common::UString rim
The module RIM file.
Definition: campaign.h:108
void leave()
Leave the campaign, ending it.
Definition: campaign.cpp:431
Aurora::LocString _description
Definition: campaign.h:129
std::list< Events::Event > EventQueue
Definition: campaign.h:118
Common::ScopedPtr< Area > _currentArea
The current area.
Definition: campaign.h:165
Common::UString _newArea
The new area to enter.
Definition: campaign.h:164
Creature * getPC() const
Return the currently playing PC.
Definition: campaign.cpp:295
Common::UString _extends
Definition: campaign.h:131
Common::UString environment
Directory in which to find environment resources.
Definition: campaign.h:107
void load()
Load the campaign for playing.
Definition: campaign.cpp:344
static void destroy(T *x)
Definition: deallocator.h:40
void processEventQueue()
Process the current event queue.
Definition: campaign.cpp:486
Common::UString area
ResRef of the area this node describes, if any.
Definition: campaign.h:105
bool isBioWare() const
Is this an original campaign by BioWare?
Definition: campaign.cpp:269
void read(const Common::UString &cifPath, const Common::UString &manifestPath)
Definition: campaign.cpp:102
A vector storing pointer to objects, with automatic deletion.
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
const Common::UString & getAreaRIM(const Common::UString &area) const
Return the RIM file containing this area.
Definition: campaign.cpp:277
Common::UString _entryArea
Definition: campaign.h:141
Handling BioWare&#39;s localized strings.
An area in Dragon Age: Origins, holding all objects and rooms within, as well as general area propert...
Definition: area.h:64
Common::ScopedPtr< RIMNode > _rimRoot
Definition: campaign.h:151
Unicode string handling.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
An object in a Dragon Age: Origins area.
Common::UString _entryAreaList
Definition: campaign.h:142
Common::UString _uid
Definition: campaign.h:123
Common::UString _entryScript
Definition: campaign.h:143
uint32_t uint32
Definition: types.h:204
Aurora::LocString _name
Definition: campaign.h:128
void movePC(const Common::UString &area)
Move the player character to this area.
Definition: campaign.cpp:507
Common::UString _cifPath
Definition: campaign.h:125
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: campaign.cpp:482
void readManifest(const Common::UString &path)
Definition: campaign.cpp:219
A node in the RIM tree.
Definition: campaign.h:101
void addAreaName(const RIMNode &node)
Campaign(Game &game, const Common::UString &cifPath="", const Common::UString &manifestPath="", const Common::UString &addinBase="")
Definition: campaign.cpp:61
bool needsAuth() const
Does this campaign need authorization from BioWare?
Definition: campaign.cpp:273
const Common::UString & getExtendsUID() const
Return the UID of the campaign this campaign/content extends, if any.
Definition: campaign.cpp:98
Common::PtrVector< const RIMNode > Children
Definition: campaign.h:102
const Common::UString & getUID() const
Return the unique ID of this campaign.
Definition: campaign.cpp:86
Creature * _pc
The player character we use.
Definition: campaign.h:162