Files
itgmania212121/stepmania/src/SongManager.h
T

180 lines
6.9 KiB
C++
Raw Normal View History

2004-06-08 01:24:17 +00:00
/* SongManager - Holder for all Songs and Steps. */
#ifndef SONGMANAGER_H
#define SONGMANAGER_H
2002-02-28 19:40:40 +00:00
2002-11-17 09:13:35 +00:00
class LoadingWindow;
class Song;
2004-06-28 07:26:00 +00:00
class Style;
2003-08-03 00:13:55 +00:00
class Steps;
class PlayerOptions;
2005-02-21 17:26:43 +00:00
struct lua_State;
2002-02-28 19:40:40 +00:00
2003-07-17 20:11:24 +00:00
#include "RageTypes.h"
#include "GameConstantsAndTypes.h"
#include "SongOptions.h"
#include "PlayerOptions.h"
#include "PlayerNumber.h"
2005-01-22 19:36:39 +00:00
#include "Difficulty.h"
#include "Course.h"
2005-05-22 15:05:15 +00:00
#include "ThemeMetric.h"
2005-06-30 22:04:10 +00:00
#include "RageTexturePreloader.h"
2003-07-17 20:11:24 +00:00
2005-08-05 10:07:49 +00:00
const int MAX_EDIT_STEPS_PER_PROFILE = 200;
const int MAX_EDIT_COURSES_PER_PROFILE = 20;
2002-02-28 19:40:40 +00:00
class SongManager
{
public:
2004-05-25 05:52:57 +00:00
SongManager();
2002-02-28 19:40:40 +00:00
~SongManager();
void InitSongsFromDisk( LoadingWindow *ld );
void FreeSongs();
2003-12-21 02:54:23 +00:00
void Cleanup();
2004-07-24 06:40:51 +00:00
void Invalidate( Song *pStaleSong );
2004-08-11 08:23:14 +00:00
void RevertFromDisk( Song *pSong, bool bAllowNotesLoss=false );
2004-07-24 06:40:51 +00:00
void RegenerateNonFixedCourses();
2004-06-05 08:08:42 +00:00
void SetPreferences();
2003-12-21 02:54:23 +00:00
2005-04-28 06:17:17 +00:00
void LoadAllFromProfileDir( const CString &sProfileDir, ProfileSlot slot );
2005-03-08 01:46:57 +00:00
int GetNumStepsLoadedFromProfile();
2005-12-01 03:20:25 +00:00
void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_INVALID );
2004-02-08 01:05:53 +00:00
void LoadGroupSymLinks( CString sDir, CString sGroupFolder );
void InitCoursesFromDisk( LoadingWindow *ld );
void InitAutogenCourses();
void FreeCourses();
2005-07-29 02:23:02 +00:00
void AddCourse( Course *pCourse ); // transfers ownership of pCourse
void DeleteCourse( Course *pCourse ); // transfers ownership of pCourse
2003-08-06 08:06:27 +00:00
2005-08-05 10:07:49 +00:00
2004-05-25 05:52:57 +00:00
void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything.
2004-02-21 01:52:00 +00:00
void Reload( LoadingWindow *ld=NULL ); // songs, courses, groups - everything.
2003-11-25 22:56:48 +00:00
void PreloadSongImages();
2002-03-06 08:25:09 +00:00
2005-06-23 08:05:09 +00:00
CString GetSongGroupBannerPath( CString sSongGroup );
2005-12-09 21:36:22 +00:00
void GetSongGroupNames( vector<CString> &AddTo );
2005-06-23 08:05:09 +00:00
bool DoesSongGroupExist( CString sSongGroup );
2005-06-03 01:57:10 +00:00
RageColor GetSongGroupColor( const CString &sSongGroupName );
2002-12-17 05:22:32 +00:00
RageColor GetSongColor( const Song* pSong );
2005-06-23 08:05:09 +00:00
2005-07-31 05:41:32 +00:00
CString GetCourseGroupBannerPath( const CString &sCourseGroup );
2005-12-09 21:36:22 +00:00
void GetCourseGroupNames( vector<CString> &AddTo );
2005-07-31 05:41:32 +00:00
bool DoesCourseGroupExist( const CString &sCourseGroup );
2005-06-03 01:57:10 +00:00
RageColor GetCourseGroupColor( const CString &sCourseGroupName );
RageColor GetCourseColor( const Course* pCourse );
2004-03-25 06:21:58 +00:00
static CString ShortenGroupName( CString sLongGroupName );
static int GetNumStagesForSong( const Song* pSong ); // LongVer songs take 2 stages, MarathonVer take 3
2002-04-01 02:04:43 +00:00
2002-03-06 08:25:09 +00:00
2003-01-22 05:29:27 +00:00
// Lookup
2003-02-05 18:34:27 +00:00
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
2005-12-01 03:20:25 +00:00
void GetBestSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = INT_MAX, ProfileSlot slot=ProfileSlot_Machine ) const;
const vector<Song*> &GetBestSongs( ProfileSlot slot=ProfileSlot_Machine ) const { return m_pBestSongs[slot]; }
const vector<Course*> &GetBestCourses( CourseType ct, ProfileSlot slot=ProfileSlot_Machine ) const { return m_pBestCourses[slot][ct]; }
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = INT_MAX ) const;
2005-06-24 06:06:16 +00:00
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,GROUP_ALL,iMaxStages); }
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,GROUP_ALL,INT_MAX); }
Song *FindSong( CString sPath );
Course *FindCourse( CString sName );
2003-02-05 18:34:27 +00:00
int GetNumSongs() const;
2005-06-23 08:05:09 +00:00
int GetNumSongGroups() const;
int GetNumCourses() const;
2005-06-23 08:05:09 +00:00
int GetNumCourseGroups() const;
2005-08-05 10:07:49 +00:00
int GetNumEditCourses( ProfileSlot slot ) const;
2003-01-22 05:29:27 +00:00
Song* GetRandomSong();
2004-02-01 23:06:07 +00:00
Course* GetRandomCourse();
2005-11-30 22:42:28 +00:00
void GetStepsLoadedFromProfile( vector<Steps*> &AddTo, ProfileSlot slot );
Song *GetSongFromSteps( Steps *pSteps );
void DeleteSteps( Steps *pSteps ); // transfers ownership of pSteps
2003-01-22 05:29:27 +00:00
2003-07-20 00:30:24 +00:00
void GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen );
void GetCourses( CourseType ct, vector<Course*> &AddTo, bool bIncludeAutogen );
2005-06-23 22:43:48 +00:00
void GetCoursesInGroup( vector<Course*> &AddTo, const CString &sCourseGroup, bool bIncludeAutogen );
2004-06-28 07:26:00 +00:00
void GetExtraStageInfo( bool bExtra2, const Style *s,
2005-09-03 03:52:22 +00:00
Song*& pSongOut, Steps*& pStepsOut, PlayerOptions *pPlayerOptionsOut, SongOptions *pSongOptionsOut );
2002-12-02 05:25:44 +00:00
Song* GetSongFromDir( CString sDir );
Course* GetCourseFromPath( CString sPath ); // path to .crs file, or path to song group dir
Course* GetCourseFromName( CString sName );
2003-01-22 05:29:27 +00:00
2004-02-27 21:28:15 +00:00
void UpdateBest(); // update Players Best
void UpdateShuffled(); // re-shuffle songs and courses
void SortSongs(); // sort m_pSongs
2003-01-22 05:29:27 +00:00
void UpdateRankingCourses(); // courses shown on the ranking screen
2005-07-31 05:41:32 +00:00
void RefreshCourseGroupInfo();
2003-09-08 07:21:41 +00:00
2005-02-21 17:26:43 +00:00
// Lua
void PushSelf( lua_State *L );
2002-02-28 19:40:40 +00:00
protected:
2002-11-17 09:13:35 +00:00
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
2002-03-06 08:25:09 +00:00
void LoadDWISongDir( CString sDir );
2002-08-30 20:49:56 +00:00
bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup,
2005-09-03 03:52:22 +00:00
Song*& pSongOut, Steps*& pStepsOut, PlayerOptions *pPlayerOptionsOut, SongOptions *pSongOptionsOut );
void SanityCheckGroupDir( CString sDir ) const;
2002-09-10 07:11:29 +00:00
void AddGroup( CString sDir, CString sGroupDirName );
2005-04-25 02:27:17 +00:00
int GetNumEditsLoadedFromProfile( ProfileSlot slot ) const;
2002-08-30 20:49:56 +00:00
Song *FindSong( CString sGroup, CString sSong );
vector<Song*> m_pSongs; // all songs that can be played
2005-12-01 03:20:25 +00:00
vector<Song*> m_pBestSongs[NUM_ProfileSlot];
2004-02-01 23:06:07 +00:00
vector<Song*> m_pShuffledSongs; // used by GetRandomSong
2005-12-09 21:36:22 +00:00
vector<CString> m_sSongGroupNames;
vector<CString> m_sSongGroupBannerPaths; // each song group may have a banner associated with it
2005-06-03 01:57:10 +00:00
2003-11-17 03:20:39 +00:00
vector<Course*> m_pCourses;
2005-12-01 03:20:25 +00:00
vector<Course*> m_pBestCourses[NUM_ProfileSlot][NUM_CourseType];
2004-02-01 23:06:07 +00:00
vector<Course*> m_pShuffledCourses; // used by GetRandomCourse
2005-07-31 05:41:32 +00:00
struct CourseGroupInfo
{
CString m_sBannerPath;
};
map<CString,CourseGroupInfo> m_mapCourseGroupToInfo;
2005-05-22 15:05:15 +00:00
2005-06-30 22:04:10 +00:00
RageTexturePreloader m_TexturePreload;
2005-05-22 15:05:15 +00:00
2005-06-03 01:57:10 +00:00
ThemeMetric<int> NUM_SONG_GROUP_COLORS;
ThemeMetric1D<RageColor> SONG_GROUP_COLOR;
ThemeMetric<int> NUM_COURSE_GROUP_COLORS;
ThemeMetric1D<RageColor> COURSE_GROUP_COLOR;
2002-02-28 19:40:40 +00:00
};
2002-05-19 01:59:48 +00:00
extern SongManager* SONGMAN; // global and accessable from anywhere in our program
#endif
2004-06-08 01:24:17 +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.
*/