fix selecting an edit and moving to chance results in weird difficulty
selection behavior
This commit is contained in:
@@ -70,13 +70,15 @@ void DifficultyList::Load()
|
|||||||
|
|
||||||
int DifficultyList::GetCurrentRowIndex( PlayerNumber pn ) const
|
int DifficultyList::GetCurrentRowIndex( PlayerNumber pn ) const
|
||||||
{
|
{
|
||||||
|
Difficulty ClosestDifficulty = GAMESTATE->GetClosestShownDifficulty(pn);
|
||||||
|
|
||||||
for( unsigned i=0; i<m_Rows.size(); i++ )
|
for( unsigned i=0; i<m_Rows.size(); i++ )
|
||||||
{
|
{
|
||||||
const Row &row = m_Rows[i];
|
const Row &row = m_Rows[i];
|
||||||
|
|
||||||
if( GAMESTATE->m_pCurSteps[pn] == NULL )
|
if( GAMESTATE->m_pCurSteps[pn] == NULL )
|
||||||
{
|
{
|
||||||
if( row.m_dc == GAMESTATE->m_PreferredDifficulty[pn] )
|
if( row.m_dc == ClosestDifficulty )
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1599,11 +1599,14 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
|
|||||||
return true;
|
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 )
|
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
|
||||||
{
|
{
|
||||||
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
|
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
|
||||||
|
|
||||||
Difficulty d = m_PreferredDifficulty[pn];
|
Difficulty d = GAMESTATE->GetClosestShownDifficulty(pn);
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
d = (Difficulty)(d+dir);
|
d = (Difficulty)(d+dir);
|
||||||
@@ -1616,6 +1619,28 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
|
|||||||
return ChangePreferredDifficulty( pn, d );
|
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 )
|
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
|
||||||
{
|
{
|
||||||
m_PreferredCourseDifficulty[pn].Set( cd );
|
m_PreferredCourseDifficulty[pn].Set( cd );
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
bool ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd );
|
bool ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd );
|
||||||
bool ChangePreferredCourseDifficulty( PlayerNumber pn, int dir );
|
bool ChangePreferredCourseDifficulty( PlayerNumber pn, int dir );
|
||||||
bool IsCourseDifficultyShown( CourseDifficulty cd );
|
bool IsCourseDifficultyShown( CourseDifficulty cd );
|
||||||
|
Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const;
|
||||||
Difficulty GetEasiestStepsDifficulty() const;
|
Difficulty GetEasiestStepsDifficulty() const;
|
||||||
RageTimer m_timeGameStarted; // from the moment the first player pressed Start
|
RageTimer m_timeGameStarted; // from the moment the first player pressed Start
|
||||||
LuaTable *m_Environment;
|
LuaTable *m_Environment;
|
||||||
|
|||||||
Reference in New Issue
Block a user