1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Merge pull request #10 from blupi-games/issue/9-sound

Remove fade on jingles (win and lost)
This commit is contained in:
Mathieu Schroeter 2017-09-13 17:32:59 +02:00 committed by GitHub
commit 81cd5e2d9b
3 changed files with 13 additions and 6 deletions

View File

@ -20,6 +20,7 @@
#include <assert.h>
#include <ctime>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
@ -3031,7 +3032,10 @@ CEvent::ChangePhase (Uint32 phase)
// FIXME: pause is better if the game is not stop but just interrupted
if (m_phase == EV_PHASE_PLAY && m_phase != phase)
m_pSound->StopAllSounds (false);
{
static const std::set<Sint32> except = {SOUND_WIN, SOUND_LOST};
m_pSound->StopAllSounds (false, &except);
}
m_phase = phase; // change de phase
m_index = index;

View File

@ -28,13 +28,16 @@
// Stops all sounds.
bool
CSound::StopAllSounds (bool immediat)
CSound::StopAllSounds (bool immediat, const std::set<Sint32> * except)
{
for (Sint32 i = 0; i < MAXSOUND; i++)
{
if (!m_lpSDL[i])
continue;
if (except && except->find (i) != except->end ())
continue;
if (Mix_Playing (i + 1) == SDL_TRUE)
{
if (immediat)

View File

@ -20,11 +20,13 @@
#pragma once
#include <SDL2/SDL_mixer.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#include <SDL2/SDL_mixer.h>
#include "blupi.h"
#define MAXSOUND 100
@ -63,7 +65,7 @@ public:
bool IsStoppedOnDemand ();
void AdaptVolumeMusic ();
void SetSuspendSkip (Sint32 nb);
bool StopAllSounds (bool immediat);
bool StopAllSounds (bool immediat, const std::set<Sint32> * except = nullptr);
protected:
bool m_bState;
@ -78,5 +80,3 @@ protected:
Sint32 m_lastMidiVolume;
Sint32 m_nbSuspendSkip;
};
/////////////////////////////////////////////////////////////////////////////