improvements on keysounds logic for hold notes

This commit is contained in:
Thai Pangsakulyanont
2011-02-24 09:47:57 +07:00
parent 253049f0a4
commit e942c4b3d4
+38 -19
View File
@@ -1293,16 +1293,15 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vector<TrackRowTap
tn.HoldResult.hns = hns; tn.HoldResult.hns = hns;
// Stop the playing keysound for the hold note. // Stop the playing keysound for the hold note.
// I think this causes crashes too -aj // I think this causes crashes too -aj
/* // Possibly fixed.
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", max(0.0, min(1.0, fLife * 5.0 - 4.0)));
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() )
{ {
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", max(0.0, min(1.0, fLife * 5.0 - 4.0)));
if (tn.HoldResult.fLife == 0) if (tn.HoldResult.fLife == 0)
{ {
m_vKeysounds[tn.iKeysoundIndex].StopPlaying(); m_vKeysounds[tn.iKeysoundIndex].StopPlaying();
} }
} }
*/
} }
if( hns != HNS_None ) if( hns != HNS_None )
@@ -2424,29 +2423,49 @@ done_checking_hopo:
iRowOfOverlappingNoteOrRow = GetClosestNote( col, iSongRow, MAX_NOTE_ROW, MAX_NOTE_ROW, true ); iRowOfOverlappingNoteOrRow = GetClosestNote( col, iSongRow, MAX_NOTE_ROW, MAX_NOTE_ROW, true );
if( iRowOfOverlappingNoteOrRow != -1 ) if( iRowOfOverlappingNoteOrRow != -1 )
{ {
switch( pbt ) int iPrevIndex = GetClosestNoteDirectional( col, iSongRow-MAX_NOTE_ROW, iSongRow, true, false );
bool bShouldPlayNextKeysound = true;
if( iPrevIndex != -1 )
{ {
DEFAULT_FAIL(pbt); const TapNote &tn = m_NoteData.GetTapNote( col, iPrevIndex );
case ButtonType_StrumFretsChanged: if( tn.type == TapNote::hold_head )
for( int i=0; i<m_NoteData.GetNumTracks(); i++ )
{ {
const TapNote &tn = m_NoteData.GetTapNote( i, iRowOfOverlappingNoteOrRow ); if( tn.HoldResult.bActive && tn.HoldResult.fOverlappedTime != 0 && tn.HoldResult.hns != HNS_Held )
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() && (tn.type != TapNote::hold_head || (!tn.HoldResult.bActive || (tn.HoldResult.fOverlappedTime == 0))) ) {
bShouldPlayNextKeysound = false;
}
}
}
if( bShouldPlayNextKeysound )
{
switch( pbt )
{
DEFAULT_FAIL(pbt);
case ButtonType_StrumFretsChanged:
for( int i=0; i<m_NoteData.GetNumTracks(); i++ )
{
const TapNote &tn = m_NoteData.GetTapNote( i, iRowOfOverlappingNoteOrRow );
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() && (tn.type != TapNote::hold_head || (!tn.HoldResult.bActive || (tn.HoldResult.fOverlappedTime == 0 || (tn.HoldResult.hns == HNS_Held)))) )
{
m_vKeysounds[tn.iKeysoundIndex].Play();
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", 1);
}
}
break;
case ButtonType_Step:
case ButtonType_Hopo:
const TapNote &tn = m_NoteData.GetTapNote( col, iRowOfOverlappingNoteOrRow );
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() && (tn.type != TapNote::hold_head || (!tn.HoldResult.bActive || (tn.HoldResult.fOverlappedTime == 0 || (tn.HoldResult.hns == HNS_Held)))) )
{ {
m_vKeysounds[tn.iKeysoundIndex].Play(); m_vKeysounds[tn.iKeysoundIndex].Play();
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", 1); m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", 1);
} }
break;
} }
break;
case ButtonType_Step:
case ButtonType_Hopo:
const TapNote &tn = m_NoteData.GetTapNote( col, iRowOfOverlappingNoteOrRow );
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() && (tn.type != TapNote::hold_head || (!tn.HoldResult.bActive || (tn.HoldResult.fOverlappedTime == 0))) )
{
m_vKeysounds[tn.iKeysoundIndex].Play();
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", 1);
}
break;
} }
} }
} }