From b39d68c8cfbe72492ddfef13b00846e7f6f9aa04 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 14 Aug 2006 12:16:31 +0000 Subject: [PATCH] Initial TapNote::lift implementation. --- stepmania/src/NoteDataUtil.cpp | 9 +++------ stepmania/src/NoteDisplay.cpp | 34 ++++++++++++++++++++++++++++---- stepmania/src/NoteDisplay.h | 7 +++++-- stepmania/src/NoteField.cpp | 3 ++- stepmania/src/NoteTypes.cpp | 1 + stepmania/src/NoteTypes.h | 2 ++ stepmania/src/Player.cpp | 36 +++++++++++++++------------------- 7 files changed, 59 insertions(+), 33 deletions(-) diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index b33b5eb0fd..41f1db0fe7 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -111,12 +111,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS case '1': tn = TAP_ORIGINAL_TAP; break; case '2': case '4': - switch( ch ) - { - case '2': tn = TAP_ORIGINAL_HOLD_HEAD; break; - case '4': tn = TAP_ORIGINAL_ROLL_HEAD; break; - default: ASSERT(0); - } + tn = ch == '2' ? TAP_ORIGINAL_HOLD_HEAD : TAP_ORIGINAL_ROLL_HEAD; /* Set the hold note to have infinite length. We'll clamp it when * we hit the tail. */ @@ -145,6 +140,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS case 'M': tn = TAP_ORIGINAL_MINE; break; // case 'A': tn = TAP_ORIGINAL_ATTACK; break; case 'K': tn = TAP_ORIGINAL_AUTO_KEYSOUND; break; + case 'L': tn = TAP_ORIGINAL_LIFT; break; default: /* Invalid data. We don't want to assert, since there might * simply be invalid data in an .SM, and we don't want to die @@ -373,6 +369,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet ) case TapNote::mine: c = 'M'; break; case TapNote::attack: c = 'A'; break; case TapNote::autoKeysound: c = 'K'; break; + case TapNote::lift: c = 'L'; break; default: FAIL_M( ssprintf("tn %i", tn.type) ); // invalid enum value } diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index 07f20d35ae..79de35800f 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -17,6 +17,7 @@ static const char *NotePartNames[] = { "TapNote", "TapAddition", "TapMine", + "TapLift", "HoldHead", "HoldTopCap", "HoldBody", @@ -48,6 +49,7 @@ struct NoteMetricCache_t bool m_bTapNoteUseLighting; bool m_bTapAdditionUseLighting; bool m_bTapMineUseLighting; + bool m_bTapLiftUseLighting; bool m_bHoldHeadUseLighting; bool m_bHoldTailUseLighting; bool m_bFlipHeadAndTailWhenReverse; @@ -60,7 +62,7 @@ void NoteMetricCache_t::Load( const RString &sButton ) m_bDrawHoldHeadForTapsOnSameRow = NOTESKIN->GetMetricB(sButton,"DrawHoldHeadForTapsOnSameRow"); FOREACH_NotePart( p ) { - const RString s = NotePartToString(p); + const RString &s = NotePartToString(p); m_fAnimationLengthInBeats[p] = NOTESKIN->GetMetricF(sButton,s+"AnimationLengthInBeats"); m_bAnimationIsVivid[p] = NOTESKIN->GetMetricB(sButton,s+"AnimationIsVivid"); m_fNoteColorTextureCoordSpacing[p].x = NOTESKIN->GetMetricF(sButton,s+"NoteColorTextureCoordSpacingX"); @@ -74,6 +76,7 @@ void NoteMetricCache_t::Load( const RString &sButton ) m_bTapNoteUseLighting = NOTESKIN->GetMetricB(sButton,"TapNoteUseLighting"); m_bTapAdditionUseLighting = NOTESKIN->GetMetricB(sButton,"TapAdditionUseLighting"); m_bTapMineUseLighting = NOTESKIN->GetMetricB(sButton,"TapMineUseLighting"); + m_bTapLiftUseLighting = NOTESKIN->GetMetricB(sButton,"TapLiftUseLighting"); m_bHoldHeadUseLighting = NOTESKIN->GetMetricB(sButton,"HoldHeadUseLighting"); m_bHoldTailUseLighting = NOTESKIN->GetMetricB(sButton,"HoldTailUseLighting"); m_bFlipHeadAndTailWhenReverse = NOTESKIN->GetMetricB(sButton,"FlipHeadAndTailWhenReverse"); @@ -261,6 +264,7 @@ void NoteDisplay::Load( int iColNum, const PlayerState* pPlayerState, float fYRe m_TapNote.Load( sButton, "tap note" ); m_TapAddition.Load( sButton, "tap addition" ); m_TapMine.Load( sButton, "tap mine" ); + m_TapLift.Load( sButton, "tap lift" ); FOREACH_HoldType( ht ) { @@ -361,6 +365,19 @@ Actor * NoteDisplay::GetTapMineActor( float fNoteBeat ) return pActorOut; } +Actor * NoteDisplay::GetTapLiftActor( float fNoteBeat ) +{ + Actor *pActorOut = m_TapLift.Get(); + + SetActiveFrame( + fNoteBeat, + *pActorOut, + cache->m_fAnimationLengthInBeats[NotePart_Lift], + cache->m_bAnimationIsVivid[NotePart_Mine] ); + + return pActorOut; +} + Sprite * NoteDisplay::GetHoldTopCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld ) { Sprite *pSpriteOut = m_HoldTopCap[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get(); @@ -998,14 +1015,23 @@ void NoteDisplay::DrawActor( Actor* pActor, int iCol, float fBeat, float fPercen } } -void NoteDisplay::DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, bool bIsMine, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels ) +void NoteDisplay::DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, bool bIsMine, bool bIsLift, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels ) { Actor* pActor = NULL; bool bUseLighting = false; - if( bIsMine ) + NotePart part = NotePart_Tap; + + if( bIsLift ) + { + pActor = GetTapLiftActor( fBeat ); + bUseLighting = cache->m_bTapLiftUseLighting; + part = NotePart_Lift; + } + else if( bIsMine ) { pActor = GetTapMineActor( fBeat ); bUseLighting = cache->m_bTapMineUseLighting; + part = NotePart_Mine; } else if( bIsAddition ) { @@ -1023,7 +1049,7 @@ void NoteDisplay::DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bo bUseLighting = cache->m_bTapNoteUseLighting; } - DrawActor( pActor, iCol, fBeat, fPercentFadeToFail, fLife, fReverseOffsetPixels, bUseLighting, bIsMine ? NotePart_Mine : NotePart_Tap ); + DrawActor( pActor, iCol, fBeat, fPercentFadeToFail, fLife, fReverseOffsetPixels, bUseLighting, part ); } /* diff --git a/stepmania/src/NoteDisplay.h b/stepmania/src/NoteDisplay.h index 1e20c84618..a8d4801b85 100644 --- a/stepmania/src/NoteDisplay.h +++ b/stepmania/src/NoteDisplay.h @@ -16,6 +16,7 @@ enum NotePart NotePart_Tap, NotePart_Addition, NotePart_Mine, + NotePart_Lift, NotePart_HoldHead, NotePart_HoldTail, NotePart_HoldTopCap, @@ -74,7 +75,7 @@ public: static void Update( float fDeltaTime ); void DrawActor( Actor* pActor, int iCol, float fBeat, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels, bool bUseLighting, NotePart part ); - void DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, bool bIsMine, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels ); + void DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, bool bIsMine, bool bIsLift, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels ); void DrawHold( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, float fPercentFadeToFail, bool bDrawGlowOnly, float fReverseOffsetPixels, float fYStartOffset, float fYEndOffset ); bool DrawHoldHeadForTapsOnSameRow() const; @@ -84,6 +85,7 @@ protected: Actor *GetTapNoteActor( float fNoteBeat ); Actor *GetTapAdditionActor( float fNoteBeat ); Actor *GetTapMineActor( float fNoteBeat ); + Actor *GetTapLiftActor( float fNoteBeat ); Actor *GetHoldHeadActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld ); Actor *GetHoldTailActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld ); Sprite *GetHoldTopCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld ); @@ -103,12 +105,13 @@ protected: NoteColorActor m_TapNote; NoteColorActor m_TapAddition; NoteColorActor m_TapMine; + NoteColorActor m_TapLift; NoteColorActor m_HoldHead[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES]; NoteColorSprite m_HoldTopCap[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES]; NoteColorSprite m_HoldBody[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES]; NoteColorSprite m_HoldBottomCap[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES]; NoteColorActor m_HoldTail[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES]; - float m_fYReverseOffsetPixels; + float m_fYReverseOffsetPixels; }; #endif diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 71ada48a68..11a65b016f 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -773,6 +773,7 @@ void NoteField::DrawPrimitives() bool bIsAddition = (tn.source == TapNote::addition); bool bIsMine = (tn.type == TapNote::mine); bool bIsAttack = (tn.type == TapNote::attack); + bool bIsLift = (tn.type == TapNote::lift); NoteDisplayCols *displayCols = tn.pn == PLAYER_INVALID ? m_pCurDisplay : m_pDisplays[tn.pn]; if( bIsAttack ) @@ -784,7 +785,7 @@ void NoteField::DrawPrimitives() } else { - displayCols->display[c].DrawTap( c, NoteRowToBeat(i), bHoldNoteBeginsOnThisBeat, bIsAddition, bIsMine, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, 1, m_fYReverseOffsetPixels ); + displayCols->display[c].DrawTap( c, NoteRowToBeat(i), bHoldNoteBeginsOnThisBeat, bIsAddition, bIsMine, bIsLift, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, 1, m_fYReverseOffsetPixels ); } } } diff --git a/stepmania/src/NoteTypes.cpp b/stepmania/src/NoteTypes.cpp index 3e24ed3cf6..c07c404653 100644 --- a/stepmania/src/NoteTypes.cpp +++ b/stepmania/src/NoteTypes.cpp @@ -8,6 +8,7 @@ TapNote TAP_EMPTY ( TapNote::empty, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); TapNote TAP_ORIGINAL_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); +TapNote TAP_ORIGINAL_LIFT ( TapNote::lift, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); TapNote TAP_ORIGINAL_HOLD_HEAD ( TapNote::hold_head, TapNote::hold_head_hold, TapNote::original, "", 0, -1 ); TapNote TAP_ORIGINAL_ROLL_HEAD ( TapNote::hold_head, TapNote::hold_head_roll, TapNote::original, "", 0, -1 ); TapNote TAP_ORIGINAL_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::original, "", 0, -1 ); diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index 7726342460..50970385ed 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -59,6 +59,7 @@ struct TapNote hold_head, // graded like a tap hold_tail, // in 2sand3s mode, holds are deleted and hold_tail is added mine, // don't step! + lift, // up attack, autoKeysound, }; @@ -153,6 +154,7 @@ extern TapNote TAP_ORIGINAL_TAP; // '1' extern TapNote TAP_ORIGINAL_HOLD_HEAD; // '2' extern TapNote TAP_ORIGINAL_ROLL_HEAD; // '4' extern TapNote TAP_ORIGINAL_MINE; // 'M' +extern TapNote TAP_ORIGINAL_LIFT; // 'L' extern TapNote TAP_ORIGINAL_ATTACK; // 'A' extern TapNote TAP_ORIGINAL_AUTO_KEYSOUND; // 'K' extern TapNote TAP_ADDITION_TAP; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 223828b4fe..9e324423a3 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -1095,33 +1095,29 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele switch( m_pPlayerState->m_PlayerController ) { case PC_HUMAN: - if( !bRelease ) + switch( tn.type ) { - switch( tn.type ) + case TapNote::mine: + // Stepped too close to mine? + if( !bRelease && fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Mine) ) + score = TNS_HitMine; + break; + + case TapNote::attack: + if( !bRelease && fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Attack) && !tn.result.bHidden ) + score = TNS_W2; /* sentinel */ + break; + + default: + if( (tn.type == TapNote::lift) == bRelease ) { - case TapNote::mine: - // stepped too close to mine? - if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Mine) ) - score = TNS_HitMine; - break; - - case TapNote::attack: - if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_Attack) && !tn.result.bHidden ) - score = TNS_W2; /* sentinel */ - break; - default: if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W1) ) score = TNS_W1; else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W2) ) score = TNS_W2; else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W3) ) score = TNS_W3; else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W4) ) score = TNS_W4; else if( fSecondsFromExact <= ADJUSTED_WINDOW_SECONDS(TW_W5) ) score = TNS_W5; - else score = TNS_None; - break; } - } - else - { - // XXX: + break; } break; @@ -1418,7 +1414,7 @@ void Player::UpdateJudgedRows() if( m_pCombinedLifeMeter ) m_pCombinedLifeMeter->ChangeLife( pn, tn.result.tns ); - //Make sure hit mines affect the dance points + // Make sure hit mines affect the dance points. if( m_pPrimaryScoreKeeper ) m_pPrimaryScoreKeeper->HandleTapScore( tn ); if( m_pSecondaryScoreKeeper )