in the middle of working on 1.70. Now compiles in Visual Studio.net

This commit is contained in:
Chris Danford
2002-03-30 20:00:13 +00:00
parent 1c6533c283
commit d2eeed810c
72 changed files with 2726 additions and 1321 deletions
+63 -17
View File
@@ -12,6 +12,7 @@
#include "Actor.h"
#include <math.h>
#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;
+36 -6
View File
@@ -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;
};
+1 -1
View File
@@ -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 );
+3
View File
@@ -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;
+1 -1
View File
@@ -17,7 +17,7 @@
#include "Song.h"
#include "ActorFrame.h"
#include "BitmapText.h"
#include "Rectangle.h"
#include "RectangleActor.h"
class BPMDisplay : public ActorFrame
+3 -3
View File
@@ -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) );
+8 -8
View File
@@ -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
+3 -3
View File
@@ -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();
+128 -283
View File
@@ -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 <stdio.h>
#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; i<NUM_CHARS; i++ )
{
m_iCharToFrameNo[i] = -1;
m_fFrameNoToWidth[i] = -1;
}
m_HorizAlign = align_center;
m_VertAlign = align_middle;
// m_bHasShadow = false;
m_pFont = NULL;
// create the vertex buffer
HRESULT hr = SCREEN->GetDevice()->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; i<MAX_TEXT_LINES; i++ )
{
m_szTextLines[i] = '\0';
m_iLineLengths[i] = -1;
m_iLineWidths[i] = 1;
}
}
BitmapText::~BitmapText()
{
SAFE_RELEASE( m_pVB );
if( m_pFont )
FONT->UnloadFont( 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; i<sCharacters.GetLength(); i++ )
{
char c = sCharacters[i];
int iFrameNo = i;
m_iCharToFrameNo[c] = iFrameNo;
}
}
else // no creator supplied characters. Assume this is a full high ASCII set
{
for( int i=0; i<NUM_CHARS; i++ )
m_iCharToFrameNo[i] = i;
}
// and load character widths
CString sWidthsValue = ini.GetValue( "Font", "Widths" );
if( sWidthsValue != "" ) // the creator supplied witdths
{
CStringArray arrayCharWidths;
split( sWidthsValue, ",", arrayCharWidths );
if( arrayCharWidths.GetSize() != (int)Sprite::GetNumStates() )
RageError( ssprintf("The number of widths specified in '%s' (%d) do not match the number of frames in the texture (%u).", m_sFontFilePath, arrayCharWidths.GetSize(), Sprite::GetNumStates()) );
for( int i=0; i<arrayCharWidths.GetSize(); i++ )
{
m_fFrameNoToWidth[i] = (float)atof( arrayCharWidths[i] );
}
}
else // no creator supplied withds. Assume each character is the width of the frame
{
for( int i=0; i<(int)Sprite::GetNumStates(); i++ )
{
m_fFrameNoToWidth[i] = (float)m_pTexture->GetSourceFrameWidth();
}
}
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<m_sTextLines.GetSize(); i++ )
int iLength = strlen( m_szText );
//
// strip out non-low ASCII chars
//
for( int i=0; i<iLength; i++ ) // for each character
{
float fLineWidth = GetLineWidthInSourcePixels(i);
if( fLineWidth > 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; i<sLine.GetLength(); i++ )
//
// calculate line lengths and widths
//
m_iWidestLineWidth = 0;
for( int l=0; l<m_iNumLines; l++ ) // for each line
{
char c = sLine[i];
int iFrameNo = m_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) );
fLineWidth += m_fFrameNoToWidth[iFrameNo];
m_iLineLengths[l] = strlen( m_szTextLines[l] );
m_iLineWidths[l] = m_pFont->GetLineWidthInSourcePixels( 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; i<m_sTextLines.GetSize(); i++ ) // foreach line
for( int i=0; i<m_iNumLines; i++ ) // foreach line
{
CString &sLine = m_sTextLines[i];
float fLineWidth = GetLineWidthInSourcePixels(i);
float fX;
LPCTSTR szLine = m_szTextLines[i];
const int iLineLength = m_iLineLengths[i];
const int iLineWidth = m_iLineWidths[i];
int iX;
switch( m_HorizAlign )
{
case align_left: fX = 0; break;
case align_center: fX = -(fLineWidth/2); break;
case align_right: fX = -fLineWidth; break;
default: ASSERT( false );
case align_left: iX = 0; break;
case align_center: iX = -(iLineWidth/2); break;
case align_right: iX = -iLineWidth; break;
default: ASSERT( false );
}
for( int j=0; j<sLine.GetLength(); j++ ) // for each character in the line
for( int j=0; j<iLineLength; j++ ) // for each character in the line
{
char c = sLine[j];
int iFrameNo = m_iCharToFrameNo[c];
const char c = szLine[j];
const int iFrameNo = m_pFont->m_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; i<m_iNumV; i++ )
v[i].color = D3DXCOLOR(0,0,0,0.5f*colorDiffuse[0].a); // semi-transparent black
v[i].color = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black
pVB->Unlock();
@@ -419,9 +288,9 @@ void BitmapText::RenderPrimitives()
for( int i=0; i<m_iNumV; i++ )
{
if( i%2 == 0 ) // this is a bottom vertex
v[i].color = colorDiffuse[0];
v[i].color = m_temp_colorDiffuse[0];
else // this is a top vertex
v[i].color = colorDiffuse[1];
v[i].color = m_temp_colorDiffuse[1];
}
@@ -442,12 +311,12 @@ void BitmapText::RenderPrimitives()
//////////////////////
// render the add pass
//////////////////////
if( colorAdd.a != 0 )
if( m_temp_colorAdd.a != 0 )
{
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
for( int i=0; i<m_iNumV; i++ )
v[i].color = colorAdd;
v[i].color = m_temp_colorAdd;
pVB->Unlock();
@@ -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<sText.GetLength(); i++ ) // for each character
if( sText[i] < 0 || sText[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 );
}
}
+25 -25
View File
@@ -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
};
+11 -18
View File
@@ -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 );
};
};
+1 -1
View File
@@ -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 );
+166
View File
@@ -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 <stdio.h>
#include "RageTextureManager.h"
#include "RageUtil.h"
#include "RageHelper.h"
Font::Font( const CString &sFontFilePath )
{
//HELPER.Log( "Font::LoadFromFontName(%s)", sFontFilePath );
for( int i=0; i<MAX_FONT_CHARS; i++ )
{
m_iCharToFrameNo[i] = -1;
m_iFrameNoToWidth[i] = -1;
}
m_iRefCount = 1;
m_sFontFilePath = sFontFilePath; // save
//
// 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() )
HELPER.FatalError( ssprintf("Error opening Font file '%s'.", m_sFontFilePath) );
//
// load texture
//
CString sTextureFile = ini.GetValue( "Font", "Texture" );
if( sTextureFile == "" )
HELPER.FatalError( ssprintf("Error reading value 'Texture' from %s.", m_sFontFilePath) );
m_sTexturePath = sFontDir + sTextureFile; // save the path of the new texture
m_sTexturePath.MakeLower();
// is this the first time the texture is being loaded?
bool bFirstTimeBeingLoaded = !TEXTURE->IsTextureLoaded( 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; i<sCharacters.GetLength(); i++ )
{
char c = sCharacters[i];
int iFrameNo = i;
m_iCharToFrameNo[c] = iFrameNo;
}
}
else // the font file creator did not supply characters. Assume this is a full low ASCII set.
{
for( int i=0; i<MAX_FONT_CHARS; i++ )
m_iCharToFrameNo[i] = i;
}
//
// load character widths
//
CString sWidthsValue = ini.GetValue( "Font", "Widths" );
if( sWidthsValue != "" ) // the creator supplied witdths
{
CStringArray arrayCharWidths;
split( sWidthsValue, ",", arrayCharWidths );
if( arrayCharWidths.GetSize() != (int)m_pTexture->GetNumFrames() )
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; i<arrayCharWidths.GetSize(); i++ )
{
m_iFrameNoToWidth[i] = atoi( arrayCharWidths[i] );
}
}
else // The font file creator didn't supply widths. Assume each character is the width of the frame.
{
for( int i=0; i<(int)m_pTexture->GetNumFrames(); 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; i<iLength; i++ )
{
const char c = szLine[i];
const int iFrameNo = m_iCharToFrameNo[c];
if( iFrameNo == -1 ) // this font doesn't impelemnt this character
HELPER.FatalError( ssprintf("The font '%s' does not implement the character '%c'", m_sFontFilePath, c) );
iLineWidth += m_iFrameNoToWidth[iFrameNo];
}
return iLineWidth;
}
+43
View File
@@ -0,0 +1,43 @@
/*
-----------------------------------------------------------------------------
File: Font
Desc: A holder for information that is used by BitmapText objects.
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#ifndef _Font_H_
#define _Font_H_
#include "RageTexture.h"
const int MAX_FONT_CHARS = 256; // only low ASCII chars are supported
class Font
{
protected:
public:
Font( const CString &sFontPath );
~Font();
int GetLineWidthInSourcePixels( LPCTSTR szLine, int iLength );
int m_iRefCount;
CString m_sFontFilePath;
CString m_sTexturePath;
RageTexture* m_pTexture;
int m_iCharToFrameNo[MAX_FONT_CHARS];
int m_iFrameNoToWidth[MAX_FONT_CHARS]; // in soure coordinate space
};
#endif
+132
View File
@@ -0,0 +1,132 @@
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
Class: FontManager
Desc: Interface for loading and releasing textures.
Copyright (c) 2001 Chris Danford. All rights reserved.
-----------------------------------------------------------------------------
*/
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "FontManager.h"
#include "Font.h"
#include "RageUtil.h"
#include "RageHelper.h"
FontManager* FONT = NULL;
//-----------------------------------------------------------------------------
// constructor/destructor
//-----------------------------------------------------------------------------
FontManager::FontManager()
{
}
FontManager::~FontManager()
{
// delete all textures
POSITION pos = m_mapPathToFont.GetStartPosition();
CString sFontFilePath;
Font* pFont;
while( pos != NULL ) // iterate over all k/v pairs in map
{
m_mapPathToFont.GetNextAssoc( pos, sFontFilePath, pFont );
HELPER.Log( "FONT LEAK: '%s', RefCount = %d.", sFontFilePath, pFont->m_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) );
}
}
+39
View File
@@ -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<CMapStringToPtr, CString, Font*> m_mapPathToFont;
};
extern FontManager* FONT; // global and accessable from anywhere in our program
#endif
+11 -20
View File
@@ -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) );
};
};
+2 -1
View File
@@ -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;
+1 -1
View File
@@ -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 );
+1 -1
View File
@@ -45,7 +45,7 @@ void HoldJudgement::RenderPrimitives()
void HoldJudgement::SetHoldJudgement( HoldNoteResult result )
{
//RageLog( "Judgement::SetJudgement()" );
//HELPER.Log( "Judgement::SetJudgement()" );
switch( result )
{
+28 -32
View File
@@ -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;
}
+1 -3
View File
@@ -13,7 +13,7 @@
#define _INIFILE_H_
#include <afxtempl.h>
#include <iostream.h>
//#include <iostream.h>
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);
+1 -1
View File
@@ -46,7 +46,7 @@ void Judgement::RenderPrimitives()
void Judgement::SetJudgement( TapNoteScore score )
{
//RageLog( "Judgement::SetJudgement()" );
//HELPER.Log( "Judgement::SetJudgement()" );
switch( score )
{
+176
View File
@@ -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();
}
+66
View File
@@ -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
+1 -1
View File
@@ -22,7 +22,7 @@ class MotionBlurSprite : public Actor
{
public:
virtual bool Load( CString sFilePath ) { for( int i=0; i<NUM_BLUR_GHOSTS; i++ ) m_sprites[i].Load( sFilePath ); return true; };
virtual bool Load( const CString &sFilePath ) { for( int i=0; i<NUM_BLUR_GHOSTS; i++ ) m_sprites[i].Load( sFilePath ); return true; };
virtual void Update( float fDeltaTime ) { for( int i=0; i<NUM_BLUR_GHOSTS; i++ ) m_sprites[i].Update( fDeltaTime ); };
virtual void Draw() { for(int i=0; i<NUM_BLUR_GHOSTS; i++) m_sprites[i].Draw(); };
+3 -2
View File
@@ -17,6 +17,7 @@
#include "ThemeManager.h"
#include "RageMusic.h"
#include "WindowManager.h" // for sending SM_PlayMusicSample
#include "RageHelper.h"
@@ -62,7 +63,7 @@ WheelItemData::WheelItemData()
m_MusicStatusDisplayType = TYPE_NONE;
}
void WheelItemData::LoadFromSectionName( CString sSectionName )
void WheelItemData::LoadFromSectionName( const CString &sSectionName )
{
m_WheelItemType = TYPE_SECTION;
m_sSectionName = sSectionName;
@@ -207,7 +208,7 @@ void WheelItemDisplay::RenderPrimitives()
MusicWheel::MusicWheel()
{
RageLog( "MusicWheel::MusicWheel()" );
HELPER.Log( "MusicWheel::MusicWheel()" );
m_sprSelectionBackground.Load( THEME->GetPathTo(GRAPHIC_MUSIC_SELECTION_HIGHLIGHT) );
m_sprSelectionBackground.SetXY( 0, 0 );
+2 -2
View File
@@ -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;
+13 -13
View File
@@ -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; i<iMissIfOlderThanThisIndex; i++ )
{
//RageLog( "Checking for miss: %d: lefttostepon == %d, score == %d", i, m_LeftToStepOn[i], m_StepScore[i] );
//HELPER.Log( "Checking for miss: %d: lefttostepon == %d, score == %d", i, m_LeftToStepOn[i], m_StepScore[i] );
if( m_TapNotesRemaining[i] != 0 && m_TapNoteScores[i] != TNS_MISS )
{
m_TapNoteScores[i] = TNS_MISS;
+33 -19
View File
@@ -43,7 +43,7 @@ void PrefsManager::ReadPrefsFromDisk()
ini.SetPath( "StepMania.ini" );
if( !ini.ReadFile() ) {
return; // load nothing
//RageError( "could not read config file" );
//HELPER.FatalError( "could not read config file" );
}
CMapStringToString* pKey = ini.GetKeyPointer("Input");
@@ -81,12 +81,6 @@ void PrefsManager::ReadPrefsFromDisk()
{
pKey->GetNextAssoc( 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;
}
}
+3 -1
View File
@@ -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 );
+69 -79
View File
@@ -23,22 +23,25 @@
#include "dxerr8.h"
#include "DXUtil.h"
#include "RageUtil.h"
#include "PrefsManager.h"
#include "RageHelper.h"
//#include <stdio.h>
#include <assert.h>
//-----------------------------------------------------------------------------
// 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;
}
}
+10 -6
View File
@@ -10,8 +10,6 @@
class RageBitmapTexture;
typedef RageBitmapTexture* LPRageBitmapTexture;
@@ -25,8 +23,8 @@ typedef RageBitmapTexture* LPRageBitmapTexture;
//#include <d3d8types.h>
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;
};
+24 -19
View File
@@ -24,9 +24,10 @@
#include "RageInput.h"
#include <dinput.h>
#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; i<NUM_JOYSTICKS; i++ )
{
@@ -393,14 +398,14 @@ HRESULT RageInput::Initialize()
// passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState().
if( m_pJoystick[i] )
if( FAILED( hr = m_pJoystick[i]->SetDataFormat( &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?!?
+3 -5
View File
@@ -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<DeviceInput, DeviceInput&> DeviceInputArray;
typedef CArray<DeviceInput, DeviceInput> 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
+35 -65
View File
@@ -30,9 +30,9 @@
#include "dxerr8.h"
#include "DXUtil.h"
#include "RageUtil.h"
#include "RageHelper.h"
#include <stdio.h>
#include <assert.h>
//-----------------------------------------------------------------------------
// 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;
}
+1 -3
View File
@@ -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
+7 -6
View File
@@ -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"
+1 -3
View File
@@ -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
+19 -19
View File
@@ -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<m_uFramesHigh; j++ ) // traverse along Y
for( int j=0; j<m_iFramesHigh; j++ ) // traverse along Y
{
for( UINT i=0; i<m_uFramesWide; i++ ) // traverse along X (important that this is the inner loop)
for( int i=0; i<m_iFramesWide; i++ ) // traverse along X (important that this is the inner loop)
{
FRECT frect( (i+0)/(float)m_uFramesWide*m_uImageWidth /m_uTextureWidth, // these will all be between 0.0 and 1.0
(j+0)/(float)m_uFramesHigh*m_uImageHeight/m_uTextureHeight,
(i+1)/(float)m_uFramesWide*m_uImageWidth /m_uTextureWidth,
(j+1)/(float)m_uFramesHigh*m_uImageHeight/m_uTextureHeight );
m_TextureCoordRects.Add( frect ); // the index of this array element will be (i + j*m_uFramesWide)
FRECT frect( (i+0)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth, // these will all be between 0.0 and 1.0
(j+0)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight,
(i+1)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth,
(j+1)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight );
m_TextureCoordRects.Add( frect ); // the index of this array element will be (i + j*m_iFramesWide)
//RageLog( "Adding frect%d %f %f %f %f", (i + j*m_uFramesWide), frect.left, frect.top, frect.right, frect.bottom );
//HELPER.Log( "Adding frect%d %f %f %f %f", (i + j*m_iFramesWide), frect.left, frect.top, frect.right, frect.bottom );
}
}
}
#include "string.h"
void RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesWide, UINT* puFramesHigh ) const
void RageTexture::GetFrameDimensionsFromFileName( CString sPath, int* piFramesWide, int* piFramesHigh ) const
{
*puFramesWide = *puFramesHigh = 1; // set default values in case we don't find the dimension in the file name
*piFramesWide = *piFramesHigh = 1; // set default values in case we don't find the dimension in the file name
sPath.MakeLower();
@@ -94,8 +94,8 @@ void RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesW
else if( !IsAnInt(arrayDimensionsBits[0]) || !IsAnInt(arrayDimensionsBits[1]) )
continue;
*puFramesWide = atoi(arrayDimensionsBits[0]);
*puFramesHigh = atoi(arrayDimensionsBits[1]);
*piFramesWide = atoi(arrayDimensionsBits[0]);
*piFramesHigh = atoi(arrayDimensionsBits[1]);
return;
}
+22 -23
View File
@@ -9,7 +9,6 @@
*/
class RageTexture;
typedef RageTexture* LPRageTexture;
#ifndef _RAGETEXTURE_H_
@@ -42,49 +41,49 @@ public:
class RageTexture
{
public:
RageTexture( LPRageScreen pScreen, CString sFilePath );
RageTexture( RageScreen* pScreen, const CString &sFilePath );
virtual ~RageTexture() PURE;
virtual LPDIRECT3DTEXTURE8 GetD3DTexture() PURE;
UINT GetSourceWidth() {return m_uSourceWidth;};
UINT GetSourceHeight() {return m_uSourceHeight;};
UINT GetTextureWidth() {return m_uTextureWidth;};
UINT GetTextureHeight() {return m_uTextureHeight;};
UINT GetImageWidth() {return m_uImageWidth;};
UINT GetImageHeight() {return m_uImageHeight;};
int GetSourceWidth() {return m_iSourceWidth;};
int GetSourceHeight() {return m_iSourceHeight;};
int GetTextureWidth() {return m_iTextureWidth;};
int GetTextureHeight() {return m_iTextureHeight;};
int GetImageWidth() {return m_iImageWidth;};
int GetImageHeight() {return m_iImageHeight;};
UINT GetFramesWide() {return m_uFramesWide;};
UINT GetFramesHigh() {return m_uFramesHigh;};
int GetFramesWide() {return m_iFramesWide;};
int GetFramesHigh() {return m_iFramesHigh;};
UINT GetSourceFrameWidth() {return GetSourceWidth() / GetFramesWide();};
UINT GetSourceFrameHeight() {return GetSourceHeight() / GetFramesHigh();};
UINT GetTextureFrameWidth() {return GetTextureWidth() / GetFramesWide();};
UINT GetTextureFrameHeight(){return GetTextureHeight() / GetFramesHigh();};
UINT GetImageFrameWidth() {return GetImageWidth() / GetFramesWide();};
UINT GetImageFrameHeight() {return GetImageHeight() / GetFramesHigh();};
int GetSourceFrameWidth() {return GetSourceWidth() / GetFramesWide();};
int GetSourceFrameHeight() {return GetSourceHeight() / GetFramesHigh();};
int GetTextureFrameWidth() {return GetTextureWidth() / GetFramesWide();};
int GetTextureFrameHeight(){return GetTextureHeight() / GetFramesHigh();};
int GetImageFrameWidth() {return GetImageWidth() / GetFramesWide();};
int GetImageFrameHeight() {return GetImageHeight() / GetFramesHigh();};
FRECT* GetTextureCoordRect( UINT uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
FRECT* GetTextureCoordRect( int uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
int GetNumFrames() {return m_TextureCoordRects.GetSize();};
CString GetFilePath() {return m_sFilePath;};
INT m_iRefCount;
protected:
virtual void CreateFrameRects();
virtual void GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesWide, UINT* puFramesHigh ) const;
virtual void GetFrameDimensionsFromFileName( CString sPath, int* puFramesWide, int* puFramesHigh ) const;
CString m_sFilePath;
LPDIRECT3DDEVICE8 m_pd3dDevice;
// LPDIRECT3DTEXTURE8 m_pd3dTexture;
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image loaded from disk
UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture in memory
UINT m_uImageWidth, m_uImageHeight; // dimensions of the image in the texture
int m_iSourceWidth, m_iSourceHeight; // dimensions of the original image loaded from disk
int m_iTextureWidth, m_iTextureHeight; // dimensions of the texture in memory
int m_iImageWidth, m_iImageHeight; // dimensions of the image in the texture
D3DFORMAT m_TextureFormat;
// The number of frames of animation in each row and column of this texture.
UINT m_uFramesWide, m_uFramesHigh;
int m_iFramesWide, m_iFramesHigh;
// RECTs that hold the bounds of each frame in the bitmap.
+40 -29
View File
@@ -17,31 +17,33 @@
#include "RageBitmapTexture.h"
#include "RageMovieTexture.h"
#include "RageUtil.h"
#include <assert.h>
#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) );
}
}
+14 -7
View File
@@ -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<CMapStringToPtr, CString, LPRageTexture> m_mapPathToTexture;
CTypedPtrMap<CMapStringToPtr, CString, RageTexture*> 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
+21 -92
View File
@@ -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<s.GetLength(); i++ )
for( UINT i=0; i<strlen(s); i++ )
{
if( s[i] < '0' || s[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;
+37 -34
View File
@@ -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);
+7 -6
View File
@@ -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
{
+2 -1
View File
@@ -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) );
+32 -28
View File
@@ -10,13 +10,12 @@
*/
#include "Util.h"
#include "Pattern.h"
#include "RageUtil.h"
#include "Song.h"
#include <assert.h>
#include <math.h> // 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<iNumNotesInThisMeasure; j++ )
{
@@ -351,7 +350,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
float fBPS;
fBPS = m_BPMSegments[0].m_fBPM/60.0f;
m_fOffsetInSeconds = fBeatOffset / fBPS;
//RageLog( "Found offset to be index %d, beat %f", iStepIndex, NoteIndexToBeat(iStepIndex) );
//HELPER.Log( "Found offset to be index %d, beat %f", iStepIndex, NoteIndexToBeat(iStepIndex) );
break;
case 03: // bpm
BPMSegment new_seg;
@@ -368,7 +367,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
}
for( i=0; i<m_BPMSegments.GetSize(); i++ )
RageLog( "There is a BPM change at beat fd, BPM %f, index %d",
HELPER.Log( "There is a BPM change at beat fd, BPM %f, index %d",
m_BPMSegments[i].m_fStartBeat, m_BPMSegments[i].m_fBPM, i );
@@ -381,7 +380,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
bool Song::LoadSongInfoFromDWIFile( CString sPath )
{
RageLog( "Song::LoadFromDWIFile(%s)", sPath );
HELPER.Log( "Song::LoadFromDWIFile(%s)", sPath );
// save song file path
m_sSongFilePath = sPath;
@@ -422,7 +421,7 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
CStdioFile file;
if( !file.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone ) )
RageError( ssprintf("Error opening DWI file '%s'.", GetSongFilePath()) );
HELPER.FatalError( ssprintf("Error opening DWI file '%s'.", GetSongFilePath()) );
// MessageBox( NULL, sFName, sFName, MB_OK );
@@ -495,7 +494,7 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
new_seg.m_fStartBeat = fFreezeBeat;
new_seg.m_fFreezeSeconds = fFreezeSeconds;
RageLog( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fFreezeSeconds );
HELPER.Log( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fFreezeSeconds );
m_FreezeSegments.Add( new_seg ); // add to back for now (we'll sort later)
SortFreezeSegmentsArray( m_FreezeSegments );
@@ -530,8 +529,13 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
{
m_arrayPatterns.SetSize( m_arrayPatterns.GetSize()+1, 1 );
Pattern &new_pattern = m_arrayPatterns[ m_arrayPatterns.GetSize()-1 ];
new_pattern.LoadFromDWIValueTokens( arrayValueTokens );
int ksjfk = 0;
new_pattern.LoadFromDWIValueTokens(
arrayValueTokens[0],
arrayValueTokens[1],
arrayValueTokens[2],
arrayValueTokens[3],
arrayValueTokens.GetSize() == 5 ? arrayValueTokens[4] : ""
);
}
else
// do nothing. We don't care about this value name
@@ -551,7 +555,7 @@ void Song::TidyUpData()
if( m_sArtist == "" ) m_sArtist = "Unknown artist";
if( m_sCreator == "" ) m_sCreator = "Unknown creator";
if( m_BPMSegments.GetSize() == 0 )
RageError( ssprintf("No #BPM specified in '%s.'", GetSongFilePath()) );
HELPER.FatalError( ssprintf("No #BPM specified in '%s.'", GetSongFilePath()) );
if( m_sMusicPath == "" || !DoesFileExist(GetMusicPath()) )
{
@@ -564,7 +568,7 @@ void Song::TidyUpData()
m_sMusicPath = m_sSongDir + arrayPossibleMusic[0];
else
m_sMusicPath = "";
// RageError( ssprintf("Music could not be found. Please check the Song file '%s' and verify the specified #MUSIC exists.", GetSongFilePath()) );
// HELPER.FatalError( ssprintf("Music could not be found. Please check the Song file '%s' and verify the specified #MUSIC exists.", GetSongFilePath()) );
}
if( !DoesFileExist(GetBannerPath()) )
@@ -595,7 +599,7 @@ void Song::TidyUpData()
else
m_sBannerPath = "";
//RageError( ssprintf("Banner could not be found. Please check the Song file '%s' and verify the specified #BANNER exists.", GetSongFilePath()) );
//HELPER.FatalError( ssprintf("Banner could not be found. Please check the Song file '%s' and verify the specified #BANNER exists.", GetSongFilePath()) );
}
if( !DoesFileExist(GetBackgroundPath()) )
@@ -705,7 +709,7 @@ void Song::SaveOffsetChangeToDisk()
CStringArray arrayLines;
CStdioFile fileIn;
if( !fileIn.Open( sPatternFileName, CFile::modeRead|CFile::shareDenyNone) )
RageError( ssprintf("Failed to open '%s' for reading", sPatternFileName) );
HELPER.FatalError( ssprintf("Failed to open '%s' for reading", sPatternFileName) );
// read the file into sFileContents
CString sLine;
@@ -718,7 +722,7 @@ void Song::SaveOffsetChangeToDisk()
// write the file back to disk with the changes
CStdioFile fileOut;
if( !fileOut.Open( sPatternFileName, CFile::modeWrite|CFile::shareDenyWrite) )
RageError( ssprintf("Failed to open '%s' for writing", sPatternFileName) );
HELPER.FatalError( ssprintf("Failed to open '%s' for writing", sPatternFileName) );
for( int j=0; j<arrayLines.GetSize(); j++ )
{
CString sLine = arrayLines[j];
@@ -755,7 +759,7 @@ void Song::SaveOffsetChangeToDisk()
CStringArray arrayLines;
CStdioFile fileIn;
if( !fileIn.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone) )
RageError( ssprintf("Failed to open '%s' for reading", GetSongFilePath()) );
HELPER.FatalError( ssprintf("Failed to open '%s' for reading", GetSongFilePath()) );
// read the file into sFileContents
CString sLine;
@@ -769,7 +773,7 @@ void Song::SaveOffsetChangeToDisk()
// write the file back to disk with the changes
CStdioFile fileOut;
if( !fileOut.Open( GetSongFilePath(), CFile::modeWrite|CFile::shareDenyWrite) )
RageError( ssprintf("Failed to open '%s' for writing", GetSongFilePath()) );
HELPER.FatalError( ssprintf("Failed to open '%s' for writing", GetSongFilePath()) );
for( int i=0; i<arrayLines.GetSize(); i++ )
{
CString sLine = arrayLines[i];
@@ -794,7 +798,7 @@ void Song::SaveOffsetChangeToDisk()
}
else
{
RageError( ssprintf("Unrecognized extension '%s' on song file '%s'", sExt, GetSongFilePath()) );
HELPER.FatalError( ssprintf("Unrecognized extension '%s' on song file '%s'", sExt, GetSongFilePath()) );
}
@@ -822,7 +826,7 @@ int CompareSongPointersByTitle(const void *arg1, const void *arg2)
CString sCompareString1 = sTitle1 + sFilePath1;
CString sCompareString2 = sTitle2 + sFilePath2;
return CompareCStrings( (void*)&sCompareString1, (void*)&sCompareString2 );
return CompareCStringsAsc( (void*)&sCompareString1, (void*)&sCompareString2 );
}
void SortSongPointerArrayByTitle( CArray<Song*, Song*> &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;
}
+5 -4
View File
@@ -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
}
+43 -102
View File
@@ -14,53 +14,32 @@
#include "RageTextureManager.h"
#include "PrefsManager.h"
#include "IniFile.h"
#include <assert.h>
#include <math.h>
#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; i<m_pTexture->GetNumFrames(); i++ )
for( int i=0; i<m_pTexture->GetNumFrames(); 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;
}
+5 -15
View File
@@ -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;
};
+28 -37
View File
@@ -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
+186 -200
View File
@@ -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;
}
+116 -44
View File
@@ -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
+1 -3
View File
@@ -12,9 +12,7 @@
#define _STEPMANIA_H_
BOOL SwitchDisplayMode();//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP );
void ApplyGraphicOptions();
+28
View File
@@ -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
+823
View File
@@ -0,0 +1,823 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="StepMania"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\.."
IntermediateDirectory=".\../Release"
ConfigurationType="1"
UseOfMFC="1"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2"
WholeProgramOptimization="TRUE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/EHa"
Optimization="3"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
OptimizeForWindowsApplication="TRUE"
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE"
MinimalRebuild="TRUE"
RuntimeLibrary="0"
BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="FALSE"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\../Release/StepMania.pch"
AssemblerListingLocation=".\../Release/"
ObjectFile=".\../Release/"
ProgramDataBaseFileName=".\../Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
OutputFile=".\../StepMania.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\../StepMania.pdb"
SubSystem="2"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../StepMania.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\.."
IntermediateDirectory=".\../Debug"
ConfigurationType="1"
UseOfMFC="1"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/EHa"
Optimization="0"
PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\../Debug/StepMania.pch"
AssemblerListingLocation=".\../Debug/"
ObjectFile=".\../Debug/"
ProgramDataBaseFileName=".\../Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
OutputFile="../StepMania-debug.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\../StepMania-debug.pdb"
SubSystem="2"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../StepMania.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Windows"
Filter="">
<File
RelativePath=".\Window.cpp">
</File>
<File
RelativePath=".\Window.h">
</File>
<File
RelativePath=".\WindowCaution.cpp">
</File>
<File
RelativePath=".\WindowCaution.h">
</File>
<File
RelativePath=".\WindowConfigurePads.cpp">
</File>
<File
RelativePath=".\WindowConfigurePads.h">
</File>
<File
RelativePath=".\WindowDancing.cpp">
</File>
<File
RelativePath=".\WindowDancing.h">
</File>
<File
RelativePath=".\WindowEdit.cpp">
</File>
<File
RelativePath=".\WindowEdit.h">
</File>
<File
RelativePath=".\WindowEditMenu.cpp">
</File>
<File
RelativePath=".\WindowEditMenu.h">
</File>
<File
RelativePath=".\WindowEditOptions.cpp">
</File>
<File
RelativePath=".\WindowEditOptions.h">
</File>
<File
RelativePath=".\WindowGameOptions.cpp">
</File>
<File
RelativePath=".\WindowGameOptions.h">
</File>
<File
RelativePath="WindowGraphicOptions.cpp">
</File>
<File
RelativePath="WindowGraphicOptions.h">
</File>
<File
RelativePath=".\WindowManager.cpp">
</File>
<File
RelativePath=".\WindowManager.h">
</File>
<File
RelativePath=".\WindowMenu.cpp">
</File>
<File
RelativePath=".\WindowMenu.h">
</File>
<File
RelativePath=".\WindowMenuResults.cpp">
</File>
<File
RelativePath=".\WindowMenuResults.h">
</File>
<File
RelativePath=".\WindowMessage.h">
</File>
<File
RelativePath=".\WindowOptions.cpp">
</File>
<File
RelativePath=".\WindowOptions.h">
</File>
<File
RelativePath=".\WindowPlayerOptions.cpp">
</File>
<File
RelativePath=".\WindowPlayerOptions.h">
</File>
<File
RelativePath=".\WindowPrompt.cpp">
</File>
<File
RelativePath=".\WindowPrompt.h">
</File>
<File
RelativePath=".\WindowSandbox.cpp">
</File>
<File
RelativePath=".\WindowSandbox.h">
</File>
<File
RelativePath="WindowSelectDifficulty.cpp">
</File>
<File
RelativePath="WindowSelectDifficulty.h">
</File>
<File
RelativePath="WindowSelectMusic.cpp">
</File>
<File
RelativePath="WindowSelectMusic.h">
</File>
<File
RelativePath="WindowSelectStyle.cpp">
</File>
<File
RelativePath="WindowSelectStyle.h">
</File>
<File
RelativePath=".\WindowSongOptions.cpp">
</File>
<File
RelativePath=".\WindowSongOptions.h">
</File>
<File
RelativePath=".\WindowSynchronize.cpp">
</File>
<File
RelativePath=".\WindowSynchronize.h">
</File>
<File
RelativePath=".\WindowSynchronizeMenu.cpp">
</File>
<File
RelativePath=".\WindowSynchronizeMenu.h">
</File>
<File
RelativePath=".\WindowTitleMenu.cpp">
</File>
<File
RelativePath=".\WindowTitleMenu.h">
</File>
</Filter>
<Filter
Name="Data Structures"
Filter="">
<File
RelativePath=".\Font.cpp">
</File>
<File
RelativePath=".\Font.h">
</File>
<File
RelativePath=".\FontManager.cpp">
</File>
<File
RelativePath=".\FontManager.h">
</File>
<File
RelativePath=".\GameConstants.h">
</File>
<File
RelativePath=".\GameManager.cpp">
</File>
<File
RelativePath=".\GameManager.h">
</File>
<File
RelativePath=".\GameTypes.h">
</File>
<File
RelativePath=".\Grade.cpp">
</File>
<File
RelativePath=".\Grade.h">
</File>
<File
RelativePath=".\PadInput.h">
</File>
<File
RelativePath=".\Pattern.cpp">
</File>
<File
RelativePath=".\Pattern.h">
</File>
<File
RelativePath=".\Player.cpp">
</File>
<File
RelativePath=".\Player.h">
</File>
<File
RelativePath=".\PlayerInput.h">
</File>
<File
RelativePath=".\PrefsManager.cpp">
</File>
<File
RelativePath=".\PrefsManager.h">
</File>
<File
RelativePath=".\RandomSample.cpp">
</File>
<File
RelativePath=".\RandomSample.h">
</File>
<File
RelativePath=".\RandomStream.cpp">
</File>
<File
RelativePath=".\RandomStream.h">
</File>
<File
RelativePath=".\Song.cpp">
</File>
<File
RelativePath=".\SongManager.cpp">
</File>
<File
RelativePath=".\SongManager.h">
</File>
<File
RelativePath=".\StyleDef.cpp">
</File>
<File
RelativePath=".\StyleDef.h">
</File>
<File
RelativePath=".\ThemeManager.cpp">
</File>
<File
RelativePath=".\ThemeManager.h">
</File>
<File
RelativePath=".\song.h">
</File>
</Filter>
<Filter
Name="File Types"
Filter="">
<File
RelativePath=".\IniFile.cpp">
</File>
<File
RelativePath=".\IniFile.h">
</File>
<File
RelativePath=".\XMLMarkup.cpp">
</File>
<File
RelativePath=".\XMLMarkup.h">
</File>
</Filter>
<Filter
Name="System"
Filter="">
<File
RelativePath=".\ScreenDimensions.h">
</File>
<File
RelativePath=".\StdAfx.cpp">
</File>
<File
RelativePath=".\StdAfx.h">
</File>
<File
RelativePath=".\StepMania.ICO">
</File>
<File
RelativePath=".\StepMania.RC">
</File>
<File
RelativePath=".\StepMania.cpp">
</File>
<File
RelativePath=".\StepMania.h">
</File>
<File
RelativePath=".\dxutil.cpp">
</File>
<File
RelativePath=".\resource.h">
</File>
</Filter>
<Filter
Name="Transitions"
Filter="">
<File
RelativePath=".\Transition.cpp">
</File>
<File
RelativePath=".\Transition.h">
</File>
<File
RelativePath=".\TransitionFade.cpp">
</File>
<File
RelativePath=".\TransitionFade.h">
</File>
<File
RelativePath=".\TransitionFadeWipe.cpp">
</File>
<File
RelativePath=".\TransitionFadeWipe.h">
</File>
<File
RelativePath=".\TransitionInvisible.cpp">
</File>
<File
RelativePath=".\TransitionInvisible.h">
</File>
<File
RelativePath="TransitionKeepAlive.cpp">
</File>
<File
RelativePath="TransitionKeepAlive.h">
</File>
<File
RelativePath=".\TransitionRectWipe.cpp">
</File>
<File
RelativePath=".\TransitionRectWipe.h">
</File>
<File
RelativePath=".\TransitionStarWipe.cpp">
</File>
<File
RelativePath=".\TransitionStarWipe.h">
</File>
<File
RelativePath=".\TransitionStarburst.cpp">
</File>
<File
RelativePath=".\TransitionStarburst.h">
</File>
</Filter>
<Filter
Name="Actors"
Filter="">
<File
RelativePath=".\Actor.cpp">
</File>
<File
RelativePath=".\Actor.h">
</File>
<File
RelativePath=".\ActorFrame.cpp">
</File>
<File
RelativePath=".\ActorFrame.h">
</File>
<File
RelativePath=".\BitmapText.cpp">
</File>
<File
RelativePath=".\BitmapText.h">
</File>
<File
RelativePath=".\RectangleActor.cpp">
</File>
<File
RelativePath=".\RectangleActor.h">
</File>
<File
RelativePath=".\Sprite.cpp">
</File>
<File
RelativePath=".\Sprite.h">
</File>
</Filter>
<Filter
Name="Actors used in Menus"
Filter="">
<File
RelativePath=".\BPMDisplay.cpp">
</File>
<File
RelativePath=".\BPMDisplay.h">
</File>
<File
RelativePath=".\Banner.cpp">
</File>
<File
RelativePath=".\Banner.h">
</File>
<File
RelativePath=".\DifficultyIcon.cpp">
</File>
<File
RelativePath=".\DifficultyIcon.h">
</File>
<File
RelativePath=".\FootMeter.cpp">
</File>
<File
RelativePath=".\FootMeter.h">
</File>
<File
RelativePath=".\GradeDisplay.cpp">
</File>
<File
RelativePath=".\GradeDisplay.h">
</File>
<File
RelativePath=".\GranularityIndicator.cpp">
</File>
<File
RelativePath=".\GranularityIndicator.h">
</File>
<File
RelativePath="MenuElements.cpp">
</File>
<File
RelativePath="MenuElements.h">
</File>
<File
RelativePath=".\MusicSortDisplay.cpp">
</File>
<File
RelativePath=".\MusicSortDisplay.h">
</File>
<File
RelativePath=".\MusicStatusDisplay.cpp">
</File>
<File
RelativePath=".\MusicStatusDisplay.h">
</File>
<File
RelativePath=".\MusicWheel.cpp">
</File>
<File
RelativePath=".\MusicWheel.h">
</File>
<File
RelativePath=".\StepsSelector.cpp">
</File>
<File
RelativePath=".\StepsSelector.h">
</File>
<File
RelativePath=".\TextBanner.cpp">
</File>
<File
RelativePath=".\TextBanner.h">
</File>
<File
RelativePath=".\TipDisplay.cpp">
</File>
<File
RelativePath=".\TipDisplay.h">
</File>
</Filter>
<Filter
Name="Actors used in Dancing"
Filter="">
<File
RelativePath=".\ArrowEffects.cpp">
</File>
<File
RelativePath=".\ArrowEffects.h">
</File>
<File
RelativePath=".\Background.cpp">
</File>
<File
RelativePath=".\Background.h">
</File>
<File
RelativePath=".\ColorArrow.cpp">
</File>
<File
RelativePath=".\ColorArrow.h">
</File>
<File
RelativePath=".\ColorArrowField.cpp">
</File>
<File
RelativePath=".\ColorArrowField.h">
</File>
<File
RelativePath=".\Combo.cpp">
</File>
<File
RelativePath=".\Combo.h">
</File>
<File
RelativePath=".\FocusingSprite.cpp">
</File>
<File
RelativePath=".\FocusingSprite.h">
</File>
<File
RelativePath=".\GhostArrow.cpp">
</File>
<File
RelativePath=".\GhostArrow.h">
</File>
<File
RelativePath=".\GhostArrowBright.cpp">
</File>
<File
RelativePath=".\GhostArrowBright.h">
</File>
<File
RelativePath=".\GhostArrows.cpp">
</File>
<File
RelativePath=".\GhostArrows.h">
</File>
<File
RelativePath=".\GrayArrow.cpp">
</File>
<File
RelativePath=".\GrayArrow.h">
</File>
<File
RelativePath=".\GrayArrows.cpp">
</File>
<File
RelativePath=".\GrayArrows.h">
</File>
<File
RelativePath=".\HoldGhostArrow.cpp">
</File>
<File
RelativePath=".\HoldGhostArrow.h">
</File>
<File
RelativePath=".\HoldJudgement.cpp">
</File>
<File
RelativePath=".\HoldJudgement.h">
</File>
<File
RelativePath=".\Judgement.cpp">
</File>
<File
RelativePath=".\Judgement.h">
</File>
<File
RelativePath=".\LifeMeterPills.cpp">
</File>
<File
RelativePath=".\LifeMeterPills.h">
</File>
<File
RelativePath=".\MotionBlurSprite.cpp">
</File>
<File
RelativePath=".\MotionBlurSprite.h">
</File>
<File
RelativePath="ScoreDisplayRolling.cpp">
</File>
<File
RelativePath="ScoreDisplayRolling.h">
</File>
<File
RelativePath="ScoreDisplayRollingWithFrame.cpp">
</File>
<File
RelativePath="ScoreDisplayRollingWithFrame.h">
</File>
</Filter>
<Filter
Name="exception"
Filter="">
<File
RelativePath="exception\AtlAux2.h">
</File>
<File
RelativePath="exception\debug_stream.h">
</File>
<File
RelativePath="exception\exception2.h">
</File>
<File
RelativePath="exception\exception_trap.h">
</File>
<File
RelativePath="exception\kbase.h">
</File>
<File
RelativePath="exception\se_translator.cpp">
</File>
<File
RelativePath="exception\se_translator.h">
</File>
<File
RelativePath="exception\sym_engine.cpp">
</File>
<File
RelativePath="exception\sym_engine.h">
</File>
<File
RelativePath="exception\unhandled_report.h">
</File>
</Filter>
<Filter
Name="Rage"
Filter="">
<File
RelativePath=".\RageBitmapTexture.cpp">
</File>
<File
RelativePath=".\RageBitmapTexture.h">
</File>
<File
RelativePath="RageHelper.cpp">
</File>
<File
RelativePath="RageHelper.h">
</File>
<File
RelativePath=".\RageInput.cpp">
</File>
<File
RelativePath=".\RageInput.h">
</File>
<File
RelativePath=".\RageMovieTexture.cpp">
</File>
<File
RelativePath=".\RageMovieTexture.h">
</File>
<File
RelativePath=".\RageMusic.cpp">
</File>
<File
RelativePath=".\RageMusic.h">
</File>
<File
RelativePath=".\RageScreen.cpp">
</File>
<File
RelativePath=".\RageScreen.h">
</File>
<File
RelativePath=".\RageSound.cpp">
</File>
<File
RelativePath=".\RageSound.h">
</File>
<File
RelativePath=".\RageSoundSample.cpp">
</File>
<File
RelativePath=".\RageSoundSample.h">
</File>
<File
RelativePath=".\RageSoundStream.cpp">
</File>
<File
RelativePath=".\RageSoundStream.h">
</File>
<File
RelativePath=".\RageTexture.cpp">
</File>
<File
RelativePath=".\RageTexture.h">
</File>
<File
RelativePath=".\RageTextureManager.cpp">
</File>
<File
RelativePath=".\RageTextureManager.h">
</File>
<File
RelativePath=".\RageUtil.cpp">
</File>
<File
RelativePath=".\RageUtil.h">
</File>
</Filter>
<File
RelativePath=".\error.bmp">
</File>
<File
RelativePath=".\splash.bmp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+1 -1
View File
@@ -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;
+29 -13
View File
@@ -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<NUM_THEME_ELEMENTS; i++ )
{
if( GetPathTo( (ThemeElement)i, sThemeName ) == "" )
RageError( ssprintf( "The theme element for theme '%s' called '%s' could not be found.", sThemeName, ElementToAssetPath((ThemeElement)i) ) );
HELPER.FatalError( ssprintf( "The theme element for theme '%s' called '%s' could not be found.", sThemeName, ElementToAssetPath((ThemeElement)i) ) );
}
}
@@ -92,8 +93,9 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case GRAPHIC_SELECT_STYLE_TOP_EDGE: sAssetPath = "Graphics\\select Style top edge"; break;
case GRAPHIC_SELECT_MUSIC_TOP_EDGE: sAssetPath = "Graphics\\select music top edge"; break;
case GRAPHIC_GAME_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\game options top edge"; break;
case GRAPHIC_GRAPHIC_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\graphic options top edge"; break;
case GRAPHIC_PLAYER_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\player options top edge"; break;
case GRAPHIC_MUSIC_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\music options top edge"; break;
case GRAPHIC_SONG_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\song options top edge"; break;
case GRAPHIC_RESULT_TOP_EDGE: sAssetPath = "Graphics\\result top edge"; break;
case GRAPHIC_FALLBACK_BANNER: sAssetPath = "Graphics\\Fallback Banner"; break;
case GRAPHIC_FALLBACK_BACKGROUND: sAssetPath = "Graphics\\Fallback Background"; break;
@@ -124,7 +126,6 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case GRAPHIC_PAD_DOUBLE: sAssetPath = "Graphics\\Pad double"; break;
case GRAPHIC_PAD_SOLO: sAssetPath = "Graphics\\Pad solo"; break;
case GRAPHIC_STYLE_ICONS: sAssetPath = "Graphics\\Style icons 1x5"; break;
case GRAPHIC_STYLE_EXPLANATIONS: sAssetPath = "Graphics\\Style explanations 1x10"; break;
case GRAPHIC_MUSIC_SELECTION_HIGHLIGHT: sAssetPath = "Graphics\\music selection highlight"; break;
case GRAPHIC_STEPS_DESCRIPTION: sAssetPath = "Graphics\\Steps description 1x8"; break;
case GRAPHIC_SECTION_BACKGROUND: sAssetPath = "Graphics\\section background"; break;
@@ -136,11 +137,25 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case GRAPHIC_ARROWS_RIGHT: sAssetPath = "Graphics\\arrows right 1x4"; break;
case GRAPHIC_EDIT_BACKGROUND: sAssetPath = "Graphics\\edit background"; break;
case GRAPHIC_EDIT_SNAP_INDICATOR: sAssetPath = "Graphics\\edit snap indicator"; break;
case GRAPHIC_GAME_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\game options background"; break;
case GRAPHIC_PLAYER_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\player options background"; break;
case GRAPHIC_MUSIC_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\music options background"; break;
case GRAPHIC_GAME_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\game options background"; break;
case GRAPHIC_GRAPHIC_OPTIONS_BACKGROUND:sAssetPath = "Graphics\\graphic options background"; break;
case GRAPHIC_PLAYER_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\player options background"; break;
case GRAPHIC_SONG_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\song options background"; break;
case GRAPHIC_SYNCHRONIZE_BACKGROUND: sAssetPath = "Graphics\\synchronize background"; break;
case GRAPHIC_SYNCHRONIZE_TOP_EDGE: sAssetPath = "Graphics\\synchronize top edge"; break;
case GRAPHIC_TITLE_MENU_LOGO: sAssetPath = "Graphics\\title menu logo"; break;
case GRAPHIC_TITLE_MENU_HELP: sAssetPath = "Graphics\\title menu help"; break;
case GRAPHIC_SELECT_DIFFICULTY_BACKGROUND: sAssetPath = "Graphics\\select difficulty background"; break;
case GRAPHIC_SELECT_DIFFICULTY_TOP_EDGE: sAssetPath = "Graphics\\select difficulty top edge"; break;
case GRAPHIC_SELECT_DIFFICULTY_EXPLANATION: sAssetPath = "Graphics\\select difficulty explanation"; break;
case GRAPHIC_SELECT_DIFFICULTY_EASY: sAssetPath = "Graphics\\select difficulty easy"; break;
case GRAPHIC_SELECT_DIFFICULTY_MEDIUM: sAssetPath = "Graphics\\select difficulty medium"; break;
case GRAPHIC_SELECT_DIFFICULTY_HARD: sAssetPath = "Graphics\\select difficulty hard"; break;
case GRAPHIC_SELECT_DIFFICULTY_ARROW: sAssetPath = "Graphics\\select difficulty arrow"; break;
case GRAPHIC_SELECT_DIFFICULTY_OK: sAssetPath = "Graphics\\select difficulty ok"; break;
case GRAPHIC_SELECT_MUSIC_INFO_FRAME: sAssetPath = "Graphics\\select music info frame"; break;
case GRAPHIC_SELECT_MUSIC_RADAR: sAssetPath = "Graphics\\select music radar"; break;
case GRAPHIC_SELECT_MUSIC_SCORE_FRAME: sAssetPath = "Graphics\\select music score frame"; break;
case SOUND_FAILED: sAssetPath = "Sounds\\failed"; break;
case SOUND_ASSIST: sAssetPath = "Sounds\\Assist"; break;
@@ -159,6 +174,7 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case SOUND_EDIT_CHANGE_SNAP: sAssetPath = "Sounds\\edit change snap"; break;
case FONT_OUTLINE: sAssetPath = "Fonts\\Outline"; break;
case FONT_CAPITALS: sAssetPath = "Fonts\\Capitals"; break;
case FONT_NORMAL: sAssetPath = "Fonts\\Normal"; break;
case FONT_FUTURISTIC: sAssetPath = "Fonts\\Futuristic"; break;
case FONT_BOLD_NUMBERS: sAssetPath = "Fonts\\Bold Numbers"; break;
@@ -186,10 +202,10 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case ANNOUNCER_RESULT_D: sAssetPath = "Announcer\\result d"; break;
case ANNOUNCER_RESULT_E: sAssetPath = "Announcer\\result e"; break;
case ANNOUNCER_TITLE: sAssetPath = "Announcer\\title"; break;
case ANNOUNCER_DIFFICULTY_COMMENT: sAssetPath = "Announcer\\difficulty comment"; break;
default:
RageError( ssprintf("Unhandled theme element %d", te) );
HELPER.FatalError( ssprintf("Unhandled theme element %d", te) );
}
return sAssetPath;
@@ -236,7 +252,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 )
@@ -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 "";
}
+20 -4
View File
@@ -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
+2 -1
View File
@@ -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 );
+2 -2
View File
@@ -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:
+1 -1
View File
@@ -29,7 +29,7 @@ TransitionFade::~TransitionFade()
void TransitionFade::RenderPrimitives()
{
float fPercentageOpaque = GetPercentageOpen();
const float fPercentageOpaque = 1 - GetPercentageOpen();
if( fPercentageOpaque == 0 )
return; // draw nothing
+1 -1
View File
@@ -16,7 +16,7 @@
#include "Transition.h"
#include "RageScreen.h"
#include "RageSound.h"
#include "Rectangle.h"
#include "RectangleActor.h"
class TransitionFade : public Transition
+1 -1
View File
@@ -16,7 +16,7 @@
#include "RageScreen.h"
#include "RageSound.h"
#include "Sprite.h"
#include "Rectangle.h"
#include "RectangleActor.h"
class TransitionFadeWipe : public Transition
+1 -1
View File
@@ -16,7 +16,7 @@
#include "Transition.h"
#include "RageScreen.h"
#include "RageSound.h"
#include "Rectangle.h"
#include "RectangleActor.h"
class TransitionInvisible : public Transition
+42
View File
@@ -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();
}
+34
View File
@@ -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
+6 -1
View File
@@ -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));
+1 -1
View File
@@ -15,7 +15,7 @@
#include "Transition.h"
#include "RageScreen.h"
#include "RageSound.h"
#include "Rectangle.h"
#include "RectangleActor.h"
class TransitionStarWipe : public Transition
View File
@@ -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