Files
itgmania212121/stepmania/src/song.h
T

249 lines
8.8 KiB
C++
Raw Normal View History

2004-05-31 21:35:31 +00:00
/* Song - Holds all music metadata and steps for one song. */
#ifndef SONG_H
#define SONG_H
2001-11-03 10:52:42 +00:00
2003-12-18 04:48:26 +00:00
#include "TimingData.h"
2005-01-22 19:36:39 +00:00
#include "Difficulty.h"
2005-06-04 21:22:50 +00:00
#include "EnumHelper.h"
2005-06-04 23:16:27 +00:00
#include "RageUtil_AutoPtr.h"
2005-10-24 07:37:38 +00:00
#include "RageTypes.h"
2003-12-18 04:48:26 +00:00
2003-12-18 03:41:47 +00:00
class Steps;
2004-06-28 07:26:00 +00:00
class Style;
2002-09-11 05:15:46 +00:00
class NotesLoader;
class LyricsLoader;
2004-02-10 09:42:01 +00:00
class Profile;
2004-04-18 08:06:14 +00:00
class StepsID;
2005-02-22 23:06:51 +00:00
struct lua_State;
2005-06-04 21:22:50 +00:00
struct BackgroundChange;
2001-11-30 09:38:35 +00:00
2005-05-26 09:35:57 +00:00
const int MAX_EDITS_PER_SONG_PER_PROFILE = 5;
2006-02-04 18:39:37 +00:00
const int MAX_EDITS_PER_SONG = 5*NUM_ProfileSlot;
extern const int FILE_CACHE_VERSION;
2001-12-28 10:15:59 +00:00
2005-06-04 21:22:50 +00:00
enum BackgroundLayer
{
BACKGROUND_LAYER_1,
BACKGROUND_LAYER_2,
NUM_BackgroundLayer,
BACKGROUND_LAYER_INVALID
2005-06-04 21:22:50 +00:00
};
#define FOREACH_BackgroundLayer( bl ) FOREACH_ENUM( BackgroundLayer, NUM_BackgroundLayer, bl )
struct LyricSegment
{
float m_fStartTime;
2006-01-22 01:00:06 +00:00
RString m_sLyric;
2003-03-19 21:30:12 +00:00
RageColor m_Color;
};
2001-11-03 10:52:42 +00:00
class Song
{
2006-01-22 01:00:06 +00:00
RString m_sSongDir;
2002-09-06 23:36:04 +00:00
public:
2006-02-04 18:39:37 +00:00
void SetSongDir( const RString sDir ) { m_sSongDir = sDir; }
2002-08-30 04:28:12 +00:00
/* Set when this song should be displayed in the music wheel: */
enum SelectionDisplay
{
SHOW_ALWAYS, /* all the time */
SHOW_ROULETTE, /* only when rouletting */
SHOW_NEVER /* never (unless song hiding is turned off) */
} m_SelectionDisplay;
2002-09-06 23:36:04 +00:00
Song();
2002-06-14 22:25:22 +00:00
~Song();
2003-06-24 20:04:35 +00:00
void Reset();
void DetachSteps();
2006-01-22 01:00:06 +00:00
NotesLoader *MakeLoader( RString sDir ) const;
2006-01-22 01:00:06 +00:00
bool LoadFromSongDir( RString sDir );
2002-06-30 23:19:33 +00:00
2002-04-16 17:31:00 +00:00
void TidyUpData(); // call after loading to clean up invalid data
void ReCalculateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving
void TranslateTitles(); // called by TidyUpData
2001-11-03 10:52:42 +00:00
2006-01-22 01:00:06 +00:00
void SaveToSMFile( RString sPath, bool bSavingCache );
2002-09-11 04:49:07 +00:00
void Save(); // saves SM and DWI
2002-06-30 23:19:33 +00:00
void SaveToCacheFile();
2002-09-11 04:49:07 +00:00
void SaveToDWIFile();
2002-05-19 01:59:48 +00:00
2006-01-22 01:00:06 +00:00
const RString &GetSongFilePath() const;
RString GetCacheFilePath() const;
2002-06-29 11:59:09 +00:00
void AddAutoGenNotes();
2003-08-07 06:16:17 +00:00
void AutoGen( StepsType ntTo, StepsType ntFrom ); // create Steps of type ntTo from Steps of type ntFrom
2003-01-30 07:18:33 +00:00
void RemoveAutoGenNotes();
/* Directory this song data came from: */
2006-01-22 01:00:06 +00:00
const RString &GetSongDir() const { return m_sSongDir; }
/* Filename associated with this file. This will always have
* an .SM extension. If we loaded an .SM, this will point to
* it, but if we loaded any other type, this will point to a
* generated .SM filename. */
2006-01-22 01:00:06 +00:00
RString m_sSongFileName;
2006-01-22 01:00:06 +00:00
RString m_sGroupName;
2002-06-29 11:59:09 +00:00
2005-12-01 03:20:25 +00:00
ProfileSlot m_LoadedFromProfile; // ProfileSlot_INVALID if wasn't loaded from a profile
bool m_bIsSymLink;
2001-12-28 10:15:59 +00:00
2006-01-22 01:00:06 +00:00
RString m_sMainTitle, m_sSubTitle, m_sArtist;
RString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit;
2003-02-11 23:52:18 +00:00
2003-05-20 04:41:47 +00:00
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
2003-02-11 23:52:18 +00:00
* Otherwise, they return the main titles. */
2006-01-22 01:00:06 +00:00
RString GetDisplayMainTitle() const;
RString GetDisplaySubTitle() const;
RString GetDisplayArtist() const;
2003-02-11 23:52:18 +00:00
/* Returns the transliterated titles, if any; otherwise returns the main titles. */
2006-01-22 01:00:06 +00:00
RString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; }
RString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; }
RString GetTranslitArtist() const { return m_sArtistTranslit.size()? m_sArtistTranslit:m_sArtist; }
2003-02-11 23:52:18 +00:00
/* "title subtitle" */
2006-01-22 01:00:06 +00:00
RString GetDisplayFullTitle() const;
RString GetTranslitFullTitle() const;
2003-02-11 23:52:18 +00:00
2006-01-22 01:00:06 +00:00
RString m_sGenre;
2005-01-31 05:25:27 +00:00
2003-02-11 23:52:18 +00:00
/* This is read and saved, but never actually used. */
2006-01-22 01:00:06 +00:00
RString m_sCredit;
2001-12-19 14:56:22 +00:00
2006-01-22 01:00:06 +00:00
RString m_sMusicFile;
2002-06-29 11:59:09 +00:00
float m_fMusicLengthSeconds;
float m_fFirstBeat; // beat of first note
float m_fLastBeat; // beat of last note
2002-06-29 11:59:09 +00:00
float m_fMusicSampleStartSeconds;
float m_fMusicSampleLengthSeconds;
enum { DISPLAY_ACTUAL, DISPLAY_SPECIFIED, DISPLAY_RANDOM } m_DisplayBPMType;
2003-06-16 17:28:58 +00:00
float m_fSpecifiedBPMMin;
float m_fSpecifiedBPMMax; // if a range, then Min != Max
2002-08-18 23:20:18 +00:00
2006-01-22 01:00:06 +00:00
RString m_sBannerFile;
RString m_sLyricsFile;
RString m_sBackgroundFile;
RString m_sCDTitleFile;
2002-06-29 11:59:09 +00:00
2006-01-22 01:00:06 +00:00
RString GetMusicPath() const;
RString GetBannerPath() const;
RString GetLyricsPath() const;
RString GetBackgroundPath() const;
RString GetCDTitlePath() const;
2002-06-29 11:59:09 +00:00
2003-12-30 03:40:29 +00:00
/* For loading only: */
bool m_bHasMusic, m_bHasBanner;
2002-06-29 11:59:09 +00:00
2002-09-07 11:45:15 +00:00
bool HasMusic() const;
bool HasBanner() const;
bool HasBackground() const;
bool HasCDTitle() const;
bool HasMovieBackground() const;
bool HasBGChanges() const;
bool HasLyrics() const;
2002-06-29 11:59:09 +00:00
2006-01-22 01:00:06 +00:00
bool Matches(RString sGroup, RString sSong) const;
2003-07-09 04:09:35 +00:00
2003-12-18 04:48:26 +00:00
TimingData m_Timing;
2005-06-04 21:22:50 +00:00
2005-06-04 23:16:27 +00:00
typedef vector<BackgroundChange> VBackgroundChange;
2005-06-04 21:22:50 +00:00
private:
2005-06-04 23:16:27 +00:00
// AutoPtr instead of raw pointer so that the auto gen'd copy constructor works correctly.
AutoPtrCopyOnWrite<VBackgroundChange> m_BackgroundChanges[NUM_BackgroundLayer]; // these must be sorted before gameplay
AutoPtrCopyOnWrite<VBackgroundChange> m_ForegroundChanges; // this must be sorted before gameplay
2005-06-04 21:22:50 +00:00
public:
const vector<BackgroundChange> &GetBackgroundChanges( BackgroundLayer bl ) const;
vector<BackgroundChange> &GetBackgroundChanges( BackgroundLayer bl );
const vector<BackgroundChange> &GetForegroundChanges() const;
vector<BackgroundChange> &GetForegroundChanges();
2004-01-07 00:13:32 +00:00
vector<LyricSegment> m_LyricSegments; // this must be sorted before gameplay
2002-06-29 11:59:09 +00:00
2003-12-18 04:48:26 +00:00
void AddBPMSegment( const BPMSegment &seg ) { m_Timing.AddBPMSegment( seg ); }
void AddStopSegment( const StopSegment &seg ) { m_Timing.AddStopSegment( seg ); }
2005-06-04 21:22:50 +00:00
void AddBackgroundChange( BackgroundLayer blLayer, BackgroundChange seg );
2004-01-07 00:13:32 +00:00
void AddForegroundChange( BackgroundChange seg );
void AddLyricSegment( LyricSegment seg );
2002-07-11 19:02:26 +00:00
void GetDisplayBpms( DisplayBpms &AddTo ) const;
2005-06-04 21:22:50 +00:00
const BackgroundChange &GetBackgroundAtBeat( BackgroundLayer iLayer, float fBeat ) const;
2003-12-18 04:48:26 +00:00
float GetBPMAtBeat( float fBeat ) const { return m_Timing.GetBPMAtBeat( fBeat ); }
void SetBPMAtBeat( float fBeat, float fBPM ) { m_Timing.SetBPMAtBeat( fBeat, fBPM ); }
BPMSegment& GetBPMSegmentAtBeat( float fBeat ) { return m_Timing.GetBPMSegmentAtBeat( fBeat ); }
float GetBeatFromElapsedTime( float fElapsedTime ) const { return m_Timing.GetBeatFromElapsedTime( fElapsedTime ); }
float GetElapsedTimeFromBeat( float fBeat ) const { return m_Timing.GetElapsedTimeFromBeat( fBeat ); }
bool HasSignificantBpmChangesOrStops() const;
2005-04-27 21:46:35 +00:00
float GetStepsSeconds() const;
2002-01-20 23:29:03 +00:00
2004-06-28 07:26:00 +00:00
bool SongCompleteForStyle( const Style *st ) const;
2004-06-02 05:52:16 +00:00
bool HasStepsType( StepsType st ) const;
bool HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const;
2005-02-23 22:14:58 +00:00
const vector<Steps*>& GetAllSteps() const { return m_vpSteps; }
const vector<Steps*>& GetStepsByStepsType( StepsType st ) const { return m_vpStepsByType[st]; }
bool IsEasy( StepsType st ) const;
bool IsTutorial() const;
bool HasEdits( StepsType st ) const;
2004-02-26 20:29:37 +00:00
SelectionDisplay GetDisplayed() const;
2004-07-25 20:51:44 +00:00
bool NormallyDisplayed() const;
bool NeverDisplayed() const;
bool RouletteDisplayed() const;
bool ShowInDemonstrationAndRanking() const;
2003-01-30 07:18:33 +00:00
2004-05-24 03:41:39 +00:00
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
void DeleteSteps( const Steps* pSteps, bool bReAutoGen = true );
2004-02-08 01:05:53 +00:00
2005-12-01 03:20:25 +00:00
void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_INVALID );
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_INVALID; }
2005-11-30 22:42:28 +00:00
void GetStepsLoadedFromProfile( ProfileSlot slot, vector<Steps*> &vpStepsOut ) const;
2004-04-23 00:26:51 +00:00
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
2004-04-23 01:33:08 +00:00
bool IsEditAlreadyLoaded( Steps* pSteps ) const;
// An array of keysound file names (e.g. "beep.wav").
// The index in this array corresponds to the index in TapNote. If you
// change the index in here, you must change all NoteData too.
// Any note that doesn't have a value in the range of this array
// means "this note doens't have a keysound".
2006-01-22 01:00:06 +00:00
vector<RString> m_vsKeysoundFile;
2005-02-22 23:06:51 +00:00
// Lua
void PushSelf( lua_State *L );
private:
2004-06-05 05:20:57 +00:00
vector<Steps*> m_vpSteps;
vector<Steps*> m_vpStepsByType[NUM_STEPS_TYPES];
2001-11-03 10:52:42 +00:00
};
#endif
2004-05-31 21:35:31 +00:00
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/