1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
// ____ _ __
// / __ )____ _____ | | / /___ ___________
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
// /_____/\____/____/ |__/|__/\__,_/_/ /____/
//
// A futuristic real-time strategy game.
// This file is part of Bos Wars.
//
/**@name sound.h - The sound header file. */
//
// (c) Copyright 1998-2007 by Lutz Sammer, Fabrice Rossi, and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef __SOUND_H__
#define __SOUND_H__
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#include <vector>
#include "unit.h"
#include "unitsound.h"
#include "player.h"
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
class CUnit;
class Missile;
class CSample;
class LuaActionListener;
/*----------------------------------------------------------------------------
-- Definitons
----------------------------------------------------------------------------*/
#define MaxSampleVolume 255 /// Maximum sample volume
#define NO_SOUND 0 /// No valid sound ID
/**
** Global game sounds, not associated to any unit-type
*/
class GameSound
{
public:
SoundConfig PlacementError; /// used by ui
SoundConfig PlacementSuccess; /// used by ui
SoundConfig Click; /// used by ui
SoundConfig Docking; /// ship reaches coast
SoundConfig BuildingConstruction; /// building under construction
SoundConfig Rescue; /// rescue units
SoundConfig ChatMessage; /// chat message
};
/**
** Sound definition.
*/
class CSound {
public:
CSound() : Range(0), Number(0)
{
memset(&Sound, 0, sizeof(Sound));
}
~CSound();
/**
** Range is a multiplier for ::DistanceSilent.
** 255 means infinite range of the sound.
*/
unsigned char Range; /// Range is a multiplier for DistanceSilent
unsigned char Number; /// single, group, or table of sounds.
union {
CSample *OneSound; /// if it's only a simple sound
CSample **OneGroup; /// when it's a simple group
struct {
CSound *First; /// first group: selected sound
CSound *Second; /// second group: annoyed sound
} TwoGroups; /// when it's a double group
} Sound;
};
/**
** A possible value for Number in the Sound struct: means a simple sound
*/
#define ONE_SOUND 0
/**
** A possible value for Number in the Sound struct: means a double group (for
** selection/annoyed sounds)
*/
#define TWO_GROUPS 1
/**
** the range value that makes a sound volume distance independent
*/
#define INFINITE_SOUND_RANGE 255
/**
** the maximum range value
*/
#define MAX_SOUND_RANGE 254
/**
** Origin of a sound
*/
struct Origin {
const void *Base; /// pointer on a Unit
int Id; /// unique identifier (if the pointer has been shared)
};
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern GameSound GameSounds; /// Game sound configuration
extern bool CallbackMusic; /// flag true callback ccl if stops
/// global range control (max cut off distance for sound)
extern int DistanceSilent;
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/// Play a unit sound
extern void PlayUnitSound(const CUnit *unit, UnitVoiceGroup unit_voice_group);
/// Play a unit sound
extern void PlayUnitSound(const CUnit *unit, CSound *sound);
/// Play a missile sound
extern void PlayMissileSound(const Missile *missile, CSound *sound);
/// Play a game sound
extern void PlayGameSound(CSound *sound, unsigned char volume);
/// Play a sound file
extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL);
/// Modify the range of a given sound.
extern void SetSoundRange(CSound *sound, unsigned char range);
/// Register a sound (can be a simple sound or a group)
extern CSound *RegisterSound(const char *files[], unsigned number);
/// Create a special sound group with two sounds
extern CSound *RegisterTwoGroups(CSound *first, CSound *second);
/// Initialize client side of the sound layer.
extern void InitSoundClient(void);
// music.cpp
/// Check if music is finished and play the next song
extern void CheckMusicFinished(bool force = false);
/// Initialize music
extern void InitMusic(void);
/// Turn music stopped callback on
#define CallbackMusicOn() \
CallbackMusic = true;
/// Turn music stopped callback off
#define CallbackMusicOff() \
CallbackMusic = false;
// sound_id.cpp
/// Map sound to identifier
extern void MapSound(const std::string &sound_name, CSound *id);
/// Get the sound id bound to an identifier
extern CSound *SoundForName(const std::string &sound_name);
/// Make a sound bound to identifier
extern CSound *MakeSound(const std::string &sound_name, const char *file[], int nb);
/// Make a sound group bound to identifier
extern CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second);
#ifdef DEBUG
extern void FreeSounds();
#endif
// script_sound.cpp
/// register ccl features
extern void SoundCclRegister(void);
//@}
#endif // !__SOUND_H__
|