From 374eb8c6d77d4e92b5eac67f7d9996c89146b97e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 2 Jul 2002 00:27:58 +0000 Subject: [PATCH] 3.0 is close! --- stepmania/src/Background.cpp | 18 ++- stepmania/src/Banner.cpp | 2 +- stepmania/src/GameConstantsAndTypes.h | 2 +- stepmania/src/IniFile.cpp | 2 +- stepmania/src/MusicWheel.cpp | 3 +- stepmania/src/NoteData.cpp | 14 +- stepmania/src/NoteData.h | 2 +- stepmania/src/NoteDataWithScoring.h | 2 +- stepmania/src/NoteField.cpp | 24 +-- stepmania/src/NoteField.h | 2 +- stepmania/src/Notes.cpp | 64 ++++---- stepmania/src/Notes.h | 1 - stepmania/src/Player.cpp | 21 ++- stepmania/src/Player.h | 4 +- stepmania/src/PrefsManager.cpp | 6 +- stepmania/src/RageTextureManager.cpp | 2 +- stepmania/src/RageUtil.cpp | 4 +- stepmania/src/ScreenEdit.cpp | 161 +++++++++++++-------- stepmania/src/ScreenEdit.h | 2 +- stepmania/src/ScreenEvaluation.cpp | 66 +-------- stepmania/src/ScreenGameplay.cpp | 13 +- stepmania/src/ScreenOptions.cpp | 4 +- stepmania/src/ScreenSongOptions.cpp | 13 +- stepmania/src/ScreenTitleMenu.cpp | 2 +- stepmania/src/Song.cpp | 201 ++++++++++++++------------ stepmania/src/SongManager.cpp | 1 + stepmania/src/StepMania.cpp | 3 +- stepmania/src/song.h | 16 +- 28 files changed, 337 insertions(+), 318 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index bf629c9b20..a837fbf8d8 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -44,14 +44,18 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations ) // Load background animations // CStringArray asBGAnimNames; - GetDirListing( BG_ANIMS_DIR+"*.*", asBGAnimNames, true ); - SortCStringArray( asBGAnimNames ); + + // We're going to try to classify songs as trance, pop, or techno based on some data about the song + if( pSong->m_BPMSegments.GetSize() + pSong->m_FreezeSegments.GetSize() >= 3 ) + GetDirListing( BG_ANIMS_DIR+"techno*.*", asBGAnimNames, true ); + else if( pSong->m_BPMSegments[0].m_fBPM > 160 ) + GetDirListing( BG_ANIMS_DIR+"trance*.*", asBGAnimNames, true ); + else + GetDirListing( BG_ANIMS_DIR+"pop*.*", asBGAnimNames, true ); + + // pick 4 random animations from this array for( int i=0; iGetGroupBannerPath( sGroupName ); diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 8eb0c1f884..45c560b47e 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -113,7 +113,7 @@ inline D3DXCOLOR GetNoteColorFromIndex( int iStepIndex ) return D3DXCOLOR(0.5f,0.5f,0.5f,1); }; -enum RadarCatrgory // starting from 12-o'clock rotating clockwise +enum RadarCategory // starting from 12-o'clock rotating clockwise { RADAR_STREAM = 0, RADAR_VOLTAGE, diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index 78045a5770..476fa1ff89 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -240,7 +240,7 @@ bool IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL crea bool IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL create) { CString temp; - temp.Format("%e",value); + temp.Format("%f",value); return SetValue(keyname, valuename, temp, create); } diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index a148bf66a9..75c4be8a5a 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -116,7 +116,7 @@ WheelItemDisplay::WheelItemDisplay() { m_GradeDisplay[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SMALL_GRADES) ); m_GradeDisplay[p].SetZoom( 1.0f ); - m_GradeDisplay[p].SetXY( 90.0f + p*30.0f, 0 ); + m_GradeDisplay[p].SetXY( 86.0f + p*26.0f, 0 ); } m_textCourse.Load( THEME->GetPathTo(FONT_TEXT_BANNER) ); @@ -318,6 +318,7 @@ MusicWheel::MusicWheel() m_HighScore[p].SetXY( SCORE_X, SCORE_Y[p]*0.97f ); m_HighScore[p].SetZoom( 0.6f ); + m_HighScore[p].SetDiffuseColor( PlayerToColor(p) ); m_frameOverlay.AddActor( &m_HighScore[p] ); } diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 9057c253f9..e50d39d735 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -3,7 +3,7 @@ ----------------------------------------------------------------------------- File: NoteData.cpp - Desc: A pattern of ColorNotes that past Y==0. + Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford @@ -72,7 +72,7 @@ void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEn ASSERT( pFrom->m_iNumTracks == m_iNumTracks ); if( iToIndexBegin == -1 ) - iToIndexBegin = iFromIndexBegin; + iToIndexBegin = 0; pFrom->ConvertHoldNotesTo2sAnd3s(); @@ -449,8 +449,8 @@ void NoteData::Turn( PlayerOptions::TurnType tt ) break; } - NoteData* pNewData = new NoteData; // write into here as we tranform - pNewData->m_iNumTracks = m_iNumTracks; + NoteData tempNoteData; // write into here as we tranform + tempNoteData.m_iNumTracks = m_iNumTracks; // transform m_TapNotes for( int i=0; im_TapNotes[iNewCol][i] = m_TapNotes[iOldCol][i]; + tempNoteData.m_TapNotes[iNewCol][i] = m_TapNotes[iOldCol][i]; } } @@ -477,7 +477,7 @@ void NoteData::Turn( PlayerOptions::TurnType tt ) if( hn.m_iTrack == iOldCol ) { HoldNote newHN = { iNewCol, hn.m_iStartIndex, hn.m_iEndIndex }; - pNewData->AddHoldNote( newHN ); + tempNoteData.AddHoldNote( newHN ); } } } @@ -485,7 +485,7 @@ void NoteData::Turn( PlayerOptions::TurnType tt ) // // copy note data from newData back into this // - (*this) = *pNewData; + (*this) = tempNoteData; } void NoteData::MakeLittle() diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index f452350d0c..2b0a7cf7a5 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -80,7 +80,7 @@ public: int GetPossibleDancePoints(); // radar values - return between 0.0 and 1.2 - float GetRadarValue( RadarCatrgory rv, float fSongSeconds ) + float GetRadarValue( RadarCategory rv, float fSongSeconds ) { switch( rv ) { diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index ca81bab457..a1be270d1b 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -29,7 +29,7 @@ struct NoteDataWithScoring : public NoteData int GetNumSuccessfulHoldNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); - float GetActualRadarValue( RadarCatrgory rv, float fSongSeconds ) + float GetActualRadarValue( RadarCategory rv, float fSongSeconds ) { switch( rv ) { diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 24d2a30481..8875577b38 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -37,7 +37,7 @@ NoteField::NoteField() m_fBeginMarker = m_fEndMarker = -1; - m_fOverrideAlpha = -1; + m_fOverrideAdd = -1; } @@ -83,9 +83,7 @@ void NoteField::CreateTapNoteInstance( ColorNoteInstance &cni, const int iCol, c const float fYPos = ArrowGetYPos( m_PlayerOptions, fYOffset ); const float fRotation = ArrowGetRotation( m_PlayerOptions, iCol, fYOffset ); const float fXPos = ArrowGetXPos( m_PlayerOptions, iCol, fYOffset, m_fSongBeat ); - float fAlpha = ArrowGetAlpha( m_PlayerOptions, fYPos ); - if( m_fOverrideAlpha != -1 ) - fAlpha = m_fOverrideAlpha; + const float fAlpha = ArrowGetAlpha( m_PlayerOptions, fYPos ); D3DXCOLOR colorLeading, colorTrailing; // of the color part. Alpha here be overwritten with fAlpha! if( color.a == -1 ) // indicated "NULL" @@ -93,7 +91,9 @@ void NoteField::CreateTapNoteInstance( ColorNoteInstance &cni, const int iCol, c else colorLeading = colorTrailing = color; - const float fAddAlpha = m_ColorNote[iCol].GetAddAlphaFromDiffuseAlpha( fAlpha ); + float fAddAlpha = m_ColorNote[iCol].GetAddAlphaFromDiffuseAlpha( fAlpha ); + if( m_fOverrideAdd != -1 ) + fAddAlpha = m_fOverrideAdd; int iGrayPartFrameNo = m_ColorNote[iCol].GetGrayPartFrameNoFromIndexAndBeat( roundf(fIndex), m_fSongBeat ); @@ -109,9 +109,7 @@ void NoteField::CreateHoldNoteInstance( ColorNoteInstance &cni, const bool bActi const float fYPos = ArrowGetYPos( m_PlayerOptions, fYOffset ); const float fRotation = ArrowGetRotation( m_PlayerOptions, iCol, fYOffset ); const float fXPos = ArrowGetXPos( m_PlayerOptions, iCol, fYOffset, m_fSongBeat ); - float fAlpha = ArrowGetAlpha( m_PlayerOptions, fYPos ); - if( m_fOverrideAlpha != -1 ) - fAlpha = m_fOverrideAlpha; + const float fAlpha = ArrowGetAlpha( m_PlayerOptions, fYPos ); int iGrayPartFrameNo; if( bActive && m_Mode == MODE_DANCING ) @@ -125,7 +123,9 @@ void NoteField::CreateHoldNoteInstance( ColorNoteInstance &cni, const bool bActi colorLeading.a = 1; D3DXCOLOR colorTrailing = colorLeading; - const float fAddAlpha = m_ColorNote[iCol].GetAddAlphaFromDiffuseAlpha( fAlpha ); + float fAddAlpha = m_ColorNote[iCol].GetAddAlphaFromDiffuseAlpha( fAlpha ); + if( m_fOverrideAdd != -1 ) + fAddAlpha = m_fOverrideAdd; ColorNoteInstance instance = { fXPos, fYPos, fRotation, fAlpha, colorLeading, colorTrailing, fAddAlpha, iGrayPartFrameNo }; cni = instance; @@ -169,7 +169,7 @@ void NoteField::DrawBPMText( const int iIndex, const float fBPM ) m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(1,0,0,1) ); m_textMeasureNumber.SetAddColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) ); m_textMeasureNumber.SetText( ssprintf("%.2f", fBPM) ); - m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 50, fYPos ); + m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 60, fYPos ); m_textMeasureNumber.Draw(); } @@ -178,10 +178,10 @@ void NoteField::DrawFreezeText( const int iIndex, const float fSecs ) const float fYOffset = ArrowGetYOffset( m_PlayerOptions, (float)iIndex, m_fSongBeat ); const float fYPos = ArrowGetYPos( m_PlayerOptions, fYOffset ); - m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(0,0,0.6f,1) ); + m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0,1) ); m_textMeasureNumber.SetAddColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) ); m_textMeasureNumber.SetText( ssprintf("%.2f", fSecs) ); - m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 20, fYPos ); + m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 10, fYPos ); m_textMeasureNumber.Draw(); } diff --git a/stepmania/src/NoteField.h b/stepmania/src/NoteField.h index c2748ad7f7..987a5822f7 100644 --- a/stepmania/src/NoteField.h +++ b/stepmania/src/NoteField.h @@ -45,7 +45,7 @@ public: float m_fBeginMarker, m_fEndMarker; // only used with MODE_EDIT - float m_fOverrideAlpha; // -1 of not overriding + float m_fOverrideAdd; // -1 of not overriding protected: inline void CreateTapNoteInstance( ColorNoteInstance &cni, const int iCol, const float fIndex, const D3DXCOLOR color = D3DXCOLOR(-1,-1,-1,-1) ); diff --git a/stepmania/src/Notes.cpp b/stepmania/src/Notes.cpp index 696072b1e7..f983b5c628 100644 --- a/stepmania/src/Notes.cpp +++ b/stepmania/src/Notes.cpp @@ -116,9 +116,9 @@ bool Notes::LoadFromBMSFile( const CString &sPath ) { LOG->WriteLine( "Notes::LoadFromBMSFile( '%s' )", sPath ); - this->GetNoteData(); // make sure NoteData is loaded - - + // make sure NoteData is loaded + ASSERT( m_pNoteData == NULL ); + m_pNoteData = new NoteData; int tempNotes[MAX_NOTE_TRACKS][MAX_TAP_NOTE_ROWS]; @@ -618,7 +618,7 @@ void Notes::LoadFromSMTokens( const CString &sDifficultyClass, const CString &sMeter, const CString &sRadarValues, - const CString &sNoteDataOut, + const CString &sNoteData, const bool bLoadNoteData ) { @@ -644,12 +644,23 @@ void Notes::LoadFromSMTokens( // // Load NoteData // - NoteData *pND = GetNoteData(); + if( !bLoadNoteData ) + { + SAFE_DELETE( m_pNoteData ); + return; // don't continue + } + // else bLoadNoteData... - pND->m_iNumTracks = NotesTypeToNumTracks( m_NotesType ); + if( m_pNoteData != NULL ) // already loaded + return; + // else not already loaded... + + m_pNoteData = new NoteData(); + + m_pNoteData->m_iNumTracks = NotesTypeToNumTracks( m_NotesType ); CStringArray asNoteData; - split( sNoteDataOut, ",", asNoteData, true ); + split( sNoteData, ",", asNoteData, true ); for( int i=0; im_iNumTracks != sNoteLine.GetLength() ) - throw RageException( "Actual number of note columns (%d) is different from the NotesType (%d).", pND->m_iNumTracks, sNoteLine.GetLength() ); + if( m_pNoteData->m_iNumTracks != sNoteLine.GetLength() ) + throw RageException( "Actual number of note columns (%d) is different from the NotesType (%d).", m_pNoteData->m_iNumTracks, sNoteLine.GetLength() ); for( int c=0; cm_TapNotes[c][iIndex] = sNoteLine[c]; + m_pNoteData->m_TapNotes[c][iIndex] = sNoteLine[c]; } } - - } void Notes::WriteSMNotesTag( FILE* fp ) { + fprintf( fp, "\n//---------------%s - %s----------------\n", NotesTypeToString(m_NotesType), m_sDescription ); fprintf( fp, "#NOTES:\n" ); fprintf( fp, " %s:\n", NotesTypeToString(m_NotesType) ); fprintf( fp, " %s:\n", m_sDescription ); @@ -702,11 +712,11 @@ void Notes::WriteSMNotesTag( FILE* fp ) // // fill in sNoteDataOut // - NoteData* pND = GetNoteData(); + ASSERT( m_pNoteData != NULL ); - pND->ConvertHoldNotesTo2sAnd3s(); + m_pNoteData->ConvertHoldNotesTo2sAnd3s(); - float fLastBeat = pND->GetLastBeat(); + float fLastBeat = m_pNoteData->GetLastBeat(); int iLastMeasure = int( fLastBeat/BEATS_PER_MEASURE ); for( int m=0; m<=iLastMeasure; m++ ) // foreach measure @@ -728,7 +738,7 @@ void Notes::WriteSMNotesTag( FILE* fp ) if( i % iNoteIndexSpacing == 0 ) continue; // skip - if( !pND->IsRowEmpty(i) ) + if( !m_pNoteData->IsRowEmpty(i) ) { bFoundSmallerNote = true; break; @@ -749,19 +759,19 @@ void Notes::WriteSMNotesTag( FILE* fp ) for( int i=iMeasureStartIndex; i<=iMeasureLastIndex; i+=iNoteIndexSpacing ) { CString sLineString; - for( int c=0; cm_iNumTracks; c++ ) - sLineString += pND->m_TapNotes[c][i]; + for( int c=0; cm_iNumTracks; c++ ) + sLineString += m_pNoteData->m_TapNotes[c][i]; fprintf( fp, "%s", sLineString ); - if( i == iMeasureLastIndex ) - fprintf( fp, ",\n" ); - else + if( i <= iMeasureLastIndex-iNoteIndexSpacing ) fprintf( fp, "\n" ); } + if( m != iLastMeasure ) + fprintf( fp, ",\n" ); } fprintf( fp, ";\n" ); - pND->Convert2sAnd3sToHoldNotes(); + m_pNoteData->Convert2sAnd3sToHoldNotes(); } @@ -807,11 +817,7 @@ bool Notes::IsNoteDataLoaded() NoteData* Notes::GetNoteData() { - if( m_pNoteData != NULL ) - return m_pNoteData; - - m_pNoteData = new NoteData; - + ASSERT( m_pNoteData != NULL ); return m_pNoteData; } diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index ad07ae8a7a..bd46f4f4b6 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -78,7 +78,6 @@ public: void SetNoteData( NoteData* pNewNoteData ); void DeleteNoteData(); -protected: static DifficultyClass DifficultyClassFromDescriptionAndMeter( CString sDescription, int iMeter ); NoteData* m_pNoteData; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index f41eff8c24..5f2bee7cdc 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -76,6 +76,7 @@ void Player::Load( PlayerNumber player_no, StyleDef* pStyleDef, NoteData* pNoteD { //LOG->WriteLine( "Player::Load()", ); this->CopyAll( pNoteData ); + NoteDataWithScoring::Init(); m_PlayerNumber = player_no; m_PlayerOptions = po; @@ -197,7 +198,8 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference m_frameJudgeAndCombo.Update( fDeltaTime ); - m_pLifeMeter->SetBeat( fSongBeat ); + if( m_pLifeMeter ) + m_pLifeMeter->SetBeat( fSongBeat ); m_GrayArrowRow.Update( fDeltaTime, fSongBeat ); m_NoteField.Update( fDeltaTime, fSongBeat ); @@ -318,7 +320,7 @@ void Player::HandlePlayerStep( float fSongBeat, int col, float fMaxBeatDiff ) if( fPercentFromPerfect < 0.30f ) score = TNS_PERFECT; else if( fPercentFromPerfect < 0.55f ) score = TNS_GREAT; - else if( fPercentFromPerfect < 0.75f ) score = TNS_GOOD; + else if( fPercentFromPerfect < 0.78f ) score = TNS_GOOD; else score = TNS_BOO; @@ -350,7 +352,8 @@ void Player::OnRowDestroyed( float fSongBeat, int col, float fMaxBeatDiff, int i // update the judgement, score, and life m_Judgement.SetJudgement( score ); - m_pLifeMeter->ChangeLife( score ); + if( m_pLifeMeter ) + m_pLifeMeter->ChangeLife( score ); // remove this row from the NoteField @@ -363,7 +366,8 @@ void Player::OnRowDestroyed( float fSongBeat, int col, float fMaxBeatDiff, int i { m_GhostArrowRow.TapNote( c, score, m_Combo.GetCurrentCombo()>100 ); // show the ghost arrow for this column - m_pScore->AddToScore( score, m_Combo.GetCurrentCombo() ); // update score - called once per note in this row + if( m_pScore ) + m_pScore->AddToScore( score, m_Combo.GetCurrentCombo() ); // update score - called once per note in this row // update combo - called once per note in this row switch( score ) @@ -419,7 +423,8 @@ int Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ) bFoundAMissInThisRow = true; } if( bFoundAMissInThisRow ) - m_pLifeMeter->ChangeLife( TNS_MISS ); + if( m_pLifeMeter ) + m_pLifeMeter->ChangeLife( TNS_MISS ); } } @@ -493,13 +498,13 @@ GameplayStatistics Player::GetGameplayStatistics() GSreturn.max_combo = m_Combo.GetMaxCombo(); GSreturn.score = m_pScore ? m_pScore->GetScore() : 0; - GSreturn.failed = this->m_pLifeMeter->HasFailed(); + GSreturn.failed = m_pLifeMeter ? m_pLifeMeter->HasFailed() : false; for( int r=0; rGetRadarValue( (RadarCatrgory)r, SONGMAN->GetCurrentSong()->m_fMusicLengthSeconds ); - GSreturn.fRadarActual[r] = this->GetActualRadarValue( (RadarCatrgory)r, SONGMAN->GetCurrentSong()->m_fMusicLengthSeconds ); + GSreturn.fRadarPossible[r] = this->GetRadarValue( (RadarCategory)r, SONGMAN->GetCurrentSong()->m_fMusicLengthSeconds ); + GSreturn.fRadarActual[r] = this->GetActualRadarValue( (RadarCategory)r, SONGMAN->GetCurrentSong()->m_fMusicLengthSeconds ); GSreturn.fRadarPossible[r] = clamp( GSreturn.fRadarPossible[r], 0, 1 ); GSreturn.fRadarActual[r] = clamp( GSreturn.fRadarActual[r], 0, 1 ); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 6b64e8cb60..76ba4d1781 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -51,8 +51,8 @@ public: GameplayStatistics GetGameplayStatistics(); - void SetOverrideAlpha( float fAlpha ) { m_NoteField.m_fOverrideAlpha = fAlpha; }; - float GetOverrideAlpha() { return m_NoteField.m_fOverrideAlpha; }; + void SetOverrideAdd( float fAdd ) { m_NoteField.m_fOverrideAdd = fAdd; }; + float GetOverrideAdd() { return m_NoteField.m_fOverrideAdd; }; protected: void OnRowDestroyed( float fSongBeat, int col, float fMaxBeatDiff, int iStepIndex ); diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index e2933be797..9ccebd3c36 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -22,7 +22,7 @@ PrefsManager::PrefsManager() { m_bWindowed = false; m_bHighDetail = true; - m_bHighTextureDetail = true; + m_bHighTextureDetail = false; m_bIgnoreJoyAxes = false; m_bShowFPS = false; m_visMode = VIS_MODE_ANIMATION; @@ -30,7 +30,7 @@ PrefsManager::PrefsManager() m_bEventMode = false; m_iNumArcadeStages = 3; m_bAutoPlay = false; - m_fJudgeWindow = 0.10f; + m_fJudgeWindow = 0.12f; for( int p=0; pm_iRefCount++; if( bForceReload ) - pTexture->Reload( m_iMaxTextureSize, m_iTextureColorDepth, iMipMaps, iAlphaBits, bDither ); + pTexture->Reload( m_iMaxTextureSize, m_iTextureColorDepth, iMipMaps, iAlphaBits, bDither, bStretch ); LOG->WriteLine( "RageTextureManager: '%s' now has %d references.", sTexturePath, pTexture->m_iRefCount ); } diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 88da4ffc3b..5286cbbf96 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -340,7 +340,9 @@ DWORD GetFileSizeInBytes( const CString &sFilePath ) NULL // handle to file with attributes to ); - return GetFileSize( hFile, NULL ); + DWORD dwSize = GetFileSize( hFile, NULL ); + CloseHandle( hFile ); + return dwSize; } bool DoesFileExist( const CString &sPath ) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index ef9530c1c2..c5dcd9150c 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -42,10 +42,12 @@ const float INFO_X = SCREEN_RIGHT - 10 ; const float INFO_Y = SCREEN_BOTTOM - 10; // bottom aligned const float MENU_WIDTH = 110; -const float EDIT_CENTER_X = CENTER_X + 100; - +const float EDIT_X = CENTER_X + 100; const float EDIT_GRAY_Y = CENTER_Y - 2.0f * (float)ARROW_SIZE; +const float PLAYER_X = EDIT_X; +const float PLAYER_Y = SCREEN_TOP; + const CString HELP_TEXT = "Esc: exit\n" "S: save changes\n" @@ -67,12 +69,13 @@ const CString HELP_TEXT = "D: Toggle difficulty\n" "Ins: Insert blank beat\n" "Del: Delete current beat and shift\n" - "F1,F2/F3,F4: Decrease/increase BPM at cur beat\n" - "F5,F6/F7,F8: Dec/inc freeze secs at cur beat\n" - "F9,F10/F11,F12: Decrease/increase music offset\n" - "NumPad / * - + : Dec/inc music preview start\n" - "NumPad 0/period: Dec/inc music length\n" - "M: Play music preview\n"; + " Hold F keys for faster change:\n" + "F7/F8: Decrease/increase BPM at cur beat\n" + "F9/F10: Dec/inc freeze secs at cur beat\n" + "F11/F12: Decrease/increase music offset\n" + "F1/F2 : Dec/inc sample music start\n" + "NumPad -/+: Dec/inc sample music length\n" + "M: Play sample music\n"; @@ -85,6 +88,14 @@ ScreenEdit::ScreenEdit() LOG->WriteLine( "ScreenEdit::ScreenEdit()" ); m_pSong = SONGMAN->GetCurrentSong(); + m_pSong->LoadNoteData(); + + m_pNotes = SONGMAN->m_pCurNotes[PLAYER_1]; + if( m_pNotes == NULL ) + { + m_pNotes = new Notes; + m_pSong->m_arrayNotes.Add( m_pNotes ); + } m_Mode = MODE_EDIT; @@ -95,42 +106,37 @@ ScreenEdit::ScreenEdit() m_PlayerOptions.m_ColorType = PlayerOptions::COLOR_NOTE; // m_PlayerOptions.m_bShowMeasureBars = true; - m_DifficultyClass = CLASS_EASY; - m_sprBackground.Load( THEME->GetPathTo( GRAPHIC_EDIT_BACKGROUND ) ); m_sprBackground.StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); - m_GranularityIndicator.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_GranularityIndicator.SetXY( EDIT_X, EDIT_GRAY_Y ); m_GranularityIndicator.Load(); m_GranularityIndicator.SetZoom( 0.5f ); - m_GrayArrowRowEdit.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_GrayArrowRowEdit.SetXY( EDIT_X, EDIT_GRAY_Y ); m_GrayArrowRowEdit.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions ); m_GrayArrowRowEdit.SetZoom( 0.5f ); - NoteData noteData; - noteData.m_iNumTracks = GAMEMAN->GetCurrentStyleDef()->m_iColsPerPlayer; - if( SONGMAN->m_pCurNotes[PLAYER_1] != NULL ) - noteData = *SONGMAN->GetCurrentNotes(PLAYER_1)->GetNoteData(); - - m_NoteFieldEdit.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_NoteFieldEdit.SetXY( EDIT_X, EDIT_GRAY_Y ); m_NoteFieldEdit.SetZoom( 0.5f ); - m_NoteFieldEdit.Load( ¬eData, PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 10, 12, NoteField::MODE_EDITING ); + m_NoteFieldEdit.Load( m_pNotes->GetNoteData(), PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 10, 12, NoteField::MODE_EDITING ); m_rectRecordBack.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) ); m_rectRecordBack.SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); - m_GrayArrowRowRecord.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_GrayArrowRowRecord.SetXY( EDIT_X, EDIT_GRAY_Y ); m_GrayArrowRowRecord.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions ); m_GrayArrowRowRecord.SetZoom( 1.0f ); - m_NoteFieldRecord.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_NoteFieldRecord.SetXY( EDIT_X, EDIT_GRAY_Y ); m_NoteFieldRecord.SetZoom( 1.0f ); - m_NoteFieldRecord.Load( ¬eData, PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 2, 5, NoteField::MODE_EDITING ); + m_NoteFieldRecord.Load( m_pNotes->GetNoteData(), PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 2, 5, NoteField::MODE_EDITING ); - m_Player.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), ¬eData, PlayerOptions(), NULL, NULL, 1 ); - m_Player.SetXY( EDIT_CENTER_X, EDIT_GRAY_Y ); + m_Clipboard.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks; + + m_Player.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_pNotes->GetNoteData(), PlayerOptions(), NULL, NULL, 1 ); + m_Player.SetXY( PLAYER_X, PLAYER_Y ); m_Fade.SetClosed(); @@ -283,13 +289,15 @@ void ScreenEdit::Update( float fDeltaTime ) "Difficulty = %s\n" "Description = %s\n" "Num notes tap: %d, hold: %d\n" + "MusicOffsetSeconds: %.2f\n" "Preview start: %.2f, length = %.2f\n", sNoteType, m_fBeat, m_NoteFieldEdit.m_fBeginMarker, m_NoteFieldEdit.m_fEndMarker, - DifficultyClassToString( m_DifficultyClass ), + DifficultyClassToString( m_pNotes->m_DifficultyClass ), SONGMAN->GetCurrentNotes(PLAYER_1) ? SONGMAN->GetCurrentNotes(PLAYER_1)->m_sDescription : "no description", iNumTapNotes, iNumHoldNotes, + m_pSong->m_fOffsetInSeconds, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds ) ); } @@ -391,6 +399,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } break; case DIK_ESCAPE: + m_pSong->LoadFromSMFile( m_pSong->GetCacheFilePath(), true ); SCREENMAN->SetNewScreen( new ScreenEditMenu ); break; case DIK_S: @@ -582,6 +591,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case DIK_DELETE: { NoteData temp; + temp.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks; int iTakeFromRow; int iPasteAtRow; switch( DeviceI.button ) @@ -629,8 +639,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ break; case DIK_V: { - int iSrcFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker ); - int iSrcLastRow = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker ); + int iSrcFirstRow = 0; + int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() ); int iDestFirstRow = BeatToNoteRow( m_fBeat ); m_NoteFieldEdit.CopyRange( &m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow ); @@ -639,25 +649,25 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case DIK_D: { - m_DifficultyClass = DifficultyClass( (m_DifficultyClass+1)%NUM_DIFFICULTY_CLASSES ); + DifficultyClass &dc = m_pNotes->m_DifficultyClass; + dc = DifficultyClass( (dc+1)%NUM_DIFFICULTY_CLASSES ); } break; - case DIK_F1: - case DIK_F2: - case DIK_F3: - case DIK_F4: + case DIK_F7: + case DIK_F8: { float fBPM = m_pSong->GetBPMAtBeat( m_fBeat ); - float fNewBPM; + float fDeltaBPM; switch( DeviceI.button ) { - case DIK_F1: fNewBPM = fBPM - 0.1f; break; - case DIK_F2: fNewBPM = fBPM + 0.1f; break; - case DIK_F3: fNewBPM = fBPM - 0.01f; break; - case DIK_F4: fNewBPM = fBPM + 0.01f; break; + case DIK_F7: fDeltaBPM = - 0.025f; break; + case DIK_F8: fDeltaBPM = + 0.025f; break; default: ASSERT(0); } + if( type == IET_FAST_REPEAT ) + fDeltaBPM *= 40; + float fNewBPM = fBPM + fDeltaBPM; for( int i=0; im_BPMSegments.GetSize(); i++ ) if( m_pSong->m_BPMSegments[i].m_fStartBeat == m_fBeat ) @@ -670,27 +680,25 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } else // BPMSegment being modified is m_BPMSegments[i] { - if( i > 0 && m_pSong->m_BPMSegments[i-1].m_fBPM == fNewBPM ) + if( i > 0 && fabsf(m_pSong->m_BPMSegments[i-1].m_fBPM - fNewBPM) < 0.025f ) m_pSong->m_BPMSegments.RemoveAt( i ); else m_pSong->m_BPMSegments[i].m_fBPM = fNewBPM; } } break; - case DIK_F5: - case DIK_F6: - case DIK_F7: - case DIK_F8: + case DIK_F9: + case DIK_F10: { float fFreezeDelta; switch( DeviceI.button ) { - case DIK_F5: fFreezeDelta = -0.1f; break; - case DIK_F6: fFreezeDelta = +0.1f; break; - case DIK_F7: fFreezeDelta = -0.01f; break; - case DIK_F8: fFreezeDelta = +0.01f; break; + case DIK_F9: fFreezeDelta = -0.025f; break; + case DIK_F10: fFreezeDelta = +0.025f; break; default: ASSERT(0); } + if( type == IET_FAST_REPEAT ) + fFreezeDelta *= 40; for( int i=0; im_FreezeSegments.GetSize(); i++ ) { @@ -707,27 +715,64 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ else // FreezeSegment being modified is m_FreezeSegments[i] { m_pSong->m_FreezeSegments[i].m_fFreezeSeconds += fFreezeDelta; - if( m_pSong->m_FreezeSegments[i].m_fFreezeSeconds < 0 ) + if( m_pSong->m_FreezeSegments[i].m_fFreezeSeconds <= 0 ) m_pSong->m_FreezeSegments.RemoveAt( i ); } } break; - case DIK_F9: m_pSong->m_fOffsetInSeconds -= 0.1f; break; - case DIK_F10: m_pSong->m_fOffsetInSeconds += 0.1f; break; - case DIK_F11: m_pSong->m_fOffsetInSeconds -= 0.01f; break; - case DIK_F12: m_pSong->m_fOffsetInSeconds += 0.01f; break; + case DIK_F11: + case DIK_F12: + { + float fOffsetDelta; + switch( DeviceI.button ) + { + case DIK_F11: fOffsetDelta = -0.025f; break; + case DIK_F12: fOffsetDelta = +0.025f; break; + default: ASSERT(0); + } + if( type == IET_FAST_REPEAT ) + fOffsetDelta *= 40; + + m_pSong->m_fOffsetInSeconds += fOffsetDelta; + } + break; case DIK_M: MUSIC->Load( m_pSong->GetMusicPath() ); MUSIC->Play( false, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds ); break; - case DIK_DIVIDE: m_pSong->m_fMusicSampleStartSeconds -= 0.1f; break; - case DIK_MULTIPLY: m_pSong->m_fMusicSampleStartSeconds += 0.1f; break; - case DIK_SUBTRACT: m_pSong->m_fMusicSampleStartSeconds -= 0.01f; break; - case DIK_ADD: m_pSong->m_fMusicSampleStartSeconds += 0.01f; break; - case DIK_NUMPAD0: m_pSong->m_fMusicSampleLengthSeconds -= 0.1f; break; - case DIK_NUMPADPERIOD: m_pSong->m_fMusicSampleLengthSeconds += 0.1f; break; + case DIK_F1: + case DIK_F2: + { + float fOffsetDelta; + switch( DeviceI.button ) + { + case DIK_F1: fOffsetDelta = -0.025f; break; + case DIK_F2: fOffsetDelta = +0.025f; break; + default: ASSERT(0); + } + if( type == IET_FAST_REPEAT ) + fOffsetDelta *= 40; - } + m_pSong->m_fMusicSampleStartSeconds += fOffsetDelta; + } + break; + case DIK_SUBTRACT: + case DIK_ADD: + { + float fDelta; + switch( DeviceI.button ) + { + case DIK_SUBTRACT: fDelta = -0.025f; break; + case DIK_ADD: fDelta = +0.025f; break; + default: ASSERT(0); + } + if( type == IET_FAST_REPEAT ) + fDelta *= 40; + + m_pSong->m_fMusicSampleLengthSeconds += fDelta; + } + break; + } } } diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 2ab3848f91..ed741ee122 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -45,6 +45,7 @@ protected: EditMode m_Mode; Song* m_pSong; + Notes* m_pNotes; PlayerOptions m_PlayerOptions; @@ -61,7 +62,6 @@ protected: float m_fTrailingBeat; // this approaches m_fBeat float m_fBeat; - DifficultyClass m_DifficultyClass; NoteData m_Clipboard; RageSoundSample m_soundChangeLine; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 41b8095ffb..192746ab09 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -76,63 +76,6 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) ASSERT(0); } -/* - ////////////////////////// - // Fill in some fake information for debugging - ////////////////////////// - m_ResultMode = RM_ARCADE_SUMMARY; - GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; - SONGMAN->SetCurrentSong( SONGMAN->m_pSongs[0] ); - for( p=0; pSetCurrentNotes((PlayerNumber)p, SONGMAN->GetCurrentSong()->m_arrayNotes[0]); - { - SONGMAN->m_aGameplayStatistics[p].Add( GameplayStatistics() ); - GameplayStatistics &GS = SONGMAN->m_aGameplayStatistics[p][SONGMAN->m_aGameplayStatistics[p].GetSize()-1]; - GS.pSong = SONGMAN->m_pSongs[0]; - GS.dc = CLASS_EASY; - GS.meter = 5; - GS.iPossibleDancePoints = 300; - GS.iActualDancePoints = 255; - GS.failed = false; - - GS.perfect = GS.great = GS.good = GS.boo = GS.miss = GS.ok = GS.ng = GS.max_combo = 100; - GS.score = 100; - for( int r=0; rm_aGameplayStatistics[p].Add( GameplayStatistics() ); - GameplayStatistics &GS = SONGMAN->m_aGameplayStatistics[p][SONGMAN->m_aGameplayStatistics[p].GetSize()-1]; - GS.pSong = SONGMAN->m_pSongs[0]; - GS.dc = CLASS_EASY; - GS.meter = 5; - GS.iPossibleDancePoints = 300; - GS.iActualDancePoints = 255; - GS.failed = false; - - GS.perfect = GS.great = GS.good = GS.boo = GS.miss = GS.ok = GS.ng = GS.max_combo = 100; - GS.score = 100; - for( int r=0; rm_aGameplayStatistics[p].Add( GameplayStatistics() ); - GameplayStatistics &GS = SONGMAN->m_aGameplayStatistics[p][SONGMAN->m_aGameplayStatistics[p].GetSize()-1]; - GS.pSong = SONGMAN->m_pSongs[0]; - GS.dc = CLASS_EASY; - GS.meter = 5; - GS.iPossibleDancePoints = 300; - GS.iActualDancePoints = 255; - GS.failed = false; - - GS.perfect = GS.great = GS.good = GS.boo = GS.miss = GS.ok = GS.ng = GS.max_combo = 100; - GS.score = 100; - for( int r=0; rLoadNoteData(); Notes* pNotes[NUM_PLAYERS]; for( p=0; pm_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) { - fPositionSeconds += (SOUND->GetPlayLatency()+0.06f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.06 seconds to make them play a tiny bit earlier + fPositionSeconds += (SOUND->GetPlayLatency()+0.04f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.04 seconds to make them play a tiny bit earlier m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); @@ -512,15 +513,15 @@ void ScreenGameplay::Update( float fDeltaTime ) if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) ) continue; - float fOverrideAlpha = m_Player[p].GetOverrideAlpha(); - if( fOverrideAlpha == -1 ) + float fOverrideAdd = m_Player[p].GetOverrideAdd(); + if( fOverrideAdd == -1 ) { - m_Player[p].SetOverrideAlpha( 0 ); + m_Player[p].SetOverrideAdd( 0 ); } else { - float fNewAlpha = min( 1, fOverrideAlpha + fDeltaTime ); - m_Player[p].SetOverrideAlpha( fNewAlpha ); + float fNewAdd = min( 1, fOverrideAdd + fDeltaTime ); + m_Player[p].SetOverrideAdd( fNewAdd ); } } diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 12663f0a30..e82d295ad0 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -37,7 +37,6 @@ const float LINE_GAP_Y = 36; const ScreenMessage SM_PlaySample = ScreenMessage(SM_User-4); const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User-5); const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User-6); -const ScreenMessage SM_JustPressedNext = ScreenMessage(SM_User-7); ScreenOptions::ScreenOptions( CString sBackgroundPath, CString sTopEdgePath ) @@ -276,6 +275,9 @@ void ScreenOptions::HandleScreenMessage( const ScreenMessage SM ) { switch( SM ) { + case SM_MenuTimer: + this->MenuStart(PLAYER_1); + break; case SM_GoToPrevState: this->ExportOptions(); this->GoToPrevState(); diff --git a/stepmania/src/ScreenSongOptions.cpp b/stepmania/src/ScreenSongOptions.cpp index 86a1b4eb84..1d81cb4421 100644 --- a/stepmania/src/ScreenSongOptions.cpp +++ b/stepmania/src/ScreenSongOptions.cpp @@ -24,10 +24,9 @@ OptionLineData g_SongOptionsLines[] = { - { "Fail", 3, {"ARCADE","END OF SONGMAN","OFF"} }, + { "Fail", 3, {"ARCADE","END OF SONG","OFF"} }, { "Assist", 2, {"OFF","TICK"} }, { "Rate", 7, {"70%","80%","90%","100%","110%","120%","130%"} }, - { "Pitch", 7, {"-1.5","-1","-0.5","+0","+0.5","+1","+1.5"} }, { "Bars", 2, {"OFF","ON"} }, }; const int NUM_SONG_OPTIONS_LINES = sizeof(g_SongOptionsLines)/sizeof(OptionLineData); @@ -36,7 +35,6 @@ enum { SO_FAIL = 0, SO_ASSIST, SO_RATE, - SO_PITCH, SO_BARS }; @@ -71,15 +69,6 @@ void ScreenSongOptions::ImportOptions() else if( so.m_fMusicRate == 1.20f ) m_iSelectedOption[0][SO_RATE] = 5; else if( so.m_fMusicRate == 1.30f ) m_iSelectedOption[0][SO_RATE] = 6; else m_iSelectedOption[0][SO_RATE] = 3; - - if( so.m_fMusicRate == -1.5f ) m_iSelectedOption[0][SO_PITCH] = 0; - else if( so.m_fMusicRate == -1.0f ) m_iSelectedOption[0][SO_PITCH] = 1; - else if( so.m_fMusicRate == -0.5f ) m_iSelectedOption[0][SO_PITCH] = 2; - else if( so.m_fMusicRate == 0.0f ) m_iSelectedOption[0][SO_PITCH] = 3; - else if( so.m_fMusicRate == 0.5f ) m_iSelectedOption[0][SO_PITCH] = 4; - else if( so.m_fMusicRate == 1.0f ) m_iSelectedOption[0][SO_PITCH] = 5; - else if( so.m_fMusicRate == 1.5f ) m_iSelectedOption[0][SO_PITCH] = 6; - else m_iSelectedOption[0][SO_PITCH] = 3; } void ScreenSongOptions::ExportOptions() diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 7f000b3861..d0c39e4ddb 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -94,7 +94,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_textVersion.Load( THEME->GetPathTo(FONT_NORMAL) ); m_textVersion.SetHorizAlign( Actor::align_right ); - m_textVersion.SetText( "v3.0 compatibility test" ); + m_textVersion.SetText( "v3.0 beta 1" ); m_textVersion.SetDiffuseColor( D3DXCOLOR(0.6f,0.6f,0.6f,1) ); // light gray m_textVersion.SetXY( SCREEN_RIGHT-16, SCREEN_BOTTOM-20 ); m_textVersion.SetZoom( 0.5f ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 7f16a329db..df169a0093 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -18,7 +18,7 @@ #include "Song.h" -const int FILE_CACHE_VERSION = 11; // increment this when the cache file format changes +const int FILE_CACHE_VERSION = 25; // increment this when the SM file format changes int CompareBPMSegments(const void *arg1, const void *arg2) @@ -228,6 +228,16 @@ CString Song::GetCacheFilePath() return ssprintf( "Cache\\%d", GetHashForString(m_sSongDir) ); } +CString Song::GetSongFilePath() +{ + CStringArray asFileNames; + GetDirListing( m_sSongDir+"*.sm", asFileNames ); + if( asFileNames.GetSize() > 0 ) + return m_sSongDir + asFileNames[0]; + else + return m_sSongDir + GetFullTitle() + ".sm"; +} + bool Song::LoadFromSongDir( CString sDir ) { LOG->WriteLine( "Song::LoadFromSongDir(%s)", sDir ); @@ -239,6 +249,11 @@ bool Song::LoadFromSongDir( CString sDir ) // save song dir m_sSongDir = sDir; + // save group name + CStringArray sDirectoryParts; + split( m_sSongDir, "\\", sDirectoryParts, true ); + m_sGroupName = sDirectoryParts[1]; + // // First look in the cache for this song (without loading NoteData) @@ -267,6 +282,15 @@ bool Song::LoadFromSongDir( CString sDir ) if( !DoesFileExist(GetCacheFilePath()) ) goto load_without_cache; LoadFromSMFile( GetCacheFilePath(), false ); // don't load NoteData + + // Save length of music + if( GetMusicPath() != "" ) + { + RageSoundStream sound; + sound.Load( GetMusicPath() ); + m_fMusicLengthSeconds = sound.GetLengthSeconds(); + } + LOG->WriteLine( "Loading '%s' from cache file '%s'.", m_sSongDir, GetCacheFilePath() ); return true; } @@ -320,31 +344,12 @@ bool Song::LoadFromBMSDir( CString sDir ) { LOG->WriteLine( "Song::LoadFromBMSDir(%s)", sDir ); - // make sure there is a trailing '\\' at the end of sDir - if( sDir.Right(1) != "\\" ) - sDir += "\\"; - - // save song dir - m_sSongDir = sDir; - - // get group name - CStringArray sDirectoryParts; - split( m_sSongDir, "\\", sDirectoryParts, true ); - m_sGroupName = sDirectoryParts[1]; - - CStringArray arrayBMSFileNames; GetDirListing( sDir + CString("*.bms"), arrayBMSFileNames ); if( arrayBMSFileNames.GetSize() == 0 ) throw RageException( "Couldn't find any BMS files in '%s'", sDir ); - - // Load the Song info from the first BMS file. Silly BMS duplicates the song info in every - // file. So, we read the song data from only the first BMS file and assume that the info - // is identical for every BMS file in the directory. - m_sSongFile = arrayBMSFileNames[0]; - // load the Notes from the rest of the BMS files for( int i=0; iWriteLine( "WARNING: Couldn't find tag '%s' in '%s'.", sTagToLookFor, GetSongFilePath() ); + LOG->WriteLine( "WARNING: Couldn't find tag '%s' in '%s'.", sTagToLookFor, sPath ); } else { @@ -545,6 +551,8 @@ bool Song::LoadFromBMSDir( CString sDir ) AddBPMSegment( newSeg ); LOG->WriteLine( "Inserting new BPM change at beat %f, BPM %f", newSeg.m_fStartBeat, newSeg.m_fBPM ); } + + file.Close(); } break; case 9: // freeze @@ -558,8 +566,8 @@ bool Song::LoadFromBMSDir( CString sDir ) // open the song file again and and look for this tag's value CStdioFile file; - if( !file.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Failed to open %s.", GetSongFilePath() ); + if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) + throw RageException( "Failed to open %s.", sPath ); CString line; while( file.ReadString(line) ) // foreach line @@ -613,7 +621,7 @@ bool Song::LoadFromBMSDir( CString sDir ) if( fFreezeSecs == -1 ) // we didn't find the line we were looking for { - LOG->WriteLine( "WARNING: Couldn't find tag '%s' in '%s'.", sTagToLookFor, GetSongFilePath() ); + LOG->WriteLine( "WARNING: Couldn't find tag '%s' in '%s'.", sTagToLookFor, sPath ); } else { @@ -621,6 +629,8 @@ bool Song::LoadFromBMSDir( CString sDir ) AddFreezeSegment( newSeg ); LOG->WriteLine( "Inserting new Freeze at beat %f, secs %f", newSeg.m_fStartBeat, newSeg.m_fFreezeSeconds ); } + + file.Close(); } break; } @@ -633,6 +643,7 @@ bool Song::LoadFromBMSDir( CString sDir ) LOG->WriteLine( "There is a BPM change at beat %f, BPM %f, index %d", m_BPMSegments[i].m_fStartBeat, m_BPMSegments[i].m_fBPM, i ); + file.Close(); return TRUE; } @@ -642,29 +653,17 @@ bool Song::LoadFromDWIFile( CString sPath ) { LOG->WriteLine( "Song::LoadFromDWIFile(%s)", sPath ); - // save song dir and file name - CString sDir, sFName, sExt; - splitrelpath(sPath, sDir, sFName, sExt); - m_sSongDir = sDir; - m_sSongFile = sFName+"."+sExt; - - // get group name - sDir.MakeLower(); - CStringArray sDirectoryParts; - split( m_sSongDir, "\\", sDirectoryParts, true ); - m_sGroupName = sDirectoryParts[1]; - CStdioFile file; - if( !file.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Error opening DWI file '%s'.", GetSongFilePath() ); + if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) + throw RageException( "Error opening DWI file '%s'.", sPath ); // read the whole file into a sFileText CString sFileText; CString buffer; while( file.ReadString(buffer) ) - sFileText += buffer; + sFileText += buffer + "\n"; file.Close(); // strip comments out of sFileText @@ -692,12 +691,15 @@ bool Song::LoadFromDWIFile( CString sPath ) // split the value string into tokens CStringArray arrayValueTokens; split( sValueString, ":", arrayValueTokens ); - + for( int j=0; jWriteLine( "Song::LoadFromSMDir(%s, %d)", sPath, bLoadNoteData ); + m_BPMSegments.RemoveAll(); + m_FreezeSegments.RemoveAll(); + int i; // get group name @@ -795,20 +800,17 @@ bool Song::LoadFromSMFile( CString sPath, bool bLoadNoteData ) split( m_sSongDir, "\\", sDirectoryParts, true ); m_sGroupName = sDirectoryParts[1]; - - m_sSongFile = sPath; - CStdioFile file; - if( !file.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Error opening DWI file '%s'.", GetSongFilePath() ); + if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) + throw RageException( "Error opening SM file '%s'.", sPath ); // read the whole file into a sFileText CString sFileText; CString buffer; while( file.ReadString(buffer) ) - sFileText += buffer; + sFileText += buffer + "\n"; file.Close(); // strip comments out of sFileText @@ -835,21 +837,21 @@ bool Song::LoadFromSMFile( CString sPath, bool bLoadNoteData ) // split the value string into tokens CStringArray arrayValueTokens; split( sValueString, ":", arrayValueTokens, false ); - + for( int j=0; jWriteLine( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fFreezeSeconds ); - m_FreezeSegments.Add( new_seg ); // add to back for now (we'll sort later) - SortFreezeSegmentsArray( m_FreezeSegments ); + AddFreezeSegment( new_seg ); } } @@ -924,28 +925,37 @@ bool Song::LoadFromSMFile( CString sPath, bool bLoadNoteData ) new_seg.m_fStartBeat = fBeat; new_seg.m_fBPM = fNewBPM; - // add and sort - m_BPMSegments.Add( new_seg ); - SortBPMSegmentsArray( m_BPMSegments ); + AddBPMSegment( new_seg ); } } else if( sValueName == "#NOTES" ) { - Notes* pNewNotes = new Notes; - if( arrayValueTokens.GetSize() != 7 ) - throw RageException( "The song file '%s' is has an incorrect number of parameters in a #NOTES tag.", GetSongFilePath() ); + Notes* pNewNotes = NULL; + // Check to see if this notes already has been allocated + for( int j=0; jm_NotesType == StringToNotesType(arrayValueTokens[1]) && + m_arrayNotes[j]->m_sDescription == arrayValueTokens[2] ) + pNewNotes = m_arrayNotes[j]; + + if( pNewNotes == NULL ) // we didn't find a match that was already loaded + { + pNewNotes = new Notes; + m_arrayNotes.Add( pNewNotes ); + } + + if( arrayValueTokens.GetSize() != 8 ) + throw RageException( "The song file '%s' is has %d in a #NOTES tag, but should have %d.", sPath, arrayValueTokens.GetSize(), 8 ); pNewNotes->LoadFromSMTokens( - arrayValueTokens[0], arrayValueTokens[1], arrayValueTokens[2], arrayValueTokens[3], arrayValueTokens[4], arrayValueTokens[5], arrayValueTokens[6], - bLoadNoteData ); - m_arrayNotes.Add( pNewNotes ); + arrayValueTokens[7], + bLoadNoteData ); } else @@ -1064,17 +1074,11 @@ void Song::TidyUpData() for( int i=0; im_pNoteData != NULL ); - float fMusicLength = m_fMusicLengthSeconds; - if( fMusicLength == 0 ) - fMusicLength = 100; - - pNM->m_fRadarValues[RADAR_STREAM] = pNM->GetNoteData()->GetStreamRadarValue( fMusicLength ); - pNM->m_fRadarValues[RADAR_VOLTAGE] = pNM->GetNoteData()->GetVoltageRadarValue( fMusicLength ); - pNM->m_fRadarValues[RADAR_AIR] = pNM->GetNoteData()->GetAirRadarValue( fMusicLength ); - pNM->m_fRadarValues[RADAR_FREEZE] = pNM->GetNoteData()->GetFreezeRadarValue( fMusicLength ); - pNM->m_fRadarValues[RADAR_CHAOS] = pNM->GetNoteData()->GetChaosRadarValue( fMusicLength ); + for( int r=0; rm_fRadarValues[r] = pNotes->GetNoteData()->GetRadarValue( (RadarCategory)r, m_fMusicLengthSeconds ); } } @@ -1107,24 +1111,28 @@ void Song::SaveToCacheFile() void Song::SaveToSMFile( CString sPath ) { if( sPath == "" ) + { sPath = GetSongFilePath(); + // + // rename all old files to avoid confusion + // + CStringArray arrayOldFileNames; + GetDirListing( m_sSongDir + "*.bms", arrayOldFileNames ); + GetDirListing( m_sSongDir + "*.dwi", arrayOldFileNames ); + + for( int i=0; iWriteLine( "Song::SaveToSMDir('%s')", sPath ); int i; - // - // rename all old files to avoid confusion - // - CStringArray arrayOldFileNames; - GetDirListing( m_sSongDir + CString("*.bms"), arrayOldFileNames ); - GetDirListing( m_sSongDir + CString("*.dwi"), arrayOldFileNames ); - - for( i=0; i 0 ) + { + if( m_arrayNotes[0]->m_pNoteData != NULL ) // if already loaded + return; + LoadFromSMFile( GetCacheFilePath(), true ); + } +} + Grade Song::GetGradeForDifficultyClass( NotesType nt, DifficultyClass dc ) { CArray aNotes; @@ -1307,4 +1325,3 @@ void SortSongPointerArrayByMostPlayed( CArray &arraySongPointers ) { qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByMostPlayed ); } - diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 075374b774..0eacdc4582 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -224,6 +224,7 @@ void SongManager::LoadDWISongDir( CString DWIHome ) void SongManager::FreeSongArray() { + // Memory is being corrupt somewhere, and this is causing a crash. Bad news. I'll fix it later. Let the OS free it for now. for( int i=0; i fBeat ) break; return m_BPMSegments[i].m_fBPM; };