fix ScreenEnding shows stats when not using a memory card

fix other bugs introduced when GetProfile was changed to return a valid pointer even with no profile loaded
This commit is contained in:
Chris Danford
2005-05-01 06:42:30 +00:00
parent b5bac56889
commit 3a726a1c9b
15 changed files with 38 additions and 55 deletions
+2 -2
View File
@@ -167,9 +167,9 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector<Course*> &vpCours
void CourseUtil::SortCoursePointerArrayByNumPlays( vector<Course*> &vpCoursesInOut, ProfileSlot slot, bool bDescending )
{
Profile* pProfile = PROFILEMAN->GetProfile(slot);
if( pProfile == NULL )
if( !PROFILEMAN->IsUsingProfile(slot) )
return; // nothing to do since we don't have data
Profile* pProfile = PROFILEMAN->GetProfile(slot);
SortCoursePointerArrayByNumPlays( vpCoursesInOut, pProfile, bDescending );
}
+1 -2
View File
@@ -619,8 +619,7 @@ void GameState::ResetStageStatistics()
FOREACH_PlayerNumber( p )
{
Profile* pProfile = PROFILEMAN->GetProfile(p);
if( pProfile )
STATSMAN->m_CurStageStats.m_player[p].iCurCombo = pProfile->m_iCurrentCombo;
STATSMAN->m_CurStageStats.m_player[p].iCurCombo = pProfile->m_iCurrentCombo;
}
}
else // GetStageIndex() > 0
+3
View File
@@ -477,7 +477,10 @@ void MemoryCardManager::CheckStateChanges()
case MEMORY_CARD_STATE_NO_CARD:
case MEMORY_CARD_STATE_REMOVED:
if( LastState == MEMORY_CARD_STATE_READY )
{
m_soundDisconnect.Play();
MESSAGEMAN->Broadcast( (Message)(MESSAGE_CARD_REMOVED_P1+p) );
}
break;
case MEMORY_CARD_STATE_READY:
m_soundReady.Play();
+2
View File
@@ -25,6 +25,8 @@ static const CString MessageNames[NUM_MESSAGES] = {
"NoteWillCrossIn500Ms",
"NoteWillCrossIn1000Ms",
"NoteWillCrossIn1500Ms",
"CardRemovedP1",
"CardRemovedP2",
};
XToString( Message, NUM_MESSAGES );
+2
View File
@@ -32,6 +32,8 @@ enum Message
MESSAGE_NOTE_WILL_CROSS_IN_500MS,
MESSAGE_NOTE_WILL_CROSS_IN_1000MS,
MESSAGE_NOTE_WILL_CROSS_IN_1500MS,
MESSAGE_CARD_REMOVED_P1,
MESSAGE_CARD_REMOVED_P2,
NUM_MESSAGES,
MESSAGE_INVALID
};
+1 -1
View File
@@ -172,7 +172,7 @@ void PaneDisplay::SetContent( PaneContents c )
const Steps *pSteps = GAMESTATE->m_pCurSteps[m_PlayerNumber];
const Course *pCourse = GAMESTATE->m_pCurCourse;
const Trail *pTrail = GAMESTATE->m_pCurTrail[m_PlayerNumber];
const Profile *pProfile = PROFILEMAN->GetProfile( m_PlayerNumber );
const Profile *pProfile = PROFILEMAN->IsUsingProfile(m_PlayerNumber) ? PROFILEMAN->GetProfile(m_PlayerNumber) : NULL;
bool bIsEdit = pSteps && pSteps->GetDifficulty() == DIFFICULTY_EDIT;
if( (g_Contents[c].req&NEED_NOTES) && !pSteps )
+4 -1
View File
@@ -49,10 +49,13 @@ public:
bool IsUsingProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); }
bool IsUsingProfile( ProfileSlot slot ) const;
const Profile* GetProfile( PlayerNumber pn ) const; // return a profile even if !IsUsingProfile
// return a profile even if !IsUsingProfile
const Profile* GetProfile( PlayerNumber pn ) const;
Profile* GetProfile( PlayerNumber pn ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(pn); }
const Profile* GetProfile( ProfileSlot slot ) const;
Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); }
CString GetProfileDir( ProfileSlot slot ) const;
CString GetProfileDirImportedFrom( ProfileSlot slot ) const;
+13 -35
View File
@@ -200,26 +200,13 @@ void ScreenEnding::Init()
SONGMAN->GetSongs( arraySongs );
SongUtil::SortSongPointerArrayByTitle( arraySongs );
FOREACH_PlayerNumber( p )
FOREACH_HumanPlayer( p )
{
m_bWaitingForRemoveCard[p] = false;
// don't show stats if not using a profile
if( !PROFILEMAN->IsUsingProfile(p) )
continue;
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
Profile* pProfile = PROFILEMAN->GetProfile( p );
m_bWaitingForRemoveCard[p] = true;
switch( MEMCARDMAN->GetCardState(p) )
{
case MEMORY_CARD_STATE_REMOVED:
case MEMORY_CARD_STATE_NO_CARD:
m_bWaitingForRemoveCard[p] = false;
break;
}
if( pProfile == NULL )
continue; // don't show the stats lines
Profile* pProfile = PROFILEMAN->GetProfile(p);
FOREACH_EndingStatsLine( i )
{
@@ -238,7 +225,15 @@ void ScreenEnding::Init()
m_sprRemoveMemoryCard[p].SetName( ssprintf("RemoveCardP%d",p+1) );
m_sprRemoveMemoryCard[p].Load( THEME->GetPathG("ScreenEnding",ssprintf("remove card P%d",p+1)) );
switch( MEMCARDMAN->GetCardState(p) )
{
case MEMORY_CARD_STATE_REMOVED:
case MEMORY_CARD_STATE_NO_CARD:
m_sprRemoveMemoryCard[p].SetHidden( true );
break;
}
SET_XY_AND_ON_COMMAND( m_sprRemoveMemoryCard[p] );
m_sprRemoveMemoryCard[p].AddCommand( ssprintf("CardRemovedP%dMessage",p+1), apActorCommands(new ActorCommands("hidden,1")) );
this->AddChild( &m_sprRemoveMemoryCard[p] );
}
@@ -262,23 +257,6 @@ void ScreenEnding::Update( float fDeltaTime )
if( m_In.IsTransitioning() && m_Out.IsTransitioning() )
return;
FOREACH_PlayerNumber( p )
{
if( m_bWaitingForRemoveCard[p] )
{
m_bWaitingForRemoveCard[p] = true;
switch( MEMCARDMAN->GetCardState(p) )
{
case MEMORY_CARD_STATE_REMOVED:
case MEMORY_CARD_STATE_NO_CARD:
m_bWaitingForRemoveCard[p] = false;
break;
}
if( !m_bWaitingForRemoveCard[p] )
m_sprRemoveMemoryCard[p].SetHidden( true );
}
}
}
void ScreenEnding::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
-1
View File
@@ -39,7 +39,6 @@ private:
} m_Lines[NUM_ENDING_STATS_LINES][NUM_PLAYERS];
Sprite m_sprRemoveMemoryCard[NUM_PLAYERS];
bool m_bWaitingForRemoveCard[NUM_PLAYERS];
};
#endif
+1 -2
View File
@@ -142,8 +142,7 @@ void ScreenJukebox::Init()
{
/* Reset the combo, in case ComboContinuesBetweenSongs is enabled. */
Profile* pProfile = PROFILEMAN->GetProfile(p);
if( pProfile )
STATSMAN->m_CurStageStats.m_player[p].iCurCombo = 0;
STATSMAN->m_CurStageStats.m_player[p].iCurCombo = 0;
if( GAMESTATE->m_bJukeboxUsesModifiers )
{
+1 -2
View File
@@ -414,8 +414,7 @@ void ScreenNameEntry::MenuStart( PlayerNumber pn )
// save last used ranking name
Profile* pProfile = PROFILEMAN->GetProfile(pn);
if( pProfile )
pProfile->m_sLastUsedHighScoreName = m_sSelectedName[pn];
pProfile->m_sLastUsedHighScoreName = m_sSelectedName[pn];
TrimRight( m_sSelectedName[pn], " " );
TrimLeft( m_sSelectedName[pn], " " );
+1 -2
View File
@@ -594,8 +594,7 @@ void ScreenNameEntryTraditional::Finish( PlayerNumber pn )
// save last used ranking name
Profile* pProfile = PROFILEMAN->GetProfile(pn);
if( pProfile )
pProfile->m_sLastUsedHighScoreName = selection;
pProfile->m_sLastUsedHighScoreName = selection;
TrimRight( selection, " " );
TrimLeft( selection, " " );
+3 -3
View File
@@ -132,12 +132,12 @@ CString ScreenSystemLayer::GetCreditsMessage( PlayerNumber pn ) const
{
case MEMORY_CARD_STATE_NO_CARD:
// this is a local machine profile
if( PROFILEMAN->LastLoadWasFromLastGood(pn) && pProfile )
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
return pProfile->GetDisplayName() + CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
else if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) )
return CREDITS_LOAD_FAILED.GetValue();
// Prefer the name of the profile over the name of the card.
else if( pProfile )
else if( PROFILEMAN->IsUsingProfile(pn) )
return pProfile->GetDisplayName();
else if( GAMESTATE->PlayersCanJoin() )
return CREDITS_INSERT_CARD.GetValue();
@@ -155,7 +155,7 @@ CString ScreenSystemLayer::GetCreditsMessage( PlayerNumber pn ) const
return CREDITS_LOAD_FAILED.GetValue();
// If there is a local profile loaded, prefer it over the name of the memory card.
if( pProfile )
if( PROFILEMAN->IsUsingProfile(pn) )
{
CString s = pProfile->GetDisplayName();
if( s.empty() )
+2 -2
View File
@@ -194,9 +194,9 @@ void SongUtil::SortSongPointerArrayByGroupAndTitle( vector<Song*> &vpSongsInOut
void SongUtil::SortSongPointerArrayByNumPlays( vector<Song*> &vpSongsInOut, ProfileSlot slot, bool bDescending )
{
Profile* pProfile = PROFILEMAN->GetProfile(slot);
if( pProfile == NULL )
if( !PROFILEMAN->IsUsingProfile(slot) )
return; // nothing to do since we don't have data
Profile* pProfile = PROFILEMAN->GetProfile(slot);
SortSongPointerArrayByNumPlays( vpSongsInOut, pProfile, bDescending );
}
+2 -2
View File
@@ -25,9 +25,9 @@ bool CompareStepsPointersBySortValueDescending(const Steps *pSteps1, const Steps
void StepsUtil::SortStepsPointerArrayByNumPlays( vector<Steps*> &vStepsPointers, ProfileSlot slot, bool bDescending )
{
Profile* pProfile = PROFILEMAN->GetProfile(slot);
if( pProfile == NULL )
if( !PROFILEMAN->IsUsingProfile(slot) )
return; // nothing to do since we don't have data
Profile* pProfile = PROFILEMAN->GetProfile(slot);
SortStepsPointerArrayByNumPlays( vStepsPointers, pProfile, bDescending );
}