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_NWN2_AREA_H
26 #define ENGINES_NWN2_AREA_H
27 
28 #include <vector>
29 #include <list>
30 #include <map>
31 
32 #include "src/common/types.h"
33 #include "src/common/scopedptr.h"
34 #include "src/common/ptrlist.h"
35 #include "src/common/ustring.h"
36 #include "src/common/mutex.h"
37 
38 #include "src/aurora/types.h"
39 
41 
42 #include "src/sound/types.h"
43 
44 #include "src/events/types.h"
45 #include "src/events/notifyable.h"
46 
48 
49 namespace Engines {
50 
51 namespace NWN2 {
52 
53 class TRXFile;
54 
55 class Module;
56 
65 class Area : public NWN2::Object, public Events::Notifyable {
66 public:
67  Area(Module &module, const Common::UString &resRef);
68  ~Area();
69 
70  // General properties
71 
73  const Common::UString &getResRef();
75  const Common::UString &getName();
78 
79  // Visibility
80 
81  void show();
82  void hide();
83 
84  // Music/Sound
85 
86  uint32 getMusicDayTrack () const;
87  uint32 getMusicNightTrack () const;
88  uint32 getMusicBattleTrack() const;
89 
90  void setMusicDayTrack (uint32 track);
91  void setMusicNightTrack (uint32 track);
92  void setMusicBattleTrack(uint32 track);
93 
94  void stopSound();
95  void stopAmbientMusic();
96  void stopAmbientSound();
97 
99  void playAmbientMusic(Common::UString music = "");
101  void playAmbientSound(Common::UString sound = "");
102 
103  // Events
104 
106  void addEvent(const Events::Event &event);
108  void processEventQueue();
109 
111  void removeFocus();
112 
113 
115  static Common::UString getName(const Common::UString &resRef);
116 
117 
118 protected:
120  void notifyCameraMoved();
121 
122 
123 private:
125  enum Orientation {
130  };
131 
133  struct Tile {
134  bool metaTile;
135 
137 
138  float position[3];
140 
143 
144  float floorTint[3][4];
145  float wallTint[3][4];
146 
149  };
150 
152  typedef std::map<uint32, Engines::NWN2::Object *> ObjectMap;
153 
154 
156 
158 
160 
163 
167 
171 
173  std::vector<Common::UString> _musicBattleStinger;
174 
177 
178  bool _visible;
179 
182 
183  bool _hasTerrain;
184 
187 
189  std::vector<Tile> _tiles;
190 
193 
196 
198 
199  std::list<Events::Event> _eventQueue;
200 
202 
203 
204  // Loading helpers
205 
206  void clear();
207 
208  void loadARE(const Aurora::GFF3Struct &are);
209  void loadGIT(const Aurora::GFF3Struct &git);
210 
211  void loadProperties(const Aurora::GFF3Struct &props);
212 
213  void loadTerrain();
214  void loadTiles(const Aurora::GFF3List &tiles);
215  void loadTile(const Aurora::GFF3Struct &t, Tile &tile);
216 
217  void loadObject(Engines::NWN2::Object &object);
218  void loadWaypoints (const Aurora::GFF3List &list);
219  void loadPlaceables (const Aurora::GFF3List &list);
220  void loadEnvironment(const Aurora::GFF3List &list);
221  void loadDoors (const Aurora::GFF3List &list);
222  void loadCreatures (const Aurora::GFF3List &list);
223 
224  // Model loading/unloading helpers
225 
226  void loadModels();
227  void unloadModels();
228 
229  void loadTileModels();
230  void unloadTileModels();
231 
232  // Highlight / active helpers
233 
234  void checkActive(int x = -1, int y = -1);
235  void setActive(Engines::NWN2::Object *object);
236  Engines::NWN2::Object *getObjectAt(int x, int y);
237 
238  void highlightAll(bool enabled);
239 
240  void click(int x, int y);
241 };
242 
243 } // End of namespace NWN2
244 
245 } // End of namespace Engines
246 
247 #endif // ENGINES_NWN2_AREA_H
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:173
void loadEnvironment(const Aurora::GFF3List &list)
Definition: area.cpp:512
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:170
Basic event types.
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:337
Common::PtrList< Engines::NWN2::Object > ObjectList
Definition: area.h:151
ObjectList _objects
List of all objects in the area.
Definition: area.h:191
uint32 _width
Width of the area in tiles, as seen from top-down.
Definition: area.h:185
bool _hasTerrain
Does area have terrain or is it purely tile-based?
Definition: area.h:183
A class holding an UTF-8 string.
Definition: ustring.h:48
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:190
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:181
An area in Neverwinter Nights 2, holding all objects, room tiles and terrain within, as well as general area properties like the current background music and ambient sounds.
Definition: area.h:65
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:625
void highlightAll(bool enabled)
Definition: area.cpp:614
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:186
Common::UString _musicNight
Music that plays by night.
Definition: area.h:169
void loadTile(const Aurora::GFF3Struct &t, Tile &tile)
Definition: area.cpp:381
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:197
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:180
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:142
void show()
Show the area.
Definition: area.cpp:216
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:199
Basic sound types.
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:496
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:157
const Common::UString & getName()
Return the area&#39;s localized name.
Definition: area.cpp:126
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:58
Orientation orientation
The tile&#39;s orientation.
Definition: area.h:139
void stopSound()
Stop all sounds.
Definition: area.cpp:177
An object within a NWN2 area.
Definition: object.h:58
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:201
void notifyCameraMoved()
Notify the area that the camera has been moved.
Definition: area.cpp:632
uint32 _height
Height of the area in tiles, as seen from top-down.
Definition: area.h:186
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:151
void unloadTileModels()
Definition: area.cpp:482
Module * _module
Definition: area.h:155
A simple scoped smart pointer template.
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:536
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:162
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:528
float floorTint[3][4]
Tint color of the floor parts.
Definition: area.h:144
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:166
A mutex.
Definition: mutex.h:40
void loadTerrain()
Definition: area.cpp:367
Orientation
Tile orientation.
Definition: area.h:125
void loadTileModels()
Definition: area.cpp:451
uint32 tileID
ID of the tile&#39;s appearance.
Definition: area.h:136
Basic Aurora graphics types.
void loadModels()
Definition: area.cpp:425
Engines::NWN2::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:195
float wallTint[3][4]
Tint color of the wall parts.
Definition: area.h:145
Common::ScopedPtr< TRXFile > _terrain
The area&#39;s terrain.
Definition: area.h:188
Common::UString _displayName
The area&#39;s localized display name.
Definition: area.h:159
Low-level type definitions to handle fixed width types portably.
A class that can be notified by the NotificationManager.
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:175
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:592
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
const Common::UString & getResRef()
Return the area&#39;s resref (resource ID).
Definition: area.cpp:122
Engines::NWN2::Object * getObjectAt(int x, int y)
Definition: area.cpp:567
std::map< uint32, Engines::NWN2::Object * > ObjectMap
Definition: area.h:152
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:138
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:311
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:192
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:165
Unicode string handling.
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:504
Thread mutex classes.
void click(int x, int y)
Definition: area.cpp:604
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
void setActive(Engines::NWN2::Object *object)
Definition: area.cpp:579
Common::UString _musicDay
Music that plays by day.
Definition: area.h:168
Common::UString modelName
ResRef of the model.
Definition: area.h:142
bool _visible
Is the area currently visible?
Definition: area.h:178
void processEventQueue()
Process the current event queue.
Definition: area.cpp:540
Graphics::Aurora::Model * model
The tile&#39;s model.
Definition: area.h:148
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:156
A struct within a GFF3.
Definition: gff3file.h:164
A handle to a sound channel.
Definition: types.h:35
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:161
uint32_t uint32
Definition: types.h:204
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:164
void unloadModels()
Definition: area.cpp:442
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:203
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:176
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:134
An object in a Neverwinter Nights 2 area.
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:276
bool metaTile
Is this tile a meta tile?
Definition: area.h:134
std::vector< Tile > _tiles
The area&#39;s tiles.
Definition: area.h:189
void loadTiles(const Aurora::GFF3List &tiles)
Definition: area.cpp:375
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:520
void loadObject(Engines::NWN2::Object &object)
Definition: area.cpp:489
const Common::UString & getDisplayName()
Return the area&#39;s localized display name.
Definition: area.cpp:130
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:146
void hide()
Hide the area.
Definition: area.cpp:246
float position[3]
The tile&#39;s position.
Definition: area.h:138
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:182