00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __SOUND_H__
00029 #define __SOUND_H__
00030
00032
00033
00034
00035
00036
00037 #include <vector>
00038
00039 #include "unit.h"
00040 #include "unitsound.h"
00041 #include "player.h"
00042
00043
00044
00045
00046
00047 class CUnit;
00048 class Missile;
00049 class CSample;
00050 class LuaActionListener;
00051
00052
00053
00054
00055
00056 #define MaxSampleVolume 255
00057 #define NO_SOUND 0
00058
00059
00062 class GameSound
00063 {
00064 public:
00065 SoundConfig PlacementError;
00066 SoundConfig PlacementSuccess;
00067 SoundConfig Click;
00068 SoundConfig Docking;
00069 SoundConfig BuildingConstruction;
00070 SoundConfig WorkComplete;
00071 SoundConfig Rescue;
00072 SoundConfig ChatMessage;
00073 };
00074
00078 class CSound {
00079 public:
00080 CSound() : Range(0), Number(0)
00081 {
00082 memset(&Sound, 0, sizeof(Sound));
00083 }
00084 ~CSound();
00085
00090 unsigned char Range;
00091 unsigned char Number;
00092 union {
00093 CSample *OneSound;
00094 CSample **OneGroup;
00095 struct {
00096 CSound *First;
00097 CSound *Second;
00098 } TwoGroups;
00099 } Sound;
00100 };
00101
00105 #define ONE_SOUND 0
00106
00110 #define TWO_GROUPS 1
00111
00115 #define INFINITE_SOUND_RANGE 255
00116
00119 #define MAX_SOUND_RANGE 254
00120
00124 struct Origin {
00125 const void *Base;
00126 unsigned Id;
00127 };
00128
00129
00130
00131
00132
00133
00134 extern GameSound GameSounds;
00135
00136 extern bool CallbackMusic;
00137
00139 extern int DistanceSilent;
00140
00141
00142
00143
00144
00146 extern void PlayUnitSound(const CUnit *unit, UnitVoiceGroup unit_voice_group);
00148 extern void PlayUnitSound(const CUnit *unit, CSound *sound);
00150 extern void PlayMissileSound(const Missile *missile, CSound *sound);
00152 extern void PlayGameSound(CSound *sound, unsigned char volume);
00153
00155 extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL);
00156
00158 extern void SetSoundRange(CSound *sound, unsigned char range);
00159
00161 extern CSound *RegisterSound(const char *files[], unsigned number);
00162
00164 extern CSound *RegisterTwoGroups(CSound *first, CSound *second);
00165
00167 extern void InitSoundClient(void);
00168
00169
00170
00171
00173 extern void CheckMusicFinished(bool force = false);
00174
00176 extern void InitMusic(void);
00177
00179 #define CallbackMusicOn() \
00180 CallbackMusic = true;
00182 #define CallbackMusicOff() \
00183 CallbackMusic = false;
00184
00185
00186
00187
00189 extern void MapSound(const std::string &sound_name, CSound *id);
00191 extern CSound *SoundForName(const std::string &sound_name);
00193 extern CSound *MakeSound(const std::string &sound_name, const char *file[], int nb);
00195 extern CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second);
00196 #ifdef DEBUG
00197 extern void FreeSounds();
00198 #endif
00199
00200
00201
00202
00204 extern void SoundCclRegister(void);
00205
00206
00208
00209 #endif // !__SOUND_H__