add PreferredStepsType, fix StepsType jumps when changing songs if multiple StepsTypes are shown

This commit is contained in:
Chris Danford
2007-05-15 19:32:39 +00:00
parent 571d0d6fda
commit 71492cd106
5 changed files with 47 additions and 23 deletions
+7 -4
View File
@@ -108,6 +108,7 @@ GameState::GameState() :
m_PlayMode( Message_PlayModeChanged ),
m_sPreferredSongGroup( Message_PreferredSongGroupChanged ),
m_sPreferredCourseGroup( Message_PreferredCourseGroupChanged ),
m_PreferredStepsType( Message_PreferredStepsTypeChanged ),
m_PreferredDifficulty( Message_PreferredDifficultyP1Changed ),
m_PreferredCourseDifficulty( Message_PreferredCourseDifficultyP1Changed ),
m_SortOrder( Message_SortOrderChanged ),
@@ -219,6 +220,7 @@ void GameState::ApplyCmdline()
void GameState::ResetPlayer( PlayerNumber pn )
{
m_PreferredStepsType.Set( StepsType_Invalid );
m_PreferredDifficulty[pn].Set( Difficulty_Invalid );
m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium );
m_iPlayerStageTokens[pn] = 0;
@@ -726,7 +728,7 @@ void GameState::LoadCurrentSettingsFromProfile( PlayerNumber pn )
ApplyPreferredModifiers( pn, sModifiers );
}
// Only set the sort order if it wasn't already set by a GameCommand (or by an earlier profile)
if( m_PreferredSortOrder == SortOrder_Invalid && pProfile->m_SortOrder != SortOrder_Invalid )
if( m_PreferredSortOrder == SortOrder_Invalid && pProfile->m_SortOrder != SortOrder_Invalid )
m_PreferredSortOrder = pProfile->m_SortOrder;
if( pProfile->m_LastDifficulty != Difficulty_Invalid )
m_PreferredDifficulty[pn].Set( pProfile->m_LastDifficulty );
@@ -1715,9 +1717,10 @@ bool GameState::DifficultiesLocked() const
return false;
}
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
bool GameState::ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st )
{
m_PreferredDifficulty[pn].Set( dc );
m_PreferredStepsType.Set( st );
if( DifficultiesLocked() )
FOREACH_PlayerNumber( p )
if( p != pn )
@@ -1768,10 +1771,10 @@ Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const
return iClosest;
}
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
bool GameState::ChangePreferredCourseDifficultyAndStepsType( PlayerNumber pn, CourseDifficulty cd, StepsType st )
{
m_PreferredCourseDifficulty[pn].Set( cd );
m_PreferredStepsType.Set( st );
if( PREFSMAN->m_bLockCourseDifficulties )
FOREACH_PlayerNumber( p )
if( p != pn )
+3 -2
View File
@@ -71,9 +71,9 @@ public:
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
bool m_bMultiplayer;
bool DifficultiesLocked() const;
bool ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc );
bool ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st );
bool ChangePreferredDifficulty( PlayerNumber pn, int dir );
bool ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd );
bool ChangePreferredCourseDifficultyAndStepsType( PlayerNumber pn, CourseDifficulty cd, StepsType st );
bool ChangePreferredCourseDifficulty( PlayerNumber pn, int dir );
bool IsCourseDifficultyShown( CourseDifficulty cd );
Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const;
@@ -115,6 +115,7 @@ public:
BroadcastOnChange<RString> m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group
BroadcastOnChange<RString> m_sPreferredCourseGroup; // GROUP_ALL denotes no preferred group
bool m_bChangedFailTypeOnScreenSongOptions; // true if FailType was changed in the song options screen
BroadcastOnChange<StepsType> m_PreferredStepsType;
BroadcastOnChange1D<Difficulty,NUM_PLAYERS> m_PreferredDifficulty;
BroadcastOnChange1D<CourseDifficulty,NUM_PLAYERS> m_PreferredCourseDifficulty;// used in nonstop
BroadcastOnChange<SortOrder> m_SortOrder; // set by MusicWheel
+1
View File
@@ -27,6 +27,7 @@ static const char *MessageIDNames[] = {
"EditCourseDifficultyChanged",
"EditSourceStepsChanged",
"EditSourceStepsTypeChanged",
"PreferredStepsTypeChanged",
"PreferredDifficultyP1Changed",
"PreferredDifficultyP2Changed",
"PreferredCourseDifficultyP1Changed",
+1
View File
@@ -24,6 +24,7 @@ enum MessageID
Message_EditCourseDifficultyChanged,
Message_EditSourceStepsChanged,
Message_EditSourceStepsTypeChanged,
Message_PreferredStepsTypeChanged,
Message_PreferredDifficultyP1Changed,
Message_PreferredDifficultyP2Changed,
Message_PreferredCourseDifficultyP1Changed,
+35 -17
View File
@@ -629,8 +629,9 @@ void ScreenSelectMusic::ChangeDifficulty( PlayerNumber pn, int dir )
if( CLAMP(m_iSelection[pn],0,m_vpSteps.size()-1) )
return;
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->ChangePreferredDifficulty( pn, m_vpSteps[ m_iSelection[pn] ]->GetDifficulty() );
// the user explicity switched difficulties. Update the preferred Difficulty and StepsType
Steps *pSteps = m_vpSteps[ m_iSelection[pn] ];
GAMESTATE->ChangePreferredDifficultyAndStepsType( pn, pSteps->GetDifficulty(), pSteps->m_StepsType );
}
else if( GAMESTATE->m_pCurCourse )
{
@@ -638,11 +639,17 @@ void ScreenSelectMusic::ChangeDifficulty( PlayerNumber pn, int dir )
if( CLAMP(m_iSelection[pn],0,m_vpTrails.size()-1) )
return;
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_vpTrails[ m_iSelection[pn] ]->m_CourseDifficulty );
// the user explicity switched difficulties. Update the preferred Difficulty and StepsType
Trail *pTrail = m_vpTrails[ m_iSelection[pn] ];
GAMESTATE->ChangePreferredCourseDifficultyAndStepsType( pn, pTrail->m_CourseDifficulty, pTrail->m_StepsType );
}
else
{
// If we're showing multiple StepsTypes in the list, don't allow changing the difficulty/StepsType
// when a non-Song, non-Course is selected. Chaning the preferred Difficulty and StepsType
// by direction is complicated when multiple StepsTypes are being shown, so we don't support it.
if( CommonMetrics::AUTO_SET_STYLE )
return;
if( !GAMESTATE->ChangePreferredDifficulty( pn, dir ) )
return;
}
@@ -1022,26 +1029,30 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
{
FOREACH_HumanPlayer( pn )
{
/* Find the closest match to the user's preferred difficulty. */
/* Find the closest match to the user's preferred difficulty and StepsType. */
int iCurDifference = -1;
int &iSelection = m_iSelection[pn];
for( unsigned i=0; i<m_vpSteps.size(); i++ )
FOREACH_CONST( Steps*, m_vpSteps, s )
{
int i = s - m_vpSteps.begin();
/* If the current steps are listed, use them. */
if( GAMESTATE->m_pCurSteps[pn] == m_vpSteps[i] )
if( GAMESTATE->m_pCurSteps[pn] == *s )
{
iSelection = i;
break;
}
if( GAMESTATE->m_PreferredDifficulty[pn] != Difficulty_Invalid )
if( GAMESTATE->m_PreferredDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
{
int iDiff = abs(m_vpSteps[i]->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn]);
int iDifficultyDifference = abs( (*s)->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn] );
int iStepsTypeDifference = abs( (*s)->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_Difficulty + iDifficultyDifference;
if( iCurDifference == -1 || iDiff < iCurDifference )
if( iCurDifference == -1 || iTotalDifference < iCurDifference )
{
iSelection = i;
iCurDifference = iDiff;
iCurDifference = iTotalDifference;
}
}
}
@@ -1056,8 +1067,10 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
/* Find the closest match to the user's preferred difficulty. */
int iCurDifference = -1;
int &iSelection = m_iSelection[pn];
for( unsigned i=0; i<m_vpTrails.size(); i++ )
FOREACH_CONST( Trail*, m_vpTrails, t )
{
int i = t - m_vpTrails.begin();
/* If the current trail is listed, use it. */
if( GAMESTATE->m_pCurTrail[pn] == m_vpTrails[i] )
{
@@ -1065,12 +1078,17 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
break;
}
int iDiff = abs(m_vpTrails[i]->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn]);
if( iCurDifference == -1 || iDiff < iCurDifference )
if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
{
iSelection = i;
iCurDifference = iDiff;
int iDifficultyDifference = abs( (*t)->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] );
int iStepsTypeDifference = abs( (*t)->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference;
if( iCurDifference == -1 || iTotalDifference < iCurDifference )
{
iSelection = i;
iCurDifference = iTotalDifference;
}
}
}