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_KOTOR2_MODULE_H
26 #define ENGINES_KOTOR2_MODULE_H
27 
28 #include <list>
29 #include <set>
30 
31 #include "src/common/scopedptr.h"
32 #include "src/common/ustring.h"
33 #include "src/common/changeid.h"
34 #include "src/common/configman.h"
35 
36 #include "src/aurora/ifofile.h"
37 
39 
40 #include "src/events/types.h"
41 
44 
46 
47 namespace Engines {
48 
49 class Console;
50 
51 namespace KotOR2 {
52 
53 class Area;
54 class Creature;
55 class IngameGUI;
56 
58 public:
59  Module(::Engines::Console &console);
60  ~Module();
61 
63  void clear();
64 
65  // .--- Module management
67  bool isLoaded() const;
69  bool isRunning() const;
70 
72  void load(const Common::UString &module, const Common::UString &entryLocation = "",
73  ObjectType entryLocationType = kObjectTypeAll);
75  void usePC(Creature *pc);
77  void exit();
78  // '---
79 
80  // .--- Information about the current module
82  const Aurora::IFOFile &getIFO() const;
83 
85  const Common::UString &getName() const;
86  // '---
87 
88  // .--- Elements of the current module
92  Creature *getPC();
93  // '---
94 
95  // .--- Interact with the current module
97  void showMenu();
98  // '---
99 
100  void delayScript(const Common::UString &script,
101  const Aurora::NWScript::ScriptState &state,
103  uint32 delay);
104 
105  // .--- PC management
107  void movePC(float x, float y, float z);
109  void movePC(const Common::UString &module, const Common::UString &object, ObjectType type = kObjectTypeAll);
111  void movedPC();
112  // '---
113 
114  // .--- Static utility methods
115  static Common::UString getName(const Common::UString &module);
116  // '---
117 
118  // .--- Module main loop (called by the Game class)
120  void enter();
122  void leave();
123 
124  void clickObject(Object *object);
125 
127  void addEvent(const Events::Event &event);
129  void processEventQueue();
130  // '---
131 
132  void toggleFreeRoamCamera();
133  void toggleWalkmesh();
134  void toggleTriggers();
135  void startConversation(const Common::UString &name, Aurora::NWScript::Object *owner = 0);
136 
137  void playAnimationOnActiveObject(const Common::UString &baseAnim,
138  const Common::UString &headAnim);
139 
140 private:
141  enum ActionType {
144  };
145 
146  struct Action {
148 
150 
154 
156 
157  bool operator<(const Action &s) const;
158  };
159 
160  typedef std::list<Events::Event> EventQueue;
161  typedef std::multiset<Action> ActionQueue;
162 
163 
165 
166  bool _hasModule;
167  bool _running;
168 
170  std::list<Common::ChangeID> _resources;
171 
174 
176 
181 
182  bool _exit;
183 
186 
191 
194 
197 
200  float _frameTime;
204  bool _inDialog;
206 
208 
209  // .--- Unloading
216  void unload(bool completeUnload = true);
217 
218  void unloadResources();
219  void unloadPC();
220  void unloadIFO();
221  void unloadArea();
222  void unloadTexturePack();
223  // '---
224 
225  // .--- Loading
226  void load();
227 
228  void loadResources();
229  void loadIFO();
230  void loadArea();
231  void loadTexturePack();
232  // '---
233 
235  void loadModule(const Common::UString &module, const Common::UString &entryLocation,
236  ObjectType entryLocationType);
238  void changeModule(const Common::UString &module, const Common::UString &entryLocation,
239  ObjectType entryLocationType);
241  void replaceModule();
242 
243  bool getObjectLocation(const Common::UString &object, ObjectType location,
244  float &entryX, float &entryY, float &entryZ, float &entryAngle);
245  bool getEntryObjectLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle);
246  void getEntryIFOLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle);
247 
248  void enterArea();
249  void leaveArea();
250 
251  void handleEvents();
252 
253  void handleActions();
254  void handlePCMovement();
255 };
256 
257 } // End of namespace KotOR2
258 
259 } // End of namespace Engines
260 
261 #endif // ENGINES_KOTOR2_MODULE_H
Basic event types.
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: module.cpp:438
Common::ScopedPtr< Area > _area
The current module&#39;s area.
Definition: module.h:192
EventQueue _eventQueue
Definition: module.h:195
Common::UString _newModule
The module we should change to.
Definition: module.h:185
A class holding an UTF-8 string.
Definition: ustring.h:48
The global config manager.
ActionQueue _delayedActions
Definition: module.h:196
bool _exit
Should we exit the module?
Definition: module.h:182
A container of Star Wars: Knights of the Old Republic II - The Sith Lords objects.
Common::UString _module
The current module&#39;s name.
Definition: module.h:184
void movePC(float x, float y, float z)
Move the player character to this position within the current area.
Definition: module.cpp:595
Area * getCurrentArea()
Return the area the PC is currently in.
Definition: module.cpp:643
bool _hasModule
Do we have a module?
Definition: module.h:166
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: module.cpp:240
Conversation/cutscene GUI for Star Wars: Knights of the Old Republic II: The Sith Lords...
bool getEntryObjectLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:390
std::list< Events::Event > EventQueue
Definition: module.h:160
std::multiset< Action > ActionQueue
Definition: module.h:161
A simple scoped smart pointer template.
SDL_Event Event
Definition: types.h:42
bool isRunning() const
Is a module currently running?
Definition: module.cpp:155
void getEntryIFOLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:394
::Engines::Console * _console
Definition: module.h:164
An object in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
Loader for the module.ifo file.
bool _running
Are we currently running a module?
Definition: module.h:167
Helper class to represent an undoable change.
Common::ScopedPtr< Engines::KotOR2::IngameGUI > _ingame
The ingame gui.
Definition: module.h:207
An IFO (module information) file, describing global module properties in many Aurora games...
Definition: ifofile.h:69
std::list< Common::ChangeID > _resources
Resources added by the current module.
Definition: module.h:170
void loadModule(const Common::UString &module, const Common::UString &entryLocation, ObjectType entryLocationType)
Load the actual module.
Definition: module.cpp:117
void movedPC()
Notify the module that the PC was moved.
Definition: module.cpp:615
Aurora::IFOFile _ifo
The current module&#39;s IFO.
Definition: module.h:173
ObjectType _entryLocationType
The type(s) of the object in the start location for this module.
Definition: module.h:190
void enter()
Enter the loaded module, starting it.
Definition: module.cpp:318
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:147
const Aurora::IFOFile & getIFO() const
Return the IFO of the currently loaded module.
Definition: module.cpp:635
bool getObjectLocation(const Common::UString &object, ObjectType location, float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:363
void changeModule(const Common::UString &module, const Common::UString &entryLocation, ObjectType entryLocationType)
Schedule a change to a new module.
Definition: module.cpp:291
void usePC(Creature *pc)
Use this character as the player character.
Definition: module.cpp:143
void processEventQueue()
Process the current event queue.
Definition: module.cpp:442
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: module.h:175
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Common::UString _entryLocation
The tag of the object in the start location for this module.
Definition: module.h:188
void replaceModule()
Actually replace the currently running module.
Definition: module.cpp:300
Aurora::NWScript::ScriptState state
Definition: module.h:151
Unicode string handling.
Reference to an NWScript object.
void clear()
Clear the whole context.
Definition: module.cpp:99
void showMenu()
Show the ingame main menu.
Definition: module.cpp:163
Aurora::NWScript::ObjectReference owner
Definition: module.h:152
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:33
A class representing an undoable change.
Definition: changeid.h:35
Module(::Engines::Console &console)
Definition: module.cpp:70
uint32_t uint32
Definition: types.h:204
float _backwardsBtnPressed
Definition: module.h:202
bool isLoaded() const
Is a module currently loaded and ready to run?
Definition: module.cpp:151
Common::UString script
Definition: module.h:149
const Common::UString & getName() const
Return the module&#39;s name.
Definition: module.cpp:639
Common::ChangeID _textures
Resources added by the current texture pack.
Definition: module.h:180
void exit()
Exit the currently running module.
Definition: module.cpp:159
void clickObject(Object *object)
Definition: module.cpp:412
Aurora::NWScript::ObjectReference triggerer
Definition: module.h:153
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
Definition: module.cpp:647
bool operator<(const Action &s) const
Definition: module.cpp:65
void leave()
Leave the running module, quitting it.
Definition: module.cpp:403
void playAnimationOnActiveObject(const Common::UString &baseAnim, const Common::UString &headAnim)
Definition: module.cpp:740
Common::ScopedPtr< DialogGUI > _dialog
Conversation/cutscene GUI.
Definition: module.h:193
An area in Star Wars: Knights of the Old Republic II - The Sith Lords, holding all objects and rooms ...
Definition: area.h:64
int _currentTexturePack
The current texture pack.
Definition: module.h:178
void startConversation(const Common::UString &name, Aurora::NWScript::Object *owner=0)
Definition: module.cpp:713