From 07410e1c5a56ab3000604794443c2e7a56ef5999 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 24 Jun 2002 22:20:51 +0000 Subject: [PATCH] no message --- stepmania/src/Background.cpp | 129 ++++++++++++++++++++++++++--------- stepmania/src/Background.h | 26 ++++--- 2 files changed, 112 insertions(+), 43 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 44cec63872..8b3b97cfea 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -22,6 +22,8 @@ const CString VIS_DIR = "Visualizations\\"; Background::Background() { + m_fSongBeat = 0; + m_bShowDanger = false; m_sprDanger.SetZoom( 2 ); @@ -31,51 +33,57 @@ Background::Background() m_sprDangerBackground.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_DANGER_BACKGROUND) ); m_sprDangerBackground.StretchTo( CRect((int)SCREEN_LEFT, (int)SCREEN_TOP, (int)SCREEN_RIGHT, (int)SCREEN_BOTTOM) ); + + // Load background animations + for( int i=0; iHasBackgroundMovie() ) { - // load the movie backgound, and don't load a visualization m_sprSongBackground.Load( pSong->GetBackgroundMoviePath() ); - m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); - m_sprSongBackground.SetZoomY( -1 ); - m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); - this->AddActor( &m_sprSongBackground ); + m_sprSongBackground.SetZoomY( -1 ); // flip + } + else if( pSong->HasBackground() ) + { + m_sprSongBackground.Load( pSong->GetBackgroundPath(), false, 2, 0, true ); } else { - // load the static background (if available), and a visualization - if( pSong->HasBackground() ) m_sprSongBackground.Load( pSong->GetBackgroundPath(), false, 2, 0, true ); - else m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), false, 2, 0, true ); - - m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); - m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); - this->AddActor( &m_sprSongBackground ); + m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), false, 2, 0, true ); + } + + m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); + m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); - if( PREFSMAN->m_bUseRandomVis && !bDisableVisualizations ) + if( PREFSMAN->m_visMode == VIS_MODE_MOVIE && !bDisableVisualizations ) + { + // load a random visualization + CStringArray sVisualizationNames; + GetDirListing( VIS_DIR + "*.avi", sVisualizationNames ); + GetDirListing( VIS_DIR + "*.mpg", sVisualizationNames ); + GetDirListing( VIS_DIR + "*.mpeg", sVisualizationNames ); + if( sVisualizationNames.GetSize() > 0 ) // there is at least one visualization { - // load a random visualization - CStringArray sVisualizationPaths; - GetDirListing( VIS_DIR + "*.avi", sVisualizationPaths ); - GetDirListing( VIS_DIR + "*.mpg", sVisualizationPaths ); - GetDirListing( VIS_DIR + "*.mpeg", sVisualizationPaths ); - if( sVisualizationPaths.GetSize() > 0 ) // there is at least one visualization - { - int iIndexRandom = rand() % sVisualizationPaths.GetSize(); + int iIndexRandom = rand() % sVisualizationNames.GetSize(); - m_sprVisualizationOverlay.Load( VIS_DIR + sVisualizationPaths[iIndexRandom] ); - - - m_sprVisualizationOverlay.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); - m_sprVisualizationOverlay.SetZoomY( m_sprVisualizationOverlay.GetZoomY()*-1 ); - m_sprVisualizationOverlay.SetBlendModeAdd(); - m_sprVisualizationOverlay.SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); - this->AddActor( &m_sprVisualizationOverlay ); - } - } + m_sprVisualizationOverlay.Load( VIS_DIR + sVisualizationNames[iIndexRandom] ); + m_sprVisualizationOverlay.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); + m_sprVisualizationOverlay.SetZoomY( m_sprVisualizationOverlay.GetZoomY()*-1 ); + m_sprVisualizationOverlay.SetBlendModeAdd(); + m_sprVisualizationOverlay.SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); + this->AddActor( &m_sprVisualizationOverlay ); + } } return true; @@ -85,6 +93,40 @@ void Background::Update( float fDeltaTime ) { ActorFrame::Update( fDeltaTime ); + if( m_fSongBeat < 8 ) + m_pCurBackgroundAnimation = NULL; + else + { + int iIndexToSwitchTo = int(m_fSongBeat/BEATS_PER_MEASURE/2) % m_BackgroundAnimations.GetSize(); + m_pCurBackgroundAnimation = m_BackgroundAnimations[ iIndexToSwitchTo ]; + } + + + if( DangerVisible() ) + { + m_sprDangerBackground.Update( fDeltaTime ); + m_sprDanger.Update( fDeltaTime ); + } + else + { + switch( PREFSMAN->m_visMode ) + { + case VIS_MODE_ANIMATION: + if( m_pCurBackgroundAnimation ) + m_pCurBackgroundAnimation->Update( fDeltaTime, m_fSongBeat ); + else + m_sprSongBackground.Update( fDeltaTime ); + break; + + case VIS_MODE_MOVIE: + m_sprVisualizationOverlay.Update( fDeltaTime ); + // fall through and draw background + + case VIS_MODE_NONE: + m_sprSongBackground.Update( fDeltaTime ); + break; + } + } m_sprVisualizationOverlay.Update( fDeltaTime ); m_sprSongBackground.Update( fDeltaTime ); m_sprDanger.Update( fDeltaTime ); @@ -95,17 +137,36 @@ void Background::DrawPrimitives() { ActorFrame::DrawPrimitives(); - if( m_bShowDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) > 0.5f ) + if( DangerVisible() ) { m_sprDangerBackground.Draw(); m_sprDanger.Draw(); } else { + switch( PREFSMAN->m_visMode ) + { + case VIS_MODE_ANIMATION: + if( m_pCurBackgroundAnimation ) + m_pCurBackgroundAnimation->DrawPrimitives(); + else + m_sprSongBackground.Draw(); + break; + + case VIS_MODE_MOVIE: + m_sprVisualizationOverlay.Draw(); + // fall through and draw background + + case VIS_MODE_NONE: + m_sprSongBackground.Draw(); + break; + } m_sprSongBackground.Draw(); m_sprVisualizationOverlay.Draw(); } } - - +bool Background::DangerVisible() +{ + return m_bShowDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) > 0.5f; +} diff --git a/stepmania/src/Background.h b/stepmania/src/Background.h index 184d61c20f..ea2fc58b4c 100644 --- a/stepmania/src/Background.h +++ b/stepmania/src/Background.h @@ -1,20 +1,22 @@ +#pragma once /* ----------------------------------------------------------------------------- - File: Background.h + Class: Background - Desc: Background behind arrows while dancing + Desc: Background behind notes while playing. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Ben Nordstrom + Chris Danford ----------------------------------------------------------------------------- */ -#ifndef _Background_H_ -#define _Background_H_ - #include "Sprite.h" #include "ActorFrame.h" #include "Song.h" +#include "BackgroundAnimation.h" + class Background : public ActorFrame @@ -27,8 +29,11 @@ public: virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); + void SetSongBeat( const float fSongBeat ) { m_fSongBeat = fSongBeat; }; + virtual void SetDiffuseColor( D3DXCOLOR c ) { + m_sprSongBackground.SetDiffuseColor( c ); m_sprVisualizationOverlay.SetDiffuseColor( c ); m_sprSongBackground.SetDiffuseColor( c ); m_sprDanger.SetDiffuseColor( c ); @@ -41,6 +46,11 @@ public: virtual bool IsDangerOn() { return m_bShowDanger; }; protected: + bool DangerVisible(); + + CArray m_BackgroundAnimations; + BackgroundAnimation* m_pCurBackgroundAnimation; + Sprite m_sprVisualizationOverlay; Sprite m_sprSongBackground; @@ -48,9 +58,7 @@ protected: Sprite m_sprDangerBackground; bool m_bShowDanger; + + float m_fSongBeat; }; - - - -#endif \ No newline at end of file