Remove backgrounds on screens. Have one shared background that persists across screens.

This commit is contained in:
Chris Danford
2004-12-09 08:16:18 +00:00
parent 08964e340b
commit b6d711b3c1
18 changed files with 92 additions and 93 deletions
+13 -13
View File
@@ -33,9 +33,6 @@ ScreenAttract::ScreenAttract( CString sName, bool bResetGameState ) : Screen( sN
// We have to do initialization in the first update because this->GetElementName() won't
// work until the object has been fully constructed.
m_Background.LoadFromAniDir( THEME->GetPathToB(m_sName+" background") );
this->AddChild( &m_Background );
m_In.Load( THEME->GetPathToB(m_sName+" in") );
m_In.StartTransitioning();
m_In.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
@@ -46,16 +43,6 @@ ScreenAttract::ScreenAttract( CString sName, bool bResetGameState ) : Screen( sN
this->AddChild( &m_Out );
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(m_sName) );
float fTimeUntilBeginFadingOut = m_Background.GetLengthSeconds() - m_Out.GetLengthSeconds();
if( 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() );
fTimeUntilBeginFadingOut = 0;
}
this->PostScreenMessage( SM_BeginFadingOut, fTimeUntilBeginFadingOut );
}
@@ -132,6 +119,19 @@ void ScreenAttract::Update( float fDelta )
{
if( IsFirstUpdate() )
{
// The shared background isn't loaded until the screen is actually
// showing. The background is loaded by the time of the first update.
BGAnimation &background = *SCREENMAN->m_pSharedBGA;
float fTimeUntilBeginFadingOut = background.GetLengthSeconds() - m_Out.GetLengthSeconds();
if( 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(), background.GetLengthSeconds() );
fTimeUntilBeginFadingOut = 0;
}
this->PostScreenMessage( SM_BeginFadingOut, fTimeUntilBeginFadingOut );
if( GAMESTATE->IsTimeToPlayAttractSounds() )
SOUND->PlayMusic( THEME->GetPathToS(m_sName + " music") );
else
-1
View File
@@ -20,7 +20,6 @@ public:
virtual void HandleScreenMessage( const ScreenMessage SM );
protected:
BGAnimation m_Background;
Transition m_In;
Transition m_Out;
};
-8
View File
@@ -412,8 +412,6 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName )
GAMESTATE->ResetNoteSkins();
GAMESTATE->StoreSelectedOptions();
m_BGAnimation.LoadFromAniDir( THEME->GetPathToB("ScreenEdit background") );
shiftAnchor = -1;
@@ -605,7 +603,6 @@ void ScreenEdit::Update( float fDeltaTime )
}
}
m_BGAnimation.Update( fDeltaTime );
m_SnapDisplay.Update( fDeltaTime );
m_NoteFieldEdit.Update( fDeltaTime );
m_In.Update( fDeltaTime );
@@ -713,7 +710,6 @@ void ScreenEdit::DrawPrimitives()
{
case MODE_EDITING:
{
m_BGAnimation.Draw();
m_sprHelp.Draw();
m_textHelp.Draw();
m_sprInfo.Draw();
@@ -733,8 +729,6 @@ void ScreenEdit::DrawPrimitives()
case MODE_RECORDING:
if( PREFSMAN->m_bEditorShowBGChangesPlay )
m_Background.Draw();
else
m_BGAnimation.Draw();
m_NoteFieldRecord.Draw();
if( PREFSMAN->m_bEditorShowBGChangesPlay )
@@ -743,8 +737,6 @@ void ScreenEdit::DrawPrimitives()
case MODE_PLAYING:
if( PREFSMAN->m_bEditorShowBGChangesPlay )
m_Background.Draw();
else
m_BGAnimation.Draw();
m_Player.Draw();
if( PREFSMAN->m_bEditorShowBGChangesPlay )
-2
View File
@@ -51,8 +51,6 @@ protected:
Song* m_pSong;
Steps* m_pSteps;
BGAnimation m_BGAnimation;
NoteField m_NoteFieldEdit;
SnapDisplay m_SnapDisplay;
+16 -9
View File
@@ -246,15 +246,6 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa
// Now that we've read the data from the profile, it's ok to Reset()
GAMESTATE->Reset();
float fSecsUntilBeginFadingOut = m_Background.GetLengthSeconds() - m_Out.GetLengthSeconds();
if( fSecsUntilBeginFadingOut < 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() );
fSecsUntilBeginFadingOut = 0;
}
this->PostScreenMessage( SM_BeginFadingOut, fSecsUntilBeginFadingOut );
}
ScreenEnding::~ScreenEnding()
@@ -263,6 +254,22 @@ ScreenEnding::~ScreenEnding()
void ScreenEnding::Update( float fDeltaTime )
{
// The shared background isn't loaded until the screen is actually
// showing. The background is loaded by the time of the first update.
if( IsFirstUpdate() )
{
BGAnimation &background = *SCREENMAN->m_pSharedBGA;
float fSecsUntilBeginFadingOut = background.GetLengthSeconds() - m_Out.GetLengthSeconds();
if( fSecsUntilBeginFadingOut < 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(), background.GetLengthSeconds() );
fSecsUntilBeginFadingOut = 0;
}
this->PostScreenMessage( SM_BeginFadingOut, fSecsUntilBeginFadingOut );
}
ScreenAttract::Update( fDeltaTime );
if( m_In.IsTransitioning() && m_Out.IsTransitioning() )
-3
View File
@@ -45,9 +45,6 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer( CString sName ) : ScreenWithMenuEl
LOG->Trace( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" );
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenEz2SelectPlayer background") );
this->AddChild( &m_Background ); // animated background =)
FOREACH_PlayerNumber( p )
{
m_sprJoinFrame[p].Load( THEME->GetPathToG("ScreenEz2SelectPlayer join frame 1x2") );
-2
View File
@@ -28,8 +28,6 @@ private:
Sprite m_sprJoinMessage[NUM_PLAYERS];
Sprite m_sprJoinFrame[NUM_PLAYERS];
BGAnimation m_Background;
};
#endif
+47 -27
View File
@@ -29,6 +29,7 @@
#include "RageTextureManager.h"
#include "ThemeManager.h"
#include "ScreenSystemLayer.h"
#include "BGAnimation.h"
ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program
@@ -50,6 +51,7 @@ void ScreenManager::Register( const CString& sClassName, CreateScreenFn pfn )
ScreenManager::ScreenManager()
{
m_pSharedBGA = new BGAnimation;
m_SystemLayer = NULL;
/* By the time this is constructed, THEME has already been set up and set to
@@ -60,7 +62,6 @@ ScreenManager::ScreenManager()
this->ThemeChanged();
m_ScreenBuffered = NULL;
m_MessageSendOnPop = SM_None;
}
@@ -71,7 +72,7 @@ ScreenManager::~ScreenManager()
EmptyDeleteQueue();
// delete current Screens
SAFE_DELETE( m_pSharedBGA );
for( unsigned i=0; i<m_ScreenStack.size(); i++ )
delete m_ScreenStack[i];
delete m_ScreenBuffered;
@@ -139,6 +140,8 @@ void ScreenManager::Update( float fDeltaTime )
*/
ASSERT( !m_ScreenStack.empty() || m_DelayedScreen != "" ); // Why play the game if there is nothing showing?
m_pSharedBGA->Update( fDeltaTime );
if( !m_ScreenStack.empty() )
{
Screen* pScreen = GetTopScreen();
@@ -149,7 +152,7 @@ void ScreenManager::Update( float fDeltaTime )
}
m_SystemLayer->Update( fDeltaTime );
EmptyDeleteQueue();
if(m_DelayedScreen.size() != 0)
@@ -180,13 +183,21 @@ void ScreenManager::Draw()
if( !DISPLAY->BeginFrame() )
return;
m_pSharedBGA->Draw();
if( !m_ScreenStack.empty() && !m_ScreenStack.back()->IsTransparent() ) // top screen isn't transparent
{
m_ScreenStack.back()->Draw();
}
else
{
for( unsigned i=0; i<m_ScreenStack.size(); i++ ) // Draw all screens bottom to top
m_ScreenStack[i]->Draw();
}
m_SystemLayer->Draw();
DISPLAY->EndFrame();
}
@@ -202,7 +213,7 @@ void ScreenManager::Input( const DeviceInput& DeviceI, const InputEventType type
}
Screen* ScreenManager::MakeNewScreen( const CString &sName )
Screen* ScreenManager::MakeNewScreen( const CString &sScreenName )
{
/* By default, RageSounds handles the song timer. When we change screens, reset this;
* screens turn this off in SM_GainFocus if they handle timers themselves (edit).
@@ -214,20 +225,20 @@ Screen* ScreenManager::MakeNewScreen( const CString &sName )
SONGMAN->Cleanup();
RageTimer t;
LOG->Trace( "Loading screen name '%s'", sName.c_str() );
LOG->Trace( "Loading screen name '%s'", sScreenName.c_str() );
CString sClassName = sName;
CString sClassName = sScreenName;
// Look up the class in the metrics group sName
if( THEME->HasMetric(sClassName,"Class") )
sClassName = THEME->GetMetric(sClassName,"Class");
map<CString,CreateScreenFn>::iterator iter = g_pmapRegistrees->find( sClassName );
ASSERT_M( iter != g_pmapRegistrees->end(), ssprintf("Screen '%s' has an invalid class '%s'",sName.c_str(),sClassName.c_str()) )
ASSERT_M( iter != g_pmapRegistrees->end(), ssprintf("Screen '%s' has an invalid class '%s'",sScreenName.c_str(),sClassName.c_str()) )
CreateScreenFn pfn = iter->second;
Screen* ret = pfn( sName );
Screen* ret = pfn( sScreenName );
LOG->Trace( "Loaded '%s' ('%s') in %f", sName.c_str(), sClassName.c_str(), t.GetDeltaTime());
LOG->Trace( "Loaded '%s' ('%s') in %f", sScreenName.c_str(), sClassName.c_str(), t.GetDeltaTime());
/* Loading probably took a little while. Let's reset stats. This prevents us
* from displaying an unnaturally low FPS value, and the next FPS value we
@@ -238,10 +249,10 @@ Screen* ScreenManager::MakeNewScreen( const CString &sName )
return ret;
}
void ScreenManager::PrepNewScreen( const CString &sClassName )
void ScreenManager::PrepNewScreen( const CString &sScreenName )
{
ASSERT(m_ScreenBuffered == NULL);
m_ScreenBuffered = MakeNewScreen(sClassName);
m_ScreenBuffered = MakeNewScreen(sScreenName);
}
void ScreenManager::LoadPreppedScreen()
@@ -255,6 +266,7 @@ void ScreenManager::LoadPreppedScreen()
void ScreenManager::DeletePreppedScreen()
{
SAFE_DELETE( m_ScreenBuffered );
TEXTUREMAN->DeleteCachedTextures();
}
@@ -285,9 +297,9 @@ void ScreenManager::SetFromNewScreen( Screen *pNewScreen, bool Stack )
PostMessageToTopScreen( SM_GainFocus, 0 );
}
void ScreenManager::SetNewScreen( const CString &sClassName )
void ScreenManager::SetNewScreen( const CString &sScreenName )
{
m_DelayedScreen = sClassName;
m_DelayedScreen = sScreenName;
/* If we're not delaying screen loads, load it now. Otherwise, we'll load
* it on the next iteration. Only delay if we already have a screen
@@ -299,7 +311,7 @@ void ScreenManager::SetNewScreen( const CString &sClassName )
void ScreenManager::LoadDelayedScreen()
{
retry:
CString sClassName = m_DelayedScreen;
CString sScreenName = m_DelayedScreen;
m_DelayedScreen = "";
/* If we prepped a screen but didn't use it, nuke it. */
@@ -307,10 +319,13 @@ retry:
Screen* pOldTopScreen = m_ScreenStack.empty() ? NULL : m_ScreenStack.back();
// It makes sense that ScreenManager should allocate memory for a new screen since it
// deletes it later on. This also convention will reduce includes because screens won't
// have to include each other's headers of other screens.
Screen* pNewScreen = MakeNewScreen(sClassName);
Screen* pNewScreen = MakeNewScreen(sScreenName);
if( pOldTopScreen!=NULL && m_ScreenStack.back()!=pOldTopScreen )
{
@@ -333,16 +348,16 @@ retry:
/* If this is a system menu, don't let the operator key touch it!
However, if you add an options screen, please include it here -- Miryokuteki */
if( sClassName == "ScreenOptionsMenu" ||
sClassName == "ScreenMachineOptions" ||
sClassName == "ScreenInputOptions" ||
sClassName == "ScreenGraphicOptions" ||
sClassName == "ScreenGameplayOptions" ||
sClassName == "ScreenMapControllers" ||
sClassName == "ScreenAppearanceOptions" ||
sClassName == "ScreenEdit" ||
sClassName == "ScreenEditMenu" ||
sClassName == "ScreenSoundOptions" )
if( sScreenName == "ScreenOptionsMenu" ||
sScreenName == "ScreenMachineOptions" ||
sScreenName == "ScreenInputOptions" ||
sScreenName == "ScreenGraphicOptions" ||
sScreenName == "ScreenGameplayOptions" ||
sScreenName == "ScreenMapControllers" ||
sScreenName == "ScreenAppearanceOptions" ||
sScreenName == "ScreenEdit" ||
sScreenName == "ScreenEditMenu" ||
sScreenName == "ScreenSoundOptions" )
GAMESTATE->m_bIsOnSystemMenu = true;
else
GAMESTATE->m_bIsOnSystemMenu = false;
@@ -355,14 +370,14 @@ retry:
SetFromNewScreen( pNewScreen, false );
}
void ScreenManager::AddNewScreenToTop( const CString &sClassName, ScreenMessage messageSendOnPop )
void ScreenManager::AddNewScreenToTop( const CString &sScreenName, ScreenMessage messageSendOnPop )
{
/* Send this before making the new screen, since it might set things that will be re-set
* in the new screen's ctor. */
if( m_ScreenStack.size() )
m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus );
Screen* pNewScreen = MakeNewScreen(sClassName);
Screen* pNewScreen = MakeNewScreen(sScreenName);
SetFromNewScreen( pNewScreen, true );
m_MessageSendOnPop = messageSendOnPop;
}
@@ -512,6 +527,11 @@ void ScreenManager::PlayBackSound()
m_soundBack.Play( &p );
}
void ScreenManager::PlaySharedBackgroundOffCommand()
{
m_pSharedBGA->PlayCommand("Off");
}
/*
* (c) 2001-2003 Chris Danford, Glenn Maynard
* All rights reserved.
+8
View File
@@ -15,6 +15,7 @@
class Screen;
struct Menu;
class ScreenSystemLayer;
class BGAnimation;
typedef Screen* (*CreateScreenFn)(const CString&);
@@ -37,6 +38,7 @@ public:
void PrepNewScreen( const CString &sName );
void LoadPreppedScreen();
void DeletePreppedScreen();
void SetNewScreen( const CString &sName );
void AddNewScreenToTop( const CString &sName, ScreenMessage messageSendOnPop );
void Prompt( ScreenMessage SM_SendWhenDone, const CString &sText, bool bYesNo = false, bool bDefaultAnswer = false, void(*OnYes)(void*) = NULL, void(*OnNo)(void*) = NULL, void* pCallbackData = NULL );
@@ -59,6 +61,12 @@ public:
Screen *GetTopScreen();
public:
//
// in draw order first to last
//
BGAnimation *m_pSharedBGA; // BGA object that's persistent between screens
void PlaySharedBackgroundOffCommand();
private:
vector<Screen*> m_ScreenStack; // bottommost to topmost
ScreenMessage m_MessageSendOnPop;
-3
View File
@@ -157,9 +157,6 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName )
GAMESTATE->m_bPastHereWeGo = true; // enable the gray arrows
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenNameEntry background") );
this->AddChild( &m_Background );
FOREACH_PlayerNumber( p )
{
// load last used ranking name if any
-2
View File
@@ -29,8 +29,6 @@ public:
private:
bool AnyStillEntering() const;
BGAnimation m_Background;
ReceptorArrowRow m_ReceptorArrowRow[NUM_PLAYERS];
BitmapText m_textSelectedChars[NUM_PLAYERS][ABS_MAX_RANKING_NAME_LENGTH];
BitmapText m_textScrollingChars[NUM_PLAYERS][ABS_MAX_RANKING_NAME_LENGTH];
@@ -60,8 +60,6 @@ private:
void ChangeDisplayedFeat();
void SelectChar( PlayerNumber pn, int c );
BGAnimation m_Background;
ActorFrame m_Keyboard[NUM_PLAYERS];
Sprite m_sprCursor[NUM_PLAYERS];
vector<BitmapText*> m_textAlphabet[NUM_PLAYERS];
+7 -9
View File
@@ -31,11 +31,6 @@ ScreenStage::ScreenStage( CString sClassName ) : Screen( sClassName )
LIGHTSMAN->SetLightsMode( LIGHTSMODE_STAGE );
m_Background.LoadFromAniDir( THEME->GetPathToB(m_sName + " "+GAMESTATE->GetStageText()) );
m_Background.SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING );
this->AddChild( &m_Background );
m_Overlay.SetName( "Overlay" );
m_Overlay.LoadFromAniDir( THEME->GetPathToB(m_sName + " overlay"));
ON_COMMAND( m_Overlay );
@@ -54,9 +49,6 @@ ScreenStage::ScreenStage( CString sClassName ) : Screen( sClassName )
m_Back.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
this->AddChild( &m_Back );
/* Prep the new screen once m_In is complete. */
this->PostScreenMessage( SM_PrepScreen, m_Background.GetLengthSeconds() );
FOREACH_PlayerNumber(p)
{
Character* pChar = GAMESTATE->m_pCurCharacters[p];
@@ -123,7 +115,8 @@ void ScreenStage::HandleScreenMessage( const ScreenMessage SM )
OFF_COMMAND( m_SongTitle );
OFF_COMMAND( m_Artist );
OFF_COMMAND( m_Banner );
OFF_COMMAND( m_Background );
SCREENMAN->PlaySharedBackgroundOffCommand();
this->PostScreenMessage( SM_GoToNextScreen, this->GetTweenTimeLeft() );
@@ -140,6 +133,11 @@ void ScreenStage::HandleScreenMessage( const ScreenMessage SM )
void ScreenStage::Update( float fDeltaTime )
{
// The shared BGA isn't loaded until after the screen is showing. It is ready
// to access by the time of the first update.
if( IsFirstUpdate() )
this->PostScreenMessage( SM_PrepScreen, SCREENMAN->m_pSharedBGA->GetLengthSeconds() );
if( m_bZeroDeltaOnNextUpdate )
{
m_bZeroDeltaOnNextUpdate = false;
-1
View File
@@ -21,7 +21,6 @@ public:
private:
Transition m_In, m_Out, m_Back;
BGAnimation m_Background;
BGAnimation m_Overlay; // overlays all elements except bitmaptexts
Banner m_Banner;
BitmapText m_SongTitle;
-3
View File
@@ -39,9 +39,6 @@ ScreenStyleSplash::ScreenStyleSplash( CString sName ) : ScreenWithMenuElements(
iDifficulty = GAMESTATE->m_PreferredDifficulty[PLAYER_2];
}
m_Background.LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenStyleSplash-%s-%s-%d",sGameName.c_str(),sStyleName.c_str(),iDifficulty) ) );
this->AddChild( &m_Background );
this->PostScreenMessage( SM_StartClosing, 2 );
}
-2
View File
@@ -18,8 +18,6 @@ public:
protected:
void MenuStart( PlayerNumber pn );
void MenuBack( PlayerNumber pn );
BGAnimation m_Background;
};
#endif
+1 -4
View File
@@ -29,9 +29,6 @@ ScreenWithMenuElements::ScreenWithMenuElements( CString sClassName ) : Screen( s
this->SetName( sClassName );
m_Background.LoadFromAniDir( THEME->GetPathToB(m_sName+" background") );
this->AddChild( &m_Background );
m_autoHeader.Load( THEME->GetPathToG(m_sName+" header") );
m_autoHeader->SetName("Header");
UtilSetXY( m_autoHeader, m_sName );
@@ -140,7 +137,7 @@ void ScreenWithMenuElements::StartTransitioning( ScreenMessage smSendWhenDone )
UtilOffCommand( m_autoFooter, m_sName );
UtilOffCommand( m_textHelp, m_sName );
m_Background.PlayCommand("Off");
SCREENMAN->PlaySharedBackgroundOffCommand();
m_Out.StartTransitioning(smSendWhenDone);
-2
View File
@@ -27,8 +27,6 @@ public:
void ResetTimer();
protected:
BGAnimation m_Background;
AutoActor m_autoHeader;
Sprite m_sprStyleIcon;
MemoryCardDisplay m_MemoryCardDisplay[NUM_PLAYERS];