Adjust fail mode after player options, not before.

This commit is contained in:
Glenn Maynard
2003-07-24 03:54:34 +00:00
parent e08a001137
commit 3967e4ca80
6 changed files with 55 additions and 50 deletions
+49 -1
View File
@@ -65,7 +65,7 @@ void GameState::Reset()
// m_iCoins = 0; // don't reset coin count!
m_MasterPlayerNumber = PLAYER_INVALID;
m_sPreferredGroup = GROUP_ALL_MUSIC;
m_bChangedFailMode = false;
m_bChangedFailType = false;
for( p=0; p<NUM_PLAYERS; p++ )
m_PreferredDifficulty[p] = DIFFICULTY_INVALID;
m_SongSortOrder = SORT_INVALID;
@@ -542,3 +542,51 @@ int GameState::GetSumOfActiveAttackLevels( PlayerNumber pn )
return iSum;
}
template<class T>
void setmin( T &a, const T &b )
{
a = min(a, b);
}
template<class T>
void setmax( T &a, const T &b )
{
a = max(a, b);
}
/* Adjust the fail mode based on the chosen difficulty. This must be called
* after the difficulty has been finalized (usually in ScreenSelectMusic or
* ScreenPlayerOptions), and before the fail mode is displayed or used (usually
* in ScreenSongOptions). */
void GameState::AdjustFailType()
{
/* If the player changed the fail mode explicitly, leave it alone. */
if( GAMESTATE->m_bChangedFailType )
return;
/* Find the easiest difficulty notes selected by either player. */
Difficulty dc = DIFFICULTY_INVALID;
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
dc = min(dc, GAMESTATE->m_pCurNotes[p]->GetDifficulty());
}
/* Reset the fail type to the default. */
SongOptions so;
so.FromString( PREFSMAN->m_sDefaultModifiers );
GAMESTATE->m_SongOptions.m_FailType = so.m_FailType;
/* Easy and beginner are never harder than FAIL_END_OF_SONG. */
if(dc <= DIFFICULTY_EASY)
setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_END_OF_SONG);
/* If beginner's steps were chosen, and this is the first stage,
* turn off failure completely--always give a second try. */
if(dc == DIFFICULTY_BEGINNER &&
!PREFSMAN->m_bEventMode && /* stage index is meaningless in event mode */
GAMESTATE->m_iCurrentStageIndex == 0)
setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_OFF);
}
+2 -1
View File
@@ -104,7 +104,7 @@ public:
CString m_sLoadingMessage; // used in loading screen
CString m_sPreferredGroup; // GROUP_ALL_MUSIC denotes no preferred group
bool m_bChangedFailMode; // true if the fail mode was changed in the song options screen
bool m_bChangedFailType; // true if FailType was changed in the song options screen
Difficulty m_PreferredDifficulty[NUM_PLAYERS];
SongSortOrder m_SongSortOrder; // used by MusicWheel
bool m_bEditing; // NoteField does special stuff when this is true
@@ -203,6 +203,7 @@ public:
void StoreSelectedOptions();
void RestoreSelectedOptions();
void AdjustFailType();
// character stuff
vector<Character*> m_pCharacters;
+2
View File
@@ -362,6 +362,8 @@ void ScreenPlayerOptions::GoToPrevState()
void ScreenPlayerOptions::GoToNextState()
{
GAMESTATE->AdjustFailType();
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen();
else if( m_bGoToOptions )
+1 -46
View File
@@ -669,51 +669,6 @@ void ScreenSelectMusic::HarderDifficulty( PlayerNumber pn )
AfterNotesChange( pn );
}
template<class T>
void setmin( T &a, const T &b )
{
a = min(a, b);
}
template<class T>
void setmax( T &a, const T &b )
{
a = max(a, b);
}
/* Adjust game options. These settings may be overridden again later by the
* SongOptions menu. */
void ScreenSelectMusic::AdjustOptions()
{
/* Find the easiest difficulty notes selected by either player. */
Difficulty dc = DIFFICULTY_INVALID;
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
dc = min(dc, GAMESTATE->m_pCurNotes[p]->GetDifficulty());
}
if( !GAMESTATE->m_bChangedFailMode )
{
/* Reset the fail type to the default. */
SongOptions so;
so.FromString( PREFSMAN->m_sDefaultModifiers );
GAMESTATE->m_SongOptions.m_FailType = so.m_FailType;
/* Easy and beginner are never harder than FAIL_END_OF_SONG. */
if(dc <= DIFFICULTY_EASY)
setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_END_OF_SONG);
/* If beginner's steps were chosen, and this is the first stage,
* turn off failure completely--always give a second try. */
if(dc == DIFFICULTY_BEGINNER &&
!PREFSMAN->m_bEventMode && /* stage index is meaningless in event mode */
GAMESTATE->m_iCurrentStageIndex == 0)
setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_OFF);
}
}
void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
{
@@ -754,6 +709,7 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
}
else
{
GAMESTATE->AdjustFailType();
SOUNDMAN->StopMusic();
SCREENMAN->SetNewScreen( NEXT_SCREEN(GAMESTATE->m_PlayMode) );
}
@@ -822,7 +778,6 @@ void ScreenSelectMusic::MenuStart( PlayerNumber pn )
if( GAMESTATE->IsCourseMode() )
GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE;
AdjustOptions();
break;
}
case TYPE_COURSE:
-1
View File
@@ -65,7 +65,6 @@ protected:
void SortOrderChanged();
void UpdateOptionsDisplays();
void AdjustOptions();
vector<Notes*> m_arrayNotes;
int m_iSelection[NUM_PLAYERS];
+1 -1
View File
@@ -104,7 +104,7 @@ void ScreenSongOptions::ExportOptions()
if( so.m_FailType != (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL] )
{
/* The user is changing the fail mode explicitly; stop messing with it. */
GAMESTATE->m_bChangedFailMode = true;
GAMESTATE->m_bChangedFailType = true;
so.m_FailType = (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL];
}
so.m_bAssistTick = !!m_iSelectedOption[0][SO_ASSIST];