2002-04-16 17:31:00 +00:00
|
|
|
#pragma once
|
2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-03-19 07:09:49 +00:00
|
|
|
Class: Song
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-03-19 07:09:49 +00:00
|
|
|
Desc: Holds data about a piece of music that can be played by one or more
|
|
|
|
|
Games.
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-03-19 07:09:49 +00:00
|
|
|
Chris Danford
|
2001-11-04 19:34:28 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
#include "Notes.h"
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-05-01 19:14:55 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-03-19 07:09:49 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
//enum DanceStyle; // why is this needed?
|
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:
|
2001-11-04 19:34:28 +00:00
|
|
|
Song();
|
2002-06-14 22:25:22 +00:00
|
|
|
~Song();
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
bool LoadFromSongDir( CString sDir ); // calls one of the loads below
|
|
|
|
|
void Save() { SaveToSMDir(); SaveToCacheFile(); };
|
|
|
|
|
|
|
|
|
|
bool LoadFromCacheFile( bool bLoadNoteData );
|
|
|
|
|
|
|
|
|
|
protected:
|
2002-04-16 17:31:00 +00:00
|
|
|
bool LoadFromDWIFile( CString sPath );
|
|
|
|
|
bool LoadFromBMSDir( CString sDir );
|
|
|
|
|
bool LoadFromSMDir( CString sDir );
|
|
|
|
|
void TidyUpData(); // call after loading to clean up invalid data
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
void SaveToSMDir(); // saves to StepMania song and notes files
|
|
|
|
|
void SaveToCacheFile(); // saves to cache file
|
|
|
|
|
|
|
|
|
|
void DeleteCacheFile();
|
|
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
public:
|
2002-01-16 10:01:32 +00:00
|
|
|
CString GetSongFilePath() {return m_sSongFilePath; };
|
2002-05-19 01:59:48 +00:00
|
|
|
CString GetCacheFilePath();
|
2002-01-16 10:01:32 +00:00
|
|
|
CString GetSongFileDir() {return m_sSongDir; };
|
|
|
|
|
CString GetGroupName() {return m_sGroupName; };
|
|
|
|
|
CString GetMusicPath() {return m_sMusicPath; };
|
2002-06-14 22:25:22 +00:00
|
|
|
float GetMusicLengthSeconds() {return m_fMusicLength; };
|
2002-04-28 20:42:32 +00:00
|
|
|
void GetMusicSampleRange( float &fStartSec, float &fEndSec ) { fStartSec = m_fMusicSampleStartSeconds; fEndSec = m_fMusicSampleStartSeconds + m_fMusicSampleLengthSeconds; };
|
2002-01-16 10:01:32 +00:00
|
|
|
CString GetBannerPath() {return m_sBannerPath; };
|
|
|
|
|
CString GetBackgroundPath() {return m_sBackgroundPath; };
|
|
|
|
|
CString GetBackgroundMoviePath(){return m_sBackgroundMoviePath; };
|
2002-04-16 17:31:00 +00:00
|
|
|
CString GetCDTitlePath() {return m_sCDTitlePath; };
|
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()); };
|
2002-04-16 17:31:00 +00:00
|
|
|
bool HasCDTitle() {return m_sCDTitlePath != "" && DoesFileExist(GetCDTitlePath()); };
|
2001-12-19 14:56:22 +00:00
|
|
|
|
|
|
|
|
|
2002-04-28 20:42:32 +00:00
|
|
|
CString GetMainTitle() {return m_sMainTitle; };
|
|
|
|
|
CString GetSubTitle() {return m_sSubTitle; };
|
2002-05-01 19:14:55 +00:00
|
|
|
CString GetFullTitle() {return m_sMainTitle + " " + m_sSubTitle; };
|
|
|
|
|
void GetMainAndSubTitlesFromFullTitle( CString sFullTitle, CString &sMainTitleOut, CString &sSubTitleOut );
|
2002-04-28 20:42:32 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
CString GetArtist() {return m_sArtist; };
|
2002-04-16 17:31:00 +00:00
|
|
|
CString GetCredit() {return m_sCredit; };
|
2001-11-30 21:21:33 +00:00
|
|
|
float GetBeatOffsetInSeconds() {return m_fOffsetInSeconds; };
|
2002-06-23 11:43:53 +00:00
|
|
|
void SetBeatOffsetInSeconds(float fNewOffset) {m_fOffsetInSeconds = fNewOffset; };
|
2001-12-28 10:15:59 +00:00
|
|
|
void GetMinMaxBPM( float &fMinBPM, float &fMaxBPM )
|
2001-11-27 22:47:30 +00:00
|
|
|
{
|
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-11-27 22:47:30 +00:00
|
|
|
}
|
|
|
|
|
};
|
2001-12-19 01:50:57 +00:00
|
|
|
void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut );
|
2002-04-16 17:31:00 +00:00
|
|
|
float GetElapsedTimeFromBeat( float fBeat );
|
2002-05-27 08:23:27 +00:00
|
|
|
void GetNotesThatMatch( NotesType nt, CArray<Notes*, Notes*>& arrayAddTo );
|
2002-01-20 23:29:03 +00:00
|
|
|
|
2002-02-02 05:11:12 +00:00
|
|
|
int GetNumTimesPlayed()
|
|
|
|
|
{
|
|
|
|
|
int iTotalNumTimesPlayed = 0;
|
2002-05-19 01:59:48 +00:00
|
|
|
for( int i=0; i<m_arrayNotes.GetSize(); i++ )
|
2002-02-02 05:11:12 +00:00
|
|
|
{
|
2002-06-14 22:25:22 +00:00
|
|
|
iTotalNumTimesPlayed += m_arrayNotes[i]->m_iNumTimesPlayed;
|
2002-02-02 05:11:12 +00:00
|
|
|
}
|
|
|
|
|
return iTotalNumTimesPlayed;
|
|
|
|
|
}
|
2002-05-19 01:59:48 +00:00
|
|
|
bool IsNew() { return GetNumTimesPlayed()==0; };
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-02-11 04:46:31 +00:00
|
|
|
bool HasChangedSinceLastSave() { return m_bChangedSinceSave; }
|
2002-06-23 11:43:53 +00:00
|
|
|
void SetChangedSinceLastSave() { m_bChangedSinceSave = true; }
|
2002-02-11 04:46:31 +00:00
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
Grade GetGradeForDifficultyClass( NotesType nt, DifficultyClass dc );
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2001-11-27 22:47:30 +00:00
|
|
|
bool m_bChangedSinceSave;
|
2002-04-28 20:42:32 +00:00
|
|
|
CString m_sMainTitle;
|
|
|
|
|
CString m_sSubTitle;
|
2001-11-03 10:52:42 +00:00
|
|
|
CString m_sArtist;
|
2002-04-16 17:31:00 +00:00
|
|
|
CString m_sCredit;
|
2001-11-27 22:47:30 +00:00
|
|
|
float m_fOffsetInSeconds;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-12-28 10:15:59 +00:00
|
|
|
CString m_sMusicPath;
|
2002-05-19 01:59:48 +00:00
|
|
|
DWORD m_iMusicBytes;
|
|
|
|
|
float m_fMusicLength;
|
2002-04-28 20:42:32 +00:00
|
|
|
float m_fMusicSampleStartSeconds, m_fMusicSampleLengthSeconds;
|
2001-12-28 10:15:59 +00:00
|
|
|
CString m_sBannerPath;
|
|
|
|
|
CString m_sBackgroundPath;
|
2002-01-16 10:01:32 +00:00
|
|
|
CString m_sBackgroundMoviePath;
|
2002-04-16 17:31:00 +00:00
|
|
|
CString m_sCDTitlePath;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
CArray<BPMSegment, BPMSegment&> m_BPMSegments; // this must be sorted before gameplay
|
|
|
|
|
CArray<FreezeSegment, FreezeSegment&> m_FreezeSegments; // this must be sorted before gameplay
|
2001-11-27 22:47:30 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
public:
|
2002-06-14 22:25:22 +00:00
|
|
|
CArray<Notes*, Notes*> m_arrayNotes;
|
2001-11-03 10:52:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2002-02-11 04:46:31 +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 );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
|
|
|
|
|