fix selecting an edit and moving to chance results in weird difficulty

selection behavior
This commit is contained in:
Glenn Maynard
2006-03-29 02:54:11 +00:00
parent 9c4dc961dd
commit 6faf9b9b69
3 changed files with 30 additions and 2 deletions
+3 -1
View File
@@ -70,13 +70,15 @@ void DifficultyList::Load()
int DifficultyList::GetCurrentRowIndex( PlayerNumber pn ) const
{
Difficulty ClosestDifficulty = GAMESTATE->GetClosestShownDifficulty(pn);
for( unsigned i=0; i<m_Rows.size(); i++ )
{
const Row &row = m_Rows[i];
if( GAMESTATE->m_pCurSteps[pn] == NULL )
{
if( row.m_dc == GAMESTATE->m_PreferredDifficulty[pn] )
if( row.m_dc == ClosestDifficulty )
return i;
}
else
+26 -1
View File
@@ -1599,11 +1599,14 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
return true;
}
/* When only displaying difficulties in DIFFICULTIES_TO_SHOW, use GetClosestShownDifficulty
* to find which difficulty to show, and ChangePreferredDifficulty(pn, dir) to change
* difficulty. */
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
{
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
Difficulty d = m_PreferredDifficulty[pn];
Difficulty d = GAMESTATE->GetClosestShownDifficulty(pn);
while( 1 )
{
d = (Difficulty)(d+dir);
@@ -1616,6 +1619,28 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
return ChangePreferredDifficulty( pn, d );
}
/* The user may be set to prefer a difficulty that isn't always shown; typically,
* DIFFICULTY_EDIT. Return the closest shown difficulty <= m_PreferredDifficulty. */
Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const
{
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
Difficulty iClosest = (Difficulty) 0;
int iClosestDist = -1;
FOREACH_CONST( Difficulty, v, dc )
{
int iDist = m_PreferredDifficulty[pn] - *dc;
if( iDist < 0 )
continue;
if( iClosestDist != -1 && iDist > iClosestDist )
continue;
iClosestDist = iDist;
iClosest = *dc;
}
return iClosest;
}
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
{
m_PreferredCourseDifficulty[pn].Set( cd );
+1
View File
@@ -67,6 +67,7 @@ public:
bool ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd );
bool ChangePreferredCourseDifficulty( PlayerNumber pn, int dir );
bool IsCourseDifficultyShown( CourseDifficulty cd );
Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const;
Difficulty GetEasiestStepsDifficulty() const;
RageTimer m_timeGameStarted; // from the moment the first player pressed Start
LuaTable *m_Environment;