From 40d0062120e0bc7a2ac6c15aaf67bbaed853c4ed Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 7 Jan 2004 04:37:00 +0000 Subject: [PATCH] add remove memory card graphic to ScreenEnding --- stepmania/src/ActorFrame.cpp | 5 +- stepmania/src/GhostArrow.cpp | 3 + stepmania/src/ScreenEnding.cpp | 165 +++++++++++++++++++++ stepmania/src/ScreenEnding.h | 36 +++++ stepmania/src/ScreenNameEntryTraditional.h | 1 + 5 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 stepmania/src/ScreenEnding.cpp create mode 100644 stepmania/src/ScreenEnding.h diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 01200d17e7..1afd12c236 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -11,6 +11,8 @@ */ #include "ActorFrame.h" +#include "arch/ArchHooks/ArchHooks.h" +#include "RageUtil.h" void ActorFrame::AddChild( Actor* pActor ) { @@ -18,8 +20,7 @@ void ActorFrame::AddChild( Actor* pActor ) // check that this Actor isn't already added. vector::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor ); if( iter != m_SubActors.end() ) - RageException::Throw( "Actor \"%s\" adds child \"%s\" more than once", - m_sName.c_str(), pActor->m_sName.c_str() ); + HOOKS->MessageBoxOK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", m_sName.c_str(), pActor->m_sName.c_str()) ); #endif ASSERT( pActor ); diff --git a/stepmania/src/GhostArrow.cpp b/stepmania/src/GhostArrow.cpp index ce4a79200e..58f81be759 100644 --- a/stepmania/src/GhostArrow.cpp +++ b/stepmania/src/GhostArrow.cpp @@ -63,6 +63,9 @@ void GhostArrow::Step( TapNoteScore score ) { for( int i=0; iGetMetricF("ScreenEnding","ScrollDelay") +#define SCROLL_SPEED THEME->GetMetricF("ScreenEnding","ScrollSpeed") +#define TEXT_ZOOM THEME->GetMetricF("ScreenEnding","TextZoom") + + +CString STATS_LINE_TITLE[NUM_STATS_LINES] = { + "Total Calories", + "Total Songs Played", + "Current Combo", +}; + +CString GetStatsLineValue( PlayerNumber pn, int iLine ) +{ + Profile* pProfile = PROFILEMAN->GetProfile( pn ); + ASSERT( pProfile ); + + switch( iLine ) + { + case 0: + return pProfile->GetDisplayCaloriesBurned(); + case 1: + return ssprintf( "%d", pProfile->GetTotalNumSongsPlayed() ); // fixme + case 2: + return ssprintf( "%d", pProfile->m_iCurrentCombo ); + default: + ASSERT(0); + return ""; + } +} + + +ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, false/*dont reset GAMESTATE*/ ) +{ + vector arraySongs; + SONGMAN->GetSongs( arraySongs ); + SortSongPointerArrayByTitle( arraySongs ); + + for( int p=0; pIsHumanPlayer(p) ) + continue; // skip + + Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p ); + + m_textPlayerName[p].LoadFromFont( THEME->GetPathToF("ScreenEnding player name") ); + m_textPlayerName[p].SetText( pProfile ? pProfile->GetDisplayName() : "NO CARD" ); + m_textPlayerName[p].SetName( ssprintf("PlayerNameP%d",p+1) ); + SET_XY_AND_ON_COMMAND( m_textPlayerName[p] ); + this->AddChild( &m_textPlayerName[p] ); + + m_bWaitingForRemoveCard[p] = MEMCARDMAN->GetCardState((PlayerNumber)p)!=MEMORY_CARD_STATE_NO_CARD; + + if( pProfile == NULL ) + continue; // don't show the stats lines + + for( int i=0; iGetPathToF("ScreenEnding stats title") ); + m_textStatsTitle[p][i].SetText( STATS_LINE_TITLE[i] ); + m_textStatsTitle[p][i].SetName( ssprintf("StatsTitleP%dLine%d",p+1,i+1) ); + SET_XY_AND_ON_COMMAND( m_textStatsTitle[p][i] ); + this->AddChild( &m_textStatsTitle[p][i] ); + + m_textStatsValue[p][i].LoadFromFont( THEME->GetPathToF("ScreenEnding stats value") ); + m_textStatsValue[p][i].SetText( GetStatsLineValue((PlayerNumber)p, i) ); + m_textStatsValue[p][i].SetName( ssprintf("StatsValueP%dLine%d",p+1,i+1) ); + SET_XY_AND_ON_COMMAND( m_textStatsValue[p][i] ); + this->AddChild( &m_textStatsValue[p][i] ); + } + + m_sprRemoveMemoryCard[p].SetName( ssprintf("RemoveCardP%d",p+1) ); + m_sprRemoveMemoryCard[p].Load( THEME->GetPathToG("ScreenEnding remove card") ); + SET_XY_AND_ON_COMMAND( m_sprRemoveMemoryCard[p] ); + this->AddChild( &m_sprRemoveMemoryCard[p] ); + } + + + this->MoveToTail( &m_In ); // put it in the back so it covers up the stuff we just added + this->MoveToTail( &m_Out ); // put it in the back so it covers up the stuff we just added + + SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("music scroll") ); + + // Now that we've read the data from the profile, it's ok to Reset() + GAMESTATE->Reset(); + + // TRICKY: Don't let the timer take us to the next screen until after all memory cards + // have been removed. + this->ClearMessageQueue(); + + m_fTimeUntilBeginFadingOut = m_Background.GetLengthSeconds() - m_Out.GetLengthSeconds(); + if( m_fTimeUntilBeginFadingOut < 0 ) + { + LOG->Warn( "Screen '%s' Out BGAnimation (%f seconds) is longer than Background BGAnimation (%f seconds); background BGA will be truncated", + m_sName.c_str(), m_Out.GetLengthSeconds(), m_Background.GetLengthSeconds() ); + m_fTimeUntilBeginFadingOut = 0; + } +} + +ScreenEnding::~ScreenEnding() +{ +} + +void ScreenEnding::Update( float fDeltaTime ) +{ + ScreenAttract::Update( fDeltaTime ); + + bool bRemovedOneOrMore = false; + bool bAllRemoved = true; + + for( int p=0; pGetCardState((PlayerNumber)p)!=MEMORY_CARD_STATE_NO_CARD; + if( m_bWaitingForRemoveCard[p] ) + { + bAllRemoved = false; + } + else + { + m_sprRemoveMemoryCard[p].SetHidden( true ); + bRemovedOneOrMore = true; + } + } + } + + m_fTimeUntilBeginFadingOut = max( 0, m_fTimeUntilBeginFadingOut-fDeltaTime ); + + if( bRemovedOneOrMore && bAllRemoved ) + this->PostScreenMessage( SM_BeginFadingOut, m_fTimeUntilBeginFadingOut ); +} + +void ScreenEnding::HandleScreenMessage( const ScreenMessage SM ) +{ + ScreenAttract::HandleScreenMessage( SM ); +} \ No newline at end of file diff --git a/stepmania/src/ScreenEnding.h b/stepmania/src/ScreenEnding.h new file mode 100644 index 0000000000..d37066ad38 --- /dev/null +++ b/stepmania/src/ScreenEnding.h @@ -0,0 +1,36 @@ +/* +----------------------------------------------------------------------------- + File: ScreenEnding.h + + Desc: Ending screen that shows stats. + + Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved. + Chris Danford + Glenn Maynard +----------------------------------------------------------------------------- +*/ + +#include "BitmapText.h" +#include "ScreenAttract.h" + +class ScreenEnding : public ScreenAttract +{ +public: + ScreenEnding( CString sName ); + ~ScreenEnding(); + + void Update( float fDeltaTime ); + void HandleScreenMessage( const ScreenMessage SM ); + +private: + BitmapText m_textPlayerName[NUM_PLAYERS]; +#define NUM_STATS_LINES 3 // Total calories burned, total songs played, current combo + BitmapText m_textStatsTitle[NUM_PLAYERS][NUM_STATS_LINES]; + BitmapText m_textStatsValue[NUM_PLAYERS][NUM_STATS_LINES]; + + Sprite m_sprRemoveMemoryCard[NUM_PLAYERS]; + bool m_bWaitingForRemoveCard[NUM_PLAYERS]; + float m_fTimeUntilBeginFadingOut; +}; + + diff --git a/stepmania/src/ScreenNameEntryTraditional.h b/stepmania/src/ScreenNameEntryTraditional.h index 1c15cfa81d..47977305d6 100644 --- a/stepmania/src/ScreenNameEntryTraditional.h +++ b/stepmania/src/ScreenNameEntryTraditional.h @@ -66,6 +66,7 @@ private: BitmapText m_textSelection[NUM_PLAYERS]; wstring m_sSelection[NUM_PLAYERS]; bool m_bStillEnteringName[NUM_PLAYERS]; + bool m_bGoToNextScreenWhenCardsRemoved; };