faster Select Music loading and new grade graphics (thanks Parasyte!)
This commit is contained in:
@@ -190,6 +190,9 @@ float BitmapText::GetLineWidthInSourcePixels( int iLineNo )
|
||||
{
|
||||
char c = sLine[i];
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -238,7 +241,8 @@ void BitmapText::RebuildVertexBuffer()
|
||||
{
|
||||
char c = sLine[j];
|
||||
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];
|
||||
|
||||
//if( c == ' ' )
|
||||
@@ -465,9 +469,9 @@ void BitmapText::SetText( CString sText )
|
||||
sText = sText.Left( MAX_NUM_VERTICIES );
|
||||
|
||||
// strip out foreign chars
|
||||
for( int i=0; i<sText.GetLength(); i++ )
|
||||
if( sText[i] > NUM_CHARS-1 )
|
||||
sText.Delete(i);
|
||||
for( int i=0; i<sText.GetLength(); i++ ) // for each character
|
||||
if( sText[i] < 0 || sText[i] > NUM_CHARS-1 )
|
||||
sText.SetAt( i, ' ' );
|
||||
|
||||
|
||||
m_sTextLines.RemoveAll();
|
||||
|
||||
@@ -19,7 +19,7 @@ class MusicStatusDisplay;
|
||||
#include "ThemeManager.h"
|
||||
|
||||
|
||||
|
||||
enum MusicStatusDisplayType { TYPE_NEW, TYPE_NONE, TYPE_CROWN1, TYPE_CROWN2, TYPE_CROWN3 };
|
||||
|
||||
class MusicStatusDisplay : public Sprite
|
||||
{
|
||||
@@ -28,79 +28,72 @@ public:
|
||||
{
|
||||
Load( THEME->GetPathTo(GRAPHIC_MUSIC_STATUS_ICONS) );
|
||||
StopAnimating();
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
|
||||
|
||||
m_bIsNew = false;
|
||||
m_Rank = NO_CROWN;
|
||||
m_bIsBlinking = false;
|
||||
m_bDisplayNewIcon = true;
|
||||
SetType( TYPE_NONE );
|
||||
};
|
||||
|
||||
SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible
|
||||
}
|
||||
void SetIsNew( bool bIsNew )
|
||||
void SetType( MusicStatusDisplayType msdt )
|
||||
{
|
||||
m_bIsNew = bIsNew;
|
||||
if( m_bIsNew )
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible
|
||||
else
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible
|
||||
SetState( 0 );
|
||||
};
|
||||
void SetBlinking( bool bIsBlinking )
|
||||
{
|
||||
m_bIsBlinking = bIsBlinking;
|
||||
};
|
||||
void SetRank( int i )
|
||||
{
|
||||
switch( i )
|
||||
m_MusicStatusDisplayType = msdt;
|
||||
|
||||
switch( m_MusicStatusDisplayType )
|
||||
{
|
||||
case 1: m_Rank = CROWN_1; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break;
|
||||
case 2: m_Rank = CROWN_2; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break;
|
||||
case 3: m_Rank = CROWN_3; SetState( 0 ); SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); break;
|
||||
default: m_Rank = NO_CROWN; SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); break;
|
||||
case TYPE_NEW:
|
||||
m_MusicStatusDisplayType = TYPE_NEW;
|
||||
SetState( 0 );
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
break;
|
||||
case TYPE_CROWN1:
|
||||
m_MusicStatusDisplayType = TYPE_CROWN1;
|
||||
SetState( 1 );
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
break;
|
||||
case TYPE_CROWN2:
|
||||
m_MusicStatusDisplayType = TYPE_CROWN2;
|
||||
SetState( 2 );
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
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 )
|
||||
{
|
||||
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( m_bIsNew )
|
||||
{
|
||||
SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
SetState( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible
|
||||
}
|
||||
};
|
||||
|
||||
virtual void RenderPrimitives()
|
||||
{
|
||||
if( m_MusicStatusDisplayType == TYPE_NONE )
|
||||
return;
|
||||
|
||||
Sprite::RenderPrimitives();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool m_bIsNew;
|
||||
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;
|
||||
enum MusicStatusDisplayType m_MusicStatusDisplayType;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+190
-135
@@ -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);
|
||||
|
||||
|
||||
WheelItem::WheelItem()
|
||||
WheelItemData::WheelItemData()
|
||||
{
|
||||
m_pSong = NULL;
|
||||
m_MusicStatusDisplayType = TYPE_NONE;
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
void WheelItemData::LoadFromSectionName( CString sSectionName )
|
||||
{
|
||||
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.SetXY( -30, 0 );
|
||||
|
||||
m_textSectionName.Load( THEME->GetPathTo(FONT_OUTLINE) );
|
||||
m_textSectionName.TurnShadowOff();
|
||||
m_textSectionName.SetText( sSectionName );
|
||||
m_textSectionName.SetHorizAlign( align_left );
|
||||
m_textSectionName.SetXY( -85, 0 );
|
||||
m_textSectionName.SetDiffuseColor( COLOR_SECTION_LETTER );
|
||||
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 );
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
void WheelItem::SetDiffuseColor( D3DXCOLOR c )
|
||||
|
||||
// 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 );
|
||||
|
||||
@@ -124,11 +155,9 @@ void WheelItem::SetDiffuseColor( D3DXCOLOR c )
|
||||
D3DXCOLOR colorTempDisplay = D3DXCOLOR( 1, 1 ,1, c.a);
|
||||
|
||||
m_MusicStatusDisplay.SetDiffuseColor( colorTempDisplay );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
void WheelItem::Update( float fDeltaTime )
|
||||
void WheelItemDisplay::Update( float fDeltaTime )
|
||||
{
|
||||
switch( m_WheelItemType )
|
||||
{
|
||||
@@ -143,7 +172,7 @@ void WheelItem::Update( float fDeltaTime )
|
||||
}
|
||||
}
|
||||
|
||||
void WheelItem::RenderPrimitives()
|
||||
void WheelItemDisplay::RenderPrimitives()
|
||||
{
|
||||
switch( m_WheelItemType )
|
||||
{
|
||||
@@ -223,16 +252,18 @@ MusicWheel::MusicWheel()
|
||||
|
||||
|
||||
// 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
|
||||
&& GetCurWheelItems()[i].m_pSong == GAMEINFO->m_pCurSong )
|
||||
if( GetCurWheelItemDatas()[i].m_pSong != NULL
|
||||
&& GetCurWheelItemDatas()[i].m_pSong == GAMEINFO->m_pCurSong )
|
||||
m_iSelection = i;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
arraySongs.Copy( GAMEINFO->m_pSongs );
|
||||
|
||||
@@ -268,13 +303,12 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
|
||||
ASSERT( true ); // unhandled SORT_ORDER
|
||||
}
|
||||
|
||||
|
||||
for( int i=0; i<arraySongs.GetSize(); i++ )
|
||||
{
|
||||
Song* pSong = arraySongs[i];
|
||||
int iNumTimesPlayed = pSong->GetNumTimesPlayed();
|
||||
}
|
||||
arrayWheelItems.RemoveAll(); // clear out the previous wheel items...
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// Build an array of WheelItemDatas from the sorted list of Song*
|
||||
///////////////////////////////////
|
||||
arrayWheelItemDatas.RemoveAll(); // clear out the previous wheel items...
|
||||
|
||||
// ...and load new ones
|
||||
switch( so )
|
||||
@@ -283,49 +317,48 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
|
||||
case SORT_MOST_PLAYED:
|
||||
case SORT_BPM:
|
||||
// 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];
|
||||
WheelItem &WI = arrayWheelItems[i];
|
||||
WI.LoadFromSong( pSong );
|
||||
WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] );
|
||||
WI.m_sSectionName = "";
|
||||
WheelItemData &WID = arrayWheelItemDatas[i];
|
||||
WID.LoadFromSong( pSong );
|
||||
WID.m_colorTint = *m_mapGroupNameToColorPtr[pSong->GetGroupName()];
|
||||
WID.m_sSectionName = "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SORT_TITLE:
|
||||
case SORT_ARTIST:
|
||||
// make WheelItems with sections
|
||||
|
||||
arrayWheelItems.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items
|
||||
|
||||
{
|
||||
CString sLastSection = "";
|
||||
int iCurWheelItem = 0;
|
||||
int iNextSectionTint = 0;
|
||||
for( int i=0; i< arraySongs.GetSize(); i++ )
|
||||
{
|
||||
Song* pSong = arraySongs[i];
|
||||
CString sThisSection = GetSectionNameFromSongAndSort( pSong, so );
|
||||
if( sThisSection != sLastSection ) // new section, make a section item
|
||||
{
|
||||
WheelItem &WI = arrayWheelItems[iCurWheelItem++];
|
||||
WI.LoadFromSectionName( sThisSection );
|
||||
WI.m_sSectionName = sThisSection;
|
||||
WI.SetTintColor( COLOR_SECTION_TINTS[iNextSectionTint++] );
|
||||
if( iNextSectionTint >= NUM_SECTION_TINTS )
|
||||
iNextSectionTint = 0;
|
||||
sLastSection = sThisSection;
|
||||
}
|
||||
// make WheelItemDatas with sections
|
||||
|
||||
WheelItem &WI = arrayWheelItems[iCurWheelItem++];
|
||||
WI.LoadFromSong( pSong );
|
||||
WI.m_sSectionName = sThisSection;
|
||||
WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] );
|
||||
arrayWheelItemDatas.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items
|
||||
|
||||
CString sLastSection = "";
|
||||
int iCurWheelItem = 0;
|
||||
int iNextSectionTint = 0;
|
||||
for( int i=0; i< arraySongs.GetSize(); i++ )
|
||||
{
|
||||
Song* pSong = arraySongs[i];
|
||||
CString sThisSection = GetSectionNameFromSongAndSort( pSong, so );
|
||||
if( sThisSection != sLastSection ) // new section, make a section item
|
||||
{
|
||||
WheelItemData &WID = arrayWheelItemDatas[iCurWheelItem++];
|
||||
WID.LoadFromSectionName( sThisSection );
|
||||
WID.m_colorTint = COLOR_SECTION_TINTS[iNextSectionTint++];
|
||||
if( iNextSectionTint >= NUM_SECTION_TINTS )
|
||||
iNextSectionTint = 0;
|
||||
sLastSection = sThisSection;
|
||||
}
|
||||
arrayWheelItems.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items
|
||||
|
||||
WheelItemData &WID = arrayWheelItemDatas[iCurWheelItem++];
|
||||
WID.LoadFromSong( pSong );
|
||||
WID.m_sSectionName = sThisSection;
|
||||
WID.m_colorTint = *m_mapGroupNameToColorPtr[pSong->GetGroupName()];
|
||||
}
|
||||
arrayWheelItemDatas.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -336,20 +369,19 @@ void MusicWheel::BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems
|
||||
if( so == SORT_MOST_PLAYED )
|
||||
{
|
||||
// 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 );
|
||||
arrayWheelItems[i].m_MusicStatusDisplay.SetRank( i+1 );
|
||||
arrayWheelItemDatas[i].m_MusicStatusDisplayType = MusicStatusDisplayType(TYPE_CROWN1 + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( arrayWheelItems.GetSize() == 0 )
|
||||
if( arrayWheelItemDatas.GetSize() == 0 )
|
||||
{
|
||||
arrayWheelItems.SetSize( 1 );
|
||||
arrayWheelItems[0].LoadFromSectionName( "No Songs" );
|
||||
arrayWheelItems[0].SetTintColor( D3DXCOLOR(0.5f,0.5f,0.5f,1) );
|
||||
arrayWheelItemDatas.SetSize( 1 );
|
||||
arrayWheelItemDatas[0].LoadFromSectionName( "No Songs" );
|
||||
arrayWheelItemDatas[0].m_colorTint = D3DXCOLOR(0.5f,0.5f,0.5f,1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,13 +451,9 @@ float MusicWheel::GetBannerX( float fPosOffsetsFromMiddle )
|
||||
return fX;
|
||||
}
|
||||
|
||||
|
||||
void MusicWheel::RenderPrimitives()
|
||||
void MusicWheel::RebuildWheelItemDisplays()
|
||||
{
|
||||
m_sprSelectionBackground.Draw();
|
||||
|
||||
|
||||
// rewind to bottom item to draw;
|
||||
// rewind to first index that will be displayed;
|
||||
int iIndex = m_iSelection;
|
||||
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ )
|
||||
{
|
||||
@@ -433,46 +461,60 @@ void MusicWheel::RenderPrimitives()
|
||||
{
|
||||
iIndex--;
|
||||
if( iIndex < 0 )
|
||||
iIndex = GetCurWheelItems().GetSize()-1;
|
||||
iIndex = GetCurWheelItemDatas().GetSize()-1;
|
||||
}
|
||||
while( GetCurWheelItems()[iIndex].m_WheelItemType == WheelItem::TYPE_MUSIC
|
||||
&& GetCurWheelItems()[iIndex].m_sSectionName != ""
|
||||
&& GetCurWheelItems()[iIndex].m_sSectionName != m_sExpandedSectionName );
|
||||
|
||||
|
||||
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_MUSIC
|
||||
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
|
||||
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != m_sExpandedSectionName );
|
||||
}
|
||||
|
||||
// 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 fX = GetBannerX( fThisBannerPositionOffsetFromSelection );
|
||||
WI.SetXY( fX, fY );
|
||||
display.SetXY( fX, fY );
|
||||
|
||||
float fBrightness = GetBannerBrightness( m_fPositionOffsetFromSelection );
|
||||
float fAlpha = GetBannerAlpha( m_fPositionOffsetFromSelection );
|
||||
|
||||
WI.SetDiffuseColor( D3DXCOLOR(fBrightness, fBrightness, fBrightness, fAlpha) );
|
||||
WI.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 );
|
||||
|
||||
display.SetDiffuseColor( D3DXCOLOR(fBrightness, fBrightness, fBrightness, fAlpha) );
|
||||
display.Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_sprSelectionOverlay.Draw();
|
||||
|
||||
ActorFrame::RenderPrimitives();
|
||||
@@ -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
|
||||
m_fTimeLeftInState -= fDeltaTime;
|
||||
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_fTimeLeftInState = FADE_TIME;
|
||||
|
||||
Song* pPrevSelectedSong = GetCurWheelItems()[m_iSelection].m_pSong;
|
||||
Song* pPrevSelectedSong = GetCurWheelItemDatas()[m_iSelection].m_pSong;
|
||||
|
||||
// change the sort order
|
||||
m_SortOrder = SongSortOrder(m_SortOrder+1);
|
||||
@@ -523,11 +568,14 @@ void MusicWheel::Update( float fDeltaTime )
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
RebuildWheelItemDisplays();
|
||||
|
||||
}
|
||||
break;
|
||||
case STATE_FLYING_ON_AFTER_NEXT_SORT:
|
||||
@@ -575,16 +623,18 @@ void MusicWheel::PrevMusic()
|
||||
|
||||
MUSIC->Stop();
|
||||
|
||||
// decrement m_iSelection
|
||||
do
|
||||
{
|
||||
m_iSelection--;
|
||||
if( m_iSelection < 0 )
|
||||
m_iSelection = GetCurWheelItems().GetSize()-1;
|
||||
m_iSelection = GetCurWheelItemDatas().GetSize()-1;
|
||||
}
|
||||
while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC
|
||||
&& GetCurWheelItems()[m_iSelection].m_sSectionName != ""
|
||||
&& GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
|
||||
while( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_MUSIC
|
||||
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
|
||||
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
|
||||
|
||||
RebuildWheelItemDisplays();
|
||||
|
||||
m_fPositionOffsetFromSelection -= 1;
|
||||
|
||||
@@ -606,16 +656,18 @@ void MusicWheel::NextMusic()
|
||||
|
||||
MUSIC->Stop();
|
||||
|
||||
// increment m_iSelection
|
||||
do
|
||||
{
|
||||
m_iSelection++;
|
||||
if( m_iSelection > GetCurWheelItems().GetSize()-1 )
|
||||
if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 )
|
||||
m_iSelection = 0;
|
||||
}
|
||||
while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC
|
||||
&& GetCurWheelItems()[m_iSelection].m_sSectionName != ""
|
||||
&& GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
|
||||
while( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_MUSIC
|
||||
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
|
||||
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
|
||||
|
||||
RebuildWheelItemDisplays();
|
||||
|
||||
m_fPositionOffsetFromSelection += 1;
|
||||
|
||||
@@ -648,17 +700,18 @@ void MusicWheel::NextSort()
|
||||
|
||||
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
|
||||
m_sExpandedSectionName = ""; // collapse it
|
||||
else // already collapsed
|
||||
m_sExpandedSectionName = sThisItemSectionName; // expand it
|
||||
|
||||
//RebuildWheelItems();
|
||||
|
||||
RebuildWheelItemDisplays();
|
||||
|
||||
|
||||
m_soundExpand.PlayRandom();
|
||||
@@ -666,10 +719,10 @@ bool MusicWheel::Select()
|
||||
|
||||
m_iSelection = 0; // reset in case we can't find the last selected song
|
||||
// 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
|
||||
&& GetCurWheelItems()[i].GetSectionName() == sThisItemSectionName )
|
||||
if( GetCurWheelItemDatas()[i].m_WheelItemType == TYPE_SECTION
|
||||
&& GetCurWheelItemDatas()[i].m_sSectionName == sThisItemSectionName )
|
||||
{
|
||||
m_iSelection = i;
|
||||
break;
|
||||
@@ -679,14 +732,15 @@ bool MusicWheel::Select()
|
||||
}
|
||||
return false;
|
||||
|
||||
case WheelItem::TYPE_MUSIC:
|
||||
case TYPE_MUSIC:
|
||||
default:
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void MusicWheel::TweenOnScreen() {
|
||||
void MusicWheel::TweenOnScreen()
|
||||
{
|
||||
m_WheelState = STATE_TWEENING_ON_SCREEN;
|
||||
m_fTimeLeftInState = FADE_TIME;
|
||||
|
||||
@@ -702,7 +756,8 @@ void MusicWheel::TweenOnScreen() {
|
||||
}
|
||||
|
||||
|
||||
void MusicWheel::TweenOffScreen(){
|
||||
void MusicWheel::TweenOffScreen()
|
||||
{
|
||||
m_WheelState = STATE_TWEENING_OFF_SCREEN;
|
||||
m_fTimeLeftInState = FADE_TIME;
|
||||
|
||||
|
||||
+32
-21
@@ -35,39 +35,48 @@ const WindowMessage SM_SongChanged = WindowMessage(SM_User+47); // this should
|
||||
const WindowMessage SM_PlaySongSample = WindowMessage(SM_User+48);
|
||||
|
||||
|
||||
enum WheelItemType { TYPE_SECTION, TYPE_MUSIC };
|
||||
|
||||
class WheelItem : public Actor
|
||||
|
||||
struct WheelItemData
|
||||
{
|
||||
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 RenderPrimitives();
|
||||
|
||||
void SetTintColor( D3DXCOLOR c );
|
||||
void SetDiffuseColor( D3DXCOLOR c );
|
||||
|
||||
|
||||
CString GetSectionName()
|
||||
{
|
||||
return m_textSectionName.GetText();
|
||||
return m_sSectionName;
|
||||
};
|
||||
|
||||
void LoadFromSong( Song* pSong );
|
||||
void LoadFromSectionName( CString sSectionName );
|
||||
|
||||
// common
|
||||
enum WheelItemType { TYPE_SECTION, TYPE_MUSIC };
|
||||
WheelItemType m_WheelItemType;
|
||||
D3DXCOLOR m_colorTint;
|
||||
CString m_sSectionName;
|
||||
void LoadFromWheelItemData( WheelItemData* pWID );
|
||||
|
||||
// for a section
|
||||
Sprite m_sprSectionBackground;
|
||||
BitmapText m_textSectionName;
|
||||
|
||||
// for a music
|
||||
Song* m_pSong;
|
||||
MusicStatusDisplay m_MusicStatusDisplay;
|
||||
TextBanner m_Banner;
|
||||
};
|
||||
@@ -97,11 +106,12 @@ public:
|
||||
float GetBannerX( float fPosOffsetsFromMiddle );
|
||||
|
||||
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:
|
||||
void BuildWheelItems( CArray<WheelItem, WheelItem&> &arrayWheelItems, SongSortOrder so );
|
||||
void BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItems, SongSortOrder so );
|
||||
void RebuildWheelItemDisplays();
|
||||
void SwitchSortOrder();
|
||||
|
||||
|
||||
@@ -110,13 +120,14 @@ protected:
|
||||
|
||||
MusicSortDisplay m_MusicSortDisplay;
|
||||
|
||||
|
||||
|
||||
CArray<WheelItem, WheelItem&> m_WheelItems[NUM_SORT_ORDERS];
|
||||
SongSortOrder m_SortOrder;
|
||||
CArray<WheelItem, WheelItem&> &GetCurWheelItems() { return m_WheelItems[m_SortOrder]; };
|
||||
|
||||
CArray<WheelItemData, WheelItemData&> m_WheelItemDatas[NUM_SORT_ORDERS];
|
||||
CArray<WheelItemData, WheelItemData&> &GetCurWheelItemDatas() { return m_WheelItemDatas[m_SortOrder]; };
|
||||
|
||||
int m_iSelection;
|
||||
WheelItemDisplay m_WheelItemDisplays[NUM_WHEEL_ITEMS_TO_DRAW];
|
||||
|
||||
int m_iSelection; // index into GetCurWheelItemDatas()
|
||||
CString m_sExpandedSectionName;
|
||||
|
||||
|
||||
|
||||
@@ -409,14 +409,14 @@ VOID DisplayErrorAndDie( CString sError )
|
||||
*/
|
||||
#ifdef DEBUG // don't use error handler in Release mode
|
||||
AfxMessageBox( sError );
|
||||
AfxDebugBreak();
|
||||
exit(1);
|
||||
#else
|
||||
FILE* fp = fopen( g_sErrorFileName, "w" );
|
||||
fprintf( fp, sError );
|
||||
fclose( fp );
|
||||
// generate an exception so the error handler shows
|
||||
int d = 0;
|
||||
int ksg = 3/d;
|
||||
throw(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow )
|
||||
MSG msg;
|
||||
ZeroMemory( &msg, sizeof(msg) );
|
||||
|
||||
|
||||
while( WM_QUIT != msg.message )
|
||||
{
|
||||
// Look for messages, if none are found then
|
||||
|
||||
@@ -79,7 +79,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
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 LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /out:"../StepMania-debug.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
|
||||
|
||||
|
||||
|
||||
|
||||
CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
|
||||
CString ThemeManager::ElementToAssetPath( ThemeElement te )
|
||||
{
|
||||
CString sThemeDir = ThemeNameToThemeDir( sThemeName );
|
||||
|
||||
CString sAssetPath; // fill this in below
|
||||
|
||||
switch( te )
|
||||
@@ -121,6 +117,16 @@ CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
|
||||
default:
|
||||
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;
|
||||
splitrelpath( sAssetPath, sAssetDir, sAssetFileName, sThrowAway );
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
CStringArray arrayThemeNames;
|
||||
GetThemeNames( arrayThemeNames );
|
||||
for( int i=0; i<arrayThemeNames.GetSize(); i++ )
|
||||
CheckThemeIsComplete( arrayThemeNames[i] );
|
||||
AssertThemeIsComplete( arrayThemeNames[i] );
|
||||
|
||||
SetTheme( DEFAULT_THEME_NAME );
|
||||
};
|
||||
@@ -160,16 +160,17 @@ public:
|
||||
|
||||
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++ )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user