Files
itgmania212121/stepmania/src/SongManager.h
T

141 lines
4.5 KiB
C++
Raw Normal View History

#ifndef SONGMANAGER_H
#define SONGMANAGER_H
2002-02-28 19:40:40 +00:00
/*
-----------------------------------------------------------------------------
Class: SongManager
2003-08-03 00:13:55 +00:00
Desc: Holder for all Songs and Steps. Also keeps track of the current
Song and Steps, and loads/saves statistics.
2002-02-28 19:40:40 +00:00
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-02-28 19:40:40 +00:00
Chris Danford
-----------------------------------------------------------------------------
*/
2002-11-17 09:13:35 +00:00
class LoadingWindow;
class Song;
class StyleDef;
2003-07-17 20:11:24 +00:00
class Course;
2003-08-03 00:13:55 +00:00
class Steps;
2002-11-17 09:13:35 +00:00
struct PlayerOptions;
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"
2002-02-28 19:40:40 +00:00
class SongManager
{
public:
2002-11-17 09:13:35 +00:00
SongManager( LoadingWindow *ld );
2002-02-28 19:40:40 +00:00
~SongManager();
2002-11-17 09:13:35 +00:00
void InitSongArrayFromDisk( LoadingWindow *ld );
2002-06-14 22:25:22 +00:00
void FreeSongArray();
void ReloadSongArray();
2002-03-06 08:25:09 +00:00
CString GetGroupBannerPath( CString sGroupName );
2002-04-01 02:04:43 +00:00
void GetGroupNames( CStringArray &AddTo );
bool DoesGroupExist( CString sGroupName );
RageColor GetGroupColor( const CString &sGroupName );
2002-12-17 05:22:32 +00:00
RageColor GetSongColor( const Song* pSong );
RageColor GetDifficultyColor( Difficulty dc );
2002-04-16 17:31:00 +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
//
// Courses for Nonstop, Oni, and Endless
//
2003-01-22 05:29:27 +00:00
vector<Course*> m_pCourses;
2002-06-14 22:25:22 +00:00
void InitCoursesFromDisk();
void InitAutogenCourses();
2003-01-22 05:29:27 +00:00
void FreeCourses();
2003-01-27 23:10:44 +00:00
void CleanData();
2002-06-14 22:25:22 +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; }
2003-07-21 21:45:59 +00:00
const vector<Song*> &GetBestSongs() const { return m_pBestSongs; }
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
Song *FindSong( CString sPath );
Course *FindCourse( CString sName );
2003-02-05 18:34:27 +00:00
int GetNumSongs() const;
int GetNumGroups() const;
int GetNumCourses() const;
2003-01-22 05:29:27 +00:00
Song* GetRandomSong();
2003-01-22 05:29:27 +00:00
2003-07-20 00:30:24 +00:00
void GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen );
void GetNonstopCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if life meter type is BAR.
void GetOniCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if life meter type is BATTERY.
void GetEndlessCourses( vector<Course*> &AddTo, bool bIncludeAutogen ); // add to if set to REPEAT.
2003-07-30 02:01:19 +00:00
void GetExtraStageInfo( bool bExtra2, const StyleDef *s,
2003-08-03 00:13:55 +00:00
Song*& pSongOut, Steps*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out );
2002-06-14 22:25:22 +00:00
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
//
// High scores
//
void InitMachineScoresFromDisk();
void SaveMachineScoresToDisk();
bool MemoryCardIsInserted( PlayerNumber pn );
2003-01-22 05:29:27 +00:00
bool IsUsingMemoryCard( PlayerNumber pn );
void LoadMemoryCardScores( PlayerNumber pn );
void SaveMemoryCardScores( PlayerNumber pn );
struct MachineScore
{
2003-06-18 20:08:39 +00:00
int iScore;
CString sName;
2003-01-27 02:00:38 +00:00
} m_MachineScores[NUM_NOTES_TYPES][NUM_RANKING_CATEGORIES][NUM_RANKING_LINES];
2003-06-18 20:08:39 +00:00
void AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], RankingCategory hsc[NUM_PLAYERS], int iScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record
2003-07-21 21:45:59 +00:00
void UpdateBest();
void UpdateRankingCourses();
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,
2003-08-03 00:13:55 +00:00
Song*& pSongOut, Steps*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out );
void SanityCheckGroupDir( CString sDir ) const;
2002-09-10 07:11:29 +00:00
void AddGroup( CString sDir, CString sGroupDirName );
2002-08-30 20:49:56 +00:00
void ReadNoteScoresFromFile( CString fn, int c );
void ReadCourseScoresFromFile( CString fn, int c );
void ReadCategoryRankingsFromFile( CString fn );
void ReadCourseRankingsFromFile( CString fn );
Song *FindSong( CString sGroup, CString sSong );
2003-07-22 07:47:27 +00:00
void SaveNoteScoresToFile( CString fn, int c );
void SaveCourseScoresToFile( CString fn, int c );
void SaveCategoryRankingsToFile( CString fn );
void SaveCourseRankingsToFile( CString fn );
vector<Song*> m_pSongs; // all songs that can be played
2003-07-21 21:45:59 +00:00
vector<Song*> m_pBestSongs;
2002-04-16 17:31:00 +00:00
CStringArray m_arrayGroupNames;
2002-09-07 07:24:44 +00:00
CStringArray m_GroupBannerPaths; // each song group has a banner associated with it
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