diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index a400132b8a..d4d0c8c2b7 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -214,11 +214,11 @@ void Actor::SetTweenX( float x ) { m_end_pos.x = x; } void Actor::SetTweenY( float y ) { m_end_pos.y = y; } void Actor::SetTweenXY( float x, float y ) { SetTweenX(x); SetTweenY(y); } void Actor::SetTweenZoom( float zoom ) { m_end_scale.x = zoom; m_end_scale.y = zoom; } +void Actor::SetTweenZoomX( float zoom ) { m_end_scale.x = zoom; } +void Actor::SetTweenZoomY( float zoom ) { m_end_scale.y = zoom; } void Actor::SetTweenRotationX( float r ) { m_end_rotation.x = r; } void Actor::SetTweenRotationY( float r ) { m_end_rotation.y = r; } void Actor::SetTweenRotationZ( float r ) { m_end_rotation.z = r; } -void Actor::SetTweenDiffuseColor( D3DXCOLOR c ) { for(int i=0; i<4; i++) m_end_colorDiffuse[i] = c; } -void Actor::SetTweenAddColor( D3DXCOLOR c ) { m_end_colorAdd = c; } void Actor::ScaleTo( LPRECT pRect, StretchType st ) diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index a5e0d08008..261185f545 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -40,9 +40,9 @@ public: virtual float GetX() { return m_pos.x; }; virtual float GetY() { return m_pos.y; }; - virtual void SetX( float x ) { m_pos.x = x; m_TweenType = no_tween; }; - virtual void SetY( float y ) { m_pos.y = y; m_TweenType = no_tween; }; - virtual void SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; }; + virtual void SetX( float x ) { m_pos.x = x; }; + virtual void SetY( float y ) { m_pos.y = y; }; + virtual void SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; }; // height and width vary depending on zoom virtual float GetZoomedWidth() { return m_size.x * m_scale.x; } @@ -51,7 +51,11 @@ public: virtual void SetHeight( float height ){ m_size.y = height; } virtual float GetZoom() { return m_scale.x; } + virtual float GetZoomX() { return m_scale.x; } + virtual float GetZoomY() { return m_scale.y; } virtual void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; } + virtual void SetZoomX( float zoom ){ m_scale.x = zoom; } + virtual void SetZoomY( float zoom ){ m_scale.y = zoom; } virtual float GetRotation() { return m_rotation.z; } virtual void SetRotation( float rot ) { m_rotation.z = rot; } @@ -61,6 +65,7 @@ public: virtual void SetRotationY( float rot ) { m_rotation.y = rot; } virtual void SetDiffuseColor( D3DXCOLOR colorDiffuse ) { for(int i=0; i<4; i++) m_colorDiffuse[i] = colorDiffuse; }; + virtual void SetDiffuseColors( int i, D3DXCOLOR colorDiffuse ) { m_colorDiffuse[i] = colorDiffuse; }; virtual void SetDiffuseColorUpperLeft( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[0] = colorDiffuse; }; virtual void SetDiffuseColorUpperRight( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[1] = colorDiffuse; }; virtual void SetDiffuseColorLowerLeft( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[2] = colorDiffuse; }; @@ -70,6 +75,7 @@ public: virtual void SetDiffuseColorBottomEdge( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[2] = m_colorDiffuse[3] = colorDiffuse; }; virtual void SetDiffuseColorLeftEdge( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[0] = m_colorDiffuse[2] = colorDiffuse; }; virtual D3DXCOLOR GetDiffuseColor() { return m_colorDiffuse[0]; }; + virtual D3DXCOLOR GetDiffuseColors( int i ) { return m_colorDiffuse[i]; }; virtual void SetAddColor( D3DXCOLOR colorAdd ) { m_colorAdd = colorAdd; }; virtual D3DXCOLOR GetAddColor() { return m_colorAdd; }; @@ -81,15 +87,26 @@ public: TweenType tt = tween_linear ); virtual void BeginTweening( float time, TweenType tt = tween_linear ); + virtual void StopTweening( float time, TweenType tt = tween_linear ) { m_TweenType = no_tween; }; virtual void SetTweenX( float x ); virtual void SetTweenY( float y ); virtual void SetTweenXY( float x, float y ); virtual void SetTweenZoom( float zoom ); + virtual void SetTweenZoomX( float zoom ); + virtual void SetTweenZoomY( float zoom ); virtual void SetTweenRotationX( float r ); virtual void SetTweenRotationY( float r ); virtual void SetTweenRotationZ( float r ); - virtual void SetTweenDiffuseColor( D3DXCOLOR c ); - virtual void SetTweenAddColor( D3DXCOLOR c ); + virtual void SetTweenDiffuseColor( D3DXCOLOR colorDiffuse ) { for(int i=0; i<4; i++) m_end_colorDiffuse[i] = colorDiffuse; }; + virtual void SetTweenDiffuseColorUpperLeft( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[0] = colorDiffuse; }; + virtual void SetTweenDiffuseColorUpperRight( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[1] = colorDiffuse; }; + virtual void SetTweenDiffuseColorLowerLeft( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[2] = colorDiffuse; }; + virtual void SetTweenDiffuseColorLowerRight( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[3] = colorDiffuse; }; + virtual void SetTweenDiffuseColorTopEdge( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[0] = m_end_colorDiffuse[1] = colorDiffuse; }; + virtual void SetTweenDiffuseColorRightEdge( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[1] = m_end_colorDiffuse[3] = colorDiffuse; }; + virtual void SetTweenDiffuseColorBottomEdge( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[2] = m_end_colorDiffuse[3] = colorDiffuse; }; + virtual void SetTweenDiffuseColorLeftEdge( D3DXCOLOR colorDiffuse ) { m_end_colorDiffuse[0] = m_end_colorDiffuse[2] = colorDiffuse; }; + virtual void SetTweenAddColor( D3DXCOLOR c ) { m_end_colorAdd = c; } // NOTE: GetEdge functions don't consider rotation diff --git a/stepmania/src/Banner.cpp b/stepmania/src/Banner.cpp index be5d1c5c01..88ce16ec17 100644 --- a/stepmania/src/Banner.cpp +++ b/stepmania/src/Banner.cpp @@ -18,6 +18,7 @@ bool Banner::LoadFromSong( Song &song ) { Sprite::LoadFromTexture( song.GetBannerPath() ); + //Sprite::TurnShadowOff(); float fSourceWidth = (float)m_pTexture->GetSourceWidth(); float fSourceHeight = (float)m_pTexture->GetSourceHeight(); diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 52108f0d98..0fa3f1bc94 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -22,6 +22,8 @@ BitmapText::BitmapText() for( int i=0; i 0 ) { SetJudgement( miss ); @@ -256,6 +283,49 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference } + // check for HoldStep misses + for( int i=0; iIsButtonDown( PlayerI ) ) // they're holding the button down + { + int iCol = m_StepToColumnNumber[ hs.m_Step ]; + m_HoldGhostArrow[iCol].Step(); + } + else // they're not holding the button down + { + m_HoldStepScores[i] = HOLD_SCORE_NG; + int iCol = m_StepToColumnNumber[ hs.m_Step ]; + SetHoldJudgement( iCol, HOLD_SCORE_NG ); + } + } + } + + // check for HoldStep completes + for( i=0; i iIndexLastArrowToDraw ) ) + { + continue; + } + + HoldStepScore &score = m_HoldStepScores[i]; + + int iColNum = m_StepToColumnNumber[ hs.m_Step ]; + + switch( score ) + { + case HOLD_SCORE_OK: + continue; // don't draw + case HOLD_SCORE_NONE: + case HOLD_SCORE_NG: + m_ColorArrow[iColNum].SetGrayPartClear(); + break; + case HOLD_STEPPED_ON: + m_ColorArrow[iColNum].SetGrayPartFull(); + break; + } + + // draw the gray parts + for( int j=hs.m_iEndIndex; j>=hs.m_iStartIndex; j-- ) // for each arrow in this freeze + { + float fYPos = GetColorArrowYPos( j, m_fSongBeat ); + if( score == HOLD_STEPPED_ON || score == HOLD_SCORE_OK ) + fYPos = max( fYPos, GetGrayArrowYPos() ); + if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; + m_ColorArrow[iColNum].SetY( fYPos ); + m_ColorArrow[iColNum].DrawGrayPart(); + } + + // draw the color parts + for( j=hs.m_iEndIndex; j>=hs.m_iStartIndex; j-- ) // for each arrow in this freeze + { + float fYPos = GetColorArrowYPos( j, m_fSongBeat ); + m_ColorArrow[iColNum].SetY( fYPos ); + if( score == HOLD_STEPPED_ON || score == HOLD_SCORE_OK ) + fYPos = max( fYPos, GetGrayArrowYPos() ); + if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; + m_ColorArrow[iColNum].SetY( fYPos ); + D3DXCOLOR color( (float)(j-hs.m_iStartIndex)/(float)(hs.m_iEndIndex-hs.m_iStartIndex), 1, 0, 1 ); // color shifts from green to yellow + m_ColorArrow[iColNum].SetDiffuseColor( color ); + m_ColorArrow[iColNum].DrawColorPart(); + } + + // draw the first arrow on top of the others + j = hs.m_iStartIndex; + float fYPos = GetColorArrowYPos( j, m_fSongBeat ); + if( score == HOLD_STEPPED_ON || score == HOLD_SCORE_OK ) + fYPos = max( fYPos, GetGrayArrowYPos() ); + if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; + m_ColorArrow[iColNum].SetY( fYPos ); + m_ColorArrow[iColNum].SetIndexAndBeat( i, m_fSongBeat ); + D3DXCOLOR color( 0, 1, 0, 1 ); // color shifts from green to yellow + m_ColorArrow[iColNum].SetDiffuseColor( color ); + m_ColorArrow[iColNum].Draw(); + + } + } @@ -555,7 +729,25 @@ void Player::DrawColorArrows() float Player::GetColorArrowYPos( int iStepIndex, float fSongBeat ) { float fBeatsUntilStep = StepIndexToBeat( iStepIndex ) - fSongBeat; - return (int)(fBeatsUntilStep * ARROW_GAP) + GRAY_ARROW_Y; + float fYOffset = fBeatsUntilStep * ARROW_GAP * m_PlayerOptions.m_fArrowScrollSpeed; + switch( m_PlayerOptions.m_EffectType ) + { + case PlayerOptions::EFFECT_BOOST: + fYOffset *= 1.4f / ((fYOffset+SCREEN_HEIGHT/1.6f)/SCREEN_HEIGHT); + break; + case PlayerOptions::EFFECT_WAVE: + fYOffset += 15*sin( fYOffset/38 ); + break; + } + float fYPos = fYOffset + GRAY_ARROW_Y; + + return fYPos; + +} + +float Player::GetGrayArrowYPos() +{ + return GRAY_ARROW_Y; } @@ -565,20 +757,43 @@ float Player::GetColorArrowYPos( int iStepIndex, float fSongBeat ) void Player::SetJudgementX( int iNewX ) { - m_sprJudgement.SetXY( iNewX, JUDGEMENT_Y ); + float fY = JUDGEMENT_Y; + if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; + m_sprJudgement.SetXY( iNewX, fY ); + + fY = HOLD_JUDGEMENT_Y; + if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; + for( int c=0; c 0.0 ) + if( m_fJudgementDisplayCountdown > 0 ) m_fJudgementDisplayCountdown -= fDeltaTime; m_sprJudgement.Update( fDeltaTime ); + + for( int c=0; c 0 ) + m_fHoldJudgementDisplayCountdown[c] -= fDeltaTime; + m_sprHoldJudgement[c].Update( fDeltaTime ); + } + } void Player::DrawJudgement() { if( m_fJudgementDisplayCountdown > 0.0 ) m_sprJudgement.Draw(); + + for( int c=0; c 0.0 ) + m_sprHoldJudgement[c].Draw(); + } } void Player::SetJudgement( StepScore score ) @@ -609,10 +824,45 @@ void Player::SetJudgement( StepScore score ) } } +void Player::SetHoldJudgement( int iCol, HoldStepScore score ) +{ + //RageLog( "Judgement::SetJudgement()" ); + + switch( score ) + { + case HOLD_SCORE_NONE: m_sprHoldJudgement[iCol].SetState( 0 ); break; // freeze! + case HOLD_SCORE_NG: m_sprHoldJudgement[iCol].SetState( 1 ); break; + case HOLD_SCORE_OK: m_sprHoldJudgement[iCol].SetState( 2 ); break; + } + + m_fHoldJudgementDisplayCountdown[iCol] = JUDGEMENT_DISPLAY_TIME; + + if( score == HOLD_SCORE_NG ) { // falling down + float fY = HOLD_JUDGEMENT_Y; + if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; + m_sprHoldJudgement[iCol].SetY( fY - 10 ); + m_sprHoldJudgement[iCol].SetZoom( 1.0f ); + m_sprHoldJudgement[iCol].BeginTweening( JUDGEMENT_DISPLAY_TIME ); + m_sprHoldJudgement[iCol].SetTweenY( HOLD_JUDGEMENT_Y + 10 ); + } else { // zooming out + float fY = HOLD_JUDGEMENT_Y; + if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; + m_sprHoldJudgement[iCol].SetY( fY ); + m_sprHoldJudgement[iCol].SetZoom( 1.5f ); + m_sprHoldJudgement[iCol].BeginTweening( JUDGEMENT_DISPLAY_TIME/3.0 ); + m_sprHoldJudgement[iCol].SetTweenZoom( 1.0f ); + } +} + void Player::SetComboX( int iNewX ) { - m_sprCombo.SetXY( iNewX+40, COMBO_Y ); - m_ComboNumber.SetXY( iNewX-50, COMBO_Y ); + float fY; + + fY = COMBO_Y; + if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; + + m_sprCombo.SetXY( iNewX+40, fY ); + m_ComboNumber.SetXY( iNewX-50, fY ); } void Player::UpdateCombo( float fDeltaTime ) diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 2b8554b6b6..14dd2e321d 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -20,6 +20,8 @@ #include "ColorArrow.h" #include "GrayArrow.h" #include "GhostArrow.h" +#include "HoldGhostArrow.h" +#include "Player.h" @@ -30,7 +32,7 @@ const int MAX_NUM_COLUMNS = 8; class Player { public: - Player(); + Player( PlayerOptions po ); void SetSteps( const Steps& newSteps, bool bLoadOnlyLeftSide = false, bool bLoadOnlyRightSide = false ); void SetX( float fX ); @@ -46,6 +48,8 @@ protected: void CheckForCompleteStep( float fSongBeat, Step player_step, float fMaxBeatDiff ); void OnCompleteStep( float fSongBeat, Step player_step, float fMaxBeatDiff, int iStepIndex ); + PlayerOptions m_PlayerOptions; + int m_iCurCombo; int m_iMaxCombo; float m_fSongBeat; @@ -54,8 +58,9 @@ protected: Step m_OriginalStep[MAX_STEP_ELEMENTS]; Step m_LeftToStepOn[MAX_STEP_ELEMENTS]; StepScore m_StepScore[MAX_STEP_ELEMENTS]; + CArray m_HoldSteps; //StepTiming m_StepTiming[MAX_STEP_ELEMENTS]; - + CArray m_HoldStepScores; // common to color and gray arrows float m_fArrowsCenterX; @@ -77,16 +82,18 @@ protected: // gray arrows void SetGrayArrowsX( int iX ); void UpdateGrayArrows( float fDeltaTime ); + float GetGrayArrowYPos(); void DrawGrayArrows(); - void GrayArrowStep( int index, StepScore score ); + void GrayArrowStep( int iCol, StepScore score ); GrayArrow m_GrayArrow[MAX_NUM_COLUMNS]; // ghost arrows void SetGhostArrowsX( int iX ); void UpdateGhostArrows( float fDeltaTime ); void DrawGhostArrows(); - void GhostArrowStep( int index, StepScore score ); + void GhostArrowStep( int iCol, StepScore score ); GhostArrow m_GhostArrow[MAX_NUM_COLUMNS]; + HoldGhostArrow m_HoldGhostArrow[MAX_NUM_COLUMNS]; // judgement @@ -97,6 +104,10 @@ protected: float m_fJudgementDisplayCountdown; Sprite m_sprJudgement; + void SetHoldJudgement( int iCol, HoldStepScore score ); + float m_fHoldJudgementDisplayCountdown[MAX_NUM_COLUMNS]; + Sprite m_sprHoldJudgement[MAX_NUM_COLUMNS]; + // combo void SetComboX( int iX ); void UpdateCombo( float fDeltaTime ); diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index 61fd442cff..c443060b86 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -35,6 +35,8 @@ RageBitmapTexture::RageBitmapTexture( LPRageScreen pScreen, CString sFilePath ) { // RageLog( "RageBitmapTexture::RageBitmapTexture()" ); + m_pd3dTexture = NULL; + Create(); CreateFrameRects(); diff --git a/stepmania/src/RageBitmapTexture.h b/stepmania/src/RageBitmapTexture.h index 46ba620fbe..d783927555 100644 --- a/stepmania/src/RageBitmapTexture.h +++ b/stepmania/src/RageBitmapTexture.h @@ -38,6 +38,8 @@ public: protected: virtual VOID Create(); + + LPDIRECT3DTEXTURE8 m_pd3dTexture; }; diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index 063f42a25e..869d970529 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -444,6 +444,7 @@ VOID RageInput::Release() } + HRESULT RageInput::GetDeviceInputs( DeviceInputArray &listDeviceInputs ) { // macros for reading DI state structures @@ -606,3 +607,36 @@ HRESULT RageInput::GetDeviceInputs( DeviceInputArray &listDeviceInputs ) } +BOOL RageInput::IsBeingPressed( DeviceInput di ) +{ + switch( di.device ) + { + case DEVICE_KEYBOARD: + return m_keys[ di.button ]; + case DEVICE_JOYSTICK1: + case DEVICE_JOYSTICK2: + case DEVICE_JOYSTICK3: + case DEVICE_JOYSTICK4: + int joy_index; + joy_index = di.device - DEVICE_JOYSTICK1; + + switch( di.button ) + { + case JOY_LEFT: + return IS_LEFT( m_joyState[joy_index].lX ); + case JOY_RIGHT: + return IS_RIGHT( m_joyState[joy_index].lX ); + case JOY_UP: + return IS_UP( m_joyState[joy_index].lX ); + case JOY_DOWN: + return IS_DOWN( m_joyState[joy_index].lX ); + default: // a joystick button + int button_index = di.button - JOY_1; + return IS_PRESSED( m_joyState[joy_index].rgbButtons[button_index] ); + } + default: + RageError( "Invalid device" ); + } + + return false; // how did we get here?!? +} \ No newline at end of file diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index 612fc53ea2..fdec200d66 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.h @@ -65,6 +65,11 @@ public: DeviceInput() { device=DEVICE_NONE; }; DeviceInput( InputDevice d, int b ) { device=d; button=b; }; + bool operator==( const DeviceInput &other ) + { + return device == other.device && button == other.button; + }; + CString GetDescription(); CString toString(); @@ -123,6 +128,7 @@ public: VOID Release(); // Get our Devices State HRESULT GetDeviceInputs( DeviceInputArray &listDeviceInputs ); + BOOL IsBeingPressed( DeviceInput di ); LPDIRECTINPUT8 GetDirectInput() { return m_pDI; } LPDIRECTINPUTDEVICE8 GetMouseDevice() { return m_pMouse; } diff --git a/stepmania/src/RageMovieTexture.cpp b/stepmania/src/RageMovieTexture.cpp index 8e3c522013..30ec2c518c 100644 --- a/stepmania/src/RageMovieTexture.cpp +++ b/stepmania/src/RageMovieTexture.cpp @@ -111,11 +111,13 @@ HRESULT CTextureRenderer::SetMediaType(const CMediaType *pmt) //----------------------------------------------------------------------------- // SetRenderTarget: Save all the information we'll need to render to a D3D texture. //----------------------------------------------------------------------------- -HRESULT CTextureRenderer::SetRenderTarget(LPDIRECT3DTEXTURE8 pTexture) +HRESULT CTextureRenderer::SetRenderTarget( RageMovieTexture* pTexture ) { HRESULT hr; - if (pTexture == NULL) { + LPDIRECT3DTEXTURE8 pD3DTexture = pTexture->GetD3DTexture(); + + if (pD3DTexture == NULL) { DXTRACE_ERR(TEXT("SetRenderTarget called with a NULL texture!"), 0); return E_FAIL; } @@ -124,7 +126,7 @@ HRESULT CTextureRenderer::SetRenderTarget(LPDIRECT3DTEXTURE8 pTexture) // get the format of the texture D3DSURFACE_DESC ddsd; - if ( FAILED( hr = m_pTexture->GetLevelDesc( 0, &ddsd ) ) ) { + if ( FAILED( hr = pD3DTexture->GetLevelDesc( 0, &ddsd ) ) ) { DXTRACE_ERR(TEXT("Could not get level Description of D3DX texture! hr = 0x%x"), hr); return hr; } @@ -151,9 +153,19 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample ) // Get the video bitmap buffer pSample->GetPointer( &pBmpBuffer ); + + // Find which texture we should render to. + LPDIRECT3DTEXTURE8 pD3DTexture; + + switch( m_pTexture->m_iIndexActiveTexture ) + { + case 0: pD3DTexture = m_pTexture->m_pd3dTexture[1]; break; // 0 is active, so render to 1 + case 1: pD3DTexture = m_pTexture->m_pd3dTexture[0]; break; // 1 is active, so render to 0 + } + // Lock the Texture D3DLOCKED_RECT d3dlr; - if (FAILED(m_pTexture->LockRect(0, &d3dlr, 0, 0))) { + if (FAILED(pD3DTexture->LockRect(0, &d3dlr, 0, 0))) { DXTRACE_ERR_NOMSGBOX(TEXT("Failed to lock the texture!"), E_FAIL); return E_FAIL; } @@ -205,13 +217,22 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample ) // Unlock the Texture - if (FAILED(m_pTexture->UnlockRect(0))) { + if (FAILED(pD3DTexture->UnlockRect(0))) { DXTRACE_ERR_NOMSGBOX(TEXT("Failed to unlock the texture!"), E_FAIL); return E_FAIL; } m_bLocked = FALSE; + + // flip active texture + switch( m_pTexture->m_iIndexActiveTexture ) + { + case 0: m_pTexture->m_iIndexActiveTexture = 1; break; + case 1: m_pTexture->m_iIndexActiveTexture = 0; break; + } + + return S_OK; } @@ -224,6 +245,9 @@ RageMovieTexture::RageMovieTexture( LPRageScreen pScreen, CString sFilePath ) : { RageLog( "RageBitmapTexture::RageBitmapTexture()" ); + m_pd3dTexture[0] = m_pd3dTexture[1] = NULL; + m_iIndexActiveTexture = 0; + Create(); CreateFrameRects(); @@ -233,7 +257,8 @@ RageMovieTexture::~RageMovieTexture() { CleanupDShow(); - SAFE_RELEASE(m_pd3dTexture); + SAFE_RELEASE(m_pd3dTexture[0]); + SAFE_RELEASE(m_pd3dTexture[1]); } //----------------------------------------------------------------------------- @@ -249,15 +274,15 @@ LPDIRECT3DTEXTURE8 RageMovieTexture::GetD3DTexture() // the video fell behind and is trying to copy several frames in a row // to catch up. So, if the TextureRenderer is busy, give it a 1ms slice of // time for it to catch up and copy all the frames it fell behind on. - while( m_pCTR->IsLocked() ) { - ::Sleep(1); - RageLog( "Sleeping waiting for unlock..." ); - } +// while( m_pCTR->IsLocked() ) { +// ::Sleep(1); +// RageLog( "Sleeping waiting for unlock..." ); +// } // restart the movie if we reach the end CheckMovieStatus(); - return m_pd3dTexture; + return m_pd3dTexture[m_iIndexActiveTexture]; } @@ -278,7 +303,7 @@ VOID RageMovieTexture::Create() // Pass the D3D texture to our TextureRenderer so it knows // where to render new movie frames to. - if( FAILED( hr = m_pCTR->SetRenderTarget(GetD3DTexture()) ) ) + if( FAILED( hr = m_pCTR->SetRenderTarget( this ) ) ) RageErrorHr( "RageMovieTexture: SetRenderTarget failed.", hr ); // Start the graph running @@ -409,12 +434,18 @@ HRESULT RageMovieTexture::CreateD3DTexture() if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice, m_uSourceHeight, m_uSourceHeight, 1, 0, - D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture ) ) ) + D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture[0] ) ) ) + RageErrorHr( "Could not create the D3DX texture!", hr ); + + if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice, + m_uSourceHeight, m_uSourceHeight, + 1, 0, + D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture[1] ) ) ) RageErrorHr( "Could not create the D3DX texture!", hr ); // D3DXCreateTexture can silently change the parameters on us D3DSURFACE_DESC ddsd; - if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) ) + if ( FAILED( hr = m_pd3dTexture[0]->GetLevelDesc( 0, &ddsd ) ) ) RageErrorHr( "Could not get level Description of D3DX texture!", hr ); m_uTextureWidth = ddsd.Width; diff --git a/stepmania/src/RageMovieTexture.h b/stepmania/src/RageMovieTexture.h index cec78bd2e9..88480ed00c 100644 --- a/stepmania/src/RageMovieTexture.h +++ b/stepmania/src/RageMovieTexture.h @@ -26,6 +26,7 @@ //----------------------------------------------------------------------------- struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureRenderer; +class RageMovieTexture; //----------------------------------------------------------------------------- // CTextureRenderer Class Declarations @@ -51,7 +52,7 @@ public: // new methods LONG GetVidWidth() {return m_lVidWidth;}; LONG GetVidHeight(){return m_lVidHeight;}; - HRESULT SetRenderTarget(LPDIRECT3DTEXTURE8 pTexture); + HRESULT SetRenderTarget( RageMovieTexture* pTexture ); BOOL IsLocked() { return m_bLocked; }; protected: @@ -59,7 +60,7 @@ protected: LONG m_lVidHeight; // Video Height LONG m_lVidPitch; // Video Pitch - LPDIRECT3DTEXTURE8 m_pTexture; // the video surface we will copy new frames to + RageMovieTexture* m_pTexture; // the video surface we will copy new frames to D3DFORMAT m_TextureFormat; // Texture format BOOL m_bLocked; // Is the texture currently locked while we // copy the movie frame to it? @@ -77,6 +78,9 @@ public: LPDIRECT3DTEXTURE8 GetD3DTexture(); + LPDIRECT3DTEXTURE8 m_pd3dTexture[2]; // double buffered + int m_iIndexActiveTexture; // either 0 or 1 + protected: virtual VOID Create(); @@ -94,6 +98,7 @@ protected: CComPtr m_pMP; // Media Postion CComPtr m_pME; // Media Event CTextureRenderer *m_pCTR; // DShow Texture renderer + }; typedef RageMovieTexture* LPRageMovieTexture; diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 90cdccc8cb..966a355bfe 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -79,6 +79,19 @@ void RageSound::StopSample( HSAMPLE hSample ) RageError( "There was an error stopping a sound sample. Are you sure this is a valid HSAMPLE?" ); } +float RageSound::GetSampleLength( HSAMPLE hSample ) +{ + return 90; +} + +float RageSound::GetSamplePosition( HSAMPLE hSample ) +{ + DWORD dwPosition = BASS_ChannelGetPosition( hSample ); + float fSeconds = BASS_ChannelBytes2Seconds( hSample, dwPosition ); +// fSeconds += 0.05f; // fudge number. Should use a BASS_SYNC to sync the music. + return fSeconds; +} + // Stream stuff @@ -127,6 +140,7 @@ float RageSound::GetStreamPosition( HSTREAM hStream ) { DWORD dwPosition = BASS_ChannelGetPosition( hStream ); float fSeconds = BASS_ChannelBytes2Seconds( hStream, dwPosition ); + //fSeconds += 0.05f; // fudge number. Should use a BASS_SYNC to sync the music. return fSeconds; } diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 8eca5c0d3a..e05fa21b1c 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -29,6 +29,8 @@ public: void UnloadSample( HSAMPLE hSample ); void PlaySample( HSAMPLE hSample ); void StopSample( HSAMPLE hSample ); + float GetSampleLength( HSAMPLE hSample ); + float GetSamplePosition( HSAMPLE hSample ); HSTREAM LoadStream( const CString sFileName ); void UnloadStream( HSTREAM hStream); @@ -39,6 +41,8 @@ public: float GetStreamPosition( HSTREAM hStream); BOOL IsPlaying(DWORD handle); + + private: HWND m_hWndApp; // this is set on GRAPHICS_Create() // HSAMPLE m_hSample[NUM_STREAMS]; diff --git a/stepmania/src/RageTexture.cpp b/stepmania/src/RageTexture.cpp index a128cd978a..bc70868e1f 100644 --- a/stepmania/src/RageTexture.cpp +++ b/stepmania/src/RageTexture.cpp @@ -38,7 +38,7 @@ RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) : // save the file path m_sFilePath = sFilePath; - m_pd3dTexture = NULL; +// m_pd3dTexture = NULL; m_iRefCount = 1; diff --git a/stepmania/src/RageTexture.h b/stepmania/src/RageTexture.h index 0b367706d8..0c6ddc6e82 100644 --- a/stepmania/src/RageTexture.h +++ b/stepmania/src/RageTexture.h @@ -68,7 +68,7 @@ protected: CString m_sFilePath; LPDIRECT3DDEVICE8 m_pd3dDevice; - LPDIRECT3DTEXTURE8 m_pd3dTexture; +// LPDIRECT3DTEXTURE8 m_pd3dTexture; UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture holding the image diff --git a/stepmania/src/ScreenDimensions.h b/stepmania/src/ScreenDimensions.h index 69e62fcde4..9bc1d54b65 100644 --- a/stepmania/src/ScreenDimensions.h +++ b/stepmania/src/ScreenDimensions.h @@ -8,6 +8,9 @@ ----------------------------------------------------------------------------- */ +#ifndef _SCREENDIMENSIONS_H_ +#define _SCREENDIMENSIONS_H_ + const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; @@ -20,3 +23,5 @@ 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; + +#endif \ No newline at end of file diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 93dfed27fe..28e38bfe27 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -20,6 +20,30 @@ #include + +int CompareBPMSegments(const void *arg1, const void *arg2) +{ + // arg1 and arg2 are of type Step** + BPMSegment* seg1 = (BPMSegment*)arg1; + BPMSegment* seg2 = (BPMSegment*)arg2; + + float score1 = seg1->m_fStartBeat; + float score2 = seg2->m_fStartBeat; + + if( score1 == score2 ) + return 0; + else if( score1 < score2 ) + return -1; + else + return 1; +} + +void SortBPMSegmentsArray( CArray &arrayBPMSegments ) +{ + qsort( arrayBPMSegments.GetData(), arrayBPMSegments.GetSize(), sizeof(BPMSegment), CompareBPMSegments ); +} + + ////////////////////////////// // Song ////////////////////////////// @@ -30,6 +54,33 @@ Song::Song() m_fOffsetInSeconds = 0; } + +void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut ) +{ + fElapsedTime += m_fOffsetInSeconds; + + for( int i=0; i fSecondsInThisSegment ) + fElapsedTime -= fSecondsInThisSegment; + else { + fBeatOut = fStartBeatThisSegment + fElapsedTime*fBPS; + fBPSOut = fBPS; + return; + } + } +} + + bool Song::LoadFromSongDir( CString sDir ) { RageLog( "Song::LoadFromSongDir(%s)", sDir ); @@ -48,9 +99,9 @@ bool Song::LoadFromSongDir( CString sDir ) GetDirListing( sDir + CString("*.bms"), arrayBMSFileNames ); int iNumBMSFiles = arrayBMSFileNames.GetSize(); - CStringArray arrayMSDFileNames; - GetDirListing( sDir + CString("*.msd"), arrayMSDFileNames ); - int iNumMSDFiles = arrayMSDFileNames.GetSize(); + CStringArray arrayDWIFileNames; + GetDirListing( sDir + CString("*.dwi"), arrayDWIFileNames ); + int iNumDWIFiles = arrayDWIFileNames.GetSize(); /* int j; @@ -75,14 +126,14 @@ bool Song::LoadFromSongDir( CString sDir ) new_steps.LoadStepsFromBMSFile( sDir + arrayBMSFileNames.GetAt(i) ); } } - else if( iNumMSDFiles == 1 ) + else if( iNumDWIFiles == 1 ) { - //m_sSongFile = arrayMSDFileNames.GetAt( 0 ); - //RageLog( "Found '%s'. Let's use it...", m_sSongFile ); - //LoadFromMSDFile( sDir + m_sSongFile ); + m_sSongFile = arrayDWIFileNames[0]; + RageLog( "Found '%s'. Let's use it...", m_sSongFile ); + LoadSongInfoFromDWIFile( sDir + m_sSongFile ); } - else if( iNumMSDFiles > 0 ) - RageError( ssprintf("Found more than one MSD file in '%s'. Which should I use?", sDir) ); + else if( iNumDWIFiles > 0 ) + RageError( ssprintf("Found more than one DWI file in '%s'. Which should I use?", sDir) ); else RageError( ssprintf("Couldn't find any BMS or MSD files in '%s'", sDir) ); @@ -95,6 +146,9 @@ bool Song::LoadSongInfoFromBMSFile( CString sPath ) { RageLog( "Song::LoadFromBMSFile(%s)", sPath ); + if( sPath == "Songs\\saints\\saint_4basic.bms" ) + int kdgjf = 0; + BmsFile bms( sPath ); bms.ReadFile(); @@ -123,14 +177,11 @@ bool Song::LoadSongInfoFromBMSFile( CString sPath ) m_sArtist = data_array[0]; else if( value_name == "#BPM" ) { BPMSegment new_seg; - new_seg.m_iStartBeat = 0; + new_seg.m_fStartBeat = 0; new_seg.m_fBPM = (float)atof( data_array[0] ); // find insertion point - for( int i=0; i new_seg.m_iStartBeat ) - break; - m_BPMSegments.InsertAt( i, new_seg ); - RageLog( "Inserting new BPM change at beat %d, BPM %f, index %d", new_seg.m_iStartBeat, new_seg.m_fBPM, i ); + m_BPMSegments.Add( new_seg ); + RageLog( "Inserting new BPM change at beat %f, BPM %f", new_seg.m_fStartBeat, new_seg.m_fBPM ); } else if( value_name == "#BackBMP" || value_name == "#backBMP") m_sBackground = data_array[0]; @@ -141,35 +192,15 @@ bool Song::LoadSongInfoFromBMSFile( CString sPath ) int iMeasureNo = atoi( value_name.Mid(1,3) ); int iTrackNum = atoi( value_name.Mid(4,2) ); - if( m_sTitle.Find("era") > 0 ) - m_sTitle = m_sTitle; - switch( iTrackNum ) - { - case 03: // bpm - { - int iNewBPM; - sscanf( data_array[0], "%x", &iNewBPM ); // data is in hexadecimal - BPMSegment new_seg; - new_seg.m_iStartBeat = iMeasureNo * 4; - new_seg.m_fBPM = (float)iNewBPM; - // find insertion point - for( int i=0; i new_seg.m_iStartBeat ) - break; - m_BPMSegments.InsertAt( i, new_seg ); - RageLog( "Inserting new BPM change at beat %d, BPM %f, index %d", new_seg.m_iStartBeat, new_seg.m_fBPM, i ); - } - break; - } - CString sNoteData = data_array[0]; - CArray arrayNotes; + CArray arrayNotes; for( int i=0; iright; 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(); + // Set the stage... 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 ); @@ -330,17 +316,76 @@ void Sprite::Draw() 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 shadow + ////////////////////// + if( m_bHasShadow ) + { + D3DXMATRIX matOriginalWorld, matNewWorld, matTemp; + pd3dDevice->GetTransform( D3DTS_WORLD, &matOriginalWorld ); // save the original world matrix + matNewWorld = matOriginalWorld; + + D3DXMatrixTranslation( &matTemp, 5, 5, 0 ); // shift by 5 units + matNewWorld = matTemp * matNewWorld; + pd3dDevice->SetTransform( D3DTS_WORLD, &matNewWorld ); // transform to local coordinates + + pVB->Lock( 0, 0, (BYTE**)&v, 0 ); + + v[0].color = v[1].color = v[2].color = v[3].color = D3DXCOLOR(0,0,0,0.5f*colorDiffuse[0].a); // semi-transparent black + + 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 + + } + + + ////////////////////// + // render the diffuse pass + ////////////////////// + if( colorDiffuse[0].a != 0 ) + { + pVB->Lock( 0, 0, (BYTE**)&v, 0 ); + + 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(); + + + 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 ); + + + // finally! Pump those triangles! + pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + } ////////////////////// // render the add pass ////////////////////// - if( colorAdd.a != 0 ) // no need to render an add pass + if( colorAdd.a != 0 ) { pVB->Lock( 0, 0, (BYTE**)&v, 0 ); @@ -357,6 +402,7 @@ void Sprite::Draw() pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); } + } diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index bfb1bcf992..38bb2366f1 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -45,6 +45,8 @@ public: void SetCustomSrcRect( FRECT new_texcoord_frect ); // for cropping + void TurnShadowOn() { m_bHasShadow = true; }; + void TurnShadowOff() { m_bHasShadow = false; }; protected: @@ -65,6 +67,8 @@ protected: bool m_bUsingCustomTexCoordRect; FRECT m_CustomTexCoordRect; + + bool m_bHasShadow; }; diff --git a/stepmania/src/StepMania.RC b/stepmania/src/StepMania.RC index dc0400b93e..7727767eaa 100644 --- a/stepmania/src/StepMania.RC +++ b/stepmania/src/StepMania.RC @@ -54,8 +54,6 @@ END IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE BEGIN - "P", IDM_PADS, VIRTKEY, CONTROL, NOINVERT - VK_ESCAPE, IDM_WINDOWED, VIRTKEY, NOINVERT VK_F4, IDM_TOGGLEFULLSCREEN, VIRTKEY, NOINVERT VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT "X", IDM_EXIT, VIRTKEY, ALT, NOINVERT diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 6b949dcc10..adc2088e26 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -75,6 +75,8 @@ HRESULT InvalidateObjects(); // invalidate game objects before a display mode HRESULT RestoreObjects(); // restore game objects after a display mode change VOID DestroyObjects(); // deallocate game objects when we're done with them +BOOL WeAreAlone( LPSTR szName ); + //----------------------------------------------------------------------------- // Name: WinMain() @@ -82,6 +84,11 @@ VOID DestroyObjects(); // deallocate game objects when we're done with them //----------------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) { + if( !WeAreAlone("StepMania") ) + { + RageError( "StepMania is already running!" ); + } + if( !DoesFileExist("Songs") ) { // change dir to path of the execuctable @@ -420,15 +427,18 @@ void Update() diArray.RemoveAll(); INPUT->GetDeviceInputs( diArray ); - DeviceInput di; - PadInput pi; + DeviceInput DeviceI; + PadInput PadI; + PlayerInput PlayerI; + for( int i=0; iDeviceToPad( di, pi ) ) - WM->Input( di, &pi ); // this di maps to a pi - else - WM->Input( di, NULL ); // this di doesn't map to a pi, so pass NULL + DeviceI = diArray[i]; + + GAMEINFO->DeviceToPad( DeviceI, PadI ); + GAMEINFO->PadToPlayer( PadI, PlayerI ); + + WM->Input( DeviceI, PadI, PlayerI ); } } @@ -520,10 +530,20 @@ void SetFullscreen( BOOL bFullscreen ) //----------------------------------------------------------------------------- -// Name: TestForDirectX() +// Name: WeAreAlone() // Desc: check for DirectX 8 //----------------------------------------------------------------------------- -#include "getdxver.h" +BOOL WeAreAlone (LPSTR szName) +{ + HANDLE hMutex = CreateMutex (NULL, TRUE, szName); + if (GetLastError() == ERROR_ALREADY_EXISTS) + { + CloseHandle(hMutex); + return FALSE; + } + return TRUE; +} + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index dd5648c70c..87f6bd6a3f 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -216,6 +216,22 @@ SOURCE=.\WindowManager.h # End Source File # Begin Source File +SOURCE=.\WindowPlayerOptions.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowPlayerOptions.h +# End Source File +# Begin Source File + +SOURCE=.\WindowPrompt.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowPrompt.h +# End Source File +# Begin Source File + SOURCE=.\WindowResults.cpp # End Source File # Begin Source File @@ -348,6 +364,14 @@ SOURCE=.\GrayArrow.h # End Source File # Begin Source File +SOURCE=.\HoldGhostArrow.cpp +# End Source File +# Begin Source File + +SOURCE=.\HoldGhostArrow.h +# End Source File +# Begin Source File + SOURCE=.\PadInput.h # End Source File # Begin Source File @@ -360,6 +384,10 @@ SOURCE=.\Player.h # End Source File # Begin Source File +SOURCE=.\PlayerInput.h +# End Source File +# Begin Source File + SOURCE=.\PreviewGraphic.cpp # End Source File # Begin Source File @@ -368,6 +396,14 @@ SOURCE=.\previewgraphic.h # End Source File # Begin Source File +SOURCE=.\Rectangle.cpp +# End Source File +# Begin Source File + +SOURCE=.\Rectangle.h +# End Source File +# Begin Source File + SOURCE=.\Song.cpp # End Source File # Begin Source File diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index 38eb76195f..484a607884 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -40,8 +40,10 @@ public: virtual void CloseWipingRight(WindowMessage send_when_done = SM_None ); virtual void CloseWipingLeft( WindowMessage send_when_done = SM_None ); - bool IsClosed() { return m_TransitionState == closed; }; - bool IsClosing() { return m_TransitionState == closing_right || m_TransitionState == closing_left; }; + bool IsOpened() { return m_TransitionState == opened; }; + bool IsOpening() { return m_TransitionState == opening_right || m_TransitionState == opening_left; }; + bool IsClosed() { return m_TransitionState == closed; }; + bool IsClosing() { return m_TransitionState == closing_right || m_TransitionState == closing_left; }; void SetTransitionTime( FLOAT fNewTransitionTime ) { m_fTransitionTime = fNewTransitionTime; }; diff --git a/stepmania/src/TransitionFade.cpp b/stepmania/src/TransitionFade.cpp index 8ecc7f165d..05e2ee2510 100644 --- a/stepmania/src/TransitionFade.cpp +++ b/stepmania/src/TransitionFade.cpp @@ -54,9 +54,8 @@ void TransitionFade::Draw() break; } - m_Color.a = fPercentageOpaque; - int alpha = (int)( fPercentageOpaque * 255 ); - SCREEN->DrawRect( CRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT), m_Color ); + D3DXCOLOR colorTemp = m_Color * fPercentageOpaque; + SCREEN->DrawRect( CRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT), colorTemp ); } diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 7b86dc8927..0a51ae68be 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -19,6 +19,11 @@ class Steps; // why is this needed? enum GameMode; // why is this needed? +struct BPMSegment{ + BPMSegment() { m_fStartBeat = m_fBPM = m_fFreezeSeconds = 0; }; + float m_fStartBeat, m_fBPM, m_fFreezeSeconds; +}; + class Song { @@ -37,7 +42,7 @@ public: private: bool LoadSongInfoFromBMSFile( CString sPath ); - bool LoadSongInfoFromMSDFile( CString sPath ); + bool LoadSongInfoFromDWIFile( CString sPath ); void TidyUpData(); @@ -65,31 +70,11 @@ public: iMinBPM = (int)m_BPMSegments[i].m_fBPM; } }; - void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut ) - { - fElapsedTime += m_fOffsetInSeconds; - - for( int i=0; i fSecondsInThisSegment ) - fElapsedTime -= fSecondsInThisSegment; - else { - fBeatOut = iStartBeatThisSegment + fElapsedTime*fBPS; - fBPSOut = fBPS; - return; - } - } - }; + void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut ); float GetBPMAtBeat( float fSongBeat ) { for( int i=0; i fSongBeat || i==m_BPMSegments.GetSize()-1 ) + if( m_BPMSegments[i].m_fStartBeat > fSongBeat || i==m_BPMSegments.GetSize()-1 ) break; } return m_BPMSegments[i].m_fBPM; @@ -97,7 +82,7 @@ public: void SetBPM( float fNewBPM, float fSongBeat ) { for( int i=0; i fSongBeat || i==m_BPMSegments.GetSize()-1 ) + if( m_BPMSegments[i].m_fStartBeat > fSongBeat || i==m_BPMSegments.GetSize()-1 ) break; } m_BPMSegments[i].m_fBPM = fNewBPM; @@ -125,8 +110,7 @@ private: CString m_sBanner; CString m_sBackground; - struct BPMSegment{ int m_iStartBeat; float m_fBPM; }; - CArray m_BPMSegments; + CArray m_BPMSegments; // this must be sorted before dancing public: CArray arraySteps;