xoreos  0.0.5
module.cpp
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 #include "src/common/scopedptr.h"
26 #include "src/common/util.h"
27 #include "src/common/maths.h"
28 #include "src/common/error.h"
29 #include "src/common/ustring.h"
30 #include "src/common/readfile.h"
31 #include "src/common/filepath.h"
32 #include "src/common/filelist.h"
33 #include "src/common/configman.h"
34 
35 #include "src/aurora/types.h"
36 #include "src/aurora/rimfile.h"
37 #include "src/aurora/gff3file.h"
38 #include "src/aurora/dlgfile.h"
39 
40 #include "src/graphics/camera.h"
41 #include "src/graphics/graphics.h"
42 
45 
46 #include "src/events/events.h"
47 
53 
58 
59 namespace Engines {
60 
61 namespace KotOR2 {
62 
63 static const float kPCMovementSpeed = 5;
64 
65 bool Module::Action::operator<(const Action &s) const {
66  return timestamp < s.timestamp;
67 }
68 
69 
72  _console(&console),
73  _hasModule(false),
74  _running(false),
76  _exit(false),
78  _dialog(new DialogGUI(*this)),
79  _freeCamEnabled(false),
80  _prevTimestamp(0),
81  _frameTime(0),
82  _forwardBtnPressed(false),
83  _backwardsBtnPressed(false),
84  _pcRunning(false),
85  _inDialog(false),
86  _cameraHeight(0.0f),
87  _ingame(new IngameGUI(*this, _console)) {
88 
90 }
91 
93  try {
94  clear();
95  } catch (...) {
96  }
97 }
98 
99 void Module::clear() {
100  unload(true);
101 }
102 
103 void Module::load(const Common::UString &module, const Common::UString &entryLocation,
104  ObjectType entryLocationType) {
105 
106  if (isRunning()) {
107  // We are currently running a module. Schedule a safe change instead
108 
109  changeModule(module, entryLocation, entryLocationType);
110  return;
111  }
112 
113  // We are not currently running a module. Directly load the new module
114  loadModule(module, entryLocation, entryLocationType);
115 }
116 
117 void Module::loadModule(const Common::UString &module, const Common::UString &entryLocation,
118  ObjectType entryLocationType) {
119 
120  unload(false);
121 
122  _module = module;
123 
124  _entryLocation = entryLocation;
125  _entryLocationType = entryLocationType;
126 
127  try {
128 
129  load();
130 
131  } catch (Common::Exception &e) {
132  _module.clear();
133 
134  e.add("Failed loading module \"%s\"", module.c_str());
135  throw e;
136  }
137 
138  _newModule.clear();
139 
140  _hasModule = true;
141 }
142 
144  _pc.reset(pc);
145 }
146 
148  return _pc.get();
149 }
150 
151 bool Module::isLoaded() const {
152  return _hasModule && _area && _pc;
153 }
154 
155 bool Module::isRunning() const {
156  return !EventMan.quitRequested() && _running && !_exit;
157 }
158 
159 void Module::exit() {
160  _exit = true;
161 }
162 
164  // TODO: Module::showMenu()
165 }
166 
167 void Module::load() {
168  loadTexturePack();
169  loadResources();
170  loadIFO();
171  loadArea();
172 }
173 
175  // Add all available resource files for the module.
176  // Apparently, the original game prefers ERFs over RIMs. This is
177  // exploited by the KotOR2 TSL Restored Content Mod.
178 
179  // General module resources
180  _resources.push_back(Common::ChangeID());
181  if (!indexOptionalArchive (_module + ".erf", 1000, &_resources.back()))
182  indexMandatoryArchive(_module + ".rim", 1000, &_resources.back());
183 
184  // Scripts
185  _resources.push_back(Common::ChangeID());
186  if (!indexOptionalArchive (_module + "_s.erf", 1001, &_resources.back()))
187  indexMandatoryArchive(_module + "_s.rim", 1001, &_resources.back());
188 
189  // Dialogs, KotOR2 only
190  _resources.push_back(Common::ChangeID());
191  if (!indexOptionalArchive(_module + "_dlg.erf", 1002, &_resources.back()))
192  indexOptionalArchive(_module + "_dlg.rim", 1002, &_resources.back());
193 
194  // Layouts, Xbox only
195  _resources.push_back(Common::ChangeID());
196  indexOptionalArchive(_module + "_a.rim" , 1003, &_resources.back());
197 
198  // Textures, Xbox only
199  _resources.push_back(Common::ChangeID());
200  indexOptionalArchive(_module + "_adx.rim", 1004, &_resources.back());
201 }
202 
204  _ifo.load();
205 
206  _tag = _ifo.getTag();
207  _name = _ifo.getName().getString();
208 
209  readScripts(*_ifo.getGFF());
210 }
211 
213  _area.reset(new Area(*this, _ifo.getEntryArea()));
214 }
215 
216 static const char * const texturePacks[3] = {
217  "swpc_tex_tpc.erf", // Worst
218  "swpc_tex_tpb.erf", // Medium
219  "swpc_tex_tpa.erf" // Best
220 };
221 
223  int level = ConfigMan.getInt("texturepack", 2);
224  if (_currentTexturePack == level)
225  // Nothing to do
226  return;
227 
229 
230  status("Loading texture pack %d", level);
232 
233  // If we already had a texture pack loaded, reload all textures
234  if (_currentTexturePack != -1)
235  TextureMan.reloadAll();
236 
237  _currentTexturePack = level;
238 }
239 
240 void Module::unload(bool completeUnload) {
241  GfxMan.pauseAnimations();
242 
243  leaveArea();
244  unloadArea();
245 
246  if (completeUnload) {
247  unloadPC();
249  }
250 
251  unloadIFO();
252  unloadResources();
253 
254  _eventQueue.clear();
255  _delayedActions.clear();
256 
257  _newModule.clear();
258  _hasModule = false;
259 
260  _module.clear();
261 
264 }
265 
267  std::list<Common::ChangeID>::reverse_iterator r;
268  for (r = _resources.rbegin(); r != _resources.rend(); ++r)
269  deindexResources(*r);
270 
271  _resources.clear();
272 }
273 
275  _ifo.unload();
276 }
277 
279  _area.reset();
280 }
281 
283  _pc.reset();
284 }
285 
288  _currentTexturePack = -1;
289 }
290 
291 void Module::changeModule(const Common::UString &module, const Common::UString &entryLocation,
292  ObjectType entryLocationType) {
293 
294  _newModule = module;
295 
296  _entryLocation = entryLocation;
297  _entryLocationType = entryLocationType;
298 }
299 
301  if (_newModule.empty())
302  return;
303 
304  _console->hide();
305 
306  const Common::UString newModule = _newModule;
307  const Common::UString entryLocation = _entryLocation;
308  const ObjectType entryLocationType = _entryLocationType;
309 
310  unload(false);
311 
312  _exit = true;
313 
314  loadModule(newModule, entryLocation, entryLocationType);
315  enter();
316 }
317 
319  if (!_hasModule)
320  throw Common::Exception("Module::enter(): Lacking a module?!?");
321 
322  if (!_pc)
323  throw Common::Exception("Module::enter(): Lacking a PC?!?");
324 
325  _console->printf("Entering module \"%s\"", _name.c_str());
326 
327  Common::UString startMovie = _ifo.getStartMovie();
328  if (!startMovie.empty())
329  playVideo(startMovie);
330 
331  float entryX, entryY, entryZ, entryAngle;
332  if (!getEntryObjectLocation(entryX, entryY, entryZ, entryAngle))
333  getEntryIFOLocation(entryX, entryY, entryZ, entryAngle);
334 
335  if (_pc) {
336  _pc->setPosition(entryX, entryY, entryZ);
337  _pc->show();
338  }
339 
340  _cameraHeight = _pc->getCameraHeight();
341 
342  float cameraDistance, cameraPitch, cameraHeight;
343  _area->getCameraStyle(cameraDistance, cameraPitch, cameraHeight);
344 
345  SatelliteCam.setTarget(entryX, entryY, entryZ + _cameraHeight);
346  SatelliteCam.setDistance(cameraDistance);
347  SatelliteCam.setPitch(cameraPitch);
348  SatelliteCam.setHeight(cameraHeight);
349  SatelliteCam.update(0);
350 
351  _ingame->show();
352 
353  enterArea();
354 
355  _area->notifyPCMoved();
356 
357  GfxMan.resumeAnimations();
358 
359  _running = true;
360  _exit = false;
361 }
362 
364  float &entryX, float &entryY, float &entryZ, float &entryAngle) {
365 
366  if (object.empty())
367  return false;
368 
370 
371 
372  KotOR2::Object *kotorObject = 0;
373  while (!kotorObject && search->get()) {
374  kotorObject = KotOR2::ObjectContainer::toObject(search->next());
375  if (!kotorObject || !(kotorObject->getType() & location))
376  kotorObject = 0;
377  }
378 
379  if (!kotorObject)
380  return false;
381 
382  // TODO: Entry orientation
383 
384  kotorObject->getPosition(entryX, entryY, entryZ);
385  entryAngle = 0.0f;
386 
387  return true;
388 }
389 
390 bool Module::getEntryObjectLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle) {
391  return getObjectLocation(_entryLocation, _entryLocationType, entryX, entryY, entryZ, entryAngle);
392 }
393 
394 void Module::getEntryIFOLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle) {
395  _ifo.getEntryPosition(entryX, entryY, entryZ);
396 
397  float entryDirX, entryDirY;
398  _ifo.getEntryDirection(entryDirX, entryDirY);
399 
400  entryAngle = -Common::rad2deg(atan2(entryDirX, entryDirY));
401 }
402 
404  _ingame->hide();
405 
406  leaveArea();
407 
408  _running = false;
409  _exit = true;
410 }
411 
413  Creature *creature = ObjectContainer::toCreature(object);
414  if (creature && !creature->getConversation().empty())
415  startConversation(creature->getConversation(), creature);
416 }
417 
419  _area->show();
420 
421  runScript(kScriptModuleLoad , this, _pc.get());
422  runScript(kScriptModuleStart, this, _pc.get());
423  runScript(kScriptEnter , this, _pc.get());
424 
425  _area->runScript(kScriptEnter, _area.get(), _pc.get());
426 }
427 
429  if (_area) {
430  _area->runScript(kScriptExit, _area.get(), _pc.get());
431 
432  _area->hide();
433  }
434 
435  runScript(kScriptExit, this, _pc.get());
436 }
437 
438 void Module::addEvent(const Events::Event &event) {
439  _eventQueue.push_back(event);
440 }
441 
443  if (!isRunning())
444  return;
445 
446  replaceModule();
447 
448  if (!isRunning())
449  return;
450 
451  uint32 now = SDL_GetTicks();
452  _frameTime = (now - _prevTimestamp) / 1000.f;
453  _prevTimestamp = now;
454 
455  handleEvents();
456  handleActions();
457 
458  if (!_freeCamEnabled) {
459  GfxMan.lockFrame();
461  SatelliteCam.update(_frameTime);
462  GfxMan.unlockFrame();
463  }
464 }
465 
467  for (EventQueue::const_iterator event = _eventQueue.begin(); event != _eventQueue.end(); ++event) {
468  // Handle console
469  if (_console->isVisible()) {
470  _console->processEvent(*event);
471  continue;
472  }
473 
474  if (event->type == Events::kEventKeyDown) {
475  // Menu
476  if (event->key.keysym.sym == SDLK_ESCAPE) {
477  showMenu();
478  continue;
479  }
480 
481  // Console
482  if ((event->key.keysym.sym == SDLK_d) && (event->key.keysym.mod & KMOD_CTRL)) {
483  _console->show();
484  continue;
485  }
486  }
487 
488  // Conversation/cutscene
489  if (_inDialog) {
490  _dialog->addEvent(*event);
491  continue;
492  }
493 
494  // PC movement
495  switch (event->type) {
497  case Events::kEventKeyUp:
498  if (event->key.keysym.scancode == SDL_SCANCODE_W) {
499  _forwardBtnPressed = event->type == Events::kEventKeyDown;
500  } else if (event->key.keysym.scancode == SDL_SCANCODE_S) {
502  }
503  break;
504  }
505 
506  // Camera
507  if (!_console->isVisible()) {
508  if (_freeCamEnabled) {
509  if (FreeRoamCam.handleCameraInput(*event))
510  continue;
511  } else if (SatelliteCam.handleCameraInput(*event))
512  continue;
513  }
514 
515  _area->addEvent(*event);
516  _ingame->addEvent(*event);
517  }
518 
519  _eventQueue.clear();
520 
521  if (_freeCamEnabled)
522  CameraMan.update();
523 
524  _area->processEventQueue();
525  _dialog->processEventQueue();
526  _ingame->processEventQueue();
527 
528  if (_inDialog && !_dialog->isConversationActive()) {
529  _dialog->hide();
530  _ingame->show();
531  _inDialog = false;
532  }
533 }
534 
536  uint32 now = EventMan.getTimestamp();
537 
538  while (!_delayedActions.empty()) {
539  ActionQueue::iterator action = _delayedActions.begin();
540 
541  if (now < action->timestamp)
542  break;
543 
544  if (action->type == kActionScript)
545  ScriptContainer::runScript(action->script, action->state,
546  action->owner, action->triggerer);
547 
548  _delayedActions.erase(action);
549  }
550 }
551 
553  if (!_pc)
554  return;
555 
556  bool haveMovement = false;
557 
559  float x, y, z;
560  _pc->getPosition(x, y, z);
561  float yaw = SatelliteCam.getYaw();
562  float newX, newY;
563 
565  _pc->setOrientation(0, 0, 1, Common::rad2deg(yaw));
566  newX = x - kPCMovementSpeed * sin(yaw) * _frameTime;
567  newY = y + kPCMovementSpeed * cos(yaw) * _frameTime;
568  haveMovement = true;
569  } else if (_backwardsBtnPressed && !_forwardBtnPressed) {
570  _pc->setOrientation(0, 0, 1, 180 + Common::rad2deg(yaw));
571  newX = x + kPCMovementSpeed * sin(yaw) * _frameTime;
572  newY = y - kPCMovementSpeed * cos(yaw) * _frameTime;
573  haveMovement = true;
574  }
575 
576  if (haveMovement) {
577  z = _area->evaluateElevation(newX, newY);
578  if (z != FLT_MIN) {
579  if (!_area->testCollision(glm::vec3(x, y, z + 0.1f),
580  glm::vec3(newX, newY, z + 0.1f)))
581  movePC(newX, newY, z);
582  }
583  }
584  }
585 
586  if (haveMovement && !_pcRunning) {
587  _pc->playAnimation(Common::UString("run"), false, -1);
588  _pcRunning = true;
589  } else if (!haveMovement && _pcRunning) {
590  _pc->playDefaultAnimation();
591  _pcRunning = false;
592  }
593 }
594 
595 void Module::movePC(float x, float y, float z) {
596  if (!_pc)
597  return;
598 
599  _pc->setPosition(x, y, z);
600  movedPC();
601 }
602 
603 void Module::movePC(const Common::UString &module, const Common::UString &object, ObjectType type) {
604  if (module.empty() || (module == _module)) {
605  float x, y, z, angle;
606  if (getObjectLocation(object, type, x, y, z, angle))
607  movePC(x, y, z);
608 
609  return;
610  }
611 
612  load(module, object, type);
613 }
614 
616  if (!_pc)
617  return;
618 
619  float x, y, z;
620  _pc->getPosition(x, y, z);
621 
622  SatelliteCam.setTarget(x, y, z + _cameraHeight);
623 
624  if (_freeCamEnabled) {
625  CameraMan.setPosition(x, y, z + _cameraHeight);
626  CameraMan.update();
627  }
628 
629  _area->evaluateTriggers(x, y);
630 
631  if (!_freeCamEnabled)
632  _area->notifyPCMoved();
633 }
634 
636  return _ifo;
637 }
638 
640  return KotOR2::Object::getName();
641 }
642 
644  return _area.get();
645 }
646 
648  const Aurora::NWScript::ScriptState &state,
650  Aurora::NWScript::Object *triggerer, uint32 delay) {
651  Action action;
652 
653  action.type = kActionScript;
654  action.script = script;
655  action.state = state;
656  action.owner = owner;
657  action.triggerer = triggerer;
658  action.timestamp = EventMan.getTimestamp() + delay;
659 
660  _delayedActions.insert(action);
661 }
662 
664  /* Return the localized name of the first (and only) area of the module,
665  * which is the closest thing to the name of the module.
666  *
667  * To do that, if looks through the module directory for a matching RIM file
668  * (case-insensitively) and opens it without indexing into the ResourceManager.
669  * It then opens the module.ifo, grabs the name of the area, opens its ARE file
670  * and returns the localized "Name" field.
671  *
672  * If there's any error while doing all this, an empty string is returned.
673  */
674 
675  try {
676  const Common::FileList modules(ConfigMan.getString("KOTOR2_moduleDir"));
677 
678  const Aurora::RIMFile rim(new Common::ReadFile(modules.findFirst(module + ".rim", true)));
679  const uint32 ifoIndex = rim.findResource("module", Aurora::kFileTypeIFO);
680 
681  const Aurora::GFF3File ifo(rim.getResource(ifoIndex), MKTAG('I', 'F', 'O', ' '));
682 
683  const Aurora::GFF3List &areas = ifo.getTopLevel().getList("Mod_Area_list");
684  if (areas.empty())
685  return "";
686 
687  const uint32 areIndex = rim.findResource((*areas.begin())->getString("Area_Name"), Aurora::kFileTypeARE);
688 
689  const Aurora::GFF3File are(rim.getResource(areIndex), MKTAG('A', 'R', 'E', ' '));
690 
691  return are.getTopLevel().getString("Name");
692 
693  } catch (...) {
694  }
695 
696  return "";
697 }
698 
701  if (_freeCamEnabled && ConfigMan.getBool("flycamallrooms", true))
702  _area->showAllRooms();
703 }
704 
706  _area->toggleWalkmesh();
707 }
708 
710  _area->toggleTriggers();
711 }
712 
714  if (_inDialog)
715  return;
716 
717  Common::UString finalName(name);
718 
719  if (finalName.empty() && owner) {
720  Creature *creature = ObjectContainer::toCreature(owner);
721  if (creature)
722  finalName = creature->getConversation();
723  }
724 
725  if (finalName.empty())
726  return;
727 
728  _dialog->startConversation(finalName, owner);
729 
730  if (_dialog->isConversationActive()) {
731  _ingame->hide();
732  _forwardBtnPressed = false;
733  _backwardsBtnPressed = false;
734  SatelliteCam.clearInput();
735  _dialog->show();
736  _inDialog = true;
737  }
738 }
739 
741  const Common::UString &headAnim) {
742  KotOR2::Object *o = _area->getActiveObject();
743  if (!o)
744  return;
745 
746  o->playAnimation(baseAnim, true, -1.0f);
747 
748  Creature *creature = ObjectContainer::toCreature(o);
749  if (creature) {
750  if (headAnim.empty())
751  creature->playDefaultHeadAnimation();
752  else
753  creature->playHeadAnimation(headAnim, true, -1.0f, 0.5f);
754  }
755 }
756 
757 } // End of namespace KotOR2
758 
759 } // End of namespace Engines
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
void playVideo(const Common::UString &video)
Play this video resource.
Definition: util.cpp:54
Generic Aurora engines resource utility functions.
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: module.cpp:438
void add(const char *s,...) GCC_PRINTF(2
Definition: error.cpp:58
bool isVisible() const
Definition: console.cpp:797
A creature in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
The global graphics manager.
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:107
Common::ScopedPtr< Area > _area
The current module&#39;s area.
Definition: module.h:192
virtual Object * next()=0
Move to the next object in the search context and return the previous one.
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
Fake value for a module object.
Definition: types.h:51
#define TextureMan
Shortcut for accessing the texture manager.
Definition: textureman.h:127
The global config manager.
virtual void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: object.cpp:177
ActionQueue _delayedActions
Definition: module.h:196
Handling BioWare&#39;s RIMs (resource archives).
void unload()
Unload a currently loaded IFO.
Definition: ifofile.cpp:97
bool _exit
Should we exit the module?
Definition: module.h:182
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
bool indexOptionalArchive(const Common::UString &file, uint32 priority, const std::vector< byte > &password, Common::ChangeID *changeID)
Definition: resources.cpp:69
Area * getCurrentArea()
Return the area the PC is currently in.
Definition: module.cpp:643
The Aurora texture manager.
Mathematical helpers.
Camera management.
A simple streaming file reading class.
Definition: readfile.h:40
static const char *const texturePacks[3]
Definition: module.cpp:216
Engine utility class for camera handling where camera rotates around PC.
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
bool _hasModule
Do we have a module?
Definition: module.h:166
void getEntryDirection(float &x, float &y) const
Return the entry direction.
Definition: ifofile.cpp:302
void unload(bool completeUnload=true)
Unload the whole shebang.
Definition: module.cpp:240
bool getEntryObjectLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:390
The context holding a Star Wars: Knights of the Old Republic II - The Sith Lords area.
The ingame GUI.
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
Definition: locstring.cpp:82
Exception that provides a stack of explanations.
Definition: error.h:36
#define FreeRoamCam
A simple scoped smart pointer template.
SDL_Event Event
Definition: types.h:42
void deindexResources(Common::ChangeID &changeID)
Remove previously added resources from the ResourceManager.
Definition: resources.cpp:164
bool isRunning() const
Is a module currently running?
Definition: module.cpp:155
Keyboard key was pressed.
Definition: types.h:46
void getEntryIFOLocation(float &entryX, float &entryY, float &entryZ, float &entryAngle)
Definition: module.cpp:394
::Engines::Console * _console
Definition: module.h:164
Basic exceptions to throw.
void load(Common::SeekableReadStream *stream, bool repairNWNPremium=false)
Take over this stream and load an IFO out of it.
Definition: ifofile.cpp:101
void indexMandatoryArchive(const Common::UString &file, uint32 priority, const std::vector< byte > &password, Common::ChangeID *changeID)
Definition: resources.cpp:36
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
void playHeadAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: creature.cpp:354
static const float kPCMovementSpeed
Definition: module.cpp:63
bool _running
Are we currently running a module?
Definition: module.h:167
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
Common::UString _name
The object&#39;s display name.
Definition: object.h:129
Utility templates and functions.
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
The global events manager.
Aurora::IFOFile _ifo
The current module&#39;s IFO.
Definition: module.h:173
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:150
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
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
A 3D model of an object.
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
ObjectSearch * findObjectsByTag(const Common::UString &tag) const
Return a search context to iterate over all objects with this tag.
Common::ScopedPtr< Creature > _pc
The player character we use.
Definition: module.h:175
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
Generic Aurora engines (debug) console.
StackException Exception
Definition: error.h:59
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
const Common::UString & getConversation() const
Definition: creature.cpp:310
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
Module information, GFF.
Definition: types.h:83
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Aurora::NWScript::ScriptState state
Definition: module.h:151
The context needed to run a Star Wars: Knights of the Old Republic II - The Sith Lords module...
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
Implementing the stream reading interfaces for files.
Unicode string handling.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
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 getType() const
Return the exact type of the object.
Definition: object.cpp:61
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:33
static KotOR2::Object * toObject(::Aurora::NWScript::Object *object)
A class representing an undoable change.
Definition: changeid.h:35
Module(::Engines::Console &console)
Definition: module.cpp:70
const GFF3Struct * getGFF() const
Return the IFO&#39;s GFF struct.
Definition: ifofile.cpp:244
uint32_t uint32
Definition: types.h:204
A list of files.
Definition: filelist.h:35
const LocString & getName() const
Return the name of the module.
Definition: ifofile.cpp:267
Common::UString _tag
Definition: object.h:56
Static area data, GFF.
Definition: types.h:81
float _backwardsBtnPressed
Definition: module.h:202
bool isLoaded() const
Is a module currently loaded and ready to run?
Definition: module.cpp:151
void status(const char *s,...)
Definition: util.cpp:52
void printf(const char *s,...) GCC_PRINTF(2
Definition: console.cpp:1093
#define FLT_MIN
Definition: maths.h:43
bool processEvent(const Events::Event &event)
Definition: console.cpp:817
#define CameraMan
Shortcut for accessing the camera manager.
Definition: camera.h:83
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
Common::UString script
Definition: module.h:149
Class to hold resource data of a RIM archive file.
Definition: rimfile.h:61
static float rad2deg(float rad)
Definition: maths.h:93
Generic Aurora engines utility functions.
void readScripts(const Aurora::GFF3Struct &gff)
Definition: container.cpp:134
A list of files.
const Common::UString & getName() const
Return the module&#39;s name.
Definition: module.cpp:639
const Common::UString & getTag() const
Return the module&#39;s tag.
Definition: ifofile.cpp:263
void getEntryPosition(float &x, float &y, float &z) const
Return the entry position.
Definition: ifofile.cpp:296
const Common::UString & getEntryArea() const
Return the entry area.
Definition: ifofile.cpp:292
Common::ChangeID _textures
Resources added by the current texture pack.
Definition: module.h:180
Keyboard key was released.
Definition: types.h:47
Engine utility class for free-roam camera handling.
#define SatelliteCam
Handling BioWare&#39;s DLGs (dialog / conversation files).
virtual Object * get()=0
Return the current object in the search context.
void clear()
Clear the string&#39;s contents.
Definition: ustring.cpp:236
void exit()
Exit the currently running module.
Definition: module.cpp:159
void clickObject(Object *object)
Definition: module.cpp:412
const Common::UString & getStartMovie() const
Return the starting movie.
Definition: ifofile.cpp:288
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
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:79
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
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
Utility class for manipulating file paths.
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
static Creature * toCreature(Aurora::NWScript::Object *object)