xoreos  0.0.5
area.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_AREA_H
26 #define ENGINES_KOTOR2_AREA_H
27 
28 #include <vector>
29 #include <list>
30 #include <map>
31 
32 #include "src/common/ptrlist.h"
33 #include "src/common/ustring.h"
34 #include "src/common/mutex.h"
35 
36 #include "src/aurora/types.h"
37 #include "src/aurora/lytfile.h"
38 #include "src/aurora/visfile.h"
39 
40 #include "src/sound/types.h"
41 
42 #include "src/events/types.h"
43 #include "src/events/notifyable.h"
44 
47 
48 namespace Engines {
49 
50 namespace KotOR2 {
51 
52 class Module;
53 class Room;
54 class Situated;
55 
64 class Area : public KotOR2::Object, public Events::Notifyable {
65 public:
66  Area(Module &module, const Common::UString &resRef);
67  ~Area();
68 
69  // General properties
70 
72  const Common::UString &getResRef();
73 
74  // Visibility
75 
76  void show();
77  void hide();
78 
79  // Music/Sound
80 
81  uint32 getMusicDayTrack () const;
82  uint32 getMusicNightTrack () const;
83  uint32 getMusicBattleTrack() const;
84 
85  void setMusicDayTrack (uint32 track);
86  void setMusicNightTrack (uint32 track);
87  void setMusicBattleTrack(uint32 track);
88 
89  void stopSound();
90  void stopAmbientMusic();
91  void stopAmbientSound();
92 
94  void playAmbientMusic(Common::UString music = "");
96  void playAmbientSound(Common::UString sound = "");
97 
98  // Events
99 
101  void addEvent(const Events::Event &event);
103  void processEventQueue();
104 
106  void removeFocus();
107 
108  // Walkmesh
109  float evaluateElevation(float x, float y);
110  bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const;
111  void toggleWalkmesh();
112 
113  // .--- Triggers
114  void toggleTriggers();
115  void evaluateTriggers(float x, float y);
116  // '---
117 
118  void showAllRooms();
119 
120  void notifyObjectMoved(Object &o);
121  void notifyPCMoved();
122 
123  void getCameraStyle(float &distance, float &pitch, float &height) const;
124  const std::vector<Common::UString> &getRoomsVisibleFrom(const Common::UString &room) const;
127 
128 
129 protected:
130  void notifyCameraMoved();
131 
132 
133 private:
134  struct CameraStyle {
135  float distance;
136  float pitch;
137  float height;
138 
139  CameraStyle();
140  };
141 
143 
145  typedef std::map<uint32, KotOR2::Object *> ObjectMap;
146 
147 
149 
152 
155 
159 
163 
165  std::vector<Common::UString> _musicBattleStinger;
166 
169 
170  bool _visible;
171 
174 
177 
179 
182 
185 
187 
188  std::list<Events::Event> _eventQueue;
189 
191 
193  std::vector<Trigger *> _triggers;
197 
200  std::list<Situated *> _situatedObjects;
201 
202 
203  // Loading helpers
204 
205  void clear();
206  void load();
207 
208  void loadLYT();
209  void loadVIS();
210 
211  void loadARE(const Aurora::GFF3Struct &are);
212  void loadGIT(const Aurora::GFF3Struct &git);
213 
214  void loadCameraStyle(uint32 id);
215 
216  void loadRooms();
217 
218  void loadProperties(const Aurora::GFF3Struct &props);
219 
220  void loadObject(KotOR2::Object &object);
221 
222  void loadWaypoints (const Aurora::GFF3List &list);
223  void loadPlaceables(const Aurora::GFF3List &list);
224  void loadDoors (const Aurora::GFF3List &list);
225  void loadCreatures (const Aurora::GFF3List &list);
226  void loadTriggers (const Aurora::GFF3List &list);
227 
228  void unload();
229 
230  // Highlight / active helpers
231 
232  void checkActive(int x = -1, int y = -1);
233  void setActive(KotOR2::Object *object);
234  KotOR2::Object *getObjectAt(int x, int y);
235 
236  void highlightAll(bool enabled);
237 
238  void click(int x, int y);
239 
240  Room *getRoomAt(float x, float y) const;
241 
242 
243  friend class Console;
244 };
245 
246 } // End of namespace KotOR2
247 
248 } // End of namespace Engines
249 
250 #endif // ENGINES_KOTOR2_AREA_H
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:157
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:188
Basic event types.
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:167
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:395
KotOR2::Object * getObjectByTag(const Common::UString &tag)
Definition: area.cpp:676
Module * _module
The module this area is in.
Definition: area.h:148
void stopSound()
Stop all sounds.
Definition: area.cpp:163
A class holding an UTF-8 string.
Definition: ustring.h:48
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:172
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:186
Trigger in a Star Wars: Knights of the Old Republic II: The Sith Lords area.
An LYT, BioWare&#39;s Layout Format.
Definition: lytfile.h:55
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:150
bool _walkmeshInvisible
Definition: area.h:199
Common::UString _musicNight
Music that plays by night.
Definition: area.h:161
void evaluateTriggers(float x, float y)
Definition: area.cpp:567
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:136
Basic sound types.
void show()
Show the object&#39;s model(s).
Definition: area.cpp:202
Common::UString _displayName
The area&#39;s localized display name.
Definition: area.h:151
Common::PtrList< KotOR2::Object > ObjectList
Definition: area.h:144
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:153
void notifyCameraMoved()
Definition: area.cpp:509
std::list< Situated * > _situatedObjects
Definition: area.h:200
Aurora::LYTFile _lyt
The area&#39;s layout description.
Definition: area.h:175
bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const
Definition: area.cpp:535
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
void setActive(KotOR2::Object *object)
Definition: area.cpp:455
Aurora::VISFile _vis
The area&#39;s inter-room visibility description.
Definition: area.h:176
void loadTriggers(const Aurora::GFF3List &list)
Definition: area.cpp:403
A mutex.
Definition: mutex.h:40
An object in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:156
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:386
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:131
Common::PtrList< Room > RoomList
Definition: area.h:142
ObjectList _objects
List of all objects in the area.
Definition: area.h:180
const std::vector< Common::UString > & getRoomsVisibleFrom(const Common::UString &room) const
Definition: area.cpp:668
void toggleWalkmesh()
Definition: area.cpp:544
void loadCameraStyle(uint32 id)
Definition: area.cpp:290
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:172
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:190
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:181
void hide()
Hide the object&#39;s model(s).
Definition: area.cpp:225
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:189
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:154
const Common::UString & getResRef()
Return the area&#39;s resref (resource ID).
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:168
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:377
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:158
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:369
Handling BioWare&#39;s VISs (Visibility files).
void toggleTriggers()
Definition: area.cpp:558
void highlightAll(bool enabled)
Definition: area.cpp:491
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:119
void click(int x, int y)
Definition: area.cpp:480
A class that can be notified by the NotificationManager.
RoomList _rooms
All rooms in the area.
Definition: area.h:178
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:298
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
float evaluateElevation(float x, float y)
Definition: area.cpp:513
A VIS, BioWare&#39;s Visibility Format.
Definition: visfile.h:52
bool _triggersVisible
Definition: area.h:194
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:412
Unicode string handling.
Thread mutex classes.
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:318
std::vector< Trigger * > _triggers
.— Triggers
Definition: area.h:193
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:141
void processEventQueue()
Process the current event queue.
Definition: area.cpp:416
A struct within a GFF3.
Definition: gff3file.h:164
Common::UString _musicDay
Music that plays by day.
Definition: area.h:160
bool _visible
Is the area currently visible?
Definition: area.h:170
A handle to a sound channel.
Definition: types.h:35
uint32_t uint32
Definition: types.h:204
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:276
KotOR2::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:184
void loadObject(KotOR2::Object &object)
Definition: area.cpp:355
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:176
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:127
KotOR2::Object * getActiveObject()
Definition: area.cpp:672
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:173
void notifyObjectMoved(Object &o)
Definition: area.cpp:607
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:123
KotOR2::Object * getObjectAt(int x, int y)
Definition: area.cpp:443
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:468
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:168
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:63
Room * getRoomAt(float x, float y) const
Definition: area.cpp:685
void notifyPCMoved()
Definition: area.cpp:613
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:502
std::map< uint32, KotOR2::Object * > ObjectMap
Definition: area.h:145
An area in Star Wars: Knights of the Old Republic II - The Sith Lords, holding all objects and rooms ...
Definition: area.h:64
Handling BioWare&#39;s LYTs (Layout files).
CameraStyle _cameraStyle
&#39;—
Definition: area.h:198
void getCameraStyle(float &distance, float &pitch, float &height) const
Definition: area.cpp:662
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:162
Trigger * _activeTrigger
Definition: area.h:195
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:165