xoreos  0.0.5
module.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_WITCHER_MODULE_H
26 #define ENGINES_WITCHER_MODULE_H
27 
28 #include <list>
29 #include <map>
30 #include <set>
31 
32 #include "src/common/ptrmap.h"
33 #include "src/common/ustring.h"
34 #include "src/common/changeid.h"
35 
36 #include "src/aurora/ifofile.h"
37 
39 
40 #include "src/events/types.h"
41 
44 
45 namespace Engines {
46 
47 class Console;
48 
49 namespace Witcher {
50 
51 class Area;
52 class Creature;
53 
55 public:
56  Module(::Engines::Console &console);
57  ~Module();
58 
59  // .--- Module management
61  bool isLoaded() const;
63  bool isRunning() const;
64  // '---
65 
66  // .--- Information about the current module
68  const Aurora::IFOFile &getIFO() const;
69 
71  const Aurora::LocString &getName() const;
73  const Aurora::LocString &getDescription() const;
74  // '---
75 
76  // .--- Elements of the current module
80  Creature *getPC();
81  // '---
82 
83  // .--- Interact with the current campaign
85  void refreshLocalized();
86  // '---
87 
88  void delayScript(const Common::UString &script,
89  const Aurora::NWScript::ScriptState &state,
91  uint32 delay);
92 
93  // .--- PC management
95  void movePC(const Common::UString &area);
97  void movePC(float x, float y, float z);
99  void movePC(const Common::UString &area, float x, float y, float z);
101  void movePC(Area *area, float x, float y, float z);
103  void movePC(const Common::UString &module, const Common::UString &object);
105  void movedPC();
106  // '---
107 
108  // .--- Static utility methods
109  static Common::UString getName(const Common::UString &module);
110  static Common::UString getDescription(const Common::UString &module);
111 
112  static Common::UString findModule(const Common::UString &module, bool relative);
113  // '---
114 
115  // .--- Module main loop (called by the Campaign class)
117  void clear();
118 
120  void load(const Common::UString &module, const Common::UString &entryLocation = "");
122  void exit();
123 
125  void enter(Creature &pc);
127  void leave();
128 
130  void addEvent(const Events::Event &event);
132  void processEventQueue();
133  // '---
134 
135 private:
136  enum ActionType {
139  };
140 
141  struct Action {
143 
145 
149 
151 
152  bool operator<(const Action &s) const;
153  };
154 
156 
157  typedef std::list<Events::Event> EventQueue;
158  typedef std::multiset<Action> ActionQueue;
159 
160 
162 
163  bool _hasModule;
164  bool _running;
165  bool _exit;
166 
169 
171 
174 
178 
181 
184 
187 
188 
189  // .--- Unloading
190  void unload();
191 
192  void unloadModule();
193  void unloadPC();
194  void unloadAreas();
195  // '---
196 
197  // .--- Loading
198  void loadAreas();
199  // '---
200 
201  void enterArea();
202 
204  void loadModule(const Common::UString &module, const Common::UString &entryLocation);
206  void changeModule(const Common::UString &module, const Common::UString &entryLocation);
208  void replaceModule();
209 
210  bool getObjectLocation(const Common::UString &object, Common::UString &area,
211  float &x, float &y, float &z, float &angle);
213  float &entryX, float &entryY, float &entryZ, float &entryAngle);
215  float &entryX, float &entryY, float &entryZ, float &entryAngle);
216 
217  void handleEvents();
218 
219  void handleActions();
220 };
221 
222 } // End of namespace Witcher
223 
224 } // End of namespace Engines
225 
226 #endif // ENGINES_WITCHER_MODULE_H
void replaceModule()
Actually replace the currently running module.
Definition: module.cpp:140
Basic event types.
A container of The Witcher objects.
void loadAreas()
Load the areas.
Definition: module.cpp:379
bool _exit
Should we exit the module?
Definition: module.h:165
std::multiset< Action > ActionQueue
Definition: module.h:158
An area in The Witcher, holding all objects and area geometry within, as well as general area propert...
Definition: area.h:63
Common::UString _entryLocation
The tag of the object in the start location for this module.
Definition: module.h:183
A map storing pointer to objects, with automatic deletion.
Common::ChangeID _resModule
Resources added by the module.
Definition: module.h:168
A class holding an UTF-8 string.
Definition: ustring.h:48
const Aurora::LocString & getDescription() const
Return the module&#39;s description.
Definition: module.cpp:496
An object within a Witcher area.
Definition: object.h:51
A localized string.
Definition: locstring.h:43
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: module.cpp:268
bool operator<(const Action &s) const
Definition: module.cpp:54
void enterArea()
Enter a new area.
Definition: module.cpp:285
Area * getCurrentArea()
Return the area the PC is currently in.
Definition: module.cpp:75
bool isLoaded() const
Is a module currently loaded and ready to run?
Definition: module.cpp:83
void unloadPC()
Unload the PC.
Definition: module.cpp:408
void loadModule(const Common::UString &module, const Common::UString &entryLocation)
Load the actual module.
Definition: module.cpp:103
void processEventQueue()
Process the current event queue.
Definition: module.cpp:272
bool _running
Are we currently running a module?
Definition: module.h:164
SDL_Event Event
Definition: types.h:42
bool isRunning() const
Is a module currently running?
Definition: module.cpp:87
Aurora::IFOFile _ifo
The module&#39;s IFO.
Definition: module.h:170
Aurora::NWScript::ObjectReference triggerer
Definition: module.h:148
Common::UString _newArea
The new area to enter.
Definition: module.h:176
void unload()
Unload the whole shebang.
Definition: module.cpp:353
Loader for the module.ifo file.
Common::PtrMap< Common::UString, Area > AreaMap
Definition: module.h:155
Helper class to represent an undoable change.
An IFO (module information) file, describing global module properties in many Aurora games...
Definition: ifofile.h:69
An object in a The Witcher area.
AreaMap _areas
The areas in the current module.
Definition: module.h:175
const Aurora::IFOFile & getIFO() const
Return the IFO of the currently loaded module.
Definition: module.cpp:488
void unloadAreas()
Unload the areas.
Definition: module.cpp:401
Aurora::NWScript::ObjectReference owner
Definition: module.h:147
bool getEntryObjectLocation(Common::UString &area, float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:242
bool getObjectLocation(const Common::UString &object, Common::UString &area, float &x, float &y, float &z, float &angle)
Definition: module.cpp:213
Module(::Engines::Console &console)
Definition: module.cpp:59
Area * _currentArea
The current area.
Definition: module.h:177
void refreshLocalized()
Refresh all localized strings.
Definition: module.cpp:500
Aurora::NWScript::ScriptState state
Definition: module.h:146
void leave()
Leave the running module, quitting it.
Definition: module.cpp:261
void unloadModule()
Unload the module.
Definition: module.cpp:359
void getEntryIFOLocation(Common::UString &area, float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:248
Common::UString _newModule
The module we should change to.
Definition: module.h:180
void movedPC()
Notify the module that the PC was moved.
Definition: module.cpp:472
Unicode string handling.
virtual void enter()
The cursor entered the object.
Definition: object.cpp:159
void changeModule(const Common::UString &module, const Common::UString &entryLocation)
Schedule a change to a new module.
Definition: module.cpp:135
Reference to an NWScript object.
::Engines::Console * _console
Definition: module.h:161
bool _hasModule
Do we have a module?
Definition: module.h:163
ActionQueue _delayedActions
Definition: module.h:186
A class representing an undoable change.
Definition: changeid.h:35
const Aurora::LocString & getName() const
Return the module&#39;s name.
Definition: module.cpp:492
uint32_t uint32
Definition: types.h:204
void load(const Common::UString &module, const Common::UString &entryLocation="")
Load a module.
Definition: module.cpp:91
std::list< Events::Event > EventQueue
Definition: module.h:157
void clear()
Clear the whole context.
Definition: module.cpp:71
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
Definition: module.cpp:505
void exit()
Exit the currently running module.
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:79
static Common::UString findModule(const Common::UString &module, bool relative)
Definition: module.cpp:551
Creature * _pc
The player character we use.
Definition: module.h:173
Common::UString _module
The current module&#39;s name.
Definition: module.h:179
EventQueue _eventQueue
Definition: module.h:185
void movePC(const Common::UString &area)
Move the player character to this area.
Definition: module.cpp:418