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_NWN_AREA_H
26 #define ENGINES_NWN_AREA_H
27 
28 #include <vector>
29 #include <list>
30 #include <map>
31 
32 #include "src/common/types.h"
33 #include "src/common/ptrlist.h"
34 #include "src/common/ustring.h"
35 #include "src/common/mutex.h"
36 
37 #include "src/aurora/types.h"
38 
40 
41 #include "src/sound/types.h"
42 
43 #include "src/events/types.h"
44 #include "src/events/notifyable.h"
45 
47 #include "src/engines/nwn/object.h"
48 
49 namespace Engines {
50 
51 namespace NWN {
52 
53 class Module;
54 
63 class Area : public NWN::Object, public Events::Notifyable {
64 public:
65  Area(Module &module, const Common::UString &resRef);
66  ~Area();
67 
68  // General properties
69 
71  const Common::UString &getResRef();
73  const Common::UString &getName();
76 
78  const Common::UString &getEnvironmentMap() const;
79 
80  // Visibility
81 
82  void show();
83  void hide();
84 
85  // Music/Sound
86 
87  uint32 getMusicDayTrack () const;
88  uint32 getMusicNightTrack () const;
89  uint32 getMusicBattleTrack() const;
90 
91  void setMusicDayTrack (uint32 track);
92  void setMusicNightTrack (uint32 track);
93  void setMusicBattleTrack(uint32 track);
94 
95  void stopSound();
96  void stopAmbientMusic();
97  void stopAmbientSound();
98 
100  void playAmbientMusic(Common::UString music = "");
102  void playAmbientSound(Common::UString sound = "");
103 
104  // Events
105 
107  void addEvent(const Events::Event &event);
109  void processEventQueue();
110 
112  void removeFocus();
113 
114 
116  static Common::UString getName(const Common::UString &resRef);
117 
118 
119 protected:
121  void notifyCameraMoved();
122 
123 
124 private:
126  enum Orientation {
131  };
132 
134  struct Tile {
136 
139 
142 
143  bool animLoop[3];
144 
146 
148  };
149 
151  typedef std::map<uint32, NWN::Object *> ObjectMap;
152 
153 
155 
157 
159 
162 
166 
170 
172  std::vector<Common::UString> _musicBattleStinger;
173 
176 
177  bool _visible;
178 
181 
184 
187 
188  std::vector<Tile> _tiles;
189 
192 
195 
197 
198  std::list<Events::Event> _eventQueue;
199 
201 
202 
203  // Loading helpers
204 
205  void clear();
206  void load();
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 loadTiles(const Aurora::GFF3List &tiles);
214  void loadTile(const Aurora::GFF3Struct &t, Tile &tile);
215 
216  void loadObject(NWN::Object &object);
217  void loadWaypoints (const Aurora::GFF3List &list);
218  void loadPlaceables(const Aurora::GFF3List &list);
219  void loadDoors (const Aurora::GFF3List &list);
220  void loadCreatures (const Aurora::GFF3List &list);
221 
222  // Model loading/unloading helpers
223 
224  void loadModels();
225  void unloadModels();
226 
227  void loadTileModels();
228  void unloadTileModels();
229 
230  void loadTileset();
231  void unloadTileset();
232 
233  void loadTiles();
234  void unloadTiles();
235 
236  // Highlight / active helpers
237 
238  void checkActive(int x = -1, int y = -1);
239  void setActive(NWN::Object *object);
240  NWN::Object *getObjectAt(int x, int y);
241 
242  void highlightAll(bool enabled);
243 
244  void click(int x, int y);
245 
246 
248 
249  friend class Console;
250 };
251 
252 } // End of namespace NWN
253 
254 } // End of namespace Engines
255 
256 #endif // ENGINES_NWN_AREA_H
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:156
Basic event types.
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:172
void unloadTiles()
Definition: area.cpp:471
void unloadModels()
Definition: area.cpp:407
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:581
ObjectList _objects
List of all objects in the area.
Definition: area.h:190
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:150
std::map< uint32, NWN::Object * > ObjectMap
Definition: area.h:151
const Common::UString & getResRef()
Return the area&#39;s resref (resource ID).
Definition: area.cpp:120
void clear()
Definition: area.cpp:88
uint8 mainLight[2]
Overall colored lighting effects.
Definition: area.h:140
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:196
const Common::UString & getEnvironmentMap() const
Return the area&#39;s environment map.
Definition: area.cpp:132
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:208
A class holding an UTF-8 string.
Definition: ustring.h:48
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:191
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:198
Graphics::Aurora::Model * model
The tile&#39;s model.
Definition: area.h:147
uint8_t uint8
Definition: types.h:200
Basic sound types.
uint32 _height
Height of the area in tiles, as seen from top-down.
Definition: area.h:183
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:321
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:179
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:271
void show()
Show the area.
Definition: area.cpp:221
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:614
Common::UString _musicDay
Music that plays by day.
Definition: area.h:167
void unloadTileModels()
Definition: area.cpp:421
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
void highlightAll(bool enabled)
Definition: area.cpp:603
Common::PtrList< NWN::Object > ObjectList
Definition: area.h:150
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:163
void click(int x, int y)
Definition: area.cpp:593
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:493
uint32 height
The number of height transitions the tile is shifted up.
Definition: area.h:137
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:142
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:195
void loadTiles()
Definition: area.cpp:444
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:501
bool _visible
Is the area currently visible?
Definition: area.h:177
Common::UString _tilesetName
Name of the tileset.
Definition: area.h:185
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:175
Common::UString _musicNight
Music that plays by night.
Definition: area.h:168
uint8 srcLight[2]
Flaming light sources.
Definition: area.h:141
A mutex.
Definition: mutex.h:40
void unloadTileset()
Definition: area.cpp:440
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:146
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:155
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:55
Basic Aurora graphics types.
void loadTileModels()
Definition: area.cpp:416
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:138
Common::ScopedPtr< Tileset > _tileset
The actual tileset.
Definition: area.h:186
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:165
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:525
Rotated by 270°.
Definition: area.h:130
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:517
void setActive(NWN::Object *object)
Definition: area.cpp:568
Common::UString _displayName
The area&#39;s localized display name.
Definition: area.h:158
void loadTile(const Aurora::GFF3Struct &t, Tile &tile)
Definition: area.cpp:362
std::vector< Tile > _tiles
The area&#39;s tiles.
Definition: area.h:188
Low-level type definitions to handle fixed width types portably.
A class that can be notified by the NotificationManager.
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:161
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
static Common::UString createDisplayName(const Common::UString &name)
Definition: area.cpp:626
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:509
bool animLoop[3]
Should the tile&#39;s AnimLoop0[123] play?
Definition: area.h:143
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
const Common::UString & getDisplayName()
Return the area&#39;s localized display name.
Definition: area.cpp:128
A tileset in Neverwinter Nights.
void hide()
Hide the area.
Definition: area.cpp:246
Module * _module
The module this area is in.
Definition: area.h:154
Unicode string handling.
Thread mutex classes.
An object in a Neverwinter Nights area.
void notifyCameraMoved()
Notify the area that the camera has been moved.
Definition: area.cpp:621
NWN::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:194
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
A struct within a GFF3.
Definition: gff3file.h:164
A handle to a sound channel.
Definition: types.h:35
uint32_t uint32
Definition: types.h:204
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:200
void stopSound()
Stop all sounds.
Definition: area.cpp:182
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:169
void loadModels()
Definition: area.cpp:390
const Tileset::Tile * tile
The actual tile within the tileset.
Definition: area.h:145
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:164
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:191
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:299
uint32 tileID
The ID of the tile within the tileset.
Definition: area.h:135
NWN::Object * getObjectAt(int x, int y)
Definition: area.cpp:556
Orientation orientation
The orientation of the tile.
Definition: area.h:138
Rotated by 180°.
Definition: area.h:129
void processEventQueue()
Process the current event queue.
Definition: area.cpp:529
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:187
uint32 _width
Width of the area in tiles, as seen from top-down.
Definition: area.h:182
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:180
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:160
void loadTileset()
Definition: area.cpp:426
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:160
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:174
void loadObject(NWN::Object &object)
Definition: area.cpp:486
Orientation
Tile orientation.
Definition: area.h:126
const Common::UString & getName()
Return the area&#39;s localized name.
Definition: area.cpp:124