00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __SOUND_H__
00031 #define __SOUND_H__
00032
00034
00035
00036
00037
00038
00039 #include <vector>
00040
00041 #include "unit.h"
00042 #include "unitsound.h"
00043 #include "player.h"
00044
00045
00046
00047
00048
00049 class CUnit;
00050 class Missile;
00051 class CSample;
00052 class LuaActionListener;
00053
00054
00055
00056
00057
00058 #define MaxSampleVolume 255
00059 #define NO_SOUND 0
00060
00061
00064 class GameSound
00065 {
00066 public:
00067 SoundConfig PlacementError[MAX_RACES];
00068 SoundConfig PlacementSuccess[MAX_RACES];
00069 SoundConfig Click;
00070 SoundConfig Docking;
00071 SoundConfig BuildingConstruction[MAX_RACES];
00072 SoundConfig WorkComplete[MAX_RACES];
00073 SoundConfig Rescue[MAX_RACES];
00074 SoundConfig ChatMessage;
00075 SoundConfig ResearchComplete[MAX_RACES];
00076 SoundConfig NotEnough1[MAX_RACES];
00077 SoundConfig NotEnough2[MAX_RACES];
00078 SoundConfig NotEnoughFood[MAX_RACES];
00079 };
00080
00084 class CSound {
00085 public:
00086 CSound() : Mapref(0), Range(0), Number(0)
00087 {
00088 memset(&Sound, 0, sizeof(Sound));
00089 }
00090 ~CSound();
00091 unsigned int Mapref;
00096 unsigned char Range;
00097 unsigned char Number;
00098 union {
00099 CSample *OneSound;
00100 CSample **OneGroup;
00101 struct {
00102 CSound *First;
00103 CSound *Second;
00104 } TwoGroups;
00105 } Sound;
00106 };
00107
00111 #define ONE_SOUND 0
00112
00116 #define TWO_GROUPS 1
00117
00121 #define INFINITE_SOUND_RANGE 255
00122
00125 #define MAX_SOUND_RANGE 254
00126
00130 struct Origin {
00131 const void *Base;
00132 unsigned Id;
00133 };
00134
00135
00136
00137
00138
00139
00140 extern GameSound GameSounds;
00141
00142 extern bool CallbackMusic;
00143
00145 extern int DistanceSilent;
00146
00147
00148
00149
00150
00152 extern void PlayUnitSound(const CUnit &unit, UnitVoiceGroup unit_voice_group);
00154 extern void PlayUnitSound(const CUnit &unit, CSound *sound);
00156 extern void PlayMissileSound(const Missile *missile, CSound *sound);
00158 extern void PlayGameSound(CSound *sound, unsigned char volume);
00159
00161 extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL);
00162
00164 extern void SetSoundRange(CSound *sound, unsigned char range);
00165
00167 extern CSound *RegisterSound(const char *files[], unsigned int number);
00168
00170 extern CSound *RegisterTwoGroups(CSound *first, CSound *second);
00171
00173 extern void InitSoundClient();
00174
00175
00176
00177
00179 extern void CheckMusicFinished(bool force = false);
00180
00182 extern void InitMusic();
00183
00185 #define CallbackMusicOn() \
00186 CallbackMusic = true;
00188 #define CallbackMusicOff() \
00189 CallbackMusic = false;
00190
00191
00192
00193
00195 extern void MapSound(const std::string &sound_name, CSound *id);
00197 extern CSound *SoundForName(const std::string &sound_name);
00199 extern CSound *MakeSound(const std::string &sound_name, const char *file[], int nb);
00201 extern CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second);
00202 #ifdef DEBUG
00203 extern void FreeSounds();
00204 #endif
00205
00206
00207
00208
00210 extern void SoundCclRegister();
00211
00212
00214
00215 #endif // !__SOUND_H__