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_WITCHER_AREA_H
26 #define ENGINES_WITCHER_AREA_H
27 
28 #include <list>
29 #include <map>
30 
31 #include "src/common/types.h"
32 #include "src/common/scopedptr.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 #include "src/aurora/locstring.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 Witcher {
52 
53 class Module;
54 
63 class Area : public Witcher::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() const;
73  const Aurora::LocString &getName() const;
74 
76  void refreshLocalized();
77 
78  // Visibility
79 
80  void show();
81  void hide();
82 
83  // Music/Sound
84 
85  uint32 getMusicDayTrack () const;
86  uint32 getMusicNightTrack () const;
87  uint32 getMusicBattleTrack() const;
88 
89  void setMusicDayTrack (uint32 track);
90  void setMusicNightTrack (uint32 track);
91  void setMusicBattleTrack(uint32 track);
92 
93  void stopAmbientMusic();
94 
96  void playAmbientMusic(Common::UString music = "");
97 
98  // Events
99 
101  void addEvent(const Events::Event &event);
103  void processEventQueue();
104 
106  void removeFocus();
107 
108 
110  static Aurora::LocString getName(const Common::UString &resRef);
111 
112 
113 protected:
115  void notifyCameraMoved();
116 
117 
118 private:
120  typedef std::map<uint32, Engines::Witcher::Object *> ObjectMap;
121 
122 
124 
126 
130 
134 
135  bool _visible;
136 
138 
141 
144 
147 
149 
150  std::list<Events::Event> _eventQueue;
151 
153 
154 
155  // Loading helpers
156 
157  void clear();
158 
159  void loadARE(const Aurora::GFF3Struct &are);
160  void loadGIT(const Aurora::GFF3Struct &git);
161 
162  void loadProperties(const Aurora::GFF3Struct &props);
163 
164  void loadObject(Engines::Witcher::Object &object);
165  void loadWaypoints (const Aurora::GFF3List &list);
166  void loadPlaceables(const Aurora::GFF3List &list);
167  void loadDoors (const Aurora::GFF3List &list);
168 
169  // Model loading/unloading helpers
170 
171  void loadModels();
172  void unloadModels();
173 
174  void loadAreaModel();
175  void unloadAreaModel();
176 
177  // Highlight / active helpers
178 
179  void checkActive(int x = -1, int y = -1);
180  void setActive(Engines::Witcher::Object *object);
181  Engines::Witcher::Object *getObjectAt(int x, int y);
182 
183  void highlightAll(bool enabled);
184 
185  void click(int x, int y);
186 };
187 
188 } // End of namespace Witcher
189 
190 } // End of namespace Engines
191 
192 #endif // ENGINES_WITCHER_AREA_H
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:239
Basic event types.
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:146
An area in The Witcher, holding all objects and area geometry within, as well as general area propert...
Definition: area.h:63
void click(int x, int y)
Definition: area.cpp:399
A class holding an UTF-8 string.
Definition: ustring.h:48
An object within a Witcher area.
Definition: object.h:51
A localized string.
Definition: locstring.h:43
void loadObject(Engines::Witcher::Object &object)
Definition: area.cpp:300
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:155
Engines::Witcher::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:146
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:216
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:128
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:420
Basic sound types.
const Common::UString & getResRef() const
Return the area&#39;s resref (resource ID).
Definition: area.cpp:111
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:124
void highlightAll(bool enabled)
Definition: area.cpp:409
Common::UString _musicNight
Music that plays by night.
Definition: area.h:132
Engines::Witcher::Object * getObjectAt(int x, int y)
Definition: area.cpp:362
A simple scoped smart pointer template.
void hide()
Hide the area.
Definition: area.cpp:191
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
void processEventQueue()
Process the current event queue.
Definition: area.cpp:335
A mutex.
Definition: mutex.h:40
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:127
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:143
Basic Aurora graphics types.
void show()
Show the area.
Definition: area.cpp:168
An object in a The Witcher area.
void unloadAreaModel()
Definition: area.cpp:296
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:148
Low-level type definitions to handle fixed width types portably.
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:387
A class that can be notified by the NotificationManager.
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:125
bool _visible
Is the area currently visible?
Definition: area.h:135
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:150
Handling BioWare&#39;s localized strings.
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:151
Common::UString _musicDay
Music that plays by day.
Definition: area.h:131
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Module * _module
Definition: area.h:123
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:253
Unicode string handling.
Thread mutex classes.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:132
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:129
Common::PtrList< Engines::Witcher::Object > ObjectList
Definition: area.h:119
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:133
A struct within a GFF3.
Definition: gff3file.h:164
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:323
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:152
Common::ScopedPtr< Graphics::Aurora::Model > _model
The actual area geometry model.
Definition: area.h:140
A handle to a sound channel.
Definition: types.h:35
uint32_t uint32
Definition: types.h:204
Common::UString _modelName
Name of area geometry ("tile") model.
Definition: area.h:139
void setActive(Engines::Witcher::Object *object)
Definition: area.cpp:374
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:137
void refreshLocalized()
Refresh all localized strings.
Definition: area.cpp:119
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:128
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:331
ObjectList _objects
List of all objects in the area.
Definition: area.h:142
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:315
const Aurora::LocString & getName() const
Return the area&#39;s name.
Definition: area.cpp:115
std::map< uint32, Engines::Witcher::Object * > ObjectMap
Definition: area.h:120
void notifyCameraMoved()
Notify the area that the camera has been moved.
Definition: area.cpp:427
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:136
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:307
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:141
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:53