From d2eeed810c7fa51e9d52ac9fc91b2a2137ccf290 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 30 Mar 2002 20:00:13 +0000 Subject: [PATCH] in the middle of working on 1.70. Now compiles in Visual Studio.net --- stepmania/src/Actor.cpp | 80 +- stepmania/src/Actor.h | 42 +- stepmania/src/ActorFrame.cpp | 2 +- stepmania/src/ArrowEffects.cpp | 3 + stepmania/src/BPMDisplay.h | 2 +- stepmania/src/Background.cpp | 6 +- stepmania/src/Banner.cpp | 16 +- stepmania/src/Banner.h | 6 +- stepmania/src/BitmapText.cpp | 411 +++------ stepmania/src/BitmapText.h | 50 +- stepmania/src/DifficultyIcon.h | 29 +- stepmania/src/FocusingSprite.h | 2 +- stepmania/src/Font.cpp | 166 ++++ stepmania/src/Font.h | 43 + stepmania/src/FontManager.cpp | 132 +++ stepmania/src/FontManager.h | 39 + stepmania/src/FootMeter.h | 31 +- stepmania/src/Grade.cpp | 3 +- stepmania/src/Grade.h | 2 +- stepmania/src/HoldJudgement.cpp | 2 +- stepmania/src/IniFile.cpp | 60 +- stepmania/src/IniFile.h | 4 +- stepmania/src/Judgement.cpp | 2 +- stepmania/src/MenuElements.cpp | 176 ++++ stepmania/src/MenuElements.h | 66 ++ stepmania/src/MotionBlurSprite.h | 2 +- stepmania/src/MusicWheel.cpp | 5 +- stepmania/src/MusicWheel.h | 4 +- stepmania/src/Player.cpp | 26 +- stepmania/src/PrefsManager.cpp | 52 +- stepmania/src/PrefsManager.h | 4 +- stepmania/src/RageBitmapTexture.cpp | 148 ++-- stepmania/src/RageBitmapTexture.h | 16 +- stepmania/src/RageInput.cpp | 43 +- stepmania/src/RageInput.h | 8 +- stepmania/src/RageMovieTexture.cpp | 100 +-- stepmania/src/RageMovieTexture.h | 4 +- stepmania/src/RageSound.cpp | 13 +- stepmania/src/RageSound.h | 4 +- stepmania/src/RageTexture.cpp | 38 +- stepmania/src/RageTexture.h | 45 +- stepmania/src/RageTextureManager.cpp | 69 +- stepmania/src/RageTextureManager.h | 21 +- stepmania/src/RageUtil.cpp | 113 +-- stepmania/src/RageUtil.h | 71 +- stepmania/src/RandomSample.cpp | 13 +- stepmania/src/ScoreDisplayRolling.cpp | 3 +- stepmania/src/Song.cpp | 60 +- stepmania/src/SongManager.cpp | 9 +- stepmania/src/Sprite.cpp | 145 +-- stepmania/src/Sprite.h | 20 +- stepmania/src/StepMania.RC | 65 +- stepmania/src/StepMania.cpp | 386 ++++---- stepmania/src/StepMania.dsp | 160 +++- stepmania/src/StepMania.h | 4 +- stepmania/src/StepMania.sln | 28 + stepmania/src/StepMania.vcproj | 823 ++++++++++++++++++ stepmania/src/TextBanner.h | 2 +- stepmania/src/ThemeManager.cpp | 42 +- stepmania/src/ThemeManager.h | 24 +- stepmania/src/TipDisplay.cpp | 3 +- stepmania/src/Transition.h | 4 +- stepmania/src/TransitionFade.cpp | 2 +- stepmania/src/TransitionFade.h | 2 +- stepmania/src/TransitionFadeWipe.h | 2 +- stepmania/src/TransitionInvisible.h | 2 +- stepmania/src/TransitionKeepAlive.cpp | 42 + stepmania/src/TransitionKeepAlive.h | 34 + stepmania/src/TransitionStarWipe.cpp | 7 +- stepmania/src/TransitionStarWipe.h | 2 +- stepmania/src/log.txt | 0 .../src/smpackage/ZipArchive/ZipArchive.dsp | 2 +- 72 files changed, 2726 insertions(+), 1321 deletions(-) create mode 100644 stepmania/src/Font.cpp create mode 100644 stepmania/src/Font.h create mode 100644 stepmania/src/FontManager.cpp create mode 100644 stepmania/src/FontManager.h create mode 100644 stepmania/src/MenuElements.cpp create mode 100644 stepmania/src/MenuElements.h create mode 100644 stepmania/src/StepMania.sln create mode 100644 stepmania/src/StepMania.vcproj create mode 100644 stepmania/src/TransitionKeepAlive.cpp create mode 100644 stepmania/src/TransitionKeepAlive.h create mode 100644 stepmania/src/log.txt diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index e088d5606d..de16e4a8a8 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -12,6 +12,7 @@ #include "Actor.h" #include #include "RageScreen.h" +#include "PrefsManager.h" Actor::Actor() @@ -22,6 +23,25 @@ Actor::Actor() m_scale = m_start_scale = D3DXVECTOR2( 1, 1 ); for(int i=0; i<4; i++) m_colorDiffuse[i] = m_start_colorDiffuse[i] = D3DXCOLOR( 1, 1, 1, 1 ); m_colorAdd = m_start_colorAdd = D3DXCOLOR( 0, 0, 0, 0 ); + + m_HorizAlign = align_center; + m_VertAlign = align_middle; + + m_Effect = no_effect ; + m_fPercentBetweenColors = 0.0f; + m_bTweeningTowardEndColor = true; + m_fDeltaPercentPerSecond = 1.0f; + m_fWagRadians = 0.2f; + m_fWagPeriod = 2.0f; + m_fWagTimer = 0.0f; + m_fSpinSpeed = 2.0f; + m_fVibrationDistance = 5.0f; + m_bVisibleThisFrame = FALSE; + + if( PREFS ) m_bShadow = PREFS->m_GraphicOptions.m_bShadows; + else m_bShadow = true; + + m_bBlendAdd = false; } @@ -29,70 +49,96 @@ void Actor::Draw() // set the world matrix and calculate actor properties, the { SCREEN->PushMatrix(); // we're actually going to do some drawing in this function + int i; - D3DXVECTOR3 pos = m_pos; - D3DXVECTOR3 rotation = m_rotation; - D3DXVECTOR2 scale = m_scale; + m_temp_pos = m_pos; + m_temp_rotation = m_rotation; + m_temp_scale = m_scale; + m_temp_colorDiffuse[4]; + for(i=0; i<4; i++) + m_temp_colorDiffuse[i] = m_colorDiffuse[i]; + m_temp_colorAdd = m_colorAdd; - // update properties based on SpriteEffects + + // + // set temporary drawing properties based on Effects + // switch( m_Effect ) { case no_effect: break; case blinking: + for(i=0; i<4; i++) + m_temp_colorDiffuse[i] = m_bTweeningTowardEndColor ? m_effect_colorDiffuse1 : m_effect_colorDiffuse2; break; case camelion: + for(i=0; i<4; i++) + m_temp_colorDiffuse[i] = m_effect_colorDiffuse1*m_fPercentBetweenColors + m_effect_colorDiffuse2*(1.0f-m_fPercentBetweenColors); break; case glowing: + m_temp_colorAdd = m_effect_colorAdd1*m_fPercentBetweenColors + m_effect_colorAdd2*(1.0f-m_fPercentBetweenColors); break; case wagging: - rotation.z = m_fWagRadians * sinf( + m_temp_rotation.z = m_fWagRadians * sinf( (m_fWagTimer / m_fWagPeriod) // percent through wag * 2.0f * D3DX_PI ); break; case spinning: - // nothing special needed + ASSERT( false ); // ugh. What was here before! break; case vibrating: - pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); - pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); + m_temp_pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); + m_temp_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++) + m_temp_colorDiffuse[i] = D3DXCOLOR(0,0,0,0); // don't draw the frame break; case bouncing: + { float fPercentThroughBounce = m_fTimeIntoBounce / m_fBouncePeriod; float fPercentOffset = sinf( fPercentThroughBounce*D3DX_PI ); - pos += m_vectBounce * fPercentOffset; + m_temp_pos += m_vectBounce * fPercentOffset; + } break; + default: + ASSERT( false ); // invalid Effect } + + - SCREEN->Translate( pos.x, pos.y, pos.z ); // offset so that pixels are aligned to texels - SCREEN->Scale( scale.x, scale.y, 1 ); + SCREEN->Translate( m_temp_pos.x, m_temp_pos.y, m_temp_pos.z ); // offset so that pixels are aligned to texels + SCREEN->Scale( m_temp_scale.x, m_temp_scale.y, 1 ); // super slow! // D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation // matNewWorld = matTemp * matNewWorld; // replace with... - if( rotation.z != 0 ) + if( m_temp_rotation.z != 0 ) { - SCREEN->RotateZ( rotation.z ); + SCREEN->RotateZ( m_temp_rotation.z ); + } + if( m_temp_rotation.y != 0 ) + { + SCREEN->RotateY( m_temp_rotation.y ); } - this->RenderPrimitives(); + this->RenderPrimitives(); // call the most-derived version of RenderPrimitives(); SCREEN->PopMatrix(); - } void Actor::Update( float fDeltaTime ) { -// RageLog( "Actor::Update( %f )", fDeltaTime ); +// HELPER.Log( "Actor::Update( %f )", fDeltaTime ); // update effect switch( m_Effect ) @@ -117,7 +163,7 @@ void Actor::Update( float fDeltaTime ) m_bTweeningTowardEndColor = TRUE; } } - //RageLog( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors ); + //HELPER.Log( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors ); break; case wagging: m_fWagTimer += fDeltaTime; diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index ad090059bf..f8d57141cc 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -157,6 +157,14 @@ public: Effect GetEffect() { return m_Effect; }; + // other properties + void TurnShadowOn() { m_bShadow = true; }; + void TurnShadowOff() { m_bShadow = false; }; + + void SetBlendModeAdd() { m_bBlendAdd = true; }; + void SetBlendModeNormal() { m_bBlendAdd = false; }; + + protected: D3DXVECTOR2 m_size; // width, height @@ -166,8 +174,9 @@ protected: D3DXCOLOR m_colorDiffuse[4]; // 4 corner colors - left to right, top to bottom D3DXCOLOR m_colorAdd; - - // tweening + // + // Stuff for tweening + // D3DXVECTOR3 m_start_pos; D3DXVECTOR3 m_start_rotation; D3DXVECTOR2 m_start_scale; @@ -202,17 +211,31 @@ protected: TweenState& GetLatestTween() { return m_QueuedTweens[m_QueuedTweens.GetSize()-1]; }; - // alignment + // + // Temporary variables that are filled just before drawing + // + D3DXVECTOR2 m_temp_size; + D3DXVECTOR3 m_temp_pos; + D3DXVECTOR3 m_temp_rotation; + D3DXVECTOR2 m_temp_scale; + D3DXCOLOR m_temp_colorDiffuse[4]; + D3DXCOLOR m_temp_colorAdd; + + + // + // Stuff for alignment + // HorizAlign m_HorizAlign; VertAlign m_VertAlign; - // effect + // + // Stuff for effects + // Effect m_Effect; - // Counting variables for sprite effects: - // camelion and glowing: + // Counting variables for camelion and glowing: D3DXCOLOR m_effect_colorDiffuse1; D3DXCOLOR m_effect_colorDiffuse2; D3DXCOLOR m_effect_colorAdd1; @@ -240,6 +263,13 @@ protected: float m_fBouncePeriod; float m_fTimeIntoBounce; + + // + // other properties + // + bool m_bShadow; + bool m_bBlendAdd; + }; diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 2d190287ed..3585ae91e0 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -23,7 +23,7 @@ void ActorFrame::RenderPrimitives() void ActorFrame::Update( float fDeltaTime ) { -// RageLog( "ActorFrame::Update( %f )", fDeltaTime ); +// HELPER.Log( "ActorFrame::Update( %f )", fDeltaTime ); Actor::Update( fDeltaTime ); diff --git a/stepmania/src/ArrowEffects.cpp b/stepmania/src/ArrowEffects.cpp index a8f0f4f4d6..0adeef3d9f 100644 --- a/stepmania/src/ArrowEffects.cpp +++ b/stepmania/src/ArrowEffects.cpp @@ -81,6 +81,9 @@ float ArrowGetAlpha( const PlayerOptions& po, float fYPos ) case PlayerOptions::APPEARANCE_STEALTH: fAlpha = 0; break; + default: + ASSERT( false ); + fAlpha = 0; }; if( fYPos < 0 ) fAlpha = 1; diff --git a/stepmania/src/BPMDisplay.h b/stepmania/src/BPMDisplay.h index fe7546313a..30443bf684 100644 --- a/stepmania/src/BPMDisplay.h +++ b/stepmania/src/BPMDisplay.h @@ -17,7 +17,7 @@ #include "Song.h" #include "ActorFrame.h" #include "BitmapText.h" -#include "Rectangle.h" +#include "RectangleActor.h" class BPMDisplay : public ActorFrame diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 41add195db..5c41ed6ddd 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -38,7 +38,7 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations ) if( pSong->HasBackgroundMovie() ) { // load the movie backgound, and don't load a visualization - m_sprSongBackground.Load( pSong->HasBackground() ); + m_sprSongBackground.Load( pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND) ); m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_sprSongBackground.SetZoomY( -1 ); m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); @@ -47,8 +47,8 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations ) else { // load the static background (if available), and a visualization - if( pSong->HasBackground() ) m_sprSongBackground.Load( pSong->GetBackgroundPath(), HINT_DITHER ); - else m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), HINT_DITHER ); + if( pSong->HasBackground() ) m_sprSongBackground.Load( pSong->GetBackgroundPath(), TEXTURE_HINT_DITHER ); + else m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), TEXTURE_HINT_DITHER ); m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); diff --git a/stepmania/src/Banner.cpp b/stepmania/src/Banner.cpp index ab337e46ca..1c139f9bb2 100644 --- a/stepmania/src/Banner.cpp +++ b/stepmania/src/Banner.cpp @@ -19,15 +19,15 @@ bool Banner::LoadFromSong( Song* pSong ) // NULL means no song { - if( pSong == NULL ) Banner::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER), HINT_NOMIPMAPS ); - else if( pSong->HasBanner() ) Banner::Load( pSong->GetBannerPath(), HINT_NOMIPMAPS ); - else if( pSong->HasBackground() ) Banner::Load( pSong->GetBackgroundPath(), HINT_NOMIPMAPS ); - else Banner::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER), HINT_NOMIPMAPS ); + if( pSong == NULL ) Banner::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER), TEXTURE_HINT_NOMIPMAPS ); + else if( pSong->HasBanner() ) Banner::Load( pSong->GetBannerPath(), TEXTURE_HINT_NOMIPMAPS ); + else if( pSong->HasBackground() ) Banner::Load( pSong->GetBackgroundPath(), TEXTURE_HINT_NOMIPMAPS ); + else Banner::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER), TEXTURE_HINT_NOMIPMAPS ); return true; } -bool Banner::Load( CString sFilePath, DWORD dwHints, bool bForceReload ) +bool Banner::Load( const CString &sFilePath, DWORD dwHints, bool bForceReload ) { Sprite::Load( sFilePath, dwHints, bForceReload ); CropToRightSize(); @@ -39,14 +39,14 @@ void Banner::CropToRightSize() { Sprite::TurnShadowOff(); - int iImageWidth = m_pTexture->GetImageWidth(); - int iImageHeight = m_pTexture->GetImageHeight(); + int iSourceWidth = m_pTexture->GetSourceWidth(); + int iSourceHeight = m_pTexture->GetSourceHeight(); // save the original X&Y. We're going to resore them later. float fOriginalX = GetX(); float fOriginalY = GetY(); - if( iImageWidth == iImageHeight ) // this is a SSR/DWI StyleDef banner + if( iSourceWidth == iSourceHeight ) // this is a SSR/DWI banner { float fCustomImageCoords[8] = { 0.22f, 0.98f, // bottom left diff --git a/stepmania/src/Banner.h b/stepmania/src/Banner.h index 4fa9061376..e4e57bc6d9 100644 --- a/stepmania/src/Banner.h +++ b/stepmania/src/Banner.h @@ -16,15 +16,15 @@ #include "Song.h" -const float BANNER_WIDTH = 264; -const float BANNER_HEIGHT = 86; +const float BANNER_WIDTH = 250; +const float BANNER_HEIGHT = 100; class Banner : public Sprite { public: bool LoadFromSong( Song* pSong ); // NULL means no Song - virtual bool Load( CString sFilePath, DWORD dwHints = 0, bool bForceReload = false ); + virtual bool Load( const CString &sFilePath, DWORD dwHints = 0, bool bForceReload = false ); protected: void CropToRightSize(); diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index f3196f59b0..cb73a2f918 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -1,160 +1,52 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - File: BitmapText.h + File: BitmapText - Desc: A font class that draws characters from a bitmap. + Desc: See header. - Copyright (c) 2001 Chris Danford. All rights reserved. + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ #include "BitmapText.h" #include "IniFile.h" -#include -#include "RageTextureManager.h" - +#include "FontManager.h" +#include "RageHelper.h" BitmapText::BitmapText() { -// m_colorTop = D3DXCOLOR(1,1,1,1); -// m_colorBottom = D3DXCOLOR(1,1,1,1); - - for( int i=0; iGetDevice()->CreateVertexBuffer( - MAX_NUM_VERTICIES * sizeof(CUSTOMVERTEX), - D3DUSAGE_WRITEONLY, - D3DFVF_CUSTOMVERTEX, - D3DPOOL_MANAGED, - &m_pVB ); - - if( FAILED( hr ) ) - { - RageErrorHr( "Vertex Buffer Could Not Be Created", hr ); - } + m_iNumLines = 0; + m_iWidestLineWidth = 0; m_iNumV = 0; + + for( int i=0; iUnloadFont( m_pFont->m_sFontFilePath ); } -bool BitmapText::Load( CString sFontFilePath ) +bool BitmapText::Load( const CString &sFontFilePath ) { - //RageLog( "BitmapText::LoadFromFontName(%s)", sFontFilePath ); - - m_sFontFilePath = sFontFilePath; // save + HELPER.Log( "BitmapText::LoadFromFontName(%s)", sFontFilePath ); - - // Split for the directory. We'll need it below - CString sFontDir, sFontFileName, sFontExtension; - splitrelpath( sFontFilePath, sFontDir, sFontFileName, sFontExtension ); - - - - // Read .font file - IniFile ini; - ini.SetPath( m_sFontFilePath ); - if( !ini.ReadFile() ) - RageError( ssprintf("Error opening Font file '%s'.", m_sFontFilePath) ); - - - - // load texture - CString sTextureFile = ini.GetValue( "Font", "Texture" ); - if( sTextureFile == "" ) - RageError( ssprintf("Error reading value 'Texture' from %s.", m_sFontFilePath) ); - - - CString sTexturePath = sFontDir + sTextureFile; // save the path of the new texture - - // is this the first time the texture is being loaded? - bool bFirstTimeBeingLoaded = !TM->IsTextureLoaded( sTexturePath ); - - LoadTexture( sTexturePath ); - - // the size of the sprite is the size of the image before it was scaled - SetWidth( (float)m_pTexture->GetSourceFrameWidth() ); - SetHeight( (float)m_pTexture->GetSourceFrameHeight() ); - - - - // find out what characters are in this font - CString sCharacters = ini.GetValue( "Font", "Characters" ); - if( sCharacters != "" ) // the creator supplied characters - { - // sanity check - if( sCharacters.GetLength() != (int)Sprite::GetNumStates() ) - RageError( ssprintf("The characters in '%s' does not match the number of frames in the texture.", m_sFontFilePath) ); - - // set the char to frameno map - for( int i=0; iGetSourceFrameWidth(); - } - } - - - if( bFirstTimeBeingLoaded ) - { - // tweak the textures frame rectangles so we don't draw extra to the left and right of the character - for( int i=0; i<(int)Sprite::GetNumStates(); i++ ) - { - FRECT* pFrect = m_pTexture->GetTextureCoordRect( i ); - - float fPixelsToChopOff = m_fFrameNoToWidth[i] - GetUnzoomedWidth(); - float fTexCoordsToChopOff = fPixelsToChopOff / m_pTexture->GetSourceWidth(); - - pFrect->left -= fTexCoordsToChopOff/2; - pFrect->right += fTexCoordsToChopOff/2; - } - } + // load font + m_pFont = FONT->LoadFont( sFontFilePath ); return true; } @@ -162,126 +54,141 @@ bool BitmapText::Load( CString sFontFilePath ) -// get a rectangle for the text, considering a possible text scaling. -// useful to know if some text is visible or not -float BitmapText::GetWidestLineWidthInSourcePixels() +void BitmapText::SetText( const CString &sText ) { - float fWidestLineWidth = 0; + // + // save the string and crop if necessary + // + strncpy( m_szText, sText, MAX_TEXT_CHARS ); + m_szText[MAX_TEXT_CHARS-1] = '\0'; - for( int i=0; i fWidestLineWidth ) - fWidestLineWidth = fLineWidth; + if( m_szText[i] < 0 || m_szText[i] > MAX_FONT_CHARS-1 ) + m_szText[i] = ' '; } - return fWidestLineWidth; -} + // + // break the string into lines + // + m_iNumLines = 0; + LPSTR token; - -float BitmapText::GetLineWidthInSourcePixels( int iLineNo ) -{ - CString &sLine = m_sTextLines[iLineNo]; - - float fLineWidth = 0; + /* Establish string and get the first token: */ + token = strtok( m_szText, "\n" ); + while( token != NULL ) + { + m_szTextLines[m_iNumLines++] = token; + token = strtok( NULL, "\n" ); + } - for( int i=0; iGetLineWidthInSourcePixels( m_szTextLines[l], m_iLineLengths[l] ); + if( m_iLineWidths[l] > m_iWidestLineWidth ) + m_iWidestLineWidth = m_iLineWidths[l]; } - - return fLineWidth; } + + void BitmapText::RebuildVertexBuffer() { + RageTexture* pTexture = m_pFont->m_pTexture; + + + + + + + + + // make the object in logical units centered at the origin - LPDIRECT3DVERTEXBUFFER8 pVB = m_pVB; + LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer(); CUSTOMVERTEX* v; pVB->Lock( 0, 0, (BYTE**)&v, 0 ); - m_iNumV = 0; // the current vertex number - float fHeight = GetUnzoomedHeight(); - float fY; // the center of the first line + const int iHeight = pTexture->GetSourceFrameHeight(); // height of a character + const int iFrameWidth = pTexture->GetSourceFrameWidth(); // width of a character frame in logical units + + int iY; // the center position of the first row of characters switch( m_VertAlign ) { - case align_top: fY = -(m_sTextLines.GetSize()-1) * fHeight; break; - case align_middle: fY = -(m_sTextLines.GetSize()-1) * fHeight / 2; break; - case align_bottom: fY = 0; break; + case align_top: iY = -(m_iNumLines-1) * iHeight; break; + case align_middle: iY = -(m_iNumLines-1) * iHeight/2; break; + case align_bottom: iY = 0; break; default: ASSERT( false ); } - for( int i=0; im_iCharToFrameNo[c]; if( iFrameNo == -1 ) // this font doesn't impelemnt this character - RageError( ssprintf("The font '%s' does not implement the character '%c'", m_sFontFilePath, c) ); - float fCharWidth = m_fFrameNoToWidth[iFrameNo]; - - //if( c == ' ' ) - //{ - // fX += fCharWidth; - // continue; - //} - + HELPER.FatalError( ssprintf("The font '%s' does not implement the character '%c'", m_sFontFilePath, c) ); + const int iCharWidth = m_pFont->m_iFrameNoToWidth[iFrameNo]; // HACK: - // The right side of italic letters is being cropped. So, we're going to draw a little bit + // The right side of any italic letter is being cropped. So, we're going to draw a little bit // to the right of the normal character. - float fPercentExtra = 0.20f; + const float fPercentExtra = min( + 0.20f, + (iFrameWidth-iCharWidth)/(float)iFrameWidth + ); - // don't go over the frame boundary and draw part of the adjacent character - float fPercentageOfFrame = fCharWidth / GetUnzoomedWidth(); - if( fPercentExtra > 1-fPercentageOfFrame ) - fPercentExtra = 1-fPercentageOfFrame; - - float fExtraPixels = fPercentExtra * GetUnzoomedWidth(); + const float fExtraPixels = fPercentExtra * pTexture->GetSourceFrameWidth(); // first triangle - v[m_iNumV++].p = D3DXVECTOR3( fX, fY-fHeight/2, 0 ); // top left - v[m_iNumV++].p = D3DXVECTOR3( fX, fY+fHeight/2, 0 ); // bottom left - fX += fCharWidth; - v[m_iNumV++].p = D3DXVECTOR3( fX+fExtraPixels, fY-fHeight/2, 0 ); // top right + v[m_iNumV++].p = D3DXVECTOR3( (float)iX, iY-iHeight/2.0f, 0 ); // top left + v[m_iNumV++].p = D3DXVECTOR3( (float)iX, iY+iHeight/2.0f, 0 ); // bottom left + iX += iCharWidth; + v[m_iNumV++].p = D3DXVECTOR3( iX+fExtraPixels, iY-iHeight/2.0f, 0 ); // top right // 2nd triangle v[m_iNumV++].p = v[m_iNumV-1].p; // top right v[m_iNumV++].p = v[m_iNumV-3].p; // bottom left - v[m_iNumV++].p = D3DXVECTOR3( fX+fExtraPixels, fY+fHeight/2, 0 ); // bottom right + v[m_iNumV++].p = D3DXVECTOR3( iX+fExtraPixels, iY+iHeight/2.0f, 0 ); // bottom right // set texture coordinates m_iNumV -= 6; - FRECT* pTexCoordRect = m_pTexture->GetTextureCoordRect( iFrameNo ); + FRECT* pTexCoordRect = pTexture->GetTextureCoordRect( iFrameNo ); - float fExtraTexCoords = fPercentExtra * m_pTexture->GetTextureFrameWidth() / m_pTexture->GetTextureWidth(); + const float fExtraTexCoords = fPercentExtra * pTexture->GetTextureFrameWidth() / pTexture->GetTextureWidth(); v[m_iNumV].tu = pTexCoordRect->left; v[m_iNumV++].tv = pTexCoordRect->top; // top left v[m_iNumV].tu = pTexCoordRect->left; v[m_iNumV++].tv = pTexCoordRect->bottom; // bottom left @@ -290,84 +197,46 @@ void BitmapText::RebuildVertexBuffer() v[m_iNumV].tu = v[m_iNumV-3].tu; v[m_iNumV++].tv = v[m_iNumV-3].tv; // bottom left v[m_iNumV].tu = pTexCoordRect->right + fExtraTexCoords; v[m_iNumV++].tv = pTexCoordRect->bottom; // bottom right - +/* + v[m_iNumV].tu = 0.0f; v[m_iNumV++].tv = 1.0f-1.0f/16; // top left + v[m_iNumV].tu = 0.0f; v[m_iNumV++].tv = 1.0f; // bottom left + v[m_iNumV].tu = 1.0f/16; v[m_iNumV++].tv = 1.0f-1.0f/16; // top right + v[m_iNumV].tu = 1.0f/16; v[m_iNumV++].tv = 1.0f-1.0f/16; // top right + v[m_iNumV].tu = 0.0f; v[m_iNumV++].tv = 1.0f; // bottom left + v[m_iNumV].tu = 1.0f/16; v[m_iNumV++].tv = 1.0f; // bottom right +*/ } - fY += fHeight; + iY += iHeight; } pVB->Unlock(); - } // draw text at x, y using colorTop blended down to colorBottom, with size multiplied by scale void BitmapText::RenderPrimitives() { - if( m_sTextLines.GetSize() == 0 ) + if( m_iNumLines == 0 ) return; - if( m_pTexture == NULL ) - return; - - - - 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_effect_colorDiffuse1 : m_effect_colorDiffuse2; - } - break; - case camelion: - { - for(int i=0; i<4; i++) - colorDiffuse[i] = m_effect_colorDiffuse1*m_fPercentBetweenColors + m_effect_colorDiffuse2*(1.0f-m_fPercentBetweenColors); - } - break; - case glowing: - colorAdd = m_effect_colorAdd1*m_fPercentBetweenColors + m_effect_colorAdd2*(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; - } - - + RageTexture* pTexture = m_pFont->m_pTexture; + // fill the RageScreen's vertex buffer with what we're going to draw RebuildVertexBuffer(); - LPDIRECT3DVERTEXBUFFER8 pVB = m_pVB; + LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer(); CUSTOMVERTEX* v; // Set the stage... LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); - pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() ); + pd3dDevice->SetTexture( 0, pTexture->GetD3DTexture() ); pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); @@ -381,12 +250,12 @@ void BitmapText::RenderPrimitives() - if( colorDiffuse[0].a != 0 ) + if( m_temp_colorDiffuse[0].a != 0 ) { ////////////////////// // render the shadow ////////////////////// - if( m_bHasShadow ) + if( m_bShadow ) { SCREEN->PushMatrix(); SCREEN->Translate( 5, 5, 0 ); // shift by 5 units @@ -394,7 +263,7 @@ void BitmapText::RenderPrimitives() pVB->Lock( 0, 0, (BYTE**)&v, 0 ); for( int i=0; iUnlock(); @@ -419,9 +288,9 @@ void BitmapText::RenderPrimitives() for( int i=0; iLock( 0, 0, (BYTE**)&v, 0 ); for( int i=0; iUnlock(); @@ -461,28 +330,4 @@ void BitmapText::RenderPrimitives() pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_iNumV/3 ); } -} - -void BitmapText::SetText( CString sText ) -{ - if( sText.GetLength() > MAX_NUM_VERTICIES ) - sText = sText.Left( MAX_NUM_VERTICIES ); - - // strip out foreign chars - for( int i=0; i NUM_CHARS-1 ) - sText.SetAt( i, ' ' ); - - - m_sTextLines.RemoveAll(); - split( sText, "\n", m_sTextLines, false ); - - - RebuildVertexBuffer(); -} - -CString BitmapText::GetText() -{ - return join( "\n", m_sTextLines ); -} - +} \ No newline at end of file diff --git a/stepmania/src/BitmapText.h b/stepmania/src/BitmapText.h index 3ee01e2b9a..e9dc88b695 100644 --- a/stepmania/src/BitmapText.h +++ b/stepmania/src/BitmapText.h @@ -1,10 +1,11 @@ /* ----------------------------------------------------------------------------- - File: BitmapText.h + File: BitmapText - Desc: A font class that draws characters from a bitmap. + Desc: An actor that holds a Font and draws text to the screen. - Copyright (c) 2001 Chris Danford. All rights reserved. + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ @@ -13,13 +14,13 @@ #include "Sprite.h" -#include "BitmapText.h" +#include "Font.h" -const int NUM_CHARS = 256; +const int MAX_TEXT_LINES = 20; +const int MAX_TEXT_CHARS = MAX_NUM_QUADS; - -class BitmapText : public Sprite +class BitmapText : public Actor { protected: @@ -27,31 +28,30 @@ public: BitmapText(); ~BitmapText(); + + bool Load( const CString &sFontName ); + void SetText( const CString &sText ); + + int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; }; + + void RebuildVertexBuffer(); // fill the RageScreen's vertex buffer with what we're going to draw virtual void RenderPrimitives(); - bool Load( CString sFontName ); - void SetText( CString sText ); - CString GetText(); - - bool LoadFontWidths( CString sFilePath ); - - float GetWidestLineWidthInSourcePixels(); // in logical, pre-zoomed units - float GetLineWidthInSourcePixels( int iLineNo ); protected: - bool LoadCharWidths( CString sWidthFilePath ); - // a vertex buffer for all to share - CString m_sFontFilePath; - int m_iCharToFrameNo[NUM_CHARS]; - float m_fFrameNoToWidth[NUM_CHARS]; // in soure coordinate space + Font* m_pFont; - - LPDIRECT3DVERTEXBUFFER8 m_pVB; // our vertex buffer only needs to be rebuilt when the text changes - int m_iNumV; // number of verticies used in the vertex buffer - void RebuildVertexBuffer(); // this should be called when the text changes + // recalculate the items below on SetText() + TCHAR m_szText[MAX_TEXT_CHARS]; + TCHAR* m_szTextLines[MAX_TEXT_LINES]; // pointers into m_szText + int m_iLineLengths[MAX_TEXT_LINES]; // in characters + int m_iNumLines; + int m_iLineWidths[MAX_TEXT_LINES]; // in source pixels + int m_iWidestLineWidth; // in source pixels - CStringArray m_sTextLines; + // recalculate on RebuildVertexBuffer() + int m_iNumV; // number of verticies we filled in the vertex buffer }; diff --git a/stepmania/src/DifficultyIcon.h b/stepmania/src/DifficultyIcon.h index 13982b526a..49443868e2 100644 --- a/stepmania/src/DifficultyIcon.h +++ b/stepmania/src/DifficultyIcon.h @@ -46,25 +46,18 @@ public: private: - void SetFromDescription( CString sDescription ) + void SetFromDescription( const CString &sDescription ) { - sDescription.MakeLower(); - if( sDescription.Find( "basic" ) != -1 ) - SetState( 0 ); - else if( sDescription.Find( "trick" ) != -1 ) - SetState( 1 ); - else if( sDescription.Find( "another" ) != -1 ) - SetState( 2 ); - else if( sDescription.Find( "maniac" ) != -1 ) - SetState( 3 ); - else if( sDescription.Find( "ssr" ) != -1 ) - SetState( 4 ); - else if( sDescription.Find( "battle" ) != -1 ) - SetState( 5 ); - else if( sDescription.Find( "couple" ) != -1 ) - SetState( 6 ); - else - SetState( 7 ); + CString sTemp = sDescription; + sTemp.MakeLower(); + if( sTemp.Find( "basic" ) != -1 ) SetState( 0 ); + else if( sTemp.Find( "trick" ) != -1 ) SetState( 1 ); + else if( sTemp.Find( "another" ) != -1 ) SetState( 2 ); + else if( sTemp.Find( "maniac" ) != -1 ) SetState( 3 ); + else if( sTemp.Find( "ssr" ) != -1 ) SetState( 4 ); + else if( sTemp.Find( "battle" ) != -1 ) SetState( 5 ); + else if( sTemp.Find( "couple" ) != -1 ) SetState( 6 ); + else SetState( 7 ); }; }; diff --git a/stepmania/src/FocusingSprite.h b/stepmania/src/FocusingSprite.h index 28f2e94c68..62f76dfab9 100644 --- a/stepmania/src/FocusingSprite.h +++ b/stepmania/src/FocusingSprite.h @@ -22,7 +22,7 @@ public: FocusingSprite(); - virtual bool Load( CString sFilePath ) + virtual bool Load( const CString &sFilePath ) { for( int i=0; i<3; i++ ) m_sprites[i].Load( sFilePath ); diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp new file mode 100644 index 0000000000..85934a5efb --- /dev/null +++ b/stepmania/src/Font.cpp @@ -0,0 +1,166 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: Font + + Desc: See header. + + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Font.h" +#include "IniFile.h" +#include +#include "RageTextureManager.h" +#include "RageUtil.h" +#include "RageHelper.h" + + +Font::Font( const CString &sFontFilePath ) +{ + //HELPER.Log( "Font::LoadFromFontName(%s)", sFontFilePath ); + for( int i=0; iIsTextureLoaded( m_sTexturePath ); + + + m_pTexture = TEXTURE->LoadTexture( m_sTexturePath, 0, false ); + assert( m_pTexture != NULL ); + + + // + // find out what characters are in this font + // + CString sCharacters = ini.GetValue( "Font", "Characters" ); + if( sCharacters != "" ) // the creator supplied characters + { + // sanity check + if( sCharacters.GetLength() != (int)m_pTexture->GetNumFrames() ) + HELPER.FatalError( ssprintf("The characters in '%s' does not match the number of frames in the texture.", m_sFontFilePath) ); + + // set the char to frame number map + for( int i=0; iGetNumFrames() ) + HELPER.FatalError( ssprintf("The number of widths specified in '%s' (%d) do not match the number of frames in the texture (%u).", m_sFontFilePath, arrayCharWidths.GetSize(), m_pTexture->GetNumFrames()) ); + + for( int i=0; iGetNumFrames(); i++ ) + { + m_iFrameNoToWidth[i] = m_pTexture->GetSourceFrameWidth(); + } + } + + + // + // Tweak the textures frame rectangles so we don't draw extra + // to the left and right of the character, saving us fill rate. + // + if( bFirstTimeBeingLoaded ) + { + for( int i=0; i<(int)m_pTexture->GetNumFrames(); i++ ) + { + FRECT* pFrect = m_pTexture->GetTextureCoordRect( i ); + + float fPixelsToChopOff = (float)m_iFrameNoToWidth[i] - m_pTexture->GetSourceFrameWidth(); + float fTexCoordsToChopOff = fPixelsToChopOff / m_pTexture->GetSourceWidth(); + + pFrect->left -= fTexCoordsToChopOff/2; + pFrect->right += fTexCoordsToChopOff/2; + } + } + +} + + +Font::~Font() +{ + if( m_pTexture != NULL ) + TEXTURE->UnloadTexture( m_sTexturePath ); +} + + +int Font::GetLineWidthInSourcePixels( LPCTSTR szLine, int iLength ) +{ + int iLineWidth = 0; + + for( int i=0; im_iRefCount ); + SAFE_DELETE( pFont ); + } + + m_mapPathToFont.RemoveAll(); +} + + +//----------------------------------------------------------------------------- +// Load/Unload textures from disk +//----------------------------------------------------------------------------- +Font* FontManager::LoadFont( CString sFontFilePath ) +{ + sFontFilePath.MakeLower(); + +// HELPER.Log( "FontManager::LoadFont(%s).", sFontFilePath ); + + + // Convert the path to lowercase so that we don't load duplicates. + // Really, this does not solve the duplicate problem. We could have to copies + // of the same bitmap if there are equivalent but different paths + // (e.g. "graphics\blah.png" and "..\stepmania\graphics\blah.png" ). + + Font* pFont = NULL; + + if( m_mapPathToFont.Lookup( sFontFilePath, pFont ) ) // if the texture already exists in the map + { + HELPER.Log( ssprintf("FontManager: The Font '%s' now has %d references.", sFontFilePath, pFont->m_iRefCount) ); + pFont->m_iRefCount++; + } + else // the texture is not already loaded + { + CString sDrive, sDir, sFName, sExt; + splitpath( FALSE, sFontFilePath, sDrive, sDir, sFName, sExt ); + + pFont = (Font*) new Font( sFontFilePath ); + + HELPER.Log( "FontManager: Loading '%s' from disk.", sFontFilePath); + + m_mapPathToFont.SetAt( sFontFilePath, pFont ); + } + + return pFont; +} + + +bool FontManager::IsFontLoaded( CString sFontFilePath ) +{ + sFontFilePath.MakeLower(); + + Font* pFont; + + if( m_mapPathToFont.Lookup( sFontFilePath, pFont ) ) // if the texture exists in the map + return true; + else + return false; +} + +void FontManager::UnloadFont( CString sFontFilePath ) +{ + sFontFilePath.MakeLower(); + +// HELPER.Log( "FontManager::UnloadTexture(%s).", sFontFilePath ); + + if( sFontFilePath == "" ) + { + HELPER.Log( "FontManager::UnloadTexture(): tried to Unload a blank" ); + return; + } + + Font* pFont; + + if( m_mapPathToFont.Lookup( sFontFilePath, pFont ) ) // if the texture exists in the map + { + pFont->m_iRefCount--; + if( pFont->m_iRefCount == 0 ) // there are no more references to this texture + { + HELPER.Log( ssprintf("FontManager: '%s' will be deleted. It has %d references.", sFontFilePath, pFont->m_iRefCount) ); + SAFE_DELETE( pFont ); // free the texture + m_mapPathToFont.RemoveKey( sFontFilePath ); // and remove the key in the map + } + else + { + HELPER.Log( ssprintf("FontManager: '%s' will not be deleted. It still has %d references.", sFontFilePath, pFont->m_iRefCount) ); + } + + } + else // lookup failed + { + HELPER.FatalError( ssprintf("Tried to Unload a font that wasn't loaded. '%s'", sFontFilePath) ); + } + +} diff --git a/stepmania/src/FontManager.h b/stepmania/src/FontManager.h new file mode 100644 index 0000000000..480b3307c2 --- /dev/null +++ b/stepmania/src/FontManager.h @@ -0,0 +1,39 @@ +/* +----------------------------------------------------------------------------- + Class: FontManager + + Desc: Manages Loading and Unloading of fonts. + + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#ifndef _FontManager_H_ +#define _FontManager_H_ + + +#include "Font.h" + + +//----------------------------------------------------------------------------- +// FontManager Class Declarations +//----------------------------------------------------------------------------- +class FontManager +{ +public: + FontManager(); + ~FontManager(); + + Font* LoadFont( CString sFontPath ); + bool IsFontLoaded( CString sFontPath ); + void UnloadFont( CString sFontPath ); + +protected: + // map from file name to a texture holder + CTypedPtrMap m_mapPathToFont; +}; + +extern FontManager* FONT; // global and accessable from anywhere in our program + +#endif diff --git a/stepmania/src/FootMeter.h b/stepmania/src/FootMeter.h index 1509a6643c..68cfef60cf 100644 --- a/stepmania/src/FootMeter.h +++ b/stepmania/src/FootMeter.h @@ -45,7 +45,7 @@ public: private: - void SetNumFeet( int iNumFeet, CString sDescription ) + void SetNumFeet( int iNumFeet, const CString &sDescription ) { CString sNewText; for( int f=0; f<=9; f++ ) @@ -56,25 +56,16 @@ private: SetText( sNewText ); - - sDescription.MakeLower(); - if( sDescription.Find( "basic" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(1,1,0,1) ); - else if( sDescription.Find( "trick" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(1,0,0,1) ); - else if( sDescription.Find( "another" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(1,0,0,1) ); - else if( sDescription.Find( "maniac" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(0,1,0,1) ); - else if( sDescription.Find( "ssr" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(0,1,0,1) ); - else if( sDescription.Find( "battle" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); - else if( sDescription.Find( "couple" ) != -1 ) - SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); - else - SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0.8f,1) ); - + CString sTemp = sDescription; + sTemp.MakeLower(); + if( sTemp.Find( "basic" ) != -1 ) SetDiffuseColor( D3DXCOLOR(1,1,0,1) ); + else if( sTemp.Find( "trick" ) != -1 ) SetDiffuseColor( D3DXCOLOR(1,0,0,1) ); + else if( sTemp.Find( "another" ) != -1 )SetDiffuseColor( D3DXCOLOR(1,0,0,1) ); + else if( sTemp.Find( "maniac" ) != -1 ) SetDiffuseColor( D3DXCOLOR(0,1,0,1) ); + else if( sTemp.Find( "ssr" ) != -1 ) SetDiffuseColor( D3DXCOLOR(0,1,0,1) ); + else if( sTemp.Find( "battle" ) != -1 ) SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); + else if( sTemp.Find( "couple" ) != -1 ) SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); + else SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0.8f,1) ); }; }; diff --git a/stepmania/src/Grade.cpp b/stepmania/src/Grade.cpp index 8351df03a4..b51e1a5104 100644 --- a/stepmania/src/Grade.cpp +++ b/stepmania/src/Grade.cpp @@ -28,8 +28,9 @@ CString GradeToString( Grade g ) } }; -Grade StringToGrade( CString s ) +Grade StringToGrade( const CString &sGrade ) { + CString s = sGrade; s.MakeUpper(); if ( s == "AAA" ) return GRADE_AAA; else if( s == "AA" ) return GRADE_AA; diff --git a/stepmania/src/Grade.h b/stepmania/src/Grade.h index ff98e26d35..a52d18b226 100644 --- a/stepmania/src/Grade.h +++ b/stepmania/src/Grade.h @@ -19,7 +19,7 @@ enum Grade { GRADE_NO_DATA=0, GRADE_E, GRADE_D, GRADE_C, GRADE_B, GRADE_A, GRADE_AA, GRADE_AAA }; CString GradeToString( Grade g ); -Grade StringToGrade( CString s ); +Grade StringToGrade( const CString &s ); diff --git a/stepmania/src/HoldJudgement.cpp b/stepmania/src/HoldJudgement.cpp index c9e33d4271..a286d21963 100644 --- a/stepmania/src/HoldJudgement.cpp +++ b/stepmania/src/HoldJudgement.cpp @@ -45,7 +45,7 @@ void HoldJudgement::RenderPrimitives() void HoldJudgement::SetHoldJudgement( HoldNoteResult result ) { - //RageLog( "Judgement::SetJudgement()" ); + //HELPER.Log( "Judgement::SetJudgement()" ); switch( result ) { diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index 5bb4b8f121..8f18f77ffb 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -10,7 +10,6 @@ #include "stdafx.h" #include "IniFile.h" -#include "fstream.h" ///////////////////////////////////////////////////////////////////// @@ -48,53 +47,57 @@ void IniFile::SetPath(CString newpath) //returns true if successful, false otherwise BOOL IniFile::ReadFile() { - CFile file; - CFileStatus status; - if( !file.GetStatus(path,status) ) - return FALSE; - ifstream inifile; - CString readinfo; - inifile.open(path); - int curkey = -1, curval = -1; - if( inifile.fail() ) + CStdioFile file; + if( !file.Open(path, CFile::modeRead) ) { error = "Unable to open ini file."; return FALSE; } + + CString line; + int curkey = -1, curval = -1; CString keyname, valuename, value; - CString temp; - while( getline(inifile,readinfo) ) + while( file.ReadString(line) ) { - if( readinfo != "" ) + if( line != "" ) { - if( readinfo[0] == '[' && readinfo[readinfo.GetLength()-1] == ']' ) //if a section heading + if( line[0] == '[' && line[line.GetLength()-1] == ']' ) //if a section heading { - keyname = readinfo; + keyname = line; keyname.TrimLeft('['); keyname.TrimRight(']'); } else //if a value { - valuename = readinfo.Left(readinfo.Find("=")); - value = readinfo.Right(readinfo.GetLength()-valuename.GetLength()-1); + int iIndexOfEqual = line.Find("="); + if( iIndexOfEqual == -1 ) // this is a malformed line + continue; + valuename = line.Left( iIndexOfEqual ); + value = line.Right(line.GetLength()-valuename.GetLength()-1); SetValue(keyname,valuename,value); } } } - inifile.close(); + file.Close(); return 1; } //writes data stored in class to ini file void IniFile::WriteFile() { - ofstream inifile; - inifile.open(path); + CStdioFile file; + if( !file.Open(path, CFile::modeCreate | CFile::modeWrite ) ) + { + error = "Unable to open ini for writing."; + return; + } // foreach key for( int keynum = 0; keynum <= names.GetUpperBound(); keynum++ ) { - inifile << '[' << names[keynum] << ']' << endl; + CString sTemp; + sTemp.Format( "[%s]\n", names[keynum] ); + file.WriteString( sTemp ); CMapStringToString &map = keys[keynum]; @@ -105,12 +108,13 @@ void IniFile::WriteFile() CString value; map.GetNextAssoc( pos, value_name, value ); - inifile << value_name << "=" << value << endl; + sTemp.Format( "%s=%s\n", value_name, value ); + file.WriteString( sTemp ); } - inifile << endl; + file.WriteString( "\n" ); } - inifile.close(); + file.Close(); } //deletes all stored ini data @@ -269,11 +273,3 @@ int IniFile::FindKey(CString keyname) return keynum; } -//overloaded from original getline to take CString -istream & IniFile:: getline(istream & is, CString & str) -{ - char buf[2048]; - is.getline(buf,2048); - str = buf; - return is; -} diff --git a/stepmania/src/IniFile.h b/stepmania/src/IniFile.h index 4dcc65b8f5..e96d5e234a 100644 --- a/stepmania/src/IniFile.h +++ b/stepmania/src/IniFile.h @@ -13,7 +13,7 @@ #define _INIFILE_H_ #include -#include +//#include class IniFile @@ -37,8 +37,6 @@ private: //all private functions private: - //overloaded to take CString - istream & getline( istream & is, CString & str ); //returns index of specified key, or -1 if not found int FindKey(CString keyname); diff --git a/stepmania/src/Judgement.cpp b/stepmania/src/Judgement.cpp index 130f26f40a..fdc4a75f6c 100644 --- a/stepmania/src/Judgement.cpp +++ b/stepmania/src/Judgement.cpp @@ -46,7 +46,7 @@ void Judgement::RenderPrimitives() void Judgement::SetJudgement( TapNoteScore score ) { - //RageLog( "Judgement::SetJudgement()" ); + //HELPER.Log( "Judgement::SetJudgement()" ); switch( score ) { diff --git a/stepmania/src/MenuElements.cpp b/stepmania/src/MenuElements.cpp new file mode 100644 index 0000000000..a9056e454d --- /dev/null +++ b/stepmania/src/MenuElements.cpp @@ -0,0 +1,176 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + File: MenuElements.h + + Desc: Base class for menu Windows. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#include "MenuElements.h" +#include "RageTextureManager.h" +#include "RageUtil.h" +#include "RageMusic.h" +#include "WindowManager.h" +#include "WindowDancing.h" +#include "ScreenDimensions.h" +#include "ThemeManager.h" +#include "RageHelper.h" + + +const float HELP_X = CENTER_X; +const float HELP_Y = SCREEN_HEIGHT-25; + +MenuElements::MenuElements() +{ + this->AddActor( &m_sprBG ); + this->AddActor( &m_sprTopEdge ); + this->AddActor( &m_sprBottomEdge ); + this->AddActor( &m_textHelp ); + +} + +void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString sHelpText ) +{ + HELPER.Log( "MenuElements::MenuElements()" ); + + + m_sprBG.Load( sBackgroundPath ); + m_sprBG.StretchTo( CRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT) ); + m_sprBG.TurnShadowOff(); + + m_sprTopEdge.Load( sTopEdgePath ); + m_sprTopEdge.TurnShadowOff(); + m_sprTopEdge.SetZ( -1 ); + + m_sprBottomEdge.Load( THEME->GetPathTo(GRAPHIC_MENU_BOTTOM_EDGE) ); + m_sprBottomEdge.TurnShadowOff(); + m_sprBottomEdge.SetZ( -1 ); + + m_textHelp.Load( THEME->GetPathTo(FONT_NORMAL) ); + m_textHelp.SetXY( HELP_X, HELP_Y ); + m_textHelp.SetZ( -1 ); + m_textHelp.SetText( sHelpText ); + m_textHelp.SetZoom( 0.5f ); + m_textHelp.SetEffectBlinking(); + + + m_soundSwoosh.Load( THEME->GetPathTo(SOUND_MENU_SWOOSH) ); + m_soundBack.Load( THEME->GetPathTo(SOUND_MENU_BACK) ); + + + SetTopEdgeOnScreen(); + SetBackgroundOnScreen(); +} + + +void MenuElements::TweenTopEdgeOnScreen() +{ + SetTopEdgeOffScreen(); + + m_sprTopEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprTopEdge.SetTweenY( m_sprTopEdge.GetZoomedHeight()/2 ); + + float fOriginalZoomY = m_textHelp.GetZoomY(); + m_textHelp.SetZoomY( 0 ); + m_textHelp.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_textHelp.SetTweenZoomY( fOriginalZoomY ); + + m_soundSwoosh.PlayRandom(); +} + +void MenuElements::TweenTopEdgeOffScreen() +{ + SetTopEdgeOnScreen(); + + m_sprTopEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprTopEdge.SetTweenY( -m_sprTopEdge.GetZoomedHeight() ); + + m_textHelp.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_textHelp.SetTweenZoomY( 0 ); + + m_soundSwoosh.PlayRandom(); +} + +void MenuElements::TweenBackgroundOnScreen() +{ + SetBackgroundOffScreen(); + + m_sprBottomEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprBottomEdge.SetTweenY( SCREEN_HEIGHT - m_sprBottomEdge.GetZoomedHeight()/2 ); + + m_sprBG.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); + m_sprBG.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprBG.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) ); + + m_soundSwoosh.PlayRandom(); +} + +void MenuElements::TweenBackgroundOffScreen() +{ + SetBackgroundOnScreen(); + + m_sprBottomEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprBottomEdge.SetTweenY( SCREEN_HEIGHT + m_sprTopEdge.GetZoomedHeight() ); + + m_sprBG.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); + m_sprBG.BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); + m_sprBG.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,1) ); + + m_soundBack.PlayRandom(); +} + +void MenuElements::TweenAllOnScreen() +{ + TweenTopEdgeOnScreen(); + TweenBackgroundOnScreen(); +} + +void MenuElements::TweenAllOffScreen() +{ + TweenTopEdgeOffScreen(); + TweenBackgroundOffScreen(); +} + +void MenuElements::SetBackgroundOnScreen() +{ + m_sprBottomEdge.SetXY( CENTER_X, SCREEN_HEIGHT - m_sprBottomEdge.GetZoomedHeight()/2 ); +} + +void MenuElements::SetBackgroundOffScreen() +{ + m_sprBottomEdge.SetXY( CENTER_X, SCREEN_HEIGHT + m_sprBottomEdge.GetZoomedHeight()/2 ); +} + +void MenuElements::SetTopEdgeOnScreen() +{ + m_sprTopEdge.SetXY( CENTER_X, m_sprTopEdge.GetZoomedHeight() ); +} + +void MenuElements::SetTopEdgeOffScreen() +{ + m_sprTopEdge.SetXY( CENTER_X, -m_sprTopEdge.GetZoomedHeight() ); +} + + +void MenuElements::RenderPrimitives() +{ + // do nothing. Call DrawBottomLayer() and DrawTopLayer() instead. +} + +void MenuElements::DrawTopLayer() +{ + m_sprTopEdge.Draw(); + m_sprBottomEdge.Draw(); + m_textHelp.Draw(); +} + +void MenuElements::DrawBottomLayer() +{ + m_sprBG.Draw(); +} + + + diff --git a/stepmania/src/MenuElements.h b/stepmania/src/MenuElements.h new file mode 100644 index 0000000000..800e0690e5 --- /dev/null +++ b/stepmania/src/MenuElements.h @@ -0,0 +1,66 @@ +/* +----------------------------------------------------------------------------- + File: MenuElements.h + + Desc: Base class for menu Windows. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ +#ifndef _MenuElements_H_ +#define _MenuElements_H_ + + + +#include "Window.h" +#include "Sprite.h" +#include "BitmapText.h" +#include "RandomSample.h" +#include "TransitionFade.h" + + +const float MENU_ELEMENTS_TWEEN_TIME = 0.30f; + + +class MenuElements : public ActorFrame +{ +public: + MenuElements(); + + virtual void RenderPrimitives(); + + void Load( CString sBackgroundPath, CString sTopEdgePath, CString sHelpText ); + + void DrawTopLayer(); + void DrawBottomLayer(); + + void TweenTopEdgeOnScreen(); + void TweenTopEdgeOffScreen(); + + void TweenAllOnScreen(); // tween top edge + background + void TweenAllOffScreen(); + +protected: + void TweenBackgroundOnScreen(); + void TweenBackgroundOffScreen(); + + void SetBackgroundOnScreen(); + void SetBackgroundOffScreen(); + + void SetTopEdgeOnScreen(); + void SetTopEdgeOffScreen(); + + + Sprite m_sprBG; + Sprite m_sprTopEdge; + Sprite m_sprBottomEdge; + BitmapText m_textHelp; + + RandomSample m_soundSwoosh; + RandomSample m_soundBack; +}; + + + + +#endif \ No newline at end of file diff --git a/stepmania/src/MotionBlurSprite.h b/stepmania/src/MotionBlurSprite.h index 3537495dc6..7e88db4510 100644 --- a/stepmania/src/MotionBlurSprite.h +++ b/stepmania/src/MotionBlurSprite.h @@ -22,7 +22,7 @@ class MotionBlurSprite : public Actor { public: - virtual bool Load( CString sFilePath ) { for( int i=0; iGetPathTo(GRAPHIC_MUSIC_SELECTION_HIGHLIGHT) ); m_sprSelectionBackground.SetXY( 0, 0 ); diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index 4c6727358a..37dd12bfad 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -17,7 +17,7 @@ #include "Song.h" #include "ActorFrame.h" #include "BitmapText.h" -#include "Rectangle.h" +#include "RectangleActor.h" #include "TextBanner.h" #include "RandomSample.h" #include "GradeDisplay.h" @@ -43,7 +43,7 @@ struct WheelItemData public: WheelItemData(); - void LoadFromSectionName( CString sSectionName ); + void LoadFromSectionName( const CString &sSectionName ); void LoadFromSong( Song* pSong ); WheelItemType m_WheelItemType; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index e455fd9387..ee377b28c2 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -58,7 +58,7 @@ Player::Player() void Player::Load( const StyleDef& StyleDef, PlayerNumber player_no, const Pattern& pattern, const PlayerOptions& po ) { - //RageLog( "Player::Load()", ); + //HELPER.Log( "Player::Load()", ); m_Style = StyleDef; m_PlayerNumber = player_no; @@ -74,7 +74,7 @@ void Player::Load( const StyleDef& StyleDef, PlayerNumber player_no, const Patte if( po.m_bLittle ) pattern2.MakeLittle(); - m_ColorArrowField.Load( StyleDef, pattern2, po, 2, 10 ); + m_ColorArrowField.Load( StyleDef, pattern2, po, 1.5f, 5.5f ); m_GrayArrows.Load( po, StyleDef ); m_GhostArrows.Load( po, StyleDef ); @@ -107,7 +107,7 @@ void Player::Load( const StyleDef& StyleDef, PlayerNumber player_no, const Patte void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference ) { - //RageLog( "Player::Update(%f, %f, %f)", fDeltaTime, fSongBeat, fMaxBeatDifference ); + //HELPER.Log( "Player::Update(%f, %f, %f)", fDeltaTime, fSongBeat, fMaxBeatDifference ); // @@ -265,7 +265,7 @@ bool Player::IsThereANoteAtIndex( int iIndex ) void Player::HandlePlayerStep( float fSongBeat, TapNote player_step, float fMaxBeatDiff ) { - //RageLog( "Player::HandlePlayerStep()" ); + //HELPER.Log( "Player::HandlePlayerStep()" ); int iColumnNum = m_Style.TapNoteToColumnNumber( player_step ); if( iColumnNum == -1 ) // if this TapNote is not used in the current StyleDef @@ -298,7 +298,7 @@ void Player::HandlePlayerStep( float fSongBeat, TapNote player_step, float fMaxB float fBeatsUntilStep = NoteIndexToBeat( (float)hn.m_iStartIndex ) - fSongBeat; float fPercentFromPerfect = fabsf( fBeatsUntilStep / fMaxBeatDiff ); - //RageLog( "fBeatsUntilStep: %f, fPercentFromPerfect: %f", + //HELPER.Log( "fBeatsUntilStep: %f, fPercentFromPerfect: %f", // fBeatsUntilStep, fPercentFromPerfect ); // compute what the score should be for the note we stepped on @@ -340,13 +340,13 @@ void Player::HandlePlayerStep( float fSongBeat, TapNote player_step, float fMaxB void Player::CheckForCompleteStep( float fSongBeat, TapNote player_step, float fMaxBeatDiff ) { - //RageLog( "Player::CheckForCompleteStep()" ); + //HELPER.Log( "Player::CheckForCompleteStep()" ); // look for the closest matching step int iIndexStartLookingAt = BeatToNoteIndex( fSongBeat ); int iNumElementsToExamine = BeatToNoteIndex( fMaxBeatDiff ); // number of elements to examine on either end of iIndexStartLookingAt - //RageLog( "iIndexStartLookingAt = %d, iNumElementsToExamine = %d", iIndexStartLookingAt, iNumElementsToExamine ); + //HELPER.Log( "iIndexStartLookingAt = %d, iNumElementsToExamine = %d", iIndexStartLookingAt, iNumElementsToExamine ); // Start at iIndexStartLookingAt and search outward. The first one that overlaps the player's step is the closest match. for( int delta=0; delta <= iNumElementsToExamine; delta++ ) @@ -361,7 +361,7 @@ void Player::CheckForCompleteStep( float fSongBeat, TapNote player_step, float f //////////////////////////// // check the step to the left of iIndexStartLookingAt //////////////////////////// - //RageLog( "Checking Pattern[%d]", iCurrentIndexEarlier ); + //HELPER.Log( "Checking Pattern[%d]", iCurrentIndexEarlier ); if( m_TapNotesRemaining[iCurrentIndexEarlier] & player_step ) // these Pattern overlap { m_TapNotesRemaining[iCurrentIndexEarlier] &= ~player_step; // subtract player_step @@ -374,7 +374,7 @@ void Player::CheckForCompleteStep( float fSongBeat, TapNote player_step, float f //////////////////////////// // check the step to the right of iIndexStartLookingAt //////////////////////////// - //RageLog( "Checking Pattern[%d]", iCurrentIndexLater ); + //HELPER.Log( "Checking Pattern[%d]", iCurrentIndexLater ); if( m_TapNotesRemaining[iCurrentIndexLater] & player_step ) // these Pattern overlap { m_TapNotesRemaining[iCurrentIndexLater] &= ~player_step; // subtract player_step @@ -394,7 +394,7 @@ void Player::OnCompleteStep( float fSongBeat, TapNote player_step, float fMaxBea float fBeatsUntilStep = fStepBeat - fSongBeat; float fPercentFromPerfect = fabsf( fBeatsUntilStep / fMaxBeatDiff ); - //RageLog( "fBeatsUntilStep: %f, fPercentFromPerfect: %f", + //HELPER.Log( "fBeatsUntilStep: %f, fPercentFromPerfect: %f", // fBeatsUntilStep, fPercentFromPerfect ); // compute what the score should be for the note we stepped on @@ -482,7 +482,7 @@ ScoreSummary Player::GetScoreSummary() int Player::UpdateStepsMissedOlderThan( float fMissIfOlderThanThisBeat ) { - //RageLog( "Pattern::UpdateStepsMissedOlderThan(%f)", fMissIfOlderThanThisBeat ); + //HELPER.Log( "Pattern::UpdateStepsMissedOlderThan(%f)", fMissIfOlderThanThisBeat ); int iMissIfOlderThanThisIndex = BeatToNoteIndex( fMissIfOlderThanThisBeat ); @@ -491,10 +491,10 @@ int Player::UpdateStepsMissedOlderThan( float fMissIfOlderThanThisBeat ) // Instead, only check 10 elements back. Even 10 is overkill. int iStartCheckingAt = max( 0, iMissIfOlderThanThisIndex-10 ); - //RageLog( "iStartCheckingAt: %d iMissIfOlderThanThisIndex: %d", iStartCheckingAt, iMissIfOlderThanThisIndex ); + //HELPER.Log( "iStartCheckingAt: %d iMissIfOlderThanThisIndex: %d", iStartCheckingAt, iMissIfOlderThanThisIndex ); for( int i=iStartCheckingAt; iGetNextAssoc( pos, name_string, value_string ); - if( name_string == "Windowed" ) m_GameOptions.m_bWindowed = ( value_string == "1" ); - if( name_string == "Resolution" ) m_GameOptions.m_iResolution = atoi( value_string ); - if( name_string == "DisplayColor" ) m_GameOptions.m_iDisplayColor = atoi( value_string ); - if( name_string == "TextureColor" ) m_GameOptions.m_iTextureColor = atoi( value_string ); - if( name_string == "FilterTextures" ) m_GameOptions.m_bFilterTextures = ( value_string == "1" ); - if( name_string == "Shadows" ) m_GameOptions.m_bShadows = ( value_string == "1" ); if( name_string == "IgnoreJoyAxes" ) m_GameOptions.m_bIgnoreJoyAxes = ( value_string == "1" ); if( name_string == "ShowFPS" ) m_GameOptions.m_bShowFPS = ( value_string == "1" ); if( name_string == "UseRandomVis" ) m_GameOptions.m_bUseRandomVis = ( value_string == "1" ); @@ -95,6 +89,23 @@ void PrefsManager::ReadPrefsFromDisk() } } + pKey = ini.GetKeyPointer( "GraphicOptions" ); + if( pKey ) + { + for( POSITION pos = pKey->GetStartPosition(); pos != NULL; ) + { + pKey->GetNextAssoc( pos, name_string, value_string ); + + if( name_string == "Windowed" ) m_GraphicOptions.m_bWindowed = ( value_string == "1" ); + if( name_string == "Resolution" ) m_GraphicOptions.m_iResolution = atoi( value_string ); + if( name_string == "MaxTextureSize" ) m_GraphicOptions.m_iMaxTextureSize = atoi( value_string ); + if( name_string == "DisplayColor" ) m_GraphicOptions.m_iDisplayColor = atoi( value_string ); + if( name_string == "TextureColor" ) m_GraphicOptions.m_iTextureColor = atoi( value_string ); + if( name_string == "Shadows" ) m_GraphicOptions.m_bShadows = ( value_string == "1" ); + if( name_string == "30fpsLock" ) m_GraphicOptions.m_b30fpsLock = ( value_string == "1" ); + } + } + } @@ -122,17 +133,20 @@ void PrefsManager::SavePrefsToDisk() } // save the GameOptions - ini.SetValue( "GameOptions", "Windowed", m_GameOptions.m_bWindowed ? "1":"0" ); - ini.SetValue( "GameOptions", "Resolution", ssprintf("%d", m_GameOptions.m_iResolution) ); - ini.SetValue( "GameOptions", "DisplayColor", ssprintf("%d", m_GameOptions.m_iDisplayColor) ); - ini.SetValue( "GameOptions", "TextureColor", ssprintf("%d", m_GameOptions.m_iTextureColor) ); - ini.SetValue( "GameOptions", "FilterTextures", m_GameOptions.m_bFilterTextures ? "1":"0" ); - ini.SetValue( "GameOptions", "Shadows", m_GameOptions.m_bShadows ? "1":"0" ); - ini.SetValue( "GameOptions", "IgnoreJoyAxes", m_GameOptions.m_bIgnoreJoyAxes ? "1":"0" ); - ini.SetValue( "GameOptions", "ShowFPS", m_GameOptions.m_bShowFPS ? "1":"0" ); - ini.SetValue( "GameOptions", "UseRandomVis", m_GameOptions.m_bUseRandomVis ? "1":"0" ); - ini.SetValue( "GameOptions", "SkipCaution", m_GameOptions.m_bSkipCaution ? "1":"0" ); - ini.SetValue( "GameOptions", "Announcer", m_GameOptions.m_bAnnouncer ? "1":"0" ); + ini.SetValue( "GraphicOptions", "Windowed", m_GraphicOptions.m_bWindowed ? "1":"0" ); + ini.SetValue( "GraphicOptions", "Resolution", ssprintf("%d", m_GraphicOptions.m_iResolution) ); + ini.SetValue( "GraphicOptions", "MaxTextureSize", ssprintf("%d", m_GraphicOptions.m_iMaxTextureSize) ); + ini.SetValue( "GraphicOptions", "DisplayColor", ssprintf("%d", m_GraphicOptions.m_iDisplayColor) ); + ini.SetValue( "GraphicOptions", "TextureColor", ssprintf("%d", m_GraphicOptions.m_iTextureColor) ); + ini.SetValue( "GraphicOptions", "Shadows", m_GraphicOptions.m_bShadows ? "1":"0" ); + ini.SetValue( "GraphicOptions", "30fpsLock", m_GraphicOptions.m_b30fpsLock ? "1":"0" ); + + + ini.SetValue( "GameOptions", "IgnoreJoyAxes", m_GameOptions.m_bIgnoreJoyAxes ? "1":"0" ); + ini.SetValue( "GameOptions", "ShowFPS", m_GameOptions.m_bShowFPS ? "1":"0" ); + ini.SetValue( "GameOptions", "UseRandomVis", m_GameOptions.m_bUseRandomVis ? "1":"0" ); + ini.SetValue( "GameOptions", "SkipCaution", m_GameOptions.m_bSkipCaution ? "1":"0" ); + ini.SetValue( "GameOptions", "Announcer", m_GameOptions.m_bAnnouncer ? "1":"0" ); @@ -387,7 +401,7 @@ bool PrefsManager::IsButtonDown( PadInput pi ) if( PadToDevice( pi, i, di ) ) { - if( INPUT->IsBeingPressed( di ) ) + if( INPUTM->IsBeingPressed( di ) ) return true; } } diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index c30459ef9b..53950dd12b 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -40,14 +40,16 @@ public: int m_iCurrentStage; // number of stages played +1 GameOptions m_GameOptions; + GraphicOptions m_GraphicOptions; PlayerOptions m_PlayerOptions[NUM_PLAYERS]; SongOptions m_SongOptions; - // read and write to disk void ReadPrefsFromDisk(); void SavePrefsToDisk(); + void AfterPrefsChanged(); // this function puts all the changes into effect + // input mapping stuff void SetInputMap( DeviceInput di, PadInput pi, int iSlotIndex, bool bOverrideHardCoded = false ); diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index f1db0d3a48..2f0b908025 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -23,22 +23,25 @@ #include "dxerr8.h" #include "DXUtil.h" #include "RageUtil.h" -#include "PrefsManager.h" +#include "RageHelper.h" -//#include -#include //----------------------------------------------------------------------------- // RageBitmapTexture constructor //----------------------------------------------------------------------------- -RageBitmapTexture::RageBitmapTexture( LPRageScreen pScreen, CString sFilePath, DWORD dwHints ) : +RageBitmapTexture::RageBitmapTexture( + RageScreen* pScreen, + const CString &sFilePath, + const DWORD dwMaxSize, + const DWORD dwTextureColorDepth, + const DWORD dwHints ) : RageTexture( pScreen, sFilePath ) { -// RageLog( "RageBitmapTexture::RageBitmapTexture()" ); +// HELPER.Log( "RageBitmapTexture::RageBitmapTexture()" ); m_pd3dTexture = NULL; - Create( dwHints ); + Create( dwMaxSize, dwTextureColorDepth, dwHints ); CreateFrameRects(); } @@ -58,7 +61,7 @@ LPDIRECT3DTEXTURE8 RageBitmapTexture::GetD3DTexture() } -void RageBitmapTexture::Create( DWORD dwHints ) +void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWORD dwHints ) { HRESULT hr; @@ -69,37 +72,33 @@ void RageBitmapTexture::Create( DWORD dwHints ) // look in the file name for a format hint m_sFilePath.MakeLower(); - if( -1 != m_sFilePath.Find("no alpha") ) + + switch( dwTextureColorDepth ) { - fmtTexture = D3DFMT_R5G6B5; - } - else if( -1 != m_sFilePath.Find("1 alpha") ) - { - fmtTexture = D3DFMT_A1R5G5B5; - } - else // no hint, assume full alpha - { - fmtTexture = D3DFMT_A4R4G4B4; + case 16: + if( -1 != m_sFilePath.Find("no alpha") ) + fmtTexture = D3DFMT_R5G6B5; + else if( -1 != m_sFilePath.Find("1 alpha") ) + fmtTexture = D3DFMT_A1R5G5B5; + else + fmtTexture = D3DFMT_A4R4G4B4; + break; + case 32: + fmtTexture = D3DFMT_A8R8G8B8; + break; + default: + ASSERT( false ); // invalid color depth value } // look in the file name for a dither hint - bool bDither = (dwHints & HINT_DITHER) + bool bDither = (dwHints & TEXTURE_HINT_DITHER) || -1 != m_sFilePath.Find("dither"); - bool bCreateMipMaps = !(dwHints & HINT_NOMIPMAPS); + bool bCreateMipMaps = !(dwHints & TEXTURE_HINT_NOMIPMAPS); - // if the user has requested high color textures, use the higher color - if( PREFS != NULL - && PREFS->m_GameOptions.m_iDisplayColor == 32 - && PREFS->m_GameOptions.m_iTextureColor == 32 ) - { - fmtTexture = D3DFMT_A8R8G8B8; - } - - ///////////////////// // Figure out whether the texture can fit into texture memory unscaled ///////////////////// @@ -110,78 +109,69 @@ void RageBitmapTexture::Create( DWORD dwHints ) m_sFilePath, &ddii ) ) ) { - RageErrorHr( ssprintf("D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath), hr ); + HELPER.FatalErrorHr( hr, "D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath ); } D3DCAPS8 caps; m_pd3dDevice->GetDeviceCaps( &caps ); - - bScaleImageToTextureSize = ddii.Width > caps.MaxTextureWidth - || ddii.Height > caps.MaxTextureHeight; + // find out what the min texture size is + dwMaxSize = min( dwMaxSize, caps.MaxTextureWidth ); - // HACK: The stupid Savage card will report that it can hold the entire texture, + bScaleImageToTextureSize = ddii.Width > dwMaxSize || ddii.Height > dwMaxSize; + +/* + // HACK: The stupid Savage driver will report that it can hold the entire texture, // then allocate something smaller than the dimensions we need! // after allocating the texture, make sure it's the size we expect. If not, // load it again with scaling turned on. - for( int i=0; i<2; i++ ) // only try twice +*/ + // I'm taking out the Savage hack because it's causing problems. Tough luck for them. I think + // the problem can be worked around by setting MaxTextureSize to 512. + if( FAILED( hr = D3DXCreateTextureFromFileEx( + m_pd3dDevice, // device + m_sFilePath, // soure file + D3DX_DEFAULT, // width + D3DX_DEFAULT, // height + bCreateMipMaps ? 4 : 0, // mip map levels + 0, // usage (is a render target?) + fmtTexture, // our preferred texture format + D3DPOOL_MANAGED, // which memory pool + (bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter + D3DX_DEFAULT | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter + 0, // no color key + &ddii, // struct to fill with source image info + NULL, // no palette + &m_pd3dTexture ) ) ) { - DWORD dwExpectedWidth = bScaleImageToTextureSize ? caps.MaxTextureWidth : ddii.Width; - DWORD dwExpectedHeight = bScaleImageToTextureSize ? caps.MaxTextureHeight : ddii.Height; - - if( FAILED( hr = D3DXCreateTextureFromFileEx( - m_pd3dDevice, // device - m_sFilePath, // soure file - D3DX_DEFAULT, D3DX_DEFAULT, // width, height - bCreateMipMaps ? 4 : 0, // mip map levels - 0, // usage (is a render target?) - fmtTexture, // our preferred texture format - D3DPOOL_MANAGED, // which memory pool - (bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter - D3DX_DEFAULT | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter - 0, // no color key - &ddii, // struct to fill with source image info - NULL, // no palette - &m_pd3dTexture ) ) ) - { - RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr ); - } - - ///////////////////// - // Save information about the texture - ///////////////////// - m_uSourceWidth = ddii.Width; - m_uSourceHeight= ddii.Height; - - D3DSURFACE_DESC ddsd; - if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) ) - RageErrorHr( "Could not get level Description of D3DX texture!", hr ); - - // save information about the texture - m_uTextureWidth = ddsd.Width; - m_uTextureHeight = ddsd.Height; - m_TextureFormat = ddsd.Format; - - if( dwExpectedWidth == ddsd.Width && - dwExpectedHeight == ddsd.Height ) - break; // done trying to load - else - bScaleImageToTextureSize = true; + HELPER.FatalErrorHr( hr, "D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath ); } + ///////////////////// + // Save information about the texture + ///////////////////// + m_iSourceWidth = ddii.Width; + m_iSourceHeight= ddii.Height; + D3DSURFACE_DESC ddsd; + if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) ) + HELPER.FatalErrorHr( hr, "Could not get level Description of D3DX texture!" ); + // save information about the texture + m_iTextureWidth = ddsd.Width; + m_iTextureHeight = ddsd.Height; + m_TextureFormat = ddsd.Format; if( bScaleImageToTextureSize ) { - m_uImageWidth = m_uTextureWidth; - m_uImageHeight = m_uTextureHeight; + m_iImageWidth = m_iTextureWidth; + m_iImageHeight = m_iTextureHeight; } else { - m_uImageWidth = m_uSourceWidth; - m_uImageHeight = m_uSourceHeight; + m_iImageWidth = m_iSourceWidth; + m_iImageHeight = m_iSourceHeight; } } diff --git a/stepmania/src/RageBitmapTexture.h b/stepmania/src/RageBitmapTexture.h index 9ca701e0d9..5280042709 100644 --- a/stepmania/src/RageBitmapTexture.h +++ b/stepmania/src/RageBitmapTexture.h @@ -10,8 +10,6 @@ class RageBitmapTexture; -typedef RageBitmapTexture* LPRageBitmapTexture; - @@ -25,8 +23,8 @@ typedef RageBitmapTexture* LPRageBitmapTexture; //#include -const DWORD HINT_NOMIPMAPS = 1 << 0; -const DWORD HINT_DITHER = 1 << 1; +const DWORD TEXTURE_HINT_NOMIPMAPS = 1 << 0; +const DWORD TEXTURE_HINT_DITHER = 1 << 1; //----------------------------------------------------------------------------- @@ -35,13 +33,19 @@ const DWORD HINT_DITHER = 1 << 1; class RageBitmapTexture : public RageTexture { public: - RageBitmapTexture( LPRageScreen pScreen, CString sFilePath, DWORD dwHints = 0 ); + RageBitmapTexture( + RageScreen* pScreen, + const CString &sFilePath, + const DWORD dwMaxSize = 2048, + const DWORD dwTextureColorDepth = 16, + const DWORD dwHints = 0 + ); ~RageBitmapTexture(); virtual LPDIRECT3DTEXTURE8 GetD3DTexture(); protected: - virtual VOID Create( DWORD dwHints ); + virtual void Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWORD dwHints ); LPDIRECT3DTEXTURE8 m_pd3dTexture; }; diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index 4788a91035..61406b82f5 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -24,9 +24,10 @@ #include "RageInput.h" #include #include "RageUtil.h" +#include "RageHelper.h" -LPRageInput INPUT = NULL; // globally accessable input device +RageInput* INPUTM = NULL; // globally accessable input device @@ -203,7 +204,7 @@ CString DeviceInput::toString() return ssprintf("%d-%d", device, button ); } -bool DeviceInput::fromString( CString s ) +bool DeviceInput::fromString( const CString &s ) { CStringArray a; split( s, "-", a); @@ -229,7 +230,7 @@ bool DeviceInput::fromString( CString s ) BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { - LPRageInput pInput = (LPRageInput)pContext; + RageInput* pInput = (RageInput*)pContext; LPDIRECTINPUT8 pDI = pInput->GetDirectInput(); @@ -238,10 +239,14 @@ BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, // Obtain an interface to the enumerated joystick. if( i >= NUM_JOYSTICKS ) return DIENUM_STOP; // we only care about the first 4 + else + ASSERT( false ); // we should never get here since the app is only initialized once HRESULT hr = pDI->CreateDevice( pdidInstance->guidInstance, &pInput->m_pJoystick[i++], NULL ); + HELPER.FatalErrorHr( hr, "Error in CreateDevice() for joystick %d.", i ); + return DIENUM_CONTINUE; } @@ -314,7 +319,7 @@ HRESULT RageInput::Initialize() //////////////////////////////// if( FAILED(hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ) ) - RageErrorHr( "DirectInput8Create failed.", hr ); + HELPER.FatalErrorHr( hr, "DirectInput8Create failed." ); ///////////////////////////// // Create the keyboard device @@ -322,21 +327,21 @@ HRESULT RageInput::Initialize() // Create our DirectInput Object for the Keyboard if( FAILED( hr = m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL ) ) ) - RageErrorHr( "CreateDevice keyboard failed.", hr ); + HELPER.FatalErrorHr( hr, "CreateDevice keyboard failed." ); // Set our Cooperation Level with each Device if( FAILED( hr = m_pKeyboard->SetCooperativeLevel(m_hWnd, DISCL_FOREGROUND | DISCL_NOWINKEY | DISCL_NONEXCLUSIVE) ) ) - RageErrorHr( "m_pKeyboard->SetCooperativeLevel failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pKeyboard->SetCooperativeLevel failed." ); // Set the Data Format of each device if( FAILED( hr = m_pKeyboard->SetDataFormat(&c_dfDIKeyboard) ) ) - RageErrorHr( "m_pKeyboard->SetDataFormat failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pKeyboard->SetDataFormat failed." ); // Acquire the Keyboard Device //if( FAILED( hr = m_pKeyboard->Acquire() ) ) - // RageErrorHr( "m_pKeyboard->Acquire failed.", hr ); + // HELPER.FatalErrorHr( "m_pKeyboard->Acquire failed.", hr ); @@ -346,13 +351,13 @@ HRESULT RageInput::Initialize() // Obtain an interface to the system mouse device. if( FAILED( hr = m_pDI->CreateDevice( GUID_SysMouse, &m_pMouse, NULL ) ) ) - RageErrorHr( "CreateDevice mouse failed.", hr ); + HELPER.FatalErrorHr( hr, "CreateDevice mouse failed." ); if( FAILED( hr = m_pMouse->SetCooperativeLevel( m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND ) ) ) - RageErrorHr( "m_pMouse->SetCooperativeLevel failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pMouse->SetCooperativeLevel failed." ); if( FAILED( hr = m_pMouse->SetDataFormat( &c_dfDIMouse2 ) ) ) - RageErrorHr( "m_pMouse->SetDataFormat failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pMouse->SetDataFormat failed." ); /* DIPROPDWORD dipdw; @@ -365,7 +370,7 @@ HRESULT RageInput::Initialize() if( FAILED( m_pMouse->SetProperty( DIPROP_AXISMODE, &dipdw.diph ) ) ) return E_FAIL;*/ //if( FAILED( hr = m_pMouse->Acquire())) - // RageErrorHr( "m_pMouse->Acquire failed.", hr ); + // HELPER.FatalErrorHr( "m_pMouse->Acquire failed.", hr ); m_RelPosition_x = 0; m_RelPosition_y = 0; @@ -382,7 +387,7 @@ HRESULT RageInput::Initialize() EnumJoysticksCallback, (VOID*)this, DIEDFL_ATTACHEDONLY ) ) ) - RageErrorHr( "m_pDI->EnumDevices failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pDI->EnumDevices failed." ); for( int i=0; iSetDataFormat( &c_dfDIJoystick2 ) ) ) - RageErrorHr( "m_pJoystick[i]->SetDataFormat failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pJoystick[i]->SetDataFormat failed." ); // Set the cooperative level to let DInput know how this device should // interact with the system and with other DInput applications. if( m_pJoystick[i] ) if( FAILED( hr = m_pJoystick[i]->SetCooperativeLevel( m_hWnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND ) ) ) - RageErrorHr( "m_pJoystick[i]->SetCooperativeLevel failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pJoystick[i]->SetCooperativeLevel failed." ); /* @@ -418,18 +423,18 @@ HRESULT RageInput::Initialize() // of enumerating device objects (axes, buttons, etc.). if( m_pJoystick[i] ) if ( FAILED( hr = m_pJoystick[i]->EnumObjects( EnumAxesCallback, (VOID*)m_pJoystick[i], DIDFT_AXIS ) ) ) - RageErrorHr( "m_pJoystick[i]->EnumObjects failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pJoystick[i]->EnumObjects failed." ); // Acquire the newly created devices if( m_pJoystick[i] ) if( FAILED( hr = m_pJoystick[i]->Acquire() ) ) - RageErrorHr( "m_pJoystick[i]->Acquire failed.", hr ); + HELPER.FatalErrorHr( hr, "m_pJoystick[i]->Acquire failed." ); } return S_OK; } -VOID RageInput::Release() +void RageInput::Release() { // Unacquire the keyboard device if (m_pKeyboard) @@ -646,7 +651,7 @@ BOOL RageInput::IsBeingPressed( DeviceInput di ) return IS_PRESSED( m_joyState[joy_index].rgbButtons[button_index] ); } default: - RageError( "Invalid device" ); + HELPER.FatalError( "Invalid device" ); } return false; // how did we get here?!? diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index ce5218181c..8a5e1e368a 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.h @@ -87,7 +87,7 @@ public: CString GetDescription(); CString toString(); - bool fromString( CString s ); + bool fromString( const CString &s ); bool IsBlank() const { return device == DEVICE_NONE; }; void MakeBlank() { device = DEVICE_NONE; }; @@ -95,7 +95,7 @@ public: -typedef CArray DeviceInputArray; +typedef CArray DeviceInputArray; class RageInput @@ -155,9 +155,7 @@ public: }; -typedef RageInput* LPRageInput; - -extern LPRageInput INPUT; // global and accessable from anywhere in our program +extern RageInput* INPUTM; // global and accessable from anywhere in our program #endif \ No newline at end of file diff --git a/stepmania/src/RageMovieTexture.cpp b/stepmania/src/RageMovieTexture.cpp index 48d71fe2b9..f42dfe7f05 100644 --- a/stepmania/src/RageMovieTexture.cpp +++ b/stepmania/src/RageMovieTexture.cpp @@ -30,9 +30,9 @@ #include "dxerr8.h" #include "DXUtil.h" #include "RageUtil.h" +#include "RageHelper.h" #include -#include //----------------------------------------------------------------------------- // Global Constants @@ -240,10 +240,10 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample ) //----------------------------------------------------------------------------- // RageMovieTexture constructor //----------------------------------------------------------------------------- -RageMovieTexture::RageMovieTexture( LPRageScreen pScreen, CString sFilePath ) : +RageMovieTexture::RageMovieTexture( RageScreen* pScreen, const CString &sFilePath ) : RageTexture( pScreen, sFilePath ) { - RageLog( "RageBitmapTexture::RageBitmapTexture()" ); + HELPER.Log( "RageBitmapTexture::RageBitmapTexture()" ); m_pd3dTexture[0] = m_pd3dTexture[1] = NULL; m_iIndexActiveTexture = 0; @@ -276,7 +276,7 @@ LPDIRECT3DTEXTURE8 RageMovieTexture::GetD3DTexture() // 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..." ); +// HELPER.Log( "Sleeping waiting for unlock..." ); // } // restart the movie if we reach the end @@ -296,62 +296,32 @@ VOID RageMovieTexture::Create() // Initialize the filter graph find and get information about the // video (dimensions, color depth, etc.) if( FAILED( hr = InitDShowTextureRenderer() ) ) - RageErrorHr( "Could not initialize the DirectShow Texture Renderer!", hr ); + HELPER.FatalErrorHr( hr, "Could not initialize the DirectShow Texture Renderer!" ); if( FAILED( hr = CreateD3DTexture() ) ) - RageErrorHr( "Could not create the D3D Texture!", hr ); + HELPER.FatalErrorHr( hr, "Could not create the D3D Texture!" ); // Pass the D3D texture to our TextureRenderer so it knows // where to render new movie frames to. if( FAILED( hr = m_pCTR->SetRenderTarget( this ) ) ) - RageErrorHr( "RageMovieTexture: SetRenderTarget failed.", hr ); + HELPER.FatalErrorHr( hr, "RageMovieTexture: SetRenderTarget failed." ); // Start the graph running if( FAILED( hr = PlayMovie() ) ) - RageErrorHr( "Could not run the DirectShow graph.", hr ); + HELPER.FatalErrorHr( hr, "Could not run the DirectShow graph." ); } 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, - "DivX412Codec.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); - } - } + HELPER.FatalError( + "Could not locate the DivX video codec.\n" + "DivX is required to movie textures and must\n" + "be installed before running the application.\n\n" + "Please visit http://www.divx.com to download the latest version." + ); + exit(1); } //----------------------------------------------------------------------------- @@ -367,17 +337,17 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer() // Create the filter graph if( FAILED( m_pGB.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC) ) ) - RageErrorHr( "Could not create CLSID_FilterGraph!", hr ); + HELPER.FatalErrorHr( hr, "Could not create CLSID_FilterGraph!" ); // Create the Texture Renderer object m_pCTR = new CTextureRenderer(NULL, &hr); if( FAILED(hr) ) - RageErrorHr( "Could not create texture renderer object!", hr ); + HELPER.FatalErrorHr( hr, "Could not create texture renderer object!" ); // Get a pointer to the IBaseFilter on the TextureRenderer, add it to graph pFTR = m_pCTR; if( FAILED( hr = m_pGB->AddFilter(pFTR, L"TEXTURERENDERER" ) ) ) - RageErrorHr( "Could not add renderer filter to graph!", hr ); + HELPER.FatalErrorHr( hr, "Could not add renderer filter to graph!" ); // convert movie file path to wide char string WCHAR wFileName[MAX_PATH]; @@ -393,21 +363,21 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer() if( FAILED( hr = m_pGB->AddSourceFilter( wFileName, L"SOURCE", &pFSrc ) ) ) // if this fails, it's probably because the user doesn't have DivX installed { HandleDivXError(); - RageErrorHr( "Could not create source filter to graph!", hr ); + HELPER.FatalErrorHr( hr, "Could not create source filter to graph!" ); } // Find the source's output and the renderer's input if( FAILED( hr = pFTR->FindPin( L"In", &pFTRPinIn ) ) ) - RageErrorHr( "Could not find input pin!", hr ); + HELPER.FatalErrorHr( hr, "Could not find input pin!" ); if( FAILED( hr = pFSrc->FindPin( L"Output", &pFSrcPinOut ) ) ) - RageErrorHr( "Could not find output pin!", hr ); + HELPER.FatalErrorHr( hr, "Could not find output pin!" ); // Connect these two filters if( FAILED( hr = m_pGB->Connect( pFSrcPinOut, pFTRPinIn ) ) ) { HandleDivXError(); - RageErrorHr( "Could not connect pins!", hr ); + HELPER.FatalErrorHr( hr, "Could not connect pins!" ); } // Get the graph's media control, event & position interfaces @@ -417,10 +387,10 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer() // The graph is built, now get the set the output video width and height. // The source and image width will always be the same since we can't scale the video - m_uSourceWidth = m_pCTR->GetVidWidth(); - m_uSourceHeight = m_pCTR->GetVidHeight(); - m_uImageWidth = m_uSourceWidth; - m_uImageHeight = m_uSourceHeight; + m_iSourceWidth = m_pCTR->GetVidWidth(); + m_iSourceHeight = m_pCTR->GetVidHeight(); + m_iImageWidth = m_iSourceWidth; + m_iImageHeight = m_iSourceHeight; return S_OK; @@ -434,28 +404,28 @@ HRESULT RageMovieTexture::CreateD3DTexture() // Create the texture that maps to this media type ////////////////////////////////////////////////// if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice, - m_uSourceHeight, m_uSourceHeight, + m_iSourceHeight, m_iSourceHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture[0] ) ) ) - RageErrorHr( "Could not create the D3DX texture!", hr ); + HELPER.FatalErrorHr( hr, "Could not create the D3DX texture!" ); if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice, - m_uSourceHeight, m_uSourceHeight, + m_iSourceHeight, m_iSourceHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture[1] ) ) ) - RageErrorHr( "Could not create the D3DX texture!", hr ); + HELPER.FatalErrorHr( hr, "Could not create the D3DX texture!" ); // D3DXCreateTexture can silently change the parameters on us D3DSURFACE_DESC ddsd; if ( FAILED( hr = m_pd3dTexture[0]->GetLevelDesc( 0, &ddsd ) ) ) - RageErrorHr( "Could not get level Description of D3DX texture!", hr ); + HELPER.FatalErrorHr( hr, "Could not get level Description of D3DX texture!" ); - m_uTextureWidth = ddsd.Width; - m_uTextureHeight = ddsd.Height; + m_iTextureWidth = ddsd.Width; + m_iTextureHeight = ddsd.Height; m_TextureFormat = ddsd.Format; if( m_TextureFormat != D3DFMT_A8R8G8B8 && m_TextureFormat != D3DFMT_A1R5G5B5 ) - RageErrorHr( "Texture is format we can't handle! Format = 0x%x!", m_TextureFormat ); + HELPER.FatalError( "Texture is format we can't handle! Format = 0x%x!", m_TextureFormat ); return S_OK; @@ -467,7 +437,7 @@ HRESULT RageMovieTexture::PlayMovie() // Start the graph running; if( FAILED( hr = m_pMC->Run() ) ) - RageErrorHr( "Could not run the DirectShow graph.", hr ); + HELPER.FatalErrorHr( hr, "Could not run the DirectShow graph." ); return S_OK; } diff --git a/stepmania/src/RageMovieTexture.h b/stepmania/src/RageMovieTexture.h index 41ec8c8af4..f8220e5f82 100644 --- a/stepmania/src/RageMovieTexture.h +++ b/stepmania/src/RageMovieTexture.h @@ -73,7 +73,7 @@ protected: class RageMovieTexture : public RageTexture { public: - RageMovieTexture( LPRageScreen pScreen, CString sFilePath ); + RageMovieTexture( RageScreen* pScreen, const CString &sFilePath ); virtual ~RageMovieTexture(); LPDIRECT3DTEXTURE8 GetD3DTexture(); @@ -101,7 +101,5 @@ protected: }; -typedef RageMovieTexture* LPRageMovieTexture; - #endif \ No newline at end of file diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index e649b785c6..8b27b2b0c4 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -12,28 +12,29 @@ #include "RageSound.h" #include "RageUtil.h" +#include "RageHelper.h" #include "bass/bass.h" #pragma comment(lib, "bass/bass.lib") -LPRageSound SOUND = NULL; +RageSound* SOUND = NULL; RageSound::RageSound( HWND hWnd ) { - RageLog( "RageSound::RageSound()" ); + HELPER.Log( "RageSound::RageSound()" ); // save the HWND if( !hWnd ) - RageError( "RageSound called with NULL hWnd." ); + HELPER.FatalError( "RageSound called with NULL hWnd." ); m_hWndApp = hWnd; 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."); + HELPER.FatalError( "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_LEAVEVOL|BASS_DEVICE_LATENCY, m_hWndApp ) ) { - RageError( + HELPER.FatalError( "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" @@ -49,7 +50,7 @@ RageSound::RageSound( HWND hWnd ) BASS_GetInfo( &m_info ); - RageLog( + HELPER.Log( "Sound card info:\n" " - play latency is %u ms\n" " - total device hardware memory is %u bytes\n" diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 7956835444..bcf2c3ffc2 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -33,10 +33,8 @@ private: }; -typedef RageSound* LPRageSound; - -extern LPRageSound SOUND; // global and accessable from anywhere in our program +extern RageSound* SOUND; // global and accessable from anywhere in our program #endif \ No newline at end of file diff --git a/stepmania/src/RageTexture.cpp b/stepmania/src/RageTexture.cpp index f313794d6f..0858d60159 100644 --- a/stepmania/src/RageTexture.cpp +++ b/stepmania/src/RageTexture.cpp @@ -20,9 +20,9 @@ //----------------------------------------------------------------------------- // RageTexture constructor //----------------------------------------------------------------------------- -RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) +RageTexture::RageTexture( RageScreen* pScreen, const CString &sFilePath ) { -// RageLog( "RageTexture::RageTexture()" ); +// HELPER.Log( "RageTexture::RageTexture()" ); // save a pointer to the D3D device m_pd3dDevice = pScreen->GetDevice(); @@ -33,10 +33,10 @@ RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) // m_pd3dTexture = NULL; m_iRefCount = 1; - m_uSourceWidth = m_uSourceHeight = 0; - m_uTextureWidth = m_uTextureHeight = 0; - m_uImageWidth = m_uImageHeight = 0; - m_uFramesWide = m_uFramesHigh = 1; + m_iSourceWidth = m_iSourceHeight = 0; + m_iTextureWidth = m_iTextureHeight = 0; + m_iImageWidth = m_iImageHeight = 0; + m_iFramesWide = m_iFramesHigh = 1; } RageTexture::~RageTexture() @@ -47,30 +47,30 @@ RageTexture::~RageTexture() void RageTexture::CreateFrameRects() { - GetFrameDimensionsFromFileName( m_sFilePath, &m_uFramesWide, &m_uFramesHigh ); + GetFrameDimensionsFromFileName( m_sFilePath, &m_iFramesWide, &m_iFramesHigh ); /////////////////////////////////// // Fill in the m_FrameRects with the bounds of each frame in the animation. /////////////////////////////////// - for( UINT j=0; j +#include "RageHelper.h" -LPRageTextureManager TM = NULL; +RageTextureManager* TEXTURE = NULL; //----------------------------------------------------------------------------- // constructor/destructor //----------------------------------------------------------------------------- -RageTextureManager::RageTextureManager( LPRageScreen pScreen ) +RageTextureManager::RageTextureManager( RageScreen* pScreen ) { assert( pScreen != NULL ); m_pScreen = pScreen; - + m_dwMaxTextureSize = 2048; // infinite size + m_dwTextureColorDepth = 16; } RageTextureManager::~RageTextureManager() { // delete all textures POSITION pos = m_mapPathToTexture.GetStartPosition(); - CString key; - LPRageTexture value; + CString sPath; + RageTexture* pTexture; while( pos != NULL ) // iterate over all k/v pairs in map { - m_mapPathToTexture.GetNextAssoc( pos, key, value ); - SAFE_DELETE( value ); + m_mapPathToTexture.GetNextAssoc( pos, sPath, pTexture ); + HELPER.Log( "TEXTURE LEAK: '%s', RefCount = %d.", sPath, pTexture->m_iRefCount ); + SAFE_DELETE( pTexture ); } m_mapPathToTexture.RemoveAll(); @@ -51,36 +53,42 @@ RageTextureManager::~RageTextureManager() //----------------------------------------------------------------------------- // Load/Unload textures from disk //----------------------------------------------------------------------------- -LPRageTexture RageTextureManager::LoadTexture( CString sTexturePath, DWORD dwHints, bool bForceReload ) +RageTexture* RageTextureManager::LoadTexture( CString sTexturePath, const DWORD dwHints, const bool bForceReload ) { -// RageLog( "RageTextureManager::LoadTexture(%s).", sTexturePath ); + sTexturePath.MakeLower(); + +// HELPER.Log( "RageTextureManager::LoadTexture(%s).", sTexturePath ); // holder for the new texture - LPRageTexture pTexture; + RageTexture* pTexture; // Convert the path to lowercase so that we don't load duplicates. // Really, this does not solve the duplicate problem. We could have to copies // of the same bitmap if there are equivalent but different paths // (e.g. "Bitmaps\me.bmp" and "..\Rage PC Edition\Bitmaps\me.bmp" ). - sTexturePath.MakeLower(); if( m_mapPathToTexture.Lookup( sTexturePath, pTexture ) ) // if the texture already exists in the map { -// RageLog( ssprintf("Found that '%s' is already loaded. Using the loaded copy.", sTexturePath) ); pTexture->m_iRefCount++; + HELPER.Log( ssprintf("RageTextureManager: '%s' now has %d references.", sTexturePath, pTexture->m_iRefCount) ); } else // the texture is not already loaded { CString sDrive, sDir, sFName, sExt; - splitpath( FALSE, sTexturePath, sDrive, sDir, sFName, sExt ); + splitpath( false, sTexturePath, sDrive, sDir, sFName, sExt ); if( sExt == "avi" || sExt == "mpg" || sExt == "mpeg" ) - pTexture = (LPRageTexture) new RageMovieTexture( m_pScreen, sTexturePath ); + pTexture = (RageTexture*) new RageMovieTexture( m_pScreen, sTexturePath ); else - pTexture = (LPRageTexture) new RageBitmapTexture( m_pScreen, sTexturePath, dwHints ); + pTexture = (RageTexture*) new RageBitmapTexture( m_pScreen, sTexturePath, m_dwMaxTextureSize, m_dwTextureColorDepth, dwHints ); - RageLog( "RageTextureManager: allocating space for '%s' (%ux%u).", sTexturePath, pTexture->GetTextureWidth(), pTexture->GetTextureHeight() ); + HELPER.Log( "RageTextureManager: Loading '%s' (%ux%u) from disk. It has %d references", + sTexturePath, + pTexture->GetTextureWidth(), + pTexture->GetTextureHeight(), + pTexture->m_iRefCount + ); m_mapPathToTexture.SetAt( sTexturePath, pTexture ); } @@ -92,6 +100,7 @@ LPRageTexture RageTextureManager::LoadTexture( CString sTexturePath, DWORD dwHin bool RageTextureManager::IsTextureLoaded( CString sTexturePath ) { sTexturePath.MakeLower(); + RageTexture* pTexture; if( m_mapPathToTexture.Lookup( sTexturePath, pTexture ) ) // if the texture exists in the map @@ -102,33 +111,35 @@ bool RageTextureManager::IsTextureLoaded( CString sTexturePath ) void RageTextureManager::UnloadTexture( CString sTexturePath ) { -// RageLog( "RageTextureManager::UnloadTexture(%s).", sTexturePath ); + sTexturePath.MakeLower(); + +// HELPER.Log( "RageTextureManager::UnloadTexture(%s).", sTexturePath ); if( sTexturePath == "" ) { - RageLog( "RageTextureManager::UnloadTexture(): tried to Unload a blank" ); + HELPER.Log( "RageTextureManager::UnloadTexture(): tried to Unload a blank texture." ); return; } - if( !IsTextureLoaded( sTexturePath ) ) - RageError( ssprintf("Tried to Unload a texture that wasn't loaded. '%s'", sTexturePath) ); - - sTexturePath.MakeLower(); - LPRageTexture pTexture; + RageTexture* pTexture; if( m_mapPathToTexture.Lookup( sTexturePath, pTexture ) ) // if the texture exists in the map { pTexture->m_iRefCount--; if( pTexture->m_iRefCount == 0 ) // there are no more references to this texture { - RageLog( ssprintf("RageTextureManager: deallocating '%s'.", sTexturePath) ); + HELPER.Log( ssprintf("RageTextureManager: '%s' will be deleted. It has %d references.", sTexturePath, pTexture->m_iRefCount) ); SAFE_DELETE( pTexture ); // free the texture m_mapPathToTexture.RemoveKey( sTexturePath ); // and remove the key in the map } -// else -// RageLog( ssprintf("The texture '%s' has %d more references. It will not be deleted.", -// sTexturePath, pTexture->m_iRefCount) ); - + else + { + HELPER.Log( ssprintf("RageTextureManager: '%s' will not be deleted. It still has %d references.", sTexturePath, pTexture->m_iRefCount) ); + } + } + else // texture not found + { + HELPER.FatalError( ssprintf("Tried to Unload texture '%s' that wasn't loaded.", sTexturePath) ); } } diff --git a/stepmania/src/RageTextureManager.h b/stepmania/src/RageTextureManager.h index 330ddde71e..5eb4dddec8 100644 --- a/stepmania/src/RageTextureManager.h +++ b/stepmania/src/RageTextureManager.h @@ -9,8 +9,6 @@ */ class RageTextureManager; -typedef RageTextureManager* LPRageTextureManager; - @@ -29,20 +27,29 @@ typedef RageTextureManager* LPRageTextureManager; class RageTextureManager { public: - RageTextureManager( LPRageScreen pScreen ); + RageTextureManager( RageScreen* pScreen ); ~RageTextureManager(); - LPRageTexture LoadTexture( CString sTexturePath, DWORD dwHints = 0, bool bForceReload = false ); + RageTexture* LoadTexture( CString sTexturePath, const DWORD dwHints = 0, const bool bForceReload = false ); bool IsTextureLoaded( CString sTexturePath ); void UnloadTexture( CString sTexturePath ); + void SetMaxTextureSize( const DWORD dwMaxSize ) { m_dwMaxTextureSize = dwMaxSize; }; + DWORD GetMaxTextureSize() { return m_dwMaxTextureSize; }; + + void SetTextureColorDepth( const DWORD dwTextureColorDepth ) { m_dwTextureColorDepth = dwTextureColorDepth; }; + DWORD GetTextureColorDepth() { return m_dwTextureColorDepth; }; + protected: - LPRageScreen m_pScreen; + RageScreen* m_pScreen; + + DWORD m_dwMaxTextureSize; + DWORD m_dwTextureColorDepth; // map from file name to a texture holder - CTypedPtrMap m_mapPathToTexture; + CTypedPtrMap m_mapPathToTexture; }; -extern LPRageTextureManager TM; // global and accessable from anywhere in our program +extern RageTextureManager* TEXTURE; // global and accessable from anywhere in our program #endif diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index f3dc0b9174..752e05c5e8 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -1,29 +1,25 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - File: RageUtil.cpp + File: RageUtil - Desc: Helper and error-controlling function used throughout the program. + Desc: See header. - Copyright (c) 2001 Chris Danford. All rights reserved. + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ #include "RageUtil.h" -const CString g_sLogFileName = "log.txt"; -const CString g_sErrorFileName = "error.txt"; -FILE* g_fileLog = NULL; - - -bool IsAnInt( CString s ) +bool IsAnInt( LPCTSTR s ) { - if( s.GetLength() == 0 ) + if( strlen(s) == 0 ) return false; - for( int i=0; i '9' ) return false; @@ -34,57 +30,6 @@ bool IsAnInt( CString s ) -//----------------------------------------------------------------------------- -// Name: RageLogStart() -// Desc: -//----------------------------------------------------------------------------- -void RageLogStart() -{ - DeleteFile( g_sLogFileName ); - DeleteFile( g_sErrorFileName ); - - // Open log file and leave it open. Let the OS close it when the app exits - g_fileLog = fopen( g_sLogFileName, "w" ); - - - SYSTEMTIME st; - GetLocalTime( &st ); - - RageLog( "%s: last compiled on %s.", g_sLogFileName, __TIMESTAMP__ ); - RageLog( "Log starting %.4d-%.2d-%.2d %.2d:%.2d:%.2d", - st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond ); - RageLog( "\n" ); -} - - -//----------------------------------------------------------------------------- -// Name: RageLog() -// Desc: -//----------------------------------------------------------------------------- -void RageLog( LPCTSTR fmt, ...) -{ - va_list va; - va_start(va, fmt); - - CString sBuff = vssprintf( fmt, va ); - sBuff += "\n"; - - fprintf( g_fileLog, sBuff ); - fflush( g_fileLog ); -// fclose( g_fileLog ); -// g_fileLog = fopen( g_sLogFileName, "w" ); -} - -void RageLogHr( HRESULT hr, LPCTSTR fmt, ...) -{ - va_list va; - va_start(va, fmt); - CString s = vssprintf( fmt, va ); - s += ssprintf( "(%s)", DXGetErrorString8(hr) ); - RageLog( s ); -} - - //----------------------------------------------------------------------------- // Name: ssprintf() // Desc: @@ -133,7 +78,7 @@ CString join(CString Deliminator, CStringArray& Source) // Name: split() // Desc: //----------------------------------------------------------------------------- -void split( CString Source, CString Deliminator, CStringArray& AddIt, bool bIgnoreEmpty ) +void split( const CString &Source, const CString &Deliminator, CStringArray& AddIt, const bool bIgnoreEmpty ) { CString newCString; CString tmpCString; @@ -169,7 +114,7 @@ void split( CString Source, CString Deliminator, CStringArray& AddIt, bool bIgno // Name: splitpath() // Desc: //----------------------------------------------------------------------------- -void splitpath( BOOL UsingDirsOnly, CString Path, CString& Drive, CString& Dir, CString& FName, CString& Ext ) +void splitpath( const bool UsingDirsOnly, const CString &Path, CString& Drive, CString& Dir, CString& FName, CString& Ext ) { int nSecond; @@ -239,7 +184,7 @@ void splitpath( BOOL UsingDirsOnly, CString Path, CString& Drive, CString& Dir, // Name: splitpath() // Desc: //----------------------------------------------------------------------------- -void splitrelpath( CString Path, CString& Dir, CString& FName, CString& Ext ) +void splitrelpath( const CString &Path, CString& Dir, CString& FName, CString& Ext ) { // need to split on both forward slashes and back slashes CStringArray sPathBits; @@ -315,7 +260,7 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs ) ::FindClose( hFind ); } -DWORD GetFileSizeInBytes( CString sFilePath ) +DWORD GetFileSizeInBytes( const CString &sFilePath ) { HANDLE hFile = CreateFile( sFilePath, // pointer to name of the file @@ -331,9 +276,9 @@ DWORD GetFileSizeInBytes( CString sFilePath ) } -bool DoesFileExist( CString sPath ) +bool DoesFileExist( const CString &sPath ) { - //RageLog( "DoesFileExist(%s)", sPath ); + //HELPER.Log( "DoesFileExist(%s)", sPath ); DWORD dwAttr = GetFileAttributes( sPath ); if( dwAttr == (DWORD)-1 ) @@ -343,43 +288,27 @@ bool DoesFileExist( CString sPath ) } -int CompareCStrings(const void *arg1, const void *arg2) +int CompareCStringsAsc(const void *arg1, const void *arg2) { CString str1 = *(CString *)arg1; CString str2 = *(CString *)arg2; return str1.CompareNoCase( str2 ); } -void SortCStringArray( CStringArray &arrayCStrings, BOOL bSortAcsending ) +int CompareCStringsDesc(const void *arg1, const void *arg2) { - qsort( arrayCStrings.GetData(), arrayCStrings.GetSize(), sizeof(CString), CompareCStrings ); + CString str1 = *(CString *)arg1; + CString str2 = *(CString *)arg2; + return str2.CompareNoCase( str1 ); } -//----------------------------------------------------------------------------- -// Name: DisplayErrorAndDie() -// Desc: -//----------------------------------------------------------------------------- - -VOID DisplayErrorAndDie( CString sError ) +void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAcsending ) { -#ifdef DEBUG - // display a message box, then break so we can see a stack trace in the debugger - AfxMessageBox( sError ); - AfxDebugBreak(); - exit(1); - -#else // RELEASE - // write the error to a file so our pretty error dialog can display what happened. - FILE* fp = fopen( g_sErrorFileName, "w" ); - fprintf( fp, sError ); - fclose( fp ); - // generate an exception so the error handler shows - throw(1); - -#endif + qsort( arrayCStrings.GetData(), arrayCStrings.GetSize(), sizeof(CString), bSortAcsending ? CompareCStringsAsc : CompareCStringsDesc ); } + LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) { HKEY hkey; diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index 8192cd507f..fe3fb10ee9 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -1,10 +1,11 @@ /* ----------------------------------------------------------------------------- - File: RageUtil.h + File: RageUtil - Desc: Helper and error-controlling function used throughout the program. + Desc: Miscellaneous helper functions. - Copyright (c) 2001 Chris Danford. All rights reserved. + Copyright (c) 2001-2002 by the names listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ @@ -12,9 +13,6 @@ #define _RAGEUTIL_H_ -#include "dxerr8.h" -#pragma comment(lib, "DxErr8.lib") - //----------------------------------------------------------------------------- // SAFE_ Macros @@ -46,15 +44,15 @@ //----------------------------------------------------------------------------- // Simple function for generating random numbers -inline float randomf( float low=-1.0f, float high=1.0f ) +inline float randomf( const float low=-1.0f, const float high=1.0f ) { return low + ( high - low ) * ( (FLOAT)rand() ) / RAND_MAX; } -inline int roundf( float f ) { return (int)((f)+0.5f); }; -inline int roundf( double f ) { return (int)((f)+0.5); }; +inline int roundf( const float f ) { return (int)((f)+0.5f); }; +inline int roundf( const double f ) { return (int)((f)+0.5); }; -bool IsAnInt( CString s ); +bool IsAnInt( LPCTSTR s ); CString ssprintf( LPCTSTR fmt, ...); @@ -65,39 +63,44 @@ CString vssprintf( LPCTSTR fmt, va_list argList ); // param1: Whether the Supplied Path (PARAM2) contains a directory name only // or a file name (Reason: some directories will end with "xxx.xxx" // which is like a file name). -void splitpath(BOOL UsingDirsOnly, CString Path, CString& Drive, CString& Dir, CString& FName, CString& Ext); +void splitpath( + const bool UsingDirsOnly, + const CString &Path, + CString &Drive, + CString &Dir, + CString &FName, + CString &Ext +); -void splitrelpath( CString Path, CString& Dir, CString& FName, CString& Ext ); +void splitrelpath( + const CString &Path, + CString& Dir, + CString& FName, + CString& Ext +); // Splits a CString into an CStringArray according the Deliminator. Supports UNC path names. -void split(CString Source, CString Deliminator, CStringArray& AddIt, bool bIgnoreEmpty = true ); +void split( + const CString &Source, + const CString &Deliminator, + CStringArray& AddIt, + const bool bIgnoreEmpty = true +); // Joins a CStringArray to create a CString according the Deliminator. -CString join(CString Deliminator, CStringArray& Source); +CString join( + const CString &Deliminator, + const CStringArray& Source +); void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs=false ); -bool DoesFileExist( CString sPath ); -DWORD GetFileSizeInBytes( CString sFilePath ); - -int CompareCStrings(const void *arg1, const void *arg2); -void SortCStringArray( CStringArray &AddTo, BOOL bSortAcsending = TRUE ); - -//----------------------------------------------------------------------------- -// Log helpers -//----------------------------------------------------------------------------- -void RageLogStart(); -void RageLog( LPCTSTR fmt, ...); -void RageLogHr( HRESULT hr, LPCTSTR fmt, ...); - -//----------------------------------------------------------------------------- -// Error helpers -//----------------------------------------------------------------------------- -void DisplayErrorAndDie( CString sError ); - -#define RageError(str) DisplayErrorAndDie( ssprintf( "%s\n\n%s(%d)", str, __FILE__, (DWORD)__LINE__) ) -#define RageErrorHr(str,hr) DisplayErrorAndDie( ssprintf("%s (%s)\n\n%s(%d)", str, DXGetErrorString8(hr), __FILE__, (DWORD)__LINE__) ) +bool DoesFileExist( const CString &sPath ); +DWORD GetFileSizeInBytes( const CString &sFilePath ); +int CompareCStringsAsc(const void *arg1, const void *arg2); +int CompareCStringsDesc(const void *arg1, const void *arg2); +void SortCStringArray( CStringArray &AddTo, const bool bSortAcsending = true ); LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); diff --git a/stepmania/src/RandomSample.cpp b/stepmania/src/RandomSample.cpp index b847a29330..48cc468e4b 100644 --- a/stepmania/src/RandomSample.cpp +++ b/stepmania/src/RandomSample.cpp @@ -13,6 +13,7 @@ #include "RandomSample.h" #include "RageUtil.h" +#include "RageHelper.h" RandomSample::RandomSample() @@ -47,7 +48,7 @@ bool RandomSample::LoadRandomSample( CString sSetFilePath ) { CStdioFile file; if( !file.Open(sSetFilePath, CFile::modeRead|CFile::shareDenyNone) ) - RageError( ssprintf("Error opening sound set file '%s'.", sSetFilePath) ); + HELPER.FatalError( ssprintf("Error opening sound set file '%s'.", sSetFilePath) ); // Split for the directory of the sound set file. We'll need it below @@ -67,18 +68,18 @@ bool RandomSample::LoadRandomSample( CString sSetFilePath ) bool RandomSample::LoadSound( CString sSoundFilePath ) { - RageLog( "RandomSample::LoadSound( %s )", sSoundFilePath ); + HELPER.Log( "RandomSample::LoadSound( %s )", sSoundFilePath ); - RageLog( "Made it here - A" ); + HELPER.Log( "Made it here - A" ); RageSoundSample* pSS = new RageSoundSample; - RageLog( "Made it here - B" ); + HELPER.Log( "Made it here - B" ); pSS->Load( sSoundFilePath ); m_pSamples.Add( pSS ); - RageLog( "Made it here - C" ); + HELPER.Log( "Made it here - C" ); return true; } @@ -88,7 +89,7 @@ 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." ); + HELPER.Log( "WARNING: Tried to play a RandomSample that has 0 sounds loaded." ); } else { diff --git a/stepmania/src/ScoreDisplayRolling.cpp b/stepmania/src/ScoreDisplayRolling.cpp index 135c5ea794..1512fc688d 100644 --- a/stepmania/src/ScoreDisplayRolling.cpp +++ b/stepmania/src/ScoreDisplayRolling.cpp @@ -11,12 +11,13 @@ #include "ScoreDisplayRolling.h" #include "RageUtil.h" +#include "RageHelper.h" #include "ThemeManager.h" ScoreDisplayRolling::ScoreDisplayRolling() { - RageLog( "ScoreDisplayRolling::ScoreDisplayRolling()" ); + HELPER.Log( "ScoreDisplayRolling::ScoreDisplayRolling()" ); // init the text Load( THEME->GetPathTo(FONT_SCORE_NUMBERS) ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 14fa080328..ae87c6e5a5 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -10,13 +10,12 @@ */ -#include "Util.h" #include "Pattern.h" #include "RageUtil.h" #include "Song.h" -#include #include // for fmod +#include "RageHelper.h" @@ -78,7 +77,7 @@ Song::Song() void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut ) { - RageLog( "GetBeatAndBPSFromElapsedTime( fElapsedTime = %f )", fElapsedTime ); + HELPER.Log( "GetBeatAndBPSFromElapsedTime( fElapsedTime = %f )", fElapsedTime ); // This function is a nightmare. Don't even try to understand it. :-) fElapsedTime += m_fOffsetInSeconds; @@ -152,7 +151,7 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl bool Song::LoadFromSongDir( CString sDir ) { - RageLog( "Song::LoadFromSongDir(%s)", sDir ); + HELPER.Log( "Song::LoadFromSongDir(%s)", sDir ); // make sure there is a trailing '\\' at the end of sDir if( sDir.Right(1) != "\\" ) @@ -175,7 +174,7 @@ bool Song::LoadFromSongDir( CString sDir ) if( iNumDWIFiles > 1 ) { - RageError( ssprintf("There is more than one DWI file in '%s'. Which one should I use?", sDir) ); + HELPER.FatalError( ssprintf("There is more than one DWI file in '%s'. Which one should I use?", sDir) ); } else if( iNumDWIFiles == 1 ) { @@ -187,7 +186,7 @@ bool Song::LoadFromSongDir( CString sDir ) } else { - RageError( ssprintf("Couldn't find any BMS or MSD files in '%s'", sDir) ); + HELPER.FatalError( ssprintf("Couldn't find any BMS or MSD files in '%s'", sDir) ); } return TRUE; @@ -197,7 +196,7 @@ bool Song::LoadFromSongDir( CString sDir ) bool Song::LoadSongInfoFromBMSDir( CString sDir ) { - RageLog( "Song::LoadSongInfoFromBMSDir(%s)", sDir ); + HELPER.Log( "Song::LoadSongInfoFromBMSDir(%s)", sDir ); // make sure there is a trailing '\\' at the end of sDir if( sDir.Right(1) != "\\" ) @@ -216,7 +215,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir ) GetDirListing( sDir + CString("*.bms"), arrayBMSFileNames ); if( arrayBMSFileNames.GetSize() == 0 ) - RageError( ssprintf("Couldn't find any BMS files in '%s'", sDir) ); + HELPER.FatalError( ssprintf("Couldn't find any BMS files in '%s'", sDir) ); // Load the Song info from the first BMS file. Silly BMS duplicates the song info in every @@ -236,7 +235,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir ) CStdioFile file; if( !file.Open( m_sSongFilePath, CFile::modeRead|CFile::shareDenyNone ) ) { - RageError( ssprintf("Failed to open %s.", m_sSongFilePath) ); + HELPER.FatalError( ssprintf("Failed to open %s.", m_sSongFilePath) ); return false; } @@ -302,7 +301,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir ) // add, then sort m_BPMSegments.Add( new_seg ); SortBPMSegmentsArray( m_BPMSegments ); - RageLog( "Inserting new BPM change at beat %f, BPM %f", new_seg.m_fStartBeat, new_seg.m_fBPM ); + HELPER.Log( "Inserting new BPM change at beat %f, BPM %f", new_seg.m_fStartBeat, new_seg.m_fBPM ); } else if( -1 != value_name.Find("#backbmp") ) { @@ -331,7 +330,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir ) } const int iNumNotesInThisMeasure = arrayNotes.GetSize(); - //RageLog( "%s:%s: iMeasureNo = %d, iTrackNum = %d, iNumNotesInThisMeasure = %d", + //HELPER.Log( "%s:%s: iMeasureNo = %d, iTrackNum = %d, iNumNotesInThisMeasure = %d", // valuename, sNoteData, iMeasureNo, iTrackNum, iNumNotesInThisMeasure ); for( int j=0; j &arraySongPointers ) @@ -845,7 +849,7 @@ int CompareSongPointersByBPM(const void *arg1, const void *arg2) if( fMaxBPM1 < fMaxBPM2 ) return -1; else if( fMaxBPM1 == fMaxBPM2 ) - return CompareCStrings( (void*)&sFilePath1, (void*)&sFilePath2 ); + return CompareCStringsAsc( (void*)&sFilePath1, (void*)&sFilePath2 ); else return 1; } diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 08a832da42..7d9a9fac26 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -12,6 +12,7 @@ #include "SongManager.h" #include "IniFile.h" +#include "RageHelper.h" SongManager* SONG = NULL; // global and accessable from anywhere in our program @@ -42,7 +43,7 @@ void SongManager::InitSongArrayFromDisk() { LoadStepManiaSongDir( "Songs" ); LoadDWISongDir( "DWI Support" ); - RageLog( "Found %d Songs.", m_pSongs.GetSize() ); + HELPER.Log( "Found %d Songs.", m_pSongs.GetSize() ); } void SongManager::LoadStepManiaSongDir( CString sDir ) @@ -67,7 +68,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir ) GetDirListing( ssprintf("%s\\%s\\*.mp3", sDir, sGroupDirName), arrayFiles ); GetDirListing( ssprintf("%s\\%s\\*.wav", sDir, sGroupDirName), arrayFiles ); if( arrayFiles.GetSize() > 0 ) - RageError( + HELPER.FatalError( ssprintf( "The song folder '%s' must be placed inside of a group folder.\n\n" "All song folders must be placed below a group folder. For example, 'Songs\\DDR 4th Mix\\B4U'. See the StepMania readme for more info.", ssprintf("%s\\%s", sDir, sGroupDirName ) ) @@ -82,7 +83,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir ) if( arrayGroupBanners.GetSize() > 0 ) { m_mapGroupToBannerPath[sGroupDirName] = ssprintf("%s\\%s\\%s", sDir, sGroupDirName, arrayGroupBanners[0] ); - RageLog( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, m_mapGroupToBannerPath[sGroupDirName]) ); + HELPER.Log( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, m_mapGroupToBannerPath[sGroupDirName]) ); } // Find all Song folders in this group directory @@ -167,7 +168,7 @@ void SongManager::ReadStatisticsFromDisk() IniFile ini; ini.SetPath( g_sStatisticsFileName ); if( !ini.ReadFile() ) { - RageLog( "WARNING: Could not read config file '%s'.", g_sStatisticsFileName ); + HELPER.Log( "WARNING: Could not read config file '%s'.", g_sStatisticsFileName ); return; // load nothing } diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 47881911e2..c6fdd0d5d2 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -14,53 +14,32 @@ #include "RageTextureManager.h" #include "PrefsManager.h" #include "IniFile.h" -#include #include +#include "RageHelper.h" Sprite::Sprite() { m_pTexture = NULL; - m_uNumStates = 0; - m_uCurState = 0; + m_iNumStates = 0; + m_iCurState = 0; m_bIsAnimating = TRUE; m_fSecsIntoState = 0.0; m_bUsingCustomTexCoords = false; - m_Effect = no_effect ; - m_fPercentBetweenColors = 0.0f; - m_bTweeningTowardEndColor = true; - m_fDeltaPercentPerSecond = 1.0f; - m_fWagRadians = 0.2f; - m_fWagPeriod = 2.0f; - m_fWagTimer = 0.0f; - m_fSpinSpeed = 2.0f; - m_fVibrationDistance = 5.0f; - m_bVisibleThisFrame = FALSE; - m_HorizAlign = align_center; - m_VertAlign = align_middle; - - - if( PREFS ) - m_bHasShadow = PREFS->m_GameOptions.m_bShadows; - else - m_bHasShadow = true; - - - m_bBlendAdd = false; } Sprite::~Sprite() { -// RageLog( "Sprite Destructor" ); +// HELPER.Log( "Sprite Destructor" ); - TM->UnloadTexture( m_sTexturePath ); + TEXTURE->UnloadTexture( m_sTexturePath ); } bool Sprite::LoadFromTexture( CString sTexturePath, DWORD dwHints, bool bForceReload ) { - RageLog( ssprintf("Sprite::LoadFromTexture(%s)", sTexturePath) ); + HELPER.Log( ssprintf("Sprite::LoadFromTexture(%s)", sTexturePath) ); //Init(); return LoadTexture( sTexturePath, dwHints, bForceReload ); @@ -76,7 +55,7 @@ bool Sprite::LoadFromTexture( CString sTexturePath, DWORD dwHints, bool bForceRe // Delay0000=2.0 bool Sprite::LoadFromSpriteFile( CString sSpritePath, DWORD dwHints, bool bForceReload ) { - RageLog( ssprintf("Sprite::LoadFromSpriteFile(%s)", sSpritePath) ); + HELPER.Log( ssprintf("Sprite::LoadFromSpriteFile(%s)", sSpritePath) ); //Init(); @@ -95,11 +74,11 @@ bool Sprite::LoadFromSpriteFile( CString sSpritePath, DWORD dwHints, bool bForce IniFile ini; ini.SetPath( m_sSpritePath ); if( !ini.ReadFile() ) - RageError( ssprintf("Error opening Sprite file '%s'.", m_sSpritePath) ); + HELPER.FatalError( ssprintf("Error opening Sprite file '%s'.", m_sSpritePath) ); CString sTextureFile = ini.GetValue( "Sprite", "Texture" ); if( sTextureFile == "" ) - RageError( ssprintf("Error reading value 'Texture' from %s.", m_sSpritePath) ); + HELPER.FatalError( ssprintf("Error reading value 'Texture' from %s.", m_sSpritePath) ); CString sTexturePath = sFontDir + sTextureFile; // save the path of the new texture @@ -118,22 +97,22 @@ bool Sprite::LoadFromSpriteFile( CString sSpritePath, DWORD dwHints, bool bForce CString sFrameKey( CString("Frame") + sStateNo ); CString sDelayKey( CString("Delay") + sStateNo ); - m_uFrame[i] = ini.GetValueI( "Sprite", sFrameKey ); - if( m_uFrame[i] >= m_pTexture->GetNumFrames() ) - RageError( ssprintf("In '%s', %s is %d, but the texture %s only has %d frames.", - m_sSpritePath, sFrameKey, m_uFrame[i], sTexturePath, m_pTexture->GetNumFrames()) ); + m_iStateToFrame[i] = ini.GetValueI( "Sprite", sFrameKey ); + if( m_iStateToFrame[i] >= m_pTexture->GetNumFrames() ) + HELPER.FatalError( ssprintf("In '%s', %s is %d, but the texture %s only has %d frames.", + m_sSpritePath, sFrameKey, m_iStateToFrame[i], sTexturePath, m_pTexture->GetNumFrames()) ); m_fDelay[i] = (float)ini.GetValueF( "Sprite", sDelayKey ); - if( m_uFrame[i] == 0 && m_fDelay[i] > -0.00001f && m_fDelay[i] < 0.00001f ) // both values are empty + if( m_iStateToFrame[i] == 0 && m_fDelay[i] > -0.00001f && m_fDelay[i] < 0.00001f ) // both values are empty break; - m_uNumStates = i+1; + m_iNumStates = i+1; } - if( m_uNumStates == 0 ) + if( m_iNumStates == 0 ) { - m_uNumStates = 1; - m_uFrame[0] = 0; + m_iNumStates = 1; + m_iStateToFrame[0] = 0; m_fDelay[0] = 10; } @@ -143,13 +122,13 @@ bool Sprite::LoadFromSpriteFile( CString sSpritePath, DWORD dwHints, bool bForce bool Sprite::LoadTexture( CString sTexturePath, DWORD dwHints, bool bForceReload ) { - if( m_sTexturePath != "" ) // If there was a previous bitmap... - TM->UnloadTexture( m_sTexturePath ); // Unload it. + if( m_pTexture != NULL ) // If there was a previous bitmap... + TEXTURE->UnloadTexture( m_sTexturePath ); // Unload it. m_sTexturePath = sTexturePath; - m_pTexture = TM->LoadTexture( m_sTexturePath, dwHints, bForceReload ); + m_pTexture = TEXTURE->LoadTexture( m_sTexturePath, dwHints, bForceReload ); assert( m_pTexture != NULL ); // the size of the sprite is the size of the image before it was scaled @@ -157,11 +136,11 @@ bool Sprite::LoadTexture( CString sTexturePath, DWORD dwHints, bool bForceReload SetHeight( (float)m_pTexture->GetSourceFrameHeight() ); // Assume the frames of this animation play in sequential order with 0.2 second delay. - for( UINT i=0; iGetNumFrames(); i++ ) + for( int i=0; iGetNumFrames(); i++ ) { - m_uFrame[i] = i; + m_iStateToFrame[i] = i; m_fDelay[i] = 0.1f; - m_uNumStates = i+1; + m_iNumStates = i+1; } return TRUE; @@ -181,13 +160,13 @@ void Sprite::Update( float fDeltaTime ) { m_fSecsIntoState += fDeltaTime; - if( m_fSecsIntoState > m_fDelay[m_uCurState] ) // it's time to switch frames + if( m_fSecsIntoState > m_fDelay[m_iCurState] ) // it's time to switch frames { // increment frame and reset the counter - m_fSecsIntoState -= m_fDelay[m_uCurState]; // leave the left over time for the next frame - m_uCurState ++; - if( m_uCurState >= m_uNumStates ) - m_uCurState = 0; + m_fSecsIntoState -= m_fDelay[m_iCurState]; // leave the left over time for the next frame + m_iCurState ++; + if( m_iCurState >= m_iNumStates ) + m_iCurState = 0; } } @@ -204,45 +183,7 @@ void Sprite::RenderPrimitives() if( m_pTexture == NULL ) return; - 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_effect_colorDiffuse1 : m_effect_colorDiffuse2; - } - break; - case camelion: - { - for(int i=0; i<4; i++) - colorDiffuse[i] = m_effect_colorDiffuse1*m_fPercentBetweenColors + m_effect_colorDiffuse2*(1.0f-m_fPercentBetweenColors); - } - break; - case glowing: - colorAdd = m_effect_colorAdd1*m_fPercentBetweenColors + m_effect_colorAdd2*(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; - } + // use m_temp_* variables to draw the object // make the object in logical units centered at the origin @@ -288,7 +229,7 @@ void Sprite::RenderPrimitives() } else { - UINT uFrameNo = m_uFrame[m_uCurState]; + UINT uFrameNo = m_iStateToFrame[m_iCurState]; FRECT* pTexCoordRect = m_pTexture->GetTextureCoordRect( uFrameNo ); v[0].tu = pTexCoordRect->left; v[0].tv = pTexCoordRect->bottom; // bottom left @@ -315,19 +256,19 @@ void Sprite::RenderPrimitives() - if( colorDiffuse[0].a != 0 ) + if( m_temp_colorDiffuse[0].a != 0 ) { ////////////////////// // render the shadow ////////////////////// - if( m_bHasShadow ) + if( m_bShadow ) { SCREEN->PushMatrix(); SCREEN->Translate( 5, 5, 0 ); // shift by 5 units 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 + v[0].color = v[1].color = v[2].color = v[3].color = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black pVB->Unlock(); @@ -349,10 +290,10 @@ void Sprite::RenderPrimitives() ////////////////////// 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 + v[0].color = m_temp_colorDiffuse[2]; // bottom left + v[1].color = m_temp_colorDiffuse[0]; // top left + v[2].color = m_temp_colorDiffuse[3]; // bottom right + v[3].color = m_temp_colorDiffuse[1]; // top right pVB->Unlock(); @@ -373,11 +314,11 @@ void Sprite::RenderPrimitives() ////////////////////// // render the add pass ////////////////////// - if( colorAdd.a != 0 ) + if( m_temp_colorAdd.a != 0 ) { pVB->Lock( 0, 0, (BYTE**)&v, 0 ); - v[0].color = v[1].color = v[2].color = v[3].color = colorAdd; + v[0].color = v[1].color = v[2].color = v[3].color = m_temp_colorAdd; pVB->Unlock(); @@ -394,10 +335,10 @@ void Sprite::RenderPrimitives() } -void Sprite::SetState( UINT uNewState ) +void Sprite::SetState( int iNewState ) { - ASSERT( uNewState >= 0 && uNewState < m_uNumStates ); - m_uCurState = uNewState; + ASSERT( iNewState >= 0 && iNewState < m_iNumStates ); + m_iCurState = iNewState; m_fSecsIntoState = 0.0; } diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 57eee7e147..631b8796d1 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -41,9 +41,9 @@ public: virtual void StartAnimating() { m_bIsAnimating = TRUE; }; virtual void StopAnimating() { m_bIsAnimating = FALSE; }; - virtual void SetState( UINT uNewState ); + virtual void SetState( int iNewState ); - UINT GetNumStates() { return m_uNumStates; }; + int GetNumStates() { return m_iNumStates; }; CString GetTexturePath() { return m_sTexturePath; }; @@ -53,12 +53,6 @@ public: void SetCustomImageRect( FRECT rectImageCoords ); // in image pixel space void SetCustomImageCoords( float fImageCoords[8] ); - void TurnShadowOn() { m_bHasShadow = true; }; - void TurnShadowOff() { m_bHasShadow = false; }; - - void SetBlendModeAdd() { m_bBlendAdd = true; }; - void SetBlendModeNormal() { m_bBlendAdd = false; }; - protected: virtual bool LoadFromTexture( CString sTexturePath, DWORD dwHints = 0, bool bForceReload = false ); @@ -72,20 +66,16 @@ protected: RageTexture* m_pTexture; CString m_sTexturePath; - UINT m_uFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames + int m_iStateToFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames float m_fDelay[MAX_SPRITE_STATES]; - UINT m_uNumStates; - UINT m_uCurState; + int m_iNumStates; + int m_iCurState; bool m_bIsAnimating; float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame bool m_bUsingCustomTexCoords; //FRECT m_CustomTexCoordRect; float m_CustomTexCoords[8]; // (x,y) * 4 - - bool m_bHasShadow; - - bool m_bBlendAdd; }; diff --git a/stepmania/src/StepMania.RC b/stepmania/src/StepMania.RC index 612ae08a6b..a5ef09fc08 100644 --- a/stepmania/src/StepMania.RC +++ b/stepmania/src/StepMania.RC @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -52,15 +52,12 @@ END // Accelerator // -IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE +IDR_MAIN_ACCEL ACCELERATORS BEGIN - VK_F4, IDM_TOGGLEFULLSCREEN, VIRTKEY, NOINVERT VK_F5, IDM_CHANGERESOLUTION, VIRTKEY, NOINVERT - VK_F6, IDM_CHANGEDISPLAYCOLOR, VIRTKEY, NOINVERT - VK_F7, IDM_CHANGETEXTURECOLOR, VIRTKEY, NOINVERT - VK_F8, IDM_TOGGLESTATISTICS, VIRTKEY, NOINVERT - VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT "X", IDM_EXIT, VIRTKEY, ALT, NOINVERT + VK_F4, IDM_TOGGLEFULLSCREEN, VIRTKEY, NOINVERT + VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT END @@ -71,9 +68,8 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_ICON ICON DISCARDABLE "StepMania.ICO" +IDI_ICON ICON "StepMania.ICO" -#ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version @@ -96,18 +92,14 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "Chris Danford\0" - VALUE "FileDescription", "StepMania\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "StepMania\0" - VALUE "LegalCopyright", "Copyright © 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "StepMania.exe\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", " StepMania\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - VALUE "SpecialBuild", "\0" + VALUE "CompanyName", "http://www.stepmania.com" + VALUE "FileDescription", "StepMania" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "StepMania" + VALUE "LegalCopyright", "Copyright © 2001-2002" + VALUE "OriginalFilename", "StepMania.exe" + VALUE "ProductName", " StepMania" + VALUE "ProductVersion", "1, 0, 0, 1" END END BLOCK "VarFileInfo" @@ -116,36 +108,35 @@ BEGIN END END -#endif // !_MAC - ///////////////////////////////////////////////////////////////////////////// // // Bitmap // -BITMAP_ERROR BITMAP DISCARDABLE "error.bmp" -BITMAP_SPLASH BITMAP DISCARDABLE "splash.bmp" +BITMAP_ERROR BITMAP "error.bmp" +BITMAP_SPLASH BITMAP "splash.bmp" ///////////////////////////////////////////////////////////////////////////// // // Dialog // -IDD_ERROR_DIALOG DIALOG DISCARDABLE 0, 0, 332, 234 -STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION +IDD_ERROR_DIALOG DIALOGEX 0, 0, 332, 234 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION CAPTION "StepMania Error" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - EDITTEXT IDC_EDIT_ERROR,5,80,320,80,ES_CENTER | ES_MULTILINE | - ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP + EDITTEXT IDC_EDIT_ERROR,5,80,320,130,ES_MULTILINE | + ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT + WS_TABSTOP DEFPUSHBUTTON "Close",IDOK,265,215,60,15 CONTROL 129,IDC_STATIC,"Static",SS_BITMAP,0,0,258,37 - LTEXT "We're sorry. An error has occurred while running StepMania.\r\n\r\nMore specific details about the error may be listeted in the box below:", - IDC_STATIC,7,47,298,28 + LTEXT "Sorry! An error has occurred while running StepMania.\r\n\r\nSpecific details about the error may be listeted in the box below:", + IDC_STATIC,7,46,298,28 PUSHBUTTON "Restart StepMania",IDC_BUTTON_RESTART,175,215,80,15 - PUSHBUTTON "Report the Error",IDC_BUTTON_REPORT,120,190,80,15 - PUSHBUTTON "View Log",IDC_BUTTON_VIEW_LOG,120,170,80,15 + PUSHBUTTON "Report the Error",IDC_BUTTON_REPORT,90,215,76,15 + PUSHBUTTON "View Log",IDC_BUTTON_VIEW_LOG,8,215,74,15 END #endif // English (U.S.) resources diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 24dd95e6f4..3d6d8b1483 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -14,6 +14,7 @@ //----------------------------------------------------------------------------- #include "resource.h" +#include "RageHelper.h" #include "RageScreen.h" #include "RageTextureManager.h" #include "RageSound.h" @@ -25,9 +26,9 @@ #include "ThemeManager.h" #include "WindowManager.h" #include "GameManager.h" +#include "FontManager.h" #include "WindowSandbox.h" -#include "WindowLoading.h" #include "WindowMenuResults.h" #include "WindowTitleMenu.h" #include "WindowPlayerOptions.h" @@ -59,8 +60,6 @@ const DWORD g_dwWindowStyle = WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_MINIMIZEBOX|WS_M BOOL g_bIsActive = FALSE; // Whether the focus is on our app -//LPRageMovieTexture g_pMovieTexture = NULL; - //----------------------------------------------------------------------------- // Function prototypes @@ -69,6 +68,8 @@ BOOL g_bIsActive = FALSE; // Whether the focus is on our app LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); +int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ); // windows entry point +void MainLoop(); // put everything in here so we can wrap it in a try...catch block void Update(); // Update the game logic void Render(); // Render a frame void ShowFrame(); // Display the contents of the back buffer to the screen @@ -79,8 +80,7 @@ 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 SwitchDisplayMode();// BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ); - +void ApplyGraphicOptions(); // Set the display mode according to the user's preferences //----------------------------------------------------------------------------- // Name: WinMain() @@ -91,135 +91,93 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) // Initialize ActiveX for Flash //AfxEnableControlContainer(); -#ifndef DEBUG // don't use error handler in Release mode - try + // + // Check to see if the app is already running. + // + g_hMutex = CreateMutex( NULL, TRUE, g_sAppName ); + if( GetLastError() == ERROR_ALREADY_EXISTS ) { -#endif - // - // Check to see if the app is already running. - // - g_hMutex = CreateMutex( NULL, TRUE, g_sAppName ); - if( GetLastError() == ERROR_ALREADY_EXISTS ) - { - CloseHandle( g_hMutex ); - RageError( "StepMania is already running!" ); - } - - // - // Make sure the current directory is the root program directory - // - if( !DoesFileExist("Songs") ) - { - // change dir to path of the execuctable - TCHAR szFullAppPath[MAX_PATH]; - GetModuleFileName(NULL, szFullAppPath, MAX_PATH); - - // strip off executable name - LPSTR pLastBackslash = strrchr(szFullAppPath, '\\'); - *pLastBackslash = '\0'; // terminate the string - - RageLog( "Changing path to '%s'", szFullAppPath ); - SetCurrentDirectory( szFullAppPath ); - } - - - - - - CoInitialize (NULL); // Initialize COM - - // Register the window class - WNDCLASS wndClass = { - 0, - WndProc, // callback handler - 0, // cbClsExtra; - 0, // cbWndExtra; - hInstance, - LoadIcon( hInstance, MAKEINTRESOURCE(IDI_ICON) ), - LoadCursor( hInstance, IDC_ARROW), - (HBRUSH)GetStockObject( BLACK_BRUSH ), - NULL, // lpszMenuName; - g_sAppClassName // lpszClassName; - }; - RegisterClass( &wndClass ); - - - // Set the window's initial width - RECT rcWnd; - SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); - AdjustWindowRect( &rcWnd, g_dwWindowStyle, FALSE ); - - - // Create our main window - g_hWndMain = CreateWindow( - g_sAppClassName,// pointer to registered class name - g_sAppName, // pointer to window name - g_dwWindowStyle, // window StyleDef - CW_USEDEFAULT, // horizontal position of window - CW_USEDEFAULT, // vertical position of window - RECTWIDTH(rcWnd), // window width - RECTHEIGHT(rcWnd),// window height - NULL, // handle to parent or owner window - NULL, // handle to menu, or child-window identifier - hInstance, // handle to application instance - NULL // pointer to window-creation data - ); - if( NULL == g_hWndMain ) - exit(1); - - - // Load keyboard accelerators - HACCEL hAccel = LoadAccelerators( NULL, MAKEINTRESOURCE(IDR_MAIN_ACCEL) ); - - // run the game - CreateObjects( g_hWndMain ); // Create the game objects - - // Now we're ready to recieve and process Windows messages. - MSG msg; - ZeroMemory( &msg, sizeof(msg) ); - - while( WM_QUIT != msg.message ) - { - // Look for messages, if none are found then - // update the state and display it - if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) - { - GetMessage(&msg, NULL, 0, 0 ); - - // Translate and dispatch the message - if( 0 == TranslateAccelerator( g_hWndMain, hAccel, &msg ) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - else // No messages are waiting. Render a frame during idle time. - { - Update(); - Render(); - //if( !g_bFullscreen ) - ::Sleep(0 ); // give some time for the movie decoding thread - } - } // end while( WM_QUIT != msg.message ) - - - // clean up after a normal exit CloseHandle( g_hMutex ); - DestroyObjects(); // deallocate our game objects and leave fullscreen - DestroyWindow( g_hWndMain ); - UnregisterClass( g_sAppClassName, hInstance ); - CoUninitialize(); // Uninitialize COM - - - -#ifndef DEBUG // only use pretty error handler in RELEASE build + HELPER.FatalError( "StepMania is already running!" ); } - catch(...) // catch all exceptions - { - CloseHandle( g_hMutex ); - DestroyObjects(); // deallocate our game objects and leave fullscreen - ShowWindow( g_hWndMain, SW_HIDE ); + + // + // Make sure the current directory is the root program directory + // + if( !DoesFileExist("Songs") ) + { + // change dir to path of the execuctable + TCHAR szFullAppPath[MAX_PATH]; + GetModuleFileName(NULL, szFullAppPath, MAX_PATH); + + // strip off executable name + LPSTR pLastBackslash = strrchr(szFullAppPath, '\\'); + *pLastBackslash = '\0'; // terminate the string + + SetCurrentDirectory( szFullAppPath ); + } + + + CoInitialize (NULL); // Initialize COM + + // Register the window class + WNDCLASS wndClass = { + 0, + WndProc, // callback handler + 0, // cbClsExtra; + 0, // cbWndExtra; + hInstance, + LoadIcon( hInstance, MAKEINTRESOURCE(IDI_ICON) ), + LoadCursor( hInstance, IDC_ARROW), + (HBRUSH)GetStockObject( BLACK_BRUSH ), + NULL, // lpszMenuName; + g_sAppClassName // lpszClassName; + }; + RegisterClass( &wndClass ); + + + // Set the window's initial width + RECT rcWnd; + SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); + AdjustWindowRect( &rcWnd, g_dwWindowStyle, FALSE ); + + + // Create our main window + g_hWndMain = CreateWindow( + g_sAppClassName,// pointer to registered class name + g_sAppName, // pointer to window name + g_dwWindowStyle, // window StyleDef + CW_USEDEFAULT, // horizontal position of window + CW_USEDEFAULT, // vertical position of window + RECTWIDTH(rcWnd), // window width + RECTHEIGHT(rcWnd),// window height + NULL, // handle to parent or owner window + NULL, // handle to menu, or child-window identifier + hInstance, // handle to application instance + NULL // pointer to window-creation data + ); + if( NULL == g_hWndMain ) + exit(1); + + + + + + + bool bSuccess = HELPER.Run( MainLoop ); + + + + + + // clean up after a normal exit + DestroyObjects(); // deallocate our game objects and leave fullscreen + ShowWindow( g_hWndMain, SW_HIDE ); + + + if( !bSuccess ) + { // throw up a pretty error dialog DialogBox( hInstance, @@ -227,15 +185,54 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) NULL, ErrorWndProc ); - exit( 1 ); } -#endif - + DestroyWindow( g_hWndMain ); + UnregisterClass( g_sAppClassName, hInstance ); + CoUninitialize(); // Uninitialize COM + CloseHandle( g_hMutex ); return 0L; } +void MainLoop() +{ + // Load keyboard accelerators + HACCEL hAccel = LoadAccelerators( NULL, MAKEINTRESOURCE(IDR_MAIN_ACCEL) ); + + // run the game + CreateObjects( g_hWndMain ); // Create the game objects + + // Now we're ready to recieve and process Windows messages. + MSG msg; + ZeroMemory( &msg, sizeof(msg) ); + + while( WM_QUIT != msg.message ) + { + // Look for messages, if none are found then + // update the state and display it + if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) + { + GetMessage(&msg, NULL, 0, 0 ); + + // Translate and dispatch the message + if( 0 == TranslateAccelerator( g_hWndMain, hAccel, &msg ) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } + else // No messages are waiting. Render a frame during idle time. + { + Update(); + Render(); + //if( !g_bFullscreen ) + //::Sleep(0 ); // give some time for the movie decoding thread + } + } // end while( WM_QUIT != msg.message ) + +} + //----------------------------------------------------------------------------- // Name: ErrorWndProc() @@ -247,25 +244,14 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { case WM_INITDIALOG: { - CString sError; - CStdioFile file; - if( file.Open("error.txt", CFile::modeRead) ) - { - CString sBuffer; - while( file.ReadString(sBuffer) ) - { - sError += sBuffer + "\r\n"; - } - } - sError.TrimRight(); - if( sError == "" ) - sError = "Program Crash. Click 'View Log' for trace."; + CString sMessage = HELPER.GetError() + "\n\nStack Trace:\n" + HELPER.GetErrorStackTrace(); + sMessage.Replace( "\n", "\r\n" ); SendDlgItemMessage( hWnd, IDC_EDIT_ERROR, WM_SETTEXT, 0, - (LPARAM)(LPCTSTR)sError + (LPARAM)(LPCTSTR)sMessage ); } break; @@ -391,31 +377,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_COMMAND: { - GameOptions &go = PREFS->m_GameOptions; + GraphicOptions &go = PREFS->m_GraphicOptions; switch( LOWORD(wParam) ) { - case IDM_TOGGLEFULLSCREEN: go.m_bWindowed = !go.m_bWindowed; - SwitchDisplayMode();// !SCREEN->IsWindowed(), SCREEN_WIDTH, SCREEN_HEIGHT, 16 ); + ApplyGraphicOptions(); return 0; case IDM_CHANGERESOLUTION: go.m_iResolution = (go.m_iResolution==640) ? 320 : 640; - SwitchDisplayMode(); + ApplyGraphicOptions(); return 0; - case IDM_CHANGEDISPLAYCOLOR: - go.m_iDisplayColor = (go.m_iDisplayColor==16) ? 32 : 16; - SwitchDisplayMode(); - return 0; - case IDM_CHANGETEXTURECOLOR: - go.m_iTextureColor = (go.m_iTextureColor==16) ? 32 : 16; - SwitchDisplayMode(); - return 0; - case IDM_TOGGLESTATISTICS: - go.m_bShowFPS = !go.m_bShowFPS; - SwitchDisplayMode(); - return 0; - case IDM_EXIT: + case IDM_EXIT: // Recieved key/menu command to exit app SendMessage( hWnd, WM_CLOSE, 0, 0 ); return 0; @@ -481,29 +454,34 @@ HRESULT CreateObjects( HWND hWnd ) // Create game objects // srand( (unsigned)time(NULL) ); // seed number generator - RageLogStart(); SOUND = new RageSound( hWnd ); MUSIC = new RageSoundStream; - INPUT = new RageInput( hWnd ); + INPUTM = new RageInput( hWnd ); PREFS = new PrefsManager; SCREEN = new RageScreen( hWnd ); - SONG = new SongManager; + SONG = new SongManager; // this takes a long time to load + GAME = new GameManager; + THEME = new ThemeManager; BringWindowToTop( hWnd ); SetForegroundWindow( hWnd ); - // switch the screen resolution according to user's prefs - SwitchDisplayMode(); + // We can't do any texture loading unless the D3D device is created. + // Set the display mode to make sure the D3D device is created. + ApplyGraphicOptions(); - TM = new RageTextureManager( SCREEN ); - THEME = new ThemeManager; + TEXTURE = new RageTextureManager( SCREEN ); + + // Ugly... Set graphic options again so the TextureManager knows our preferences + ApplyGraphicOptions(); + + // These things depend on the TextureManager, so do them last! + FONT = new FontManager; WM = new WindowManager; - GAME = new GameManager; - // Ugly... Switch the screen resolution again so that the system message will display - SwitchDisplayMode(); + ApplyGraphicOptions(); WM->SystemMessage( ssprintf("Found %d songs.", SONG->m_pSongs.GetSize()) ); @@ -533,11 +511,12 @@ void DestroyObjects() SAFE_DELETE( PREFS ); SAFE_DELETE( SONG ); SAFE_DELETE( GAME ); + SAFE_DELETE( FONT ); - SAFE_DELETE( INPUT ); + SAFE_DELETE( INPUTM ); SAFE_DELETE( MUSIC ); SAFE_DELETE( SOUND ); - SAFE_DELETE( TM ); + SAFE_DELETE( TEXTURE ); SAFE_DELETE( SCREEN ); } @@ -607,7 +586,7 @@ void Update() // This was a hack to fix timing issues with the old WindowSelectSong // - if( fDeltaTime > 0.050f ) // we dropped > 5 frames + if( fDeltaTime > 0.050f ) // we dropped a bunch of frames fDeltaTime = 0.050f; MUSIC->Update( fDeltaTime ); @@ -616,8 +595,8 @@ void Update() static DeviceInputArray diArray; - diArray.RemoveAll(); - INPUT->GetDeviceInputs( diArray ); + diArray.SetSize( 0, 10 ); // zero the array + INPUTM->GetDeviceInputs( diArray ); DeviceInput DeviceI; PadInput PadI; @@ -661,7 +640,7 @@ void Render() } else { - RageErrorHr( "Failed to SCREEN->Reset()", hr ); + HELPER.FatalErrorHr( hr, "Failed to SCREEN->Reset()" ); } break; @@ -707,16 +686,27 @@ void ShowFrame() //----------------------------------------------------------------------------- -// Name: SwitchDisplayMode() +// Name: ApplyGraphicOptions() // Desc: //----------------------------------------------------------------------------- -BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ) +void ApplyGraphicOptions() { InvalidateObjects(); + GraphicOptions &go = PREFS->m_GraphicOptions; + // + // Let the texture manager know about our preferences + // + if( TEXTURE != NULL ) + { + TEXTURE->SetMaxTextureSize( go.m_iMaxTextureSize ); + TEXTURE->SetTextureColorDepth( go.m_iTextureColor ); + } + + // // use GameOptions to get the display settings - GameOptions &go = PREFS->m_GameOptions; + // bool bWindowed = go.m_bWindowed; DWORD dwWidth = go.m_iResolution; DWORD dwHeight; @@ -734,31 +724,32 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD } DWORD dwBPP = go.m_iDisplayColor; + DWORD dwFlags = 0 | (go.m_b30fpsLock ? SCREEN_FLAG_CAP_AT_30HZ : 0); + // // If the requested resolution doesn't work, keep switching until we find one that does. - - if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) + // + if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP, dwFlags ) ) { // We failed. Try full screen with same params. bWindowed = false; - if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) + if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP, dwFlags ) ) { // Failed again. Try 16 BPP dwBPP = 16; - if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) + if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP, dwFlags ) ) { // Failed again. Try 640x480 dwWidth = 640; dwHeight = 480; - if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) + if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP, dwFlags ) ) { // Failed again. Try 320x240 dwWidth = 320; dwHeight = 240; - if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) ) + if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP, dwFlags ) ) { - RageError( "Tried every possible display mode, and couldn't change to any of them." ); - return false; + HELPER.FatalError( "Tried every possible display mode, and couldn't change to any of them." ); } } } @@ -768,20 +759,15 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD RestoreObjects(); - if( PREFS ) - { - PREFS->m_GameOptions.m_bWindowed = bWindowed; - PREFS->m_GameOptions.m_iDisplayColor = dwBPP; - PREFS->m_GameOptions.m_iResolution = dwWidth; - PREFS->SavePrefsToDisk(); - } + go.m_bWindowed = bWindowed; + go.m_iDisplayColor = dwBPP; + go.m_iResolution = dwWidth; + PREFS->SavePrefsToDisk(); if( WM ) { WM->SystemMessage( ssprintf("%s - %ux%u - %u bits", bWindowed ? "Windowed" : "FullScreen", dwWidth, dwHeight, dwBPP) ); } - - return true; } diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 79f9c14b65..d7863870cb 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -100,6 +100,14 @@ SOURCE=.\RageBitmapTexture.h # End Source File # Begin Source File +SOURCE=.\RageHelper.cpp +# End Source File +# Begin Source File + +SOURCE=.\RageHelper.h +# End Source File +# Begin Source File + SOURCE=.\RageInput.cpp # End Source File # Begin Source File @@ -248,27 +256,11 @@ SOURCE=.\WindowGameOptions.h # End Source File # Begin Source File -SOURCE=.\WindowIdle.cpp +SOURCE=.\WindowGraphicOptions.cpp # End Source File # Begin Source File -SOURCE=.\WindowIdle.h -# End Source File -# Begin Source File - -SOURCE=.\WindowIntroCovers.cpp -# End Source File -# Begin Source File - -SOURCE=.\WindowIntroCovers.h -# End Source File -# Begin Source File - -SOURCE=.\WindowLoading.cpp -# End Source File -# Begin Source File - -SOURCE=.\WindowLoading.h +SOURCE=.\WindowGraphicOptions.h # End Source File # Begin Source File @@ -296,22 +288,6 @@ SOURCE=.\WindowMenuResults.h # End Source File # Begin Source File -SOURCE=.\WindowMenuSelectMusic.cpp -# End Source File -# Begin Source File - -SOURCE=.\WindowMenuSelectMusic.h -# End Source File -# Begin Source File - -SOURCE=.\WindowMenuSelectStyle.cpp -# End Source File -# Begin Source File - -SOURCE=.\WindowMenuSelectStyle.h -# End Source File -# Begin Source File - SOURCE=.\WindowMessage.h # End Source File # Begin Source File @@ -348,6 +324,30 @@ SOURCE=.\WindowSandbox.h # End Source File # Begin Source File +SOURCE=.\WindowSelectDifficulty.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowSelectDifficulty.h +# End Source File +# Begin Source File + +SOURCE=.\WindowSelectMusic.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowSelectMusic.h +# End Source File +# Begin Source File + +SOURCE=.\WindowSelectStyle.cpp +# End Source File +# Begin Source File + +SOURCE=.\WindowSelectStyle.h +# End Source File +# Begin Source File + SOURCE=.\WindowSongOptions.cpp # End Source File # Begin Source File @@ -384,6 +384,22 @@ SOURCE=.\WindowTitleMenu.h # PROP Default_Filter "" # Begin Source File +SOURCE=.\Font.cpp +# End Source File +# Begin Source File + +SOURCE=.\Font.h +# End Source File +# Begin Source File + +SOURCE=.\FontManager.cpp +# End Source File +# Begin Source File + +SOURCE=.\FontManager.h +# End Source File +# Begin Source File + SOURCE=.\GameConstants.h # End Source File # Begin Source File @@ -576,14 +592,6 @@ SOURCE=.\TransitionFadeWipe.h # End Source File # Begin Source File -SOURCE=.\TransitionFadeWipeWithLogo.cpp -# End Source File -# Begin Source File - -SOURCE=.\TransitionFadeWipeWithLogo.h -# End Source File -# Begin Source File - SOURCE=.\TransitionInvisible.cpp # End Source File # Begin Source File @@ -592,6 +600,14 @@ SOURCE=.\TransitionInvisible.h # End Source File # Begin Source File +SOURCE=.\TransitionKeepAlive.cpp +# End Source File +# Begin Source File + +SOURCE=.\TransitionKeepAlive.h +# End Source File +# Begin Source File + SOURCE=.\TransitionRectWipe.cpp # End Source File # Begin Source File @@ -644,11 +660,11 @@ SOURCE=.\BitmapText.h # End Source File # Begin Source File -SOURCE=.\Rectangle.cpp +SOURCE=.\RectangleActor.cpp # End Source File # Begin Source File -SOURCE=.\Rectangle.h +SOURCE=.\RectangleActor.h # End Source File # Begin Source File @@ -712,6 +728,14 @@ SOURCE=.\GranularityIndicator.h # End Source File # Begin Source File +SOURCE=.\MenuElements.cpp +# End Source File +# Begin Source File + +SOURCE=.\MenuElements.h +# End Source File +# Begin Source File + SOURCE=.\MusicSortDisplay.cpp # End Source File # Begin Source File @@ -907,6 +931,54 @@ SOURCE=.\ScoreDisplayRollingWithFrame.cpp SOURCE=.\ScoreDisplayRollingWithFrame.h # End Source File # End Group +# Begin Group "exception" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\exception\AtlAux2.h +# End Source File +# Begin Source File + +SOURCE=.\exception\debug_stream.h +# End Source File +# Begin Source File + +SOURCE=.\exception\exception2.h +# End Source File +# Begin Source File + +SOURCE=.\exception\exception_trap.h +# End Source File +# Begin Source File + +SOURCE=.\exception\kbase.h +# End Source File +# Begin Source File + +SOURCE=.\exception\se_translator.cpp +# End Source File +# Begin Source File + +SOURCE=.\exception\se_translator.h +# End Source File +# Begin Source File + +SOURCE=.\exception\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\exception\sym_engine.cpp +# End Source File +# Begin Source File + +SOURCE=.\exception\sym_engine.h +# End Source File +# Begin Source File + +SOURCE=.\exception\unhandled_report.h +# End Source File +# End Group # Begin Source File SOURCE=.\error.bmp diff --git a/stepmania/src/StepMania.h b/stepmania/src/StepMania.h index 81f413b024..b14dccb06c 100644 --- a/stepmania/src/StepMania.h +++ b/stepmania/src/StepMania.h @@ -12,9 +12,7 @@ #define _STEPMANIA_H_ -BOOL SwitchDisplayMode();//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ); - - +void ApplyGraphicOptions(); diff --git a/stepmania/src/StepMania.sln b/stepmania/src/StepMania.sln new file mode 100644 index 0000000000..505a0b2292 --- /dev/null +++ b/stepmania/src/StepMania.sln @@ -0,0 +1,28 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StepMania", "StepMania.vcproj", "{670745A6-106B-420D-A2A9-D4F89A23986E}" +EndProject +Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "ZipArchive", "smpackage\ZipArchive\ZipArchive.dsp", "{2AF0D4D5-0984-4AD4-A2BD-402D4BE285CE}" +EndProject +Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "smpackage", "smpackage\smpackage.dsp", "{775C9F19-F852-43AC-8563-D869C027722D}" + ProjectSection(DevStudioProjDeps) = postProject + 0 = ZipArchive + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {670745A6-106B-420D-A2A9-D4F89A23986E}.Debug.ActiveCfg = Debug|Win32 + {670745A6-106B-420D-A2A9-D4F89A23986E}.Debug.Build.0 = Debug|Win32 + {670745A6-106B-420D-A2A9-D4F89A23986E}.Release.ActiveCfg = Release|Win32 + {670745A6-106B-420D-A2A9-D4F89A23986E}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj new file mode 100644 index 0000000000..5021e8c5e1 --- /dev/null +++ b/stepmania/src/StepMania.vcproj @@ -0,0 +1,823 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stepmania/src/TextBanner.h b/stepmania/src/TextBanner.h index 14f3b2d903..3aef40748f 100644 --- a/stepmania/src/TextBanner.h +++ b/stepmania/src/TextBanner.h @@ -15,7 +15,7 @@ #include "ActorFrame.h" #include "Song.h" #include "BitmapText.h" -#include "Rectangle.h" +#include "RectangleActor.h" const float TEXT_BANNER_WIDTH = 250; diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index ac510a74a8..b88ddc51dc 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - Class: ThemeManager + Class: FontManager Desc: See header. @@ -11,6 +11,7 @@ */ #include "ThemeManager.h" +#include "RageHelper.h" @@ -50,7 +51,7 @@ bool ThemeManager::SetTheme( CString sThemeName ) // return false if theme does if( !DoesFileExist( sThemeDir ) ) { - RageError( ssprintf( "The theme in diretory '%' could not be loaded.", sThemeDir ) ); + HELPER.FatalError( ssprintf( "The theme in diretory '%' could not be loaded.", sThemeDir ) ); return false; } @@ -62,7 +63,7 @@ void ThemeManager::AssertThemeIsComplete( CString sThemeName ) // return false for( int i=0; i 0 ) @@ -271,7 +287,7 @@ CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName ) } else { - RageError( ssprintf("Unknown theme asset dir '%s'.", sAssetDir) ); + HELPER.FatalError( ssprintf("Unknown theme asset dir '%s'.", sAssetDir) ); } if( arrayPossibleElementFileNames.GetSize() > 0 ) @@ -279,6 +295,6 @@ CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName ) - RageError( ssprintf("The theme element '%s' does not exist in the current theme directory or the default theme directory.", sAssetDir + "\\" + sAssetFileName) ); + HELPER.FatalError( ssprintf("The theme element '%s' does not exist in the current theme directory or the default theme directory.", sAssetDir + "\\" + sAssetFileName) ); return ""; } diff --git a/stepmania/src/ThemeManager.h b/stepmania/src/ThemeManager.h index 63430f7c6f..958ddcca24 100644 --- a/stepmania/src/ThemeManager.h +++ b/stepmania/src/ThemeManager.h @@ -25,8 +25,9 @@ enum ThemeElement { GRAPHIC_SELECT_STYLE_TOP_EDGE, GRAPHIC_SELECT_MUSIC_TOP_EDGE, GRAPHIC_GAME_OPTIONS_TOP_EDGE, + GRAPHIC_GRAPHIC_OPTIONS_TOP_EDGE, GRAPHIC_PLAYER_OPTIONS_TOP_EDGE, - GRAPHIC_MUSIC_OPTIONS_TOP_EDGE, + GRAPHIC_SONG_OPTIONS_TOP_EDGE, GRAPHIC_RESULT_TOP_EDGE, GRAPHIC_FALLBACK_BANNER, GRAPHIC_FALLBACK_BACKGROUND, @@ -57,7 +58,6 @@ enum ThemeElement { GRAPHIC_PAD_DOUBLE, GRAPHIC_PAD_SOLO, GRAPHIC_STYLE_ICONS, - GRAPHIC_STYLE_EXPLANATIONS, GRAPHIC_MUSIC_SELECTION_HIGHLIGHT, GRAPHIC_STEPS_DESCRIPTION, GRAPHIC_SECTION_BACKGROUND, @@ -70,11 +70,25 @@ enum ThemeElement { GRAPHIC_EDIT_BACKGROUND, GRAPHIC_EDIT_SNAP_INDICATOR, GRAPHIC_GAME_OPTIONS_BACKGROUND, + GRAPHIC_GRAPHIC_OPTIONS_BACKGROUND, GRAPHIC_PLAYER_OPTIONS_BACKGROUND, - GRAPHIC_MUSIC_OPTIONS_BACKGROUND, + GRAPHIC_SONG_OPTIONS_BACKGROUND, GRAPHIC_SYNCHRONIZE_BACKGROUND, GRAPHIC_SYNCHRONIZE_TOP_EDGE, - + GRAPHIC_TITLE_MENU_LOGO, + GRAPHIC_TITLE_MENU_HELP, + GRAPHIC_SELECT_DIFFICULTY_BACKGROUND, + GRAPHIC_SELECT_DIFFICULTY_TOP_EDGE, + GRAPHIC_SELECT_DIFFICULTY_EXPLANATION, + GRAPHIC_SELECT_DIFFICULTY_EASY, + GRAPHIC_SELECT_DIFFICULTY_MEDIUM, + GRAPHIC_SELECT_DIFFICULTY_HARD, + GRAPHIC_SELECT_DIFFICULTY_ARROW, + GRAPHIC_SELECT_DIFFICULTY_OK, + GRAPHIC_SELECT_MUSIC_INFO_FRAME, + GRAPHIC_SELECT_MUSIC_RADAR, + GRAPHIC_SELECT_MUSIC_SCORE_FRAME, + SOUND_FAILED, SOUND_ASSIST, SOUND_SELECT, @@ -92,6 +106,7 @@ enum ThemeElement { SOUND_EDIT_CHANGE_SNAP, FONT_OUTLINE, + FONT_CAPITALS, FONT_NORMAL, FONT_FUTURISTIC, FONT_BOLD_NUMBERS, @@ -119,6 +134,7 @@ enum ThemeElement { ANNOUNCER_RESULT_D, ANNOUNCER_RESULT_E, ANNOUNCER_TITLE, + ANNOUNCER_DIFFICULTY_COMMENT, NUM_THEME_ELEMENTS // leave this at the end diff --git a/stepmania/src/TipDisplay.cpp b/stepmania/src/TipDisplay.cpp index 388d63791b..68e25cad94 100644 --- a/stepmania/src/TipDisplay.cpp +++ b/stepmania/src/TipDisplay.cpp @@ -12,6 +12,7 @@ #include "TipDisplay.h" #include "RageUtil.h" #include "ThemeManager.h" +#include "RageHelper.h" const float TIP_FADE_TIME = 0.3f; @@ -20,7 +21,7 @@ const float TIP_SHOW_TIME = 2; TipDisplay::TipDisplay() { - RageLog( "TipDisplay::TipDisplay()" ); + HELPER.Log( "TipDisplay::TipDisplay()" ); m_textTip.Load( THEME->GetPathTo(FONT_NORMAL) ); this->AddActor( &m_textTip ); diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index 5068a7886e..67c103b4b8 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -70,10 +70,10 @@ protected: { case opening_right: case opening_left: - return 1.0f - m_fPercentThroughTransition; + return m_fPercentThroughTransition; case closing_right: case closing_left: - return m_fPercentThroughTransition; + return 1.0f - m_fPercentThroughTransition; case opened: return 0; case closed: diff --git a/stepmania/src/TransitionFade.cpp b/stepmania/src/TransitionFade.cpp index a72490a03b..13bb8e1df1 100644 --- a/stepmania/src/TransitionFade.cpp +++ b/stepmania/src/TransitionFade.cpp @@ -29,7 +29,7 @@ TransitionFade::~TransitionFade() void TransitionFade::RenderPrimitives() { - float fPercentageOpaque = GetPercentageOpen(); + const float fPercentageOpaque = 1 - GetPercentageOpen(); if( fPercentageOpaque == 0 ) return; // draw nothing diff --git a/stepmania/src/TransitionFade.h b/stepmania/src/TransitionFade.h index 0b38b1f2fb..ace6fb1e36 100644 --- a/stepmania/src/TransitionFade.h +++ b/stepmania/src/TransitionFade.h @@ -16,7 +16,7 @@ #include "Transition.h" #include "RageScreen.h" #include "RageSound.h" -#include "Rectangle.h" +#include "RectangleActor.h" class TransitionFade : public Transition diff --git a/stepmania/src/TransitionFadeWipe.h b/stepmania/src/TransitionFadeWipe.h index b4ddda407d..bc37cb19ca 100644 --- a/stepmania/src/TransitionFadeWipe.h +++ b/stepmania/src/TransitionFadeWipe.h @@ -16,7 +16,7 @@ #include "RageScreen.h" #include "RageSound.h" #include "Sprite.h" -#include "Rectangle.h" +#include "RectangleActor.h" class TransitionFadeWipe : public Transition diff --git a/stepmania/src/TransitionInvisible.h b/stepmania/src/TransitionInvisible.h index da24f34f51..18c9815c87 100644 --- a/stepmania/src/TransitionInvisible.h +++ b/stepmania/src/TransitionInvisible.h @@ -16,7 +16,7 @@ #include "Transition.h" #include "RageScreen.h" #include "RageSound.h" -#include "Rectangle.h" +#include "RectangleActor.h" class TransitionInvisible : public Transition diff --git a/stepmania/src/TransitionKeepAlive.cpp b/stepmania/src/TransitionKeepAlive.cpp new file mode 100644 index 0000000000..6f97d668d5 --- /dev/null +++ b/stepmania/src/TransitionKeepAlive.cpp @@ -0,0 +1,42 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + File: TransitionStarWipe.cpp + + Desc: Black bands (horizontal window blinds) gradually close. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#include "RageUtil.h" + +#include "TransitionKeepAlive.h" +#include "ScreenDimensions.h" +#include "ThemeManager.h" + + +TransitionKeepAlive::TransitionKeepAlive() +{ + m_sprLogo.Load( THEME->GetPathTo(GRAPHIC_KEEP_ALIVE) ); + m_sprLogo.SetXY( CENTER_X, CENTER_Y ); +} + +void TransitionKeepAlive::Update( float fDeltaTime ) +{ + // hack: Smooth out the big hickups. + fDeltaTime = min( fDeltaTime, 1/15.0f ); + + Transition::Update( fDeltaTime ); +} + + +void TransitionKeepAlive::RenderPrimitives() +{ + const float fPercentClosed = 1 - this->GetPercentageOpen(); + m_sprLogo.SetDiffuseColor( D3DXCOLOR(1,1,1,fPercentClosed) ); + if( fPercentClosed > 0 ) + m_sprLogo.Draw(); +} + + diff --git a/stepmania/src/TransitionKeepAlive.h b/stepmania/src/TransitionKeepAlive.h new file mode 100644 index 0000000000..d6206dd896 --- /dev/null +++ b/stepmania/src/TransitionKeepAlive.h @@ -0,0 +1,34 @@ +/* +----------------------------------------------------------------------------- + File: TransitionKeepAlive.cpp + + Desc: Fades out or in. + + Copyright (c) 2001 Chris Danford. All rights reserved. +----------------------------------------------------------------------------- +*/ + +#ifndef _TransitionKeepAlive_H_ +#define _TransitionKeepAlive_H_ + + +#include "Sprite.h" +#include "TransitionFadeWipe.h" + + +class TransitionKeepAlive : public Transition +{ +public: + TransitionKeepAlive(); + + virtual void Update( float fDeltaTime ); + virtual void RenderPrimitives(); + +protected: + Sprite m_sprLogo; +}; + + + + +#endif \ No newline at end of file diff --git a/stepmania/src/TransitionStarWipe.cpp b/stepmania/src/TransitionStarWipe.cpp index b46d8b8307..03b5aedc6e 100644 --- a/stepmania/src/TransitionStarWipe.cpp +++ b/stepmania/src/TransitionStarWipe.cpp @@ -37,7 +37,8 @@ void TransitionStarWipe::RenderPrimitives() return; } - float fPercentOpen; + float fPercentOpen = GetPercentageOpen(); + /* switch( m_TransitionState ) { case opening_right: @@ -49,6 +50,7 @@ void TransitionStarWipe::RenderPrimitives() fPercentOpen = m_fPercentThroughTransition; break; } + */ int iNumStars = SCREEN_HEIGHT/m_iStarHeight + 1; @@ -69,6 +71,9 @@ void TransitionStarWipe::RenderPrimitives() x_tilt = abs( y - SCREEN_HEIGHT/2 ); if( bIsAnEvenRow ) x_tilt *= -1; break; + default: + ASSERT( false ); + x_tilt = 0; } int x_offset = (int)(fPercentOpen*(SCREEN_WIDTH+SCREEN_HEIGHT+m_iStarWidth)); diff --git a/stepmania/src/TransitionStarWipe.h b/stepmania/src/TransitionStarWipe.h index 112dc966ef..d685ff1aaf 100644 --- a/stepmania/src/TransitionStarWipe.h +++ b/stepmania/src/TransitionStarWipe.h @@ -15,7 +15,7 @@ #include "Transition.h" #include "RageScreen.h" #include "RageSound.h" -#include "Rectangle.h" +#include "RectangleActor.h" class TransitionStarWipe : public Transition diff --git a/stepmania/src/log.txt b/stepmania/src/log.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stepmania/src/smpackage/ZipArchive/ZipArchive.dsp b/stepmania/src/smpackage/ZipArchive/ZipArchive.dsp index c9288f830e..647f1f7c87 100644 --- a/stepmania/src/smpackage/ZipArchive/ZipArchive.dsp +++ b/stepmania/src/smpackage/ZipArchive/ZipArchive.dsp @@ -69,7 +69,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "_AFXDLL" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "ZIP_ARCHIVE_MFC_PROJ" /Fr /YX"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_AFXDLL" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "ZIP_ARCHIVE_MFC_PROJ" /Fr /YX"stdafx.h" /FD /GZ /c # ADD BASE RSC /l 0x415 /d "_DEBUG" /d "_AFXDLL" # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" BSC32=bscmake.exe