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_NWN_MODULE_H
26 #define ENGINES_NWN_MODULE_H
27 
28 #include <list>
29 #include <map>
30 #include <set>
31 
32 #include "src/common/scopedptr.h"
33 #include "src/common/ptrmap.h"
34 #include "src/common/ustring.h"
35 #include "src/common/changeid.h"
36 
37 #include "src/aurora/ifofile.h"
38 
40 
42 
43 #include "src/events/types.h"
44 
46 
48 #include "src/engines/nwn/object.h"
49 
50 namespace Engines {
51 
52 class Console;
53 
54 namespace NWN {
55 
56 class Version;
57 
58 class Area;
59 class Creature;
60 
61 class IngameGUI;
62 
63 class Module : public NWN::Object, public NWN::ObjectContainer {
64 public:
65  Module(::Engines::Console &console, const Version &gameVersion);
66  ~Module();
67 
68  const Version &getGameVersion() const;
69 
71  void clear();
72 
73  // .--- Module management
75  bool isLoaded() const;
77  bool isRunning() const;
78 
80  void load(const Common::UString &module);
82  void usePC(const Common::UString &bic, bool local);
83  void usePC(Creature *creature);
85  void exit();
86  // '---
87 
88  // .--- Information about the current module
90  const Aurora::IFOFile &getIFO() const;
91  // '---
92 
93  // .--- Elements of the current module
97  Creature *getPC();
98  // '---
99 
100  // .--- Interact with the current module
102  void showMenu();
103 
113  bool startConversation(const Common::UString &conv, Creature &pc,
114  NWN::Object &obj, bool playHello = true);
115  // '---
116 
117  void delayScript(const Common::UString &script,
118  const Aurora::NWScript::ScriptState &state,
120  uint32 delay);
121 
122  // .--- PC management
124  void movePC(const Common::UString &area);
126  void movePC(float x, float y, float z);
128  void movePC(const Common::UString &area, float x, float y, float z);
130  void movePC(Area *area, float x, float y, float z);
132  void movedPC();
133  // '---
134 
135  // .--- Static utility methods
136  static Common::UString getDescription(const Common::UString &module);
137  // '---
138 
139  // .--- Module main loop (called by the Game class)
141  void enter();
143  void leave();
144 
146  void addEvent(const Events::Event &event);
148  void processEventQueue();
149  // '---
150 
151 private:
152  enum ActionType {
155  };
156 
157  struct Action {
159 
161 
165 
167 
168  bool operator<(const Action &s) const;
169  };
170 
172 
173  typedef std::list<Events::Event> EventQueue;
174  typedef std::multiset<Action> ActionQueue;
175 
176 
178 
180 
181  bool _hasModule;
182  bool _running;
183 
185 
190 
193 
195 
197 
198  // Texture pack
201 
202  bool _exit;
203 
207 
209 
212 
213 
214  // .--- Unloading
221  void unload(bool completeUnload = true);
222 
223  void unloadModule();
224  void unloadPC();
225  void unloadTLK();
226  void unloadHAKs();
227  void unloadTexturePack();
228  void unloadAreas();
229  // '---
230 
231  // .--- Loading
233  void preparePremiumModule(const Common::UString &module);
234 
235  void checkXPs();
236  void checkHAKs();
237 
238  void loadTLK();
239  void loadHAKs();
240  void loadTexturePack();
241  void loadAreas();
242  // '---
243 
246 
247  void setPCTokens();
248  void removePCTokens();
249 
250  void enterArea();
251 
253  void loadModule(const Common::UString &module);
255  void changeModule(const Common::UString &module);
257  void replaceModule();
258 
259  void handleEvents();
260 
261  void handleActions();
262 };
263 
264 } // End of namespace NWN
265 
266 } // End of namespace Engines
267 
268 #endif // ENGINES_NWN_MODULE_H
Basic event types.
void checkHAKs()
Do we have all HAKs needed for the module?
Definition: module.cpp:209
AreaMap _areas
The areas in the current module.
Definition: module.h:204
void showMenu()
Show the ingame main menu.
Definition: module.cpp:671
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:298
void preparePremiumModule(const Common::UString &module)
Check if this is premium module, and if so, prepare its loading.
Definition: module.cpp:140
Generic Aurora engines resource utility functions.
void unloadAreas()
Unload the areas.
Definition: module.cpp:662
A container of Neverwinter Nights objects.
A map storing pointer to objects, with automatic deletion.
A class holding an UTF-8 string.
Definition: ustring.h:48
void replaceModule()
Actually replace the currently running module.
Definition: module.cpp:306
void changeModule(const Common::UString &module)
Schedule a change to a new module.
Definition: module.cpp:302
void enterArea()
Enter a new area.
Definition: module.cpp:397
bool _exit
Should we exit the module?
Definition: module.h:202
void unloadHAKs()
Unload the HAKs required by the module.
Definition: module.cpp:599
void loadTLK()
Load the TLK used by the module.
Definition: module.cpp:581
Common::PtrMap< Common::UString, Area > AreaMap
Definition: module.h:171
Aurora::NWScript::ObjectReference owner
Definition: module.h:163
void unloadTLK()
Unload the TLK used by the module.
Definition: module.cpp:588
void loadHAKs()
Load the HAKs required by the module.
Definition: module.cpp:592
void movePC(const Common::UString &area)
Move the player character to this area.
Definition: module.cpp:689
const Common::UString & getDescription() const
Return the object&#39;s description.
Definition: object.cpp:94
void clear()
Clear the whole context.
Definition: module.cpp:123
const Version & getGameVersion() const
Definition: module.cpp:119
void exit()
Exit the currently running module.
Definition: module.cpp:440
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
bool _running
Are we currently running a module?
Definition: module.h:182
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
Definition: module.cpp:756
EventQueue _eventQueue
Definition: module.h:210
A simple scoped smart pointer template.
std::list< Common::ChangeID > ChangeList
Definition: resources.h:41
SDL_Event Event
Definition: types.h:42
ChangeList _resHAKs
Resources added by the HAKs of the module.
Definition: module.h:192
Aurora::NWScript::ObjectReference triggerer
Definition: module.h:164
Common::ChangeID _resModule
Resources added by the module.
Definition: module.h:187
void loadTexturePack()
Load the texture pack.
Definition: module.cpp:610
std::list< Events::Event > EventQueue
Definition: module.h:173
void load(const Common::UString &module)
Load a module.
Definition: module.cpp:127
Common::ScopedPtr< IngameGUI > _ingameGUI
The ingame GUI elements.
Definition: module.h:184
Loader for the module.ifo file.
ActionQueue _delayedActions
Definition: module.h:211
Common::ChangeID _resTP[4]
Definition: module.h:200
Basic Aurora graphics types.
void enter()
Enter the loaded module, starting it.
Definition: module.cpp:322
Helper class to represent an undoable change.
An IFO (module information) file, describing global module properties in many Aurora games...
Definition: ifofile.h:69
Area * getCurrentArea()
Return the area the PC is currently in.
Definition: module.cpp:752
const Aurora::IFOFile & getIFO() const
Return the IFO of the currently loaded module.
Definition: module.cpp:748
bool operator<(const Action &s) const
Definition: module.cpp:100
bool isLoaded() const
Is a module currently loaded and ready to run?
Definition: module.cpp:446
void loadModule(const Common::UString &module)
Load the actual module.
Definition: module.cpp:162
bool isRunning() const
Is a module currently running?
Definition: module.cpp:450
Area * _currentArea
The current area.
Definition: module.h:206
Aurora::IFOFile _ifo
The module&#39;s IFO.
Definition: module.h:194
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Common::UString _newArea
The new area to enter.
Definition: module.h:205
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: module.h:196
Module(::Engines::Console &console, const Version &gameVersion)
Definition: module.cpp:105
Common::UString script
Definition: module.h:160
void usePC(const Common::UString &bic, bool local)
Use this character as the player character.
Definition: module.cpp:268
Unicode string handling.
An object in a Neverwinter Nights area.
void loadAreas()
Load the areas.
Definition: module.cpp:640
Reference to an NWScript object.
bool _hasModule
Do we have a module?
Definition: module.h:181
void unloadModule()
Unload the module.
Definition: module.cpp:548
static Common::UString getDescriptionCampaign(Common::UString module)
Definition: module.cpp:787
std::multiset< Action > ActionQueue
Definition: module.h:174
A class representing an undoable change.
Definition: changeid.h:35
static Common::UString getDescriptionExtra(Common::UString module)
Definition: module.cpp:772
uint32_t uint32
Definition: types.h:204
void processEventQueue()
Process the current event queue.
Definition: module.cpp:458
Common::UString _newModule
The module we should change to.
Definition: module.h:208
bool startConversation(const Common::UString &conv, Creature &pc, NWN::Object &obj, bool playHello=true)
Start a conversation.
Definition: module.cpp:683
Common::ChangeID _resTLK
Resources added for the custom TLK.
Definition: module.h:189
void checkXPs()
Do we have all expansions needed for the module?
Definition: module.cpp:195
void unloadPC()
Unload the PC.
Definition: module.cpp:570
Aurora::NWScript::ScriptState state
Definition: module.h:162
void leave()
Leave the running module, quitting it.
Definition: module.cpp:389
void movedPC()
Notify the module that the PC was moved.
Definition: module.cpp:729
::Engines::Console * _console
Definition: module.h:177
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: module.cpp:454
const Version * _gameVersion
Definition: module.h:179
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: module.cpp:533
void unloadTexturePack()
Unload the texture pack.
Definition: module.cpp:633