add course meter

This commit is contained in:
Glenn Maynard
2003-07-21 22:33:01 +00:00
parent fb0b6ed89e
commit 5618c2b3d1
2 changed files with 45 additions and 0 deletions
+43
View File
@@ -39,6 +39,7 @@ Course::Course()
m_bRandomize = false;
m_bDifficult = false;
m_iLives = -1;
m_iMeter = -1;
SetDefaultScore();
}
@@ -107,6 +108,43 @@ PlayMode Course::GetPlayMode() const
return PLAY_MODE_NONSTOP;
}
const int DifficultMeterRamp = 3;
int Course::GetMeter() const
{
if( m_iMeter != -1 )
return m_iMeter + GAMESTATE->m_bDifficultCourses? DifficultMeterRamp:0;
vector<Info> ci;
GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci );
/* Take the aveage meter. */
float fTotalMeter = 0;
for( unsigned c = 0; c < ci.size(); ++c )
{
if( ci[c].Random )
{
switch( GetDifficulty(ci[c]) )
{
case DIFFICULTY_INVALID:
{
int iMeterLow, iMeterHigh;
GetMeterRange(ci[c], iMeterLow, iMeterHigh);
fTotalMeter += int( (iMeterLow + iMeterHigh) / 2.0f );
break;
}
case DIFFICULTY_BEGINNER: fTotalMeter += 1; break;
case DIFFICULTY_EASY: fTotalMeter += 2; break;
case DIFFICULTY_MEDIUM: fTotalMeter += 5; break;
case DIFFICULTY_HARD: fTotalMeter += 7; break;
case DIFFICULTY_CHALLENGE: fTotalMeter += 9; break;
}
}
else
fTotalMeter += ci[c].Notes->GetMeter();
}
return (int)roundf( fTotalMeter / ci.size() );
}
void Course::LoadFromCRSFile( CString sPath )
{
m_sPath = sPath; // save path
@@ -154,6 +192,9 @@ void Course::LoadFromCRSFile( CString sPath )
else if( 0 == stricmp(sValueName, "LIVES") )
m_iLives = atoi( sParams[1] );
else if( 0 == stricmp(sValueName, "METER") )
m_iMeter = atoi( sParams[1] );
else if( 0 == stricmp(sValueName, "SONG") )
{
Entry new_entry;
@@ -275,6 +316,7 @@ void Course::Save()
fprintf( fp, "#COURSE:%s;\n", m_sName.c_str() );
fprintf( fp, "#REPEAT:%s;\n", m_bRepeat ? "YES" : "NO" );
fprintf( fp, "#LIVES:%i;\n", m_iLives );
fprintf( fp, "#METER:%i;\n", m_iMeter );
for( unsigned i=0; i<m_entries.size(); i++ )
{
@@ -320,6 +362,7 @@ void Course::AutogenEndlessFromGroup( CString sGroupName, vector<Song*> &apSongs
m_bRepeat = true;
m_bRandomize = true;
m_iLives = -1;
m_iMeter = -1;
m_sName = SONGMAN->ShortenGroupName( sGroupName );
m_sBannerPath = SONGMAN->GetGroupBannerPath( sGroupName );
+2
View File
@@ -58,6 +58,7 @@ public:
bool m_bRandomize; // play the songs in a random order
bool m_bDifficult; // only make something difficult once
int m_iLives; // -1 means use bar life meter
int m_iMeter; // -1 autogens
struct Info
{
@@ -94,6 +95,7 @@ public:
bool IsOni() const { return !m_bRepeat && m_iLives > 0; } // use battery life meter
bool IsEndless() const { return m_bRepeat; }
PlayMode GetPlayMode() const;
int GetMeter() const;
void LoadFromCRSFile( CString sPath );
void Save();