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

Course.h

Go to the documentation of this file.
00001 /* Course - A queue of songs and notes. */ 00002 00003 #ifndef COURSE_H 00004 #define COURSE_H 00005 00006 #include "PlayerNumber.h" 00007 #include "GameConstantsAndTypes.h" 00008 #include "Attack.h" 00009 #include <map> 00010 #include "Trail.h" 00011 00012 struct PlayerOptions; 00013 struct SongOptions; 00014 class Song; 00015 class Steps; 00016 class Profile; 00017 00018 enum CourseEntryType 00019 { 00020 COURSE_ENTRY_FIXED, 00021 COURSE_ENTRY_RANDOM, 00022 COURSE_ENTRY_RANDOM_WITHIN_GROUP, 00023 COURSE_ENTRY_BEST, 00024 COURSE_ENTRY_WORST, 00025 NUM_COURSE_ENTRY_TYPES // leave this at the end 00026 }; 00027 00028 inline CString CourseEntryTypeToString( CourseEntryType cet ) 00029 { 00030 switch( cet ) 00031 { 00032 case COURSE_ENTRY_FIXED: return "fixed"; 00033 case COURSE_ENTRY_RANDOM: return "random"; 00034 case COURSE_ENTRY_RANDOM_WITHIN_GROUP: return "random_within_group"; 00035 case COURSE_ENTRY_BEST: return "best"; 00036 case COURSE_ENTRY_WORST: return "worst"; 00037 default: ASSERT(0); return ""; 00038 } 00039 } 00040 00041 class CourseEntry 00042 { 00043 public: 00044 CourseEntryType type; 00045 bool mystery; // show "??????" 00046 Song* pSong; // used in type=fixed 00047 CString group_name; // used in type=random_within_group 00048 Difficulty difficulty; // = DIFFICULTY_INVALID if no difficulty specified 00049 bool no_difficult; // if true, difficult course setting doesn't affect this entry 00050 int low_meter; // = -1 if no meter range specified 00051 int high_meter; // = -1 if no meter range specified 00052 int players_index; // ignored if type isn't 'best' or 'worst' 00053 CString modifiers; // set player and song options using these 00054 AttackArray attacks; // set timed modifiers 00055 00056 CourseEntry() 00057 { 00058 type = (CourseEntryType)0; 00059 mystery = false; 00060 pSong = NULL; 00061 group_name = ""; 00062 difficulty = DIFFICULTY_INVALID; 00063 no_difficult = false; 00064 low_meter = -1; 00065 high_meter = -1; 00066 players_index = 0; 00067 modifiers = ""; 00068 } 00069 }; 00070 00071 class Course 00072 { 00073 public: 00074 Course(); 00075 00076 bool m_bIsAutogen; // was this created by AutoGen? 00077 CString m_sPath; 00078 private: 00079 CString m_sMainTitle, m_sMainTitleTranslit; 00080 CString m_sSubTitle, m_sSubTitleTranslit; 00081 00082 public: 00083 bool HasBanner() const; 00084 00085 CString m_sBannerPath; 00086 CString m_sCDTitlePath; 00087 00088 bool m_bRepeat; // repeat after last song? "Endless" 00089 bool m_bRandomize; // play the songs in a random order 00090 int m_iLives; // -1 means use bar life meter 00091 int m_iCustomMeter[NUM_DIFFICULTIES]; // -1 = no meter specified 00092 bool m_bSortByMeter; 00093 00094 vector<CourseEntry> m_entries; 00095 00096 /* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below. 00097 * Otherwise, they return the main titles. */ 00098 CString GetDisplayMainTitle() const; 00099 CString GetDisplaySubTitle() const; 00100 00101 /* Returns the transliterated titles, if any; otherwise returns the main titles. */ 00102 CString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; } 00103 CString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; } 00104 00105 /* "title subtitle" */ 00106 CString GetFullDisplayTitle() const; 00107 CString GetFullTranslitTitle() const; 00108 00109 // Dereferences course_entries and returns only the playable Songs and Steps 00110 Trail* GetTrail( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const; 00111 void GetTrails( vector<Trail*> &AddTo, StepsType st ) const; 00112 float GetMeter( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const; 00113 bool HasMods() const; 00114 bool AllSongsAreFixed() const; 00115 00116 int GetEstimatedNumStages() const { return m_entries.size(); } 00117 bool IsPlayableIn( StepsType st ) const; 00118 bool CourseHasBestOrWorst() const; 00119 RageColor GetColor() const; 00120 bool GetTotalSeconds( StepsType st, float& fSecondsOut ) const; 00121 00122 bool IsNonstop() const { return GetPlayMode() == PLAY_MODE_NONSTOP; } 00123 bool IsOni() const { return GetPlayMode() == PLAY_MODE_ONI; } 00124 bool IsEndless() const { return GetPlayMode() == PLAY_MODE_ENDLESS; } 00125 PlayMode GetPlayMode() const; 00126 00127 bool IsFixed() const; 00128 00129 bool ShowInDemonstrationAndRanking() const { return true; } 00130 00131 void LoadFromCRSFile( CString sPath ); 00132 void RevertFromDisk(); 00133 void Init(); 00134 void Save(); 00135 void AutogenEndlessFromGroup( CString sGroupName, Difficulty dc ); 00136 void AutogenNonstopFromGroup( CString sGroupName, Difficulty dc ); 00137 void AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector<Song*> aSongs, Difficulty dc ); 00138 00139 // sorting values 00140 int m_SortOrder_TotalDifficulty; 00141 int m_SortOrder_Ranking; 00142 bool IsRanking() const; 00143 00144 void UpdateCourseStats( StepsType st ); 00145 00146 /* Call to regenerate Trails with random entries */ 00147 void RegenerateNonFixedTrails(); 00148 00149 /* Call when a Song or its Steps are deleted/changed. */ 00150 void Invalidate( Song *pStaleSong ); 00151 00152 void GetAllCachedTrails( vector<Trail *> &out ); 00153 00154 const CourseEntry *FindFixedSong( const Song *pSong ) const; 00155 00156 private: 00157 bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; 00158 bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; 00159 00160 typedef pair<StepsType,Difficulty> CacheEntry; 00161 struct CacheData 00162 { 00163 Trail trail; 00164 bool null; 00165 }; 00166 typedef map<CacheEntry, CacheData> TrailCache_t; 00167 mutable TrailCache_t m_TrailCache; 00168 mutable int m_iTrailCacheSeed; 00169 }; 00170 00171 #endif 00172 00173 /* 00174 * (c) 2001-2004 Chris Danford, Glenn Maynard 00175 * All rights reserved. 00176 * 00177 * Permission is hereby granted, free of charge, to any person obtaining a 00178 * copy of this software and associated documentation files (the 00179 * "Software"), to deal in the Software without restriction, including 00180 * without limitation the rights to use, copy, modify, merge, publish, 00181 * distribute, and/or sell copies of the Software, and to permit persons to 00182 * whom the Software is furnished to do so, provided that the above 00183 * copyright notice(s) and this permission notice appear in all copies of 00184 * the Software and that both the above copyright notice(s) and this 00185 * permission notice appear in supporting documentation. 00186 * 00187 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00188 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00189 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00190 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00191 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00192 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00193 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00194 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00195 * PERFORMANCE OF THIS SOFTWARE. 00196 */

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