store a current NoteSkin in NoteSkinManager so that NoteSkin elements can use NOTESKIN:GetPath()

This commit is contained in:
Chris Danford
2005-04-18 01:19:56 +00:00
parent 299e0a8f1a
commit abac6af93b
17 changed files with 281 additions and 204 deletions
+3 -4
View File
@@ -7,7 +7,7 @@ GhostArrow::GhostArrow()
{ {
} }
void GhostArrow::Load( CString sNoteSkin, CString sButton, CString sElement ) void GhostArrow::Load( const CString &sButton, const CString &sElement )
{ {
FOREACH_TapNoteScore( i ) FOREACH_TapNoteScore( i )
{ {
@@ -17,7 +17,7 @@ void GhostArrow::Load( CString sNoteSkin, CString sButton, CString sElement )
ASSERT( !m_spr[i].IsLoaded() ); // don't double-load ASSERT( !m_spr[i].IsLoaded() ); // don't double-load
m_spr[i].Load( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sFullElement) ); m_spr[i].Load( NOTESKIN->GetPath(sButton, sFullElement) );
m_spr[i]->SetHidden( true ); m_spr[i]->SetHidden( true );
this->AddChild( m_spr[i] ); this->AddChild( m_spr[i] );
} }
@@ -26,8 +26,7 @@ void GhostArrow::Load( CString sNoteSkin, CString sButton, CString sElement )
{ {
CString sJudge = TapNoteScoreToString( i ); CString sJudge = TapNoteScoreToString( i );
CString sCommand = Capitalize(sJudge)+"Command"; CString sCommand = Capitalize(sJudge)+"Command";
apActorCommands p( new ActorCommands(NOTESKIN->GetMetric(sNoteSkin,m_sName,sCommand)) ); m_acScoreCommand[i] = NOTESKIN->GetMetricA(m_sName,sCommand);
m_acScoreCommand[i] = p;
} }
} }
+1 -1
View File
@@ -14,7 +14,7 @@ class GhostArrow : public ActorFrame
public: public:
GhostArrow(); GhostArrow();
void Load( CString sNoteSkin, CString sButton, CString sFile ); void Load( const CString &sButton, const CString &sFile );
void Step( TapNoteScore score ); void Step( TapNoteScore score );
+5 -5
View File
@@ -18,7 +18,7 @@ GhostArrowRow::GhostArrowRow()
m_iNumCols = 0; m_iNumCols = 0;
} }
void GhostArrowRow::Load( const PlayerState* pPlayerState, CString NoteSkin, float fYReverseOffset ) void GhostArrowRow::Load( const PlayerState* pPlayerState, float fYReverseOffset )
{ {
Unload(); Unload();
@@ -32,7 +32,7 @@ void GhostArrowRow::Load( const PlayerState* pPlayerState, CString NoteSkin, flo
// init arrows // init arrows
for( int c=0; c<m_iNumCols; c++ ) for( int c=0; c<m_iNumCols; c++ )
{ {
CString Button = GAMESTATE->GetCurrentGame()->ColToButtonName( c ); const CString &sButton = GAMESTATE->GetCurrentGame()->ColToButtonName( c );
m_GhostDim.push_back( new GhostArrow ); m_GhostDim.push_back( new GhostArrow );
m_GhostBright.push_back( new GhostArrow ); m_GhostBright.push_back( new GhostArrow );
@@ -42,9 +42,9 @@ void GhostArrowRow::Load( const PlayerState* pPlayerState, CString NoteSkin, flo
m_GhostBright[c]->SetName( "GhostArrowBright" ); m_GhostBright[c]->SetName( "GhostArrowBright" );
m_HoldGhost[c]->SetName( "HoldGhostArrow" ); m_HoldGhost[c]->SetName( "HoldGhostArrow" );
m_GhostDim[c]->Load( NoteSkin, Button, "tap explosion dim" ); m_GhostDim[c]->Load( sButton, "tap explosion dim" );
m_GhostBright[c]->Load( NoteSkin, Button, "tap explosion bright" ); m_GhostBright[c]->Load( sButton, "tap explosion bright" );
m_HoldGhost[c]->Load( NoteSkin, Button, "hold explosion" ); m_HoldGhost[c]->Load( sButton, "hold explosion" );
} }
} }
+1 -1
View File
@@ -19,7 +19,7 @@ public:
virtual void DrawPrimitives(); virtual void DrawPrimitives();
virtual void CopyTweening( const GhostArrowRow &from ); virtual void CopyTweening( const GhostArrowRow &from );
void Load( const PlayerState* pPlayerState, CString NoteSkin, float fYReverseOffset ); void Load( const PlayerState* pPlayerState, float fYReverseOffset );
void Unload(); void Unload();
void DidTapNote( int iCol, TapNoteScore score, bool bBright ); void DidTapNote( int iCol, TapNoteScore score, bool bBright );
+5 -3
View File
@@ -2,15 +2,17 @@
#include "HoldGhostArrow.h" #include "HoldGhostArrow.h"
#include "NoteSkinManager.h" #include "NoteSkinManager.h"
HoldGhostArrow::HoldGhostArrow() HoldGhostArrow::HoldGhostArrow()
{ {
m_bHoldIsActive = false; m_bHoldIsActive = false;
} }
void HoldGhostArrow::Load( CString sNoteSkin, CString sButton, CString sElement ) void HoldGhostArrow::Load( const CString &sButton, const CString &sElement )
{ {
Sprite::Load( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sElement) ); // not optional Sprite::Load( NOTESKIN->GetPath(sButton, sElement) ); // not optional
this->RunCommands( ActorCommands(NOTESKIN->GetMetric(sNoteSkin,"HoldGhostArrow","OnCommand")) ); this->RunCommands( NOTESKIN->GetMetricA("HoldGhostArrow","OnCommand") );
} }
void HoldGhostArrow::Update( float fDeltaTime ) void HoldGhostArrow::Update( float fDeltaTime )
+1 -1
View File
@@ -10,7 +10,7 @@ class HoldGhostArrow : public Sprite
public: public:
HoldGhostArrow(); HoldGhostArrow();
virtual void Load( CString sNoteSkin, CString sButton, CString sElement ); virtual void Load( const CString &sButton, const CString &sElement );
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
virtual bool EarlyAbortDraw() { return !m_bHoldIsActive; } virtual bool EarlyAbortDraw() { return !m_bHoldIsActive; }
+131 -98
View File
@@ -48,55 +48,72 @@ struct NoteMetricCache_t
bool m_bHoldTailUseLighting; bool m_bHoldTailUseLighting;
bool m_bFlipHeadAndTailWhenReverse; bool m_bFlipHeadAndTailWhenReverse;
void Load(CString skin, const CString &name); void Load( const CString &sButton );
} *NoteMetricCache; } *NoteMetricCache;
void NoteMetricCache_t::Load(CString skin, const CString &name) void NoteMetricCache_t::Load( const CString &sButton )
{ {
m_bDrawHoldHeadForTapsOnSameRow = NOTESKIN->GetMetricB(skin,name,"DrawHoldHeadForTapsOnSameRow"); m_bDrawHoldHeadForTapsOnSameRow = NOTESKIN->GetMetricB(sButton,"DrawHoldHeadForTapsOnSameRow");
m_fAnimationLengthInBeats[PART_TAP] = NOTESKIN->GetMetricF(skin,name,"TapNoteAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_TAP] = NOTESKIN->GetMetricF(sButton,"TapNoteAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_ADDITION] = NOTESKIN->GetMetricF(skin,name,"TapAdditionAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_ADDITION] = NOTESKIN->GetMetricF(sButton,"TapAdditionAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_MINE] = NOTESKIN->GetMetricF(skin,name,"TapMineAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_MINE] = NOTESKIN->GetMetricF(sButton,"TapMineAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_HOLD_HEAD] = NOTESKIN->GetMetricF(skin,name,"HoldHeadAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_HOLD_HEAD] = NOTESKIN->GetMetricF(sButton,"HoldHeadAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_HOLD_TOP_CAP] = NOTESKIN->GetMetricF(skin,name,"HoldTopCapAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_HOLD_TOP_CAP] = NOTESKIN->GetMetricF(sButton,"HoldTopCapAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_HOLD_BODY] = NOTESKIN->GetMetricF(skin,name,"HoldBodyAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_HOLD_BODY] = NOTESKIN->GetMetricF(sButton,"HoldBodyAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_HOLD_BOTTOM_CAP] = NOTESKIN->GetMetricF(skin,name,"HoldBottomCapAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_HOLD_BOTTOM_CAP]=NOTESKIN->GetMetricF(sButton,"HoldBottomCapAnimationLengthInBeats");
m_fAnimationLengthInBeats[PART_HOLD_TAIL] = NOTESKIN->GetMetricF(skin,name,"HoldTailAnimationLengthInBeats"); m_fAnimationLengthInBeats[PART_HOLD_TAIL] = NOTESKIN->GetMetricF(sButton,"HoldTailAnimationLengthInBeats");
m_bAnimationIsVivid[PART_TAP] = NOTESKIN->GetMetricB(skin,name,"TapNoteAnimationIsVivid"); m_bAnimationIsVivid[PART_TAP] = NOTESKIN->GetMetricB(sButton,"TapNoteAnimationIsVivid");
m_bAnimationIsVivid[PART_ADDITION] = NOTESKIN->GetMetricB(skin,name,"TapAdditionAnimationIsVivid"); m_bAnimationIsVivid[PART_ADDITION] = NOTESKIN->GetMetricB(sButton,"TapAdditionAnimationIsVivid");
m_bAnimationIsVivid[PART_MINE] = NOTESKIN->GetMetricB(skin,name,"TapMineAnimationIsVivid"); m_bAnimationIsVivid[PART_MINE] = NOTESKIN->GetMetricB(sButton,"TapMineAnimationIsVivid");
m_bAnimationIsVivid[PART_HOLD_HEAD] = NOTESKIN->GetMetricB(skin,name,"HoldHeadAnimationIsVivid"); m_bAnimationIsVivid[PART_HOLD_HEAD] = NOTESKIN->GetMetricB(sButton,"HoldHeadAnimationIsVivid");
m_bAnimationIsVivid[PART_HOLD_TOP_CAP] = NOTESKIN->GetMetricB(skin,name,"HoldTopCapAnimationIsVivid"); m_bAnimationIsVivid[PART_HOLD_TOP_CAP] = NOTESKIN->GetMetricB(sButton,"HoldTopCapAnimationIsVivid");
m_bAnimationIsVivid[PART_HOLD_BODY] = NOTESKIN->GetMetricB(skin,name,"HoldBodyAnimationIsVivid"); m_bAnimationIsVivid[PART_HOLD_BODY] = NOTESKIN->GetMetricB(sButton,"HoldBodyAnimationIsVivid");
m_bAnimationIsVivid[PART_HOLD_BOTTOM_CAP] = NOTESKIN->GetMetricB(skin,name,"HoldBottomCapAnimationIsVivid"); m_bAnimationIsVivid[PART_HOLD_BOTTOM_CAP] = NOTESKIN->GetMetricB(sButton,"HoldBottomCapAnimationIsVivid");
m_bAnimationIsVivid[PART_HOLD_TAIL] = NOTESKIN->GetMetricB(skin,name,"HoldTailAnimationIsVivid"); m_bAnimationIsVivid[PART_HOLD_TAIL] = NOTESKIN->GetMetricB(sButton,"HoldTailAnimationIsVivid");
m_bAnimationIsNoteColor[PART_TAP] = NOTESKIN->GetMetricB(skin,name,"TapNoteAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_TAP] = NOTESKIN->GetMetricB(sButton,"TapNoteAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_ADDITION] = NOTESKIN->GetMetricB(skin,name,"TapAdditionAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_ADDITION] = NOTESKIN->GetMetricB(sButton,"TapAdditionAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_MINE] = NOTESKIN->GetMetricB(skin,name,"TapMineAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_MINE] = NOTESKIN->GetMetricB(sButton,"TapMineAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_HOLD_HEAD] = NOTESKIN->GetMetricB(skin,name,"HoldHeadAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_HOLD_HEAD] = NOTESKIN->GetMetricB(sButton,"HoldHeadAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_HOLD_TOP_CAP] =NOTESKIN->GetMetricB(skin,name,"HoldTopCapAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_HOLD_TOP_CAP] = NOTESKIN->GetMetricB(sButton,"HoldTopCapAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_HOLD_BODY] = NOTESKIN->GetMetricB(skin,name,"HoldBodyAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_HOLD_BODY] = NOTESKIN->GetMetricB(sButton,"HoldBodyAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_HOLD_BOTTOM_CAP] = NOTESKIN->GetMetricB(skin,name,"HoldBottomCapAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_HOLD_BOTTOM_CAP] = NOTESKIN->GetMetricB(sButton,"HoldBottomCapAnimationIsNoteColor");
m_bAnimationIsNoteColor[PART_HOLD_TAIL] = NOTESKIN->GetMetricB(skin,name,"HoldTailAnimationIsNoteColor"); m_bAnimationIsNoteColor[PART_HOLD_TAIL] = NOTESKIN->GetMetricB(sButton,"HoldTailAnimationIsNoteColor");
m_bHoldHeadIsAboveWavyParts = NOTESKIN->GetMetricB(skin,name,"HoldHeadIsAboveWavyParts"); m_bHoldHeadIsAboveWavyParts = NOTESKIN->GetMetricB(sButton,"HoldHeadIsAboveWavyParts");
m_bHoldTailIsAboveWavyParts = NOTESKIN->GetMetricB(skin,name,"HoldTailIsAboveWavyParts"); m_bHoldTailIsAboveWavyParts = NOTESKIN->GetMetricB(sButton,"HoldTailIsAboveWavyParts");
m_iStartDrawingHoldBodyOffsetFromHead = NOTESKIN->GetMetricI(skin,name,"StartDrawingHoldBodyOffsetFromHead"); m_iStartDrawingHoldBodyOffsetFromHead = NOTESKIN->GetMetricI(sButton,"StartDrawingHoldBodyOffsetFromHead");
m_iStopDrawingHoldBodyOffsetFromTail = NOTESKIN->GetMetricI(skin,name,"StopDrawingHoldBodyOffsetFromTail"); m_iStopDrawingHoldBodyOffsetFromTail = NOTESKIN->GetMetricI(sButton,"StopDrawingHoldBodyOffsetFromTail");
m_fHoldNGGrayPercent = NOTESKIN->GetMetricF(skin,name,"HoldNGGrayPercent"); m_fHoldNGGrayPercent = NOTESKIN->GetMetricF(sButton,"HoldNGGrayPercent");
m_bTapNoteUseLighting = NOTESKIN->GetMetricB(skin,name,"TapNoteUseLighting"); m_bTapNoteUseLighting = NOTESKIN->GetMetricB(sButton,"TapNoteUseLighting");
m_bTapAdditionUseLighting = NOTESKIN->GetMetricB(skin,name,"TapAdditionUseLighting"); m_bTapAdditionUseLighting = NOTESKIN->GetMetricB(sButton,"TapAdditionUseLighting");
m_bTapMineUseLighting = NOTESKIN->GetMetricB(skin,name,"TapMineUseLighting"); m_bTapMineUseLighting = NOTESKIN->GetMetricB(sButton,"TapMineUseLighting");
m_bHoldHeadUseLighting = NOTESKIN->GetMetricB(skin,name,"HoldHeadUseLighting"); m_bHoldHeadUseLighting = NOTESKIN->GetMetricB(sButton,"HoldHeadUseLighting");
m_bHoldTailUseLighting = NOTESKIN->GetMetricB(skin,name,"HoldTailUseLighting"); m_bHoldTailUseLighting = NOTESKIN->GetMetricB(sButton,"HoldTailUseLighting");
m_bFlipHeadAndTailWhenReverse = NOTESKIN->GetMetricB(skin,name,"FlipHeadAndTailWhenReverse"); m_bFlipHeadAndTailWhenReverse = NOTESKIN->GetMetricB(sButton,"FlipHeadAndTailWhenReverse");
} }
struct NoteSkinAndPath
{
NoteSkinAndPath( const CString sNoteSkin_, const CString sPath_ ) { sNoteSkin = sNoteSkin_; sPath = sPath_; }
CString sNoteSkin;
CString sPath;
bool operator<( const NoteSkinAndPath &other ) const
{
switch( strcmp(sNoteSkin, other.sNoteSkin) )
{
case -1: return true;
case 0: return sPath < other.sPath;
case 1: return false;
default: ASSERT(0); return false;
}
}
};
struct NoteResource struct NoteResource
{ {
NoteResource( CString sPath ): m_sPath(sPath) NoteResource( const NoteSkinAndPath &nsap ): m_nsap(nsap)
{ {
m_iRefCount = 0; m_iRefCount = 0;
m_pActor = NULL; m_pActor = NULL;
@@ -107,33 +124,33 @@ struct NoteResource
delete m_pActor; delete m_pActor;
} }
const CString m_sPath; /* should be refcounted along with g_NoteResource[] */ const NoteSkinAndPath m_nsap; /* should be refcounted along with g_NoteResource[] */
int m_iRefCount; int m_iRefCount;
Actor *m_pActor; Actor *m_pActor;
}; };
static map<CString, NoteResource *> g_NoteResource; static map<NoteSkinAndPath, NoteResource *> g_NoteResource;
static NoteResource *MakeNoteResource( const CString &sPath, bool bSpriteOnly ) static NoteResource *MakeNoteResource( const NoteSkinAndPath &nsap, bool bSpriteOnly )
{ {
map<CString, NoteResource *>::iterator it = g_NoteResource.find( sPath ); map<NoteSkinAndPath, NoteResource *>::iterator it = g_NoteResource.find( nsap );
if( it == g_NoteResource.end() ) if( it == g_NoteResource.end() )
{ {
NoteResource *pRes = new NoteResource( sPath ); NoteResource *pRes = new NoteResource( nsap );
if( bSpriteOnly ) if( bSpriteOnly )
{ {
Sprite *pSprite = new Sprite; Sprite *pSprite = new Sprite;
pSprite->Load( sPath ); pSprite->Load( nsap.sPath );
pRes->m_pActor = pSprite; pRes->m_pActor = pSprite;
} }
else else
{ {
pRes->m_pActor = ActorUtil::MakeActor( sPath ); pRes->m_pActor = ActorUtil::MakeActor( nsap.sPath );
ASSERT( pRes->m_pActor ); ASSERT( pRes->m_pActor );
} }
g_NoteResource[sPath] = pRes; g_NoteResource[nsap] = pRes;
it = g_NoteResource.find( sPath ); it = g_NoteResource.find( nsap );
} }
NoteResource *pRet = it->second; NoteResource *pRet = it->second;
@@ -143,7 +160,7 @@ static NoteResource *MakeNoteResource( const CString &sPath, bool bSpriteOnly )
static NoteResource *FindNoteResource( const Actor *pActor ) static NoteResource *FindNoteResource( const Actor *pActor )
{ {
map<CString, 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 )
{ {
NoteResource *pRes = it->second; NoteResource *pRes = it->second;
@@ -167,19 +184,19 @@ static void DeleteNoteResource( const Actor *pActor )
if( pRes->m_iRefCount ) if( pRes->m_iRefCount )
return; return;
g_NoteResource.erase( pRes->m_sPath ); g_NoteResource.erase( pRes->m_nsap );
delete pRes; delete pRes;
} }
Actor *MakeRefcountedActor( const CString &sPath ) Actor *MakeRefcountedActor( const NoteSkinAndPath &nsap )
{ {
NoteResource *pRes = MakeNoteResource( sPath, false ); NoteResource *pRes = MakeNoteResource( nsap, false );
return pRes->m_pActor; return pRes->m_pActor;
} }
Sprite *MakeRefcountedSprite( const CString &sPath ) Sprite *MakeRefcountedSprite( const NoteSkinAndPath &nsap )
{ {
NoteResource *pRes = MakeNoteResource( sPath, true ); NoteResource *pRes = MakeNoteResource( nsap, true );
return (Sprite *) pRes->m_pActor; /* XXX ick */ return (Sprite *) pRes->m_pActor; /* XXX ick */
} }
@@ -197,17 +214,17 @@ NoteColorActor::~NoteColorActor()
m_bIsNoteColor = false; m_bIsNoteColor = false;
} }
void NoteColorActor::Load( bool bIsNoteColor, const CString &sNoteSkin, const CString &sButton, const CString &sElement ) void NoteColorActor::Load( bool bIsNoteColor, const CString &sButton, const CString &sElement )
{ {
m_bIsNoteColor = bIsNoteColor; m_bIsNoteColor = bIsNoteColor;
if( m_bIsNoteColor ) if( m_bIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
m_p[i] = MakeRefcountedActor( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sElement+" "+NoteTypeToString((NoteType)i)) ); m_p[i] = MakeRefcountedActor( NoteSkinAndPath( NOTESKIN->GetCurrentNoteSkin(), NOTESKIN->GetPath(sButton, sElement+" "+NoteTypeToString((NoteType)i)) ) );
} }
else else
{ {
m_p[0] = MakeRefcountedActor( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sElement) ); m_p[0] = MakeRefcountedActor( NoteSkinAndPath( NOTESKIN->GetCurrentNoteSkin(), NOTESKIN->GetPath(sButton, sElement) ) );
} }
} }
@@ -237,17 +254,17 @@ NoteColorSprite::~NoteColorSprite()
m_bIsNoteColor = false; m_bIsNoteColor = false;
} }
void NoteColorSprite::Load( bool bIsNoteColor, const CString &sNoteSkin, const CString &sButton, const CString &sElement ) void NoteColorSprite::Load( bool bIsNoteColor, const CString &sButton, const CString &sElement )
{ {
m_bIsNoteColor = bIsNoteColor; m_bIsNoteColor = bIsNoteColor;
if( m_bIsNoteColor ) if( m_bIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
m_p[i] = MakeRefcountedSprite( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sElement+" "+NoteTypeToString((NoteType)i)) ); m_p[i] = MakeRefcountedSprite( NoteSkinAndPath( NOTESKIN->GetCurrentNoteSkin(), NOTESKIN->GetPath(sButton, sElement+" "+NoteTypeToString((NoteType)i)) ) );
} }
else else
{ {
m_p[0] = MakeRefcountedSprite( NOTESKIN->GetPathToFromNoteSkinAndButton(sNoteSkin, sButton, sElement) ); m_p[0] = MakeRefcountedSprite( NoteSkinAndPath( NOTESKIN->GetCurrentNoteSkin(), NOTESKIN->GetPath(sButton, sElement) ) );
} }
} }
@@ -262,6 +279,20 @@ Sprite* NoteColorSprite::Get( NoteType nt )
} }
static const CString HoldTypeNames[NUM_HOLD_TYPES] = {
"hold",
"roll",
};
XToString( HoldType, NUM_HOLD_TYPES );
static const CString ActiveTypeNames[NUM_ACTIVE_TYPES] = {
"active",
"inactive",
};
XToString( ActiveType, NUM_ACTIVE_TYPES );
NoteDisplay::NoteDisplay() NoteDisplay::NoteDisplay()
{ {
cache = new NoteMetricCache_t; cache = new NoteMetricCache_t;
@@ -272,28 +303,30 @@ NoteDisplay::~NoteDisplay()
delete cache; delete cache;
} }
void NoteDisplay::Load( int iColNum, const PlayerState* pPlayerState, const CString &sNoteSkin, float fYReverseOffsetPixels ) void NoteDisplay::Load( int iColNum, const PlayerState* pPlayerState, float fYReverseOffsetPixels )
{ {
m_pPlayerState = pPlayerState; m_pPlayerState = pPlayerState;
m_fYReverseOffsetPixels = fYReverseOffsetPixels; m_fYReverseOffsetPixels = fYReverseOffsetPixels;
CString sButton = GAMESTATE->GetCurrentGame()->ColToButtonName( iColNum ); const CString &sButton = GAMESTATE->GetCurrentGame()->ColToButtonName( iColNum );
cache->Load( sNoteSkin, sButton ); cache->Load( sButton );
m_TapNote.Load( cache->m_bAnimationIsNoteColor[PART_TAP], sNoteSkin, sButton, "tap note" ); m_TapNote.Load( cache->m_bAnimationIsNoteColor[PART_TAP], sButton, "tap note" );
m_TapAddition.Load( cache->m_bAnimationIsNoteColor[PART_ADDITION], sNoteSkin, sButton, "tap addition" ); m_TapAddition.Load( cache->m_bAnimationIsNoteColor[PART_ADDITION], sButton, "tap addition" );
m_TapMine.Load( cache->m_bAnimationIsNoteColor[PART_MINE], sNoteSkin, sButton, "tap mine" ); m_TapMine.Load( cache->m_bAnimationIsNoteColor[PART_MINE], sButton, "tap mine" );
m_HoldHeadActive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_HEAD], sNoteSkin, sButton, "hold head active" );
m_HoldHeadInactive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_HEAD], sNoteSkin, sButton, "hold head inactive" ); FOREACH_HoldType( ht )
m_HoldTopCapActive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TOP_CAP], sNoteSkin, sButton, "hold topcap active" ); {
m_HoldTopCapInactive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TOP_CAP], sNoteSkin, sButton, "hold topcap inactive" ); FOREACH_ActiveType( at )
m_HoldBodyActive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BODY], sNoteSkin, sButton, "hold body active" ); {
m_HoldBodyInactive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BODY], sNoteSkin, sButton, "hold body inactive" ); m_HoldHead[ht][at].Load( cache->m_bAnimationIsNoteColor[PART_HOLD_HEAD], sButton, HoldTypeToString(ht)+" head "+ActiveTypeToString(at) );
m_HoldBottomCapActive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BOTTOM_CAP], sNoteSkin, sButton, "hold bottomcap active" ); m_HoldTopCap[ht][at].Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TOP_CAP], sButton, HoldTypeToString(ht)+" topcap "+ActiveTypeToString(at) );
m_HoldBottomCapInactive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BOTTOM_CAP], sNoteSkin, sButton, "hold bottomcap inactive" ); m_HoldBody[ht][at].Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BODY], sButton, HoldTypeToString(ht)+" body "+ActiveTypeToString(at) );
m_HoldTailActive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TAIL], sNoteSkin, sButton, "hold tail active" ); m_HoldBottomCap[ht][at].Load( cache->m_bAnimationIsNoteColor[PART_HOLD_BOTTOM_CAP], sButton, HoldTypeToString(ht)+" bottomcap "+ActiveTypeToString(at) );
m_HoldTailInactive.Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TAIL], sNoteSkin, sButton, "hold tail inactive" ); m_HoldTail[ht][at].Load( cache->m_bAnimationIsNoteColor[PART_HOLD_TAIL], sButton, HoldTypeToString(ht)+" tail "+ActiveTypeToString(at) );
}
}
} }
bool NoteDisplay::DrawHoldHeadForTapsOnSameRow() const bool NoteDisplay::DrawHoldHeadForTapsOnSameRow() const
@@ -305,7 +338,7 @@ 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<CString, 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 )
{ {
NoteResource *pRes = it->second; NoteResource *pRes = it->second;
@@ -390,10 +423,10 @@ Actor * NoteDisplay::GetTapMineActor( float fNoteBeat )
return pActorOut; return pActorOut;
} }
Sprite * NoteDisplay::GetHoldTopCapSprite( float fNoteBeat, bool bIsBeingHeld ) Sprite * NoteDisplay::GetHoldTopCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = BeatToNoteType( fNoteBeat );
Sprite *pSpriteOut = (bIsBeingHeld ? m_HoldTopCapActive : m_HoldTopCapInactive).Get( nt ); Sprite *pSpriteOut = m_HoldTopCap[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get( nt );
SetActiveFrame( SetActiveFrame(
fNoteBeat, fNoteBeat,
@@ -405,10 +438,10 @@ Sprite * NoteDisplay::GetHoldTopCapSprite( float fNoteBeat, bool bIsBeingHeld )
return pSpriteOut; return pSpriteOut;
} }
Sprite * NoteDisplay::GetHoldBottomCapSprite( float fNoteBeat, bool bIsBeingHeld ) Sprite * NoteDisplay::GetHoldBottomCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = BeatToNoteType( fNoteBeat );
Sprite *pSpriteOut = (bIsBeingHeld ? m_HoldBottomCapActive : m_HoldBottomCapInactive).Get( nt ); Sprite *pSpriteOut = m_HoldBottomCap[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get( nt );
SetActiveFrame( SetActiveFrame(
fNoteBeat, fNoteBeat,
@@ -421,10 +454,10 @@ Sprite * NoteDisplay::GetHoldBottomCapSprite( float fNoteBeat, bool bIsBeingHeld
} }
Actor* NoteDisplay::GetHoldHeadActor( float fNoteBeat, bool bIsBeingHeld ) Actor* NoteDisplay::GetHoldHeadActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = BeatToNoteType( fNoteBeat );
Actor *pActorOut = (bIsBeingHeld ? m_HoldHeadActive : m_HoldHeadInactive).Get( nt ); Actor *pActorOut = m_HoldHead[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get( nt );
SetActiveFrame( SetActiveFrame(
fNoteBeat, fNoteBeat,
@@ -436,10 +469,10 @@ Actor* NoteDisplay::GetHoldHeadActor( float fNoteBeat, bool bIsBeingHeld )
return pActorOut; return pActorOut;
} }
Sprite *NoteDisplay::GetHoldBodySprite( float fNoteBeat, bool bIsBeingHeld ) Sprite *NoteDisplay::GetHoldBodySprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = BeatToNoteType( fNoteBeat );
Sprite *pSpriteOut = (bIsBeingHeld ? m_HoldBodyActive : m_HoldBodyInactive).Get( nt ); Sprite *pSpriteOut = m_HoldBody[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get( nt );
SetActiveFrame( SetActiveFrame(
fNoteBeat, fNoteBeat,
@@ -451,10 +484,10 @@ Sprite *NoteDisplay::GetHoldBodySprite( float fNoteBeat, bool bIsBeingHeld )
return pSpriteOut; return pSpriteOut;
} }
Actor* NoteDisplay::GetHoldTailActor( float fNoteBeat, bool bIsBeingHeld ) Actor* NoteDisplay::GetHoldTailActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = BeatToNoteType( fNoteBeat );
Actor *pActorOut = (bIsBeingHeld ? m_HoldTailActive : m_HoldTailInactive).Get( nt ); Actor *pActorOut = m_HoldTail[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get( nt );
SetActiveFrame( SetActiveFrame(
fNoteBeat, fNoteBeat,
@@ -501,14 +534,14 @@ struct StripBuffer
int Free() const { return size - Used(); } int Free() const { return size - Used(); }
}; };
void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ) void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset )
{ {
// //
// Draw the top cap (always wavy) // Draw the top cap (always wavy)
// //
StripBuffer queue; StripBuffer queue;
Sprite* pSprTopCap = GetHoldTopCapSprite( NoteRowToBeat(iRow), bIsBeingHeld ); Sprite* pSprTopCap = GetHoldTopCapSprite( NoteRowToBeat(iRow), tn.bIsRoll, bIsBeingHeld );
pSprTopCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) ); pSprTopCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
@@ -589,7 +622,7 @@ void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, const b
} }
void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow,
float fYStartOffset, float fYEndOffset ) float fYStartOffset, float fYEndOffset )
{ {
// //
@@ -597,7 +630,7 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iRow, const boo
// //
StripBuffer queue; StripBuffer queue;
Sprite* pSprBody = GetHoldBodySprite( NoteRowToBeat(iRow), bIsBeingHeld ); Sprite* pSprBody = GetHoldBodySprite( NoteRowToBeat(iRow), tn.bIsRoll, bIsBeingHeld );
pSprBody->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) ); pSprBody->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
@@ -688,14 +721,14 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iRow, const boo
queue.Draw(); queue.Draw();
} }
void NoteDisplay::DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ) void NoteDisplay::DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset )
{ {
// //
// Draw the bottom cap (always wavy) // Draw the bottom cap (always wavy)
// //
StripBuffer queue; StripBuffer queue;
Sprite* pBottomCap = GetHoldBottomCapSprite( NoteRowToBeat(iRow), bIsBeingHeld ); Sprite* pBottomCap = GetHoldBottomCapSprite( NoteRowToBeat(iRow), tn.bIsRoll, bIsBeingHeld );
pBottomCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) ); pBottomCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
@@ -772,12 +805,12 @@ void NoteDisplay::DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, cons
queue.Draw(); queue.Draw();
} }
void NoteDisplay::DrawHoldTail( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYTail, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ) void NoteDisplay::DrawHoldTail( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYTail, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset )
{ {
// //
// Draw the tail // Draw the tail
// //
Actor* pSprTail = GetHoldTailActor( NoteRowToBeat(iRow), bIsBeingHeld ); Actor* pSprTail = GetHoldTailActor( NoteRowToBeat(iRow), tn.bIsRoll, bIsBeingHeld );
pSprTail->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) ); pSprTail->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
@@ -826,12 +859,12 @@ void NoteDisplay::DrawHoldTail( const TapNote& tn, int iCol, int iRow, const boo
} }
} }
void NoteDisplay::DrawHoldHead( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ) void NoteDisplay::DrawHoldHead( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset )
{ {
// //
// Draw the head // Draw the head
// //
Actor* pActor = GetHoldHeadActor( NoteRowToBeat(iRow), bIsBeingHeld ); Actor* pActor = GetHoldHeadActor( NoteRowToBeat(iRow), tn.bIsRoll, bIsBeingHeld );
pActor->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) ); pActor->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
@@ -1014,7 +1047,7 @@ void NoteDisplay::DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bo
} }
else if( bOnSameRowAsHoldStart && cache->m_bDrawHoldHeadForTapsOnSameRow ) else if( bOnSameRowAsHoldStart && cache->m_bDrawHoldHeadForTapsOnSameRow )
{ {
pActor = GetHoldHeadActor( fBeat, false ); pActor = GetHoldHeadActor( fBeat, false, false );
bUseLighting = cache->m_bHoldHeadUseLighting; bUseLighting = cache->m_bHoldHeadUseLighting;
} }
else else
+27 -23
View File
@@ -17,7 +17,7 @@ struct NoteColorActor
{ {
NoteColorActor(); NoteColorActor();
~NoteColorActor(); ~NoteColorActor();
void Load( bool bIsNoteColor, const CString &sNoteSkin, const CString &sButton, const CString &sElement ); void Load( bool bIsNoteColor, const CString &sButton, const CString &sElement );
Actor* Get( NoteType nt ); Actor* Get( NoteType nt );
private: private:
Actor* m_p[NOTE_COLOR_IMAGES]; Actor* m_p[NOTE_COLOR_IMAGES];
@@ -28,20 +28,29 @@ struct NoteColorSprite
{ {
NoteColorSprite(); NoteColorSprite();
~NoteColorSprite(); ~NoteColorSprite();
void Load( bool bIsNoteColor, const CString &sNoteSkin, const CString &sButton, const CString &sElement ); void Load( bool bIsNoteColor, const CString &sButton, const CString &sElement );
Sprite* Get( NoteType nt ); Sprite* Get( NoteType nt );
private: private:
Sprite* m_p[NOTE_COLOR_IMAGES]; Sprite* m_p[NOTE_COLOR_IMAGES];
bool m_bIsNoteColor; bool m_bIsNoteColor;
}; };
enum HoldType { hold, roll, NUM_HOLD_TYPES };
#define FOREACH_HoldType( i ) FOREACH_ENUM( HoldType, NUM_HOLD_TYPES, i )
const CString &HoldTypeToString( HoldType ht );
enum ActiveType { active, inactive, NUM_ACTIVE_TYPES };
#define FOREACH_ActiveType( i ) FOREACH_ENUM( ActiveType, NUM_ACTIVE_TYPES, i )
const CString &ActiveTypeToString( ActiveType at );
class NoteDisplay class NoteDisplay
{ {
public: public:
NoteDisplay(); NoteDisplay();
~NoteDisplay(); ~NoteDisplay();
void Load( int iColNum, const PlayerState* pPlayerState, const CString &sNoteSkin, float fYReverseOffsetPixels ); void Load( int iColNum, const PlayerState* pPlayerState, float fYReverseOffsetPixels );
static void Update( float fDeltaTime ); static void Update( float fDeltaTime );
@@ -56,17 +65,17 @@ protected:
Actor *GetTapNoteActor( float fNoteBeat ); Actor *GetTapNoteActor( float fNoteBeat );
Actor *GetTapAdditionActor( float fNoteBeat ); Actor *GetTapAdditionActor( float fNoteBeat );
Actor *GetTapMineActor( float fNoteBeat ); Actor *GetTapMineActor( float fNoteBeat );
Actor *GetHoldHeadActor( float fNoteBeat, bool bIsBeingHeld ); Actor *GetHoldHeadActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld );
Actor* GetHoldTailActor( float fNoteBeat, bool bIsBeingHeld ); Actor *GetHoldTailActor( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld );
Sprite *GetHoldTopCapSprite( float fNoteBeat, bool bIsBeingHeld ); Sprite *GetHoldTopCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld );
Sprite *GetHoldBodySprite( float fNoteBeat, bool bIsBeingHeld ); Sprite *GetHoldBodySprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld );
Sprite *GetHoldBottomCapSprite( float fNoteBeat, bool bIsBeingHeld ); Sprite *GetHoldBottomCapSprite( float fNoteBeat, bool bIsRoll, bool bIsBeingHeld );
void DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset );
void DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset );
void DrawHoldBody( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldBody( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset );
void DrawHoldTail( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYTail, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldTail( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYTail, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset );
void DrawHoldHead( const TapNote& tn, int iCol, int iRow, const bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldHead( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset );
const PlayerState* m_pPlayerState; // to look up PlayerOptions const PlayerState* m_pPlayerState; // to look up PlayerOptions
@@ -75,16 +84,11 @@ protected:
NoteColorActor m_TapNote; NoteColorActor m_TapNote;
NoteColorActor m_TapAddition; NoteColorActor m_TapAddition;
NoteColorActor m_TapMine; NoteColorActor m_TapMine;
NoteColorActor m_HoldHeadActive; NoteColorActor m_HoldHead[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES];
NoteColorActor m_HoldHeadInactive; NoteColorSprite m_HoldTopCap[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES];
NoteColorSprite m_HoldTopCapActive; NoteColorSprite m_HoldBody[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES];
NoteColorSprite m_HoldTopCapInactive; NoteColorSprite m_HoldBottomCap[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES];
NoteColorSprite m_HoldBodyActive; NoteColorActor m_HoldTail[NUM_HOLD_TYPES][NUM_ACTIVE_TYPES];
NoteColorSprite m_HoldBodyInactive;
NoteColorSprite m_HoldBottomCapActive;
NoteColorSprite m_HoldBottomCapInactive;
NoteColorActor m_HoldTailActive;
NoteColorActor m_HoldTailInactive;
float m_fYReverseOffsetPixels; float m_fYReverseOffsetPixels;
}; };
+11 -8
View File
@@ -52,21 +52,24 @@ void NoteField::Unload()
LastDisplay = NULL; LastDisplay = NULL;
} }
void NoteField::CacheNoteSkin( CString skin ) void NoteField::CacheNoteSkin( const CString &sNoteSkin_ )
{ {
skin.ToLower(); CString sNoteSkin = sNoteSkin_;
sNoteSkin.ToLower();
if( m_NoteDisplays.find(skin) != m_NoteDisplays.end() ) if( m_NoteDisplays.find(sNoteSkin) != m_NoteDisplays.end() )
return; return;
LOG->Trace("NoteField::CacheNoteSkin: cache %s", skin.c_str() ); LockNoteSkin l( sNoteSkin );
LOG->Trace("NoteField::CacheNoteSkin: cache %s", sNoteSkin.c_str() );
NoteDisplayCols *nd = new NoteDisplayCols( GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer ); NoteDisplayCols *nd = new NoteDisplayCols( GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer );
for( int c=0; c<GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; c++ ) for( int c=0; c<GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; c++ )
nd->display[c].Load( c, m_pPlayerState, skin, m_fYReverseOffsetPixels ); nd->display[c].Load( c, m_pPlayerState, m_fYReverseOffsetPixels );
nd->m_ReceptorArrowRow.Load( m_pPlayerState, skin, m_fYReverseOffsetPixels ); nd->m_ReceptorArrowRow.Load( m_pPlayerState, m_fYReverseOffsetPixels );
nd->m_GhostArrowRow.Load( m_pPlayerState, skin, m_fYReverseOffsetPixels ); nd->m_GhostArrowRow.Load( m_pPlayerState, m_fYReverseOffsetPixels );
m_NoteDisplays[ skin ] = nd; m_NoteDisplays[ sNoteSkin ] = nd;
} }
void NoteField::CacheAllUsedNoteSkins() void NoteField::CacheAllUsedNoteSkins()
+1 -1
View File
@@ -32,7 +32,7 @@ public:
int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT
void FadeToFail(); void FadeToFail();
void CacheNoteSkin( CString skin ); void CacheNoteSkin( const CString &sNoteSkin );
void Step( int iCol, TapNoteScore score ); void Step( int iCol, TapNoteScore score );
void SetPressed( int iCol ); void SetPressed( int iCol );
+53 -34
View File
@@ -156,9 +156,10 @@ CString NoteSkinManager::GetNoteSkinDir( const CString &sSkinName )
return NOTESKINS_DIR + sGame + "/" + sSkinName + "/"; return NOTESKINS_DIR + sGame + "/" + sSkinName + "/";
} }
CString NoteSkinManager::GetMetric( const CString &_sNoteSkinName, const CString &sButtonName, const CString &sValue ) CString NoteSkinManager::GetMetric( const CString &sButtonName, const CString &sValue )
{ {
CString sNoteSkinName = _sNoteSkinName; ASSERT( !m_sCurrentNoteSkin.empty() );
CString sNoteSkinName = m_sCurrentNoteSkin;
sNoteSkinName.MakeLower(); sNoteSkinName.MakeLower();
map<CString,NoteSkinData>::const_iterator it = m_mapNameToData.find(sNoteSkinName); map<CString,NoteSkinData>::const_iterator it = m_mapNameToData.find(sNoteSkinName);
ASSERT_M( it != m_mapNameToData.end(), sNoteSkinName ); // this NoteSkin doesn't exist! ASSERT_M( it != m_mapNameToData.end(), sNoteSkinName ); // this NoteSkin doesn't exist!
@@ -173,68 +174,55 @@ CString NoteSkinManager::GetMetric( const CString &_sNoteSkinName, const CString
return sReturn; return sReturn;
} }
int NoteSkinManager::GetMetricI( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName ) int NoteSkinManager::GetMetricI( const CString &sButtonName, const CString &sValueName )
{ {
return atoi( GetMetric(sNoteSkinName,sButtonName,sValueName) ); return atoi( GetMetric(sButtonName,sValueName) );
} }
float NoteSkinManager::GetMetricF( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName ) float NoteSkinManager::GetMetricF( const CString &sButtonName, const CString &sValueName )
{ {
return strtof( GetMetric(sNoteSkinName,sButtonName,sValueName), NULL ); return strtof( GetMetric(sButtonName,sValueName), NULL );
} }
bool NoteSkinManager::GetMetricB( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName ) bool NoteSkinManager::GetMetricB( const CString &sButtonName, const CString &sValueName )
{ {
return atoi( GetMetric(sNoteSkinName,sButtonName,sValueName) ) != 0; return atoi( GetMetric(sButtonName,sValueName) ) != 0;
} }
RageColor NoteSkinManager::GetMetricC( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName ) apActorCommands NoteSkinManager::GetMetricA( const CString &sButtonName, const CString &sValueName )
{ {
RageColor c; return apActorCommands( new ActorCommands( GetMetric(sButtonName,sValueName) ) );
if( !c.FromString( GetMetric(sNoteSkinName,sButtonName,sValueName) ) )
LOG->Warn( "The color value for NoteSkin metric '%s : %s : %s' is invalid.", sNoteSkinName.c_str(), sButtonName.c_str(), sValueName.c_str() );
return c;
} }
Commands NoteSkinManager::GetMetricA( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName ) CString NoteSkinManager::GetPath( const CString &sButtonName, const CString &sElement )
{
return ParseCommands( GetMetric(sNoteSkinName,sButtonName,sValueName) );
}
CString NoteSkinManager::GetPathToFromNoteSkinAndButton( const CString &NoteSkin, const CString &sButtonName, const CString &sElement, bool bOptional )
{ {
try_again: try_again:
const CString CacheString = m_sCurrentNoteSkin + "/" + sButtonName + "/" + sElement;
const CString CacheString = NoteSkin + "/" + sButtonName + "/" + sElement;
map<CString,CString>::iterator it = g_PathCache.find( CacheString ); map<CString,CString>::iterator it = g_PathCache.find( CacheString );
if( it != g_PathCache.end() ) if( it != g_PathCache.end() )
return it->second; return it->second;
const NoteSkinData &data = m_mapNameToData[NoteSkin]; map<CString,NoteSkinData>::const_iterator iter = m_mapNameToData.find( m_sCurrentNoteSkin );
ASSERT( iter != m_mapNameToData.end() );
const NoteSkinData &data = iter->second;
CString sPath; CString sPath; // fill this in below
FOREACHD_CONST( CString, data.vsDirSearchOrder, iter ) FOREACHD_CONST( CString, data.vsDirSearchOrder, iter )
{ {
if( *iter == GLOBAL_BASE_NOTESKIN_DIR ) if( *iter == GLOBAL_BASE_NOTESKIN_DIR )
sPath = GetPathToFromDir( *iter, "Fallback "+sElement ); sPath = GetPathFromDirAndFile( *iter, "Fallback "+sElement );
else else
sPath = GetPathToFromDir( *iter, sButtonName+" "+sElement ); sPath = GetPathFromDirAndFile( *iter, sButtonName+" "+sElement );
if( !sPath.empty() ) if( !sPath.empty() )
break; // done searching break; // done searching
} }
if( sPath.empty() ) if( sPath.empty() )
{ {
if( bOptional )
{
g_PathCache[CacheString] = sPath;
return sPath;
}
CString message = ssprintf( CString message = ssprintf(
"The NoteSkin element '%s %s' could not be found in '%s', '%s', or '%s'.", "The NoteSkin element '%s %s' could not be found in '%s', '%s', or '%s'.",
sButtonName.c_str(), sElement.c_str(), sButtonName.c_str(), sElement.c_str(),
GetNoteSkinDir(NoteSkin).c_str(), GetNoteSkinDir(m_sCurrentNoteSkin).c_str(),
GetNoteSkinDir(GAME_BASE_NOTESKIN_NAME).c_str(), GetNoteSkinDir(GAME_BASE_NOTESKIN_NAME).c_str(),
GLOBAL_BASE_NOTESKIN_DIR.c_str() ); GLOBAL_BASE_NOTESKIN_DIR.c_str() );
@@ -255,7 +243,7 @@ try_again:
FOREACHD_CONST( CString, data.vsDirSearchOrder, iter ) FOREACHD_CONST( CString, data.vsDirSearchOrder, iter )
{ {
sRealPath = GetPathToFromDir( *iter, sNewFileName ); sRealPath = GetPathFromDirAndFile( *iter, sNewFileName );
if( !sRealPath.empty() ) if( !sRealPath.empty() )
break; // done searching break; // done searching
} }
@@ -284,7 +272,7 @@ try_again:
return sPath; return sPath;
} }
CString NoteSkinManager::GetPathToFromDir( const CString &sDir, const CString &sFileName ) CString NoteSkinManager::GetPathFromDirAndFile( const CString &sDir, const CString &sFileName )
{ {
CStringArray matches; // fill this with the possible files CStringArray matches; // fill this with the possible files
@@ -312,6 +300,37 @@ CString NoteSkinManager::GetPathToFromDir( const CString &sDir, const CString &s
return matches[0]; return matches[0];
} }
// lua start
#include "LuaBinding.h"
template<class T>
class LunaNoteSkinManager : public Luna<T>
{
public:
LunaNoteSkinManager() { LUA->Register( Register ); }
static int GetPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetPath(SArg(1),SArg(2)) ); return 1; }
static void Register(lua_State *L)
{
ADD_METHOD( GetPath )
Luna<T>::Register( L );
// Add global singleton if constructed already. If it's not constructed yet,
// then we'll register it later when we reinit Lua just before
// initializing the display.
if( NOTESKIN )
{
lua_pushstring(L, "NOTESKIN");
NOTESKIN->PushSelf( LUA->L );
lua_settable(L, LUA_GLOBALSINDEX);
}
}
};
LUA_REGISTER_CLASS( NoteSkinManager )
// lua end
/* /*
* (c) 2003-2004 Chris Danford * (c) 2003-2004 Chris Danford
* All rights reserved. * All rights reserved.
+24 -11
View File
@@ -3,7 +3,7 @@
#ifndef NOTE_SKIN_MANAGER_H #ifndef NOTE_SKIN_MANAGER_H
#define NOTE_SKIN_MANAGER_H #define NOTE_SKIN_MANAGER_H
#include "Command.h" #include "ActorCommands.h"
#include "RageTypes.h" #include "RageTypes.h"
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "IniFile.h" #include "IniFile.h"
@@ -21,21 +21,25 @@ public:
void RefreshNoteSkinData( const Game* game ); void RefreshNoteSkinData( const Game* game );
void GetNoteSkinNames( const Game* game, CStringArray &AddTo, bool bFilterDefault=true ); void GetNoteSkinNames( const Game* game, CStringArray &AddTo, bool bFilterDefault=true );
void GetNoteSkinNames( CStringArray &AddTo ); // looks up current const Game* in GAMESTATE void GetNoteSkinNames( CStringArray &AddTo ); // looks up current const Game* in GAMESTATE
bool DoesNoteSkinExist( const CString &sSkinName ); // looks up current const Game* in GAMESTATE bool DoesNoteSkinExist( const CString &sNoteSkin ); // looks up current const Game* in GAMESTATE
CString GetPathToFromNoteSkinAndButton( const CString &sNoteSkin, const CString &sButtonName, const CString &sElement, bool bOptional=false ); void SetCurrentNoteSkin( const CString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
const CString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
CString GetMetric( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValue ); CString GetPath( const CString &sButtonName, const CString &sElement );
int GetMetricI( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName );
float GetMetricF( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName );
bool GetMetricB( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName );
RageColor GetMetricC( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName );
Commands GetMetricA( const CString &sNoteSkinName, const CString &sButtonName, const CString &sValueName );
CString GetNoteSkinDir( const CString &sSkinName ); CString GetMetric( const CString &sButtonName, const CString &sValue );
int GetMetricI( const CString &sButtonName, const CString &sValueName );
float GetMetricF( const CString &sButtonName, const CString &sValueName );
bool GetMetricB( const CString &sButtonName, const CString &sValueName );
apActorCommands GetMetricA( const CString &sButtonName, const CString &sValueName );
// Lua
void PushSelf( lua_State *L );
protected: protected:
CString GetPathToFromDir( const CString &sDir, const CString &sFileName ); CString GetNoteSkinDir( const CString &sSkinName );
CString GetPathFromDirAndFile( const CString &sDir, const CString &sFileName );
struct NoteSkinData struct NoteSkinData
{ {
@@ -47,6 +51,7 @@ protected:
}; };
void LoadNoteSkinData( const CString &sNoteSkinName, NoteSkinData& data_out ); void LoadNoteSkinData( const CString &sNoteSkinName, NoteSkinData& data_out );
void LoadNoteSkinDataRecursive( const CString &sNoteSkinName, NoteSkinData& data_out ); void LoadNoteSkinDataRecursive( const CString &sNoteSkinName, NoteSkinData& data_out );
CString m_sCurrentNoteSkin;
map<CString,NoteSkinData> m_mapNameToData; map<CString,NoteSkinData> m_mapNameToData;
const Game* m_pCurGame; const Game* m_pCurGame;
}; };
@@ -55,6 +60,14 @@ protected:
extern NoteSkinManager* NOTESKIN; // global and accessable from anywhere in our program extern NoteSkinManager* NOTESKIN; // global and accessable from anywhere in our program
class LockNoteSkin
{
public:
LockNoteSkin( const CString &sNoteSkin ) { ASSERT( NOTESKIN->GetCurrentNoteSkin().empty() ); NOTESKIN->SetCurrentNoteSkin( sNoteSkin ); }
~LockNoteSkin() { NOTESKIN->SetCurrentNoteSkin( CString() ); }
};
#endif #endif
/* /*
+5 -6
View File
@@ -17,24 +17,23 @@ ReceptorArrow::ReceptorArrow()
StopAnimating(); StopAnimating();
} }
bool ReceptorArrow::Load( CString NoteSkin, const PlayerState* pPlayerState, int iColNo ) bool ReceptorArrow::Load( const PlayerState* pPlayerState, int iColNo )
{ {
m_pPlayerState = pPlayerState; m_pPlayerState = pPlayerState;
m_iColNo = iColNo; m_iColNo = iColNo;
CString sButton = GAMESTATE->GetCurrentGame()->ColToButtonName( iColNo ); CString sButton = GAMESTATE->GetCurrentGame()->ColToButtonName( iColNo );
CString sPath; m_pReceptorWaiting.Load( NOTESKIN->GetPath(sButton,"receptor waiting") );
m_pReceptorWaiting.Load( NOTESKIN->GetPathToFromNoteSkinAndButton(NoteSkin,sButton,"receptor waiting") ); m_pReceptorGo.Load( NOTESKIN->GetPath(sButton,"receptor go") );
m_pReceptorGo.Load( NOTESKIN->GetPathToFromNoteSkinAndButton(NoteSkin,sButton,"receptor go") );
FOREACH_TapNoteScore( i ) FOREACH_TapNoteScore( i )
{ {
CString sJudge = TapNoteScoreToString( i ); CString sJudge = TapNoteScoreToString( i );
CString sCommand = Capitalize(sJudge)+"Command"; CString sCommand = Capitalize(sJudge)+"Command";
m_sScoreCommand[i] = apActorCommands( new ActorCommands(NOTESKIN->GetMetric(NoteSkin,m_sName,sCommand)) ); m_sScoreCommand[i] = NOTESKIN->GetMetricA(m_sName,sCommand);
} }
m_pPressBlock.Load( NOTESKIN->GetPathToFromNoteSkinAndButton(NoteSkin,sButton,"KeypressBlock") ); m_pPressBlock.Load( NOTESKIN->GetPath(sButton,"KeypressBlock") );
m_pReceptorWaiting->SetEffectClock( Actor::CLOCK_BGM_BEAT ); m_pReceptorWaiting->SetEffectClock( Actor::CLOCK_BGM_BEAT );
m_pReceptorGo->SetEffectClock( Actor::CLOCK_BGM_BEAT ); m_pReceptorGo->SetEffectClock( Actor::CLOCK_BGM_BEAT );
+1 -1
View File
@@ -14,7 +14,7 @@ class ReceptorArrow : public ActorFrame
{ {
public: public:
ReceptorArrow(); ReceptorArrow();
bool Load( CString NoteSkin, const PlayerState* pPlayerState, int iColNo ); bool Load( const PlayerState* pPlayerState, int iColNo );
virtual void DrawPrimitives(); virtual void DrawPrimitives();
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
+2 -2
View File
@@ -16,7 +16,7 @@ ReceptorArrowRow::ReceptorArrowRow()
m_iNumCols = 0; m_iNumCols = 0;
} }
void ReceptorArrowRow::Load( const PlayerState* pPlayerState, CString NoteSkin, float fYReverseOffset ) void ReceptorArrowRow::Load( const PlayerState* pPlayerState, float fYReverseOffset )
{ {
m_pPlayerState = pPlayerState; m_pPlayerState = pPlayerState;
m_fYReverseOffsetPixels = fYReverseOffset; m_fYReverseOffsetPixels = fYReverseOffset;
@@ -28,7 +28,7 @@ void ReceptorArrowRow::Load( const PlayerState* pPlayerState, CString NoteSkin,
for( int c=0; c<m_iNumCols; c++ ) for( int c=0; c<m_iNumCols; c++ )
{ {
m_ReceptorArrow[c].SetName( "ReceptorArrow" ); m_ReceptorArrow[c].SetName( "ReceptorArrow" );
m_ReceptorArrow[c].Load( NoteSkin, m_pPlayerState, c ); m_ReceptorArrow[c].Load( m_pPlayerState, c );
} }
} }
+1 -1
View File
@@ -15,7 +15,7 @@ class ReceptorArrowRow : public ActorFrame
public: public:
ReceptorArrowRow(); ReceptorArrowRow();
void Load( const PlayerState* pPlayerState, CString NoteSkin, float fYReverseOffset ); void Load( const PlayerState* pPlayerState, float fYReverseOffset );
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
virtual void DrawPrimitives(); virtual void DrawPrimitives();
+6 -1
View File
@@ -20,6 +20,7 @@
#include "ScreenDimensions.h" #include "ScreenDimensions.h"
#include "PlayerState.h" #include "PlayerState.h"
#include "Style.h" #include "Style.h"
#include "NoteSkinManager.h"
// //
@@ -181,10 +182,14 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName )
float fPlayerX = PLAYER_X(p,GAMESTATE->GetCurrentStyle()->m_StyleType); float fPlayerX = PLAYER_X(p,GAMESTATE->GetCurrentStyle()->m_StyleType);
m_ReceptorArrowRow[p].Load( GAMESTATE->m_pPlayerState[p], GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.m_sNoteSkin, 0 ); {
LockNoteSkin l( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.m_sNoteSkin );
m_ReceptorArrowRow[p].Load( GAMESTATE->m_pPlayerState[p], 0 );
m_ReceptorArrowRow[p].SetX( fPlayerX ); m_ReceptorArrowRow[p].SetX( fPlayerX );
m_ReceptorArrowRow[p].SetY( SCREEN_TOP + 100 ); m_ReceptorArrowRow[p].SetY( SCREEN_TOP + 100 );
this->AddChild( &m_ReceptorArrowRow[p] ); this->AddChild( &m_ReceptorArrowRow[p] );
}
const Style* pStyle = GAMESTATE->GetCurrentStyle(); const Style* pStyle = GAMESTATE->GetCurrentStyle();