diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 22fd42a69a..5c4fe3f635 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -21,6 +21,7 @@ const CString BG_ANIMS_DIR = "BGAnimations\\"; const CString VISUALIZATIONS_DIR = "Visualizations\\"; +const CString RANDOMMOVIES_DIR = "RandomMovies\\"; int CompareAnimSegs(const void *arg1, const void *arg2) @@ -65,6 +66,9 @@ Background::Background() m_quadBGBrightness.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) ); m_quadBGBrightness.SetDiffuseColor( D3DXCOLOR(0,0,0,1-0.5f) ); + + m_pCurBGA = NULL; + m_iCurAnimSegment = -1; } Background::~Background() @@ -90,6 +94,8 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations ) m_BackgroundMode = MODE_MOVIE_BG; else if( PREFSMAN->m_BackgroundMode == PrefsManager::BGMODE_MOVIEVIS ) m_BackgroundMode = MODE_MOVIE_VIS; + else if( PREFSMAN->m_BackgroundMode == PrefsManager::BGMODE_RANDOMMOVIES ) + m_BackgroundMode = MODE_RANDOMMOVIES; else m_BackgroundMode = MODE_ANIMATIONS; @@ -197,6 +203,33 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations ) } } break; + case MODE_RANDOMMOVIES: + { + CStringArray asMovieNames; + GetDirListing( RANDOMMOVIES_DIR + "*.avi", asMovieNames ); + GetDirListing( RANDOMMOVIES_DIR + "*.mpg", asMovieNames ); + GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", asMovieNames ); + for( int i=0; im_fLastBeat; i+=16 ) + m_aAnimSegs.Add( AnimSeg((float)i,rand()%m_BackgroundAnimations.GetSize()) ); // change BG every 4 bars + + for( i=0; im_BPMSegments.GetSize(); i++ ) + { + const BPMSegment& bpmseg = pSong->m_BPMSegments[i]; + m_aAnimSegs.Add( AnimSeg(bpmseg.m_fStartBeat,int(bpmseg.m_fBPM)%m_BackgroundAnimations.GetSize()) ); // change BG every BPM change + } + SortAnimSegArray( m_aAnimSegs ); + } + break; default: ASSERT(0); } @@ -234,8 +267,33 @@ void Background::Update( float fDeltaTime ) m_sprMovieVis.Update( fDeltaTime ); break; case MODE_ANIMATIONS: - if( GetCurBGA() ) - GetCurBGA()->Update( fDeltaTime, m_fSongBeat ); + case MODE_RANDOMMOVIES: + { + // Find the AnimSeg we're in + for( int i=0; i m_fSongBeat ) + break; + int iNewAnimationSegment = i; + if( iNewAnimationSegment > m_iCurAnimSegment ) + { + m_iCurAnimSegment = iNewAnimationSegment; + if( m_pCurBGA ) + m_pCurBGA->LosingFocus(); + if( i > m_aAnimSegs.GetSize() ) + { + m_pCurBGA = NULL; + } + else + { + int iNewAnimIndex = m_aAnimSegs[i].m_iAnimationIndex; + m_pCurBGA = m_BackgroundAnimations[iNewAnimIndex]; + m_pCurBGA->GainingFocus(); + } + } + + if( m_pCurBGA ) + m_pCurBGA->Update( fDeltaTime, m_fSongBeat ); + } break; default: ASSERT(0); @@ -258,7 +316,6 @@ void Background::DrawPrimitives() { ActorFrame::DrawPrimitives(); - if( DangerVisible() ) { m_sprDangerBackground.Draw(); @@ -273,19 +330,26 @@ void Background::DrawPrimitives() m_sprSongBackground.Draw(); break; case MODE_MOVIE_BG: - ::Sleep(4); // let the movie decode a frame + ::Sleep(2); // let the movie decode a frame m_sprMovieBackground.Draw(); break; case MODE_MOVIE_VIS: m_sprSongBackground.Draw(); - ::Sleep(4); // let the movie decode a frame + ::Sleep(2); // let the movie decode a frame m_sprMovieVis.Draw(); break; case MODE_ANIMATIONS: - if( GetCurBGA() ) - GetCurBGA()->Draw(); + case MODE_RANDOMMOVIES: + if( m_pCurBGA ) + { + if( m_pCurBGA->IsAMovie() ) + ::Sleep(2); // let the movie decode a frame + m_pCurBGA->Draw(); + } else + { m_sprSongBackground.Draw(); + } break; default: ASSERT(0); diff --git a/stepmania/src/Background.h b/stepmania/src/Background.h index 53d6c4aac6..3b648477af 100644 --- a/stepmania/src/Background.h +++ b/stepmania/src/Background.h @@ -55,7 +55,7 @@ protected: Song* m_pSong; - enum BackgroundMode { MODE_STATIC_BG, MODE_MOVIE_BG, MODE_ANIMATIONS, MODE_MOVIE_VIS }; + enum BackgroundMode { MODE_STATIC_BG, MODE_MOVIE_BG, MODE_ANIMATIONS, MODE_MOVIE_VIS, MODE_RANDOMMOVIES }; BackgroundMode m_BackgroundMode; Sprite m_sprSongBackground; @@ -69,20 +69,8 @@ protected: // for animations CArray m_BackgroundAnimations; CArray m_aAnimSegs; - BackgroundAnimation* GetCurBGA() - { - if( m_aAnimSegs.GetSize() == 0 ) - return NULL; - - if( m_fSongBeat < m_pSong->m_fFirstBeat || m_fSongBeat > m_pSong->m_fLastBeat ) - return NULL; - - for( int i=0; i m_fSongBeat ) - break; - int iIndex = m_aAnimSegs[i].m_iAnimationIndex; - return m_BackgroundAnimations[iIndex]; - }; + BackgroundAnimation* m_pCurBGA; + int m_iCurAnimSegment; // this increases as we move into new segments // for movie vis diff --git a/stepmania/src/InputQueue.cpp b/stepmania/src/InputQueue.cpp index d7696a9cbb..5e41eb5d15 100644 --- a/stepmania/src/InputQueue.cpp +++ b/stepmania/src/InputQueue.cpp @@ -15,6 +15,7 @@ #include "GameManager.h" #include "RageException.h" #include "RageTimer.h" +#include "InputMapper.h" InputQueue* INPUTQUEUE = NULL; // global and accessable from anywhere in our program @@ -34,6 +35,35 @@ void InputQueue::RememberInput( const GameInput GameI ) m_aQueue[c].Add( GameButtonAndTime(GameI.button,TIMER->GetTimeSinceStart()) ); }; +bool InputQueue::MatchesPattern( const GameController c, const MenuButton* button_sequence, const int iNumButtons, float fMaxSecondsBack ) +{ + if( fMaxSecondsBack == -1 ) + fMaxSecondsBack = 0.4f + iNumButtons*0.15f; + + float fOldestTimeAllowed = TIMER->GetTimeSinceStart() - fMaxSecondsBack; + + int sequence_index = iNumButtons-1; // count down + for( int queue_index=m_aQueue[c].GetSize()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest + { + GameButtonAndTime BandT = m_aQueue[c][queue_index]; + GameInput GameI( c, BandT.button ); + MenuInput MenuI; + INPUTMAPPER->GameToMenu( GameI, MenuI ); + if( MenuI.button != button_sequence[sequence_index] || + BandT.fTime < fOldestTimeAllowed ) + { + return false; + } + if( sequence_index == 0 ) // we matched the whole pattern + { + m_aQueue[c].RemoveAll(); // empty the queue so we don't match on it again + return true; + } + sequence_index--; + } + return false; +} + bool InputQueue::MatchesPattern( const GameController c, const GameButton* button_sequence, const int iNumButtons, float fMaxSecondsBack ) { if( fMaxSecondsBack == -1 ) diff --git a/stepmania/src/InputQueue.h b/stepmania/src/InputQueue.h index 27d6c8ec62..f57df126b6 100644 --- a/stepmania/src/InputQueue.h +++ b/stepmania/src/InputQueue.h @@ -12,6 +12,7 @@ #include "GameConstantsAndTypes.h" #include "GameInput.h" +#include "MenuInput.h" const int MAX_INPUT_QUEUE_LENGTH = 8; @@ -22,7 +23,7 @@ public: void RememberInput( GameInput ); bool MatchesPattern( const GameController c, const GameButton* button_sequence, const int iNumButtons, float fMaxSecondsBack = -1 ); - + bool MatchesPattern( const GameController c, const MenuButton* button_sequence, const int iNumButtons, float fMaxSecondsBack = -1 ); protected: struct GameButtonAndTime diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index a7e54881db..5544405b36 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -842,7 +842,7 @@ void MusicWheel::Update( float fDeltaTime ) { if ( m_bUseRandomExtra ) { - MUSIC->Stop; + MUSIC->Stop(); m_soundExpand.Play(); m_WheelState = STATE_ROULETTE_SPINNING; m_SortOrder = SORT_GROUP; diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 8a4ff0640c..5e3daae6f8 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -24,7 +24,7 @@ public: PrefsManager(); ~PrefsManager(); - enum BackgroundMode { BGMODE_OFF, BGMODE_ANIMATIONS, BGMODE_MOVIEVIS }; + enum BackgroundMode { BGMODE_OFF, BGMODE_ANIMATIONS, BGMODE_MOVIEVIS, BGMODE_RANDOMMOVIES }; // GameOptions (ARE saved between sessions) bool m_bWindowed; diff --git a/stepmania/src/RageBitmapTexture.h b/stepmania/src/RageBitmapTexture.h index ac79597ed1..51d7cd7695 100644 --- a/stepmania/src/RageBitmapTexture.h +++ b/stepmania/src/RageBitmapTexture.h @@ -43,6 +43,8 @@ public: ); virtual LPDIRECT3DTEXTURE8 GetD3DTexture(); + virtual bool IsAMovie() { return true; }; + protected: virtual void Create( diff --git a/stepmania/src/RageMovieTexture.h b/stepmania/src/RageMovieTexture.h index 58d66bc45b..eeefcbba9a 100644 --- a/stepmania/src/RageMovieTexture.h +++ b/stepmania/src/RageMovieTexture.h @@ -99,6 +99,7 @@ public: virtual void Play(); virtual void SetPosition( float fSeconds ); virtual void Pause(); + virtual bool IsAMovie() { return true; }; LPDIRECT3DTEXTURE8 m_pd3dTexture[2]; // double buffered int m_iIndexActiveTexture; // either 0 or 1 diff --git a/stepmania/src/RageTexture.h b/stepmania/src/RageTexture.h index 23ab42e16b..b7bfaa6576 100644 --- a/stepmania/src/RageTexture.h +++ b/stepmania/src/RageTexture.h @@ -63,6 +63,7 @@ public: virtual void Play() {}; virtual void SetPosition( float fSeconds ) {}; virtual void Pause() {}; + virtual bool IsAMovie() = 0; int GetSourceWidth() {return m_iSourceWidth;}; int GetSourceHeight() {return m_iSourceHeight;}; diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index e2762ddcf7..8c1de27326 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - File: ScreenOptions.h + Class: ScreenOptions - Desc: Select a song. + Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ @@ -23,16 +24,15 @@ - -const float HEADER_X = CENTER_X; -const float HEADER_Y = 50; -const float HELP_X = CENTER_X; -const float HELP_Y = SCREEN_HEIGHT-35; -const float ITEM_GAP_X = 12; -const float LABELS_X = 80; -const float LINE_START_Y= 80; -const float LINE_GAP_Y = 34; - +const float HEADER_X = CENTER_X; +const float HEADER_Y = 50; +const float HELP_X = CENTER_X; +const float HELP_Y = SCREEN_HEIGHT-35; +const float ITEM_GAP_X = 14; +const float LABELS_X = 80; +const float LINE_START_Y = 80; +const float LINE_GAP_Y = 34; +const float ITEMS_START_X = 160; const ScreenMessage SM_PlaySample = ScreenMessage(SM_User-4); const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User-5); @@ -152,7 +152,7 @@ void ScreenOptions::InitOptionsText() this->AddSubActor( &title ); // init all text in this line and count the width of the line - float fX = 150; // indent 70 pixels + float fX = ITEMS_START_X; // indent 70 pixels for( int j=0; jGetPathTo(FONT_NORMAL) ); option.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); option.SetText( optline.szOptionsText[j] ); - option.SetZoom( 0.65f ); + option.SetZoom( 0.5f ); option.SetShadowLength( 2 ); this->AddSubActor( &option ); diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index cf7a122c92..c635f47ba8 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -65,7 +65,7 @@ const float DIFFICULTY_ARROW_X[NUM_DIFFICULTY_ITEMS][NUM_PLAYERS] = { const float ARROW_SHADOW_OFFSET = 10; -const float LOCK_INPUT_TIME = 0.75f; // lock input while waiting for tweening to complete +const float LOCK_INPUT_TIME = 0.50f; // lock input while waiting for tweening to complete const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User + 1);