$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2007 by Lutz Sammer, Fabrice Rossi, and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __SOUND_H__ 00031 #define __SOUND_H__ 00032 00034 00035 /*---------------------------------------------------------------------------- 00036 -- Includes 00037 ----------------------------------------------------------------------------*/ 00038 00039 #include "unitsound.h" 00040 00041 /*---------------------------------------------------------------------------- 00042 -- Declarations 00043 ----------------------------------------------------------------------------*/ 00044 00045 class CUnit; 00046 class Missile; 00047 class CSample; 00048 class LuaActionListener; 00049 00050 /*---------------------------------------------------------------------------- 00051 -- Definitons 00052 ----------------------------------------------------------------------------*/ 00053 00054 #define MaxSampleVolume 255 00055 #define NO_SOUND 0 00056 00057 00060 enum UnitVoiceGroup { 00061 VoiceSelected, 00062 VoiceAcknowledging, 00063 VoiceReady, 00064 VoiceHelpMe, 00065 VoiceDying, 00066 VoiceWorkCompleted, 00067 VoiceBuilding, 00068 VoiceDocking, 00069 VoiceRepairing, 00070 VoiceHarvesting, 00071 VoiceAttack 00072 }; 00073 00074 00078 class GameSound 00079 { 00080 public: 00081 SoundConfig PlacementError[MAX_RACES]; 00082 SoundConfig PlacementSuccess[MAX_RACES]; 00083 SoundConfig Click; 00084 SoundConfig Docking; 00085 SoundConfig BuildingConstruction[MAX_RACES]; 00086 SoundConfig WorkComplete[MAX_RACES]; 00087 SoundConfig Rescue[MAX_RACES]; 00088 SoundConfig ChatMessage; 00089 SoundConfig ResearchComplete[MAX_RACES]; 00090 SoundConfig NotEnoughRes[MAX_RACES][MaxCosts]; 00091 SoundConfig NotEnoughFood[MAX_RACES]; 00092 }; 00093 00097 class CSound 00098 { 00099 public: 00100 CSound() : Mapref(0), Range(0), Number(0) { 00101 memset(&Sound, 0, sizeof(Sound)); 00102 } 00103 ~CSound(); 00104 unsigned int Mapref; 00109 unsigned char Range; 00110 unsigned char Number; 00111 union { 00112 CSample *OneSound; 00113 CSample **OneGroup; 00114 struct { 00115 CSound *First; 00116 CSound *Second; 00117 } TwoGroups; 00118 } Sound; 00119 }; 00120 00124 #define ONE_SOUND 0 00125 00129 #define TWO_GROUPS 1 00130 00134 #define INFINITE_SOUND_RANGE 255 00135 00138 #define MAX_SOUND_RANGE 254 00139 00143 struct Origin { 00144 const void *Base; 00145 unsigned Id; 00146 }; 00147 00148 00149 /*---------------------------------------------------------------------------- 00150 -- Variables 00151 ----------------------------------------------------------------------------*/ 00152 00153 extern GameSound GameSounds; 00154 00155 extern bool CallbackMusic; 00156 00158 extern int DistanceSilent; 00159 00160 /*---------------------------------------------------------------------------- 00161 -- Functions 00162 ----------------------------------------------------------------------------*/ 00163 00165 extern void PlayUnitSound(const CUnit &unit, UnitVoiceGroup unit_voice_group); 00167 extern void PlayUnitSound(const CUnit &unit, CSound *sound); 00169 extern void PlayMissileSound(const Missile &missile, CSound *sound); 00171 extern void PlayGameSound(CSound *sound, unsigned char volume); 00172 00174 extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL); 00175 00177 extern void SetSoundRange(CSound *sound, unsigned char range); 00178 00180 extern CSound *RegisterSound(const std::vector<std::string> &files); 00181 00183 extern CSound *RegisterTwoGroups(CSound *first, CSound *second); 00184 00186 extern void InitSoundClient(); 00187 00188 00189 // music.cpp 00190 00192 extern void CheckMusicFinished(bool force = false); 00193 00195 extern void InitMusic(); 00196 00198 #define CallbackMusicOn() \ 00199 CallbackMusic = true; 00201 #define CallbackMusicOff() \ 00202 CallbackMusic = false; 00203 00204 00205 // sound_id.cpp 00206 00208 extern void MapSound(const std::string &sound_name, CSound *id); 00210 extern CSound *SoundForName(const std::string &sound_name); 00212 extern CSound *MakeSound(const std::string &sound_name, const std::vector<std::string> &files); 00214 extern CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second); 00215 #ifdef DEBUG 00216 extern void FreeSounds(); 00217 #endif 00218 00219 00220 // script_sound.cpp 00221 00223 extern void SoundCclRegister(); 00224 00225 00227 00228 #endif // !__SOUND_H__