diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 8ba898a602..575a861a98 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -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 NUM_CHARS-1 ) - sText.Delete(i); + for( int i=0; i NUM_CHARS-1 ) + sText.SetAt( i, ' ' ); m_sTextLines.RemoveAll(); diff --git a/stepmania/src/MusicStatusDisplay.h b/stepmania/src/MusicStatusDisplay.h index 0bb8e2aebe..ece922e790 100644 --- a/stepmania/src/MusicStatusDisplay.h +++ b/stepmania/src/MusicStatusDisplay.h @@ -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; }; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 2aa5e15d7c..e52f7a7a38 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -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; im_pCurSong ) + if( GetCurWheelItemDatas()[i].m_pSong != NULL + && GetCurWheelItemDatas()[i].m_pSong == GAMEINFO->m_pCurSong ) m_iSelection = i; } for( int so=0; som_SongSortOrder = m_SortOrder; } -void MusicWheel::BuildWheelItems( CArray &arrayWheelItems, SongSortOrder so ) +void MusicWheel::BuildWheelItemDatas( CArray &arrayWheelItemDatas, SongSortOrder so ) { + + /////////////////////////////////// + // Make an array of Song*, then sort them + /////////////////////////////////// CArray arraySongs; arraySongs.Copy( GAMEINFO->m_pSongs ); @@ -268,13 +303,12 @@ void MusicWheel::BuildWheelItems( CArray &arrayWheelItems ASSERT( true ); // unhandled SORT_ORDER } - - for( int i=0; iGetNumTimesPlayed(); - } - 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 &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; iGetGroupName()] ); - 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 &arrayWheelItems if( so == SORT_MOST_PLAYED ) { // init crown icons - for( int i=0; i 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 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; iStop(); + // 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 &arrayWheelItems, SongSortOrder so ); + void BuildWheelItemDatas( CArray &arrayWheelItems, SongSortOrder so ); + void RebuildWheelItemDisplays(); void SwitchSortOrder(); @@ -110,13 +120,14 @@ protected: MusicSortDisplay m_MusicSortDisplay; - - - CArray m_WheelItems[NUM_SORT_ORDERS]; SongSortOrder m_SortOrder; - CArray &GetCurWheelItems() { return m_WheelItems[m_SortOrder]; }; + + CArray m_WheelItemDatas[NUM_SORT_ORDERS]; + CArray &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; diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 2b1e626e64..898d00f9d6 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -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 } diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 2d717fd018..c8d678cbaa 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -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 diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index b8c93e90d2..5a4ed63f0a 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -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 diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index d2e273d02b..0af9d9b254 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -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 ); diff --git a/stepmania/src/ThemeManager.h b/stepmania/src/ThemeManager.h index 16981f6260..bf923e1a78 100644 --- a/stepmania/src/ThemeManager.h +++ b/stepmania/src/ThemeManager.h @@ -126,7 +126,7 @@ public: CStringArray arrayThemeNames; GetThemeNames( arrayThemeNames ); for( int i=0; i