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_DRAGONAGE2_CAMPAIGN_H
26 #define ENGINES_DRAGONAGE2_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 DragonAge2 {
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 
110 
111  const RIMNode *parent;
113 
114  RIMNode(const RIMNode *p = 0);
115  };
117  typedef std::map<Common::UString, const RIMNode *> AreaMap;
118 
119  typedef std::list<Events::Event> EventQueue;
120 
121 
123 
125 
128 
131 
133 
134  bool _enabled;
135  bool _bioware;
137 
141 
146 
147  float _entryPosition[3];
149 
150  std::vector<Common::UString> _packages;
151 
154 
155  std::vector<Common::UString> _areas;
156 
157  bool _loaded;
158 
161 
164 
167 
169 
170 
171  Campaign(Game &game, const Common::UString &cifPath = "",
172  const Common::UString &manifestPath = "", const Common::UString &addinBase = "");
173  ~Campaign();
174 
175  // .--- Loader
176  void read(const Common::UString &cifPath, const Common::UString &manifestPath);
177  void readCIFStatic(const Common::UString &path);
178  RIMNode *readRIMs(const Aurora::GFF4Struct &node, const RIMNode *parent = 0);
179  void readManifest(const Common::UString &path);
180 
181  void addAreaName(const RIMNode &node);
182 
183  void readCIFDynamic(const Common::UString &path);
184  void loadResources();
185  // '---
186 
187  // .--- Methods called by the Campaigns context
189  void load();
191  void unload();
192 
194  void enter(Creature &pc);
196  void leave();
197 
199  void addEvent(const Events::Event &event);
201  void processEventQueue();
202 
203  void loadArea();
204  void unloadArea();
205  bool changeArea();
206 
207  void enterArea(bool startArea = false);
208  void leaveArea();
209 
210  void handleEvents();
211  // '---
212 
213  friend class Campaigns;
214 
215  template<typename T>
216  friend void Common::DeallocatorDefault::destroy(T *);
217 };
218 
219 } // End of namespace DragonAge2
220 
221 } // End of namespace Engines
222 
223 #endif // ENGINES_DRAGONAGE2_CAMPAIGN_H
Basic event types.
A node in the RIM tree.
Definition: campaign.h:101
Generic Aurora engines resource utility functions.
const Common::UString & getExtendsUID() const
Return the UID of the campaign this campaign/content extends, if any.
Definition: campaign.cpp:98
void leave()
Leave the campaign, ending it.
Definition: campaign.cpp:432
void readCIFStatic(const Common::UString &path)
Definition: campaign.cpp:139
Common::PtrVector< const RIMNode > Children
Definition: campaign.h:102
A container of Dragon Age II objects.
A class holding an UTF-8 string.
Definition: ustring.h:48
A localized string.
Definition: locstring.h:43
virtual void enter()
The cursor entered the object.
Definition: object.cpp:161
Common::UString _entryClientScript
Definition: campaign.h:145
Creature * getPC() const
Return the currently playing PC.
Definition: campaign.cpp:296
const Aurora::LocString & getDescription() const
Definition: campaign.cpp:94
bool isEnabled() const
Is this Campaign enabled?
Definition: campaign.cpp:266
Creature * _pc
The player character we use.
Definition: campaign.h:163
An area in Dragon Age II, holding all objects and rooms within, as well as general area properties li...
Definition: area.h:64
void read(const Common::UString &cifPath, const Common::UString &manifestPath)
Definition: campaign.cpp:102
Common::UString environment
Directory in which to find environment resources.
Definition: campaign.h:107
bool isLoaded() const
Is this campaign currently loaded?
Definition: campaign.cpp:300
bool isBioWare() const
Is this an original campaign by BioWare?
Definition: campaign.cpp:270
An object in a Dragon Age II area.
Common::ScopedPtr< Area > _currentArea
The current area.
Definition: campaign.h:166
std::list< Events::Event > EventQueue
Definition: campaign.h:119
A simple scoped smart pointer template.
std::list< Common::ChangeID > ChangeList
Definition: resources.h:41
SDL_Event Event
Definition: types.h:42
std::vector< Common::UString > _packages
Definition: campaign.h:150
const Common::UString & getAreaRIM(const Common::UString &area) const
Return the RIM file containing this area.
Definition: campaign.cpp:278
Area * getCurrentArea() const
Return the area the PC is currently in.
Definition: campaign.cpp:292
Aurora::LocString _description
Definition: campaign.h:130
Common::UString _extends
Definition: campaign.h:132
Common::ScopedPtr< RIMNode > _rimRoot
Definition: campaign.h:152
void enterArea(bool startArea=false)
Definition: campaign.cpp:376
static void destroy(T *x)
Definition: deallocator.h:40
Common::UString _cifPath
Definition: campaign.h:126
A vector storing pointer to objects, with automatic deletion.
Common::UString _addinBase
Definition: campaign.h:127
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Common::UString _newArea
The new area to enter.
Definition: campaign.h:165
Handling BioWare&#39;s localized strings.
Common::UString _entryScript
Definition: campaign.h:144
Campaign(Game &game, const Common::UString &cifPath="", const Common::UString &manifestPath="", const Common::UString &addinBase="")
Definition: campaign.cpp:61
Unicode string handling.
std::vector< Common::UString > _areas
Definition: campaign.h:155
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
Common::UString area
ResRef of the area this node describes, if any.
Definition: campaign.h:105
const std::vector< Common::UString > & getAreas() const
Definition: campaign.cpp:288
void movePC(const Common::UString &area)
Move the player character to this area.
Definition: campaign.cpp:508
void unload()
Unload the campaign after playing.
Definition: campaign.cpp:357
uint32_t uint32
Definition: types.h:204
Common::UString rim
The module RIM file.
Definition: campaign.h:108
void load()
Load the campaign for playing.
Definition: campaign.cpp:345
void readCIFDynamic(const Common::UString &path)
Definition: campaign.cpp:327
RIMNode * readRIMs(const Aurora::GFF4Struct &node, const RIMNode *parent=0)
std::map< Common::UString, const RIMNode * > AreaMap
Map of area RIMNodes indexed by the area resref.
Definition: campaign.h:117
bool needsAuth() const
Does this campaign need authorization from BioWare?
Definition: campaign.cpp:274
void addAreaName(const RIMNode &node)
Common::UString tag
Name of the node itself, not unique.
Definition: campaign.h:104
const Common::UString & getUID() const
Return the unique ID of this campaign.
Definition: campaign.cpp:86
Aurora::LocString _name
Definition: campaign.h:129
const Aurora::LocString & getName() const
Definition: campaign.cpp:90
void processEventQueue()
Process the current event queue.
Definition: campaign.cpp:487
Common::UString _entryAreaList
Definition: campaign.h:143
Common::UString rimFXE
The RIM file containing facial animations (FXE).
Definition: campaign.h:109
void readManifest(const Common::UString &path)
Definition: campaign.cpp:220
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: campaign.cpp:483
Common::UString _entryArea
Definition: campaign.h:142