diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d304b3c3c3..491df29f99 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -192,7 +192,7 @@ Notes* Course::GetNotesForStage( int iStage ) for( i=0; im_apNotes.size(); i++ ) { Notes* pNotes = pSong->m_apNotes[i]; - if( 0==stricmp(pNotes->m_sDescription, sDescription) && + if( 0==stricmp(pNotes->GetDescription(), sDescription) && GAMESTATE->GetCurrentStyleDef()->MatchesNotesType(pNotes->m_NotesType) ) return pNotes; } @@ -204,7 +204,7 @@ Notes* Course::GetNotesForStage( int iStage ) for( i=0; im_apNotes.size(); i++ ) { Notes* pNotes = pSong->m_apNotes[i]; - if( pNotes->m_Difficulty == dc && + if( pNotes->GetDifficulty() == dc && GAMESTATE->GetCurrentStyleDef()->MatchesNotesType(pNotes->m_NotesType) ) return pNotes; } diff --git a/stepmania/src/CourseContentsFrame.cpp b/stepmania/src/CourseContentsFrame.cpp index f556646363..65e295c31d 100644 --- a/stepmania/src/CourseContentsFrame.cpp +++ b/stepmania/src/CourseContentsFrame.cpp @@ -78,7 +78,7 @@ void CourseContentDisplay::Load( int iNum, Song* pSong, Notes* pNotes ) m_textFoot.SetText( "1" ); m_textFoot.SetDiffuse( colorNotes ); - m_textDifficultyNumber.SetText( ssprintf("%d", pNotes->m_iMeter) ); + m_textDifficultyNumber.SetText( ssprintf("%d", pNotes->GetMeter()) ); m_textDifficultyNumber.SetDiffuse( colorNotes ); } diff --git a/stepmania/src/FootMeter.cpp b/stepmania/src/FootMeter.cpp index 5f94c218d0..1cab6cac7e 100644 --- a/stepmania/src/FootMeter.cpp +++ b/stepmania/src/FootMeter.cpp @@ -34,8 +34,8 @@ void FootMeter::SetFromNotes( Notes* pNotes ) if( pNotes != NULL ) { SetDiffuse( RageColor(1,1,1,1) ); - SetNumFeet( pNotes->m_iMeter ); - if( pNotes->m_iMeter > GLOW_IF_METER_GREATER_THAN ) + SetNumFeet( pNotes->GetMeter() ); + if( pNotes->GetMeter() > GLOW_IF_METER_GREATER_THAN ) this->SetEffectGlowing(); else this->SetEffectNone(); diff --git a/stepmania/src/GrooveRadar.cpp b/stepmania/src/GrooveRadar.cpp index eb4ff87a42..527f85e75b 100644 --- a/stepmania/src/GrooveRadar.cpp +++ b/stepmania/src/GrooveRadar.cpp @@ -108,7 +108,7 @@ void GrooveRadar::GrooveRadarValueMap::SetFromNotes( PlayerNumber pn, Notes* pNo { const float fValueCurrent = m_fValuesOld[pn][c] * (1-m_PercentTowardNew[pn]) + m_fValuesNew[pn][c] * m_PercentTowardNew[pn]; m_fValuesOld[pn][c] = fValueCurrent; - m_fValuesNew[pn][c] = pNotes->m_fRadarValues[c]; + m_fValuesNew[pn][c] = pNotes->GetRadarValues()[c]; } if( m_bValuesVisible[pn] == false ) // the values WERE invisible diff --git a/stepmania/src/LifeMeterBattery.cpp b/stepmania/src/LifeMeterBattery.cpp index f1f8ed950b..225250f8b7 100644 --- a/stepmania/src/LifeMeterBattery.cpp +++ b/stepmania/src/LifeMeterBattery.cpp @@ -89,7 +89,7 @@ void LifeMeterBattery::SongEnded() return; m_iTrailingLivesLeft = m_iLivesLeft; - m_iLivesLeft += ( GAMESTATE->m_pCurNotes[m_PlayerNumber]->m_iMeter>=8 ? 2 : 1 ); + m_iLivesLeft += ( GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetMeter()>=8 ? 2 : 1 ); m_iLivesLeft = min( m_iLivesLeft, GAMESTATE->m_SongOptions.m_iBatteryLives ); m_soundGainLife.Play(); diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index abc6f22988..aacf57caef 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -303,7 +303,7 @@ MusicWheel::MusicWheel() m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT ); this->AddChild( &m_ScrollBar ); - m_soundChangeMusic.Load( THEME->GetPathTo("Sounds","select music change music"), 16 ); + m_soundChangeMusic.Load( THEME->GetPathTo("Sounds","select music change music") ); m_soundChangeSort.Load( THEME->GetPathTo("Sounds","select music change sort") ); m_soundExpand.Load( THEME->GetPathTo("Sounds","select music section expand") ); m_soundStart.Load( THEME->GetPathTo("Sounds","menu start") ); diff --git a/stepmania/src/Notes.cpp b/stepmania/src/Notes.cpp index 06412a3365..edea4d70d0 100644 --- a/stepmania/src/Notes.cpp +++ b/stepmania/src/Notes.cpp @@ -7,6 +7,7 @@ Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford + Glenn Maynard ----------------------------------------------------------------------------- */ @@ -39,7 +40,6 @@ Notes::Notes() * it'd trip obscure asserts all over the place, so I'll wait * until after b6 to do this. -glenn */ m_NotesType = NOTES_TYPE_DANCE_SINGLE; - m_bAutoGen = false; m_Difficulty = CLASS_INVALID; m_iMeter = 0; for(int i = 0; i < NUM_RADAR_VALUES; ++i) @@ -51,6 +51,7 @@ Notes::Notes() m_TopGrade = GRADE_NO_DATA; notes = NULL; notes_comp = NULL; + parent = NULL; } Notes::~Notes() @@ -63,6 +64,8 @@ void Notes::SetNoteData( NoteData* pNewNoteData ) { ASSERT( pNewNoteData->m_iNumTracks == GameManager::NotesTypeToNumTracks(m_NotesType) ); + DeAutogen(); + delete notes_comp; notes_comp = NULL; @@ -102,7 +105,7 @@ CString Notes::GetSMNoteData() const // Color is a function of Difficulty and Intended Style NotesDisplayType Notes::GetNotesDisplayType() const { - CString sDescription = m_sDescription; + CString sDescription = GetDescription(); sDescription.MakeLower(); if( -1 != sDescription.Find("battle") ) return NOTES_DISPLAY_BATTLE; @@ -110,7 +113,7 @@ NotesDisplayType Notes::GetNotesDisplayType() const else if( -1 != sDescription.Find("smaniac") ) return NOTES_DISPLAY_S_HARD; else if( -1 != sDescription.Find("challenge") ) return NOTES_DISPLAY_CHALLENGE; - switch( m_Difficulty ) + switch( GetDifficulty() ) { case DIFFICULTY_EASY: return NOTES_DISPLAY_EASY; case DIFFICULTY_MEDIUM: return NOTES_DISPLAY_MEDIUM; @@ -135,16 +138,16 @@ RageColor Notes::GetColor() const void Notes::TidyUpData() { - if( m_Difficulty == CLASS_INVALID ) - m_Difficulty = DifficultyFromDescriptionAndMeter( m_sDescription, m_iMeter ); + if( GetDifficulty() == CLASS_INVALID ) + SetDifficulty(DifficultyFromDescriptionAndMeter( GetDescription(), GetMeter() )); - if( m_iMeter < 1 || m_iMeter > 10 ) + if( GetMeter() < 1 || GetMeter() > 10 ) { - switch( m_Difficulty ) + switch( GetDifficulty() ) { - case DIFFICULTY_EASY: m_iMeter = 3; break; - case DIFFICULTY_MEDIUM: m_iMeter = 5; break; - case DIFFICULTY_HARD: m_iMeter = 8; break; + case DIFFICULTY_EASY: SetMeter(3); break; + case DIFFICULTY_MEDIUM: SetMeter(5); break; + case DIFFICULTY_HARD: SetMeter(8); break; default: ASSERT(0); } } @@ -199,8 +202,8 @@ bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes for( int r=0; rm_fRadarValues[r]; - fScore2 += pNotes2->m_fRadarValues[r]; + fScore1 += pNotes1->GetRadarValues()[r]; + fScore2 += pNotes2->GetRadarValues()[r]; } return fScore1 < fScore2; @@ -208,18 +211,18 @@ bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2) { - if( pNotes1->m_iMeter < pNotes2->m_iMeter ) + if( pNotes1->GetMeter() < pNotes2->GetMeter() ) return true; - if( pNotes1->m_iMeter > pNotes2->m_iMeter ) + if( pNotes1->GetMeter() > pNotes2->GetMeter() ) return false; return CompareNotesPointersByRadarValues( pNotes1, pNotes2 ); } bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2) { - if( pNotes1->m_Difficulty < pNotes2->m_Difficulty ) + if( pNotes1->GetDifficulty() < pNotes2->GetDifficulty() ) return true; - if( pNotes1->m_Difficulty > pNotes2->m_Difficulty ) + if( pNotes1->GetDifficulty() > pNotes2->GetDifficulty() ) return false; return CompareNotesPointersByMeter( pNotes1, pNotes2 ); } @@ -231,9 +234,25 @@ void SortNotesArrayByDifficulty( CArray &arraySteps ) void Notes::Decompress() const { - if(!notes_comp) return; /* no data is no data */ if(notes) return; + if(parent) + { + NoteData pdata; + parent->GetNoteData(&pdata); + + notes = new NoteData; + notes->m_iNumTracks = GameManager::NotesTypeToNumTracks(m_NotesType); + if(pdata.m_iNumTracks == notes->m_iNumTracks) + notes->CopyRange( &pdata, 0, pdata.GetLastRow(), 0 ); + else + notes->LoadTransformedSlidingWindow( &pdata, notes->m_iNumTracks ); + + return; + } + + if(!notes_comp) return; /* no data is no data */ + notes = new NoteData; notes->m_iNumTracks = GameManager::NotesTypeToNumTracks(m_NotesType); @@ -252,3 +271,69 @@ void Notes::Compress() const notes = NULL; } +/* Copy our parent's data. This is done when we're being changed from autogen + * to normal. (needed?) */ +void Notes::DeAutogen() +{ + if(!parent) + return; /* OK */ + + m_iMeter = Real()->m_iMeter; + m_sDescription = Real()->m_sDescription; + m_Difficulty = Real()->m_Difficulty; + for(int i = 0; i < NUM_RADAR_VALUES; ++i) + m_fRadarValues[i] = Real()->m_fRadarValues[i]; + + delete notes; + notes = NULL; + + if(!notes_comp) + notes_comp = new CString; + + *notes_comp = parent->GetSMNoteData(); + + parent = NULL; +} + +void Notes::AutogenFrom( Notes *parent_, NotesType ntTo ) +{ + parent = parent_; + m_NotesType = ntTo; +} + +const Notes *Notes::Real() const +{ + if(parent) return parent; + return this; +} + +bool Notes::IsAutogen() const +{ + return parent != NULL; +} + +void Notes::SetDescription(CString desc) +{ + DeAutogen(); + m_sDescription = desc; +} + +void Notes::SetDifficulty(Difficulty d) +{ + DeAutogen(); + m_Difficulty = d; +} + +void Notes::SetMeter(int meter) +{ + DeAutogen(); + m_iMeter = meter; +} + +void Notes::SetRadarValue(int r, float val) +{ + DeAutogen(); + ASSERT(r < NUM_RADAR_VALUES); + m_fRadarValues[r] = val; +} + diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index 627d0606b5..0f58db008e 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -33,30 +33,29 @@ public: Notes(); ~Notes(); - // Loading - bool LoadFromNotesFile( const CString &sPath ); - - /* We can have one or both of these; if we have both, they're always identical. - * Call Compress() to force us to only have notes_comp; otherwise, creation of - * these is transparent. */ - mutable NoteData *notes; - mutable CString *notes_comp; void Decompress() const; public: void Compress() const; + CString GetDescription() const { return Real()->m_sDescription; } + Difficulty GetDifficulty() const { return Real()->m_Difficulty; } + int GetMeter() const { return Real()->m_iMeter; } + const float *GetRadarValues() const { return Real()->m_fRadarValues; } + + void SetDescription(CString desc); + void SetDifficulty(Difficulty d); + void SetMeter(int meter); + void SetRadarValue(int r, float val); + bool IsAutogen() const; // Was created by autogen? + NotesType m_NotesType; - CString m_sDescription; // This text is displayed next to thte number of feet when a song is selected - bool m_bAutoGen; // Was created by autogen? - Difficulty m_Difficulty; // difficulty classification - int m_iMeter; // difficulty rating from 1-10 - float m_fRadarValues[NUM_RADAR_VALUES]; // between 0.0-1.2 starting from 12-o'clock rotating clockwise void GetNoteData( NoteData* pNoteDataOut ) const; void SetNoteData( NoteData* pNewNoteData ); void SetSMNoteData( const CString &out ); CString GetSMNoteData() const; + void AutogenFrom( Notes *parent, NotesType ntTo ); NotesDisplayType GetNotesDisplayType() const; RageColor GetColor() const; @@ -72,7 +71,26 @@ public: void TidyUpData(); protected: + /* If this Notes is autogenerated, this will point to the autogen + * source. If this is true, notes_comp will always be NULL. */ + const Notes *parent; + /* We can have one or both of these; if we have both, they're always identical. + * Call Compress() to force us to only have notes_comp; otherwise, creation of + * these is transparent. */ + mutable NoteData *notes; + mutable CString *notes_comp; + + const Notes *Real() const; + + /* These values are pulled from the autogen source first, if there is one. */ + CString m_sDescription; // This text is displayed next to the number of feet when a song is selected + Difficulty m_Difficulty; // difficulty classification + int m_iMeter; // difficulty rating from 1-10 + float m_fRadarValues[NUM_RADAR_VALUES]; // between 0.0-1.2 starting from 12-o'clock rotating clockwise + + /* If this Notes is autogenerated, make it a real Notes. */ + void DeAutogen(); }; bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2); diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index 8a5bfe0afb..344c190f23 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -121,29 +121,29 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out ) } if( -1 != value_name.Find("#title") ) { - out.m_sDescription = value_data; + value_data.MakeLower(); // extract the Notes description (looks like 'Music ') - int iPosOpenBracket = out.m_sDescription.Find( "<" ); + int iPosOpenBracket = value_data.Find( "<" ); if( iPosOpenBracket == -1 ) - iPosOpenBracket = out.m_sDescription.Find( "(" ); - int iPosCloseBracket = out.m_sDescription.Find( ">" ); + iPosOpenBracket = value_data.Find( "(" ); + int iPosCloseBracket = value_data.Find( ">" ); if( iPosCloseBracket == -1 ) - iPosCloseBracket = out.m_sDescription.Find( ")" ); + iPosCloseBracket = value_data.Find( ")" ); if( iPosOpenBracket != -1 && iPosCloseBracket != -1 ) - out.m_sDescription = out.m_sDescription.Mid( iPosOpenBracket+1, iPosCloseBracket-iPosOpenBracket-1 ); - out.m_sDescription.MakeLower(); - LOG->Trace( "Notes description found to be '%s'", out.m_sDescription.GetString() ); + value_data = value_data.Mid( iPosOpenBracket+1, iPosCloseBracket-iPosOpenBracket-1 ); + LOG->Trace( "Notes description found to be '%s'", value_data.GetString() ); + + out.SetDescription(value_data); // if there's a 6 in the description, it's probably part of "6panel" or "6-panel" - if( out.m_sDescription.Find("6") != -1 ) + if( value_data.Find("6") != -1 ) out.m_NotesType = NOTES_TYPE_DANCE_SOLO; - } if( -1 != value_name.Find("#playlevel") ) { - out.m_iMeter = atoi( value_data ); + out.SetMeter(atoi(value_data)); } else if( value_name.Left(1) == "#" && IsAnInt( value_name.Mid(1,3) ) diff --git a/stepmania/src/NotesLoaderDWI.cpp b/stepmania/src/NotesLoaderDWI.cpp index 5f14e405fb..cb122b09ea 100644 --- a/stepmania/src/NotesLoaderDWI.cpp +++ b/stepmania/src/NotesLoaderDWI.cpp @@ -120,11 +120,11 @@ bool DWILoader::LoadFromDWITokens( ASSERT(0); } - out.m_sDescription = sDescription; + out.SetDescription(sDescription); - out.m_iMeter = atoi( sNumFeet ); + out.SetMeter(atoi(sNumFeet)); - //m_Difficulty = DifficultyFromDescriptionAndMeter( m_sDescription, m_iMeter ); + //SetDifficulty(DifficultyFromDescriptionAndMeter( GetDescription(), GetMeter() )); NoteData* pNoteData = new NoteData; ASSERT( pNoteData ); diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index 746c2077c0..ad357aa08b 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -33,7 +33,7 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Notes &out ) else if( 0==stricmp(sValueName,"STEP") ) iStep = sParams[1]; else if( 0==stricmp(sValueName,"DIFFICULTY") ) - out.m_iMeter = atoi(sParams[1]); + out.SetMeter(atoi(sParams[1])); } if( iTickCount == -1 ) @@ -53,26 +53,26 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Notes &out ) splitrelpath( sPath, sDir, sFName, sExt ); sFName.MakeLower(); - out.m_sDescription = sFName; + out.SetDescription(sFName); if( sFName.Find("crazy")!=-1 ) { - out.m_Difficulty = DIFFICULTY_HARD; - if(!out.m_iMeter) out.m_iMeter = 8; + out.SetDifficulty(DIFFICULTY_HARD); + if(!out.GetMeter()) out.SetMeter(8); } else if( sFName.Find("hard")!=-1 ) { - out.m_Difficulty = DIFFICULTY_MEDIUM; - if(!out.m_iMeter) out.m_iMeter = 5; + out.SetDifficulty(DIFFICULTY_MEDIUM); + if(!out.GetMeter()) out.SetMeter(5); } else if( sFName.Find("easy")!=-1 ) { - out.m_Difficulty = DIFFICULTY_EASY; - if(!out.m_iMeter) out.m_iMeter = 2; + out.SetDifficulty(DIFFICULTY_EASY); + if(!out.GetMeter()) out.SetMeter(2); } else { - out.m_Difficulty = DIFFICULTY_MEDIUM; - if(!out.m_iMeter) out.m_iMeter = 5; + out.SetDifficulty(DIFFICULTY_MEDIUM); + if(!out.GetMeter()) out.SetMeter(5); } notedata.m_iNumTracks = 5; diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 5acb2ee6e0..bec7e3abf0 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -28,14 +28,14 @@ void SMLoader::LoadFromSMTokens( // LOG->Trace( "Notes::LoadFromSMTokens()" ); out.m_NotesType = GameManager::StringToNotesType(sNotesType); - out.m_sDescription = sDescription; - out.m_Difficulty = StringToDifficulty( sDifficulty ); - out.m_iMeter = atoi(sMeter); + out.SetDescription(sDescription); + out.SetDifficulty(StringToDifficulty( sDifficulty )); + out.SetMeter(atoi(sMeter)); CStringArray saValues; split( sRadarValues, ",", saValues, true ); if( saValues.size() == NUM_RADAR_VALUES ) for( int r=0; rm_sDescription.Find("autogen") ) + if( -1 != out.m_apNotes[i]->GetDescription().Find("autogen") ) continue; // don't save autogen notes if(!WriteDWINotesTag( fp, *out.m_apNotes[i] )) diff --git a/stepmania/src/NotesWriterSM.cpp b/stepmania/src/NotesWriterSM.cpp index 3011962868..ffdbe50a0d 100644 --- a/stepmania/src/NotesWriterSM.cpp +++ b/stepmania/src/NotesWriterSM.cpp @@ -74,16 +74,16 @@ void NotesWriterSM::WriteGlobalTags(FILE *fp, const Song &out) void NotesWriterSM::WriteSMNotesTag( const Notes &in, FILE* fp ) { fprintf( fp, "\n//---------------%s - %s----------------\n", - GameManager::NotesTypeToString(in.m_NotesType).GetString(), in.m_sDescription.GetString() ); + GameManager::NotesTypeToString(in.m_NotesType).GetString(), in.GetDescription().GetString() ); fprintf( fp, "#NOTES:\n" ); fprintf( fp, " %s:\n", GameManager::NotesTypeToString(in.m_NotesType).GetString() ); - fprintf( fp, " %s:\n", in.m_sDescription.GetString() ); - fprintf( fp, " %s:\n", DifficultyToString(in.m_Difficulty).GetString() ); - fprintf( fp, " %d:\n", in.m_iMeter ); + fprintf( fp, " %s:\n", in.GetDescription().GetString() ); + fprintf( fp, " %s:\n", DifficultyToString(in.GetDifficulty()).GetString() ); + fprintf( fp, " %d:\n", in.GetMeter() ); CStringArray asRadarValues; for( int r=0; r < NUM_RADAR_VALUES; r++ ) - asRadarValues.push_back( ssprintf("%.3f", in.m_fRadarValues[r]) ); + asRadarValues.push_back( ssprintf("%.3f", in.GetRadarValues()[r]) ); fprintf( fp, " %s:\n", join(",",asRadarValues).GetString() ); fprintf( fp, "%s;\n", in.GetSMNoteData().GetString() ); @@ -109,8 +109,8 @@ bool NotesWriterSM::Write(CString sPath, const Song &out, bool bSavingCache) for( i=0; im_bAutoGen ) - continue; /* only write autogen notes to cache */ + if( pNotes->IsAutogen() ) + continue; /* don't write autogen notes */ WriteSMNotesTag( *out.m_apNotes[i], fp ); } diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 46e012084d..45ac54a1b6 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -7,7 +7,7 @@ ScoreKeeperMAX2::ScoreKeeperMAX2(Notes *notes, NoteDataWithScoring &data, Player { // Stats_DoublesCount = true; - int Meter = notes? notes->m_iMeter : 5; + int Meter = notes? notes->GetMeter() : 5; /* Hold notes count as two tap notes. However, hold notes already count * as 1 in GetNumTapNotes(), so only add 1*GetNumHoldNotes, not 2. */ diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 06841ef66f..7e5aa85dac 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -191,12 +191,13 @@ ScreenEdit::ScreenEdit() m_pSong = GAMESTATE->m_pCurSong; m_pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; + if( m_pNotes == NULL ) { m_pNotes = new Notes; - m_pNotes->m_Difficulty = DIFFICULTY_MEDIUM; + m_pNotes->SetDifficulty(DIFFICULTY_MEDIUM); m_pNotes->m_NotesType = GAMESTATE->GetCurrentStyleDef()->m_NotesType; - m_pNotes->m_sDescription = "Untitled"; + m_pNotes->SetDescription("Untitled"); // In ScreenEditMenu, the screen preceding this one, // GAMEMAN->m_CurStyle is set to the target game style @@ -523,8 +524,8 @@ void ScreenEdit::Update( float fDeltaTime ) GAMESTATE->m_fSongBeat, m_NoteFieldEdit.m_fBeginMarker, m_NoteFieldEdit.m_fEndMarker, GAMESTATE->m_SongOptions.m_fMusicRate, - DifficultyToString( m_pNotes->m_Difficulty ).GetString(), - GAMESTATE->m_pCurNotes[PLAYER_1] ? GAMESTATE->m_pCurNotes[PLAYER_1]->m_sDescription.GetString() : "no description", + DifficultyToString( m_pNotes->GetDifficulty() ).GetString(), + GAMESTATE->m_pCurNotes[PLAYER_1] ? GAMESTATE->m_pCurNotes[PLAYER_1]->GetDescription().GetString() : "no description", m_pSong->m_sMainTitle.GetString(), m_pSong->m_sSubTitle.GetString(), iNumTapNotes, iNumHoldNotes, @@ -639,7 +640,7 @@ void AddBGChange( CString sBGName ) void ChangeDescription( CString sNew ) { Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; - pNotes->m_sDescription = sNew; + pNotes->SetDescription(sNew); } void ChangeMainTitle( CString sNew ) @@ -752,7 +753,6 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ // copy edit into current Notes Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; ASSERT( pNotes ); - pNotes->m_bAutoGen = false; // set not autogen so these Notes will be saved to disk. pNotes->SetNoteData( &m_NoteFieldEdit ); GAMESTATE->m_pCurSong->Save(); @@ -1033,13 +1033,13 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case SDLK_d: { - Difficulty &dc = m_pNotes->m_Difficulty; - dc = Difficulty( (dc+1)%NUM_DIFFICULTIES ); + Difficulty dc = Difficulty( (m_pNotes->GetDifficulty()+1)%NUM_DIFFICULTIES ); + m_pNotes->SetDifficulty(dc); } break; case SDLK_e: - SCREENMAN->TextEntry( SM_None, "Edit notes description.\nPress Enter to confirm,\nEscape to cancel.", m_pNotes->m_sDescription, ChangeDescription, NULL ); + SCREENMAN->TextEntry( SM_None, "Edit notes description.\nPress Enter to confirm,\nEscape to cancel.", m_pNotes->GetDescription(), ChangeDescription, NULL ); break; case SDLK_b: diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 15a88be156..fdb9e783bd 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -358,7 +358,7 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if( GAMESTATE->m_pCurNotes[p]->m_Difficulty == DIFFICULTY_HARD && grade[p] >= GRADE_AA ) + if( GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_HARD && grade[p] >= GRADE_AA ) m_bTryExtraStage = true; } } diff --git a/stepmania/src/ScreenEz2SelectMusic.cpp b/stepmania/src/ScreenEz2SelectMusic.cpp index 3bc8811956..3029fde9d1 100644 --- a/stepmania/src/ScreenEz2SelectMusic.cpp +++ b/stepmania/src/ScreenEz2SelectMusic.cpp @@ -262,7 +262,7 @@ void ScreenEz2SelectMusic::EasierDifficulty( PlayerNumber pn ) m_iSelection[pn]--; // the user explicity switched difficulties. Update the preferred difficulty - GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->m_Difficulty; + GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->GetDifficulty(); // m_soundChangeNotes.Play(); @@ -282,7 +282,7 @@ void ScreenEz2SelectMusic::HarderDifficulty( PlayerNumber pn ) m_iSelection[pn]++; // the user explicity switched difficulties. Update the preferred difficulty - GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->m_Difficulty; + GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->GetDifficulty(); // m_soundChangeNotes.Play(); @@ -320,7 +320,7 @@ void ScreenEz2SelectMusic::AfterNotesChange( PlayerNumber pn ) Notes* pNotes = m_arrayNotes[pn].empty()? NULL: m_arrayNotes[pn][m_iSelection[pn]]; if( pNotes != NULL ) - m_PumpDifficultyRating.SetText(ssprintf("Lv.%d",pNotes->m_iMeter)); + m_PumpDifficultyRating.SetText(ssprintf("Lv.%d",pNotes->GetMeter())); GAMESTATE->m_pCurNotes[pn] = pNotes; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 081736a775..b3129b180d 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -156,7 +156,6 @@ ScreenGameplay::ScreenGameplay() } break; } - } m_bChangedOffsetOrBPM = (GAMESTATE->m_SongOptions.m_AutoAdjust == SongOptions::ADJUST_ON); @@ -1212,7 +1211,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if( GAMESTATE->m_pCurNotes[p]->m_Difficulty == DIFFICULTY_HARD && GAMESTATE->GetCurrentGrade((PlayerNumber)p) >= GRADE_AA ) + if( GAMESTATE->m_pCurNotes[p]->GetDifficulty() == DIFFICULTY_HARD && GAMESTATE->GetCurrentGrade((PlayerNumber)p) >= GRADE_AA ) bTryExtraStage = true; } } diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index ffacdb322d..a8299ef8ee 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -494,7 +494,7 @@ void ScreenSelectMusic::EasierDifficulty( PlayerNumber pn ) m_iSelection[pn]--; // the user explicity switched difficulties. Update the preferred difficulty - GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->m_Difficulty; + GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->GetDifficulty(); m_soundChangeNotes.Play(); @@ -514,7 +514,7 @@ void ScreenSelectMusic::HarderDifficulty( PlayerNumber pn ) m_iSelection[pn]++; // the user explicity switched difficulties. Update the preferred difficulty - GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->m_Difficulty; + GAMESTATE->m_PreferredDifficulty[pn] = m_arrayNotes[pn][ m_iSelection[pn] ]->GetDifficulty(); m_soundChangeNotes.Play(); @@ -620,7 +620,7 @@ void ScreenSelectMusic::MenuStart( PlayerNumber pn ) { if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if( GAMESTATE->m_pCurNotes[p] && GAMESTATE->m_pCurNotes[p]->m_iMeter >= 10 ) + if( GAMESTATE->m_pCurNotes[p] && GAMESTATE->m_pCurNotes[p]->GetMeter() >= 10 ) bIsHard = true; } @@ -765,7 +765,7 @@ void ScreenSelectMusic::AfterMusicChange() continue; for( unsigned i=0; im_Difficulty == GAMESTATE->m_PreferredDifficulty[p] ) + if( m_arrayNotes[p][i]->GetDifficulty() == GAMESTATE->m_PreferredDifficulty[p] ) { m_iSelection[p] = i; break; diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index fc1edd5851..1ef2b34b54 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -279,7 +279,7 @@ bool Song::LoadWithoutCache( CString sDir ) return false; TidyUpData(); - + // save a cache file so we don't have to parse it all over again next time SaveToCacheFile(); return true; @@ -359,6 +359,9 @@ bool Song::LoadFromSongDir( CString sDir ) } } + /* Add AutoGen pointers. (These aren't cached.) */ + AddAutoGenNotes(); + return true; } @@ -404,8 +407,6 @@ void Song::TidyUpData() * their source's values. */ ReCalulateRadarValuesAndLastBeat(); - AddAutoGenNotes(); - TrimRight(m_sMainTitle); if( m_sMainTitle == "" ) m_sMainTitle = "Untitled song"; TrimRight(m_sSubTitle); @@ -554,10 +555,10 @@ void Song::TidyUpData() GetNotesThatMatch( nt, apNotes ); if( apNotes.size() == 1 ) { - if( 0 == apNotes[0]->m_sDescription.CompareNoCase("smaniac") ) + if( 0 == apNotes[0]->GetDescription().CompareNoCase("smaniac") ) { - apNotes[0]->m_sDescription = "Challenge"; - apNotes[0]->m_Difficulty = DIFFICULTY_HARD; + apNotes[0]->SetDescription("Challenge"); + apNotes[0]->SetDifficulty(DIFFICULTY_HARD); } } } @@ -579,12 +580,11 @@ void Song::ReCalulateRadarValuesAndLastBeat() for( int r=0; rm_bAutoGen && pNotes->m_fRadarValues[r] != -1) + /* If it's autogen, radar vals come from the parent. */ + if(pNotes->IsAutogen()) continue; - pNotes->m_fRadarValues[r] = NoteDataUtil::GetRadarValue( tempNoteData, (RadarCategory)r, m_fMusicLengthSeconds ); + + pNotes->SetRadarValue(r, NoteDataUtil::GetRadarValue( tempNoteData, (RadarCategory)r, m_fMusicLengthSeconds )); } float fFirstBeat = tempNoteData.GetFirstBeat(); @@ -629,7 +629,7 @@ bool Song::SongHasNotesType( NotesType nt ) const bool Song::SongHasNotesTypeAndDifficulty( NotesType nt, Difficulty dc ) const { for( unsigned i=0; i < m_apNotes.size(); i++ ) // foreach Notes - if( m_apNotes[i]->m_NotesType == nt && m_apNotes[i]->m_Difficulty == dc ) + if( m_apNotes[i]->m_NotesType == nt && m_apNotes[i]->GetDifficulty() == dc ) return true; return false; } @@ -699,8 +699,6 @@ void Song::AddAutoGenNotes() { for( NotesType ntMissing=(NotesType)0; ntMissingNotesTypeToNumTracks(ntMissing); - unsigned j; - - // look for previously autogen'd data with the same number of tracks - // XXX Why do this? Notes with the same number of tracks will be preferred - // below anyway; why prefer autogen'd data? -glenn - for( j=0; jm_NotesType; - int iNumOriginalNotesTracks = GAMEMAN->NotesTypeToNumTracks(ntOriginal); - - if( pOriginalNotes->m_bAutoGen && iNumTracksOfMissing == iNumOriginalNotesTracks ) - { - AutoGen( ntMissing, ntOriginal ); - goto next_notes_type; // done searching - } - } - - // look for closest match NotesType ntBestMatch = (NotesType)-1; int iBestTrackDifference = 10000; // inf for( NotesType nt=(NotesType)0; ntNotesTypeToNumTracks(nt); - int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing); CArray apNotes; this->GetNotesThatMatch( nt, apNotes ); - if( iTrackDifference < iBestTrackDifference && !apNotes.empty() && !apNotes[0]->m_bAutoGen ) + + if(apNotes.empty() || apNotes[0]->IsAutogen()) + continue; /* can't autogen from other autogen */ + + int iNumTracks = GAMEMAN->NotesTypeToNumTracks(nt); + int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing); + if( iTrackDifference < iBestTrackDifference ) { ntBestMatch = nt; iBestTrackDifference = iTrackDifference; @@ -751,7 +734,7 @@ next_notes_type: void Song::AutoGen( NotesType ntTo, NotesType ntFrom ) { - int iNumTracksOfTo = GAMEMAN->NotesTypeToNumTracks(ntTo); +// int iNumTracksOfTo = GAMEMAN->NotesTypeToNumTracks(ntTo); for( unsigned int j=0; jm_NotesType == ntFrom ) { Notes* pNewNotes = new Notes; - pNewNotes->m_Difficulty = pOriginalNotes->m_Difficulty; - pNewNotes->m_iMeter = pOriginalNotes->m_iMeter; - pNewNotes->m_sDescription = pOriginalNotes->m_sDescription; - pNewNotes->m_bAutoGen = true; - pNewNotes->m_NotesType = ntTo; - /* Assume the radar values are the same, so we don't spend a long - * time recomputing them. */ - for(int i = 0; i < NUM_RADAR_VALUES; ++i) - pNewNotes->m_fRadarValues[i] = pOriginalNotes->m_fRadarValues[i]; - - NoteData originalNoteData; - NoteData newNoteData; - pOriginalNotes->GetNoteData( &originalNoteData ); - newNoteData.m_iNumTracks = iNumTracksOfTo; - if(originalNoteData.m_iNumTracks == iNumTracksOfTo) - newNoteData.CopyRange( &originalNoteData, 0, originalNoteData.GetLastRow(), 0 ); - else - newNoteData.LoadTransformedSlidingWindow( &originalNoteData, iNumTracksOfTo ); - pNewNotes->SetNoteData( &newNoteData ); + pNewNotes->AutogenFrom(pOriginalNotes, ntTo); this->m_apNotes.push_back( pNewNotes ); } } @@ -795,7 +760,7 @@ Grade Song::GetGradeForDifficulty( const StyleDef *st, int p, Difficulty dc ) co for( unsigned i=0; im_Difficulty == dc ) + if( pNotes->GetDifficulty() == dc ) grade = max( grade, pNotes->m_TopGrade ); } return grade; @@ -814,7 +779,7 @@ bool Song::IsEasy( NotesType nt ) const Notes* pNotes = m_apNotes[i]; if( pNotes->m_NotesType != nt ) continue; - if( pNotes->m_iMeter <= 2 ) + if( pNotes->GetMeter() <= 2 ) return true; } return false; @@ -857,9 +822,9 @@ int CompareSongPointersByDifficulty(const Song *pSong1, const Song *pSong2) unsigned i; for( i=0; im_iMeter ); + iEasiestMeter1 = min( iEasiestMeter1, aNotes1[i]->GetMeter() ); for( i=0; im_iMeter ); + iEasiestMeter2 = min( iEasiestMeter2, aNotes2[i]->GetMeter() ); if( iEasiestMeter1 < iEasiestMeter2 ) return true; diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index fffa93d34c..a384f3afb2 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -307,7 +307,7 @@ void SongManager::ReadStatisticsFromDisk() for( i=0; im_apNotes.size(); i++ ) { if( pSong->m_apNotes[i]->m_NotesType == notesType && - pSong->m_apNotes[i]->m_sDescription == szNotesDescription ) // match! + pSong->m_apNotes[i]->GetDescription() == szNotesDescription ) // match! { pNotes = pSong->m_apNotes[i]; break; @@ -355,7 +355,7 @@ void SongManager::SaveStatisticsToDisk() // Each value has the format "SongName::NotesName=TimesPlayed::TopGrade::TopScore::MaxCombo". - CString sName = ssprintf( "%s::%s::%s", pSong->GetSongDir().GetString(), GameManager::NotesTypeToString(pNotes->m_NotesType).GetString(), pNotes->m_sDescription.GetString() ); + CString sName = ssprintf( "%s::%s::%s", pSong->GetSongDir().GetString(), GameManager::NotesTypeToString(pNotes->m_NotesType).GetString(), pNotes->GetDescription().GetString() ); CString sValue = ssprintf( "%d::%s::%d::%d", pNotes->m_iNumTimesPlayed, @@ -409,7 +409,7 @@ RageColor SongManager::GetSongColor( const Song* pSong ) for( unsigned i=0; im_apNotes.size(); i++ ) { const Notes* pNotes = pSong->m_apNotes[i]; - if( pNotes->m_iMeter == 10 ) + if( pNotes->GetMeter() == 10 ) return EXTRA_COLOR; } @@ -578,7 +578,7 @@ void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, cons } // for extra 2, we don't want to choose the hardest notes possible. So, we'll disgard Notes with meter > 8 - if( bExtra2 && pNotes->m_iMeter > 8 ) + if( bExtra2 && pNotes->GetMeter() > 8 ) continue; // skip if( pExtra2Notes == NULL || CompareNotesPointersByDifficulty(pExtra2Notes,pNotes) ) // pNotes is harder than pHardestNotes { diff --git a/stepmania/src/SongSelector.cpp b/stepmania/src/SongSelector.cpp index d8def2bdcc..8a576521a2 100644 --- a/stepmania/src/SongSelector.cpp +++ b/stepmania/src/SongSelector.cpp @@ -283,10 +283,10 @@ void SongSelector::OnNotesChange() m_textNotes.SetText( "(NEW)" ); else { - CString sDescription = GetSelectedNotes()->m_sDescription; + CString sDescription = GetSelectedNotes()->GetDescription(); if( sDescription == "" ) sDescription = "[no name]"; - if( GetSelectedNotes()->m_bAutoGen ) + if( GetSelectedNotes()->IsAutogen() ) sDescription += " (autogen)"; m_textNotes.SetText( sDescription ); }