Added synchronize

This commit is contained in:
Chris Danford
2002-02-11 04:46:31 +00:00
parent 7682367a4e
commit 6ed1d938e7
18 changed files with 180 additions and 45 deletions
+5 -5
View File
@@ -32,12 +32,12 @@ Background::Background()
m_sprDangerBackground.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
}
bool Background::LoadFromSong( Song &song )
bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
{
if( song.HasBackgroundMovie() )
if( pSong->HasBackgroundMovie() )
{
// load the movie backgound, and don't load a visualization
m_sprSongBackground.Load( song.HasBackground() );
m_sprSongBackground.Load( pSong->HasBackground() );
m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
m_sprSongBackground.SetZoomY( -1 );
m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
@@ -46,7 +46,7 @@ bool Background::LoadFromSong( Song &song )
else
{
// load the static background (if available), and a visualization
if( song.HasBackground() ) m_sprSongBackground.Load( song.GetBackgroundPath(), HINT_DITHER );
if( pSong->HasBackground() ) m_sprSongBackground.Load( pSong->GetBackgroundPath(), HINT_DITHER );
else m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), HINT_DITHER );
m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
@@ -54,7 +54,7 @@ bool Background::LoadFromSong( Song &song )
this->AddActor( &m_sprSongBackground );
if( GAMEINFO->m_GameOptions.m_bRandomVis )
if( GAMEINFO->m_GameOptions.m_bRandomVis && !bDisableVisualizations )
{
// load a random visualization
CStringArray sVisualizationPaths;
+1 -1
View File
@@ -22,7 +22,7 @@ class Background : public ActorFrame
public:
Background();
virtual bool LoadFromSong( Song &song );
virtual bool LoadFromSong( Song *pSong, bool bDisableVisualizations = false );
virtual void Update( float fDeltaTime );
virtual void RenderPrimitives();
+2 -2
View File
@@ -219,7 +219,7 @@ void BitmapText::RebuildVertexBuffer()
case align_top: fY = -(m_sTextLines.GetSize()) * fHeight / 2; break;
case align_middle: fY = 0; break;
case align_bottom: fY = (m_sTextLines.GetSize()) * fHeight / 2; break;
default: ASSERT( true );
default: ASSERT( false );
}
@@ -234,7 +234,7 @@ void BitmapText::RebuildVertexBuffer()
case align_left: fX = 0; break;
case align_center: fX = -(fLineWidth/2); break;
case align_right: fX = -fLineWidth; break;
default: ASSERT( true );
default: ASSERT( false );
}
for( int j=0; j<sLine.GetLength(); j++ ) // for each character in the line
+1 -1
View File
@@ -35,7 +35,7 @@ void GhostArrow::Step( StepScore score )
case great: SetDiffuseColor( D3DXCOLOR(0.0f,1.0f,0.4f,0.7f) ); break; // green
case good: SetDiffuseColor( D3DXCOLOR(0.3f,0.8f,1.0f,0.7f) ); break;
case boo: SetDiffuseColor( D3DXCOLOR(0.8f,0.0f,0.6f,0.7f) ); break;
case miss: ASSERT(true); break;
case miss: ASSERT( false ); break;
}
SetZoom( 1.0f );
BeginTweening( 0.3f );
+1 -1
View File
@@ -35,7 +35,7 @@ void GhostArrowBright::Step( StepScore score )
case great: SetDiffuseColor( D3DXCOLOR(0.0f,1.0f,0.4f,0.9f) ); break; // green
case good: SetDiffuseColor( D3DXCOLOR(0.3f,0.8f,1.0f,0.9f) ); break;
case boo: SetDiffuseColor( D3DXCOLOR(0.8f,0.0f,0.6f,0.9f) ); break;
case miss: ASSERT(true); break;
case miss: ASSERT( false ); break;
}
SetState( 0 );
SetZoom( 1.2f );
+2 -2
View File
@@ -23,7 +23,7 @@ CString GradeToString( Grade g )
case GRADE_D: return "D";
case GRADE_E: return "E";
case GRADE_NO_DATA: return "N";
default: ASSERT(true); return "N";
default: ASSERT( false ); return "N";
}
};
@@ -38,5 +38,5 @@ Grade StringToGrade( CString s )
else if( s == "D" ) return GRADE_D;
else if( s == "E" ) return GRADE_E;
else if( s == "N" ) return GRADE_NO_DATA;
else ASSERT(true); return GRADE_NO_DATA; // invalid grade string
else ASSERT( false ); return GRADE_NO_DATA; // invalid grade string
};
+1 -1
View File
@@ -41,7 +41,7 @@ public:
case GRADE_D: SetState(5); break;
case GRADE_E: SetState(6); break;
case GRADE_NO_DATA: SetState(7); break;
default: ASSERT( true );
default: ASSERT( false );
}
};
+1 -1
View File
@@ -52,7 +52,7 @@ void MusicSortDisplay::Set( SongSortOrder so )
SetState( 5 );
break;
default:
ASSERT( true ); // unimplemented MusicSortOrder
ASSERT( false ); // unimplemented MusicSortOrder
}
}
+5 -5
View File
@@ -122,7 +122,7 @@ void WheelItemDisplay::LoadFromWheelItemData( WheelItemData* pWID )
m_MusicStatusDisplay.SetType( m_MusicStatusDisplayType );
break;
default:
ASSERT( true ); // invalid type
ASSERT( false ); // invalid type
}
}
@@ -215,7 +215,7 @@ MusicWheel::MusicWheel()
// init m_mapGroupNameToBannerColor
CArray<Song*, Song*&> arraySongs;
CArray<Song*, Song*> arraySongs;
arraySongs.Copy( GAMEINFO->m_pSongs );
SortSongPointerArrayByGroup( arraySongs );
@@ -283,7 +283,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
///////////////////////////////////
// Make an array of Song*, then sort them
///////////////////////////////////
CArray<Song*, Song*&> arraySongs;
CArray<Song*, Song*> arraySongs;
// copy only song that have at least one Steps for the current GameMode
for( int i=0; i<GAMEINFO->m_pSongs.GetSize(); i++ )
@@ -317,7 +317,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
SortSongPointerArrayByMostPlayed( arraySongs );
break;
default:
ASSERT( true ); // unhandled SORT_ORDER
ASSERT( false ); // unhandled SORT_ORDER
}
@@ -379,7 +379,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
}
break;
default:
ASSERT( true ); // unhandled SORT_ORDER
ASSERT( false ); // unhandled SORT_ORDER
}
// init crowns
+1 -1
View File
@@ -163,7 +163,7 @@ Player::Player()
m_ColumnToRotation[7] = mapStepToRotation[STEP_PAD2_RIGHT];
break;
default:
ASSERT( true ); // invalid GameMode
ASSERT( false ); // invalid GameMode
}
+7 -9
View File
@@ -32,15 +32,13 @@ RageSound::RageSound( HWND hWnd )
if( !BASS_Init( -1, 44100, BASS_DEVICE_LEAVEVOL, m_hWndApp ) )
{
MessageBox( NULL,
"There was an error while initializing your sound card.\n\n"
"The most likely cause of this problem is that you do not have a sound card\n"
"installed, or that you have not yet installed a driver for your sound card.\n"
"Before running this program again, please verify that your sound card is\n"
"is working in other Windows applications.",
"Sound error",
MB_ICONSTOP );
RageError( "BASS can't initialize sound device." );
RageError(
"There was an error while initializing your sound card.\n\n"
"The most likely cause of this problem is that you do not have a sound card\n"
"installed, or that you have not yet installed a driver for your sound card.\n"
"Before running this program again, please verify that your sound card is\n"
"is working in other Windows applications."
);
}
BASS_Start();
+119 -8
View File
@@ -220,7 +220,7 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
// Load the Song info from the first BMS file. Silly BMS duplicates the song info in every
// 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];
m_sSongFilePath = m_sSongDir + arrayBMSFileNames[0];
// load the Steps from the rest of the BMS files
for( int i=0; i<arrayBMSFileNames.GetSize(); i++ )
@@ -232,9 +232,9 @@ bool Song::LoadSongInfoFromBMSDir( CString sDir )
CStdioFile file;
if( !file.Open( sBMSFilePath, CFile::modeRead|CFile::shareDenyNone ) )
if( !file.Open( m_sSongFilePath, CFile::modeRead|CFile::shareDenyNone ) )
{
RageError( ssprintf("Failed to open %s.", sBMSFilePath) );
RageError( ssprintf("Failed to open %s.", m_sSongFilePath) );
return false;
}
@@ -684,7 +684,118 @@ void Song::GetNumFeet( GameMode gm, int& iDiffEasyOut, int& iDiffMediumOut, int&
}
void Song::SaveOffsetChangeToDisk()
{
CString sDir, sFName, sExt;
splitrelpath( GetSongFilePath(), sDir, sFName, sExt );
sExt.MakeLower();
if( sExt == "bms" )
{
for( int i=0; i<arraySteps.GetSize(); i++ ) // for each Steps
{
CString sStepsFileName = arraySteps[i].m_sStepsFilePath;
CStringArray arrayLines;
CStdioFile fileIn;
if( !fileIn.Open( sStepsFileName, CFile::modeRead|CFile::shareDenyNone) )
RageError( ssprintf("Failed to open '%s' for reading", sStepsFileName) );
// read the file into sFileContents
CString sLine;
while( fileIn.ReadString(sLine) )
{
arrayLines.Add( sLine+"\n" );
}
fileIn.Close();
// write the file back to disk with the changes
CStdioFile fileOut;
if( !fileOut.Open( sStepsFileName, CFile::modeWrite|CFile::shareDenyWrite) )
RageError( ssprintf("Failed to open '%s' for writing", sStepsFileName) );
for( int j=0; j<arrayLines.GetSize(); j++ )
{
CString sLine = arrayLines[j];
if( -1 != sLine.Find("01:") )
{
float fBPM = m_BPMSegments[0].m_fBPM;
float fBPS = fBPM/60;
float fOffsetInBeats = m_fOffsetInSeconds * fBPS;
float fOffsetInMeasures = fOffsetInBeats / BEATS_PER_MEASURE;
int iMeasure = (int)fOffsetInMeasures;
float fPercentIntoMeasure = fmodf( fOffsetInMeasures, 1 );
CString sBMSMeasureString;
for( int k=0; k<64; k++ )
{
if( k == int(fPercentIntoMeasure*64) )
sBMSMeasureString += "99";
else
sBMSMeasureString += "00";
}
fileOut.WriteString( ssprintf("#%03d01:%s;\n", iMeasure, sBMSMeasureString) );
}
else
{
fileOut.WriteString( sLine );
}
}
fileOut.Close();
}
}
else if( sExt == "dwi" )
{
CStringArray arrayLines;
CStdioFile fileIn;
if( !fileIn.Open( GetSongFilePath(), CFile::modeRead|CFile::shareDenyNone) )
RageError( ssprintf("Failed to open '%s' for reading", GetSongFilePath()) );
// read the file into sFileContents
CString sLine;
while( fileIn.ReadString(sLine) )
{
arrayLines.Add( sLine+"\n" );
}
fileIn.Close();
// 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()) );
for( int i=0; i<arrayLines.GetSize(); i++ )
{
CString sLine = arrayLines[i];
if( -1 != sLine.Find("#GAP") )
{
// replace with new offset
fileOut.WriteString( ssprintf("#GAP:%d;\n", roundf(GetBeatOffsetInSeconds()*-1*1000)) );
}
else
{
fileOut.WriteString( sLine );
}
}
fileOut.Close();
}
else
{
RageError( ssprintf("Unrecognized extension '%s' on song file '%s'", sExt, GetSongFilePath()) );
}
m_bChangedSinceSave = false;
}
/////////////////////////////////////
// Sorting
/////////////////////////////////////
int CompareSongPointersByTitle(const void *arg1, const void *arg2)
{
@@ -703,7 +814,7 @@ int CompareSongPointersByTitle(const void *arg1, const void *arg2)
return CompareCStrings( (void*)&sCompareString1, (void*)&sCompareString2 );
}
void SortSongPointerArrayByTitle( CArray<Song*, Song*&> &arraySongPointers )
void SortSongPointerArrayByTitle( CArray<Song*, Song*> &arraySongPointers )
{
qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByTitle );
}
@@ -728,7 +839,7 @@ int CompareSongPointersByBPM(const void *arg1, const void *arg2)
return 1;
}
void SortSongPointerArrayByBPM( CArray<Song*, Song*&> &arraySongPointers )
void SortSongPointerArrayByBPM( CArray<Song*, Song*> &arraySongPointers )
{
qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByBPM );
}
@@ -751,7 +862,7 @@ int CompareSongPointersByArtist(const void *arg1, const void *arg2)
return CompareCStrings( (void*)&sCompareString1, (void*)&sCompareString2 );
}
void SortSongPointerArrayByArtist( CArray<Song*, Song*&> &arraySongPointers )
void SortSongPointerArrayByArtist( CArray<Song*, Song*> &arraySongPointers )
{
qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByArtist );
}
@@ -773,7 +884,7 @@ int CompareSongPointersByGroup(const void *arg1, const void *arg2)
return CompareCStrings( (void*)&sCompareString1, (void*)&sCompareString2 );
}
void SortSongPointerArrayByGroup( CArray<Song*, Song*&> &arraySongPointers )
void SortSongPointerArrayByGroup( CArray<Song*, Song*> &arraySongPointers )
{
qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByGroup );
}
@@ -797,7 +908,7 @@ int CompareSongPointersByMostPlayed(const void *arg1, const void *arg2)
return 1;
}
void SortSongPointerArrayByMostPlayed( CArray<Song*, Song*&> &arraySongPointers )
void SortSongPointerArrayByMostPlayed( CArray<Song*, Song*> &arraySongPointers )
{
qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByMostPlayed );
}
+2 -2
View File
@@ -255,7 +255,7 @@ void Sprite::RenderPrimitives()
case align_top: quadVerticies.left = 0; quadVerticies.right = m_size.x; break;
case align_middle: quadVerticies.left = -m_size.x/2; quadVerticies.right = m_size.x/2; break;
case align_bottom: quadVerticies.left = -m_size.x; quadVerticies.right = 0; break;
default: ASSERT( true );
default: ASSERT( false );
}
switch( m_VertAlign )
@@ -263,7 +263,7 @@ void Sprite::RenderPrimitives()
case align_bottom: quadVerticies.top = 0; quadVerticies.bottom = m_size.y; break;
case align_middle: quadVerticies.top = -m_size.y/2; quadVerticies.bottom = m_size.y/2; break;
case align_top: quadVerticies.top = -m_size.y; quadVerticies.bottom = 0; break;
default: ASSERT( true );
default: ASSERT( false );
}
+16
View File
@@ -332,6 +332,22 @@ SOURCE=.\WindowSongOptions.h
# End Source File
# Begin Source File
SOURCE=.\WindowSynchronize.cpp
# End Source File
# Begin Source File
SOURCE=.\WindowSynchronize.h
# End Source File
# Begin Source File
SOURCE=.\WindowSynchronizeMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\WindowSynchronizeMenu.h
# End Source File
# Begin Source File
SOURCE=.\WindowTitleMenu.cpp
# End Source File
# Begin Source File
+2
View File
@@ -69,6 +69,8 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
case GRAPHIC_MUSIC_STATUS_ICONS: sAssetPath = "Graphics\\music status icons 1x4"; break;
case GRAPHIC_DANGER_TEXT: sAssetPath = "Graphics\\danger text"; break;
case GRAPHIC_DANGER_BACKGROUND: sAssetPath = "Graphics\\danger background"; break;
case GRAPHIC_ARROWS_LEFT: sAssetPath = "Graphics\\arrows left 1x4"; break;
case GRAPHIC_ARROWS_RIGHT: sAssetPath = "Graphics\\arrows right 1x4"; break;
case SOUND_FAILED: sAssetPath = "Sounds\\failed"; break;
case SOUND_ASSIST: sAssetPath = "Sounds\\Assist"; break;
+2
View File
@@ -63,6 +63,8 @@ enum ThemeElement {
GRAPHIC_MUSIC_STATUS_ICONS,
GRAPHIC_DANGER_TEXT,
GRAPHIC_DANGER_BACKGROUND,
GRAPHIC_ARROWS_LEFT,
GRAPHIC_ARROWS_RIGHT,
SOUND_FAILED,
SOUND_ASSIST,
+1 -1
View File
@@ -79,7 +79,7 @@ protected:
case closed:
return 1;
default:
ASSERT( true );
ASSERT( false );
return 0;
}
};
+11 -5
View File
@@ -43,6 +43,9 @@ public:
bool LoadFromSongDir( CString sDir );
bool LoadSongInfoFromDWIFile( CString sPath );
bool LoadSongInfoFromBMSDir( CString sDir );
void SaveOffsetChangeToDisk();
private:
void TidyUpData();
@@ -93,6 +96,9 @@ public:
return iTotalNumTimesPlayed;
}
bool HasChangedSinceLastSave() { return m_bChangedSinceSave; }
void SetChangedSinceLastSave() { m_bChangedSinceSave = true; }
private:
CString m_sSongFilePath;
CString m_sSongDir;
@@ -118,11 +124,11 @@ public:
};
void SortSongPointerArrayByTitle( CArray<Song*, Song*&> &arraySongPointers );
void SortSongPointerArrayByBPM( CArray<Song*, Song*&> &arraySongPointers );
void SortSongPointerArrayByArtist( CArray<Song*, Song*&> &arraySongPointers );
void SortSongPointerArrayByGroup( CArray<Song*, Song*&> &arraySongPointers );
void SortSongPointerArrayByMostPlayed( CArray<Song*, Song*&> &arraySongPointers );
void SortSongPointerArrayByTitle( CArray<Song*, Song*> &arraySongPointers );
void SortSongPointerArrayByBPM( CArray<Song*, Song*> &arraySongPointers );
void SortSongPointerArrayByArtist( CArray<Song*, Song*> &arraySongPointers );
void SortSongPointerArrayByGroup( CArray<Song*, Song*> &arraySongPointers );
void SortSongPointerArrayByMostPlayed( CArray<Song*, Song*> &arraySongPointers );