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

SongManager.h

Go to the documentation of this file.
00001 /* SongManager - Holder for all Songs and Steps. */ 00002 00003 #ifndef SONGMANAGER_H 00004 #define SONGMANAGER_H 00005 00006 class LoadingWindow; 00007 class Song; 00008 class Style; 00009 class Course; 00010 class Steps; 00011 struct PlayerOptions; 00012 00013 #include "RageTypes.h" 00014 #include "GameConstantsAndTypes.h" 00015 #include "SongOptions.h" 00016 #include "PlayerOptions.h" 00017 #include "PlayerNumber.h" 00018 #include "Difficulty.h" 00019 00020 class SongManager 00021 { 00022 public: 00023 SongManager(); 00024 ~SongManager(); 00025 00026 void InitSongsFromDisk( LoadingWindow *ld ); 00027 void FreeSongs(); 00028 void Cleanup(); 00029 00030 void Invalidate( Song *pStaleSong ); 00031 void RevertFromDisk( Song *pSong, bool bAllowNotesLoss=false ); 00032 00033 void RegenerateNonFixedCourses(); 00034 void SetPreferences(); 00035 00036 void LoadAllFromProfiles(); // song, edits 00037 void FreeAllLoadedFromProfiles(); 00038 00039 void LoadGroupSymLinks( CString sDir, CString sGroupFolder ); 00040 00041 void InitCoursesFromDisk( LoadingWindow *ld ); 00042 void InitAutogenCourses(); 00043 void FreeCourses(); 00044 00045 void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything. 00046 void Reload( LoadingWindow *ld=NULL ); // songs, courses, groups - everything. 00047 void PreloadSongImages(); 00048 00049 00050 CString GetGroupBannerPath( CString sGroupName ); 00051 void GetGroupNames( CStringArray &AddTo ); 00052 bool DoesGroupExist( CString sGroupName ); 00053 00054 RageColor GetGroupColor( const CString &sGroupName ); 00055 RageColor GetSongColor( const Song* pSong ); 00056 RageColor GetDifficultyColor( Difficulty dc ) const; 00057 00058 static CString ShortenGroupName( CString sLongGroupName ); 00059 static int GetNumStagesForSong( const Song* pSong ); // LongVer songs take 2 stages, MarathonVer take 3 00060 00061 00062 // Lookup 00063 const vector<Song*> &GetAllSongs() const { return m_pSongs; } 00064 void GetBestSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/, ProfileSlot slot=PROFILE_SLOT_MACHINE ) const; 00065 const vector<Song*> &GetBestSongs( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestSongs[slot]; } 00066 const vector<Course*> &GetBestCourses( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[slot]; } 00067 void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const; 00068 void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,GROUP_ALL_MUSIC,iMaxStages); } 00069 void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,GROUP_ALL_MUSIC,100000 /*inf*/ ); } 00070 Song *FindSong( CString sPath ); 00071 Course *FindCourse( CString sName ); 00072 int GetNumSongs() const; 00073 int GetNumGroups() const; 00074 int GetNumCourses() const; 00075 Song* GetRandomSong(); 00076 Course* GetRandomCourse(); 00077 00078 00079 void GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); 00080 void GetNonstopCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if life meter type is BAR. 00081 void GetOniCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if life meter type is BATTERY. 00082 void GetEndlessCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if set to REPEAT. 00083 00084 void GetExtraStageInfo( bool bExtra2, const Style *s, 00085 Song*& pSongOut, Steps*& pStepsOut, PlayerOptions& po_out, SongOptions& so_out ); 00086 00087 Song* GetSongFromDir( CString sDir ); 00088 Course* GetCourseFromPath( CString sPath ); // path to .crs file, or path to song group dir 00089 Course* GetCourseFromName( CString sName ); 00090 00091 00092 void UpdateBest(); // update Players Best 00093 void UpdateShuffled(); // re-shuffle songs and courses 00094 void SortSongs(); // sort m_pSongs 00095 00096 void UpdateRankingCourses(); // courses shown on the ranking screen 00097 00098 protected: 00099 void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ); 00100 void LoadDWISongDir( CString sDir ); 00101 bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, 00102 Song*& pSongOut, Steps*& pStepsOut, PlayerOptions& po_out, SongOptions& so_out ); 00103 void SanityCheckGroupDir( CString sDir ) const; 00104 void AddGroup( CString sDir, CString sGroupDirName ); 00105 00106 Song *FindSong( CString sGroup, CString sSong ); 00107 00108 vector<Song*> m_pSongs; // all songs that can be played 00109 vector<Song*> m_pBestSongs[NUM_PROFILE_SLOTS]; 00110 vector<Song*> m_pShuffledSongs; // used by GetRandomSong 00111 CStringArray m_sGroupNames; 00112 CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it 00113 vector<Course*> m_pCourses; 00114 vector<Course*> m_pBestCourses[NUM_PROFILE_SLOTS]; 00115 vector<Course*> m_pShuffledCourses; // used by GetRandomCourse 00116 }; 00117 00118 00119 extern SongManager* SONGMAN; // global and accessable from anywhere in our program 00120 00121 #endif 00122 00123 /* 00124 * (c) 2001-2004 Chris Danford, Glenn Maynard 00125 * All rights reserved. 00126 * 00127 * Permission is hereby granted, free of charge, to any person obtaining a 00128 * copy of this software and associated documentation files (the 00129 * "Software"), to deal in the Software without restriction, including 00130 * without limitation the rights to use, copy, modify, merge, publish, 00131 * distribute, and/or sell copies of the Software, and to permit persons to 00132 * whom the Software is furnished to do so, provided that the above 00133 * copyright notice(s) and this permission notice appear in all copies of 00134 * the Software and that both the above copyright notice(s) and this 00135 * permission notice appear in supporting documentation. 00136 * 00137 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00138 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00139 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00140 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00141 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00142 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00143 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00144 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00145 * PERFORMANCE OF THIS SOFTWARE. 00146 */

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