Files
itgmania212121/stepmania/src/song.h
T

132 lines
3.6 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?
2002-01-16 10:01:32 +00:00
#include "Grade.h"
2001-11-30 09:38:35 +00:00
2001-12-28 10:15:59 +00:00
struct BPMSegment
{
BPMSegment() { m_fStartBeat = m_fBPM = -1; };
float m_fStartBeat;
float m_fBPM;
};
struct FreezeSegment
{
FreezeSegment() { m_fStartBeat = m_fFreezeSeconds = -1; };
float m_fStartBeat;
float m_fFreezeSeconds;
2001-12-19 01:50:57 +00:00
};
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-12-19 01:50:57 +00:00
bool LoadSongInfoFromDWIFile( CString sPath );
2001-12-28 10:15:59 +00:00
bool LoadSongInfoFromBMSDir( CString sDir );
private:
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:
2002-01-16 10:01:32 +00:00
CString GetSongFilePath() {return m_sSongFilePath; };
CString GetSongFileDir() {return m_sSongDir; };
CString GetGroupName() {return m_sGroupName; };
CString GetMusicPath() {return m_sMusicPath; };
CString GetBannerPath() {return m_sBannerPath; };
CString GetBackgroundPath() {return m_sBackgroundPath; };
CString GetBackgroundMoviePath(){return m_sBackgroundMoviePath; };
2001-11-03 10:52:42 +00:00
2001-12-28 10:15:59 +00:00
2002-01-16 10:01:32 +00:00
bool HasMusic() {return m_sMusicPath != "" && DoesFileExist(GetMusicPath()); };
bool HasBanner() {return m_sBannerPath != "" && DoesFileExist(GetBannerPath()); };
bool HasBackground() {return m_sBackgroundPath != "" && DoesFileExist(GetBackgroundPath()); };
bool HasBackgroundMovie() {return m_sBackgroundMoviePath != ""&& DoesFileExist(GetBackgroundMoviePath()); };
2001-12-19 14:56:22 +00:00
2002-01-16 10:01:32 +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; };
2001-12-28 10:15:59 +00:00
void GetMinMaxBPM( float &fMinBPM, float &fMaxBPM )
{
2001-12-28 10:15:59 +00:00
fMaxBPM = 0;
fMinBPM = 100000; // inf
for( int i=0; i<m_BPMSegments.GetSize(); i++ )
{
BPMSegment &seg = m_BPMSegments[i];
fMaxBPM = max( seg.m_fBPM, fMaxBPM );
fMinBPM = min( seg.m_fBPM, fMinBPM );
}
};
2001-12-19 01:50:57 +00:00
void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut );
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:
2002-01-16 10:01:32 +00:00
int m_iNumTimesPlayed;
2001-11-03 10:52:42 +00:00
2002-01-20 23:29:03 +00:00
// statistics for single-basic, single-another... double-basic... double-maniac:
Grade m_TopGrade[6];
int m_iTopScore[6];
int m_iMaxCombo[6];
2001-11-03 10:52:42 +00:00
private:
2001-12-28 10:15:59 +00:00
CString m_sSongFilePath;
2001-11-03 10:52:42 +00:00
CString m_sSongDir;
2001-12-28 10:15:59 +00:00
CString m_sGroupName;
2001-11-03 10:52:42 +00:00
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
2001-12-28 10:15:59 +00:00
CString m_sMusicPath;
CString m_sBannerPath;
CString m_sBackgroundPath;
2002-01-16 10:01:32 +00:00
CString m_sBackgroundMoviePath;
2001-11-03 10:52:42 +00:00
2001-12-19 01:50:57 +00:00
CArray<BPMSegment, BPMSegment&> m_BPMSegments; // this must be sorted before dancing
2001-12-28 10:15:59 +00:00
CArray<FreezeSegment, FreezeSegment&> m_FreezeSegments; // this must be sorted before dancing
2001-11-03 10:52:42 +00:00
public:
CArray<Steps, Steps&> arraySteps;
};
2002-01-16 10:01:32 +00:00
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 );
2001-11-03 10:52:42 +00:00
#endif