make SOUND handle ScreenGameplay's music
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "ScreenAttract.h" // for AttractInput()
|
#include "ScreenAttract.h" // for AttractInput()
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
#include "RageSoundManager.h"
|
#include "RageSoundManager.h"
|
||||||
|
#include "RageSounds.h"
|
||||||
|
|
||||||
|
|
||||||
#define SHOW_RANDOM_MODIFIERS THEME->GetMetricF("ScreenDemonstration","SecondsToShow")
|
#define SHOW_RANDOM_MODIFIERS THEME->GetMetricF("ScreenDemonstration","SecondsToShow")
|
||||||
@@ -102,7 +103,7 @@ void ScreenDemonstration::Input( const DeviceInput& DeviceI, const InputEventTyp
|
|||||||
if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit )
|
if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit )
|
||||||
break; // don't fall through
|
break; // don't fall through
|
||||||
|
|
||||||
m_soundMusic.Stop();
|
SOUND->StopMusic();
|
||||||
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
|
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
|
||||||
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
|
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
m_Out.StartTransitioning( SM_GoToNextScreen );
|
m_Out.StartTransitioning( SM_GoToNextScreen );
|
||||||
return;
|
return;
|
||||||
case SM_GoToNextScreen:
|
case SM_GoToNextScreen:
|
||||||
m_soundMusic.Stop();
|
SOUND->StopMusic();
|
||||||
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
|
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
|
||||||
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
|
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
|
||||||
|
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ void ScreenEdit::PlayTicks()
|
|||||||
void ScreenEdit::PlayPreviewMusic()
|
void ScreenEdit::PlayPreviewMusic()
|
||||||
{
|
{
|
||||||
SOUND->PlayMusic("");
|
SOUND->PlayMusic("");
|
||||||
SOUND->PlayMusic( m_pSong->GetMusicPath(), false,
|
SOUND->PlayMusic( m_pSong->GetMusicPath(), true,
|
||||||
m_pSong->m_fMusicSampleStartSeconds,
|
m_pSong->m_fMusicSampleStartSeconds,
|
||||||
m_pSong->m_fMusicSampleLengthSeconds,
|
m_pSong->m_fMusicSampleLengthSeconds,
|
||||||
1.5f );
|
1.5f );
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
|
|||||||
else
|
else
|
||||||
LIGHTSMAN->SetLightMode( LIGHTMODE_GAMEPLAY );
|
LIGHTSMAN->SetLightMode( LIGHTMODE_GAMEPLAY );
|
||||||
|
|
||||||
/* We do this ourself. */
|
m_soundMusic = NULL;
|
||||||
SOUND->HandleSongTimer( false );
|
|
||||||
|
|
||||||
SECONDS_BETWEEN_COMMENTS.Refresh();
|
SECONDS_BETWEEN_COMMENTS.Refresh();
|
||||||
TICK_EARLY_SECONDS.Refresh();
|
TICK_EARLY_SECONDS.Refresh();
|
||||||
@@ -752,7 +751,7 @@ ScreenGameplay::~ScreenGameplay()
|
|||||||
}
|
}
|
||||||
SAFE_DELETE( m_pCombinedLifeMeter );
|
SAFE_DELETE( m_pCombinedLifeMeter );
|
||||||
|
|
||||||
m_soundMusic.StopPlaying();
|
SOUND->StopMusic();
|
||||||
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,8 +949,9 @@ void ScreenGameplay::LoadNextSong()
|
|||||||
LL.LoadFromLRCFile(GAMESTATE->m_pCurSong->GetLyricsPath(), *GAMESTATE->m_pCurSong);
|
LL.LoadFromLRCFile(GAMESTATE->m_pCurSong->GetLyricsPath(), *GAMESTATE->m_pCurSong);
|
||||||
|
|
||||||
|
|
||||||
m_soundMusic.SetAccurateSync();
|
m_soundMusic = new RageSound;
|
||||||
m_soundMusic.Load( GAMESTATE->m_pCurSong->GetMusicPath() );
|
m_soundMusic->SetAccurateSync();
|
||||||
|
m_soundMusic->Load( GAMESTATE->m_pCurSong->GetMusicPath() );
|
||||||
|
|
||||||
/* Set up song-specific graphics. */
|
/* Set up song-specific graphics. */
|
||||||
|
|
||||||
@@ -1005,12 +1005,16 @@ float ScreenGameplay::StartPlayingSong(float MinTimeToNotes, float MinTimeToMusi
|
|||||||
|
|
||||||
fStartSecond = min(fStartSecond, -MinTimeToMusic);
|
fStartSecond = min(fStartSecond, -MinTimeToMusic);
|
||||||
|
|
||||||
m_soundMusic.SetPositionSeconds( fStartSecond );
|
ASSERT( m_soundMusic );
|
||||||
m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
|
m_soundMusic->SetPositionSeconds( fStartSecond );
|
||||||
|
m_soundMusic->SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
|
||||||
|
|
||||||
/* Keep the music playing after it's finished; we'll stop it. */
|
/* Keep the music playing after it's finished; we'll stop it. */
|
||||||
m_soundMusic.SetStopMode(RageSound::M_CONTINUE);
|
m_soundMusic->SetStopMode(RageSound::M_CONTINUE);
|
||||||
m_soundMusic.StartPlaying();
|
m_soundMusic->StartPlaying();
|
||||||
|
|
||||||
|
SOUND->TakeOverSound( m_soundMusic, &GAMESTATE->m_pCurSong->m_Timing );
|
||||||
|
m_soundMusic = NULL; // SOUND owns it now
|
||||||
|
|
||||||
/* Return the amount of time until the first beat. */
|
/* Return the amount of time until the first beat. */
|
||||||
return fFirstSecond - fStartSecond;
|
return fFirstSecond - fStartSecond;
|
||||||
@@ -1098,23 +1102,6 @@ void ScreenGameplay::Update( float fDeltaTime )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Very important: Update GAMESTATE's song beat information
|
|
||||||
* -before- calling update on all the classes that depend on it.
|
|
||||||
* If you don't do this first, the classes are all acting on old
|
|
||||||
* information and will lag. -Chris */
|
|
||||||
|
|
||||||
/* If ScreenJukebox is changing screens, it'll stop m_soundMusic to tell
|
|
||||||
* us not to update the time here. (In that case, we've already created
|
|
||||||
* a new ScreenJukebox and reset music statistics, and if we do this then
|
|
||||||
* we'll un-reset them.) */
|
|
||||||
if( m_soundMusic.IsPlaying() )
|
|
||||||
{
|
|
||||||
RageTimer tm;
|
|
||||||
const float fSeconds = m_soundMusic.GetPositionSeconds( NULL, &tm );
|
|
||||||
GAMESTATE->UpdateSongPosition( fSeconds, GAMESTATE->m_pCurSong->m_Timing, tm );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_bZeroDeltaOnNextUpdate )
|
if( m_bZeroDeltaOnNextUpdate )
|
||||||
{
|
{
|
||||||
Screen::Update( 0 );
|
Screen::Update( 0 );
|
||||||
@@ -1507,7 +1494,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
|
|||||||
*
|
*
|
||||||
* We're doing #3. I'm not sure which is best.
|
* We're doing #3. I'm not sure which is best.
|
||||||
*/
|
*/
|
||||||
m_soundMusic.StopPlaying();
|
SOUND->StopMusic();
|
||||||
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
||||||
|
|
||||||
this->ClearMessageQueue();
|
this->ClearMessageQueue();
|
||||||
@@ -2145,7 +2132,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
|
|
||||||
case SM_BeginFailed:
|
case SM_BeginFailed:
|
||||||
m_DancingState = STATE_OUTRO;
|
m_DancingState = STATE_OUTRO;
|
||||||
m_soundMusic.StopPlaying();
|
SOUND->StopMusic();
|
||||||
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
|
||||||
TweenOffScreen();
|
TweenOffScreen();
|
||||||
m_Failed.StartTransitioning( SM_GoToScreenAfterFail );
|
m_Failed.StartTransitioning( SM_GoToScreenAfterFail );
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ protected:
|
|||||||
bool m_bDemonstration;
|
bool m_bDemonstration;
|
||||||
|
|
||||||
RageSound m_soundAssistTick;
|
RageSound m_soundAssistTick;
|
||||||
RageSound m_soundMusic;
|
RageSound *m_soundMusic;
|
||||||
|
|
||||||
BeginnerHelper m_BeginnerHelper;
|
BeginnerHelper m_BeginnerHelper;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -217,9 +217,7 @@ void ScreenJukebox::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
m_Out.StartTransitioning( SM_GoToNextScreen );
|
m_Out.StartTransitioning( SM_GoToNextScreen );
|
||||||
return;
|
return;
|
||||||
case SM_GoToNextScreen:
|
case SM_GoToNextScreen:
|
||||||
/* We're actually under Update(), so make sure ScreenGameplay doesn't
|
SOUND->StopMusic();
|
||||||
* continue grading for this call. */
|
|
||||||
m_soundMusic.StopPlaying();
|
|
||||||
SCREENMAN->SetNewScreen( "ScreenJukebox" );
|
SCREENMAN->SetNewScreen( "ScreenJukebox" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1303,6 +1303,10 @@ static void GameLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DISPLAY->Update( fDeltaTime );
|
DISPLAY->Update( fDeltaTime );
|
||||||
|
|
||||||
|
/* Update song beat information -before- calling update on all the classes that
|
||||||
|
* depend on it. If you don't do this first, the classes are all acting on old
|
||||||
|
* information and will lag. (but no longer fatally, due to timestamping -glenn) */
|
||||||
SOUND->Update( fDeltaTime );
|
SOUND->Update( fDeltaTime );
|
||||||
TEXTUREMAN->Update( fDeltaTime );
|
TEXTUREMAN->Update( fDeltaTime );
|
||||||
GAMESTATE->Update( fDeltaTime );
|
GAMESTATE->Update( fDeltaTime );
|
||||||
|
|||||||
Reference in New Issue
Block a user