src\NoteDisplay.cpp

This commit is contained in:
AJ Kelly
2011-03-02 16:37:20 -06:00
parent 387bb95745
commit d750f2a1e8
3 changed files with 49 additions and 46 deletions
+36 -36
View File
@@ -247,21 +247,21 @@ void NoteDisplay::Load( int iColNum, const PlayerState* pPlayerState, float fYRe
cache->Load( sButton ); cache->Load( sButton );
// "normal" note types // "normal" note types
m_TapNote.Load( sButton, "Tap Note" ); m_TapNote.Load( sButton, "Tap Note" );
m_TapMine.Load( sButton, "Tap Mine" ); m_TapMine.Load( sButton, "Tap Mine" );
m_TapLift.Load( sButton, "Tap Lift" ); m_TapLift.Load( sButton, "Tap Lift" );
m_TapFake.Load( sButton, "Tap Fake" ); m_TapFake.Load( sButton, "Tap Fake" );
// hold types // hold types
FOREACH_HoldType( ht ) FOREACH_HoldType( ht )
{ {
FOREACH_ActiveType( at ) FOREACH_ActiveType( at )
{ {
m_HoldHead[ht][at].Load( sButton, HoldTypeToString(ht)+" Head "+ActiveTypeToString(at) ); m_HoldHead[ht][at].Load( sButton, HoldTypeToString(ht)+" Head "+ActiveTypeToString(at) );
m_HoldTopCap[ht][at].Load( sButton, HoldTypeToString(ht)+" Topcap "+ActiveTypeToString(at) ); m_HoldTopCap[ht][at].Load( sButton, HoldTypeToString(ht)+" Topcap "+ActiveTypeToString(at) );
m_HoldBody[ht][at].Load( sButton, HoldTypeToString(ht)+" Body "+ActiveTypeToString(at) ); m_HoldBody[ht][at].Load( sButton, HoldTypeToString(ht)+" Body "+ActiveTypeToString(at) );
m_HoldBottomCap[ht][at].Load( sButton, HoldTypeToString(ht)+" Bottomcap "+ActiveTypeToString(at) ); m_HoldBottomCap[ht][at].Load( sButton, HoldTypeToString(ht)+" Bottomcap "+ActiveTypeToString(at) );
m_HoldTail[ht][at].Load( sButton, HoldTypeToString(ht)+" Tail "+ActiveTypeToString(at) ); m_HoldTail[ht][at].Load( sButton, HoldTypeToString(ht)+" Tail "+ActiveTypeToString(at) );
} }
} }
} }
@@ -274,7 +274,7 @@ bool NoteDisplay::DrawHoldHeadForTapsOnSameRow() const
void NoteDisplay::Update( float fDeltaTime ) void NoteDisplay::Update( float fDeltaTime )
{ {
/* This function is static: it's called once per game loop, not once per /* This function is static: it's called once per game loop, not once per
* NoteDisplay. Update each cached item exactly once. */ * NoteDisplay. Update each cached item exactly once. */
map<NoteSkinAndPath, NoteResource *>::iterator it; map<NoteSkinAndPath, NoteResource *>::iterator it;
for( it = g_NoteResource.begin(); it != g_NoteResource.end(); ++it ) for( it = g_NoteResource.begin(); it != g_NoteResource.end(); ++it )
{ {
@@ -285,11 +285,11 @@ void NoteDisplay::Update( float fDeltaTime )
void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAnimationLength, bool bVivid ) void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAnimationLength, bool bVivid )
{ {
/* -inf ... inf */ // -inf ... inf
float fBeatOrSecond = cache->m_bAnimationBasedOnBeats ? GAMESTATE->m_fSongBeat : GAMESTATE->m_fMusicSeconds; float fBeatOrSecond = cache->m_bAnimationBasedOnBeats ? GAMESTATE->m_fSongBeat : GAMESTATE->m_fMusicSeconds;
/* -len ... +len */ // -len ... +len
float fPercentIntoAnimation = fmodf( fBeatOrSecond, fAnimationLength ); float fPercentIntoAnimation = fmodf( fBeatOrSecond, fAnimationLength );
/* -1 ... 1 */ // -1 ... 1
fPercentIntoAnimation /= fAnimationLength; fPercentIntoAnimation /= fAnimationLength;
if( bVivid ) if( bVivid )
@@ -304,7 +304,7 @@ void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAni
} }
else else
{ {
/* 0 ... 1, wrapped */ // 0 ... 1, wrapped
if( fPercentIntoAnimation < 0 ) if( fPercentIntoAnimation < 0 )
fPercentIntoAnimation += 1.0f; fPercentIntoAnimation += 1.0f;
} }
@@ -393,8 +393,8 @@ void NoteDisplay::DrawHoldPart( vector<Sprite*> &vpSpr, int iCol, int fYStep, fl
const float fFrameWidth = pSprite->GetZoomedWidth(); const float fFrameWidth = pSprite->GetZoomedWidth();
const float fFrameHeight = pSprite->GetZoomedHeight(); const float fFrameHeight = pSprite->GetZoomedHeight();
/* Only draw the section that's within the range specified. If a hold note is /* Only draw the section that's within the range specified. If a hold note is
* very long, don't process or draw the part outside of the range. Don't change * very long, don't process or draw the part outside of the range. Don't change
* fYTop or fYBottom; they need to be left alone to calculate texture coordinates. */ * fYTop or fYBottom; they need to be left alone to calculate texture coordinates. */
fYStartPos = max( fYTop, fYStartPos ); fYStartPos = max( fYTop, fYStartPos );
fYEndPos = min( fYBottom, fYEndPos ); fYEndPos = min( fYBottom, fYEndPos );
@@ -416,8 +416,8 @@ void NoteDisplay::DrawHoldPart( vector<Sprite*> &vpSpr, int iCol, int fYStep, fl
if( bWrapping ) if( bWrapping )
{ {
/* For very large hold notes, shift the texture coordinates to be near 0, so we /* For very large hold notes, shift the texture coordinates to be near 0,
* don't send very large values to the renderer. */ * so we don't send very large values to the renderer. */
const float fDistFromTop = fYStartPos - fYTop; const float fDistFromTop = fYStartPos - fYTop;
float fTexCoordTop = SCALE( fDistFromTop, 0, fFrameHeight, rect.top, rect.bottom ); float fTexCoordTop = SCALE( fDistFromTop, 0, fFrameHeight, rect.top, rect.bottom );
fTexCoordTop += fAddToTexCoord; fTexCoordTop += fAddToTexCoord;
@@ -479,8 +479,8 @@ void NoteDisplay::DrawHoldPart( vector<Sprite*> &vpSpr, int iCol, int fYStep, fl
if( queue.Free() < 3 || bLast ) if( queue.Free() < 3 || bLast )
{ {
/* The queue is full. Render it, clear the buffer, and move back a step to /* The queue is full. Render it, clear the buffer, and move back
* start off the strip again. */ * a step to start off the strip again. */
if( !bAllAreTransparent ) if( !bAllAreTransparent )
{ {
FOREACH( Sprite*, vpSpr, spr ) FOREACH( Sprite*, vpSpr, spr )
@@ -542,8 +542,8 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b
DISPLAY->SetZTestMode( bWavyPartsNeedZBuffer?ZTEST_WRITE_ON_PASS:ZTEST_OFF ); DISPLAY->SetZTestMode( bWavyPartsNeedZBuffer?ZTEST_WRITE_ON_PASS:ZTEST_OFF );
DISPLAY->SetZWrite( bWavyPartsNeedZBuffer ); DISPLAY->SetZWrite( bWavyPartsNeedZBuffer );
/* Hack: Z effects need a finer grain step. */ // Hack: Z effects need a finer grain step.
const int fYStep = bWavyPartsNeedZBuffer? 4: 16; // use small steps only if wavy const int fYStep = bWavyPartsNeedZBuffer? 4: 16; // use small steps only if wavy
if( bFlipHoldBody ) if( bFlipHoldBody )
{ {
@@ -610,9 +610,9 @@ void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iRow, bool bIsBeing
// HACK: If life > 0, don't set YOffset to 0 so that it doesn't jiggle around the receptor. // HACK: If life > 0, don't set YOffset to 0 so that it doesn't jiggle around the receptor.
bool bStartIsPastPeak = true; bool bStartIsPastPeak = true;
float fStartYOffset = 0; float fStartYOffset = 0;
if( tn.HoldResult.bActive && tn.HoldResult.fLife > 0 ) if( tn.HoldResult.bActive && tn.HoldResult.fLife > 0 )
; // use the default values filled in above ; // use the default values filled in above
else else
fStartYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fStartBeat, fThrowAway, bStartIsPastPeak ); fStartYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fStartBeat, fThrowAway, bStartIsPastPeak );
@@ -641,23 +641,23 @@ void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iRow, bool bIsBeing
/* The body and caps should have no overlap, so their order doesn't matter. /* The body and caps should have no overlap, so their order doesn't matter.
* Draw the head last, so it appears on top. */ * Draw the head last, so it appears on top. */
float fBeat = NoteRowToBeat(iRow); float fBeat = NoteRowToBeat(iRow);
//if( !cache->m_bHoldHeadIsAboveWavyParts ) /*
//{ if( !cache->m_bHoldHeadIsAboveWavyParts )
// Actor *pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld ); {
// DrawActor( tn, pActor, NotePart_HoldHead, iCol, bFlipHeadAndTail ? fEndYOffset : fStartYOffset, fBeat, bIsAddition, fPercentFadeToFail, fReverseOffsetPixels, fColorScale, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); Actor *pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
//} DrawActor( tn, pActor, NotePart_HoldHead, iCol, bFlipHeadAndTail ? fEndYOffset : fStartYOffset, fBeat, bIsAddition, fPercentFadeToFail, fReverseOffsetPixels, fColorScale, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
//if( !cache->m_bHoldTailIsAboveWavyParts ) }
//{ if( !cache->m_bHoldTailIsAboveWavyParts )
// Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld ); {
// DrawActor( tn, pActor, NotePart_HoldTail, iCol, bFlipHeadAndTail ? fStartYOffset : fEndYOffset, fBeat, bIsAddition, fPercentFadeToFail, fReverseOffsetPixels, fColorScale, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
//} DrawActor( tn, pActor, NotePart_HoldTail, iCol, bFlipHeadAndTail ? fStartYOffset : fEndYOffset, fBeat, bIsAddition, fPercentFadeToFail, fReverseOffsetPixels, fColorScale, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
}
*/
DrawHoldBody( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, bIsAddition, fPercentFadeToFail, fColorScale, false, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); DrawHoldBody( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, bIsAddition, fPercentFadeToFail, fColorScale, false, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
DrawHoldBody( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, bIsAddition, fPercentFadeToFail, fColorScale, true, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); DrawHoldBody( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, bIsAddition, fPercentFadeToFail, fColorScale, true, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
/* These set the texture mode themselves. */ // These set the texture mode themselves.
// this part was modified in pumpmania, where it flips the draw order
// of the head and tail. Perhaps make this a theme/noteskin metric? -aj
if( cache->m_bHoldTailIsAboveWavyParts ) if( cache->m_bHoldTailIsAboveWavyParts )
{ {
Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld ); Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
+7 -2
View File
@@ -5,6 +5,7 @@
#include "RageLog.h" #include "RageLog.h"
#include "RadarValues.h" #include "RadarValues.h"
#include "Steps.h" #include "Steps.h"
#include "NoteSkinManager.h"
PlayerState::PlayerState() PlayerState::PlayerState()
{ {
@@ -28,6 +29,9 @@ void PlayerState::Reset()
m_iCpuSkill = 5; m_iCpuSkill = 5;
m_iNoteSkinColSpacing = 0;
m_iNoteSkinArrowSize = 0;
m_iLastPositiveSumOfAttackLevels = 0; m_iLastPositiveSumOfAttackLevels = 0;
m_fSecondsUntilAttacksPhasedOut = 0; m_fSecondsUntilAttacksPhasedOut = 0;
m_bAttackBeganThisUpdate = false; m_bAttackBeganThisUpdate = false;
@@ -189,9 +193,10 @@ int PlayerState::GetSumOfActiveAttackLevels() const
return iSum; return iSum;
} }
/*
void PlayerState::LoadNoteSkinMetrics() void PlayerState::LoadNoteSkinMetrics()
{ {
/*
// Read metrics from current noteskin for setting row/col spacing and // Read metrics from current noteskin for setting row/col spacing and
// arrow size (originally from StepMania AMX) // arrow size (originally from StepMania AMX)
@@ -206,8 +211,8 @@ void PlayerState::LoadNoteSkinMetrics()
// todo: allow per-column spacing values? -aj // todo: allow per-column spacing values? -aj
m_iNoteSkinColSpacing = NOTESKIN->GetMetricI( m_sNoteSkin, sStepsType, "ColSpacing" ); m_iNoteSkinColSpacing = NOTESKIN->GetMetricI( m_sNoteSkin, sStepsType, "ColSpacing" );
m_iNoteSkinArrowSize = NOTESKIN->GetMetricI( m_sNoteSkin, sStepsType, "ArrowSize" ); m_iNoteSkinArrowSize = NOTESKIN->GetMetricI( m_sNoteSkin, sStepsType, "ArrowSize" );
*/
} }
*/
// lua start // lua start
#include "LuaBinding.h" #include "LuaBinding.h"
-2
View File
@@ -47,11 +47,9 @@ public:
ModsGroup<PlayerOptions> m_PlayerOptions; ModsGroup<PlayerOptions> m_PlayerOptions;
// Metricable noteskin things // Metricable noteskin things
/*
void LoadNoteSkinMetrics(); void LoadNoteSkinMetrics();
int m_iNoteSkinColSpacing; int m_iNoteSkinColSpacing;
int m_iNoteSkinArrowSize; int m_iNoteSkinArrowSize;
*/
// not sure I want to let noteskins change row spacing, as that changes how // not sure I want to let noteskins change row spacing, as that changes how
// the speed mods work... -aj // the speed mods work... -aj
//int m_iNoteSkinRowSpacing; //int m_iNoteSkinRowSpacing;