From 353fd47f85f3b336c2d5bfdf1e25f7b58176d06d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 10 Mar 2002 10:30:45 +0000 Subject: [PATCH] final 1.64 checkin --- stepmania/src/MusicWheel.h | 8 +-- stepmania/src/Player.cpp | 11 +++- stepmania/src/Player.h | 2 +- stepmania/src/PrefsManager.cpp | 8 +-- stepmania/src/RandomSample.cpp | 112 +++++++++++++++++++++++++++++++++ stepmania/src/RandomSample.h | 57 +++++++++++++++++ stepmania/src/StepMania.cpp | 26 ++++---- stepmania/src/StepMania.dsp | 24 ++++--- stepmania/src/Transition.h | 4 +- 9 files changed, 220 insertions(+), 32 deletions(-) create mode 100644 stepmania/src/RandomSample.cpp create mode 100644 stepmania/src/RandomSample.h diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index 77ae2c293d..4c6727358a 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -19,7 +19,7 @@ #include "BitmapText.h" #include "Rectangle.h" #include "TextBanner.h" -#include "SoundSet.h" +#include "RandomSample.h" #include "GradeDisplay.h" #include "RageSoundStream.h" #include "GameTypes.h" @@ -147,9 +147,9 @@ protected: // having sounds here causes a crash in Bass. What the heck!?!?! - SoundSet m_soundChangeMusic; - SoundSet m_soundChangeSort; - SoundSet m_soundExpand; + RandomSample m_soundChangeMusic; + RandomSample m_soundChangeSort; + RandomSample m_soundExpand; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index d8d888b22d..be2eb62374 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -249,7 +249,16 @@ void Player::RenderPrimitives() bool Player::IsThereANoteAtIndex( int iIndex ) { - return m_TapStepsOriginal[iIndex] != STEP_NONE; + if( m_TapStepsOriginal[iIndex] != STEP_NONE ) + return true; + + for( int i=0; iLoad( sSoundFilePath ); + + + m_pSamples.Add( pSS ); + + RageLog( "Made it here - C" ); + + return true; +} + +void RandomSample::PlayRandom() +{ + // play one of the samples + if( m_pSamples.GetSize() == 0 ) + { + RageLog( "WARNING: Tried to play a RandomSample that has 0 sounds loaded." ); + } + else + { + int iIndexToPlay = rand() % m_pSamples.GetSize(); + m_pSamples[iIndexToPlay]->Play(); + m_iIndexLastPlayed = iIndexToPlay; + } +} + +void RandomSample::Pause() +{ + m_pSamples[m_iIndexLastPlayed]->Pause(); +} + +void RandomSample::Stop() +{ + if( m_iIndexLastPlayed == -1 ) // nothing is currently playing + return; + + m_pSamples[m_iIndexLastPlayed]->Stop(); +} diff --git a/stepmania/src/RandomSample.h b/stepmania/src/RandomSample.h new file mode 100644 index 0000000000..52d0b123cf --- /dev/null +++ b/stepmania/src/RandomSample.h @@ -0,0 +1,57 @@ +/* +----------------------------------------------------------------------------- + File: RandomSample.h + + Desc: Holds multiple sounds samples and can play a random sound easily. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#ifndef _RandomSample_H_ +#define _RandomSample_H_ + + +#include "RageSound.h" +#include "RageSoundSample.h" +#include "RageUtil.h" + +class RandomSample +{ +public: + RandomSample(); + ~RandomSample(); + + virtual bool Load( CString sFilePath ) + { + CString sDir, sFName, sExt; + splitrelpath( sFilePath, sDir, sFName, sExt ); + + sExt.MakeLower(); + + if( sExt == "" ) + return LoadSoundDir( sFilePath ); + else if( sExt == "set" ) + return LoadRandomSample( sFilePath ); + else + return LoadSound( sFilePath ); + }; + + void PlayRandom(); + void Pause(); + void Stop(); + +private: + bool LoadSoundDir( CString sDir ); + bool LoadRandomSample( CString sSetFilePath ); + bool LoadSound( CString sSoundFilePath ); + + + CArray m_pSamples; + int m_iIndexLastPlayed; +}; + + + + +#endif \ No newline at end of file diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index c05af2c327..301d42e56c 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -485,11 +485,6 @@ HRESULT CreateObjects( HWND hWnd ) // switch the screen resolution according to user's prefs SwitchDisplayMode(); -// go.m_bWindowed, -// go.m_iResolution, -// go.m_iResolution==640 ? 480 : 240, -// go.m_iDisplayColor -// ); TM = new RageTextureManager( SCREEN ); THEME = new ThemeManager; @@ -498,11 +493,6 @@ HRESULT CreateObjects( HWND hWnd ) // Ugly... Switch the screen resolution again so that the system message will display SwitchDisplayMode(); -// go.m_bWindowed, -// go.m_iResolution, -// go.m_iResolution==640 ? 480 : 240, -// go.m_iDisplayColor -// ); WM->SystemMessage( ssprintf("Found %d songs.", SONGS->m_pSongs.GetSize()) ); @@ -717,7 +707,19 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD GameOptions &go = PREFS->m_GameOptions; bool bWindowed = go.m_bWindowed; DWORD dwWidth = go.m_iResolution; - DWORD dwHeight = go.m_iResolution==640 ? 480 : 240; + DWORD dwHeight; + // fill in dwHeight + switch( dwWidth ) + { + case 320: dwHeight = 240; break; + case 400: dwHeight = 300; break; + case 512: dwHeight = 384; break; + case 640: dwHeight = 480; break; + case 800: dwHeight = 600; break; + case 1024: dwHeight = 768; break; + case 1280: dwHeight = 1024; break; + default: dwHeight = 480; break; + } DWORD dwBPP = go.m_iDisplayColor; @@ -738,7 +740,7 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwHeight = 480; if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) { - // Failed again. Try 640x480 + // Failed again. Try 320x240 dwWidth = 320; dwHeight = 240; if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 992282c9db..ee30566d05 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -424,6 +424,22 @@ SOURCE=.\PrefsManager.h # End Source File # Begin Source File +SOURCE=.\RandomSample.cpp +# End Source File +# Begin Source File + +SOURCE=.\RandomSample.h +# End Source File +# Begin Source File + +SOURCE=.\RandomStream.cpp +# End Source File +# Begin Source File + +SOURCE=.\RandomStream.h +# End Source File +# Begin Source File + SOURCE=.\Song.cpp # End Source File # Begin Source File @@ -440,14 +456,6 @@ SOURCE=.\SongManager.h # End Source File # Begin Source File -SOURCE=.\SoundSet.cpp -# End Source File -# Begin Source File - -SOURCE=.\SoundSet.h -# End Source File -# Begin Source File - SOURCE=.\Steps.cpp # End Source File # Begin Source File diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index dace317322..5068a7886e 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -17,10 +17,10 @@ #include "Window.h" #include "WindowManager.h" #include "Actor.h" -#include "SoundSet.h" +#include "RandomSample.h" -const float DEFAULT_TRANSITION_TIME = 0.75f; +const float DEFAULT_TRANSITION_TIME = 0.40f; class Transition : public Actor