diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index c561eb6b40..a400132b8a 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -113,7 +113,7 @@ void Actor::Update( const float &fDeltaTime ) m_bTweeningTowardEndColor = TRUE; } } - RageLog( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors ); + //RageLog( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors ); break; case wagging: m_fWagTimer += fDeltaTime; diff --git a/stepmania/src/Background.h b/stepmania/src/Background.h index c4e634adbf..e147841a50 100644 --- a/stepmania/src/Background.h +++ b/stepmania/src/Background.h @@ -22,7 +22,7 @@ class Background : public Sprite public: void LoadFromSong( Song& song ); - void Update( const FLOAT& fDeltaTime); + void Update( float fDeltaTime); void Draw(); Sprite m_sprVis; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 200140ebf1..5ec9199764 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -239,7 +239,7 @@ void Player::SetSteps( const Steps& newSteps, bool bLoadOnlyLeftSide, bool bLoad } -void Player::Update( const float &fDeltaTime, float fSongBeat, float fMaxBeatDifference ) +void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference ) { //RageLog( "Player::Update(%f, %f, %f)", fDeltaTime, fSongBeat, fMaxBeatDifference ); @@ -439,14 +439,14 @@ float Player::GetArrowColumnX( int iColNum ) return m_fArrowsCenterX + fColOffsetFromCenter * ARROW_SIZE; } -void Player::UpdateGrayArrows( const float &fDeltaTime ) +void Player::UpdateGrayArrows( float fDeltaTime ) { for( int i=0; i < m_iNumColumns; i++ ) { m_GrayArrow[i].Update( fDeltaTime ); } } -void Player::UpdateGhostArrows( const float &fDeltaTime ) +void Player::UpdateGhostArrows( float fDeltaTime ) { for( int i=0; i < m_iNumColumns; i++ ) { m_GhostArrow[i].Update( fDeltaTime ); @@ -499,7 +499,7 @@ void Player::GhostArrowStep( int index, StepScore score ) m_GhostArrow[index].Step( score ); } -void Player::UpdateColorArrows( const float &fDeltaTime ) +void Player::UpdateColorArrows( float fDeltaTime ) { int iIndexFirstArrowToDraw = BeatToStepIndex( m_fSongBeat - 2.0f ); // 2 beats earlier if( iIndexFirstArrowToDraw < 0 ) iIndexFirstArrowToDraw = 0; @@ -568,7 +568,7 @@ void Player::SetJudgementX( int iNewX ) m_sprJudgement.SetXY( iNewX, JUDGEMENT_Y ); } -void Player::UpdateJudgement( const float &fDeltaTime ) +void Player::UpdateJudgement( float fDeltaTime ) { if( m_fJudgementDisplayCountdown > 0.0 ) m_fJudgementDisplayCountdown -= fDeltaTime; @@ -615,7 +615,7 @@ void Player::SetComboX( int iNewX ) m_ComboNumber.SetXY( iNewX-50, COMBO_Y ); } -void Player::UpdateCombo( const float &fDeltaTime ) +void Player::UpdateCombo( float fDeltaTime ) { m_sprCombo.Update( fDeltaTime ); m_ComboNumber.Update( fDeltaTime ); @@ -663,7 +663,7 @@ void Player::SetLifeMeterX( int iNewX ) m_sprLifeMeterPills.SetXY( iNewX, LIFEMETER_PILLS_Y ); } -void Player::UpdateLifeMeter( const float &fDeltaTime ) +void Player::UpdateLifeMeter( float fDeltaTime ) { m_sprLifeMeterFrame.Update( fDeltaTime ); m_sprLifeMeterPills.Update( fDeltaTime ); @@ -728,7 +728,7 @@ void Player::SetScoreX( int iNewX ) m_ScoreNumber.SetXY( iNewX, SCORE_Y ); } -void Player::UpdateScore( const float &fDeltaTime ) +void Player::UpdateScore( float fDeltaTime ) { m_sprScoreFrame.Update( fDeltaTime ); m_ScoreNumber.Update( fDeltaTime ); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index e13b36b57a..2b8554b6b6 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -34,7 +34,7 @@ public: void SetSteps( const Steps& newSteps, bool bLoadOnlyLeftSide = false, bool bLoadOnlyRightSide = false ); void SetX( float fX ); - void Update( const float &fDeltaTime, float fSongBeat, float fMaxBeatDifference ); + void Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference ); void Draw(); @@ -68,7 +68,7 @@ protected: // color arrows void SetColorArrowsX( int iX ); - void UpdateColorArrows( const float& fDeltaTime ); + void UpdateColorArrows( float fDeltaTime ); float GetColorArrowYPos( int iStepIndex, float fSongBeat ); void DrawColorArrows(); int m_iColorArrowFrameOffset[MAX_STEP_ELEMENTS]; @@ -76,14 +76,14 @@ protected: // gray arrows void SetGrayArrowsX( int iX ); - void UpdateGrayArrows( const float& fDeltaTime ); + void UpdateGrayArrows( float fDeltaTime ); void DrawGrayArrows(); void GrayArrowStep( int index, StepScore score ); GrayArrow m_GrayArrow[MAX_NUM_COLUMNS]; // ghost arrows void SetGhostArrowsX( int iX ); - void UpdateGhostArrows( const float& fDeltaTime ); + void UpdateGhostArrows( float fDeltaTime ); void DrawGhostArrows(); void GhostArrowStep( int index, StepScore score ); GhostArrow m_GhostArrow[MAX_NUM_COLUMNS]; @@ -91,7 +91,7 @@ protected: // judgement void SetJudgementX( int iX ); - void UpdateJudgement( const float& fDeltaTime ); + void UpdateJudgement( float fDeltaTime ); void DrawJudgement(); void SetJudgement( StepScore score ); float m_fJudgementDisplayCountdown; @@ -99,7 +99,7 @@ protected: // combo void SetComboX( int iX ); - void UpdateCombo( const float& fDeltaTime ); + void UpdateCombo( float fDeltaTime ); void DrawCombo(); void SetCombo( int iNum ); bool m_bComboVisible; @@ -108,7 +108,7 @@ protected: // life meter void SetLifeMeterX( int iX ); - void UpdateLifeMeter( const float& fDeltaTime ); + void UpdateLifeMeter( float fDeltaTime ); void DrawLifeMeter(); void ChangeLife( StepScore score ); public: @@ -120,7 +120,7 @@ private: // score void SetScoreX( int iX ); - void UpdateScore( const float& fDeltaTime ); + void UpdateScore( float fDeltaTime ); void DrawScore(); void ChangeScore( StepScore stepscore, int iCurCombo ); float m_fScore; diff --git a/stepmania/src/RageMovieTexture.cpp b/stepmania/src/RageMovieTexture.cpp index ff43141a81..8e3c522013 100644 --- a/stepmania/src/RageMovieTexture.cpp +++ b/stepmania/src/RageMovieTexture.cpp @@ -288,6 +288,46 @@ VOID RageMovieTexture::Create() } +void HandleDivXError() +{ + int iRetVal = MessageBox( NULL, "Could not locate the DivX video codec. \n\ +DivX is required to play the animations in this game and must \n\ +be installed before running the application.\n\n\ +If you'd like, we can install the DivX codec version 3.11 \n\ +automatically for you. Would you like to do this?", "Error - DivX missing", MB_YESNO|MB_ICONSTOP ); + if( iRetVal == IDYES ) + { + STARTUPINFO si; + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + PROCESS_INFORMATION pi; + + + CreateProcess( + NULL, + "divx/Register_DivX.exe", // pointer to command line string + NULL, // process security attributes + NULL, // thread security attributes + FALSE, // handle inheritance flag + 0, // creation flags + NULL, // pointer to new environment block + "divx", // pointer to current directory name + &si, // pointer to STARTUPINFO + &pi // pointer to PROCESS_INFORMATION + ); + exit(1); + } + else + { + int iRetVal = MessageBox( NULL, "We're sorry, but you must install DivX before using this application.\n\ +Would you like to visit www.divx.com for more information on DivX codec?", "Sorry", MB_YESNO|MB_ICONSTOP ); + if( iRetVal == IDYES ) + { + GotoURL("http://www.divx.com"); + exit(1); + } + } +} //----------------------------------------------------------------------------- // InitDShowTextureRenderer : Create DirectShow filter graph and run the graph @@ -325,46 +365,9 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer() // Add the source filter - if( FAILED( hr = m_pGB->AddSourceFilter( wFileName, L"SOURCE", &pFSrc ) ) ) + if( FAILED( hr = m_pGB->AddSourceFilter( wFileName, L"SOURCE", &pFSrc ) ) ) // if this fails, it's probably because the user doesn't have DivX installed { - int iRetVal = MessageBox( NULL, "Could not locate the DivX video codec. \n\ -DivX is required to play the animations in this game and must \n\ -be installed before running the application.\n\n\ -If you'd like, we can install the DivX codec version 3.11 \n\ -automatically for you. Would you like to do this?", "Error - DivX missing", MB_YESNO|MB_ICONSTOP ); - if( iRetVal == IDYES ) - { - STARTUPINFO si; - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - PROCESS_INFORMATION pi; - - - CreateProcess( - NULL, - "divx/Register_DivX.exe", // pointer to command line string - NULL, // process security attributes - NULL, // thread security attributes - FALSE, // handle inheritance flag - 0, // creation flags - NULL, // pointer to new environment block - "divx", // pointer to current directory name - &si, // pointer to STARTUPINFO - &pi // pointer to PROCESS_INFORMATION - ); - - } - else - { - int iRetVal = MessageBox( NULL, "We're sorry, but you must install DivX before using this application.\n\ -Would you like to visit www.divx.com for more information on DivX codec?", "Sorry", MB_YESNO|MB_ICONSTOP ); - if( iRetVal == IDYES ) - { - GotoURL("http://www.divx.com"); - } - } - exit(1); - // if this fails, it's probably because the user doesn't have DivX installed + HandleDivXError(); RageErrorHr( "Could not create source filter to graph!", hr ); } @@ -377,7 +380,10 @@ Would you like to visit www.divx.com for more information on DivX codec?", "Sorr // Connect these two filters if( FAILED( hr = m_pGB->Connect( pFSrcPinOut, pFTRPinIn ) ) ) - RageErrorHr( "Could not connect pins!", hr ); + { + HandleDivXError(); + RageErrorHr( "Could not connect pins!", hr ); + } // Get the graph's media control, event & position interfaces m_pGB.QueryInterface(&m_pMC); diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 4d796c596a..90cdccc8cb 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -27,11 +27,18 @@ RageSound::RageSound( HWND hWnd ) RageError( "RageSound called with NULL hWnd." ); m_hWndApp = hWnd; - if( BASS_GetVersion() != MAKELONG(1,1) ) - RageError( "BASS version 1.1 DLL could not be loaded. Verify that Bass.dll exists in the program directory."); + if( BASS_GetVersion() != MAKELONG(1,3) ) + RageError( "BASS version 1.3 DLL could not be loaded. Verify that Bass.dll exists in the program directory."); if( !BASS_Init( -1, 44100, BASS_DEVICE_NOSYNC, m_hWndApp ) ) + { + MessageBox( NULL, "There was an error while initializing your sound card.\n\n\ +The most likely cause of this problem is that you do not have a sound card\n\ +installed, or that you have not yet installed a driver for your sound card.\n\ +Before running this program again, please verify that your sound card is\n\ +is working in other Windows applications.", "Error - Need updated video driver", MB_ICONSTOP ); RageError( "BASS can't initialize sound device." ); + } BASS_Start(); } @@ -42,7 +49,9 @@ RageSound::~RageSound() } -HSAMPLE RageSound::LoadSound( const CString sFileName ) +// Sample stuff + +HSAMPLE RageSound::LoadSample( const CString sFileName ) { RageLog( "RageSound::LoadSound( '%s' )", sFileName ); @@ -53,19 +62,76 @@ HSAMPLE RageSound::LoadSound( const CString sFileName ) return hSample; } -VOID RageSound::UnloadSound( HSAMPLE hSample ) +void RageSound::UnloadSample( HSAMPLE hSample ) { BASS_SampleFree( hSample ); } -VOID RageSound::Play( HSAMPLE hSample ) +void RageSound::PlaySample( HSAMPLE hSample ) { - if( NULL == BASS_SamplePlay( hSample ) ) + if( FALSE == BASS_SamplePlay( hSample ) ) RageError( "There was an error playing a sound sample. Are you sure this is a valid HSAMPLE?" ); } -VOID RageSound::Stop( HSAMPLE hSample ) +void RageSound::StopSample( HSAMPLE hSample ) { if( FALSE == BASS_SampleStop( hSample ) ) RageError( "There was an error stopping a sound sample. Are you sure this is a valid HSAMPLE?" ); +} + + +// Stream stuff + +HSTREAM RageSound::LoadStream( const CString sFileName ) +{ + RageLog( "RageSound::LoadSound( '%s' )", sFileName ); + + HSAMPLE hStream = BASS_StreamCreateFile( FALSE, (void*)((LPCTSTR)sFileName), 0, 0, 0 ); + if( hStream == NULL ) + RageError( ssprintf("RageSound::LoadSound: error loading %s (error code %d)", + sFileName, BASS_ErrorGetCode()) ); + return hStream; +} + +void RageSound::UnloadStream( HSTREAM hStream ) +{ + BASS_StreamFree( hStream ); +} + +void RageSound::PlayStream( HSTREAM hStream ) +{ + if( FALSE == BASS_StreamPlay( hStream, FALSE, 0 ) ) + RageError( "There was an error playing a sound stream. Are you sure this is a valid HSTREAM?" ); +} + +void RageSound::PauseStream( HSTREAM hStream ) +{ + if( FALSE == BASS_ChannelPause( hStream ) ) + RageError( "There was an error pausing a sound stream. Are you sure this is a valid HSTREAM?" ); +} + +void RageSound::StopStream( HSTREAM hStream ) +{ + if( FALSE == BASS_ChannelStop( hStream ) ) + RageError( "There was an error stopping a sound stream. Are you sure this is a valid HSTREAM?" ); +} + +float RageSound::GetStreamLength( HSTREAM hStream ) +{ + DWORD dwLength = BASS_StreamGetLength(hStream); + float fSeconds = BASS_ChannelBytes2Seconds( hStream, dwLength ); + return fSeconds; +} + +float RageSound::GetStreamPosition( HSTREAM hStream ) +{ + DWORD dwPosition = BASS_ChannelGetPosition( hStream ); + float fSeconds = BASS_ChannelBytes2Seconds( hStream, dwPosition ); + return fSeconds; +} + +BOOL RageSound::IsPlaying( DWORD handle ) +{ + BOOL bIsPlaying = (0 == BASS_ChannelIsActive(handle) ); + return bIsPlaying; } \ No newline at end of file diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 516626cd3e..8eca5c0d3a 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -18,15 +18,6 @@ #define NUM_STREAMS 16 -#define EFFECT_CHANNEL_1 0 -#define EFFECT_CHANNEL_2 1 -#define EFFECT_CHANNEL_3 2 -#define EFFECT_CHANNEL_4 3 -#define EFFECT_CHANNEL_5 4 -#define ANOUNCER_CHANNEL 13 -#define CROWD_CHANNEL 14 -#define MUSIC_CHANNEL 15 - class RageSound { @@ -34,10 +25,19 @@ public: RageSound( HWND hWnd ); ~RageSound(); - HSAMPLE LoadSound( const CString sFileName ); - VOID UnloadSound( HSAMPLE hSample ); - VOID Play( HSAMPLE hSample ); - VOID Stop( HSAMPLE hSample ); + HSAMPLE LoadSample( const CString sFileName ); + void UnloadSample( HSAMPLE hSample ); + void PlaySample( HSAMPLE hSample ); + void StopSample( HSAMPLE hSample ); + + HSTREAM LoadStream( const CString sFileName ); + void UnloadStream( HSTREAM hStream); + void PlayStream( HSTREAM hStream); + void PauseStream( HSTREAM hStream); + void StopStream( HSTREAM hStream); + float GetStreamLength( HSTREAM hStream); + float GetStreamPosition( HSTREAM hStream); + BOOL IsPlaying(DWORD handle); private: HWND m_hWndApp; // this is set on GRAPHICS_Create() diff --git a/stepmania/src/RageTexture.h b/stepmania/src/RageTexture.h index daa32d0501..0b367706d8 100644 --- a/stepmania/src/RageTexture.h +++ b/stepmania/src/RageTexture.h @@ -22,6 +22,7 @@ typedef RageTexture* LPRageTexture; //#include + struct FRECT { public: @@ -34,6 +35,7 @@ public: }; + //----------------------------------------------------------------------------- // RageTexture Class Declarations //----------------------------------------------------------------------------- diff --git a/stepmania/src/ScreenDimensions.h b/stepmania/src/ScreenDimensions.h index e7e982b35b..69e62fcde4 100644 --- a/stepmania/src/ScreenDimensions.h +++ b/stepmania/src/ScreenDimensions.h @@ -9,8 +9,14 @@ */ -#define SCREEN_WIDTH (640) -#define SCREEN_HEIGHT (480) -#define CENTER_X (SCREEN_WIDTH/2) -#define CENTER_Y (SCREEN_HEIGHT/2) +const int SCREEN_WIDTH = 640; +const int SCREEN_HEIGHT = 480; + +const float LEFT_EDGE = 0; +const float RIGHT_EDGE = SCREEN_WIDTH; +const float TOP_EDGE = 0; +const float BOTTOM_EDGE = SCREEN_HEIGHT; + +const float CENTER_X = LEFT_EDGE + (RIGHT_EDGE - LEFT_EDGE)/2.0f; +const float CENTER_Y = TOP_EDGE + (BOTTOM_EDGE - TOP_EDGE)/2.0f; diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 4123cf32ca..93dfed27fe 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -342,7 +342,6 @@ void Song::TidyUpData() if( m_sMusic == "" || !DoesFileExist(GetMusicPath()) ) { CStringArray arrayPossibleMusic; - GetDirListing( m_sSongDir + CString("*.wma"), arrayPossibleMusic ); GetDirListing( m_sSongDir + CString("*.mp3"), arrayPossibleMusic ); GetDirListing( m_sSongDir + CString("*.wav"), arrayPossibleMusic ); diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index e81e29035a..09c999290e 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -146,17 +146,8 @@ bool Sprite::LoadTexture( CString sTexturePath ) } -void Sprite::PrintDebugInfo() -{ -// Actor::PrintDebugInfo(); - RageLog( "Sprite::PrintDebugInfo()" ); - RageLog( "m_uNumStates: %u, m_uCurState: %u, m_fSecsIntoState: %f", - m_uNumStates, m_uCurState, m_fSecsIntoState ); -} - - -void Sprite::Update( const float &fDeltaTime ) +void Sprite::Update( float fDeltaTime ) { //PrintDebugInfo(); @@ -186,24 +177,9 @@ void Sprite::Update( const float &fDeltaTime ) void Sprite::Draw() { - Actor::Draw(); // set up our world matrix - - if( m_pTexture == NULL ) - return; - - FRECT* pTexCoordRect; // the texture coordinates of the frame we're going to use - if( m_bUsingCustomTexCoordRect ) { - pTexCoordRect = &m_CustomTexCoordRect; - } else { - UINT uFrameNo = m_uFrame[m_uCurState]; - pTexCoordRect = m_pTexture->GetTextureCoordRect( uFrameNo ); - } - - - D3DXCOLOR colorDiffuse[4]; - for(int i=0; i<4; i++) - colorDiffuse[i] = m_colorDiffuse[i]; - D3DXCOLOR colorAdd = m_colorAdd; + D3DXVECTOR2 pos = m_pos; + D3DXVECTOR3 rotation = m_rotation; + D3DXVECTOR2 scale = m_scale; // update properties based on SpriteEffects switch( m_Effect ) @@ -211,110 +187,180 @@ void Sprite::Draw() case no_effect: break; case blinking: - { - for(int i=0; i<4; i++) - colorDiffuse[i] = m_bTweeningTowardEndColor ? m_start_colorDiffuse[i] : m_end_colorDiffuse[i]; - } break; case camelion: - { - for(int i=0; i<4; i++) - colorDiffuse[i] = m_start_colorDiffuse[i]*m_fPercentBetweenColors + m_end_colorDiffuse[i]*(1.0f-m_fPercentBetweenColors); - } break; case glowing: - colorAdd = m_start_colorAdd*m_fPercentBetweenColors + m_end_colorAdd*(1.0f-m_fPercentBetweenColors); break; case wagging: + rotation.z = m_fWagRadians * (float)sin( + (m_fWagTimer / m_fWagPeriod) // percent through wag + * 2.0 * D3DX_PI ); break; case spinning: // nothing special needed break; case vibrating: + pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); + pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); break; case flickering: - m_bVisibleThisFrame = !m_bVisibleThisFrame; - if( !m_bVisibleThisFrame ) - for(int i=0; i<4; i++) - colorDiffuse[i] = D3DXCOLOR(0,0,0,0); // don't draw the frame break; } - // make the object in logical units centered at the origin - LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer(); - CUSTOMVERTEX* v; - pVB->Lock( 0, 0, (BYTE**)&v, 0 ); - - float fHalfSizeX = m_size.x/2; - float fHalfSizeY = m_size.y/2; - - v[0].p = D3DXVECTOR3( -fHalfSizeX, fHalfSizeY, 0 ); // bottom left - v[1].p = D3DXVECTOR3( -fHalfSizeX, -fHalfSizeY, 0 ); // top left - v[2].p = D3DXVECTOR3( fHalfSizeX, fHalfSizeY, 0 ); // bottom right - v[3].p = D3DXVECTOR3( fHalfSizeX, -fHalfSizeY, 0 ); // top right - - v[0].tu = pTexCoordRect->left; v[0].tv = pTexCoordRect->bottom; // bottom left - v[1].tu = pTexCoordRect->left; v[1].tv = pTexCoordRect->top; // top left - v[2].tu = pTexCoordRect->right; v[2].tv = pTexCoordRect->bottom; // bottom right - v[3].tu = pTexCoordRect->right; v[3].tv = pTexCoordRect->top; // top right - - v[0].color = colorDiffuse[2]; // bottom left - v[1].color = colorDiffuse[0]; // top left - v[2].color = colorDiffuse[3]; // bottom right - v[3].color = colorDiffuse[1]; // top right - - pVB->Unlock(); - - - ////////////////////// - // render the diffuse pass - ////////////////////// - - // set texture and alpha properties LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); - pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); - //pd3dDevice->SetRenderState( D3DRS_SRCBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA ); - //pd3dDevice->SetRenderState( D3DRS_DESTBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA ); - pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); - pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + // calculate and apply world transform + D3DXMATRIX matOriginalWorld, matNewWorld, matTemp; + pd3dDevice->GetTransform( D3DTS_WORLD, &matOriginalWorld ); // save the original world matrix + matNewWorld = matOriginalWorld; // initialize the matrix we're about to build to transform into this Frame's coord space - // finally! Pump those triangles! - pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); - pd3dDevice->SetStreamSource( 0, pVB, sizeof(CUSTOMVERTEX) ); - pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + D3DXMatrixTranslation( &matTemp, pos.x, pos.y, 0 ); // add in the translation + matNewWorld = matTemp * matNewWorld; + D3DXMatrixTranslation( &matTemp, -0.5f, -0.5f, 0 ); // shift to align texels with pixels + matNewWorld = matTemp * matNewWorld; + D3DXMatrixScaling( &matTemp, scale.x, scale.y, 1 ); // add in the zoom + matNewWorld = matTemp * matNewWorld; + D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation + matNewWorld = matTemp * matNewWorld; + pd3dDevice->SetTransform( D3DTS_WORLD, &matNewWorld ); // transform to local coordinates - ////////////////////// - // render the diffuse pass - ////////////////////// - if( colorAdd.a == 0 ) // no need to render an add pass - return; - - pVB->Lock( 0, 0, (BYTE**)&v, 0 ); - - v[0].color = v[1].color = v[2].color = v[3].color = colorAdd; - pVB->Unlock(); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + if( m_pTexture != NULL ) + { - pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + FRECT* pTexCoordRect; // the texture coordinates of the frame we're going to use + if( m_bUsingCustomTexCoordRect ) { + pTexCoordRect = &m_CustomTexCoordRect; + } else { + UINT uFrameNo = m_uFrame[m_uCurState]; + pTexCoordRect = m_pTexture->GetTextureCoordRect( uFrameNo ); + } + + + D3DXCOLOR colorDiffuse[4]; + for(int i=0; i<4; i++) + colorDiffuse[i] = m_colorDiffuse[i]; + D3DXCOLOR colorAdd = m_colorAdd; + + // update properties based on SpriteEffects + switch( m_Effect ) + { + case no_effect: + break; + case blinking: + { + for(int i=0; i<4; i++) + colorDiffuse[i] = m_bTweeningTowardEndColor ? m_start_colorDiffuse[i] : m_end_colorDiffuse[i]; + } + break; + case camelion: + { + for(int i=0; i<4; i++) + colorDiffuse[i] = m_start_colorDiffuse[i]*m_fPercentBetweenColors + m_end_colorDiffuse[i]*(1.0f-m_fPercentBetweenColors); + } + break; + case glowing: + colorAdd = m_start_colorAdd*m_fPercentBetweenColors + m_end_colorAdd*(1.0f-m_fPercentBetweenColors); + break; + case wagging: + break; + case spinning: + // nothing special needed + break; + case vibrating: + break; + case flickering: + m_bVisibleThisFrame = !m_bVisibleThisFrame; + if( !m_bVisibleThisFrame ) + for(int i=0; i<4; i++) + colorDiffuse[i] = D3DXCOLOR(0,0,0,0); // don't draw the frame + break; + } + + + // make the object in logical units centered at the origin + LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer(); + CUSTOMVERTEX* v; + pVB->Lock( 0, 0, (BYTE**)&v, 0 ); + + float fHalfSizeX = m_size.x/2; + float fHalfSizeY = m_size.y/2; + + v[0].p = D3DXVECTOR3( -fHalfSizeX, fHalfSizeY, 0 ); // bottom left + v[1].p = D3DXVECTOR3( -fHalfSizeX, -fHalfSizeY, 0 ); // top left + v[2].p = D3DXVECTOR3( fHalfSizeX, fHalfSizeY, 0 ); // bottom right + v[3].p = D3DXVECTOR3( fHalfSizeX, -fHalfSizeY, 0 ); // top right + + v[0].tu = pTexCoordRect->left; v[0].tv = pTexCoordRect->bottom; // bottom left + v[1].tu = pTexCoordRect->left; v[1].tv = pTexCoordRect->top; // top left + v[2].tu = pTexCoordRect->right; v[2].tv = pTexCoordRect->bottom; // bottom right + v[3].tu = pTexCoordRect->right; v[3].tv = pTexCoordRect->top; // top right + + v[0].color = colorDiffuse[2]; // bottom left + v[1].color = colorDiffuse[0]; // top left + v[2].color = colorDiffuse[3]; // bottom right + v[3].color = colorDiffuse[1]; // top right + + pVB->Unlock(); + + + ////////////////////// + // render the diffuse pass + ////////////////////// + + // set texture and alpha properties + // LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); + pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() ); + + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); + //pd3dDevice->SetRenderState( D3DRS_SRCBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA ); + //pd3dDevice->SetRenderState( D3DRS_DESTBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA ); + pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); + pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); + + + // finally! Pump those triangles! + pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); + pd3dDevice->SetStreamSource( 0, pVB, sizeof(CUSTOMVERTEX) ); + pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + + + ////////////////////// + // render the add pass + ////////////////////// + if( colorAdd.a != 0 ) // no need to render an add pass + { + pVB->Lock( 0, 0, (BYTE**)&v, 0 ); + + v[0].color = v[1].color = v[2].color = v[3].color = colorAdd; + + pVB->Unlock(); + + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + + pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + } + } + + + pd3dDevice->SetTransform( D3DTS_WORLD, &matOriginalWorld ); // restore the original world matrix } diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index b5a8411523..bfb1bcf992 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -29,19 +29,15 @@ public: virtual ~Sprite(); - - - bool LoadFromTexture( CString sTexturePath ); - bool LoadFromSpriteFile( CString sSpritePath ); - - void PrintDebugInfo(); + virtual bool LoadFromTexture( CString sTexturePath ); + virtual bool LoadFromSpriteFile( CString sSpritePath ); virtual void Draw(); - virtual void Update( const float &fDeltaTime ); + virtual void Update( float fDeltaTime ); - void StartAnimating() { m_bIsAnimating = TRUE; }; - void StopAnimating() { m_bIsAnimating = FALSE; }; - void SetState( UINT uNewState ); + virtual void StartAnimating() { m_bIsAnimating = TRUE; }; + virtual void StopAnimating() { m_bIsAnimating = FALSE; }; + virtual void SetState( UINT uNewState ); UINT GetNumStates() { return m_uNumStates; }; CString GetTexturePath() { return m_sTexturePath; }; diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 428ee07dc6..6b949dcc10 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -25,6 +25,7 @@ #include "WindowTitleMenu.h" #include "WindowSandbox.h" +#include "WindowLoading.h" #include @@ -67,7 +68,6 @@ void Update(); // Update the game logic void Render(); // Render a frame void ShowFrame(); // Display the contents of the back buffer to the screen void SetFullscreen( BOOL bFullscreen ); // Switch between fullscreen and windowed modes. -void TestForDirectX(); // check for DirectX 8 // Functions that work with game objects HRESULT CreateObjects( HWND hWnd ); // allocate and initialize game objects @@ -82,6 +82,17 @@ VOID DestroyObjects(); // deallocate game objects when we're done with them //----------------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) { + if( !DoesFileExist("Songs") ) + { + // change dir to path of the execuctable + TCHAR szFullAppPath[MAX_PATH]; + GetModuleFileName(NULL, szFullAppPath, MAX_PATH); + LPSTR pLastBackslash = strrchr(szFullAppPath, '\\'); + *pLastBackslash = '\0'; // terminate the string + //MessageBox(NULL, szFullAppPath, szFullAppPath, MB_OK); + SetCurrentDirectory(szFullAppPath); + } + CoInitialize (NULL); // Initialize COM // Register the window class @@ -123,9 +134,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) if( NULL == g_hWndMain ) exit(1); - - TestForDirectX(); - // Load keyboard accelerators HACCEL hAccel = LoadAccelerators( NULL, MAKEINTRESOURCE(IDR_MAIN_ACCEL) ); @@ -158,7 +166,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) { Update(); Render(); - ShowFrame(); //if( !g_bFullscreen ) ::Sleep(16); // give some time for the movie } @@ -294,12 +301,20 @@ HRESULT CreateObjects( HWND hWnd ) SCREEN = new RageScreen( hWnd ); TM = new RageTextureManager( SCREEN ); + WM = new WindowManager; + + // throw something up on the screen while the game resources are loading + WM->SetNewWindow( new WindowLoading ); + Render(); + ShowFrame(); + + SOUND = new RageSound( hWnd ); MUSIC = new RageMusic; INPUT = new RageInput( hWnd ); GAMEINFO = new GameInfo; - WM = new WindowManager; + //WM->SetNewWindow( new WindowSandbox ); WM->SetNewWindow( new WindowTitleMenu ); @@ -472,6 +487,8 @@ void Render() } break; } + + ShowFrame(); } @@ -508,21 +525,5 @@ void SetFullscreen( BOOL bFullscreen ) //----------------------------------------------------------------------------- #include "getdxver.h" -void TestForDirectX() -{ - if( GetDXVersion() < 0x0800 ) - { - int iRetVal = MessageBox( NULL, "We're sorry, but you have an old version of the Microsoft DirectX drivers.\n\ -This application requires DirectX version 8.1 or higher.\n\n\ -Would you like to visit the Microsoft DirectX site to download the latest version?", "Sorry", MB_YESNO|MB_ICONSTOP ); - if( iRetVal == IDYES ) - { - GotoURL("http://www.microsoft.com/directx/homeuser/downloads/default.asp"); - } - - exit(1); - } - -} diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index c110c9e164..dd5648c70c 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -200,6 +200,14 @@ SOURCE=.\WindowIntroCovers.h # End Source File # Begin Source File +SOURCE=.\WindowLoading.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowLoading.h +# End Source File +# Begin Source File + SOURCE=.\WindowManager.cpp # End Source File # Begin Source File @@ -268,6 +276,14 @@ SOURCE=.\Actor.h # End Source File # Begin Source File +SOURCE=.\ActorFrame.cpp +# End Source File +# Begin Source File + +SOURCE=.\ActorFrame.h +# End Source File +# Begin Source File + SOURCE=.\Background.cpp # End Source File # Begin Source File @@ -390,6 +406,14 @@ SOURCE=.\Steps.cpp SOURCE=.\Steps.h # End Source File +# Begin Source File + +SOURCE=.\TextBanner.cpp +# End Source File +# Begin Source File + +SOURCE=.\TextBanner.h +# End Source File # End Group # Begin Group "File Types" diff --git a/stepmania/src/TextBanner.cpp b/stepmania/src/TextBanner.cpp new file mode 100644 index 0000000000..b65ca0c27a --- /dev/null +++ b/stepmania/src/TextBanner.cpp @@ -0,0 +1,52 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + File: TextBanner.h + + Desc: The song's TextBanner displayed in SelectSong. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#include "RageUtil.h" + +#include "TextBanner.h" + +TextBanner::TextBanner() +{ + m_textTitle.LoadFromFontName( "Arial Bold" ); + m_textSubTitle.LoadFromFontName( "Arial Bold" ); + m_textArtist.LoadFromFontName( "Arial Bold" ); + + this->AddActor( &m_textTitle ); + this->AddActor( &m_textSubTitle ); + this->AddActor( &m_textArtist ); + this->SetZoom( 0.5f ); + + +} + + +bool TextBanner::LoadFromSong( Song &song ) +{ + CString sTitle = song.GetTitle(); + CString sSubTitle; + + m_textTitle.SetText( sTitle ); + m_textTitle.SetZoom( 1.0f ); + m_textTitle.SetXY( 0, -30 ); + + m_textSubTitle.SetText( sSubTitle ); + m_textTitle.SetZoom( 0.5f ); + m_textSubTitle.SetXY( 0, 0 ); + + m_textArtist.SetText( song.GetArtist() ); + m_textTitle.SetZoom( 0.5f ); + m_textArtist.SetXY( 0, 30 ); + + + + + return true; +} diff --git a/stepmania/src/TextBanner.h b/stepmania/src/TextBanner.h new file mode 100644 index 0000000000..9fb17901e5 --- /dev/null +++ b/stepmania/src/TextBanner.h @@ -0,0 +1,39 @@ +/* +----------------------------------------------------------------------------- + File: TextBanner.h + + Desc: The song's TextBanner displayed in SelectSong. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#ifndef _TextBanner_H_ +#define _TextBanner_H_ + + +#include "ActorFrame.h" +#include "Song.h" +#include "BitmapText.h" + + +const float TEXT_BANNER_WIDTH = 192; // from the source art of DDR +const float TEXT_BANNER_HEIGHT = 55; + + +class TextBanner : public ActorFrame +{ +public: + TextBanner(); + bool LoadFromSong( Song &song); + +private: + BitmapText m_textTitle, m_textSubTitle, m_textArtist; + + +}; + + + + +#endif \ No newline at end of file diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index 563e2c3f3f..1fa12fd329 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -25,17 +25,17 @@ Transition::Transition() : { m_bPlayCloseWipingRightSound = TRUE; m_bPlayCloseWipingLeftSound = TRUE; - m_hCloseWipingRightSound = SOUND->LoadSound( SOUND_NEXT ); - m_hCloseWipingLeftSound = SOUND->LoadSound( SOUND_BACK ); + m_hCloseWipingRightSound = SOUND->LoadSample( SOUND_NEXT ); + m_hCloseWipingLeftSound = SOUND->LoadSample( SOUND_BACK ); } Transition::~Transition() { - SOUND->UnloadSound( m_hCloseWipingRightSound ); - SOUND->UnloadSound( m_hCloseWipingLeftSound ); + SOUND->UnloadSample( m_hCloseWipingRightSound ); + SOUND->UnloadSample( m_hCloseWipingLeftSound ); } -void Transition::Update( const FLOAT &fDeltaTime ) +void Transition::Update( float fDeltaTime ) { switch( m_TransitionState ) { @@ -96,7 +96,7 @@ void Transition::CloseWipingRight( WindowMessage send_when_done ) m_TransitionState = closing_right; m_fPercentThroughTransition = 0.0; if( m_bPlayCloseWipingRightSound ) - SOUND->Play( m_hCloseWipingRightSound ); + SOUND->PlaySample( m_hCloseWipingRightSound ); } void Transition::CloseWipingLeft( WindowMessage send_when_done ) @@ -105,7 +105,7 @@ void Transition::CloseWipingLeft( WindowMessage send_when_done ) m_TransitionState = closing_left; m_fPercentThroughTransition = 0.0; if( m_bPlayCloseWipingLeftSound ) - SOUND->Play( m_hCloseWipingLeftSound ); + SOUND->PlaySample( m_hCloseWipingLeftSound ); } @@ -113,13 +113,13 @@ void Transition::SetCloseWipingRightSound( CString sSoundPath ) { if( sSoundPath == "" ) { - SOUND->UnloadSound( m_hCloseWipingRightSound ); + SOUND->UnloadSample( m_hCloseWipingRightSound ); m_bPlayCloseWipingRightSound = FALSE; } else { - SOUND->UnloadSound( m_hCloseWipingRightSound ); - m_hCloseWipingRightSound = SOUND->LoadSound( SOUND_NEXT ); + SOUND->UnloadSample( m_hCloseWipingRightSound ); + m_hCloseWipingRightSound = SOUND->LoadSample( SOUND_NEXT ); m_bPlayCloseWipingRightSound = TRUE; } } @@ -128,13 +128,13 @@ void Transition::SetCloseWipingLeftSound( CString sSoundPath ) { if( sSoundPath == "" ) { - SOUND->UnloadSound( m_hCloseWipingRightSound ); + SOUND->UnloadSample( m_hCloseWipingRightSound ); m_bPlayCloseWipingLeftSound = FALSE; } else { - SOUND->UnloadSound( m_hCloseWipingLeftSound ); - m_hCloseWipingLeftSound = SOUND->LoadSound( SOUND_NEXT ); + SOUND->UnloadSample( m_hCloseWipingLeftSound ); + m_hCloseWipingLeftSound = SOUND->LoadSample( SOUND_NEXT ); m_bPlayCloseWipingLeftSound = TRUE; } }; diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index c508438ce2..38eb76195f 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -29,7 +29,7 @@ public: Transition(); ~Transition(); - void Update( const FLOAT &fDeltaTime ); + void Update( float fDeltaTime ); virtual void Draw() PURE; virtual void SetOpened();