Add and use accessors for most of Notes.

Don't autogen data until it's needed.
This commit is contained in:
Glenn Maynard
2003-01-02 22:10:51 +00:00
parent b797141aa3
commit bb8940adad
23 changed files with 231 additions and 164 deletions
+2 -2
View File
@@ -192,7 +192,7 @@ Notes* Course::GetNotesForStage( int iStage )
for( i=0; i<pSong->m_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; i<pSong->m_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;
}
+1 -1
View File
@@ -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 );
}
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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") );
+102 -17
View File
@@ -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; r<NUM_RADAR_VALUES; r++ )
{
fScore1 += pNotes1->m_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<Notes*,Notes*> &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;
}
+31 -13
View File
@@ -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);
+11 -11
View File
@@ -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 <BASIC>')
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) )
+3 -3
View File
@@ -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 );
+10 -10
View File
@@ -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;
+4 -4
View File
@@ -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; r<NUM_RADAR_VALUES; r++ )
out.m_fRadarValues[r] = (float)atof(saValues[r]);
out.SetRadarValue(r, (float)atof(saValues[r]));
out.SetSMNoteData(sNoteData);
+5 -5
View File
@@ -199,13 +199,13 @@ bool NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out )
default: return false; // not a type supported by DWI
}
if( 0==out.m_sDescription.CompareNoCase("challenge") )
if( 0==out.GetDescription().CompareNoCase("challenge") )
fprintf( fp, "SMANIAC:" );
else if( 0==out.m_sDescription.CompareNoCase("smaniac") )
else if( 0==out.GetDescription().CompareNoCase("smaniac") )
fprintf( fp, "SMANIAC:" );
else
{
switch( out.m_Difficulty )
switch( out.GetDifficulty() )
{
case DIFFICULTY_EASY: fprintf( fp, "BASIC:" ); break;
case DIFFICULTY_MEDIUM: fprintf( fp, "ANOTHER:" ); break;
@@ -214,7 +214,7 @@ bool NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out )
}
}
fprintf( fp, "%d:\n", out.m_iMeter );
fprintf( fp, "%d:\n", out.GetMeter() );
return true;
}
@@ -264,7 +264,7 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
for( unsigned i=0; i<out.m_apNotes.size(); i++ )
{
if( -1 != out.m_apNotes[i]->m_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] ))
+7 -7
View File
@@ -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; i<out.m_apNotes.size(); i++ )
{
Notes* pNotes = out.m_apNotes[i];
if( !bSavingCache && pNotes->m_bAutoGen )
continue; /* only write autogen notes to cache */
if( pNotes->IsAutogen() )
continue; /* don't write autogen notes */
WriteSMNotesTag( *out.m_apNotes[i], fp );
}
+1 -1
View File
@@ -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. */
+9 -9
View File
@@ -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:
+1 -1
View File
@@ -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;
}
}
+3 -3
View File
@@ -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;
+1 -2
View File
@@ -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;
}
}
+4 -4
View File
@@ -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; i<m_arrayNotes[p].size(); i++ )
{
if( m_arrayNotes[p][i]->m_Difficulty == GAMESTATE->m_PreferredDifficulty[p] )
if( m_arrayNotes[p][i]->GetDifficulty() == GAMESTATE->m_PreferredDifficulty[p] )
{
m_iSelection[p] = i;
break;
+25 -60
View File
@@ -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; r<NUM_RADAR_VALUES; r++ )
{
/* If it's autogen, and we already have radar values, leave them alone.
* If it's not autogen, regen them, since the radar calculation might
* have changed. */
if(pNotes->m_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; ntMissing<NUM_NOTES_TYPES; ntMissing=(NotesType)(ntMissing+1) )
{
next_notes_type:
if( SongHasNotesType(ntMissing) )
continue;
@@ -708,36 +706,21 @@ next_notes_type:
// missing Notes of this type
int iNumTracksOfMissing = GAMEMAN->NotesTypeToNumTracks(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; j<m_apNotes.size(); j++ )
{
Notes* pOriginalNotes = m_apNotes[j];
NotesType ntOriginal = pOriginalNotes->m_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; nt<NUM_NOTES_TYPES; nt=(NotesType)(nt+1) )
{
int iNumTracks = GAMEMAN->NotesTypeToNumTracks(nt);
int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing);
CArray<Notes*,Notes*> 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; j<m_apNotes.size(); j++ )
{
@@ -759,25 +742,7 @@ void Song::AutoGen( NotesType ntTo, NotesType ntFrom )
if( pOriginalNotes->m_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; i<aNotes.size(); i++ )
{
const Notes* pNotes = aNotes[i];
if( pNotes->m_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; i<aNotes1.size(); i++ )
iEasiestMeter1 = min( iEasiestMeter1, aNotes1[i]->m_iMeter );
iEasiestMeter1 = min( iEasiestMeter1, aNotes1[i]->GetMeter() );
for( i=0; i<aNotes2.size(); i++ )
iEasiestMeter2 = min( iEasiestMeter2, aNotes2[i]->m_iMeter );
iEasiestMeter2 = min( iEasiestMeter2, aNotes2[i]->GetMeter() );
if( iEasiestMeter1 < iEasiestMeter2 )
return true;
+4 -4
View File
@@ -307,7 +307,7 @@ void SongManager::ReadStatisticsFromDisk()
for( i=0; i<pSong->m_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; i<pSong->m_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
{
+2 -2
View File
@@ -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 );
}