From 9c6fe5cf646b6c96aec6c52454f7ab82e490fa0f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 13 Dec 2002 22:09:26 +0000 Subject: [PATCH] Add NoteDataUtil and move some stuff into it --- stepmania/src/NoteData.cpp | 316 ++++++++++++++++++------------------- stepmania/src/NoteData.h | 18 ++- stepmania/src/Notes.cpp | 4 +- 3 files changed, 172 insertions(+), 166 deletions(-) diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 6a82671ca8..e3e79d143a 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -20,7 +20,7 @@ #include "RageException.h" #include "GameState.h" #include "math.h" - +#include "NotesLoaderSM.h" NoteData::NoteData() @@ -38,126 +38,6 @@ NoteData::~NoteData() { } -void NoteData::LoadFromSMNoteDataString( CString sSMNoteData ) -{ - int iNumTracks = m_iNumTracks; - Init(); - m_iNumTracks = iNumTracks; - - // strip comments out of sSMNoteData - while( sSMNoteData.Find("//") != -1 ) - { - int iIndexCommentStart = sSMNoteData.Find("//"); - int iIndexCommentEnd = sSMNoteData.Find("\n", iIndexCommentStart); - if( iIndexCommentEnd == -1 ) // comment doesn't have an end? - sSMNoteData.Delete( iIndexCommentStart, 2 ); - else - sSMNoteData.Delete( iIndexCommentStart, iIndexCommentEnd-iIndexCommentStart ); - } - - CStringArray asMeasures; - split( sSMNoteData, ",", asMeasures, true ); // ignore empty is important - for( unsigned m=0; mConvert2sAnd3sToHoldNotes(); - - Compress(); -} - -CString NoteData::GetSMNoteDataString() -{ - this->ConvertHoldNotesTo2sAnd3s(); - - float fLastBeat = GetLastBeat(); - int iLastMeasure = int( fLastBeat/BEATS_PER_MEASURE ); - - CStringArray asMeasureStrings; - - for( int m=0; m<=iLastMeasure; m++ ) // foreach measure - { - NoteType nt = GetSmallestNoteTypeForMeasure( m ); - int iRowSpacing; - if( nt == NOTE_TYPE_INVALID ) - iRowSpacing = 1; - else - iRowSpacing = int(roundf( NoteTypeToBeat(nt) * ROWS_PER_BEAT )); - - CStringArray asMeasureLines; - asMeasureLines.push_back( ssprintf(" // measure %d", m+1) ); - - const int iMeasureStartRow = m * ROWS_PER_MEASURE; - const int iMeasureLastRow = (m+1) * ROWS_PER_MEASURE - 1; - - for( int r=iMeasureStartRow; r<=iMeasureLastRow; r+=iRowSpacing ) - { - CString szLineString; - for( int t=0; tConvert2sAnd3sToHoldNotes(); - - return join( "\n,", asMeasureStrings ); -} - /* Clear [iNoteIndexBegin,iNoteIndexEnd]; that is, including iNoteIndexEnd. */ void NoteData::ClearRange( int iNoteIndexBegin, int iNoteIndexEnd ) { @@ -1006,43 +886,6 @@ void NoteData::LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTra } -NoteType NoteData::GetSmallestNoteTypeForMeasure( int iMeasureIndex ) -{ - const int iMeasureStartIndex = iMeasureIndex * ROWS_PER_MEASURE; - const int iMeasureLastIndex = (iMeasureIndex+1) * ROWS_PER_MEASURE - 1; - - // probe to find the smallest note type - NoteType nt; - for( nt=(NoteType)0; ntm_iNumTracks == GameManager::NotesTypeToNumTracks(m_NotesType) ); - m_sSMNoteData = pNewNoteData->GetSMNoteDataString(); + m_sSMNoteData = NoteDataUtil::GetSMNoteDataString(*pNewNoteData); } void Notes::GetNoteData( NoteData* pNoteDataOut ) const { pNoteDataOut->m_iNumTracks = GameManager::NotesTypeToNumTracks( m_NotesType ); - pNoteDataOut->LoadFromSMNoteDataString( m_sSMNoteData ); + NoteDataUtil::LoadFromSMNoteDataString( *pNoteDataOut, m_sSMNoteData ); } // Color is a function of Difficulty and Intended Style