make SOUND handle ScreenGameplay's music

This commit is contained in:
Glenn Maynard
2004-01-20 06:08:56 +00:00
parent 614b3d6f3d
commit 42e0413e0f
6 changed files with 25 additions and 35 deletions
+3 -2
View File
@@ -19,6 +19,7 @@
#include "ScreenAttract.h" // for AttractInput()
#include "ScreenManager.h"
#include "RageSoundManager.h"
#include "RageSounds.h"
#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 )
break; // don't fall through
m_soundMusic.Stop();
SOUND->StopMusic();
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
@@ -123,7 +124,7 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM )
m_Out.StartTransitioning( SM_GoToNextScreen );
return;
case SM_GoToNextScreen:
m_soundMusic.Stop();
SOUND->StopMusic();
if( !GAMESTATE->IsTimeToPlayAttractSounds() )
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
+1 -1
View File
@@ -397,7 +397,7 @@ void ScreenEdit::PlayTicks()
void ScreenEdit::PlayPreviewMusic()
{
SOUND->PlayMusic("");
SOUND->PlayMusic( m_pSong->GetMusicPath(), false,
SOUND->PlayMusic( m_pSong->GetMusicPath(), true,
m_pSong->m_fMusicSampleStartSeconds,
m_pSong->m_fMusicSampleLengthSeconds,
1.5f );
+15 -28
View File
@@ -101,8 +101,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
else
LIGHTSMAN->SetLightMode( LIGHTMODE_GAMEPLAY );
/* We do this ourself. */
SOUND->HandleSongTimer( false );
m_soundMusic = NULL;
SECONDS_BETWEEN_COMMENTS.Refresh();
TICK_EARLY_SECONDS.Refresh();
@@ -752,7 +751,7 @@ ScreenGameplay::~ScreenGameplay()
}
SAFE_DELETE( m_pCombinedLifeMeter );
m_soundMusic.StopPlaying();
SOUND->StopMusic();
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
}
@@ -950,8 +949,9 @@ void ScreenGameplay::LoadNextSong()
LL.LoadFromLRCFile(GAMESTATE->m_pCurSong->GetLyricsPath(), *GAMESTATE->m_pCurSong);
m_soundMusic.SetAccurateSync();
m_soundMusic.Load( GAMESTATE->m_pCurSong->GetMusicPath() );
m_soundMusic = new RageSound;
m_soundMusic->SetAccurateSync();
m_soundMusic->Load( GAMESTATE->m_pCurSong->GetMusicPath() );
/* Set up song-specific graphics. */
@@ -1005,12 +1005,16 @@ float ScreenGameplay::StartPlayingSong(float MinTimeToNotes, float MinTimeToMusi
fStartSecond = min(fStartSecond, -MinTimeToMusic);
m_soundMusic.SetPositionSeconds( fStartSecond );
m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
ASSERT( m_soundMusic );
m_soundMusic->SetPositionSeconds( fStartSecond );
m_soundMusic->SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
/* Keep the music playing after it's finished; we'll stop it. */
m_soundMusic.SetStopMode(RageSound::M_CONTINUE);
m_soundMusic.StartPlaying();
m_soundMusic->SetStopMode(RageSound::M_CONTINUE);
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 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 )
{
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.
*/
m_soundMusic.StopPlaying();
SOUND->StopMusic();
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
this->ClearMessageQueue();
@@ -2145,7 +2132,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
case SM_BeginFailed:
m_DancingState = STATE_OUTRO;
m_soundMusic.StopPlaying();
SOUND->StopMusic();
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
TweenOffScreen();
m_Failed.StartTransitioning( SM_GoToScreenAfterFail );
+1 -1
View File
@@ -199,7 +199,7 @@ protected:
bool m_bDemonstration;
RageSound m_soundAssistTick;
RageSound m_soundMusic;
RageSound *m_soundMusic;
BeginnerHelper m_BeginnerHelper;
};
+1 -3
View File
@@ -217,9 +217,7 @@ void ScreenJukebox::HandleScreenMessage( const ScreenMessage SM )
m_Out.StartTransitioning( SM_GoToNextScreen );
return;
case SM_GoToNextScreen:
/* We're actually under Update(), so make sure ScreenGameplay doesn't
* continue grading for this call. */
m_soundMusic.StopPlaying();
SOUND->StopMusic();
SCREENMAN->SetNewScreen( "ScreenJukebox" );
return;
}
+4
View File
@@ -1303,6 +1303,10 @@ static void GameLoop()
}
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 );
TEXTUREMAN->Update( fDeltaTime );
GAMESTATE->Update( fDeltaTime );