faster Select Music loading and new grade graphics (thanks Parasyte!)

This commit is contained in:
Chris Danford
2002-02-09 04:30:27 +00:00
parent 35248690ac
commit 89ae7ed30c
9 changed files with 298 additions and 229 deletions
+8 -4
View File
@@ -190,6 +190,9 @@ float BitmapText::GetLineWidthInSourcePixels( int iLineNo )
{ {
char c = sLine[i]; char c = sLine[i];
int iFrameNo = m_iCharToFrameNo[c]; int iFrameNo = m_iCharToFrameNo[c];
if( iFrameNo == -1 ) // this font doesn't impelemnt this character
RageError( ssprintf("The font '%s' does not implement the character '%c'", m_sFontFilePath, c) );
fLineWidth += m_fFrameNoToWidth[iFrameNo]; fLineWidth += m_fFrameNoToWidth[iFrameNo];
} }
@@ -238,7 +241,8 @@ void BitmapText::RebuildVertexBuffer()
{ {
char c = sLine[j]; char c = sLine[j];
int iFrameNo = m_iCharToFrameNo[c]; int iFrameNo = m_iCharToFrameNo[c];
ASSERT( iFrameNo != -1 ); // this font doesn't impelemnt this character if( iFrameNo == -1 ) // this font doesn't impelemnt this character
RageError( ssprintf("The font '%s' does not implement the character '%c'", m_sFontFilePath, c) );
float fCharWidth = m_fFrameNoToWidth[iFrameNo]; float fCharWidth = m_fFrameNoToWidth[iFrameNo];
//if( c == ' ' ) //if( c == ' ' )
@@ -465,9 +469,9 @@ void BitmapText::SetText( CString sText )
sText = sText.Left( MAX_NUM_VERTICIES ); sText = sText.Left( MAX_NUM_VERTICIES );
// strip out foreign chars // strip out foreign chars
for( int i=0; i<sText.GetLength(); i++ ) for( int i=0; i<sText.GetLength(); i++ ) // for each character
if( sText[i] > NUM_CHARS-1 ) if( sText[i] < 0 || sText[i] > NUM_CHARS-1 )
sText.Delete(i); sText.SetAt( i, ' ' );
m_sTextLines.RemoveAll(); m_sTextLines.RemoveAll();
+46 -53
View File
@@ -19,7 +19,7 @@ class MusicStatusDisplay;
#include "ThemeManager.h" #include "ThemeManager.h"
enum MusicStatusDisplayType { TYPE_NEW, TYPE_NONE, TYPE_CROWN1, TYPE_CROWN2, TYPE_CROWN3 };
class MusicStatusDisplay : public Sprite class MusicStatusDisplay : public Sprite
{ {
@@ -28,79 +28,72 @@ public:
{ {
Load( THEME->GetPathTo(GRAPHIC_MUSIC_STATUS_ICONS) ); Load( THEME->GetPathTo(GRAPHIC_MUSIC_STATUS_ICONS) );
StopAnimating(); StopAnimating();
SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_bIsNew = false; SetType( TYPE_NONE );
m_Rank = NO_CROWN; };
m_bIsBlinking = false;
m_bDisplayNewIcon = true;
SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible void SetType( MusicStatusDisplayType msdt )
}
void SetIsNew( bool bIsNew )
{ {
m_bIsNew = bIsNew; m_MusicStatusDisplayType = msdt;
if( m_bIsNew )
SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible switch( m_MusicStatusDisplayType )
else {
SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible case TYPE_NEW:
m_MusicStatusDisplayType = TYPE_NEW;
SetState( 0 ); SetState( 0 );
}; SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
void SetBlinking( bool bIsBlinking ) break;
{ case TYPE_CROWN1:
m_bIsBlinking = bIsBlinking; m_MusicStatusDisplayType = TYPE_CROWN1;
}; SetState( 1 );
void SetRank( int i ) SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
{ break;
switch( i ) case TYPE_CROWN2:
{ m_MusicStatusDisplayType = TYPE_CROWN2;
case 1: m_Rank = CROWN_1; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break; SetState( 2 );
case 2: m_Rank = CROWN_2; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break; SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
case 3: m_Rank = CROWN_3; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break; break;
default: m_Rank = NO_CROWN; SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); break; case TYPE_CROWN3:
m_MusicStatusDisplayType = TYPE_CROWN3;
SetState( 3 );
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
break;
case TYPE_NONE:
default:
m_MusicStatusDisplayType = TYPE_NONE;
SetDiffuseColor( D3DXCOLOR(0,0,0,0) );
break;
} }
}; };
virtual void Update( float fDeltaTime ) virtual void Update( float fDeltaTime )
{ {
Sprite::Update( fDeltaTime ); Sprite::Update( fDeltaTime );
if( m_bIsBlinking ) switch( m_MusicStatusDisplayType )
{ {
case TYPE_CROWN1:
case TYPE_CROWN2:
case TYPE_CROWN3:
// blink
if( (GetTickCount() % 1000) > 500 ) // show the new icon if( (GetTickCount() % 1000) > 500 ) // show the new icon
{
if( m_bIsNew )
{
SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
SetState( 0 );
}
else else
{
SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible
} }
}
else // show the rank icon
{
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
switch( m_Rank )
{
case CROWN_1: SetState(1); break;
case CROWN_2: SetState(2); break;
case CROWN_3: SetState(3); break;
case NO_CROWN: SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); break;
}
}
}
}; };
virtual void RenderPrimitives()
{
if( m_MusicStatusDisplayType == TYPE_NONE )
return;
Sprite::RenderPrimitives();
}
protected: protected:
bool m_bIsNew; enum MusicStatusDisplayType m_MusicStatusDisplayType;
enum Rank { NO_CROWN, CROWN_1, CROWN_2, CROWN_3 };
Rank m_Rank;
bool m_bIsBlinking; // blink in order to display the new and crown icons
bool m_bDisplayNewIcon;
}; };
+175 -120
View File
@@ -54,52 +54,83 @@ const int NUM_SECTION_TINTS = sizeof(COLOR_SECTION_TINTS) / sizeof(D3DXCOLOR);
D3DXCOLOR COLOR_SECTION_LETTER = D3DXCOLOR(1,1,0.3f,1); D3DXCOLOR COLOR_SECTION_LETTER = D3DXCOLOR(1,1,0.3f,1);
WheelItem::WheelItem() WheelItemData::WheelItemData()
{ {
m_pSong = NULL; m_pSong = NULL;
m_MusicStatusDisplayType = TYPE_NONE;
} }
void WheelItemData::LoadFromSectionName( CString sSectionName )
void WheelItem::LoadFromSong( Song* pSong )
{
ASSERT( pSong != NULL );
m_pSong = pSong;
m_WheelItemType = TYPE_MUSIC;
m_MusicStatusDisplay.SetIsNew( m_pSong->GetNumTimesPlayed() == 0 );
m_MusicStatusDisplay.SetXY( -132, 0 );
m_Banner.LoadFromSong( pSong );
m_Banner.SetHorizAlign( align_left );
m_Banner.SetXY( 15, 0 );
}
void WheelItem::LoadFromSectionName( CString sSectionName )
{ {
m_WheelItemType = TYPE_SECTION; m_WheelItemType = TYPE_SECTION;
m_sSectionName = sSectionName;
m_colorTint = D3DXCOLOR(0.5f,0.5f,0.5f,1);
}
void WheelItemData::LoadFromSong( Song* pSong )
{
ASSERT( pSong != NULL );
m_pSong = pSong;
m_WheelItemType = TYPE_MUSIC;
}
WheelItemDisplay::WheelItemDisplay()
{
m_MusicStatusDisplay.SetXY( -132, 0 );
m_Banner.SetHorizAlign( align_left );
m_Banner.SetXY( 15, 0 );
m_sprSectionBackground.Load( THEME->GetPathTo(GRAPHIC_SECTION_BACKGROUND) ); m_sprSectionBackground.Load( THEME->GetPathTo(GRAPHIC_SECTION_BACKGROUND) );
m_sprSectionBackground.SetXY( -30, 0 ); m_sprSectionBackground.SetXY( -30, 0 );
m_textSectionName.Load( THEME->GetPathTo(FONT_OUTLINE) ); m_textSectionName.Load( THEME->GetPathTo(FONT_OUTLINE) );
m_textSectionName.TurnShadowOff(); m_textSectionName.TurnShadowOff();
m_textSectionName.SetText( sSectionName );
m_textSectionName.SetHorizAlign( align_left ); m_textSectionName.SetHorizAlign( align_left );
m_textSectionName.SetXY( -85, 0 ); m_textSectionName.SetXY( -85, 0 );
m_textSectionName.SetDiffuseColor( COLOR_SECTION_LETTER );
m_textSectionName.SetZoom( 1.5f ); m_textSectionName.SetZoom( 1.5f );
m_textSectionName.SetDiffuseColor( COLOR_SECTION_LETTER );
} }
void WheelItem::SetTintColor( D3DXCOLOR c ) void WheelItemDisplay::LoadFromWheelItemData( WheelItemData* pWID )
{ {
m_colorTint = c; ASSERT( pWID != NULL );
};
void WheelItem::SetDiffuseColor( D3DXCOLOR c )
// copy all data items
m_WheelItemType = pWID->m_WheelItemType;
m_colorTint = pWID->m_colorTint;
m_sSectionName = pWID->m_sSectionName;
m_pSong = pWID->m_pSong;
m_MusicStatusDisplayType = pWID->m_MusicStatusDisplayType;
// init type specific stuff
switch( pWID->m_WheelItemType )
{
case TYPE_SECTION:
m_textSectionName.SetText( m_sSectionName );
m_sprSectionBackground.SetDiffuseColor( m_colorTint );
break;
case TYPE_MUSIC:
m_Banner.LoadFromSong( m_pSong );
m_Banner.SetDiffuseColor( m_colorTint );
m_MusicStatusDisplay.SetType( (m_pSong->GetNumTimesPlayed()==0) ? TYPE_NEW : TYPE_NONE );
break;
default:
ASSERT( true ); // invalid type
}
}
void WheelItemDisplay::SetDiffuseColor( D3DXCOLOR c )
{ {
Actor::SetDiffuseColor( c ); Actor::SetDiffuseColor( c );
@@ -124,11 +155,9 @@ void WheelItem::SetDiffuseColor( D3DXCOLOR c )
D3DXCOLOR colorTempDisplay = D3DXCOLOR( 1, 1 ,1, c.a); D3DXCOLOR colorTempDisplay = D3DXCOLOR( 1, 1 ,1, c.a);
m_MusicStatusDisplay.SetDiffuseColor( colorTempDisplay ); m_MusicStatusDisplay.SetDiffuseColor( colorTempDisplay );
}
void WheelItemDisplay::Update( float fDeltaTime )
};
void WheelItem::Update( float fDeltaTime )
{ {
switch( m_WheelItemType ) switch( m_WheelItemType )
{ {
@@ -143,7 +172,7 @@ void WheelItem::Update( float fDeltaTime )
} }
} }
void WheelItem::RenderPrimitives() void WheelItemDisplay::RenderPrimitives()
{ {
switch( m_WheelItemType ) switch( m_WheelItemType )
{ {
@@ -223,16 +252,18 @@ MusicWheel::MusicWheel()
// find the previously selected song (if any), and select it // find the previously selected song (if any), and select it
for( i=0; i<GetCurWheelItems().GetSize(); i++ ) for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
{ {
if( GetCurWheelItems()[i].m_pSong != NULL if( GetCurWheelItemDatas()[i].m_pSong != NULL
&& GetCurWheelItems()[i].m_pSong == GAMEINFO->m_pCurSong ) && GetCurWheelItemDatas()[i].m_pSong == GAMEINFO->m_pCurSong )
m_iSelection = i; m_iSelection = i;
} }
for( int so=0; so<NUM_SORT_ORDERS; so++ ) for( int so=0; so<NUM_SORT_ORDERS; so++ )
BuildWheelItems( m_WheelItems[so], SongSortOrder(so) ); BuildWheelItemDatas( m_WheelItemDatas[so], SongSortOrder(so) );
RebuildWheelItemDisplays();
} }
@@ -241,8 +272,12 @@ MusicWheel::~MusicWheel()
GAMEINFO->m_SongSortOrder = m_SortOrder; GAMEINFO->m_SongSortOrder = m_SortOrder;
} }
void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems, SongSortOrder so ) void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItemDatas, SongSortOrder so )
{ {
///////////////////////////////////
// Make an array of Song*, then sort them
///////////////////////////////////
CArray<Song*, Song*&> arraySongs; CArray<Song*, Song*&> arraySongs;
arraySongs.Copy( GAMEINFO->m_pSongs ); arraySongs.Copy( GAMEINFO->m_pSongs );
@@ -269,12 +304,11 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
} }
for( int i=0; i<arraySongs.GetSize(); i++ )
{ ///////////////////////////////////
Song* pSong = arraySongs[i]; // Build an array of WheelItemDatas from the sorted list of Song*
int iNumTimesPlayed = pSong->GetNumTimesPlayed(); ///////////////////////////////////
} arrayWheelItemDatas.RemoveAll(); // clear out the previous wheel items...
arrayWheelItems.RemoveAll(); // clear out the previous wheel items...
// ...and load new ones // ...and load new ones
switch( so ) switch( so )
@@ -283,25 +317,25 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
case SORT_MOST_PLAYED: case SORT_MOST_PLAYED:
case SORT_BPM: case SORT_BPM:
// make WheelItems without sections // make WheelItems without sections
arrayWheelItems.SetSize( arraySongs.GetSize() ); arrayWheelItemDatas.SetSize( arraySongs.GetSize() );
{ {
for( int i=0; i< arraySongs.GetSize(); i++ ) for( int i=0; i<arraySongs.GetSize(); i++ )
{ {
Song* pSong = arraySongs[i]; Song* pSong = arraySongs[i];
WheelItem &WI = arrayWheelItems[i]; WheelItemData &WID = arrayWheelItemDatas[i];
WI.LoadFromSong( pSong ); WID.LoadFromSong( pSong );
WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); WID.m_colorTint = *m_mapGroupNameToColorPtr[pSong->GetGroupName()];
WI.m_sSectionName = ""; WID.m_sSectionName = "";
} }
} }
break; break;
case SORT_TITLE: case SORT_TITLE:
case SORT_ARTIST: case SORT_ARTIST:
// make WheelItems with sections
arrayWheelItems.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items
{ {
// make WheelItemDatas with sections
arrayWheelItemDatas.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items
CString sLastSection = ""; CString sLastSection = "";
int iCurWheelItem = 0; int iCurWheelItem = 0;
int iNextSectionTint = 0; int iNextSectionTint = 0;
@@ -311,21 +345,20 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
CString sThisSection = GetSectionNameFromSongAndSort( pSong, so ); CString sThisSection = GetSectionNameFromSongAndSort( pSong, so );
if( sThisSection != sLastSection ) // new section, make a section item if( sThisSection != sLastSection ) // new section, make a section item
{ {
WheelItem &WI = arrayWheelItems[iCurWheelItem++]; WheelItemData &WID = arrayWheelItemDatas[iCurWheelItem++];
WI.LoadFromSectionName( sThisSection ); WID.LoadFromSectionName( sThisSection );
WI.m_sSectionName = sThisSection; WID.m_colorTint = COLOR_SECTION_TINTS[iNextSectionTint++];
WI.SetTintColor( COLOR_SECTION_TINTS[iNextSectionTint++] );
if( iNextSectionTint >= NUM_SECTION_TINTS ) if( iNextSectionTint >= NUM_SECTION_TINTS )
iNextSectionTint = 0; iNextSectionTint = 0;
sLastSection = sThisSection; sLastSection = sThisSection;
} }
WheelItem &WI = arrayWheelItems[iCurWheelItem++]; WheelItemData &WID = arrayWheelItemDatas[iCurWheelItem++];
WI.LoadFromSong( pSong ); WID.LoadFromSong( pSong );
WI.m_sSectionName = sThisSection; WID.m_sSectionName = sThisSection;
WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); WID.m_colorTint = *m_mapGroupNameToColorPtr[pSong->GetGroupName()];
} }
arrayWheelItems.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items arrayWheelItemDatas.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items
} }
break; break;
default: default:
@@ -336,20 +369,19 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
if( so == SORT_MOST_PLAYED ) if( so == SORT_MOST_PLAYED )
{ {
// init crown icons // init crown icons
for( int i=0; i<arrayWheelItems.GetSize(); i++ ) for( int i=0; i<arrayWheelItemDatas.GetSize(); i++ )
{ {
arrayWheelItems[i].m_MusicStatusDisplay.SetBlinking( true ); arrayWheelItemDatas[i].m_MusicStatusDisplayType = MusicStatusDisplayType(TYPE_CROWN1 + i);
arrayWheelItems[i].m_MusicStatusDisplay.SetRank( i+1 );
} }
} }
if( arrayWheelItems.GetSize() == 0 ) if( arrayWheelItemDatas.GetSize() == 0 )
{ {
arrayWheelItems.SetSize( 1 ); arrayWheelItemDatas.SetSize( 1 );
arrayWheelItems[0].LoadFromSectionName( "No Songs" ); arrayWheelItemDatas[0].LoadFromSectionName( "No Songs" );
arrayWheelItems[0].SetTintColor( D3DXCOLOR(0.5f,0.5f,0.5f,1) ); arrayWheelItemDatas[0].m_colorTint = D3DXCOLOR(0.5f,0.5f,0.5f,1);
} }
} }
@@ -419,13 +451,9 @@ float MusicWheel::GetBannerX( float fPosOffsetsFromMiddle )
return fX; return fX;
} }
void MusicWheel::RebuildWheelItemDisplays()
void MusicWheel::RenderPrimitives()
{ {
m_sprSelectionBackground.Draw(); // rewind to first index that will be displayed;
// rewind to bottom item to draw;
int iIndex = m_iSelection; int iIndex = m_iSelection;
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ ) for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ )
{ {
@@ -433,44 +461,58 @@ void MusicWheel::RenderPrimitives()
{ {
iIndex--; iIndex--;
if( iIndex < 0 ) if( iIndex < 0 )
iIndex = GetCurWheelItems().GetSize()-1; iIndex = GetCurWheelItemDatas().GetSize()-1;
} }
while( GetCurWheelItems()[iIndex].m_WheelItemType == WheelItem::TYPE_MUSIC while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_MUSIC
&& GetCurWheelItems()[iIndex].m_sSectionName != "" && GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
&& GetCurWheelItems()[iIndex].m_sSectionName != m_sExpandedSectionName ); && GetCurWheelItemDatas()[iIndex].m_sSectionName != m_sExpandedSectionName );
} }
// iIndex is now the index of the lowest WheelItem to draw // iIndex is now the index of the lowest WheelItem to draw
for( i=-NUM_WHEEL_ITEMS_TO_DRAW/2; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ ) for( i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{ {
WheelItem& WI = GetCurWheelItems()[iIndex]; WheelItemData& data = GetCurWheelItemDatas()[iIndex];
WheelItemDisplay& display = m_WheelItemDisplays[i];
float fThisBannerPositionOffsetFromSelection = m_fPositionOffsetFromSelection + i; display.LoadFromWheelItemData( &data );
// increment iIndex
do
{
iIndex++;
if( iIndex > GetCurWheelItemDatas().GetSize()-1 )
iIndex = 0;
}
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_MUSIC
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != m_sExpandedSectionName );
}
}
void MusicWheel::RenderPrimitives()
{
m_sprSelectionBackground.Draw();
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS_TO_DRAW/2 + m_fPositionOffsetFromSelection;
float fY = GetBannerY( fThisBannerPositionOffsetFromSelection ); float fY = GetBannerY( fThisBannerPositionOffsetFromSelection );
float fX = GetBannerX( fThisBannerPositionOffsetFromSelection ); float fX = GetBannerX( fThisBannerPositionOffsetFromSelection );
WI.SetXY( fX, fY ); display.SetXY( fX, fY );
float fBrightness = GetBannerBrightness( m_fPositionOffsetFromSelection ); float fBrightness = GetBannerBrightness( m_fPositionOffsetFromSelection );
float fAlpha = GetBannerAlpha( m_fPositionOffsetFromSelection ); float fAlpha = GetBannerAlpha( m_fPositionOffsetFromSelection );
WI.SetDiffuseColor( D3DXCOLOR(fBrightness, fBrightness, fBrightness, fAlpha) ); display.SetDiffuseColor( D3DXCOLOR(fBrightness, fBrightness, fBrightness, fAlpha) );
WI.Draw(); display.Draw();
do
{
iIndex++;
if( iIndex > GetCurWheelItems().GetSize()-1 )
iIndex = 0;
} }
while( GetCurWheelItems()[iIndex].m_WheelItemType == WheelItem::TYPE_MUSIC
&& GetCurWheelItems()[iIndex].m_sSectionName != ""
&& GetCurWheelItems()[iIndex].m_sSectionName != m_sExpandedSectionName );
}
m_sprSelectionOverlay.Draw(); m_sprSelectionOverlay.Draw();
@@ -487,12 +529,15 @@ void MusicWheel::Update( float fDeltaTime )
for( int i=0; i<GetCurWheelItems().GetSize(); i++ ) for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{ {
GetCurWheelItems()[i].Update( fDeltaTime ); WheelItemDisplay& display = m_WheelItemDisplays[i];
display.Update( fDeltaTime );
} }
// update wheel state // update wheel state
m_fTimeLeftInState -= fDeltaTime; m_fTimeLeftInState -= fDeltaTime;
if( m_fTimeLeftInState <= 0 ) // time to go to a new state if( m_fTimeLeftInState <= 0 ) // time to go to a new state
@@ -508,7 +553,7 @@ void MusicWheel::Update( float fDeltaTime )
m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT; m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT;
m_fTimeLeftInState = FADE_TIME; m_fTimeLeftInState = FADE_TIME;
Song* pPrevSelectedSong = GetCurWheelItems()[m_iSelection].m_pSong; Song* pPrevSelectedSong = GetCurWheelItemDatas()[m_iSelection].m_pSong;
// change the sort order // change the sort order
m_SortOrder = SongSortOrder(m_SortOrder+1); m_SortOrder = SongSortOrder(m_SortOrder+1);
@@ -523,11 +568,14 @@ void MusicWheel::Update( float fDeltaTime )
// find the previously selected song, and select it // find the previously selected song, and select it
for( i=0; i<GetCurWheelItems().GetSize(); i++ ) for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
{ {
if( GetCurWheelItems()[i].m_pSong == pPrevSelectedSong ) if( GetCurWheelItemDatas()[i].m_pSong == pPrevSelectedSong )
m_iSelection = i; m_iSelection = i;
} }
RebuildWheelItemDisplays();
} }
break; break;
case STATE_FLYING_ON_AFTER_NEXT_SORT: case STATE_FLYING_ON_AFTER_NEXT_SORT:
@@ -575,16 +623,18 @@ void MusicWheel::PrevMusic()
MUSIC->Stop(); MUSIC->Stop();
// decrement m_iSelection
do do
{ {
m_iSelection--; m_iSelection--;
if( m_iSelection < 0 ) if( m_iSelection < 0 )
m_iSelection = GetCurWheelItems().GetSize()-1; m_iSelection = GetCurWheelItemDatas().GetSize()-1;
} }
while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC while( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_MUSIC
&& GetCurWheelItems()[m_iSelection].m_sSectionName != "" && GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
&& GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName ); && GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
RebuildWheelItemDisplays();
m_fPositionOffsetFromSelection -= 1; m_fPositionOffsetFromSelection -= 1;
@@ -606,16 +656,18 @@ void MusicWheel::NextMusic()
MUSIC->Stop(); MUSIC->Stop();
// increment m_iSelection
do do
{ {
m_iSelection++; m_iSelection++;
if( m_iSelection > GetCurWheelItems().GetSize()-1 ) if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 )
m_iSelection = 0; m_iSelection = 0;
} }
while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC while( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_MUSIC
&& GetCurWheelItems()[m_iSelection].m_sSectionName != "" && GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
&& GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName ); && GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
RebuildWheelItemDisplays();
m_fPositionOffsetFromSelection += 1; m_fPositionOffsetFromSelection += 1;
@@ -648,17 +700,18 @@ void MusicWheel::NextSort()
bool MusicWheel::Select() bool MusicWheel::Select()
{ {
switch( GetCurWheelItems()[m_iSelection].m_WheelItemType ) switch( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType )
{ {
case WheelItem::TYPE_SECTION: case TYPE_SECTION:
{ {
CString sThisItemSectionName = GetCurWheelItems()[m_iSelection].GetSectionName(); CString sThisItemSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName;
if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded
m_sExpandedSectionName = ""; // collapse it m_sExpandedSectionName = ""; // collapse it
else // already collapsed else // already collapsed
m_sExpandedSectionName = sThisItemSectionName; // expand it m_sExpandedSectionName = sThisItemSectionName; // expand it
//RebuildWheelItems();
RebuildWheelItemDisplays();
m_soundExpand.PlayRandom(); m_soundExpand.PlayRandom();
@@ -666,10 +719,10 @@ bool MusicWheel::Select()
m_iSelection = 0; // reset in case we can't find the last selected song m_iSelection = 0; // reset in case we can't find the last selected song
// find the section header and select it // find the section header and select it
for( int i=0; i<GetCurWheelItems().GetSize(); i++ ) for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
{ {
if( GetCurWheelItems()[i].m_WheelItemType == WheelItem::TYPE_SECTION if( GetCurWheelItemDatas()[i].m_WheelItemType == TYPE_SECTION
&& GetCurWheelItems()[i].GetSectionName() == sThisItemSectionName ) && GetCurWheelItemDatas()[i].m_sSectionName == sThisItemSectionName )
{ {
m_iSelection = i; m_iSelection = i;
break; break;
@@ -679,14 +732,15 @@ bool MusicWheel::Select()
} }
return false; return false;
case WheelItem::TYPE_MUSIC: case TYPE_MUSIC:
default: default:
return true; return true;
} }
} }
void MusicWheel::TweenOnScreen() { void MusicWheel::TweenOnScreen()
{
m_WheelState = STATE_TWEENING_ON_SCREEN; m_WheelState = STATE_TWEENING_ON_SCREEN;
m_fTimeLeftInState = FADE_TIME; m_fTimeLeftInState = FADE_TIME;
@@ -702,7 +756,8 @@ void MusicWheel::TweenOnScreen() {
} }
void MusicWheel::TweenOffScreen(){ void MusicWheel::TweenOffScreen()
{
m_WheelState = STATE_TWEENING_OFF_SCREEN; m_WheelState = STATE_TWEENING_OFF_SCREEN;
m_fTimeLeftInState = FADE_TIME; m_fTimeLeftInState = FADE_TIME;
+32 -21
View File
@@ -35,39 +35,48 @@ const WindowMessage SM_SongChanged = WindowMessage(SM_User+47); // this should
const WindowMessage SM_PlaySongSample = WindowMessage(SM_User+48); const WindowMessage SM_PlaySongSample = WindowMessage(SM_User+48);
enum WheelItemType { TYPE_SECTION, TYPE_MUSIC };
class WheelItem : public Actor
struct WheelItemData
{ {
public: public:
WheelItem(); WheelItemData();
void LoadFromSectionName( CString sSectionName );
void LoadFromSong( Song* pSong );
WheelItemType m_WheelItemType;
D3DXCOLOR m_colorTint;
CString m_sSectionName;
Song* m_pSong;
MusicStatusDisplayType m_MusicStatusDisplayType;
};
class WheelItemDisplay : public Actor,
public WheelItemData
{
public:
WheelItemDisplay();
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
virtual void RenderPrimitives(); virtual void RenderPrimitives();
void SetTintColor( D3DXCOLOR c );
void SetDiffuseColor( D3DXCOLOR c ); void SetDiffuseColor( D3DXCOLOR c );
CString GetSectionName() CString GetSectionName()
{ {
return m_textSectionName.GetText(); return m_sSectionName;
}; };
void LoadFromSong( Song* pSong ); void LoadFromWheelItemData( WheelItemData* pWID );
void LoadFromSectionName( CString sSectionName );
// common
enum WheelItemType { TYPE_SECTION, TYPE_MUSIC };
WheelItemType m_WheelItemType;
D3DXCOLOR m_colorTint;
CString m_sSectionName;
// for a section // for a section
Sprite m_sprSectionBackground; Sprite m_sprSectionBackground;
BitmapText m_textSectionName; BitmapText m_textSectionName;
// for a music // for a music
Song* m_pSong;
MusicStatusDisplay m_MusicStatusDisplay; MusicStatusDisplay m_MusicStatusDisplay;
TextBanner m_Banner; TextBanner m_Banner;
}; };
@@ -97,11 +106,12 @@ public:
float GetBannerX( float fPosOffsetsFromMiddle ); float GetBannerX( float fPosOffsetsFromMiddle );
bool Select(); // return true if the selected item is a music, otherwise false bool Select(); // return true if the selected item is a music, otherwise false
Song* GetSelectedSong() { return GetCurWheelItems()[m_iSelection].m_pSong; }; Song* GetSelectedSong() { return GetCurWheelItemDatas()[m_iSelection].m_pSong; };
protected: protected:
void BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems, SongSortOrder so ); void BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItems, SongSortOrder so );
void RebuildWheelItemDisplays();
void SwitchSortOrder(); void SwitchSortOrder();
@@ -110,13 +120,14 @@ protected:
MusicSortDisplay m_MusicSortDisplay; MusicSortDisplay m_MusicSortDisplay;
CArray<WheelItem, WheelItem&> m_WheelItems[NUM_SORT_ORDERS];
SongSortOrder m_SortOrder; SongSortOrder m_SortOrder;
CArray<WheelItem, WheelItem&> &GetCurWheelItems() { return m_WheelItems[m_SortOrder]; };
int m_iSelection; CArray<WheelItemData, WheelItemData&> m_WheelItemDatas[NUM_SORT_ORDERS];
CArray<WheelItemData, WheelItemData&> &GetCurWheelItemDatas() { return m_WheelItemDatas[m_SortOrder]; };
WheelItemDisplay m_WheelItemDisplays[NUM_WHEEL_ITEMS_TO_DRAW];
int m_iSelection; // index into GetCurWheelItemDatas()
CString m_sExpandedSectionName; CString m_sExpandedSectionName;
+2 -2
View File
@@ -409,14 +409,14 @@ VOID DisplayErrorAndDie( CString sError )
*/ */
#ifdef DEBUG // don't use error handler in Release mode #ifdef DEBUG // don't use error handler in Release mode
AfxMessageBox( sError ); AfxMessageBox( sError );
AfxDebugBreak();
exit(1); exit(1);
#else #else
FILE* fp = fopen( g_sErrorFileName, "w" ); FILE* fp = fopen( g_sErrorFileName, "w" );
fprintf( fp, sError ); fprintf( fp, sError );
fclose( fp ); fclose( fp );
// generate an exception so the error handler shows // generate an exception so the error handler shows
int d = 0; throw(1);
int ksg = 3/d;
#endif #endif
} }
-1
View File
@@ -165,7 +165,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow )
MSG msg; MSG msg;
ZeroMemory( &msg, sizeof(msg) ); ZeroMemory( &msg, sizeof(msg) );
while( WM_QUIT != msg.message ) while( WM_QUIT != msg.message )
{ {
// Look for messages, if none are found then // Look for messages, if none are found then
+1 -1
View File
@@ -79,7 +79,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /out:"../StepMania-debug.exe" /pdbtype:sept
!ENDIF !ENDIF
+11 -5
View File
@@ -16,12 +16,8 @@
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
CString ThemeManager::ElementToAssetPath( ThemeElement te )
CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
{ {
CString sThemeDir = ThemeNameToThemeDir( sThemeName );
CString sAssetPath; // fill this in below CString sAssetPath; // fill this in below
switch( te ) switch( te )
@@ -122,6 +118,16 @@ CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
RageError( ssprintf("Unhandled theme element %d", te) ); RageError( ssprintf("Unhandled theme element %d", te) );
} }
return sAssetPath;
}
CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
{
CString sThemeDir = ThemeNameToThemeDir( sThemeName );
CString sAssetPath = ElementToAssetPath( te );
CString sAssetDir, sAssetFileName, sThrowAway; CString sAssetDir, sAssetFileName, sThrowAway;
splitrelpath( sAssetPath, sAssetDir, sAssetFileName, sThrowAway ); splitrelpath( sAssetPath, sAssetDir, sAssetFileName, sThrowAway );
+6 -5
View File
@@ -126,7 +126,7 @@ public:
CStringArray arrayThemeNames; CStringArray arrayThemeNames;
GetThemeNames( arrayThemeNames ); GetThemeNames( arrayThemeNames );
for( int i=0; i<arrayThemeNames.GetSize(); i++ ) for( int i=0; i<arrayThemeNames.GetSize(); i++ )
CheckThemeIsComplete( arrayThemeNames[i] ); AssertThemeIsComplete( arrayThemeNames[i] );
SetTheme( DEFAULT_THEME_NAME ); SetTheme( DEFAULT_THEME_NAME );
}; };
@@ -160,17 +160,18 @@ public:
return true; return true;
}; };
bool CheckThemeIsComplete( CString sThemeName ) // return false if theme doesn't exist
void AssertThemeIsComplete( CString sThemeName ) // return false if theme doesn't exist
{ {
for( int i=0; i<NUM_THEME_ELEMENTS; i++ ) for( int i=0; i<NUM_THEME_ELEMENTS; i++ )
{ {
if( GetPathTo( (ThemeElement)i, sThemeName ) == "" ) if( GetPathTo( (ThemeElement)i, sThemeName ) == "" )
return false; RageError( ssprintf( "The theme element for theme '%s' called '%s' could not be found.", sThemeName, ElementToAssetPath((ThemeElement)i) ) );
} }
return true;
}; };
CString ElementToAssetPath( ThemeElement te );
CString GetPathTo( ThemeElement te ) CString GetPathTo( ThemeElement te )
{ {
return GetPathTo( te, m_sCurThemeName ); return GetPathTo( te, m_sCurThemeName );