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_SONIC_AREA_H
26 #define ENGINES_SONIC_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 
39 #include "src/events/types.h"
40 #include "src/events/notifyable.h"
41 
43 
44 namespace Engines {
45 
46 namespace Sonic {
47 
48 class Module;
49 
50 class AreaBackground;
51 class AreaMiniMap;
52 
53 class Object;
54 
55 class Area : public Sonic::Object, public Events::Notifyable {
56 public:
57  Area(Module &module, uint32 id);
58  ~Area();
59 
60  // General properties
61 
63  const Common::UString &getName();
64 
65  uint32 getWidth() const;
66  uint32 getHeight() const;
67 
68  float getStartX() const;
69  float getStartY() const;
70 
71  // Entering/Leaving
72 
73  void enter();
74  void leave();
75 
76  // Visibility
77 
78  void show();
79  void hide();
80 
81  // Events
82 
84  void addEvent(const Events::Event &event);
86  void processEventQueue();
87 
89  void removeFocus();
90 
91  // Utility methods
92 
94  static void getCameraPosition(float x, float y, float &cameraX, float &cameraY, float &cameraZ);
96  static void getWorldPosition(float x, float y, float z, float &worldX, float &worldY, float &worldZ);
97 
98 
99 protected:
101  void notifyCameraMoved();
102 
103 
104 private:
106  typedef std::map<uint32, Object *> ObjectMap;
107 
108 
110 
114 
117 
118  float _startPosX;
119  float _startPosY;
120 
122 
125 
127 
132 
135 
136  std::list<Events::Event> _eventQueue;
137 
140 
143 
145 
147 
149 
150 
151  // Loading helpers
152 
153  void load();
154  void loadDefinition();
155  void loadBackground();
156  void loadMiniMap();
157  void loadLayout();
158 
159  void loadObject(Object &object);
160 
161  void loadPlaceables(const Aurora::GFF4List &list);
162 
163  void getCameraLimits(float &minX, float &minY, float &minZ,
164  float &maxX, float &maxY, float &maxZ) const;
165 
166  // Highlight / active helpers
167 
168  void checkActive();
169  void setActive(Object *object);
170  Object *getObjectAt(int x, int y);
171 
172  void highlightAll(bool enabled);
173 };
174 
175 } // End of namespace Sonic
176 
177 } // End of namespace Engines
178 
179 #endif // ENGINES_SONIC_AREA_H
Basic event types.
void loadDefinition()
Definition: area.cpp:211
Common::ScopedPtr< AreaBackground > _bgPanel
Definition: area.h:138
A class holding an UTF-8 string.
Definition: ustring.h:48
Common::UString _background
Definition: area.h:112
Common::UString _soundMap
Definition: area.h:126
float getStartY() const
Return the starting Y position within this area.
Definition: area.cpp:95
Common::UString _miniMap
Definition: area.h:121
Common::PtrList< Object > ObjectList
Definition: area.h:105
void loadBackground()
Definition: area.cpp:258
void checkActive()
Definition: area.cpp:321
Area(Module &module, uint32 id)
Definition: area.cpp:54
float _startPosY
Definition: area.h:119
static void getWorldPosition(float x, float y, float z, float &worldX, float &worldY, float &worldZ)
Return a position that would position on object at these coordinates within the area.
Definition: area.cpp:105
void loadMiniMap()
Definition: area.cpp:266
uint32 _height
Definition: area.h:116
A simple scoped smart pointer template.
An object within a Sonic area.
Definition: object.h:40
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
int32 _soundMapBank
Definition: area.h:128
std::vector< const GFF4Struct * > GFF4List
Definition: types.h:453
ObjectList _objects
Definition: area.h:141
Module * _module
Definition: area.h:109
A mutex.
Definition: mutex.h:40
void show()
Show the area.
Definition: area.cpp:124
void setActive(Object *object)
Definition: area.cpp:308
Common::Mutex _mutex
Definition: area.h:148
uint32 _numberRings
Definition: area.h:133
void processEventQueue()
Process the current event queue.
Definition: area.cpp:182
void getCameraLimits(float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ) const
Definition: area.cpp:113
Common::ScopedPtr< AreaMiniMap > _mmPanel
Definition: area.h:139
uint32 _numberChaoEggs
Definition: area.h:134
void loadObject(Object &object)
Definition: area.cpp:281
void hide()
Hide the area.
Definition: area.cpp:139
uint32 getWidth() const
Return the width of the area, in pixels.
Definition: area.cpp:83
Object * _activeObject
Definition: area.h:144
Low-level type definitions to handle fixed width types portably.
A class that can be notified by the NotificationManager.
int32 _soundType
Definition: area.h:130
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Object * getObjectAt(int x, int y)
Definition: area.cpp:296
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:343
Unicode string handling.
Thread mutex classes.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
uint32 getHeight() const
Return the height of the area, in pixels.
Definition: area.cpp:87
static void getCameraPosition(float x, float y, float &cameraX, float &cameraY, float &cameraZ)
Return a position that would position the camera on these coordinates within the area.
Definition: area.cpp:99
std::map< uint32, Object * > ObjectMap
Definition: area.h:106
Common::UString _layout
Definition: area.h:113
A Sonic module.
Definition: module.h:45
ObjectMap _objectMap
Definition: area.h:142
uint32 _miniMapWidth
Definition: area.h:123
void highlightAll(bool enabled)
Definition: area.cpp:333
uint32_t uint32
Definition: types.h:204
int32 _soundBank
Definition: area.h:131
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:178
uint32 _miniMapHeight
Definition: area.h:124
std::list< Events::Event > _eventQueue
Definition: area.h:136
An object in a Sonic Chronicles: The Dark Brotherhood area.
Common::UString _name
Definition: area.h:111
float getStartX() const
Return the starting X position within this area.
Definition: area.cpp:91
void notifyCameraMoved()
Notify the area that the camera has been moved.
Definition: area.cpp:350
void enter()
Enter the area.
Definition: area.cpp:156
float _startPosX
Definition: area.h:118
void loadPlaceables(const Aurora::GFF4List &list)
Definition: area.cpp:288
const Common::UString & getName()
Return the area&#39;s localized name.
Definition: area.cpp:79
int32_t int32
Definition: types.h:203
bool _highlightAll
Definition: area.h:146
void leave()
Leave the area.
Definition: area.cpp:173