add PreferredStepsType, fix StepsType jumps when changing songs if multiple StepsTypes are shown
This commit is contained in:
@@ -108,6 +108,7 @@ GameState::GameState() :
|
|||||||
m_PlayMode( Message_PlayModeChanged ),
|
m_PlayMode( Message_PlayModeChanged ),
|
||||||
m_sPreferredSongGroup( Message_PreferredSongGroupChanged ),
|
m_sPreferredSongGroup( Message_PreferredSongGroupChanged ),
|
||||||
m_sPreferredCourseGroup( Message_PreferredCourseGroupChanged ),
|
m_sPreferredCourseGroup( Message_PreferredCourseGroupChanged ),
|
||||||
|
m_PreferredStepsType( Message_PreferredStepsTypeChanged ),
|
||||||
m_PreferredDifficulty( Message_PreferredDifficultyP1Changed ),
|
m_PreferredDifficulty( Message_PreferredDifficultyP1Changed ),
|
||||||
m_PreferredCourseDifficulty( Message_PreferredCourseDifficultyP1Changed ),
|
m_PreferredCourseDifficulty( Message_PreferredCourseDifficultyP1Changed ),
|
||||||
m_SortOrder( Message_SortOrderChanged ),
|
m_SortOrder( Message_SortOrderChanged ),
|
||||||
@@ -219,6 +220,7 @@ void GameState::ApplyCmdline()
|
|||||||
|
|
||||||
void GameState::ResetPlayer( PlayerNumber pn )
|
void GameState::ResetPlayer( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
|
m_PreferredStepsType.Set( StepsType_Invalid );
|
||||||
m_PreferredDifficulty[pn].Set( Difficulty_Invalid );
|
m_PreferredDifficulty[pn].Set( Difficulty_Invalid );
|
||||||
m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium );
|
m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium );
|
||||||
m_iPlayerStageTokens[pn] = 0;
|
m_iPlayerStageTokens[pn] = 0;
|
||||||
@@ -726,7 +728,7 @@ void GameState::LoadCurrentSettingsFromProfile( PlayerNumber pn )
|
|||||||
ApplyPreferredModifiers( pn, sModifiers );
|
ApplyPreferredModifiers( pn, sModifiers );
|
||||||
}
|
}
|
||||||
// Only set the sort order if it wasn't already set by a GameCommand (or by an earlier profile)
|
// 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;
|
m_PreferredSortOrder = pProfile->m_SortOrder;
|
||||||
if( pProfile->m_LastDifficulty != Difficulty_Invalid )
|
if( pProfile->m_LastDifficulty != Difficulty_Invalid )
|
||||||
m_PreferredDifficulty[pn].Set( pProfile->m_LastDifficulty );
|
m_PreferredDifficulty[pn].Set( pProfile->m_LastDifficulty );
|
||||||
@@ -1715,9 +1717,10 @@ bool GameState::DifficultiesLocked() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
|
bool GameState::ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st )
|
||||||
{
|
{
|
||||||
m_PreferredDifficulty[pn].Set( dc );
|
m_PreferredDifficulty[pn].Set( dc );
|
||||||
|
m_PreferredStepsType.Set( st );
|
||||||
if( DifficultiesLocked() )
|
if( DifficultiesLocked() )
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
if( p != pn )
|
if( p != pn )
|
||||||
@@ -1768,10 +1771,10 @@ Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const
|
|||||||
return iClosest;
|
return iClosest;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
|
bool GameState::ChangePreferredCourseDifficultyAndStepsType( PlayerNumber pn, CourseDifficulty cd, StepsType st )
|
||||||
{
|
{
|
||||||
m_PreferredCourseDifficulty[pn].Set( cd );
|
m_PreferredCourseDifficulty[pn].Set( cd );
|
||||||
|
m_PreferredStepsType.Set( st );
|
||||||
if( PREFSMAN->m_bLockCourseDifficulties )
|
if( PREFSMAN->m_bLockCourseDifficulties )
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
if( p != pn )
|
if( p != pn )
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ public:
|
|||||||
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
|
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
|
||||||
bool m_bMultiplayer;
|
bool m_bMultiplayer;
|
||||||
bool DifficultiesLocked() const;
|
bool DifficultiesLocked() const;
|
||||||
bool ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc );
|
bool ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st );
|
||||||
bool ChangePreferredDifficulty( PlayerNumber pn, int dir );
|
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 ChangePreferredCourseDifficulty( PlayerNumber pn, int dir );
|
||||||
bool IsCourseDifficultyShown( CourseDifficulty cd );
|
bool IsCourseDifficultyShown( CourseDifficulty cd );
|
||||||
Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const;
|
Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const;
|
||||||
@@ -115,6 +115,7 @@ public:
|
|||||||
BroadcastOnChange<RString> m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group
|
BroadcastOnChange<RString> m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group
|
||||||
BroadcastOnChange<RString> m_sPreferredCourseGroup; // 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
|
bool m_bChangedFailTypeOnScreenSongOptions; // true if FailType was changed in the song options screen
|
||||||
|
BroadcastOnChange<StepsType> m_PreferredStepsType;
|
||||||
BroadcastOnChange1D<Difficulty,NUM_PLAYERS> m_PreferredDifficulty;
|
BroadcastOnChange1D<Difficulty,NUM_PLAYERS> m_PreferredDifficulty;
|
||||||
BroadcastOnChange1D<CourseDifficulty,NUM_PLAYERS> m_PreferredCourseDifficulty;// used in nonstop
|
BroadcastOnChange1D<CourseDifficulty,NUM_PLAYERS> m_PreferredCourseDifficulty;// used in nonstop
|
||||||
BroadcastOnChange<SortOrder> m_SortOrder; // set by MusicWheel
|
BroadcastOnChange<SortOrder> m_SortOrder; // set by MusicWheel
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ static const char *MessageIDNames[] = {
|
|||||||
"EditCourseDifficultyChanged",
|
"EditCourseDifficultyChanged",
|
||||||
"EditSourceStepsChanged",
|
"EditSourceStepsChanged",
|
||||||
"EditSourceStepsTypeChanged",
|
"EditSourceStepsTypeChanged",
|
||||||
|
"PreferredStepsTypeChanged",
|
||||||
"PreferredDifficultyP1Changed",
|
"PreferredDifficultyP1Changed",
|
||||||
"PreferredDifficultyP2Changed",
|
"PreferredDifficultyP2Changed",
|
||||||
"PreferredCourseDifficultyP1Changed",
|
"PreferredCourseDifficultyP1Changed",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ enum MessageID
|
|||||||
Message_EditCourseDifficultyChanged,
|
Message_EditCourseDifficultyChanged,
|
||||||
Message_EditSourceStepsChanged,
|
Message_EditSourceStepsChanged,
|
||||||
Message_EditSourceStepsTypeChanged,
|
Message_EditSourceStepsTypeChanged,
|
||||||
|
Message_PreferredStepsTypeChanged,
|
||||||
Message_PreferredDifficultyP1Changed,
|
Message_PreferredDifficultyP1Changed,
|
||||||
Message_PreferredDifficultyP2Changed,
|
Message_PreferredDifficultyP2Changed,
|
||||||
Message_PreferredCourseDifficultyP1Changed,
|
Message_PreferredCourseDifficultyP1Changed,
|
||||||
|
|||||||
@@ -629,8 +629,9 @@ void ScreenSelectMusic::ChangeDifficulty( PlayerNumber pn, int dir )
|
|||||||
if( CLAMP(m_iSelection[pn],0,m_vpSteps.size()-1) )
|
if( CLAMP(m_iSelection[pn],0,m_vpSteps.size()-1) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// the user explicity switched difficulties. Update the preferred difficulty
|
// the user explicity switched difficulties. Update the preferred Difficulty and StepsType
|
||||||
GAMESTATE->ChangePreferredDifficulty( pn, m_vpSteps[ m_iSelection[pn] ]->GetDifficulty() );
|
Steps *pSteps = m_vpSteps[ m_iSelection[pn] ];
|
||||||
|
GAMESTATE->ChangePreferredDifficultyAndStepsType( pn, pSteps->GetDifficulty(), pSteps->m_StepsType );
|
||||||
}
|
}
|
||||||
else if( GAMESTATE->m_pCurCourse )
|
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) )
|
if( CLAMP(m_iSelection[pn],0,m_vpTrails.size()-1) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// the user explicity switched difficulties. Update the preferred difficulty
|
// the user explicity switched difficulties. Update the preferred Difficulty and StepsType
|
||||||
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_vpTrails[ m_iSelection[pn] ]->m_CourseDifficulty );
|
Trail *pTrail = m_vpTrails[ m_iSelection[pn] ];
|
||||||
|
GAMESTATE->ChangePreferredCourseDifficultyAndStepsType( pn, pTrail->m_CourseDifficulty, pTrail->m_StepsType );
|
||||||
}
|
}
|
||||||
else
|
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 ) )
|
if( !GAMESTATE->ChangePreferredDifficulty( pn, dir ) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1022,26 +1029,30 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
|
|||||||
{
|
{
|
||||||
FOREACH_HumanPlayer( pn )
|
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 iCurDifference = -1;
|
||||||
int &iSelection = m_iSelection[pn];
|
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 the current steps are listed, use them. */
|
||||||
if( GAMESTATE->m_pCurSteps[pn] == m_vpSteps[i] )
|
if( GAMESTATE->m_pCurSteps[pn] == *s )
|
||||||
{
|
{
|
||||||
iSelection = i;
|
iSelection = i;
|
||||||
break;
|
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;
|
iSelection = i;
|
||||||
iCurDifference = iDiff;
|
iCurDifference = iTotalDifference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1056,8 +1067,10 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
|
|||||||
/* Find the closest match to the user's preferred difficulty. */
|
/* Find the closest match to the user's preferred difficulty. */
|
||||||
int iCurDifference = -1;
|
int iCurDifference = -1;
|
||||||
int &iSelection = m_iSelection[pn];
|
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 the current trail is listed, use it. */
|
||||||
if( GAMESTATE->m_pCurTrail[pn] == m_vpTrails[i] )
|
if( GAMESTATE->m_pCurTrail[pn] == m_vpTrails[i] )
|
||||||
{
|
{
|
||||||
@@ -1065,12 +1078,17 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iDiff = abs(m_vpTrails[i]->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn]);
|
if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
|
||||||
|
|
||||||
if( iCurDifference == -1 || iDiff < iCurDifference )
|
|
||||||
{
|
{
|
||||||
iSelection = i;
|
int iDifficultyDifference = abs( (*t)->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] );
|
||||||
iCurDifference = iDiff;
|
int iStepsTypeDifference = abs( (*t)->m_StepsType - GAMESTATE->m_PreferredStepsType );
|
||||||
|
int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference;
|
||||||
|
|
||||||
|
if( iCurDifference == -1 || iTotalDifference < iCurDifference )
|
||||||
|
{
|
||||||
|
iSelection = i;
|
||||||
|
iCurDifference = iTotalDifference;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user