Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

song.h

Go to the documentation of this file.
00001 /* Song - Holds all music metadata and steps for one song. */ 00002 00003 #ifndef SONG_H 00004 #define SONG_H 00005 00006 #include "PlayerNumber.h" 00007 #include "GameConstantsAndTypes.h" 00008 #include "Grade.h" 00009 #include "TimingData.h" 00010 #include "Difficulty.h" 00011 00012 class Steps; 00013 class Style; 00014 class NotesLoader; 00015 class LyricsLoader; 00016 class Profile; 00017 class StepsID; 00018 00019 #define MAX_EDITS_PER_SONG_PER_PROFILE 5 00020 #define MAX_EDITS_PER_SONG 5*NUM_PROFILE_SLOTS 00021 00022 extern const int FILE_CACHE_VERSION; 00023 00024 00025 struct BackgroundChange 00026 { 00027 BackgroundChange() { m_fStartBeat=-1; m_fRate=1; m_bFadeLast=false; m_bRewindMovie=false; m_bLoop=true; }; 00028 BackgroundChange( float s, CString n, float r=1.f, bool f=false, bool m=false, bool l=true ) { m_fStartBeat=s; m_sBGName=n; m_fRate=r; m_bFadeLast=f; m_bRewindMovie=m; m_bLoop=l; }; 00029 float m_fStartBeat; 00030 CString m_sBGName; 00031 float m_fRate; 00032 bool m_bFadeLast; 00033 bool m_bRewindMovie; 00034 bool m_bLoop; 00035 }; 00036 00037 void SortBackgroundChangesArray( vector<BackgroundChange> &arrayBackgroundChanges ); 00038 00039 struct LyricSegment 00040 { 00041 float m_fStartTime; 00042 CString m_sLyric; 00043 RageColor m_Color; 00044 }; 00045 00046 00047 class Song 00048 { 00049 CString m_sSongDir; 00050 00051 public: 00052 /* Set when this song should be displayed in the music wheel: */ 00053 enum SelectionDisplay { SHOW_ALWAYS, /* all the time */ 00054 SHOW_ROULETTE, /* only when rouletting */ 00055 SHOW_NEVER } /* never (unless song hiding is turned off) */ 00056 m_SelectionDisplay; 00057 00058 Song(); 00059 ~Song(); 00060 void Reset(); 00061 00062 NotesLoader *MakeLoader( CString sDir ) const; 00063 00064 bool LoadFromSongDir( CString sDir ); 00065 00066 void TidyUpData(); // call after loading to clean up invalid data 00067 void ReCalculateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving 00068 void TranslateTitles(); // called by TidyUpData 00069 00070 void SaveToSMFile( CString sPath, bool bSavingCache ); 00071 void Save(); // saves SM and DWI 00072 void SaveToCacheFile(); 00073 void SaveToDWIFile(); 00074 00075 const CString &GetSongFilePath() const; 00076 CString GetCacheFilePath() const; 00077 00078 void AddAutoGenNotes(); 00079 void AutoGen( StepsType ntTo, StepsType ntFrom ); // create Steps of type ntTo from Steps of type ntFrom 00080 void RemoveAutoGenNotes(); 00081 00082 /* Directory this song data came from: */ 00083 const CString &GetSongDir() const { return m_sSongDir; } 00084 00085 /* Filename associated with this file. This will always have 00086 * an .SM extension. If we loaded an .SM, this will point to 00087 * it, but if we loaded any other type, this will point to a 00088 * generated .SM filename. */ 00089 CString m_sSongFileName; 00090 00091 CString m_sGroupName; 00092 00093 ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile 00094 bool m_bIsSymLink; 00095 00096 CString m_sMainTitle, m_sSubTitle, m_sArtist; 00097 CString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit; 00098 00099 /* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below. 00100 * Otherwise, they return the main titles. */ 00101 CString GetDisplayMainTitle() const; 00102 CString GetDisplaySubTitle() const; 00103 CString GetDisplayArtist() const; 00104 00105 /* Returns the transliterated titles, if any; otherwise returns the main titles. */ 00106 CString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; } 00107 CString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; } 00108 CString GetTranslitArtist() const { return m_sArtistTranslit.size()? m_sArtistTranslit:m_sArtist; } 00109 00110 /* "title subtitle" */ 00111 CString GetFullDisplayTitle() const; 00112 CString GetFullTranslitTitle() const; 00113 00114 /* This is read and saved, but never actually used. */ 00115 CString m_sCredit; 00116 00117 CString m_sMusicFile; 00118 float m_fMusicLengthSeconds; 00119 float m_fFirstBeat; 00120 float m_fLastBeat; 00121 float m_fMusicSampleStartSeconds; 00122 float m_fMusicSampleLengthSeconds; 00123 enum { DISPLAY_ACTUAL, DISPLAY_SPECIFIED, DISPLAY_RANDOM } m_DisplayBPMType; 00124 float m_fSpecifiedBPMMin; 00125 float m_fSpecifiedBPMMax; // if a range, then Min != Max 00126 00127 CString m_sBannerFile; 00128 CString m_sLyricsFile; 00129 CString m_sBackgroundFile; 00130 CString m_sCDTitleFile; 00131 00132 CString GetMusicPath() const; 00133 CString GetBannerPath() const; 00134 CString GetLyricsPath() const; 00135 CString GetBackgroundPath() const; 00136 CString GetCDTitlePath() const; 00137 00138 /* For loading only: */ 00139 bool m_bHasMusic, m_bHasBanner; 00140 00141 bool HasMusic() const; 00142 bool HasBanner() const; 00143 bool HasBackground() const; 00144 bool HasCDTitle() const; 00145 bool HasMovieBackground() const; 00146 bool HasBGChanges() const; 00147 bool HasLyrics() const; 00148 00149 bool Matches(CString sGroup, CString sSong) const; 00150 00151 TimingData m_Timing; 00152 vector<BackgroundChange> m_BackgroundChanges; // this must be sorted before gameplay 00153 vector<BackgroundChange> m_ForegroundChanges; // this must be sorted before gameplay 00154 vector<LyricSegment> m_LyricSegments; // this must be sorted before gameplay 00155 00156 void AddBPMSegment( const BPMSegment &seg ) { m_Timing.AddBPMSegment( seg ); } 00157 void AddStopSegment( const StopSegment &seg ) { m_Timing.AddStopSegment( seg ); } 00158 void AddBackgroundChange( BackgroundChange seg ); 00159 void AddForegroundChange( BackgroundChange seg ); 00160 void AddLyricSegment( LyricSegment seg ); 00161 00162 void GetDisplayBpms( DisplayBpms &AddTo ) const; 00163 CString GetBackgroundAtBeat( float fBeat ) const; 00164 00165 float GetBPMAtBeat( float fBeat ) const { return m_Timing.GetBPMAtBeat( fBeat ); } 00166 void SetBPMAtBeat( float fBeat, float fBPM ) { m_Timing.SetBPMAtBeat( fBeat, fBPM ); } 00167 BPMSegment& GetBPMSegmentAtBeat( float fBeat ) { return m_Timing.GetBPMSegmentAtBeat( fBeat ); } 00168 void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut ) const { m_Timing.GetBeatAndBPSFromElapsedTime( fElapsedTime, fBeatOut, fBPSOut, bFreezeOut ); } 00169 float GetBeatFromElapsedTime( float fElapsedTime ) const { return m_Timing.GetBeatFromElapsedTime( fElapsedTime ); } 00170 float GetElapsedTimeFromBeat( float fBeat ) const { return m_Timing.GetElapsedTimeFromBeat( fBeat ); } 00171 bool HasSignificantBpmChangesOrStops() const; 00172 00173 bool SongCompleteForStyle( const Style *st ) const; 00174 bool HasStepsType( StepsType st ) const; 00175 bool HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const; 00176 const vector<Steps*>& GetAllSteps( StepsType st=STEPS_TYPE_INVALID ) const { return st==STEPS_TYPE_INVALID? m_vpSteps:m_vpStepsByType[st]; } 00177 void GetSteps( 00178 vector<Steps*>& arrayAddTo, 00179 StepsType st = STEPS_TYPE_INVALID, 00180 Difficulty dc = DIFFICULTY_INVALID, 00181 int iMeterLow = -1, 00182 int iMeterHigh = -1, 00183 const CString &sDescription = "", 00184 bool bIncludeAutoGen = true, 00185 unsigned uHash = 0, 00186 int iMaxToGet = -1 00187 ) const; 00188 Steps* GetSteps( 00189 StepsType st = STEPS_TYPE_INVALID, 00190 Difficulty dc = DIFFICULTY_INVALID, 00191 int iMeterLow = -1, 00192 int iMeterHigh = -1, 00193 const CString &sDescription = "", 00194 unsigned uHash = 0, 00195 bool bIncludeAutoGen = true 00196 ) const; 00197 Steps* GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen = true ) const; 00198 Steps* GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const; 00199 Steps* GetStepsByDescription( StepsType st, CString sDescription ) const; 00200 Steps* GetClosestNotes( StepsType st, Difficulty dc ) const; 00201 bool IsEasy( StepsType st ) const; 00202 bool IsTutorial() const; 00203 bool HasEdits( StepsType st ) const; 00204 SelectionDisplay GetDisplayed() const; 00205 bool NormallyDisplayed() const; 00206 bool NeverDisplayed() const; 00207 bool RouletteDisplayed() const; 00208 bool ShowInDemonstrationAndRanking() const; 00209 00210 void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps! 00211 void RemoveSteps( const Steps* pSteps ); 00212 00213 void FreeAllLoadedFromProfiles(); 00214 bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } 00215 int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const; 00216 bool IsEditAlreadyLoaded( Steps* pSteps ) const; 00217 00218 // An array of keysound file names (e.g. "beep.wav"). 00219 // The index in this array corresponds to the index in TapNote. If you 00220 // change the index in here, you must change all NoteData too. 00221 // Any note that doesn't have a value in the range of this array 00222 // means "this note doens't have a keysound". 00223 vector<CString> m_vsKeysoundFile; 00224 00225 private: 00226 void AdjustDuplicateSteps(); // part of TidyUpData 00227 void DeleteDuplicateSteps( vector<Steps*> &vSteps ); 00228 00229 vector<Steps*> m_vpSteps; 00230 vector<Steps*> m_vpStepsByType[NUM_STEPS_TYPES]; 00231 }; 00232 00233 #endif 00234 00235 /* 00236 * (c) 2001-2004 Chris Danford, Glenn Maynard 00237 * All rights reserved. 00238 * 00239 * Permission is hereby granted, free of charge, to any person obtaining a 00240 * copy of this software and associated documentation files (the 00241 * "Software"), to deal in the Software without restriction, including 00242 * without limitation the rights to use, copy, modify, merge, publish, 00243 * distribute, and/or sell copies of the Software, and to permit persons to 00244 * whom the Software is furnished to do so, provided that the above 00245 * copyright notice(s) and this permission notice appear in all copies of 00246 * the Software and that both the above copyright notice(s) and this 00247 * permission notice appear in supporting documentation. 00248 * 00249 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00250 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00251 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00252 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00253 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00254 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00255 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00256 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00257 * PERFORMANCE OF THIS SOFTWARE. 00258 */

Generated on Thu Jan 27 20:57:33 2005 for StepMania by doxygen 1.3.7