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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
#ifndef SOUNDINTERFACE_H
#define SOUNDINTERFACE_H
#include "Tools.h"
#include "SDLTools.h"
//----------------------------------------------------------------------------
class SoundInterface
{
public:
//------------------------------------------------------------------------
SoundInterface() {}
virtual ~SoundInterface() {}
//------------------------------------------------------------------------
virtual void enableSound() = 0;
virtual void disableSound() = 0;
virtual bool isSoundEnabled() const = 0;
virtual void enableMusic() = 0;
virtual void disableMusic() = 0;
virtual bool isMusicEnabled() const = 0;
virtual void setSoundVolume(Uint8 volume) = 0;
virtual Uint8 getSoundVolume() const = 0;
virtual void setMusicVolume(Uint8 volume) = 0;
virtual Uint8 getMusicVolume() const = 0;
//------------------------------------------------------------------------
virtual void playTitleMusic() = 0;
virtual void playInGameMusic() = 0;
virtual void playHighScoreMusic1stEntry() = 0;
virtual void playHighScoreMusicOtherEntry() = 0;
virtual void playHighScoreMusicNoEntry() = 0;
//------------------------------------------------------------------------
virtual void onShipShoot() = 0;
virtual void onShipExplosion() = 0;
virtual void onShipThrustOn() = 0;
virtual void onShipThrustOff() = 0;
virtual void onShipPlatformBump() = 0;
virtual void onShipOutOfFuel() = 0;
virtual void onCratePickUp() = 0;
virtual void onCrateUnload() = 0;
virtual void onMissileExplosion() = 0;
virtual void onTurretShoot() = 0;
virtual void onTurretExplosion() = 0;
virtual void onMortarShoot() = 0;
virtual void onMortarExplosion() = 0;
virtual void onTankShoot() = 0;
virtual void onTankExplosion() = 0;
virtual void onSAMBatteryShoot() = 0;
virtual void onSAMBatteryExplosion() = 0;
virtual void onProjectileExplosion() = 0;
virtual void onGrenadeExplosion() = 0;
virtual void onAddFuelToScore() = 0;
virtual void onAddBonusToScore() = 0;
//------------------------------------------------------------------------
static void setInstance(SoundInterface *instance)
{
sm_instance = instance;
}
static SoundInterface *getInstance()
{
return sm_instance;
}
private:
//------------------------------------------------------------------------
static SoundInterface *sm_instance;
};
//----------------------------------------------------------------------------
class NullSoundInterface : public SoundInterface
{
SINGLETON_OBJECT(NullSoundInterface);
public:
//------------------------------------------------------------------------
NullSoundInterface()
{
m_enableSound = false;
m_enableMusic = false;
m_soundVolume = 0;
m_musicVolume = 0;
}
~NullSoundInterface() {}
//------------------------------------------------------------------------
void enableSound() { m_enableSound = true; }
void disableSound() { m_enableSound = false; }
bool isSoundEnabled() const { return m_enableSound; }
void enableMusic() { m_enableMusic = true; }
void disableMusic() { m_enableMusic = false; }
bool isMusicEnabled() const { return m_enableMusic; }
void setSoundVolume(Uint8 volume) { m_soundVolume = volume; }
Uint8 getSoundVolume() const { return m_soundVolume; }
void setMusicVolume(Uint8 volume) { m_musicVolume = volume; }
Uint8 getMusicVolume() const { return m_musicVolume; }
//------------------------------------------------------------------------
void playTitleMusic() {}
void playInGameMusic() {}
void playHighScoreMusic1stEntry() {}
void playHighScoreMusicOtherEntry() {}
void playHighScoreMusicNoEntry() {}
//------------------------------------------------------------------------
void onShipShoot() {}
void onShipExplosion() {}
void onShipThrustOn() {}
void onShipThrustOff() {}
void onShipPlatformBump() {}
void onShipOutOfFuel() {}
void onCratePickUp() {}
void onCrateUnload() {}
void onMissileExplosion() {}
void onTurretShoot() {}
void onTurretExplosion() {}
void onMortarShoot() {}
void onMortarExplosion() {}
void onTankShoot() {}
void onTankExplosion() {}
void onSAMBatteryShoot() {}
void onSAMBatteryExplosion() {}
void onProjectileExplosion() {}
void onGrenadeExplosion() {}
void onAddFuelToScore() {}
void onAddBonusToScore() {}
private:
//------------------------------------------------------------------------
bool m_enableSound;
bool m_enableMusic;
Uint8 m_soundVolume;
Uint8 m_musicVolume;
};
//----------------------------------------------------------------------------
class SoundBridge : public SoundInterface
{
SINGLETON_OBJECT(SoundBridge);
public:
//------------------------------------------------------------------------
SoundBridge() { m_thrustChannel = -1; }
~SoundBridge() {}
//------------------------------------------------------------------------
void enableSound();
void disableSound();
bool isSoundEnabled() const;
void enableMusic();
void disableMusic();
bool isMusicEnabled() const;
void setSoundVolume(Uint8 volume);
Uint8 getSoundVolume() const;
void setMusicVolume(Uint8 volume);
Uint8 getMusicVolume() const;
//------------------------------------------------------------------------
void playTitleMusic();
void playInGameMusic();
void playHighScoreMusic1stEntry();
void playHighScoreMusicOtherEntry();
void playHighScoreMusicNoEntry();
//------------------------------------------------------------------------
void onShipShoot();
void onShipExplosion();
void onShipThrustOn();
void onShipThrustOff();
void onShipPlatformBump();
void onShipOutOfFuel();
void onCratePickUp();
void onCrateUnload();
void onMissileExplosion();
void onTurretShoot();
void onTurretExplosion();
void onMortarShoot();
void onMortarExplosion();
void onTankShoot();
void onTankExplosion();
void onSAMBatteryShoot();
void onSAMBatteryExplosion();
void onProjectileExplosion();
void onGrenadeExplosion();
void onAddFuelToScore();
void onAddBonusToScore();
private:
//------------------------------------------------------------------------
int m_thrustChannel;
};
#endif //SOUNDINTERFACE_H
|