instead of toggling head/tail as wavy/not, have a wavy part (top cap

and bottom cap) and a solid part (head/tail).

allow overriding note skin metric values per-button

(rather larger patch than I intended to commit at once; sorry)
This commit is contained in:
Glenn Maynard
2003-02-08 23:47:47 +00:00
parent 8a9feafd62
commit 2c7db70f4b
4 changed files with 444 additions and 337 deletions
+289 -206
View File
@@ -26,79 +26,106 @@
#include "NoteTypes.h" #include "NoteTypes.h"
#define DRAW_HOLD_HEAD_FOR_TAPS_ON_SAME_ROW NOTESKIN->GetMetricB("NoteDisplay","DrawHoldHeadForTapsOnSameRow") #define DRAW_HOLD_HEAD_FOR_TAPS_ON_SAME_ROW NOTESKIN->GetMetricB(name,"DrawHoldHeadForTapsOnSameRow")
#define TAP_NOTE_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF("NoteDisplay","TapNoteAnimationLengthInBeats") #define TAP_NOTE_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"TapNoteAnimationLengthInBeats")
#define HOLD_HEAD_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF("NoteDisplay","HoldHeadAnimationLengthInBeats") #define HOLD_HEAD_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"HoldHeadAnimationLengthInBeats")
#define HOLD_BODY_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF("NoteDisplay","HoldBodyAnimationLengthInBeats") #define HOLD_TOPCAP_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"HoldTopCapAnimationLengthInBeats")
#define HOLD_TAIL_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF("NoteDisplay","HoldTailAnimationLengthInBeats") #define HOLD_BODY_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"HoldBodyAnimationLengthInBeats")
#define TAP_NOTE_ANIMATION_IS_VIVID NOTESKIN->GetMetricB("NoteDisplay","TapNoteAnimationIsVivid") #define HOLD_BOTTOMCAP_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"HoldBottomCapAnimationLengthInBeats")
#define HOLD_HEAD_ANIMATION_IS_VIVID NOTESKIN->GetMetricB("NoteDisplay","HoldHeadAnimationIsVivid") #define HOLD_TAIL_ANIMATION_LENGTH_IN_BEATS NOTESKIN->GetMetricF(name,"HoldTailAnimationLengthInBeats")
#define HOLD_BODY_ANIMATION_IS_VIVID NOTESKIN->GetMetricB("NoteDisplay","HoldBodyAnimationIsVivid") #define TAP_NOTE_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"TapNoteAnimationIsVivid")
#define HOLD_TAIL_ANIMATION_IS_VIVID NOTESKIN->GetMetricB("NoteDisplay","HoldTailAnimationIsVivid") #define HOLD_HEAD_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"HoldHeadAnimationIsVivid")
#define TAP_NOTE_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB("NoteDisplay","TapNoteAnimationIsNoteColor") #define HOLD_TOPCAP_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"HoldTopCapAnimationIsVivid")
#define HOLD_HEAD_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB("NoteDisplay","HoldHeadAnimationIsNoteColor") #define HOLD_BODY_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"HoldBodyAnimationIsVivid")
#define HOLD_BODY_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB("NoteDisplay","HoldBodyAnimationIsNoteColor") #define HOLD_BOTTOMCAP_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"HoldBottomCapAnimationIsVivid")
#define HOLD_TAIL_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB("NoteDisplay","HoldTailAnimationIsNoteColor") #define HOLD_TAIL_ANIMATION_IS_VIVID NOTESKIN->GetMetricB(name,"HoldTailAnimationIsVivid")
#define START_DRAWING_HOLD_BODY_OFFSET_FROM_HEAD NOTESKIN->GetMetricI("NoteDisplay","StartDrawingHoldBodyOffsetFromHead") #define TAP_NOTE_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"TapNoteAnimationIsNoteColor")
#define STOP_DRAWING_HOLD_BODY_OFFSET_FROM_TAIL NOTESKIN->GetMetricI("NoteDisplay","StopDrawingHoldBodyOffsetFromTail") #define HOLD_HEAD_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"HoldHeadAnimationIsNoteColor")
#define HOLD_HEAD_IS_WAVY NOTESKIN->GetMetricB("NoteDisplay","HoldHeadIsWavy") #define HOLD_TOPCAP_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"HoldHeadAnimationIsNoteColor")
#define HOLD_TAIL_IS_WAVY NOTESKIN->GetMetricB("NoteDisplay","HoldTailIsWavy") #define HOLD_BODY_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"HoldBodyAnimationIsNoteColor")
#define HOLD_NG_GRAY_PERCENT NOTESKIN->GetMetricF("NoteDisplay","HoldNGGrayPercent") #define HOLD_BOTTOMCAP_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"HoldHeadAnimationIsNoteColor")
#define HOLD_TAIL_ANIMATION_IS_NOTE_COLOR NOTESKIN->GetMetricB(name,"HoldTailAnimationIsNoteColor")
#define START_DRAWING_HOLD_BODY_OFFSET_FROM_HEAD NOTESKIN->GetMetricI(name,"StartDrawingHoldBodyOffsetFromHead")
#define STOP_DRAWING_HOLD_BODY_OFFSET_FROM_TAIL NOTESKIN->GetMetricI(name,"StopDrawingHoldBodyOffsetFromTail")
#define HOLD_NG_GRAY_PERCENT NOTESKIN->GetMetricF(name,"HoldNGGrayPercent")
// cache // cache
bool g_bDrawHoldHeadForTapsOnSameRow; struct NoteMetricCache_t {
float g_fTapNoteAnimationLengthInBeats; bool m_bDrawHoldHeadForTapsOnSameRow;
float g_fHoldHeadAnimationLengthInBeats; float m_fTapNoteAnimationLengthInBeats;
float g_fHoldBodyAnimationLengthInBeats; float m_fHoldHeadAnimationLengthInBeats;
float g_fHoldTailAnimationLengthInBeats; float m_fHoldTopCapAnimationLengthInBeats;
bool g_bTapNoteAnimationIsVivid; float m_fHoldBodyAnimationLengthInBeats;
bool g_bHoldHeadAnimationIsVivid; float m_fHoldBottomCapAnimationLengthInBeats;
bool g_bHoldBodyAnimationIsVivid; float m_fHoldTailAnimationLengthInBeats;
bool g_bHoldTailAnimationIsVivid; bool m_bTapNoteAnimationIsVivid;
bool g_bTapNoteAnimationIsNoteColor; bool m_bHoldHeadAnimationIsVivid;
bool g_bHoldHeadAnimationIsNoteColor; bool m_bHoldTopCapAnimationIsVivid;
bool g_bHoldBodyAnimationIsNoteColor; bool m_bHoldBodyAnimationIsVivid;
bool g_bHoldTailAnimationIsNoteColor; bool m_bHoldBottomCapAnimationIsVivid;
int g_iStartDrawingHoldBodyOffsetFromHead; bool m_bHoldTailAnimationIsVivid;
int g_iStopDrawingHoldBodyOffsetFromTail; bool m_bTapNoteAnimationIsNoteColor;
bool g_bHoldHeadIsWavy; bool m_bHoldHeadAnimationIsNoteColor;
bool g_bHoldTailIsWavy; bool m_bHoldTopCapAnimationIsNoteColor;
float g_fHoldNGGrayPercent; bool m_bHoldBodyAnimationIsNoteColor;
bool m_bHoldBottomCapAnimationIsNoteColor;
bool m_bHoldTailAnimationIsNoteColor;
int m_iStartDrawingHoldBodyOffsetFromHead;
int m_iStopDrawingHoldBodyOffsetFromTail;
float m_fHoldNGGrayPercent;
void Load(const CString &name);
} *NoteMetricCache;
void NoteMetricCache_t::Load(const CString &name)
{
m_bDrawHoldHeadForTapsOnSameRow = DRAW_HOLD_HEAD_FOR_TAPS_ON_SAME_ROW;
m_fTapNoteAnimationLengthInBeats = TAP_NOTE_ANIMATION_LENGTH_IN_BEATS;
m_fHoldHeadAnimationLengthInBeats = HOLD_HEAD_ANIMATION_LENGTH_IN_BEATS;
m_fHoldTopCapAnimationLengthInBeats = HOLD_TOPCAP_ANIMATION_LENGTH_IN_BEATS;
m_fHoldBodyAnimationLengthInBeats = HOLD_BODY_ANIMATION_LENGTH_IN_BEATS;
m_fHoldBottomCapAnimationLengthInBeats = HOLD_BOTTOMCAP_ANIMATION_LENGTH_IN_BEATS;
m_fHoldTailAnimationLengthInBeats = HOLD_TAIL_ANIMATION_LENGTH_IN_BEATS;
m_bTapNoteAnimationIsVivid = TAP_NOTE_ANIMATION_IS_VIVID;
m_bHoldHeadAnimationIsVivid = HOLD_HEAD_ANIMATION_IS_VIVID;
m_bHoldTopCapAnimationIsVivid = HOLD_TOPCAP_ANIMATION_IS_VIVID;
m_bHoldBodyAnimationIsVivid = HOLD_BODY_ANIMATION_IS_VIVID;
m_bHoldBottomCapAnimationIsVivid = HOLD_BOTTOMCAP_ANIMATION_IS_VIVID;
m_bHoldTailAnimationIsVivid = HOLD_TAIL_ANIMATION_IS_VIVID;
m_bTapNoteAnimationIsNoteColor = TAP_NOTE_ANIMATION_IS_NOTE_COLOR;
m_bHoldHeadAnimationIsNoteColor = HOLD_HEAD_ANIMATION_IS_NOTE_COLOR;
m_bHoldTopCapAnimationIsNoteColor = HOLD_TOPCAP_ANIMATION_IS_NOTE_COLOR;
m_bHoldBodyAnimationIsNoteColor = HOLD_BODY_ANIMATION_IS_NOTE_COLOR;
m_bHoldBottomCapAnimationIsNoteColor = HOLD_BOTTOMCAP_ANIMATION_IS_NOTE_COLOR;
m_bHoldTailAnimationIsNoteColor = HOLD_TAIL_ANIMATION_IS_NOTE_COLOR;
m_iStartDrawingHoldBodyOffsetFromHead = START_DRAWING_HOLD_BODY_OFFSET_FROM_HEAD;
m_iStopDrawingHoldBodyOffsetFromTail = STOP_DRAWING_HOLD_BODY_OFFSET_FROM_TAIL;
m_fHoldNGGrayPercent = HOLD_NG_GRAY_PERCENT;
}
NoteDisplay::NoteDisplay() NoteDisplay::NoteDisplay()
{ {
g_bDrawHoldHeadForTapsOnSameRow = DRAW_HOLD_HEAD_FOR_TAPS_ON_SAME_ROW; cache = new NoteMetricCache_t;
g_fTapNoteAnimationLengthInBeats = TAP_NOTE_ANIMATION_LENGTH_IN_BEATS;
g_fHoldHeadAnimationLengthInBeats = HOLD_HEAD_ANIMATION_LENGTH_IN_BEATS;
g_fHoldBodyAnimationLengthInBeats = HOLD_BODY_ANIMATION_LENGTH_IN_BEATS;
g_fHoldTailAnimationLengthInBeats = HOLD_TAIL_ANIMATION_LENGTH_IN_BEATS;
g_bTapNoteAnimationIsVivid = TAP_NOTE_ANIMATION_IS_VIVID;
g_bHoldHeadAnimationIsVivid = HOLD_HEAD_ANIMATION_IS_VIVID;
g_bHoldBodyAnimationIsVivid = HOLD_BODY_ANIMATION_IS_VIVID;
g_bHoldTailAnimationIsVivid = HOLD_TAIL_ANIMATION_IS_VIVID;
g_bTapNoteAnimationIsNoteColor = TAP_NOTE_ANIMATION_IS_NOTE_COLOR;
g_bHoldHeadAnimationIsNoteColor = HOLD_HEAD_ANIMATION_IS_NOTE_COLOR;
g_bHoldBodyAnimationIsNoteColor = HOLD_BODY_ANIMATION_IS_NOTE_COLOR;
g_bHoldTailAnimationIsNoteColor = HOLD_TAIL_ANIMATION_IS_NOTE_COLOR;
g_iStartDrawingHoldBodyOffsetFromHead = START_DRAWING_HOLD_BODY_OFFSET_FROM_HEAD;
g_iStopDrawingHoldBodyOffsetFromTail = STOP_DRAWING_HOLD_BODY_OFFSET_FROM_TAIL;
g_bHoldHeadIsWavy = HOLD_HEAD_IS_WAVY;
g_bHoldTailIsWavy = HOLD_TAIL_IS_WAVY;
g_fHoldNGGrayPercent = HOLD_NG_GRAY_PERCENT;
} }
NoteDisplay::~NoteDisplay()
{
delete cache;
}
void NoteDisplay::Load( int iColNum, PlayerNumber pn ) void NoteDisplay::Load( int iColNum, PlayerNumber pn )
{ {
m_PlayerNumber = pn; m_PlayerNumber = pn;
cache->Load(NoteSkinManager::ColToButtonName(iColNum));
// Look up note names once and store them here. // Look up note names once and store them here.
CString sNoteType[ NOTE_COLOR_IMAGES ]; CString sNoteType[ NOTE_COLOR_IMAGES ];
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
sNoteType[i] = NoteTypeToString( (NoteType)i ); sNoteType[i] = NoteTypeToString( (NoteType)i );
if( g_bTapNoteAnimationIsNoteColor ) if( cache->m_bTapNoteAnimationIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
m_sprTapNote[i].Load( NOTESKIN->GetPathTo(iColNum, "tap note "+sNoteType[i]) ); m_sprTapNote[i].Load( NOTESKIN->GetPathTo(iColNum, "tap note "+sNoteType[i]) );
@@ -108,7 +135,7 @@ void NoteDisplay::Load( int iColNum, PlayerNumber pn )
m_sprTapNote[0].Load( NOTESKIN->GetPathTo(iColNum, "tap note") ); m_sprTapNote[0].Load( NOTESKIN->GetPathTo(iColNum, "tap note") );
} }
if( g_bHoldHeadAnimationIsNoteColor ) if( cache->m_bHoldHeadAnimationIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
{ {
@@ -122,7 +149,21 @@ void NoteDisplay::Load( int iColNum, PlayerNumber pn )
m_sprHoldHeadInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold head inactive") ); m_sprHoldHeadInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold head inactive") );
} }
if( g_bHoldBodyAnimationIsNoteColor ) if( cache->m_bHoldTopCapAnimationIsNoteColor )
{
for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
{
m_sprHoldTopCapActive[i].Load( NOTESKIN->GetPathTo(iColNum, "hold topcap active "+sNoteType[i]) );
m_sprHoldTopCapInactive[i].Load( NOTESKIN->GetPathTo(iColNum, "hold topcap inactive "+sNoteType[i]) );
}
}
else
{
m_sprHoldTopCapActive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold topcap active") );
m_sprHoldTopCapInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold topcap inactive") );
}
if( cache->m_bHoldBodyAnimationIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
{ {
@@ -136,7 +177,21 @@ void NoteDisplay::Load( int iColNum, PlayerNumber pn )
m_sprHoldBodyInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold body inactive") ); m_sprHoldBodyInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold body inactive") );
} }
if( g_bHoldTailAnimationIsNoteColor ) if( cache->m_bHoldBottomCapAnimationIsNoteColor )
{
for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
{
m_sprHoldBottomCapActive[i].Load( NOTESKIN->GetPathTo(iColNum, "hold bottomcap active "+sNoteType[i]) );
m_sprHoldBottomCapInactive[i].Load( NOTESKIN->GetPathTo(iColNum, "hold bottomcap inactive "+sNoteType[i]) );
}
}
else
{
m_sprHoldBottomCapActive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold bottomcap active") );
m_sprHoldBottomCapInactive[0].Load( NOTESKIN->GetPathTo(iColNum, "hold bottomcap inactive") );
}
if( cache->m_bHoldTailAnimationIsNoteColor )
{ {
for( int i=0; i<NOTE_COLOR_IMAGES; i++ ) for( int i=0; i<NOTE_COLOR_IMAGES; i++ )
{ {
@@ -152,8 +207,9 @@ void NoteDisplay::Load( int iColNum, PlayerNumber pn )
} }
int NoteDisplay::GetFrameNo( float fNoteBeat, int iNumFrames, float fAnimationLengthInBeats, bool bVivid, bool bNoteColor ) void NoteDisplay::SetActiveFrame( float fNoteBeat, Sprite &Spr, float fAnimationLengthInBeats, bool bVivid, bool bNoteColor )
{ {
const int iNumFrames = Spr.GetNumStates();
float fSongBeat = GAMESTATE->m_fSongBeat; float fSongBeat = GAMESTATE->m_fSongBeat;
float fPrecentIntoAnimation = fmodf(fSongBeat,fAnimationLengthInBeats) / fAnimationLengthInBeats; float fPrecentIntoAnimation = fmodf(fSongBeat,fAnimationLengthInBeats) / fAnimationLengthInBeats;
float fNoteBeatFraction = fmodf( fNoteBeat, 1.0f ); float fNoteBeatFraction = fmodf( fNoteBeat, 1.0f );
@@ -166,88 +222,128 @@ int NoteDisplay::GetFrameNo( float fNoteBeat, int iNumFrames, float fAnimationLe
iFrameNo %= iNumFrames; iFrameNo %= iNumFrames;
ASSERT( iFrameNo>=0 && iFrameNo<iNumFrames ); ASSERT( iFrameNo>=0 && iFrameNo<iNumFrames );
return iFrameNo;
Spr.SetState( iFrameNo );
} }
void NoteDisplay::GetTapNoteSpriteAndFrameNo( float fNoteBeat, Sprite*& pSpriteOut, int& iFrameNoOut ) Sprite * NoteDisplay::GetTapNoteSprite( float fNoteBeat )
{ {
if( g_bTapNoteAnimationIsNoteColor ) NoteType nt = NoteType(0);
{ if( cache->m_bTapNoteAnimationIsNoteColor )
NoteType nt = BeatToNoteType( fNoteBeat ); nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID ) if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND; nt = NOTE_TYPE_32ND;
pSpriteOut = &m_sprTapNote[nt]; Sprite *pSpriteOut = &m_sprTapNote[nt];
}
else
pSpriteOut = &m_sprTapNote[0];
iFrameNoOut = GetFrameNo( SetActiveFrame(
fNoteBeat, fNoteBeat,
pSpriteOut->GetNumStates(), *pSpriteOut,
g_fTapNoteAnimationLengthInBeats, cache->m_fTapNoteAnimationLengthInBeats,
g_bTapNoteAnimationIsVivid, cache->m_bTapNoteAnimationIsVivid,
g_bTapNoteAnimationIsNoteColor ); cache->m_bTapNoteAnimationIsNoteColor );
return pSpriteOut;
} }
void NoteDisplay::GetHoldHeadSpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut ) Sprite * NoteDisplay::GetHoldTopCapSprite( float fNoteBeat, bool bActive )
{ {
if( g_bHoldHeadAnimationIsNoteColor ) NoteType nt = NoteType(0);
{ if( cache->m_bHoldTopCapAnimationIsNoteColor )
NoteType nt = BeatToNoteType( fNoteBeat ); nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID ) if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND; nt = NOTE_TYPE_32ND;
pSpriteOut = bActive ? &m_sprHoldHeadActive[nt] : &m_sprHoldHeadInactive[nt];
}
else
pSpriteOut = bActive ? &m_sprHoldHeadActive[0] : &m_sprHoldHeadInactive[0];
iFrameNoOut = GetFrameNo( Sprite *pSpriteOut = bActive ? &m_sprHoldTopCapActive[nt] : &m_sprHoldTopCapInactive[nt];
SetActiveFrame(
fNoteBeat, fNoteBeat,
pSpriteOut->GetNumStates(), *pSpriteOut,
g_fHoldHeadAnimationLengthInBeats, cache->m_fHoldTopCapAnimationLengthInBeats,
g_bHoldHeadAnimationIsVivid, cache->m_bHoldTopCapAnimationIsVivid,
g_bHoldHeadAnimationIsNoteColor ); cache->m_bHoldTopCapAnimationIsNoteColor );
return pSpriteOut;
} }
void NoteDisplay::GetHoldBodySpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut ) Sprite * NoteDisplay::GetHoldBottomCapSprite( float fNoteBeat, bool bActive )
{ {
if( g_bHoldBodyAnimationIsNoteColor ) NoteType nt = NoteType(0);
{ if( cache->m_bHoldBottomCapAnimationIsNoteColor )
NoteType nt = BeatToNoteType( fNoteBeat ); nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID ) if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND; nt = NOTE_TYPE_32ND;
pSpriteOut = bActive ? &m_sprHoldBodyActive[nt] : &m_sprHoldBodyInactive[nt];
}
else
pSpriteOut = bActive ? &m_sprHoldBodyActive[0] : &m_sprHoldBodyInactive[0];
iFrameNoOut = GetFrameNo( Sprite *pSpriteOut = bActive ? &m_sprHoldBottomCapActive[nt] : &m_sprHoldBottomCapInactive[nt];
SetActiveFrame(
fNoteBeat, fNoteBeat,
pSpriteOut->GetNumStates(), *pSpriteOut,
g_fHoldBodyAnimationLengthInBeats, cache->m_fHoldBottomCapAnimationLengthInBeats,
g_bHoldBodyAnimationIsVivid, cache->m_bHoldBottomCapAnimationIsVivid,
g_bHoldBodyAnimationIsNoteColor ); cache->m_bHoldBottomCapAnimationIsNoteColor );
return pSpriteOut;
} }
void NoteDisplay::GetHoldTailSpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut )
{
if( g_bHoldTailAnimationIsNoteColor ) Sprite * NoteDisplay::GetHoldHeadSprite( float fNoteBeat, bool bActive )
{ {
NoteType nt = BeatToNoteType( fNoteBeat ); NoteType nt = NoteType(0);
if( cache->m_bHoldHeadAnimationIsNoteColor )
nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID ) if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND; nt = NOTE_TYPE_32ND;
pSpriteOut = bActive ? &m_sprHoldTailActive[nt] : &m_sprHoldTailInactive[nt];
}
else
pSpriteOut = bActive ? &m_sprHoldTailActive[0] : &m_sprHoldTailInactive[0];
iFrameNoOut = GetFrameNo( Sprite *pSpriteOut = bActive ? &m_sprHoldHeadActive[nt] : &m_sprHoldHeadInactive[nt];
SetActiveFrame(
fNoteBeat, fNoteBeat,
pSpriteOut->GetNumStates(), *pSpriteOut,
g_fHoldTailAnimationLengthInBeats, cache->m_fHoldHeadAnimationLengthInBeats,
g_bHoldTailAnimationIsVivid, cache->m_bHoldHeadAnimationIsVivid,
g_bHoldTailAnimationIsNoteColor ); cache->m_bHoldHeadAnimationIsNoteColor );
return pSpriteOut;
}
Sprite *NoteDisplay::GetHoldBodySprite( float fNoteBeat, bool bActive )
{
NoteType nt = NoteType(0);
if( cache->m_bHoldBodyAnimationIsNoteColor )
nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND;
Sprite *pSpriteOut = bActive ? &m_sprHoldBodyActive[nt] : &m_sprHoldBodyInactive[nt];
SetActiveFrame(
fNoteBeat,
*pSpriteOut,
cache->m_fHoldBodyAnimationLengthInBeats,
cache->m_bHoldBodyAnimationIsVivid,
cache->m_bHoldBodyAnimationIsNoteColor );
return pSpriteOut;
}
Sprite * NoteDisplay::GetHoldTailSprite( float fNoteBeat, bool bActive )
{
NoteType nt = NoteType(0);
if( cache->m_bHoldTailAnimationIsNoteColor )
nt = BeatToNoteType( fNoteBeat );
if( nt == NOTE_TYPE_INVALID )
nt = NOTE_TYPE_32ND;
Sprite *pSpriteOut = bActive ? &m_sprHoldTailActive[nt] : &m_sprHoldTailInactive[nt];
SetActiveFrame(
fNoteBeat,
*pSpriteOut,
cache->m_fHoldTailAnimationLengthInBeats,
cache->m_bHoldTailAnimationIsVivid,
cache->m_bHoldTailAnimationIsNoteColor );
return pSpriteOut;
} }
@@ -268,29 +364,27 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const int fYStep = 16; // 16 logical pixels per segment const int fYStep = 16; // 16 logical pixels per segment
const float fColorScale = 1*fLife + (1-fLife)*g_fHoldNGGrayPercent; const float fColorScale = 1*fLife + (1-fLife)*cache->m_fHoldNGGrayPercent;
// //
// draw from tail to head (so head appears on top) // draw from tail to head (so head appears on top)
// //
/* The body and caps should have no overlap, so their order doesn't matter.
* Draw the head last, so it appears on top. */
static RageVertex queue[4096]; static RageVertex queue[4096];
// //
// Draw the tail // Draw the bottom cap (always wavy)
// //
{ {
Sprite* pSprTail; Sprite* pBottomCap = GetHoldBottomCapSprite( hn.m_fStartBeat, bActive );
int iFrameNo;
GetHoldTailSpriteAndFrameNo( hn.m_fStartBeat, bActive, pSprTail, iFrameNo );
if( g_bHoldTailIsWavy )
{
// draw manually in small segments // draw manually in small segments
RageVertex *v = &queue[0]; RageVertex *v = &queue[0];
RageTexture* pTexture = pSprTail->GetTexture(); RageTexture* pTexture = pBottomCap->GetTexture();
const RectF* pRect = pTexture->GetTextureCoordRect( iFrameNo ); const RectF *pRect = pBottomCap->GetCurrentTextureCoordRect();
DISPLAY->SetTexture( pTexture ); DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendModeNormal(); DISPLAY->SetBlendModeNormal();
if( bDrawGlowOnly ) if( bDrawGlowOnly )
@@ -299,25 +393,26 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
DISPLAY->SetTextureModeModulate(); DISPLAY->SetTextureModeModulate();
DISPLAY->DisableTextureWrapping(); DISPLAY->DisableTextureWrapping();
const float fFrameWidth = pBottomCap->GetUnzoomedWidth();
const float fFrameHeight = pBottomCap->GetUnzoomedHeight();
const float fYCapTop = fYTail+cache->m_iStopDrawingHoldBodyOffsetFromTail;
const float fYCapBottom = fYTail+cache->m_iStopDrawingHoldBodyOffsetFromTail+fFrameHeight;
const float fFrameWidth = pSprTail->GetUnzoomedWidth(); // don't draw any part of the tail that is before the middle of the head
const float fFrameHeight = pSprTail->GetUnzoomedHeight(); float fY=max( fYCapTop, fYHead );
const float fYTailTop = fYTail-fFrameHeight/2; for( ; fY<fYCapBottom; fY+=fYStep )
const float fYTailBottom = fYTail+fFrameHeight/2;
float fY=max( fYTailTop, fYHead ); // don't draw any part of the tail that is before the middle of the head
for( ; fY<fYTailBottom; fY+=fYStep )
{ {
const float fYTop = fY; const float fYTop = fY;
const float fYBottom = min( fY+fYStep, fYTailBottom ); const float fStepHeight = min( fYStep, fFrameHeight );
const float fYBottom = min( fY+fStepHeight, fYCapBottom );
const float fXTop = ArrowGetXPos( m_PlayerNumber, iCol, fYTop ); const float fXTop = ArrowGetXPos( m_PlayerNumber, iCol, fYTop );
const float fXBottom = ArrowGetXPos( m_PlayerNumber, iCol, fYBottom ); const float fXBottom = ArrowGetXPos( m_PlayerNumber, iCol, fYBottom );
const float fXTopLeft = fXTop - fFrameWidth/2; const float fXTopLeft = fXTop - fFrameWidth/2;
const float fXTopRight = fXTop + fFrameWidth/2; const float fXTopRight = fXTop + fFrameWidth/2;
const float fXBottomLeft = fXBottom - fFrameWidth/2; const float fXBottomLeft = fXBottom - fFrameWidth/2;
const float fXBottomRight = fXBottom + fFrameWidth/2; const float fXBottomRight = fXBottom + fFrameWidth/2;
const float fTopDistFromTailTop = fYTop - fYTailTop; const float fTopDistFromTailTop = fYTop - fYCapTop;
const float fBottomDistFromTailTop = fYBottom - fYTailTop; const float fBottomDistFromTailTop = fYBottom - fYCapTop;
const float fTexCoordTop = SCALE( fTopDistFromTailTop, 0, fFrameHeight, pRect->top, pRect->bottom ); const float fTexCoordTop = SCALE( fTopDistFromTailTop, 0, fFrameHeight, pRect->top, pRect->bottom );
const float fTexCoordBottom = SCALE( fBottomDistFromTailTop, 0, fFrameHeight, pRect->top, pRect->bottom ); const float fTexCoordBottom = SCALE( fBottomDistFromTailTop, 0, fFrameHeight, pRect->top, pRect->bottom );
const float fTexCoordLeft = pRect->left; const float fTexCoordLeft = pRect->left;
@@ -344,44 +439,17 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
} }
DISPLAY->DrawQuads( queue, v-queue ); DISPLAY->DrawQuads( queue, v-queue );
} }
else // !g_bHoldTailIsWavy
{
// draw with normal Sprite
const float fY = fYTail;
const float fX = ArrowGetXPos( m_PlayerNumber, iCol, fY );
const float fAlpha = ArrowGetAlpha( m_PlayerNumber, fY, fPercentFadeToFail );
const float fGlow = ArrowGetGlow( m_PlayerNumber, fY, fPercentFadeToFail );
const RageColor colorDiffuse= RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
const RageColor colorGlow = RageColor(1,1,1,fGlow);
pSprTail->SetXY( fX, fY );
pSprTail->SetState( iFrameNo );
if( bDrawGlowOnly )
{
pSprTail->SetDiffuse( RageColor(1,1,1,0) );
pSprTail->SetGlow( colorGlow );
}
else
{
pSprTail->SetDiffuse( colorDiffuse );
pSprTail->SetGlow( RageColor(0,0,0,0) );
}
pSprTail->Draw();
}
}
// //
// Draw the body (always wavy) // Draw the body (always wavy)
// //
{ {
Sprite* pSprBody; Sprite* pSprBody = GetHoldBodySprite( hn.m_fStartBeat, bActive );
int iFrameNo;
GetHoldBodySpriteAndFrameNo( hn.m_fStartBeat, bActive, pSprBody, iFrameNo );
// draw manually in small segments // draw manually in small segments
RageVertex *v = &queue[0]; RageVertex *v = &queue[0];
RageTexture* pTexture = pSprBody->GetTexture(); RageTexture* pTexture = pSprBody->GetTexture();
const RectF* pRect = pTexture->GetTextureCoordRect( iFrameNo ); const RectF *pRect = pSprBody->GetCurrentTextureCoordRect();
DISPLAY->SetTexture( pTexture ); DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendModeNormal(); DISPLAY->SetBlendModeNormal();
if( bDrawGlowOnly ) if( bDrawGlowOnly )
@@ -393,8 +461,8 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const float fFrameWidth = pSprBody->GetUnzoomedWidth(); const float fFrameWidth = pSprBody->GetUnzoomedWidth();
const float fFrameHeight = pSprBody->GetUnzoomedHeight(); const float fFrameHeight = pSprBody->GetUnzoomedHeight();
const float fYBodyTop = fYHead + g_iStartDrawingHoldBodyOffsetFromHead; const float fYBodyTop = fYHead + cache->m_iStartDrawingHoldBodyOffsetFromHead;
const float fYBodyBottom = fYTail + g_iStopDrawingHoldBodyOffsetFromTail; const float fYBodyBottom = fYTail + cache->m_iStopDrawingHoldBodyOffsetFromTail;
// top to bottom // top to bottom
for( float fY=fYBodyTop; fY<=fYBodyBottom; fY+=fYStep ) for( float fY=fYBodyTop; fY<=fYBodyBottom; fY+=fYStep )
@@ -450,49 +518,45 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
DISPLAY->DrawQuads( queue, v-queue ); DISPLAY->DrawQuads( queue, v-queue );
} }
// //
// Draw the head // Draw the top cap (always wavy)
// //
{ {
Sprite* pSprHead; Sprite* pSprTopCap = GetHoldTopCapSprite( hn.m_fStartBeat, bActive );
int iFrameNo;
GetHoldHeadSpriteAndFrameNo( hn.m_fStartBeat, bActive, pSprHead, iFrameNo );
if( g_bHoldHeadIsWavy )
{
// draw manually in small segments // draw manually in small segments
RageVertex *v = &queue[0]; RageVertex *v = &queue[0];
RageTexture* pTexture = pSprHead->GetTexture(); RageTexture* pTexture = pSprTopCap->GetTexture();
const RectF* pRect = pTexture->GetTextureCoordRect( iFrameNo ); const RectF *pRect = pSprTopCap->GetCurrentTextureCoordRect();
DISPLAY->SetTexture( pTexture ); DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendModeNormal(); DISPLAY->SetBlendModeNormal();
if( bDrawGlowOnly ) if( bDrawGlowOnly )
DISPLAY->SetTextureModeGlow(); DISPLAY->SetTextureModeGlow();
else else
DISPLAY->SetTextureModeModulate(); DISPLAY->SetTextureModeModulate();
DISPLAY->EnableTextureWrapping(); DISPLAY->DisableTextureWrapping();
const float fFrameWidth = pSprHead->GetUnzoomedWidth(); const float fFrameWidth = pSprTopCap->GetUnzoomedWidth();
const float fFrameHeight = pSprHead->GetUnzoomedHeight(); const float fFrameHeight = pSprTopCap->GetUnzoomedHeight();
const float fYHeadTop = fYHead-fFrameHeight/2; const float fYCapTop = fYHead+cache->m_iStartDrawingHoldBodyOffsetFromHead-fFrameHeight;
const float fYHeadBottom = fYHead+fFrameHeight/2; const float fYCapBottom = fYHead+cache->m_iStartDrawingHoldBodyOffsetFromHead;
for( float fY=fYHeadTop; fY<fYHeadBottom; fY+=fYStep ) for( float fY=fYCapTop; fY<fYCapBottom; fY+=fYStep )
{ {
const float fYTop = fY; const float fYTop = fY;
const float fYBottom = fY+fYStep; const float fStepHeight = min( fYStep, fFrameHeight );
const float fYBottom = min( fY+fStepHeight, fYCapBottom );
const float fXTop = ArrowGetXPos( m_PlayerNumber, iCol, fYTop ); const float fXTop = ArrowGetXPos( m_PlayerNumber, iCol, fYTop );
const float fXBottom = ArrowGetXPos( m_PlayerNumber, iCol, fYBottom ); const float fXBottom = ArrowGetXPos( m_PlayerNumber, iCol, fYBottom );
const float fXTopLeft = fXTop - fFrameWidth/2; const float fXTopLeft = fXTop - fFrameWidth/2;
const float fXTopRight = fXTop + fFrameWidth/2; const float fXTopRight = fXTop + fFrameWidth/2;
const float fXBottomLeft = fXBottom - fFrameWidth/2; const float fXBottomLeft = fXBottom - fFrameWidth/2;
const float fXBottomRight = fXBottom + fFrameWidth/2; const float fXBottomRight = fXBottom + fFrameWidth/2;
const float fTopDistFromHeadTop = fYTop - fYHeadTop; const float fTopDistFromHeadTop = fYTop - fYCapTop;
const float fBottomDistFromHeadTop = fYBottom - fYHeadTop; const float fBottomDistFromHeadTop = fYBottom - fYCapTop;
const float fTexCoordTop = SCALE( fTopDistFromHeadTop, 0, fFrameHeight, pRect->top, pRect->bottom ); const float fTexCoordTop = SCALE( fTopDistFromHeadTop, 0, fFrameHeight, pRect->top, pRect->bottom );
const float fTexCoordBottom = SCALE( fBottomDistFromHeadTop, 0, fFrameHeight, pRect->top, pRect->bottom ); const float fTexCoordBottom = SCALE( fBottomDistFromHeadTop, 0, fFrameHeight, pRect->top, pRect->bottom );
ASSERT( fTexCoordTop>=0 && fTexCoordBottom<=1 ); ASSERT( fTexCoordTop>=-0.0001 && fTexCoordBottom<=1.0001 ); /* allow for rounding error */
const float fTexCoordLeft = pRect->left; const float fTexCoordLeft = pRect->left;
const float fTexCoordRight = pRect->right; const float fTexCoordRight = pRect->right;
const float fAlphaTop = ArrowGetAlpha( m_PlayerNumber, fYTop, fPercentFadeToFail ); const float fAlphaTop = ArrowGetAlpha( m_PlayerNumber, fYTop, fPercentFadeToFail );
@@ -517,8 +581,40 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
} }
DISPLAY->DrawQuads( queue, v-queue ); DISPLAY->DrawQuads( queue, v-queue );
} }
else // !g_bHoldHeadIsWavy
//
// Draw the tail
//
{ {
Sprite* pSprTail = GetHoldTailSprite( hn.m_fStartBeat, bActive );
const float fY = fYTail;
const float fX = ArrowGetXPos( m_PlayerNumber, iCol, fY );
const float fAlpha = ArrowGetAlpha( m_PlayerNumber, fY, fPercentFadeToFail );
const float fGlow = ArrowGetGlow( m_PlayerNumber, fY, fPercentFadeToFail );
const RageColor colorDiffuse= RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
const RageColor colorGlow = RageColor(1,1,1,fGlow);
pSprTail->SetXY( fX, fY );
if( bDrawGlowOnly )
{
pSprTail->SetDiffuse( RageColor(1,1,1,0) );
pSprTail->SetGlow( colorGlow );
}
else
{
pSprTail->SetDiffuse( colorDiffuse );
pSprTail->SetGlow( RageColor(0,0,0,0) );
}
pSprTail->Draw();
}
//
// Draw the head
//
{
Sprite* pSprHead = GetHoldHeadSprite( hn.m_fStartBeat, bActive );
// draw with normal Sprite // draw with normal Sprite
const float fY = fYHead; const float fY = fYHead;
const float fX = ArrowGetXPos( m_PlayerNumber, iCol, fY ); const float fX = ArrowGetXPos( m_PlayerNumber, iCol, fY );
@@ -528,7 +624,6 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const RageColor colorGlow = RageColor(1,1,1,fGlow); const RageColor colorGlow = RageColor(1,1,1,fGlow);
pSprHead->SetXY( fX, fY ); pSprHead->SetXY( fX, fY );
pSprHead->SetState( iFrameNo );
if( bDrawGlowOnly ) if( bDrawGlowOnly )
{ {
pSprHead->SetDiffuse( RageColor(1,1,1,0) ); pSprHead->SetDiffuse( RageColor(1,1,1,0) );
@@ -541,8 +636,6 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
} }
pSprHead->Draw(); pSprHead->Draw();
} }
}
// now, draw the glow pass // now, draw the glow pass
if( !bDrawGlowOnly ) if( !bDrawGlowOnly )
@@ -573,34 +666,24 @@ void NoteDisplay::DrawTap( const int iCol, const float fBeat, const bool bOnSame
} }
*/ */
if( bOnSameRowAsHoldStart && g_bDrawHoldHeadForTapsOnSameRow ) Sprite* pSprite;
if( bOnSameRowAsHoldStart && cache->m_bDrawHoldHeadForTapsOnSameRow )
{ {
// draw hold head // draw hold head
Sprite* pSprHead; pSprite = GetHoldHeadSprite( fBeat, false );
int iFrameNo; pSprite->StopUsingCustomCoords();
GetHoldHeadSpriteAndFrameNo( fBeat, false, pSprHead, iFrameNo );
pSprHead->SetXY( fXPos, fYPos );
pSprHead->SetDiffuse( diffuse );
pSprHead->SetGlow( glow );
pSprHead->StopUsingCustomCoords();
pSprHead->SetState( iFrameNo );
pSprHead->Draw();
} }
else else
{ {
// draw tap // draw tap
Sprite* pSprTap; pSprite = GetTapNoteSprite( fBeat );
int iFrameNo; pSprite->SetRotation( fRotation );
GetTapNoteSpriteAndFrameNo( fBeat, pSprTap, iFrameNo );
pSprTap->SetXY( fXPos, fYPos );
pSprTap->SetRotation( fRotation );
pSprTap->SetGlow( glow );
pSprTap->SetDiffuse( diffuse );
pSprTap->SetState( iFrameNo );
pSprTap->Draw();
} }
pSprite->SetXY( fXPos, fYPos );
pSprite->SetDiffuse( diffuse );
pSprite->SetGlow( glow );
pSprite->Draw();
} }
+16 -5
View File
@@ -17,10 +17,13 @@
#include "NoteTypes.h" #include "NoteTypes.h"
struct NoteMetricCache_t;
class NoteDisplay class NoteDisplay
{ {
public: public:
NoteDisplay(); NoteDisplay();
~NoteDisplay();
void Load( int iColNum, PlayerNumber pn ); void Load( int iColNum, PlayerNumber pn );
@@ -28,21 +31,29 @@ public:
void DrawHold( const HoldNote& hn, const bool bActive, const float fLife, const float fPercentFadeToFail, bool bDrawGlowOnly = false ); void DrawHold( const HoldNote& hn, const bool bActive, const float fLife, const float fPercentFadeToFail, bool bDrawGlowOnly = false );
protected: protected:
int GetFrameNo( float fNoteBeat, int iNumFrames, float fAnimationLengthInBeats, bool bVivid, bool bNoteColor ); void SetActiveFrame( float fNoteBeat, Sprite &Spr, float fAnimationLengthInBeats, bool bVivid, bool bNoteColor );
void GetTapNoteSpriteAndFrameNo( float fNoteBeat, Sprite*& pSpriteOut, int& iFrameNoOut ); Sprite *GetTapNoteSprite( float fNoteBeat );
void GetHoldHeadSpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut ); Sprite *GetHoldHeadSprite( float fNoteBeat, bool bActive );
void GetHoldBodySpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut ); Sprite *GetHoldTopCapSprite( float fNoteBeat, bool bActive );
void GetHoldTailSpriteAndFrameNo( float fNoteBeat, bool bActive, Sprite*& pSpriteOut, int& iFrameNoOut ); Sprite *GetHoldBodySprite( float fNoteBeat, bool bActive );
Sprite *GetHoldBottomCapSprite( float fNoteBeat, bool bActive );
Sprite *GetHoldTailSprite( float fNoteBeat, bool bActive );
PlayerNumber m_PlayerNumber; // to look up PlayerOptions PlayerNumber m_PlayerNumber; // to look up PlayerOptions
struct NoteMetricCache_t *cache;
#define NOTE_COLOR_IMAGES 6 #define NOTE_COLOR_IMAGES 6
Sprite m_sprTapNote[NOTE_COLOR_IMAGES]; Sprite m_sprTapNote[NOTE_COLOR_IMAGES];
Sprite m_sprHoldHeadActive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldHeadActive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldHeadInactive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldHeadInactive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldTopCapActive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldTopCapInactive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldBodyActive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldBodyActive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldBodyInactive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldBodyInactive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldBottomCapActive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldBottomCapInactive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldTailActive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldTailActive[NOTE_COLOR_IMAGES];
Sprite m_sprHoldTailInactive[NOTE_COLOR_IMAGES]; Sprite m_sprHoldTailInactive[NOTE_COLOR_IMAGES];
}; };
+25 -14
View File
@@ -75,7 +75,11 @@ void NoteSkinManager::SwitchNoteSkin( CString sNewNoteSkin )
CStringArray as; CStringArray as;
GetNoteSkinNames( as ); GetNoteSkinNames( as );
ASSERT( !as.empty() ); ASSERT( !as.empty() );
/* Prefer "default" if it exists. */
sNewNoteSkin = as[0]; sNewNoteSkin = as[0];
for(unsigned i = 0; i < as.size(); ++i)
if(!as[i].CompareNoCase("default")) sNewNoteSkin = "default";
} }
m_sCurNoteSkinName = sNewNoteSkin; m_sCurNoteSkinName = sNewNoteSkin;
@@ -94,54 +98,61 @@ CString NoteSkinManager::GetNoteSkinDir( CString sSkinName )
return NOTESKINS_DIR + ssprintf("%s/%s/", pGameDef->m_szName, sSkinName.GetString()); return NOTESKINS_DIR + ssprintf("%s/%s/", pGameDef->m_szName, sSkinName.GetString());
} }
CString NoteSkinManager::GetMetric( CString sClassName, CString sValue ) // looks in GAMESTATE for the current Style CString NoteSkinManager::GetMetric( CString sButtonName, CString sValue ) // looks in GAMESTATE for the current Style
{ {
CString sReturn; CString sReturn;
if( !m_pIniMetrics->GetValue( sClassName, sValue, sReturn ) ) if( m_pIniMetrics->GetValue( sButtonName, sValue, sReturn ) )
RageException::Throw( "Could not read metric '%s - %s'", sClassName.GetString(), sValue.GetString() ); return sReturn;
if( !m_pIniMetrics->GetValue( "NoteDisplay", sValue, sReturn ) )
RageException::Throw( "Could not read metric '%s - %s' or 'NoteDisplay - %s'",
sButtonName.GetString(), sValue.GetString(), sValue.GetString() );
return sReturn; return sReturn;
} }
int NoteSkinManager::GetMetricI( CString sClassName, CString sValueName ) int NoteSkinManager::GetMetricI( CString sButtonName, CString sValueName )
{ {
return atoi( GetMetric(sClassName,sValueName) ); return atoi( GetMetric(sButtonName,sValueName) );
} }
float NoteSkinManager::GetMetricF( CString sClassName, CString sValueName ) float NoteSkinManager::GetMetricF( CString sButtonName, CString sValueName )
{ {
return (float)atof( GetMetric(sClassName,sValueName) ); return (float)atof( GetMetric(sButtonName,sValueName) );
} }
bool NoteSkinManager::GetMetricB( CString sClassName, CString sValueName ) bool NoteSkinManager::GetMetricB( CString sButtonName, CString sValueName )
{ {
return atoi( GetMetric(sClassName,sValueName) ) != 0; return atoi( GetMetric(sButtonName,sValueName) ) != 0;
} }
RageColor NoteSkinManager::GetMetricC( CString sClassName, CString sValueName ) RageColor NoteSkinManager::GetMetricC( CString sButtonName, CString sValueName )
{ {
float r=1,b=1,g=1,a=1; // initialize in case sscanf fails float r=1,b=1,g=1,a=1; // initialize in case sscanf fails
CString sValue = GetMetric(sClassName,sValueName); CString sValue = GetMetric(sButtonName,sValueName);
char szValue[40]; char szValue[40];
strncpy( szValue, sValue, 39 ); strncpy( szValue, sValue, 39 );
int result = sscanf( szValue, "%f,%f,%f,%f", &r, &g, &b, &a ); int result = sscanf( szValue, "%f,%f,%f,%f", &r, &g, &b, &a );
if( result != 4 ) if( result != 4 )
{ {
LOG->Warn( "The color value '%s' for theme metric '%s : %s' is invalid.", szValue, sClassName.GetString(), sValueName.GetString() ); LOG->Warn( "The color value '%s' for theme metric '%s : %s' is invalid.", szValue, sButtonName.GetString(), sValueName.GetString() );
ASSERT(0); ASSERT(0);
} }
return RageColor(r,g,b,a); return RageColor(r,g,b,a);
} }
CString NoteSkinManager::GetPathTo( int col, CString sFileName ) // looks in GAMESTATE for the current Style CString NoteSkinManager::ColToButtonName(int col)
{ {
const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef();
const GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); const GameDef* pGameDef = GAMESTATE->GetCurrentGameDef();
StyleInput SI( PLAYER_1, col ); StyleInput SI( PLAYER_1, col );
GameInput GI = pStyleDef->StyleInputToGameInput( SI ); GameInput GI = pStyleDef->StyleInputToGameInput( SI );
CString sButtonName = pGameDef->m_szButtonNames[GI.button]; return pGameDef->m_szButtonNames[GI.button];
}
CString NoteSkinManager::GetPathTo( int col, CString sFileName ) // looks in GAMESTATE for the current Style
{
CString sButtonName = ColToButtonName(col);
CString sCurNoteSkinName = m_sCurNoteSkinName; CString sCurNoteSkinName = m_sCurNoteSkinName;
if( GAMESTATE->m_bEditing ) if( GAMESTATE->m_bEditing )
+7 -5
View File
@@ -31,11 +31,13 @@ public:
CString GetPathTo( int col, CString sFileName ); CString GetPathTo( int col, CString sFileName );
CString GetMetric( CString sClassName, CString sValueName ); CString GetMetric( CString sButtonName, CString sValueName );
int GetMetricI( CString sClassName, CString sValueName ); int GetMetricI( CString sButtonName, CString sValueName );
float GetMetricF( CString sClassName, CString sValueName ); float GetMetricF( CString sButtonName, CString sValueName );
bool GetMetricB( CString sClassName, CString sValueName ); bool GetMetricB( CString sButtonName, CString sValueName );
RageColor GetMetricC( CString sClassName, CString sValueName ); RageColor GetMetricC( CString sButtonName, CString sValueName );
static CString NoteSkinManager::ColToButtonName(int col);
protected: protected:
CString GetPathTo( CString sSkinName, CString sButtonName, CString sFileName ); CString GetPathTo( CString sSkinName, CString sButtonName, CString sFileName );