Files
itgmania212121/stepmania/src/Course.h
T

249 lines
7.6 KiB
C++
Raw Normal View History

2004-05-31 22:42:12 +00:00
/* Course - A queue of songs and notes. */
#ifndef COURSE_H
#define COURSE_H
2002-06-14 22:25:22 +00:00
#include "GameConstantsAndTypes.h"
2003-10-25 22:55:11 +00:00
#include "Attack.h"
#include "EnumHelper.h"
2006-08-19 23:35:31 +00:00
#include "Trail.h"
2005-10-24 07:37:38 +00:00
#include "RageTypes.h"
#include "RageUtil_CachedObject.h"
#include "SongUtil.h"
#include "StepsUtil.h"
2006-08-19 23:35:31 +00:00
#include <map>
#include <set>
2002-12-17 05:41:04 +00:00
2005-02-21 17:20:11 +00:00
struct lua_State;
2007-04-10 23:59:14 +00:00
class Style;
class Game;
2002-06-14 22:25:22 +00:00
2005-08-04 21:13:29 +00:00
const int MAX_EDIT_COURSE_TITLE_LENGTH = 12;
2005-07-29 02:23:02 +00:00
enum CourseType
{
COURSE_TYPE_NONSTOP, // if life meter type is BAR
2006-08-18 02:35:58 +00:00
COURSE_TYPE_ONI, // if life meter type is BATTERY
COURSE_TYPE_ENDLESS, // if set to REPEAT
2005-04-21 04:27:13 +00:00
COURSE_TYPE_SURVIVAL, // if life meter type is TIME
2006-06-12 09:14:20 +00:00
NUM_CourseType,
2006-10-07 04:25:28 +00:00
CourseType_Invalid
};
2006-10-07 08:56:58 +00:00
#define FOREACH_CourseType( i ) FOREACH_ENUM( CourseType, i )
2006-01-22 01:00:06 +00:00
const RString& CourseTypeToString( CourseType i );
const RString& CourseTypeToLocalizedString( CourseType i );
2006-09-26 01:54:36 +00:00
LuaDeclareType( CourseType );
inline PlayMode CourseTypeToPlayMode( CourseType ct ) { return (PlayMode)(PLAY_MODE_NONSTOP+ct); }
inline CourseType PlayModeToCourseType( PlayMode pm ) { return (CourseType)(pm-PLAY_MODE_NONSTOP); }
2005-06-26 21:31:07 +00:00
2005-06-28 08:11:30 +00:00
enum SongSort
{
SongSort_Randomize,
SongSort_MostPlays,
SongSort_FewestPlays,
SongSort_TopGrades,
SongSort_LowestGrades,
2005-07-30 04:50:17 +00:00
NUM_SongSort,
2005-06-28 08:11:30 +00:00
};
2006-10-07 08:56:58 +00:00
#define FOREACH_SongSort( i ) FOREACH_ENUM( SongSort, i )
2006-01-22 01:00:06 +00:00
const RString& SongSortToString( SongSort ss );
const RString& SongSortToLocalizedString( SongSort ss );
2005-06-28 08:11:30 +00:00
2003-08-11 02:18:13 +00:00
class CourseEntry
{
public:
bool bSecret; // show "??????" instead of an exact song
// filter criteria, applied from top to bottom
2007-08-12 22:43:45 +00:00
SongID songID; // don't filter if unset
SongCriteria songCriteria;
StepsCriteria stepsCriteria;
2006-02-21 11:01:29 +00:00
bool bNoDifficult; // if true, CourseDifficulty doesn't affect this entry
2005-06-28 08:11:30 +00:00
2006-02-21 11:01:29 +00:00
SongSort songSort; // sort by this after filtering
int iChooseIndex; //
2006-01-22 01:00:06 +00:00
RString sModifiers; // set player and song options using these
2006-02-21 11:01:29 +00:00
AttackArray attacks; // timed sModifiers
2005-04-21 04:27:13 +00:00
float fGainSeconds; // time gained back at the beginning of the song. LifeMeterTime only.
int iGainLives; // lives gained back at the beginning of the next song
2003-08-10 23:48:10 +00:00
CourseEntry()
{
2005-03-10 22:54:55 +00:00
bSecret = false;
bNoDifficult = false;
2005-06-28 08:11:30 +00:00
songSort = SongSort_Randomize;
iChooseIndex = 0;
sModifiers = "";
2005-04-21 04:27:13 +00:00
fGainSeconds = 0;
iGainLives = -1;
2003-08-10 23:48:10 +00:00
}
2007-08-12 22:43:45 +00:00
bool IsFixedSong() const { return songID.IsValid(); }
2005-07-30 04:50:17 +00:00
2006-01-22 01:00:06 +00:00
RString GetTextDescription() const;
2005-07-30 19:34:23 +00:00
int GetNumModChanges() const;
2005-08-03 03:12:09 +00:00
// Lua
void PushSelf( lua_State *L );
2003-08-10 23:48:10 +00:00
};
2005-07-30 23:40:26 +00:00
const int MAX_ENTRIES_PER_COURSE = 50;
2002-06-14 22:25:22 +00:00
class Course
{
public:
Course();
2002-06-14 22:25:22 +00:00
2007-05-25 22:26:43 +00:00
RString GetBannerPath() const;
bool HasBanner() const;
2004-07-11 10:02:38 +00:00
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
* Otherwise, they return the main titles. */
2006-01-22 01:00:06 +00:00
RString GetDisplayMainTitle() const;
RString GetDisplaySubTitle() const;
2004-07-11 10:02:38 +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; }
2004-07-11 10:02:38 +00:00
/* "title subtitle" */
2006-01-22 01:00:06 +00:00
RString GetDisplayFullTitle() const;
RString GetTranslitFullTitle() const;
2003-07-27 19:14:05 +00:00
2003-08-03 00:13:55 +00:00
// Dereferences course_entries and returns only the playable Songs and Steps
Trail* GetTrail( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const;
Trail* GetTrailForceRegenCache( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const;
2004-06-03 08:22:02 +00:00
void GetTrails( vector<Trail*> &AddTo, StepsType st ) const;
2005-03-22 10:33:47 +00:00
void GetAllTrails( vector<Trail*> &AddTo ) const;
int GetMeter( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const;
2004-03-13 23:11:57 +00:00
bool HasMods() const;
2007-06-12 18:46:15 +00:00
bool HasTimedMods() const;
bool AllSongsAreFixed() const;
2007-04-29 19:54:56 +00:00
const Style *GetCourseStyle( const Game *pGame, int iNumPlayers ) const;
2003-07-21 21:54:07 +00:00
2005-06-28 08:11:30 +00:00
int GetEstimatedNumStages() const { return m_vEntries.size(); }
bool IsPlayableIn( StepsType st ) const;
bool CourseHasBestOrWorst() const;
RageColor GetColor() const;
bool GetTotalSeconds( StepsType st, float& fSecondsOut ) const;
2002-07-02 17:34:20 +00:00
2003-07-27 19:14:05 +00:00
bool IsNonstop() const { return GetPlayMode() == PLAY_MODE_NONSTOP; }
bool IsOni() const { return GetPlayMode() == PLAY_MODE_ONI; }
bool IsEndless() const { return GetPlayMode() == PLAY_MODE_ENDLESS; }
CourseType GetCourseType() const;
2005-08-01 05:18:24 +00:00
void SetCourseType( CourseType ct );
2003-07-20 01:54:17 +00:00
PlayMode GetPlayMode() const;
2002-06-14 22:25:22 +00:00
2005-03-27 10:31:27 +00:00
bool ShowInDemonstrationAndRanking() const;
2004-07-24 06:40:51 +00:00
void RevertFromDisk();
void Init();
2002-06-14 22:25:22 +00:00
bool IsRanking() const;
void UpdateCourseStats( StepsType st );
2004-07-24 06:40:51 +00:00
/* Call to regenerate Trails with random entries */
void RegenerateNonFixedTrails() const;
2004-07-24 06:40:51 +00:00
/* Call when a Song or its Steps are deleted/changed. */
2006-11-13 18:28:29 +00:00
void Invalidate( const Song *pStaleSong );
2003-12-21 02:54:23 +00:00
2004-08-30 22:15:57 +00:00
void GetAllCachedTrails( vector<Trail *> &out );
2006-01-22 01:00:06 +00:00
RString GetCacheFilePath() const;
2004-08-30 22:15:57 +00:00
const CourseEntry *FindFixedSong( const Song *pSong ) const;
2005-07-29 02:23:02 +00:00
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
2006-05-01 21:49:59 +00:00
bool Matches(RString sGroup, RString sCourse) const;
2005-02-21 17:20:11 +00:00
// Lua
void PushSelf( lua_State *L );
void CalculateRadarValues();
bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
2003-12-21 02:54:23 +00:00
2006-10-07 03:32:16 +00:00
bool IsAnEdit() const { return m_LoadedFromProfile != ProfileSlot_Invalid; }
bool m_bIsAutogen; // was this created by AutoGen?
RString m_sPath;
RString m_sMainTitle, m_sMainTitleTranslit;
RString m_sSubTitle, m_sSubTitleTranslit;
RString m_sBannerPath;
RString m_sCDTitlePath;
RString m_sGroupName;
bool m_bRepeat; // repeat after last song? "Endless"
bool m_bShuffle; // play the songs in a random order
int m_iLives; // -1 means use bar life meter
int m_iCustomMeter[NUM_Difficulty]; // -1 = no meter specified
bool m_bSortByMeter;
bool m_bIncomplete;
vector<CourseEntry> m_vEntries;
// sorting values
int m_SortOrder_TotalDifficulty;
int m_SortOrder_Ranking;
2006-10-07 03:32:16 +00:00
ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if wasn't loaded from a profile
2005-07-29 02:23:02 +00:00
typedef pair<StepsType,Difficulty> CacheEntry;
struct CacheData
{
Trail trail;
bool null;
};
typedef map<CacheEntry, CacheData> TrailCache_t;
mutable TrailCache_t m_TrailCache;
mutable int m_iTrailCacheSeed;
2005-03-07 22:30:39 +00:00
typedef map<CacheEntry, RadarValues> RadarCache_t;
RadarCache_t m_RadarCache;
2007-04-10 23:59:14 +00:00
/* Preferred styles: */
set<RString> m_setStyles;
CachedObject<Course> m_CachedObject;
2002-06-14 22:25:22 +00:00
};
2002-07-27 19:29:51 +00:00
#endif
2004-05-31 22:42:12 +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.
*/