Files
itgmania212121/stepmania/src/Course.h
T

201 lines
6.3 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 "PlayerNumber.h"
2002-06-14 22:25:22 +00:00
#include "GameConstantsAndTypes.h"
2003-10-25 22:55:11 +00:00
#include "Attack.h"
2003-12-21 02:54:23 +00:00
#include <map>
#include "Trail.h"
2002-12-17 05:41:04 +00:00
2002-07-28 20:28:37 +00:00
struct PlayerOptions;
struct SongOptions;
2002-06-14 22:25:22 +00:00
class Song;
2003-08-03 00:13:55 +00:00
class Steps;
2004-02-10 09:42:01 +00:00
class Profile;
2005-02-21 17:20:11 +00:00
struct lua_State;
2002-06-14 22:25:22 +00:00
2003-08-10 23:48:10 +00:00
enum CourseEntryType
2002-06-14 22:25:22 +00:00
{
2003-08-10 23:48:10 +00:00
COURSE_ENTRY_FIXED,
COURSE_ENTRY_RANDOM,
COURSE_ENTRY_RANDOM_WITHIN_GROUP,
COURSE_ENTRY_BEST,
COURSE_ENTRY_WORST,
NUM_COURSE_ENTRY_TYPES // leave this at the end
};
inline CString CourseEntryTypeToString( CourseEntryType cet )
{
switch( cet )
{
case COURSE_ENTRY_FIXED: return "fixed";
case COURSE_ENTRY_RANDOM: return "random";
case COURSE_ENTRY_RANDOM_WITHIN_GROUP: return "random_within_group";
case COURSE_ENTRY_BEST: return "best";
case COURSE_ENTRY_WORST: return "worst";
default: ASSERT(0); return "";
}
}
2003-08-11 02:18:13 +00:00
class CourseEntry
{
public:
2003-08-10 23:48:10 +00:00
CourseEntryType type;
bool mystery; // show "??????"
Song* pSong; // used in type=fixed
CString group_name; // used in type=random_within_group
Difficulty difficulty; // = DIFFICULTY_INVALID if no difficulty specified
2004-02-10 22:52:43 +00:00
bool no_difficult; // if true, difficult course setting doesn't affect this entry
2003-08-10 23:48:10 +00:00
int low_meter; // = -1 if no meter range specified
int high_meter; // = -1 if no meter range specified
int players_index; // ignored if type isn't 'best' or 'worst'
CString modifiers; // set player and song options using these
2003-10-26 03:02:30 +00:00
AttackArray attacks; // set timed modifiers
2002-12-17 05:41:04 +00:00
2003-08-10 23:48:10 +00:00
CourseEntry()
{
2003-08-11 06:09:57 +00:00
type = (CourseEntryType)0;
2003-08-12 06:51:03 +00:00
mystery = false;
pSong = NULL;
group_name = "";
2003-08-10 23:48:10 +00:00
difficulty = DIFFICULTY_INVALID;
2004-02-10 22:52:43 +00:00
no_difficult = false;
2003-08-10 23:48:10 +00:00
low_meter = -1;
high_meter = -1;
2003-08-12 06:51:03 +00:00
players_index = 0;
modifiers = "";
2003-08-10 23:48:10 +00:00
}
};
class Course
{
2002-06-14 22:25:22 +00:00
public:
Course();
2002-06-14 22:25:22 +00:00
bool m_bIsAutogen; // was this created by AutoGen?
CString m_sPath;
2004-07-11 10:02:38 +00:00
private:
CString m_sMainTitle, m_sMainTitleTranslit;
CString m_sSubTitle, m_sSubTitleTranslit;
2004-07-11 10:02:38 +00:00
public:
bool HasBanner() const;
2002-06-14 22:25:22 +00:00
CString m_sBannerPath;
CString m_sCDTitlePath;
2002-12-17 05:16:33 +00:00
bool m_bRepeat; // repeat after last song? "Endless"
2002-07-29 03:06:55 +00:00
bool m_bRandomize; // play the songs in a random order
2002-07-27 19:29:51 +00:00
int m_iLives; // -1 means use bar life meter
int m_iCustomMeter[NUM_DIFFICULTIES]; // -1 = no meter specified
bool m_bSortByMeter;
2003-08-10 23:48:10 +00:00
vector<CourseEntry> m_entries;
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. */
CString GetDisplayMainTitle() const;
CString GetDisplaySubTitle() const;
/* Returns the transliterated titles, if any; otherwise returns the main titles. */
CString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; }
CString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; }
/* "title subtitle" */
CString GetFullDisplayTitle() const;
CString GetFullTranslitTitle() 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;
2004-06-03 08:22:02 +00:00
void GetTrails( vector<Trail*> &AddTo, StepsType st ) const;
float GetMeter( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const;
2004-03-13 23:11:57 +00:00
bool HasMods() const;
bool AllSongsAreFixed() const;
2003-07-21 21:54:07 +00:00
int GetEstimatedNumStages() const { return m_entries.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; }
2003-07-20 01:54:17 +00:00
PlayMode GetPlayMode() const;
2002-07-23 01:41:40 +00:00
bool IsFixed() const;
bool ShowInDemonstrationAndRanking() const { return true; }
2003-02-05 19:16:00 +00:00
void LoadFromCRSFile( CString sPath );
2004-07-24 06:40:51 +00:00
void RevertFromDisk();
void Init();
2003-04-11 00:12:22 +00:00
void Save();
void AutogenEndlessFromGroup( CString sGroupName, Difficulty dc );
void AutogenNonstopFromGroup( CString sGroupName, Difficulty dc );
2004-05-25 04:08:21 +00:00
void AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector<Song*> aSongs, Difficulty dc );
2002-06-14 22:25:22 +00:00
// sorting values
int m_SortOrder_TotalDifficulty;
int m_SortOrder_Ranking;
bool IsRanking() const;
void UpdateCourseStats( StepsType st );
2004-07-24 06:40:51 +00:00
/* Call to regenerate Trails with random entries */
void RegenerateNonFixedTrails();
/* Call when a Song or its Steps are deleted/changed. */
void Invalidate( Song *pStaleSong );
2003-12-21 02:54:23 +00:00
2004-08-30 22:15:57 +00:00
void GetAllCachedTrails( vector<Trail *> &out );
const CourseEntry *FindFixedSong( const Song *pSong ) const;
2005-02-21 17:20:11 +00:00
// Lua
void PushSelf( lua_State *L );
private:
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
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;
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.
*/