no message

This commit is contained in:
Chris Danford
2002-06-23 02:50:33 +00:00
parent 248ad096af
commit 1500459bb1
45 changed files with 1128 additions and 524 deletions
+153 -62
View File
@@ -43,13 +43,15 @@ const float PLAYER_OPTIONS_LOCAL_Y[NUM_PLAYERS] = { -10, +10 };
const float DIFFICULTY_X[NUM_PLAYERS] = { SCREEN_LEFT+60, SCREEN_RIGHT-60 };
const float DIFFICULTY_Y[NUM_PLAYERS] = { SCREEN_BOTTOM-70, SCREEN_BOTTOM-70 };
const float MAX_SECONDS_CAN_BE_OFF_BY = 0.25f;
const float DEBUG_X = CENTER_X;
const float DEBUG_Y = CENTER_Y-70;
const float TIME_BETWEEN_DANCING_COMMENTS = 15;
// received while STATE_DANCING
const ScreenMessage SM_SongEnded = ScreenMessage(SM_User+102);
const ScreenMessage SM_PlayMusic = ScreenMessage(SM_User+101);
const ScreenMessage SM_MusicEnded = ScreenMessage(SM_User+102);
const ScreenMessage SM_LifeIs0 = ScreenMessage(SM_User+103);
@@ -62,7 +64,7 @@ const ScreenMessage SM_BeginFailed = ScreenMessage(SM_User+121);
const ScreenMessage SM_ShowFailed = ScreenMessage(SM_User+122);
const ScreenMessage SM_PlayFailComment = ScreenMessage(SM_User+123);
const ScreenMessage SM_HideFailed = ScreenMessage(SM_User+124);
const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+125);
const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+125);
@@ -71,6 +73,8 @@ ScreenGameplay::ScreenGameplay()
LOG->WriteLine( "ScreenGameplay::ScreenGameplay()" );
m_pCurSong = NULL;
for( int p=0; p<NUM_PLAYERS; p++ )
m_pCurNotes[p] = NULL;
switch( PREFSMAN->m_PlayMode )
{
@@ -106,7 +110,7 @@ ScreenGameplay::ScreenGameplay()
for( int p=0; p<NUM_PLAYERS; p++ )
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMEMAN->IsPlayerEnabled(PlayerNumber(p)) )
continue;
@@ -150,12 +154,8 @@ ScreenGameplay::ScreenGameplay()
m_textStageNumber.Load( THEME->GetPathTo(FONT_HEADER2) );
m_textStageNumber.TurnShadowOff();
m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCAL_Y );
CString sStageText = PREFSMAN->GetStageText();
m_textStageNumber.SetText( sStageText );
if( stricmp(sStageText, "Final") == 0 )
m_textStageNumber.SetDiffuseColor( D3DXCOLOR(1,0.1f,0.1f,1) ); // red
else
m_textStageNumber.SetDiffuseColor( D3DXCOLOR(0.3f,1,0.3f,1) ); // green
m_textStageNumber.SetText( PREFSMAN->GetStageText() );
m_textStageNumber.SetDiffuseColor( PREFSMAN->GetStageColor() );
m_frameTop.AddActor( &m_textStageNumber );
@@ -178,6 +178,7 @@ ScreenGameplay::ScreenGameplay()
m_ScoreDisplay[p].SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] );
m_ScoreDisplay[p].SetZoom( 0.8f );
m_ScoreDisplay[p].SetDiffuseColor( PlayerToColor(p) );
m_frameBottom.AddActor( &m_ScoreDisplay[p] );
m_textPlayerOptions[p].Load( THEME->GetPathTo(FONT_NORMAL) );
@@ -207,9 +208,13 @@ ScreenGameplay::ScreenGameplay()
}
m_textDebug.Load( THEME->GetPathTo(FONT_NORMAL) );
m_textDebug.SetXY( DEBUG_X, DEBUG_Y );
m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
this->AddActor( &m_textDebug );
m_StarWipe.SetClosed();
@@ -262,18 +267,38 @@ ScreenGameplay::~ScreenGameplay()
}
void ScreenGameplay::SaveSummary()
{
// save score summaries
if( m_pCurSong != NULL )
{
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) )
continue; // skip
SONGMAN->m_aGameplayStatistics[p].Add( m_Player[p].GetGameplayStatistics(m_pCurSong, m_pCurNotes[p]) );
}
m_pCurSong = NULL;
}
}
void ScreenGameplay::LoadNextSong()
{
int p;
m_pCurSong = m_apSongQueue[m_apSongQueue.GetSize()-1];
m_apSongQueue.RemoveAt(m_apSongQueue.GetSize()-1);
Notes* pNotes[NUM_PLAYERS];
SaveSummary();
m_pCurSong = m_apSongQueue[0];
m_apSongQueue.RemoveAt(0);
for( p=0; p<NUM_PLAYERS; p++ )
{
pNotes[p] = m_apNotesQueue[p][m_apNotesQueue[p].GetSize()-1];
m_apNotesQueue[p].RemoveAt(m_apNotesQueue[p].GetSize()-1);
m_pCurNotes[p] = m_apNotesQueue[p][0];
m_apNotesQueue[p].RemoveAt(0);
}
@@ -285,10 +310,10 @@ void ScreenGameplay::LoadNextSong()
if( !GAMEMAN->IsPlayerEnabled(PlayerNumber(p)) )
continue;
m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), pNotes[p] );
m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), m_pCurNotes[p] );
NoteData* pOriginalNoteData = pNotes[p]->GetNoteData();
NoteData* pOriginalNoteData = m_pCurNotes[p]->GetNoteData();
NoteData newNoteData;
pStyleDef->GetTransformedNoteDataForStyle( (PlayerNumber)p, pOriginalNoteData, newNoteData );
@@ -297,6 +322,7 @@ void ScreenGameplay::LoadNextSong()
(PlayerNumber)p,
GAMEMAN->GetCurrentStyleDef(),
&newNoteData,
m_pCurNotes[p]->m_iMeter,
PREFSMAN->m_PlayerOptions[p],
&m_LifeMeter[p],
&m_ScoreDisplay[p]
@@ -304,6 +330,8 @@ void ScreenGameplay::LoadNextSong()
}
m_soundMusic.Load( m_pCurSong->GetMusicPath() );
this->SendScreenMessage( SM_PlayMusic, 3 );
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
m_Background.LoadFromSong( m_pCurSong );
m_Background.SetDiffuseColor( D3DXCOLOR(0.5f,0.5f,0.5f,1) );
@@ -318,6 +346,10 @@ void ScreenGameplay::Update( float fDeltaTime )
Screen::Update( fDeltaTime );
if( m_pCurSong == NULL )
return;
float fSongBeat, fBPS;
float fPositionSeconds = m_soundMusic.GetPositionSeconds();
@@ -328,7 +360,7 @@ void ScreenGameplay::Update( float fDeltaTime )
//LOG->WriteLine( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() );
float fMaxBeatDifference = fBPS*MAX_SECONDS_CAN_BE_OFF_BY;
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate;
for( int p=0; p<NUM_PLAYERS; p++ )
{
@@ -356,16 +388,12 @@ void ScreenGameplay::Update( float fDeltaTime )
continue;
if( !m_LifeMeter[p].IsAboutToFail() )
{
bAllAboutToFail = false;
if( !m_LifeMeter[p].HasFailed() )
bAllFailed = false;
}
else if( !m_LifeMeter[p].HasFailed() )
{
bAllFailed = false;
}
break;
}
if( bAllAboutToFail ) m_Background.TurnDangerOn();
else m_Background.TurnDangerOff();
@@ -387,9 +415,11 @@ void ScreenGameplay::Update( float fDeltaTime )
// Check for end of song
if( m_DancingState == STATE_DANCING &&
m_soundMusic.GetLengthSeconds() - m_soundMusic.GetPositionSeconds() < 2 )
this->SendScreenMessage( SM_SongEnded, 1 );
m_soundMusic.GetLengthSeconds() - m_soundMusic.GetPositionSeconds() < 0.5f )
{
this->SendScreenMessage( SM_MusicEnded, 0 );
}
// Check to see if it's time to play a gameplay comment
if( PREFSMAN->m_bAnnouncer )
{
@@ -408,31 +438,52 @@ void ScreenGameplay::Update( float fDeltaTime )
//
// Send crossed row messages to Player
//
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
static int iRowLastCrossed = 0;
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
{
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMEMAN->IsPlayerEnabled( (PlayerNumber)p ) )
continue; // skip
m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference );
}
}
iRowLastCrossed = iRowNow;
//
// play assist ticks
//
// Sound cards have a latency between when a sample is Play()ed and when the sound
// will start coming out the speaker. Compensate for this by boosting
// fPositionSeconds ahead
if( PREFSMAN->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK )
{
//
// play assist ticks
//
// Sound cards have a latency between when a sample is Play()ed and when the sound
// will start coming out the speaker. Compensate for this by boosting
// fPositionSeconds ahead
fPositionSeconds += (SOUND->GetPlayLatency()+0.06f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.06 seconds to make them play a tiny bit earlier
m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS );
int iIndexNow = BeatToNoteIndexNotRounded( fSongBeat );
static int iIndexLastCrossed = 0;
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
static int iRowLastCrossed = 0;
bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed
for( int i=iIndexLastCrossed+1; i<=iIndexNow; i++ ) // for each index we crossed since the last update
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
{
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMEMAN->IsPlayerEnabled( (PlayerNumber)p ) )
continue; // skip
bAnyoneHasANote |= m_Player[p].IsThereANoteAtIndex( i );
m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference );
bAnyoneHasANote |= m_Player[p].IsThereANoteAtRow( r );
break; // this will only play the tick for the first player that is joined
}
}
@@ -441,7 +492,7 @@ void ScreenGameplay::Update( float fDeltaTime )
m_soundAssistTick.PlayRandom();
iIndexLastCrossed = iIndexNow;
iRowLastCrossed = iRowNow;
}
}
@@ -460,6 +511,44 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
float fSongBeat, fBPS;
m_pCurSong->GetBeatAndBPSFromElapsedTime( m_soundMusic.GetPositionSeconds(), fSongBeat, fBPS );
// Handle special keys to adjust the offset
if( type == IET_FIRST_PRESS && DeviceI.device == DEVICE_KEYBOARD )
{
switch( DeviceI.button )
{
case DIK_F9:
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()-0.01f );
break;
case DIK_F10:
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()+0.01f );
break;
case DIK_F11:
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()-(1/fBPS) );
break;
case DIK_F12:
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()+(1/fBPS) );
break;
}
switch( DeviceI.button )
{
case DIK_F9:
case DIK_F10:
case DIK_F11:
case DIK_F12:
m_textDebug.SetText( ssprintf("Offset = %f.", m_pCurSong->GetBeatOffsetInSeconds()) );
m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_textDebug.StopTweening();
m_textDebug.BeginTweeningQueued( 3 ); // sleep
m_textDebug.BeginTweeningQueued( 0.5f ); // fade out
m_textDebug.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
break;
}
}
if( MenuI.IsValid() )
{
@@ -478,14 +567,14 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
}
}
float fMaxBeatsCanBeOffBy = MAX_SECONDS_CAN_BE_OFF_BY * fBPS;
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate;
if( type == IET_FIRST_PRESS )
{
if( StyleI.IsValid() )
{
if( GAMEMAN->IsPlayerEnabled( StyleI.player ) )
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatsCanBeOffBy );
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatDifference );
}
}
}
@@ -515,8 +604,6 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
if( PREFSMAN->m_bAnnouncer )
m_announcerHereWeGo.PlayRandom();
m_Background.SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0.8f,1) );
m_soundMusic.Play();
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
break;
case SM_User+6:
break;
@@ -535,21 +622,33 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
this->SendScreenMessage( SM_BeginFailed, 0 );
m_DancingState = STATE_OUTRO;
break;
case SM_SongEnded:
case SM_PlayMusic:
m_soundMusic.Play();
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
break;
case SM_MusicEnded:
if( m_DancingState == STATE_OUTRO ) // gameplay already ended
return; // ignore
if( m_bBothHaveFailed ) // fail them
if( m_apSongQueue.GetSize() > 0 )
{
this->SendScreenMessage( SM_BeginFailed, 0 );
LoadNextSong();
}
else // cleared
else
{
m_StarWipe.CloseWipingRight( SM_ShowCleared );
if( PREFSMAN->m_bAnnouncer )
m_announcerCleared.PlayRandom(); // crowd cheer
if( m_bBothHaveFailed ) // fail them
{
this->SendScreenMessage( SM_BeginFailed, 0 );
}
else // cleared
{
m_StarWipe.CloseWipingRight( SM_ShowCleared );
if( PREFSMAN->m_bAnnouncer )
m_announcerCleared.PlayRandom(); // crowd cheer
}
m_DancingState = STATE_OUTRO;
}
m_DancingState = STATE_OUTRO;
break;
// received while STATE_OUTRO
@@ -562,16 +661,8 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
SCREENMAN->SendMessageToTopScreen( SM_GoToResults, 1 );
break;
case SM_GoToResults:
{
// send score summaries to the PREFSMAN object so ScreenResults can grab it.
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) )
continue; // skip
m_Player[p].GetGameplayStatistics( SONGMAN->m_GameplayStatistics[PREFSMAN->m_iNumArcadeStages-1][p] );
}
SCREENMAN->SetNewScreen( new ScreenResults(false) );
}
SaveSummary();
SCREENMAN->SetNewScreen( new ScreenResults(false) );
break;