Messed a lot with BMS reading. See changelog.txt.

This commit is contained in:
Chris Danford
2002-01-24 08:01:24 +00:00
parent 38c125ff4d
commit 2f8cd4feb4
10 changed files with 187 additions and 88 deletions
+2
View File
@@ -38,6 +38,8 @@ public:
virtual void TurnDangerOn() { m_bShowDanger = true; };
virtual void TurnDangerOff() { m_bShowDanger = false; };
virtual bool IsDangerOn() { return m_bShowDanger; };
protected:
Sprite m_sprVisualizationOverlay;
Sprite m_sprSongBackground;
+9 -9
View File
@@ -105,7 +105,7 @@ bool BitmapText::Load( CString sFontFilePath )
split( sWidthsValue, ",", arrayCharWidths );
if( arrayCharWidths.GetSize() != Sprite::GetNumStates() )
RageError( ssprintf("The number of widths specified in '%s' do not match the number of frames in the texture.", m_sFontFilePath) );
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++ )
{
@@ -130,7 +130,7 @@ bool BitmapText::Load( CString sFontFilePath )
FRECT* pFrect = m_pTexture->GetTextureCoordRect( i );
float fPixelsToChopOff = m_fFrameNoToWidth[i] - GetUnzoomedWidth();
float fTexCoordsToChopOff = fPixelsToChopOff / m_pTexture->GetTextureWidth();
float fTexCoordsToChopOff = fPixelsToChopOff / m_pTexture->GetSourceWidth();
pFrect->left -= fTexCoordsToChopOff/2;
pFrect->right += fTexCoordsToChopOff/2;
@@ -245,9 +245,9 @@ void BitmapText::RenderPrimitives()
float fY;
switch( m_VertAlign )
{
case align_top: fY = 0; break;
case align_middle: fY = (m_sTextLines.GetSize()-1) * fHeight / 2; break;
case align_bottom: fY = (m_sTextLines.GetSize()-1) * fHeight; break;
case align_top: fY = -(m_sTextLines.GetSize()) * fHeight / 2; break; break;
case align_middle: fY = 0; break;
case align_bottom: fY = (m_sTextLines.GetSize()) * fHeight / 2; break;
default: ASSERT( true );
}
@@ -293,15 +293,15 @@ void BitmapText::RenderPrimitives()
// set vertex positions
v[iVNum++].p = D3DXVECTOR3( fX, fHeight/2, 0 ); // bottom left
v[iVNum++].p = D3DXVECTOR3( fX, -fHeight/2, 0 ); // top left
v[iVNum++].p = D3DXVECTOR3( fX, fY+fHeight/2, 0 ); // bottom left
v[iVNum++].p = D3DXVECTOR3( fX, fY-fHeight/2, 0 ); // top left
fX += fCharWidth;
float fExtraPixels = fPercentExtra * GetUnzoomedWidth();
v[iVNum++].p = D3DXVECTOR3( fX+fExtraPixels, fHeight/2, 0 ); // bottom right
v[iVNum++].p = D3DXVECTOR3( fX+fExtraPixels, -fHeight/2, 0 ); // top right
v[iVNum++].p = D3DXVECTOR3( fX+fExtraPixels, fY+fHeight/2, 0 ); // bottom right
v[iVNum++].p = D3DXVECTOR3( fX+fExtraPixels, fY-fHeight/2, 0 ); // top right
// set texture coordinates
+1
View File
@@ -555,6 +555,7 @@ void MusicWheel::NextSort()
{
case STATE_IDLE:
case STATE_SWITCHING_MUSIC:
case STATE_FLYING_ON_AFTER_NEXT_SORT:
break; // fall through
default:
return; // don't continue
+4
View File
@@ -67,6 +67,10 @@ void RageBitmapTexture::Create()
{
fmtTexture = D3DFMT_A4R4G4B4;
}
else if( GAMEINFO->m_GameOptions.m_iDisplayColor == 16 )
{
fmtTexture = D3DFMT_A4R4G4B4;
}
else
{
switch( GAMEINFO->m_GameOptions.m_iTextureColor )
+4 -3
View File
@@ -69,10 +69,8 @@ LPRageTexture RageTextureManager::LoadTexture( CString sTexturePath )
// RageLog( ssprintf("Found that '%s' is already loaded. Using the loaded copy.", sTexturePath) );
pTexture->m_iRefCount++;
}
else
else // the texture is not already loaded
{
RageLog( ssprintf("RageTextureManager: allocating space for '%s'.", sTexturePath) );
CString sDrive, sDir, sFName, sExt;
splitpath( FALSE, sTexturePath, sDrive, sDir, sFName, sExt );
@@ -81,6 +79,9 @@ LPRageTexture RageTextureManager::LoadTexture( CString sTexturePath )
else
pTexture = (LPRageTexture) new RageBitmapTexture( m_pScreen, sTexturePath );
RageLog( "RageTextureManager: allocating space for '%s' (%ux%u).", sTexturePath, pTexture->GetTextureWidth(), pTexture->GetTextureHeight() );
m_mapPathToTexture.SetAt( sTexturePath, pTexture );
}
+78 -59
View File
@@ -11,8 +11,6 @@
#include "Util.h"
#include "IniFile.h"
#include "BmsFile.h"
#include "Steps.h"
#include "RageUtil.h"
@@ -228,8 +226,8 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
// Load the Song info from the first BMS file. Silly BMS duplicates the song info in every
// file, so this method assumes that the song info is identical for every BMS file in
// the directory.
// file. So, we read the song data from only the first BMS file and assume that the info
// is identical for every BMS file in the directory.
CString sBMSFilePath = m_sSongDir + arrayBMSFileNames[0];
// load the Steps from the rest of the BMS files
@@ -241,53 +239,93 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
}
BmsFile bms( sBMSFilePath );
bms.ReadFile();
CMapStringToString &mapValues = bms.mapValues;
POSITION pos = mapValues.GetStartPosition();
while( pos != NULL )
CStdioFile file;
if( !file.Open( sBMSFilePath, CFile::modeRead|CFile::shareDenyNone ) )
{
CString value_name;
CString data_string;
CStringArray data_array;
mapValues.GetNextAssoc( pos, value_name, data_string );
split(data_string, ":", data_array);
RageError( ssprintf("Failed to open %s.", sBMSFilePath) );
return false;
}
CString line;
while( file.ReadString(line) ) // foreach line
{
CString value_name; // fill these in
CString value_data;
// BMS value names can be separated by a space or a colon.
int iIndexOfFirstColon = line.Find( ":" );
int iIndexOfFirstSpace = line.Find( " " );
if( iIndexOfFirstColon == -1 )
iIndexOfFirstColon = 10000;
if( iIndexOfFirstSpace == -1 )
iIndexOfFirstSpace = 10000;
int iIndexOfSeparator = min( iIndexOfFirstSpace, iIndexOfFirstColon );
if( iIndexOfSeparator != 10000 )
{
value_name = line.Mid( 0, iIndexOfSeparator );
value_data = line; // the rest
value_data.Delete(0,iIndexOfSeparator+1);
}
else // no separator
{
value_name = line;
}
value_name.MakeLower();
// handle the data
if( value_name == "#GENRE" )
m_sCreator = data_array[0];
else if( value_name == "#TITLE" ) {
m_sTitle = data_array[0];
// strip steps type out of description leaving only song title (looks like 'Music <BASIC>')
int iPosBracket = m_sTitle.Find( " <" );
if( iPosBracket != -1 )
m_sTitle = m_sTitle.Left( iPosBracket );
if( -1 != value_name.Find("#genre") )
{
m_sCreator = value_data;
}
else if( value_name == "#ARTIST" )
m_sArtist = data_array[0];
else if( value_name == "#BPM" ) {
else if( -1 != value_name.Find("#title") )
{
m_sTitle = value_data;
// strip steps type out of description leaving only song title (looks like 'B4U <BASIC>')
m_sTitle.Replace( "(ANOTHER)", "" );
m_sTitle.Replace( "(BASIC)", "" );
m_sTitle.Replace( "(MANIAC)", "" );
m_sTitle.Replace( "<ANOTHER>", "" );
m_sTitle.Replace( "<BASIC>", "" );
m_sTitle.Replace( "<MANIAC>", "" );
}
else if( -1 != value_name.Find("#artist") )
{
m_sArtist = value_data;
}
else if( -1 != value_name.Find("#bpm") )
{
BPMSegment new_seg;
new_seg.m_fStartBeat = 0;
new_seg.m_fBPM = (float)atof( data_array[0] );
new_seg.m_fBPM = (float)atof( value_data );
// 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 );
}
else if( value_name == "#BackBMP" || value_name == "#backBMP")
m_sBackgroundPath = m_sSongDir + data_array[0];
else if( value_name == "#WAV99" )
m_sMusicPath = m_sSongDir + data_array[0];
else if( value_name.GetLength() == 6 ) // this is probably step or offset data. Looks like "#00705"
else if( -1 != value_name.Find("#backbmp") )
{
m_sBackgroundPath = m_sSongDir + value_data;
}
else if( -1 != value_name.Find("#wav") )
{
m_sMusicPath = m_sSongDir + value_data;
}
else if( value_name.Left(1) == "#"
&& IsAnInt( value_name.Mid(1,3) )
&& IsAnInt( value_name.Mid(4,2) ) ) // this is step or offset data. Looks like "#00705"
{
int iMeasureNo = atoi( value_name.Mid(1,3) );
int iTrackNum = atoi( value_name.Mid(4,2) );
CString sNoteData = data_array[0];
CString sNoteData = value_data;
CArray<int, int> arrayNotes;
for( int i=0; i<sNoteData.GetLength(); i+=2 )
@@ -389,7 +427,7 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
CStdioFile file;
if( !file.Open( GetSongFilePath(), CFile::modeRead ) )
if( !file.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone ) )
RageError( ssprintf("Error opening DWI file '%s'.", GetSongFilePath()) );
@@ -608,30 +646,11 @@ void Song::GetStepsThatMatchGameMode( GameMode gm, CArray<Steps*, Steps*&>& arra
for( int i=0; i<arraySteps.GetSize(); i++ ) // for each of the Song's Steps
{
Steps* pCurrentSteps = &arraySteps[i];
Steps::StepsMode sm = pCurrentSteps->m_StepsMode;
switch( gm ) // different logic for different game modes
if( gm == pCurrentSteps->m_GameMode // if the current GameModes matches the Steps's GameMode
|| (gm == MODE_VERSUS && pCurrentSteps->m_GameMode == MODE_SINGLE) )
{
case MODE_SINGLE:
if( sm == Steps::SMsingle4 )
arrayAddTo.Add( pCurrentSteps );
break;
case MODE_SOLO:
if( sm == Steps::SMsingle6 )
arrayAddTo.Add( pCurrentSteps );
break;
case MODE_VERSUS:
if( sm == Steps::SMsingle4 )
arrayAddTo.Add( pCurrentSteps );
break;
case MODE_COUPLE:
if( sm == Steps::SMcouple || sm == Steps::SMbattle )
arrayAddTo.Add( pCurrentSteps );
break;
case MODE_DOUBLE:
if( sm == Steps::SMdouble4 )
arrayAddTo.Add( pCurrentSteps );
break;
arrayAddTo.Add( pCurrentSteps );
}
}
+7
View File
@@ -114,6 +114,13 @@ END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
SPLASH BITMAP DISCARDABLE "splash.bmp"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
+77 -16
View File
@@ -298,30 +298,50 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
//-----------------------------------------------------------------------------
HRESULT CreateObjects( HWND hWnd )
{
////////////////////////////////
// Draw a splash bitmap so the user isn't looking at a black screen
////////////////////////////////
HBITMAP hSplashBitmap = (HBITMAP)LoadImage(
GetModuleHandle( NULL ),
TEXT("SPLASH"),
IMAGE_BITMAP,
0, 0, LR_CREATEDIBSECTION );
BITMAP bmp;
RECT rc;
GetClientRect( hWnd, &rc );
// Display the splash bitmap in the window
HDC hDCWindow = GetDC( hWnd );
HDC hDCImage = CreateCompatibleDC( NULL );
SelectObject( hDCImage, hSplashBitmap );
GetObject( hSplashBitmap, sizeof(bmp), &bmp );
StretchBlt( hDCWindow, 0, 0, rc.right, rc.bottom,
hDCImage, 0, 0,
bmp.bmWidth, bmp.bmHeight, SRCCOPY );
DeleteDC( hDCImage );
ReleaseDC( hWnd, hDCWindow );
// Delete the bitmap
DeleteObject( hSplashBitmap );
/////////////////////////////////
// Create game objects
/////////////////////////////////
srand( (unsigned)time(NULL) ); // seed number generator
RageLogStart();
SCREEN = new RageScreen( hWnd, true, SCREEN_WIDTH, SCREEN_HEIGHT, 16 );
TM = new RageTextureManager( SCREEN );
THEME = new ThemeManager;
WM = new WindowManager;
// throw something up on the screen while the game resources are loading
WM->SetNewWindow( new WindowLoading );
Render();
ShowFrame();
// this stuff takes a long time...
SOUND = new RageSound( hWnd );
MUSIC = new RageSoundStream;
INPUT = new RageInput( hWnd );
GAMEINFO= new GameInfo;
SCREEN = new RageScreen( hWnd );
BringWindowToTop( hWnd );
SetForegroundWindow( hWnd );
// switch the screen resolution according to user's prefs
GameOptions &go = GAMEINFO->m_GameOptions;
SwitchDisplayMode(
go.m_bWindowed,
@@ -330,7 +350,12 @@ HRESULT CreateObjects( HWND hWnd )
go.m_iDisplayColor
);
TM = new RageTextureManager( SCREEN );
THEME = new ThemeManager;
WM = new WindowManager;
//WM->SetNewWindow( new WindowLoading );
//WM->SetNewWindow( new WindowSandbox );
//WM->SetNewWindow( new WindowMenuResults );
//WM->SetNewWindow( new WindowPlayerOptions );
@@ -538,17 +563,53 @@ BOOL SwitchDisplayMode( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwB
{
InvalidateObjects();
BOOL bResult = SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP );
// If the requested resolution doesn't work, keep switching until we find one that does.
if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) )
{
// We failed. Try full screen with same params.
bWindowed = false;
if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) )
{
// Failed again. Try 16 BPP
dwBPP = 16;
if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) )
{
// Failed again. Try 640x480
dwWidth = 640;
dwHeight = 480;
if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) )
{
// Failed again. Try 640x480
dwWidth = 320;
dwHeight = 240;
if( !SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP ) )
{
RageError( "Tried every possible display mode, and couldn't change to any of them." );
return false;
}
}
}
}
}
RestoreObjects();
if( GAMEINFO )
{
GAMEINFO->m_GameOptions.m_bWindowed = bWindowed;
GAMEINFO->m_GameOptions.m_iDisplayColor = dwBPP;
GAMEINFO->m_GameOptions.m_iResolution = dwWidth;
GAMEINFO->SaveConfigToDisk();
}
return bResult;
if( WM )
{
WM->SetSystemMessage( ssprintf("%s - %ux%u - %u bits", bWindowed ? "Windowed" : "FullScreen", dwWidth, dwHeight, dwBPP) );
}
return true;
}
+4
View File
@@ -743,5 +743,9 @@ SOURCE=.\TipDisplay.cpp
SOURCE=.\TipDisplay.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\splash.bmp
# End Source File
# End Target
# End Project
+1 -1
View File
@@ -85,7 +85,7 @@ void TransitionStarWipe::RenderPrimitives()
int x_rect_leading_edge = x + ( bIsAnEvenRow ? - m_iStarWidth/2 : m_iStarWidth/2 );
int x_rect_trailing_edge = ( bIsAnEvenRow ? 0 : SCREEN_WIDTH );
int y_top = y - m_iStarHeight/2;
int y_bot = y + m_iStarHeight/2;
int y_bot = y + m_iStarHeight/2+1;
m_rect.StretchTo( CRect(x_rect_leading_edge, y_top, x_rect_trailing_edge, y_bot) );
m_rect.SetDiffuseColor( D3DCOLOR_ARGB(255,0,0,0) );
m_rect.Draw();