Files
itgmania212121/stepmania/src/song.h
T

126 lines
3.3 KiB
C++
Raw Normal View History

/*
-----------------------------------------------------------------------------
File: Song.h
Desc: Holds metadata for a song and the song's step data.
Copyright (c) 2001 Chris Danford. All rights reserved.
-----------------------------------------------------------------------------
*/
2001-11-03 10:52:42 +00:00
#ifndef _SONG_H_
#define _SONG_H_
#include "Steps.h"
2001-11-20 11:49:10 +00:00
class Steps; // why is this needed?
2001-11-03 10:52:42 +00:00
2001-11-30 09:38:35 +00:00
#include "GameInfo.h" // for definition of GameMode
enum GameMode; // why is this needed?
2001-12-19 01:50:57 +00:00
struct BPMSegment{
BPMSegment() { m_fStartBeat = m_fBPM = m_fFreezeSeconds = 0; };
float m_fStartBeat, m_fBPM, m_fFreezeSeconds;
};
2001-11-03 10:52:42 +00:00
class Song
{
public:
Song();
2001-11-03 10:52:42 +00:00
bool LoadFromSongDir( CString sDir );
2001-11-20 11:49:10 +00:00
bool IsUsingMovieBG()
2001-11-03 10:52:42 +00:00
{
CString sBGFile = m_sBackground;
sBGFile.MakeLower();
2001-11-20 11:49:10 +00:00
return sBGFile.Right(3) == "avi" ||
sBGFile.Right(3) == "mpg";
2001-11-03 10:52:42 +00:00
};
private:
bool LoadSongInfoFromBMSFile( CString sPath );
2001-12-19 01:50:57 +00:00
bool LoadSongInfoFromDWIFile( CString sPath );
2001-11-03 10:52:42 +00:00
2001-11-25 04:31:44 +00:00
void TidyUpData();
2001-11-03 10:52:42 +00:00
public:
CString GetSongFilePath() {return m_sSongDir + m_sSongFile; };
CString GetSongFileDir() {return m_sSongDir; };
CString GetMusicPath() {return m_sSongDir + m_sMusic; };
CString GetBannerPath() {return m_sSongDir + m_sBanner; };
CString GetBackgroundPath() {return m_sSongDir + m_sBackground; };
// Steps& GetStepsAt( int iIndex ) {return arraySteps[iIndex]; };
2001-12-19 14:56:22 +00:00
bool HasMusic() {return m_sMusic != "" && DoesFileExist(GetMusicPath()); };
bool HasBanner() {return m_sBanner != "" && DoesFileExist(GetBannerPath()); };
bool HasBackground() {return m_sBackground != "" && DoesFileExist(GetBackgroundPath()); };
2001-11-03 10:52:42 +00:00
CString GetTitle() {return m_sTitle; };
CString GetArtist() {return m_sArtist; };
CString GetCreator() {return m_sCreator; };
2001-11-30 21:21:33 +00:00
float GetBeatOffsetInSeconds() {return m_fOffsetInSeconds; };
void SetBeatOffsetInSeconds(float fNewOffset) {m_fOffsetInSeconds = fNewOffset; };
void GetMinMaxBPM( int &iMinBPM, int &iMaxBPM )
{
iMaxBPM = 0;
iMinBPM = 100000; // inf
for( int i=0; i<m_BPMSegments.GetSize(); i++ ) {
if( m_BPMSegments[i].m_fBPM > iMaxBPM )
iMaxBPM = (int)m_BPMSegments[i].m_fBPM;
if( m_BPMSegments[i].m_fBPM < iMinBPM )
iMinBPM = (int)m_BPMSegments[i].m_fBPM;
}
};
2001-12-19 01:50:57 +00:00
void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut );
2001-11-30 21:21:33 +00:00
float GetBPMAtBeat( float fSongBeat )
{
for( int i=0; i<m_BPMSegments.GetSize(); i++ ) {
2001-12-19 01:50:57 +00:00
if( m_BPMSegments[i].m_fStartBeat > fSongBeat || i==m_BPMSegments.GetSize()-1 )
2001-11-30 21:21:33 +00:00
break;
}
return m_BPMSegments[i].m_fBPM;
};
void SetBPM( float fNewBPM, float fSongBeat )
{
for( int i=0; i<m_BPMSegments.GetSize(); i++ ) {
2001-12-19 01:50:57 +00:00
if( m_BPMSegments[i].m_fStartBeat > fSongBeat || i==m_BPMSegments.GetSize()-1 )
2001-11-30 21:21:33 +00:00
break;
}
m_BPMSegments[i].m_fBPM = fNewBPM;
};
2001-11-03 10:52:42 +00:00
2001-11-30 09:38:35 +00:00
void GetStepsThatMatchGameMode( GameMode gm, CArray<Steps*, Steps*&>& arrayAddTo );
void GetNumFeet( GameMode gm, int& iDiffEasy, int& iDiffMedium, int& iDiffHard );
2001-11-30 21:21:33 +00:00
2001-11-30 09:38:35 +00:00
2001-11-03 10:52:42 +00:00
public:
private:
CString m_sSongFile;
CString m_sSongDir;
bool m_bChangedSinceSave;
2001-11-03 10:52:42 +00:00
CString m_sTitle;
CString m_sArtist;
CString m_sCreator;
// float m_fBPM;
float m_fOffsetInSeconds;
2001-11-03 10:52:42 +00:00
CString m_sMusic;
CString m_sBanner;
CString m_sBackground;
2001-12-19 01:50:57 +00:00
CArray<BPMSegment, BPMSegment&> m_BPMSegments; // this must be sorted before dancing
2001-11-03 10:52:42 +00:00
public:
CArray<Steps, Steps&> arraySteps;
};
#endif