Planeshift
sectormngr.h
Go to the documentation of this file.
1 /*
2  * sectormngr.h, Author: Andrea Rizzi <88whacko@gmail.com>
3  *
4  * Copyright (C) 2001-2012 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program 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 (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef SND_SECTOR_MNGR_H
21 #define SND_SECTOR_MNGR_H
22 
23 
24 //====================================================================================
25 // Crystal Space Includes
26 //====================================================================================
27 #include <cssysdef.h>
28 
29 //====================================================================================
30 // Project Includes
31 //====================================================================================
32 #include "util/singleton.h"
33 
34 //====================================================================================
35 // Local Includes
36 //====================================================================================
37 #include "soundctrl.h"
38 
39 //------------------------------------------------------------------------------------
40 // Forward Declarations
41 //------------------------------------------------------------------------------------
42 class csString;
43 class SoundControl;
44 class psSoundSector;
45 struct iMeshWrapper;
46 struct iObjectRegistry;
47 
52 class SoundSectorManager: public iSoundControlListener, public Singleton<SoundSectorManager>
53 {
54 public:
55 
60 
64  virtual ~SoundSectorManager();
65 
72  bool Initialize(iObjectRegistry* objectReg);
73 
77  void UnloadSectors();
78 
84  bool ReloadSectors();
85 
90  void Update();
91 
96  bool IsLoopBGMOn() const
97  {
98  return loopBGM;
99  }
100 
105  void SetLoopBGMToggle(bool toggle);
106 
111  bool IsCombatMusicOn() const
112  {
113  return isCombatMusicOn;
114  }
115 
120  void SetCombatMusicToggle(bool toggle);
121 
127  {
128  return commonSector;
129  }
130 
137  bool SetActiveSector(const char* sectorName);
138 
143  int GetCombatStance() const
144  {
145  return combatStance;
146  }
147 
152  void SetCombatStance(int newCombatStance);
153 
158  int GetTimeOfDay() const
159  {
160  return timeOfDay;
161  }
162 
167  void SetTimeOfDay(int newTimeOfDay);
168 
173  void SetWeather(int newWeather);
174 
187  void SetEntityState(int state, iMeshWrapper* mesh, const char* meshName, bool forceChange);
188 
194  void AddObjectEntity(iMeshWrapper* mesh, const char* meshName);
195 
201  void RemoveObjectEntity(iMeshWrapper* mesh, const char* meshName);
202 
208  void UpdateObjectEntity(iMeshWrapper* mesh, const char* meshName);
209 
210 
211  // From iSoundControlListener
212  //-----------------------------
213  virtual void OnSoundChange(SoundControl* sndCtrl);
214 
215 private:
216  iObjectRegistry* objectReg;
217 
218  int weather;
219  int timeOfDay;
220  int combatStance;
221 
222  bool loopBGM;
223  bool isCombatMusicOn;
224 
225  SoundControl* musicSndCtrl;
226  SoundControl* ambientSndCtrl;
227 
228  bool areSectorsLoaded;
229  psSoundSector* activeSector;
230  psSoundSector* commonSector;
231  csArray<psSoundSector*> sectors;
232 
240  bool LoadSectors();
241 
247  psSoundSector* FindSector(const csString &sectorName) const;
248 
253  void UpdateSector(psSoundSector* sector);
254 
260  void ConvertFactoriesToEmitter(psSoundSector* sector);
261 
269  void TransferHandles(psSoundSector* oldSector, psSoundSector* newSector);
270 
271 };
272 
273 #endif /* SND_SECTOR_MNGR_H */
274 
bool IsLoopBGMOn() const
Checks if the background music loop is allowed.
Definition: sectormngr.h:96
bool Initialize(iObjectRegistry *objectReg)
Load all sound sectors defined in XML files stored in the areas folder.
void UpdateObjectEntity(iMeshWrapper *mesh, const char *meshName)
Updates an object entity managed from the current sector.
void SetWeather(int newWeather)
Sets the current weather.
Interface to implement to handle SoundControl&#39;s events.
Definition: soundctrl.h:49
SoundSectorManager()
Constructor.
void SetTimeOfDay(int newTimeOfDay)
Sets the current time of the day.
work in progress - Looks like a mishap.
Definition: pssoundsector.h:48
bool SetActiveSector(const char *sectorName)
Sets the current active sector to the one with the given name and deactivate the previous one (if any...
psSoundSector * GetCommonSector()
Gets the common sector.
Definition: sectormngr.h:126
void RemoveObjectEntity(iMeshWrapper *mesh, const char *meshName)
Removes an object entity managed from the current sector.
bool ReloadSectors()
Reload all sound sectors from XML definition.
void SetEntityState(int state, iMeshWrapper *mesh, const char *meshName, bool forceChange)
Sets the new state for the entity associated to the given mesh.
This class handles every sound defined in a sector.
Definition: sectormngr.h:52
virtual void OnSoundChange(SoundControl *sndCtrl)
This function is called everytime the volume or the toggle change.
A Volume and Sound control class.
Definition: control.h:40
int GetTimeOfDay() const
Gets the time of the day.
Definition: sectormngr.h:158
virtual ~SoundSectorManager()
Destructor.
void SetCombatMusicToggle(bool toggle)
Toggles the combat music.
void Update()
Update the active sector.
void UnloadSectors()
Unload all sound sectors.
bool IsCombatMusicOn() const
Checks if the combat music is activated.
Definition: sectormngr.h:111
void AddObjectEntity(iMeshWrapper *mesh, const char *meshName)
Adds an object entity to be managed from the current sector.
void SetCombatStance(int newCombatStance)
Sets the current combat stance.
void SetLoopBGMToggle(bool toggle)
Toggles the background music.
int GetCombatStance() const
Gets the current combat stance.
Definition: sectormngr.h:143