Planeshift

handle.h

Go to the documentation of this file.
00001 /*
00002  * handle.h
00003  *
00004  * Copyright (C) 2001-2010 Atomic Blue ([email protected], http://www.planeshift.it)
00005  *
00006  * Credits : Saul Leite <[email protected]>
00007  *           Mathias 'AgY' Voeroes <[email protected]>
00008  *           and all past and present planeshift coders
00009  *
00010  * This program is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public License
00012  * as published by the Free Software Foundation (version 2 of the License.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021  *
00022  */
00023 
00024 #ifndef _SOUND_HANDLE_H_
00025 #define _SOUND_HANDLE_H_
00026 
00027 #include <isndsys.h>
00028 #include <csutil/csstring.h>
00029 
00030 class SoundControl;
00031 class SoundSystemManager;
00032 
00033 enum
00034 {
00035     FADE_DOWN   =   0,
00036     FADE_UP     =   1,
00037     FADE_STOP   =   -1
00038 };
00039 
00040 class SoundHandle
00041 {
00042     public:
00043     csString                                name;           
00044     SoundControl                           *sndCtrl;        
00045     float                                   preset_volume;  
00046     int                                     fade;           
00047     float                                   fade_volume;    
00048     bool                                    fade_stop;      
00049     bool                                    autoremove;     
00050 
00051     csRef<iSndSysData>                      snddata;        
00052     csRef<iSndSysStream>                    sndstream;      
00053     csRef<iSndSysSource>                    sndsource;      
00054     csRef<iSndSysSource3D>                  sndsource3d;    
00055     csRef<iSndSysSource3DDirectionalSimple> sndsourcedir;   
00056 
00057     SoundHandle (SoundSystemManager*);                      
00058     ~SoundHandle ();                                        
00059 
00065     void Fade (float volume, int time, int direction);
00075     bool Init (const char *resname, bool loop,
00076                float volume_preset, int type,
00077                SoundControl* &ctrl);
00078 
00089     void ConvertTo3D (float mindist, float maxdist,
00090                       csVector3 pos, csVector3 dir,
00091                       float rad);
00092 
00099     void SetAutoRemove (bool toggle);
00103     bool GetAutoRemove ();
00104 
00110     void SetCallback(void (*object), void (*function) (void *));
00114     void RemoveCallback();    
00115 
00116     private:
00117     SoundSystemManager* manager;
00118     bool hasCallback;                  
00119     void (*callbackobject);            
00120     void (*callbackfunction) (void *); 
00121 
00126     void Callback ();
00127 
00128 };
00129 
00130 #endif /*_SOUND_HANDLE_H_*/