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_JADE_MODULE_H
26 #define ENGINES_JADE_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 
38 
39 #include "src/events/types.h"
40 
42 
43 namespace Engines {
44 
45 class Console;
46 
47 namespace Jade {
48 
49 class Area;
50 class Creature;
51 
53 class Module : public Jade::ObjectContainer {
54 public:
55  Module(::Engines::Console &console);
56  ~Module();
57 
59  void clear();
60 
61  // .--- Module management
63  bool isLoaded() const;
65  bool isRunning() const;
66 
68  void load(const Common::UString &module);
70  void usePC(Creature *pc);
72  void exit();
73  // '---
74 
75  // .--- Information about the current module
77  const Common::UString &getName() const;
78  // '---
79 
80  // .--- Elements of the current module
84  Creature *getPC();
85  // '---
86 
87  // .--- Interact with the current module
89  void showMenu();
90  // '---
91 
102  bool startConversation(const Common::UString &conv, Creature &pc,
103  Object &obj, bool noWidescreen = false, bool resetZoom = true);
104  // '---
105 
106  void delayScript(const Common::UString &script,
107  const Aurora::NWScript::ScriptState &state,
109  uint32 delay);
110 
111  // .--- PC management
113  void movePC(float x, float y, float z);
115  void movePC(const Common::UString &module);
117  void movedPC();
118  // '---
119 
120  // .--- Module main loop (called by the Game class)
122  void enter();
124  void leave();
125 
127  void addEvent(const Events::Event &event);
129  void processEventQueue();
130  // '---
131 
132 private:
133  enum ActionType {
136  };
137 
138  struct Action {
140 
142 
146 
148 
149  bool operator<(const Action &s) const;
150  };
151 
152  typedef std::list<Events::Event> EventQueue;
153  typedef std::multiset<Action> ActionQueue;
154 
155 
157 
158  bool _hasModule;
159  bool _running;
160 
162  std::list<Common::ChangeID> _resources;
163 
165 
166  bool _exit;
167 
170 
172 
175 
176 
177  // .--- Unloading
184  void unload(bool completeUnload = true);
185 
186  void unloadPC();
187  void unloadArea();
188  // '---
189 
190  // .--- Loading
191  void load();
192 
193  void loadArea();
194  // '---
195 
197  void loadModule(const Common::UString &module);
199  void changeModule(const Common::UString &module);
201  void replaceModule();
202 
203  void enterArea();
204  void leaveArea();
205 
206  void handleEvents();
207 
208  void handleActions();
209 };
210 
211 } // End of namespace Jade
212 
213 } // End of namespace Engines
214 
215 #endif // ENGINES_JADE_MODULE_H
void movedPC()
Notify the module that the PC was moved.
Definition: module.cpp:322
Basic event types.
void exit()
Exit the currently running module.
Definition: module.cpp:119
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: module.cpp:141
Common::UString _module
The current module&#39;s name.
Definition: module.h:168
bool startConversation(const Common::UString &conv, Creature &pc, Object &obj, bool noWidescreen=false, bool resetZoom=true)
Start a conversation.
Definition: module.cpp:127
A class holding an UTF-8 string.
Definition: ustring.h:48
The global config manager.
Aurora::NWScript::ObjectReference triggerer
Definition: module.h:145
Area * getCurrentArea()
Return the area the PC is currently in.
Definition: module.cpp:338
bool _exit
Should we exit the module?
Definition: module.h:166
Module(::Engines::Console &console)
Definition: module.cpp:50
std::multiset< Action > ActionQueue
Definition: module.h:153
Common::UString _newModule
The module we should change to.
Definition: module.h:169
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: module.h:164
A simple scoped smart pointer template.
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:107
SDL_Event Event
Definition: types.h:42
A container of Jade Empire objects.
::Engines::Console * _console
Definition: module.h:156
void leave()
Leave the running module, quitting it.
Definition: module.cpp:215
Helper class to represent an undoable change.
Common::UString script
Definition: module.h:141
void processEventQueue()
Process the current event queue.
Definition: module.cpp:240
An area in Jade Empire, holding all objects and rooms within, as well as general area properties like...
Definition: area.h:57
void changeModule(const Common::UString &module)
Schedule a change to a new module.
Definition: module.cpp:171
void replaceModule()
Actually replace the currently running module.
Definition: module.cpp:180
void loadModule(const Common::UString &module)
Load the actual module.
Definition: module.cpp:78
void enter()
Enter the loaded module, starting it.
Definition: module.cpp:196
Aurora::NWScript::ScriptState state
Definition: module.h:143
void usePC(Creature *pc)
Use this character as the player character.
Definition: module.cpp:99
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
An object within a Jade area.
Definition: object.h:53
A Jade module.
Definition: module.h:53
Unicode string handling.
Reference to an NWScript object.
An NWScript object.
void showMenu()
Show the ingame main menu.
Definition: module.cpp:123
uint32_t uint32
Definition: types.h:204
void movePC(float x, float y, float z)
Move the player character to this position within the current area.
Definition: module.cpp:307
std::list< Events::Event > EventQueue
Definition: module.h:152
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: module.cpp:236
void clear()
Clear the whole context.
Definition: module.cpp:62
Common::ScopedPtr< Area > _area
The current module&#39;s area.
Definition: module.h:171
const Common::UString & getName() const
Return the module&#39;s name.
Definition: module.cpp:334
Aurora::NWScript::ObjectReference owner
Definition: module.h:144
bool _hasModule
Do we have a module?
Definition: module.h:158
bool isLoaded() const
Is a module currently loaded and ready to run?
Definition: module.cpp:111
bool isRunning() const
Is a module currently running?
Definition: module.cpp:115
bool operator<(const Action &s) const
Definition: module.cpp:45
EventQueue _eventQueue
Definition: module.h:173
bool _running
Are we currently running a module?
Definition: module.h:159
std::list< Common::ChangeID > _resources
Resources added by the current module.
Definition: module.h:162
ActionQueue _delayedActions
Definition: module.h:174
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
Definition: module.cpp:342