diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index 3ac4de6c5d..15bcc09e39 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -12,7 +12,6 @@ #include "LuaManager.h" #include "Foreach.h" #include "Song.h" -#include "Course.h" #include "GameState.h" #include "arch/Dialog/Dialog.h" @@ -152,17 +151,6 @@ namespace pActor->AppendAttrFrom("Texture", pVal, false); return "Sprite"; } - else if (sFile.EqualsNoCase("coursebanner")) - { - XNodeStringValue *pVal = new XNodeStringValue; - Course *pCourse = GAMESTATE->m_pCurCourse; - if (pCourse && pCourse->HasBanner()) - pVal->SetValue(pCourse->GetBannerPath()); - else - pVal->SetValue(THEME->GetPathG("Common", "fallback banner")); - pActor->AppendAttrFrom("Texture", pVal, false); - return "Sprite"; - } } // Fallback: use XML tag name for actor class diff --git a/src/AdjustSync.cpp b/src/AdjustSync.cpp index 7258f0dcbb..94db2fa98a 100644 --- a/src/AdjustSync.cpp +++ b/src/AdjustSync.cpp @@ -84,8 +84,6 @@ void AdjustSync::ResetAutosync() bool AdjustSync::IsSyncDataChanged() { // Can't sync in course modes - if( GAMESTATE->IsCourseMode() ) - return false; vector vs; AdjustSync::GetSyncChangeTextGlobal( vs ); AdjustSync::GetSyncChangeTextSong( vs ); @@ -94,9 +92,6 @@ bool AdjustSync::IsSyncDataChanged() void AdjustSync::SaveSyncChanges() { - if( GAMESTATE->IsCourseMode() ) - return; - /* TODO: Save all of the timing data changes. * Luckily, only the song timing data needs comparing here. */ if( GAMESTATE->m_pCurSong && s_vpTimingDataOriginal[0] != GAMESTATE->m_pCurSong->m_SongTiming ) @@ -119,8 +114,6 @@ void AdjustSync::SaveSyncChanges() void AdjustSync::RevertSyncChanges() { - if( GAMESTATE->IsCourseMode() ) - return; PREFSMAN->m_fGlobalOffsetSeconds.Set( s_fGlobalOffsetSecondsOriginal ); // The first one is ALWAYS the song timing. @@ -143,8 +136,6 @@ static LocalizedString AUTOSYNC_CORRECTION_APPLIED ( "AdjustSync", "Autosync: Co static LocalizedString AUTOSYNC_CORRECTION_NOT_APPLIED ( "AdjustSync", "Autosync: Correction NOT applied. Deviation too high." ); void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime ) { - if( GAMESTATE->IsCourseMode() ) - return; AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType; switch( type ) { case AutosyncType_Off: @@ -174,8 +165,6 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime ) void AdjustSync::HandleSongEnd() { - if( GAMESTATE->IsCourseMode() ) - return; if( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType == AutosyncType_Tempo ) { AutosyncTempo(); diff --git a/src/BPMDisplay.cpp b/src/BPMDisplay.cpp index 4229c222e0..e3552357b8 100644 --- a/src/BPMDisplay.cpp +++ b/src/BPMDisplay.cpp @@ -3,7 +3,6 @@ #include "RageUtil.h" #include "GameConstantsAndTypes.h" #include "GameState.h" -#include "Course.h" #include "Style.h" #include "ActorUtil.h" #include "CommonMetrics.h" @@ -210,29 +209,6 @@ void BPMDisplay::SetBpmFromSteps( const Steps* pSteps ) m_fCycleTime = 1.0f; } -void BPMDisplay::SetBpmFromCourse( const Course* pCourse ) -{ - ASSERT( pCourse != NULL ); - ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL ); - - StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType; - Trail *pTrail = pCourse->GetTrail( st ); - // GetTranslitFullTitle because "Crashinfo.txt is garbled because of the ANSI output as usual." -f - ASSERT_M( pTrail != NULL, ssprintf("Course '%s' has no trail for StepsType '%s'", pCourse->GetTranslitFullTitle().c_str(), StringConversion::ToString(st).c_str() ) ); - - m_fCycleTime = (float)COURSE_CYCLE_SPEED; - - if( (int)pTrail->m_vEntries.size() > CommonMetrics::MAX_COURSE_ENTRIES_BEFORE_VARIOUS ) - { - SetVarious(); - return; - } - - DisplayBpms bpms; - pTrail->GetDisplayBpms( bpms ); - SetBPMRange( bpms ); -} - void BPMDisplay::SetConstantBpm( float fBPM ) { DisplayBpms bpms; @@ -257,16 +233,6 @@ void BPMDisplay::SetFromGameState() SetBpmFromSong( GAMESTATE->m_pCurSong ); return; } - if( GAMESTATE->m_pCurCourse.Get() ) - { - if( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) == NULL ) - ; // This is true when backing out from ScreenSelectCourse to ScreenTitleMenu. So, don't call SetBpmFromCourse where an assert will fire. - else - SetBpmFromCourse( GAMESTATE->m_pCurCourse ); - - return; - } - NoBPM(); } @@ -328,16 +294,6 @@ class LunaBPMDisplay: public Luna } COMMON_RETURN_SELF; } - static int SetFromCourse( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->NoBPM(); } - else - { - const Course* pCourse = Luna::check( L, 1, true ); - p->SetBpmFromCourse(pCourse); - } - COMMON_RETURN_SELF; - } static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; } LunaBPMDisplay() @@ -345,7 +301,6 @@ class LunaBPMDisplay: public Luna ADD_METHOD( SetFromGameState ); ADD_METHOD( SetFromSong ); ADD_METHOD( SetFromSteps ); - ADD_METHOD( SetFromCourse ); ADD_METHOD( GetText ); } }; diff --git a/src/BPMDisplay.h b/src/BPMDisplay.h index d868ab23be..65d56e07d3 100644 --- a/src/BPMDisplay.h +++ b/src/BPMDisplay.h @@ -7,7 +7,6 @@ #include "LocalizedString.h" class Song; class Steps; -class Course; struct DisplayBpms; /** @brief Displays a BPM or a range of BPMs. */ @@ -36,11 +35,6 @@ class BPMDisplay : public BitmapText * @param pSteps the steps in question. */ void SetBpmFromSteps( const Steps* pSteps ); - /** - * @brief Use the BPM[s] from a course. - * @param pCourse the course in question. - */ - void SetBpmFromCourse( const Course* pCourse ); /** * @brief Use a specified, constant BPM. * @param fBPM the constant BPM. diff --git a/src/Banner.cpp b/src/Banner.cpp index 780596a29f..57faff90af 100644 --- a/src/Banner.cpp +++ b/src/Banner.cpp @@ -5,7 +5,6 @@ #include "RageUtil.h" #include "Song.h" #include "RageTextureManager.h" -#include "Course.h" #include "Character.h" #include "ThemeMetric.h" #include "CharacterManager.h" @@ -130,15 +129,6 @@ void Banner::LoadFromSongGroup( const RString &sSongGroup ) m_bScrolling = false; } -void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course -{ - if( pCourse == NULL ) LoadFallback(); - else if( pCourse->GetBannerPath() != "" ) Load( pCourse->GetBannerPath() ); - else LoadCourseFallback(); - - m_bScrolling = false; -} - void Banner::LoadCardFromCharacter( const Character *pCharacter ) { if( pCharacter == NULL ) LoadFallback(); @@ -196,11 +186,6 @@ void Banner::LoadGroupFallback() Load( THEME->GetPathG("Banner","group fallback") ); } -void Banner::LoadCourseFallback() -{ - Load( THEME->GetPathG("Banner","course fallback") ); -} - void Banner::LoadFallbackCharacterIcon() { Character *pCharacter = CHARMAN->GetDefaultCharacter(); @@ -252,12 +237,6 @@ class LunaBanner: public Luna else { Song *pS = Luna::check(L,1); p->LoadFromSong( pS ); } COMMON_RETURN_SELF; } - static int LoadFromCourse( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->LoadFromCourse( NULL ); } - else { Course *pC = Luna::check(L,1); p->LoadFromCourse( pC ); } - COMMON_RETURN_SELF; - } static int LoadFromCachedBanner( T* p, lua_State *L ) { p->LoadFromCachedBanner( SArg(1) ); @@ -311,7 +290,6 @@ class LunaBanner: public Luna ADD_METHOD( scaletoclipped ); ADD_METHOD( ScaleToClipped ); ADD_METHOD( LoadFromSong ); - ADD_METHOD( LoadFromCourse ); ADD_METHOD( LoadFromCachedBanner ); ADD_METHOD( LoadIconFromCharacter ); ADD_METHOD( LoadCardFromCharacter ); diff --git a/src/Banner.h b/src/Banner.h index 127822632a..4dee740244 100644 --- a/src/Banner.h +++ b/src/Banner.h @@ -7,7 +7,6 @@ #include "RageTextureID.h" #include "GameConstantsAndTypes.h" class Song; -class Course; class Character; class UnlockEntry; @@ -32,7 +31,6 @@ class Banner : public Sprite void LoadFromSong( Song* pSong ); void LoadMode(); void LoadFromSongGroup( const RString &sSongGroup ); - void LoadFromCourse( const Course *pCourse ); void LoadCardFromCharacter( const Character *pCharacter ); void LoadIconFromCharacter( const Character *pCharacter ); void LoadBannerFromUnlockEntry( const UnlockEntry* pUE ); @@ -43,7 +41,6 @@ class Banner : public Sprite void LoadFallback(); void LoadFallbackBG(); void LoadGroupFallback(); - void LoadCourseFallback(); void LoadFallbackCharacterIcon(); void SetScrolling( bool bScroll, float Percent = 0 ); diff --git a/src/CommonMetrics.cpp b/src/CommonMetrics.cpp index 7ca1fa2569..2d3eac4885 100644 --- a/src/CommonMetrics.cpp +++ b/src/CommonMetrics.cpp @@ -12,11 +12,9 @@ ThemeMetric CommonMetrics::OPERATOR_MENU_SCREEN ("Common","OperatorMe ThemeMetric CommonMetrics::FIRST_ATTRACT_SCREEN ("Common","FirstAttractScreen"); ThemeMetric CommonMetrics::DEFAULT_MODIFIERS ("Common","DefaultModifiers" ); LocalizedString CommonMetrics::WINDOW_TITLE ("Common","WindowTitle"); -ThemeMetric CommonMetrics::MAX_COURSE_ENTRIES_BEFORE_VARIOUS("Common","MaxCourseEntriesBeforeShowVarious"); ThemeMetric CommonMetrics::TICK_EARLY_SECONDS ("ScreenGameplay","TickEarlySeconds"); ThemeMetric CommonMetrics::DEFAULT_NOTESKIN_NAME ("Common","DefaultNoteSkinName"); ThemeMetricDifficultiesToShow CommonMetrics::DIFFICULTIES_TO_SHOW ("Common","DifficultiesToShow"); -ThemeMetricCourseDifficultiesToShow CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW ("Common","CourseDifficultiesToShow"); ThemeMetricStepsTypesToShow CommonMetrics::STEPS_TYPES_TO_SHOW ("Common","StepsTypesToHide"); ThemeMetric CommonMetrics::AUTO_SET_STYLE ("Common","AutoSetStyle"); ThemeMetric CommonMetrics::PERCENT_SCORE_DECIMAL_PLACES ("Common","PercentScoreDecimalPlaces"); @@ -59,45 +57,6 @@ void ThemeMetricDifficultiesToShow::Read() } const vector& ThemeMetricDifficultiesToShow::GetValue() const { return m_v; } - -ThemeMetricCourseDifficultiesToShow::ThemeMetricCourseDifficultiesToShow( const RString& sGroup, const RString& sName ) : - ThemeMetric(sGroup,sName) -{ - // re-read because ThemeMetric::ThemeMetric calls ThemeMetric::Read, not the derived one - if( IsLoaded() ) - Read(); -} -void ThemeMetricCourseDifficultiesToShow::Read() -{ - ASSERT( GetName().Right(6) == "ToShow" ); - - ThemeMetric::Read(); - - m_v.clear(); - - vector v; - split( ThemeMetric::GetValue(), ",", v ); - if(v.empty()) - { - LuaHelpers::ReportScriptError("CourseDifficultiesToShow must have at least one entry."); - return; - } - - FOREACH_CONST( RString, v, i ) - { - CourseDifficulty d = StringToDifficulty( *i ); - if( d == Difficulty_Invalid ) - { - LuaHelpers::ReportScriptErrorFmt("Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str()); - } - else - { - m_v.push_back( d ); - } - } -} -const vector& ThemeMetricCourseDifficultiesToShow::GetValue() const { return m_v; } - static void RemoveStepsTypes( vector& inout, RString sStepsTypesToRemove ) { vector v; diff --git a/src/CommonMetrics.h b/src/CommonMetrics.h index ba0529b361..ca4b0a439f 100644 --- a/src/CommonMetrics.h +++ b/src/CommonMetrics.h @@ -18,16 +18,6 @@ class ThemeMetricDifficultiesToShow : public ThemeMetric private: vector m_v; }; -class ThemeMetricCourseDifficultiesToShow : public ThemeMetric -{ -public: - ThemeMetricCourseDifficultiesToShow(): m_v() { } - ThemeMetricCourseDifficultiesToShow( const RString& sGroup, const RString& sName ); - void Read(); - const vector &GetValue() const; -private: - vector m_v; -}; class ThemeMetricStepsTypesToShow : public ThemeMetric { public: @@ -54,16 +44,12 @@ namespace CommonMetrics extern ThemeMetric DEFAULT_MODIFIERS; /** @brief The caption on the title bar. */ extern LocalizedString WINDOW_TITLE; - /** @brief How many entries should be shown before showing "Various" instead. */ - extern ThemeMetric MAX_COURSE_ENTRIES_BEFORE_VARIOUS; /** @brief Adjusts the assist tick sound's playback time. */ extern ThemeMetric TICK_EARLY_SECONDS; /** @brief the name of the default noteskin. */ extern ThemeMetric DEFAULT_NOTESKIN_NAME; /** @brief Which difficulties are to be shown? */ extern ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW; - /** @brief Which course difficulties are to be shown? */ - extern ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW; /** * @brief Which step types are to be shown? * diff --git a/src/Course.cpp b/src/Course.cpp index d098a683b1..e69de29bb2 100644 --- a/src/Course.cpp +++ b/src/Course.cpp @@ -1,1376 +0,0 @@ -#include -#include "global.h" -#include "Course.h" -#include "CourseLoaderCRS.h" -#include "Foreach.h" -#include "GameManager.h" -#include "GameState.h" -#include "LocalizedString.h" -#include "LuaManager.h" -#include "Preference.h" -#include "PrefsManager.h" -#include "ProfileManager.h" -#include "RageLog.h" -#include "Song.h" -#include "SongCacheIndex.h" -#include "Steps.h" -#include "ThemeManager.h" -#include "UnlockManager.h" -#include "Game.h" -#include "Style.h" - -static Preference MAX_SONGS_IN_EDIT_COURSE( "MaxSongsInEditCourse", -1 ); - -static const char *SongSortNames[] = { - "Randomize", - "MostPlays", - "FewestPlays", - "TopGrades", - "LowestGrades", -}; -XToString( SongSort ); -XToLocalizedString( SongSort ); - - -/* Maximum lower value of ranges when difficult: */ -const int MAX_BOTTOM_RANGE = 10; - -#define SORT_PREFERRED_COLOR THEME->GetMetricC("Course","SortPreferredColor") -#define SORT_LEVEL1_COLOR THEME->GetMetricC("Course","SortLevel1Color") -#define SORT_LEVEL2_COLOR THEME->GetMetricC("Course","SortLevel2Color") -#define SORT_LEVEL3_COLOR THEME->GetMetricC("Course","SortLevel3Color") -#define SORT_LEVEL4_COLOR THEME->GetMetricC("Course","SortLevel4Color") -#define SORT_LEVEL5_COLOR THEME->GetMetricC("Course","SortLevel5Color") - -//#define INCLUDE_BEGINNER_STEPS THEME->GetMetricB( "Course","IncludeBeginnerSteps" ); - -RString CourseEntry::GetTextDescription() const -{ - vector vsEntryDescription; - Song *pSong = songID.ToSong(); - if( pSong ) - vsEntryDescription.push_back( pSong->GetTranslitFullTitle() ); - else - vsEntryDescription.push_back( "Random" ); - if( !songCriteria.m_sGroupName.empty() ) - vsEntryDescription.push_back( songCriteria.m_sGroupName ); - if( songCriteria.m_bUseSongGenreAllowedList ) - vsEntryDescription.push_back( join(",",songCriteria.m_vsSongGenreAllowedList) ); - if( stepsCriteria.m_difficulty != Difficulty_Invalid && stepsCriteria.m_difficulty != Difficulty_Medium ) - vsEntryDescription.push_back( CourseDifficultyToLocalizedString(stepsCriteria.m_difficulty) ); - if( stepsCriteria.m_iLowMeter != -1 ) - vsEntryDescription.push_back( ssprintf("Low meter: %d", stepsCriteria.m_iLowMeter) ); - if( stepsCriteria.m_iHighMeter != -1 ) - vsEntryDescription.push_back( ssprintf("High meter: %d", stepsCriteria.m_iHighMeter) ); - if( songSort != SongSort_Randomize ) - vsEntryDescription.push_back( "Sort: %d" + SongSortToLocalizedString(songSort) ); - if( songSort != SongSort_Randomize && iChooseIndex != 0 ) - vsEntryDescription.push_back( "Choose " + FormatNumberAndSuffix(iChooseIndex) + " match" ); - int iNumModChanges = GetNumModChanges(); - if( iNumModChanges != 0 ) - vsEntryDescription.push_back( ssprintf("%d mod changes", iNumModChanges) ); - if( fGainSeconds != 0 ) - vsEntryDescription.push_back( ssprintf("Low meter: %.0f", fGainSeconds) ); - - RString s = join( ",", vsEntryDescription ); - return s; -} - -int CourseEntry::GetNumModChanges() const -{ - int iNumModChanges = 0; - if( !sModifiers.empty() ) - iNumModChanges++; - iNumModChanges += attacks.size(); - return iNumModChanges; -} - - -Course::Course(): m_bIsAutogen(false), m_sPath(""), m_sMainTitle(""), - m_sMainTitleTranslit(""), m_sSubTitle(""), m_sSubTitleTranslit(""), - m_sScripter(""), m_sDescription(""), m_sBannerPath(""), m_sBackgroundPath(""), - m_sCDTitlePath(""), m_sGroupName(""), m_bRepeat(false), - m_bShuffle(false), m_iLives(-1), m_bSortByMeter(false), - m_bIncomplete(false), m_vEntries(), m_SortOrder_TotalDifficulty(0), - m_SortOrder_Ranking(0), m_LoadedFromProfile(ProfileSlot_Invalid), - m_TrailCache(), m_iTrailCacheSeed(0), m_RadarCache(), - m_setStyles(), m_CachedObject() -{ - FOREACH_ENUM( Difficulty,dc) - m_iCustomMeter[dc] = -1; -} - -CourseType Course::GetCourseType() const -{ - if( m_bRepeat ) - return COURSE_TYPE_ENDLESS; - if( m_iLives > 0 ) - return COURSE_TYPE_ONI; - if( !m_vEntries.empty() && m_vEntries[0].fGainSeconds > 0 ) - return COURSE_TYPE_SURVIVAL; - return COURSE_TYPE_NONSTOP; -} - -void Course::SetCourseType( CourseType ct ) -{ - if( GetCourseType() == ct ) - return; - - m_bRepeat = false; - m_iLives = -1; - if( !m_vEntries.empty() ) - m_vEntries[0].fGainSeconds = 0; - - switch( ct ) - { - default: - FAIL_M(ssprintf("Invalid course type: %i", ct)); - case COURSE_TYPE_NONSTOP: - break; - case COURSE_TYPE_ONI: - m_iLives = 4; - break; - case COURSE_TYPE_ENDLESS: - m_bRepeat = true; - break; - case COURSE_TYPE_SURVIVAL: - if( !m_vEntries.empty() ) - m_vEntries[0].fGainSeconds = 120; - break; - } -} - -PlayMode Course::GetPlayMode() const -{ - CourseType ct = GetCourseType(); - switch( ct ) - { - case COURSE_TYPE_ENDLESS: return PLAY_MODE_ENDLESS; - case COURSE_TYPE_ONI: return PLAY_MODE_ONI; - case COURSE_TYPE_SURVIVAL: return PLAY_MODE_ONI; - case COURSE_TYPE_NONSTOP: return PLAY_MODE_NONSTOP; - default: - FAIL_M(ssprintf("Invalid course type: %i", ct)); - } -} - -void Course::RevertFromDisk() -{ - // trying to catch invalid an Course - ASSERT( !m_sPath.empty() ); - - CourseLoaderCRS::LoadFromCRSFile( m_sPath, *this ); -} - -RString Course::GetCacheFilePath() const -{ - return SongCacheIndex::GetCacheFilePath( "Courses", m_sPath ); -} - -void Course::Init() -{ - m_bIsAutogen = false; - m_sPath = ""; - - m_sMainTitle = ""; - m_sMainTitleTranslit = ""; - m_sSubTitle = ""; - m_sSubTitleTranslit = ""; - m_sScripter = ""; - m_sDescription = ""; - - m_sBannerPath = ""; - m_sBackgroundPath = ""; - m_sCDTitlePath = ""; - m_sGroupName = ""; - - m_bRepeat = false; - m_bShuffle = false; - - m_iLives = -1; - FOREACH_ENUM( Difficulty,dc) - m_iCustomMeter[dc] = -1; - m_bSortByMeter = false; - - m_vEntries.clear(); - - m_SortOrder_TotalDifficulty = 0; - m_SortOrder_Ranking = 0; - - m_LoadedFromProfile = ProfileSlot_Invalid; - m_bIncomplete = false; - m_TrailCache.clear(); - m_iTrailCacheSeed = 0; - m_RadarCache.clear(); -} - -bool Course::IsPlayableIn( StepsType st ) const -{ - Trail t; - FOREACH_ShownCourseDifficulty( cd ) - { - if( GetTrailUnsorted( st, cd, t ) ) - return true; - } - - // No valid trail for this StepsType. - return false; -} - - -struct SortTrailEntry -{ - TrailEntry entry; - int SortMeter; - - SortTrailEntry(): entry(), SortMeter(0) {} - - bool operator< ( const SortTrailEntry &rhs ) const { return SortMeter < rhs.SortMeter; } -}; - -RString Course::GetDisplayMainTitle() const -{ - if( !PREFSMAN->m_bShowNativeLanguage ) - return GetTranslitMainTitle(); - return m_sMainTitle; -} - -RString Course::GetDisplaySubTitle() const -{ - if( !PREFSMAN->m_bShowNativeLanguage ) - return GetTranslitSubTitle(); - return m_sSubTitle; -} - -RString Course::GetDisplayFullTitle() const -{ - RString sTitle = GetDisplayMainTitle(); - RString sSubTitle = GetDisplaySubTitle(); - - if( !sSubTitle.empty() ) - sTitle += " " + sSubTitle; - return sTitle; -} - -RString Course::GetTranslitFullTitle() const -{ - RString sTitle = GetTranslitMainTitle(); - RString sSubTitle = GetTranslitSubTitle(); - - if( !sSubTitle.empty() ) - sTitle += " " + sSubTitle; - return sTitle; -} - -/* This is called by many simple functions, like Course::GetTotalSeconds, and may - * be called on all songs to sort. It can take time to execute, so we cache the - * results. Returned pointers remain valid for the lifetime of the Course. If the - * course difficulty doesn't exist, NULL is returned. */ -Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const -{ - ASSERT( cd != Difficulty_Invalid ); - - // Check to see if the Trail cache is out of date - if( m_iTrailCacheSeed != GAMESTATE->m_iStageSeed ) - { - RegenerateNonFixedTrails(); - m_iTrailCacheSeed = GAMESTATE->m_iStageSeed; - } - - // Look in the Trail cache - { - TrailCache_t::iterator it = m_TrailCache.find( CacheEntry(st, cd) ); - if( it != m_TrailCache.end() ) - { - CacheData &cache = it->second; - if( cache.null ) - return NULL; - return &cache.trail; - } - } - - return GetTrailForceRegenCache( st, cd ); -} - -Trail* Course::GetTrailForceRegenCache( StepsType st, CourseDifficulty cd ) const -{ - // Construct a new Trail, add it to the cache, then return it. - CacheData &cache = m_TrailCache[ CacheEntry(st, cd) ]; - Trail &trail = cache.trail; - trail.Init(); - if( !GetTrailSorted(st, cd, trail) ) - { - // This course difficulty doesn't exist. - cache.null = true; - return NULL; - } - - // If we have cached RadarValues for this trail, insert them. - { - RadarCache_t::const_iterator it = m_RadarCache.find( CacheEntry( st, cd ) ); - if( it != m_RadarCache.end() ) - { - const RadarValues &rv = it->second; - trail.SetRadarValues(rv); - } - } - - cache.null = false; - return &cache.trail; -} - -bool Course::GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const -{ - if( !GetTrailUnsorted( st, cd, trail ) ) - return false; - - if( this->m_bSortByMeter ) - { - /* Sort according to Difficulty_Medium, since the order of songs - * must not change across difficulties. */ - Trail SortTrail; - if( cd == Difficulty_Medium ) - SortTrail = trail; - else - { - bool bOK = GetTrailUnsorted( st, Difficulty_Medium, SortTrail ); - - /* If we have any other difficulty, we must have Difficulty_Medium. */ - ASSERT( bOK ); - } - ASSERT_M( trail.m_vEntries.size() == SortTrail.m_vEntries.size(), - ssprintf("%i %i", static_cast(trail.m_vEntries.size()), static_cast(SortTrail.m_vEntries.size())) ); - - vector entries; - for( unsigned i = 0; i < trail.m_vEntries.size(); ++i ) - { - SortTrailEntry ste; - ste.entry = trail.m_vEntries[i]; - ste.SortMeter = SortTrail.m_vEntries[i].pSteps->GetMeter(); - entries.push_back( ste ); - } - - stable_sort( entries.begin(), entries.end() ); - for( unsigned i = 0; i < trail.m_vEntries.size(); ++i ) - trail.m_vEntries[i] = entries[i].entry; - } - - if( trail.m_vEntries.empty() ) - return false; - return true; -} - -// TODO: Move Course initialization after PROFILEMAN is created -static void CourseSortSongs( SongSort sort, vector &vpPossibleSongs, RandomGen &rnd ) -{ - switch( sort ) - { - DEFAULT_FAIL(sort); - case SongSort_Randomize: - std::shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); - break; - case SongSort_MostPlays: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), true ); // descending - break; - case SongSort_FewestPlays: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), false ); // ascending - break; - case SongSort_TopGrades: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, true ); // descending - break; - case SongSort_LowestGrades: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, false ); // ascending - break; - } -} - -namespace -{ - struct SongIsEqual - { - const Song *m_pSong; - SongIsEqual( const Song *pSong ) : m_pSong(pSong) { } - bool operator()( const SongAndSteps &sas ) const { return sas.pSong == m_pSong; } - }; -} - -bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const -{ - trail.Init(); - - // XXX: Why are beginner and challenge excluded here? -Wolfman2000 - // No idea, probably an obsolete design decision from ITG, removing - // exclusion here, but there's some other area that prevents it too. -Kyz - /* - switch( cd ) - { - case Difficulty_Beginner: - return false; - case Difficulty_Challenge: - return false; - default: break; - } - */ - - // Construct a new Trail, add it to the cache, then return it. - // Different seed for each course, but the same for the whole round: - RandomGen rnd( GAMESTATE->m_iStageSeed + GetHashForString(m_sMainTitle) ); - - vector tmp_entries; - if( m_bShuffle ) - { - /* Always randomize the same way per round. Otherwise, the displayed course - * will change every time it's viewed, and the displayed order will have no - * bearing on what you'll actually play. */ - tmp_entries = m_vEntries; - std::shuffle( tmp_entries.begin(), tmp_entries.end(), rnd ); - } - - const vector &entries = m_bShuffle ? tmp_entries:m_vEntries; - - // This can take some time, so don't fill it out unless we need it. - vector vSongsByMostPlayed; - vector AllSongsShuffled; - - trail.m_StepsType = st; - trail.m_CourseType = GetCourseType(); - trail.m_CourseDifficulty = cd; - trail.m_vEntries.reserve(entries.size()); - - // Set to true if CourseDifficulty is able to change something. - bool bCourseDifficultyIsSignificant = (cd == Difficulty_Medium); - - - - // Resolve each entry to a Song and Steps. - if( trail.m_CourseType == COURSE_TYPE_ENDLESS ) - { - GetTrailUnsortedEndless(entries, trail, st, cd, rnd, bCourseDifficultyIsSignificant); - } - else - { - vector vSongAndSteps; - FOREACH_CONST( CourseEntry, entries, e ) - { - SongAndSteps resolved; // fill this in - SongCriteria soc = e->songCriteria; - - Song *pSong = e->songID.ToSong(); - if( pSong ) - { - soc.m_bUseSongAllowedList = true; - soc.m_vpSongAllowedList.push_back( pSong ); - } - soc.m_Tutorial = SongCriteria::Tutorial_No; - soc.m_Locked = SongCriteria::Locked_Unlocked; - if( !soc.m_bUseSongAllowedList ) - soc.m_iMaxStagesForSong = 1; - - StepsCriteria stc = e->stepsCriteria; - stc.m_st = st; - stc.m_Locked = StepsCriteria::Locked_Unlocked; - - const bool bSameSongCriteria = e != entries.begin() && ( e - 1 )->songCriteria == soc; - const bool bSameStepsCriteria = e != entries.begin() && ( e - 1 )->stepsCriteria == stc; - - if( pSong ) - { - StepsUtil::GetAllMatching( pSong, stc, vSongAndSteps ); - } - else if( vSongAndSteps.empty() || !( bSameSongCriteria && bSameStepsCriteria ) ) - { - vSongAndSteps.clear(); - StepsUtil::GetAllMatching( soc, stc, vSongAndSteps ); - } - - // It looks bad to have the same song 2x in a row in a randomly generated course. - // Don't allow the same song to be played 2x in a row, unless there's only - // one song in vpPossibleSongs. - if( trail.m_vEntries.size() > 0 && vSongAndSteps.size() > 1 ) - { - const TrailEntry &teLast = trail.m_vEntries.back(); - RemoveIf( vSongAndSteps, SongIsEqual( teLast.pSong ) ); - } - - // if there are no songs to choose from, abort this CourseEntry - if( vSongAndSteps.empty() ) - continue; - - vector vpSongs; - typedef vector StepsVector; - map mapSongToSteps; - FOREACH_CONST( SongAndSteps, vSongAndSteps, sas ) - { - StepsVector &v = mapSongToSteps[ sas->pSong ]; - - v.push_back( sas->pSteps ); - if( v.size() == 1 ) - vpSongs.push_back( sas->pSong ); - } - - CourseSortSongs( e->songSort, vpSongs, rnd ); - - ASSERT( e->iChooseIndex >= 0 ); - if( e->iChooseIndex < static_cast( vSongAndSteps.size() ) ) - { - resolved.pSong = vpSongs[ e->iChooseIndex ]; - const vector &mappedSongs = mapSongToSteps[ resolved.pSong ]; - resolved.pSteps = mappedSongs[ RandomInt( mappedSongs.size() ) ]; - } - else - { - continue; - } - - /* If we're not COURSE_DIFFICULTY_REGULAR, then we should be choosing steps that are - * either easier or harder than the base difficulty. If no such steps exist, then - * just use the one we already have. */ - Difficulty dc = resolved.pSteps->GetDifficulty(); - int iLowMeter = e->stepsCriteria.m_iLowMeter; - int iHighMeter = e->stepsCriteria.m_iHighMeter; - if( cd != Difficulty_Medium && !e->bNoDifficult ) - { - Difficulty new_dc = ( Difficulty )( dc + cd - Difficulty_Medium ); - new_dc = clamp( new_dc, ( Difficulty )0, ( Difficulty )( Difficulty_Edit - 1 ) ); - /* - // re-edit this code to work using the metric. - Difficulty new_dc; - if( INCLUDE_BEGINNER_STEPS ) - { - // don't factor in the course difficulty if we're including - // beginner steps -aj - new_dc = clamp( dc, Difficulty_Beginner, (Difficulty)(Difficulty_Edit-1) ); - } - else - { - new_dc = (Difficulty)(dc + cd - Difficulty_Medium); - new_dc = clamp( new_dc, (Difficulty)0, (Difficulty)(Difficulty_Edit-1) ); - } - */ - - bool bChangedDifficulty = false; - if( new_dc != dc ) - { - Steps* pNewSteps = SongUtil::GetStepsByDifficulty( resolved.pSong, st, new_dc ); - if( pNewSteps ) - { - dc = new_dc; - resolved.pSteps = pNewSteps; - bChangedDifficulty = true; - bCourseDifficultyIsSignificant = true; - } - } - - /* Hack: We used to adjust low_meter/high_meter above while searching for - * songs. However, that results in a different song being chosen for - * difficult courses, which is bad when LockCourseDifficulties is disabled; - * each player can end up with a different song. Instead, choose based - * on the original range, bump the steps based on course difficulty, and - * then retroactively tweak the low_meter/high_meter so course displays - * line up. */ - if( e->stepsCriteria.m_difficulty == Difficulty_Invalid && bChangedDifficulty ) - { - /* Minimum and maximum to add to make the meter range contain the actual - * meter: */ - int iMinDist = resolved.pSteps->GetMeter() - iHighMeter; - int iMaxDist = resolved.pSteps->GetMeter() - iLowMeter; - - /* Clamp the possible adjustments to try to avoid going under 1 or over - * MAX_BOTTOM_RANGE. */ - iMinDist = min( max( iMinDist, -iLowMeter + 1 ), iMaxDist ); - iMaxDist = max( min( iMaxDist, MAX_BOTTOM_RANGE - iHighMeter ), iMinDist ); - - int iAdd; - if ( iMaxDist == iMinDist ) - { - iAdd = iMaxDist; - } - else - { - iAdd = random_up_to(rnd, iMaxDist - iMinDist) + iMinDist; - } - iLowMeter += iAdd; - iHighMeter += iAdd; - } - } - - TrailEntry te; - te.pSong = resolved.pSong; - te.pSteps = resolved.pSteps; - te.Modifiers = e->sModifiers; - te.Attacks = e->attacks; - te.bSecret = e->bSecret; - te.iLowMeter = iLowMeter; - te.iHighMeter = iHighMeter; - - /* If we chose based on meter (not difficulty), then store Difficulty_Invalid, so - * other classes can tell that we used meter. */ - if( e->stepsCriteria.m_difficulty == Difficulty_Invalid ) - { - te.dc = Difficulty_Invalid; - } - else - { - /* Otherwise, store the actual difficulty we got (post-course-difficulty). - * This may or may not be the same as e.difficulty. */ - te.dc = dc; - } - trail.m_vEntries.push_back( te ); - - // LOG->Trace( "Chose: %s, %d", te.pSong->GetSongDir().c_str(), te.pSteps->GetMeter() ); - - if( IsAnEdit() && MAX_SONGS_IN_EDIT_COURSE > 0 && - static_cast( trail.m_vEntries.size() ) >= MAX_SONGS_IN_EDIT_COURSE ) - { - break; - } - } - } - - /* Hack: If any entry was non-FIXED, or m_bShuffle is set, then radar values - * for this trail will be meaningless as they'll change every time. Pre-cache - * empty data. XXX: How can we do this cleanly, without propagating lots of - * otherwise unnecessary data (course entry types, m_bShuffle) to Trail, or - * storing a Course pointer in Trail (yuck)? */ - if( !AllSongsAreFixed() || m_bShuffle ) - { - trail.m_bRadarValuesCached = true; - trail.m_CachedRadarValues = RadarValues(); - } - - /* If we have a manually-entered meter for this difficulty, use it. */ - if( m_iCustomMeter[cd] != -1 ) - trail.m_iSpecifiedMeter = m_iCustomMeter[cd]; - - /* If the course difficulty never actually changed anything, then this difficulty - * is equivalent to Difficulty_Medium; it doesn't exist. */ - return bCourseDifficultyIsSignificant && trail.m_vEntries.size() > 0; -} - -void Course::GetTrailUnsortedEndless( const vector &entries, Trail &trail, StepsType &st, - CourseDifficulty &cd, RandomGen &rnd, bool &bCourseDifficultyIsSignificant ) const -{ - vector vpAllPossibleSongs; - vector vSongAndSteps; - vector vpSongs; - typedef vector StepsVector; - map mapSongToSteps; - int songIndex = 0; - bool vpSongsSorted = false; - FOREACH_CONST( CourseEntry, entries, e ) - { - - SongAndSteps resolved; // fill this in - SongCriteria soc = e->songCriteria; - - - Song *pSong = e->songID.ToSong(); - if( pSong ) - { - soc.m_bUseSongAllowedList = true; - soc.m_vpSongAllowedList.push_back( pSong ); - } - soc.m_Tutorial = SongCriteria::Tutorial_No; - soc.m_Locked = SongCriteria::Locked_Unlocked; - if( !soc.m_bUseSongAllowedList ) - soc.m_iMaxStagesForSong = 1; - - StepsCriteria stc = e->stepsCriteria; - stc.m_st = st; - stc.m_Locked = StepsCriteria::Locked_Unlocked; - - const bool bSameSongCriteria = e != entries.begin() && ( e - 1 )->songCriteria == soc; - const bool bSameStepsCriteria = e != entries.begin() && ( e - 1 )->stepsCriteria == stc; - - if( pSong ) - { - StepsUtil::GetAllMatchingEndless( pSong, stc, vSongAndSteps ); - } - else if( vSongAndSteps.empty() || !( bSameSongCriteria && bSameStepsCriteria ) ) - { - vSongAndSteps.clear(); - StepsUtil::GetAllMatching( soc, stc, vSongAndSteps ); - } - - // if there are no songs to choose from, abort this CourseEntry - if( vSongAndSteps.empty() ) - continue; - - if( !vpSongsSorted && !vSongAndSteps.empty() ) { - FOREACH_CONST( SongAndSteps, vSongAndSteps, sas ) - { - StepsVector &v = mapSongToSteps[ sas->pSong ]; - v.push_back( sas->pSteps ); - if( v.size() == 1 ) - vpSongs.push_back( sas->pSong ); - } - vpSongsSorted = true; - CourseSortSongs( e->songSort, vpSongs, rnd ); - songIndex = 0; - } - - ASSERT( e->iChooseIndex >= 0 ); - if( e->iChooseIndex < static_cast( vSongAndSteps.size() ) ) - { - if( songIndex >= vpSongs.size() ) { - songIndex = 0; - } - resolved.pSong = vpSongs[ songIndex ]; - const vector &mappedSongs = mapSongToSteps[ resolved.pSong ]; - songIndex++; - resolved.pSteps = mappedSongs[ RandomInt( mappedSongs.size() ) ]; - } - else - { - continue; - } - - /* If we're not COURSE_DIFFICULTY_REGULAR, then we should be choosing steps that are - * either easier or harder than the base difficulty. If no such steps exist, then - * just use the one we already have. */ - Difficulty dc = resolved.pSteps->GetDifficulty(); - int iLowMeter = e->stepsCriteria.m_iLowMeter; - int iHighMeter = e->stepsCriteria.m_iHighMeter; - if( cd != Difficulty_Medium && !e->bNoDifficult ) - { - Difficulty new_dc = ( Difficulty )( dc + cd - Difficulty_Medium ); - if( dc != Difficulty_Medium ) - { - new_dc = cd; - } - new_dc = clamp( new_dc, ( Difficulty )0, ( Difficulty )( Difficulty_Edit - 1 ) ); - /* - // re-edit this code to work using the metric. - Difficulty new_dc; - if( INCLUDE_BEGINNER_STEPS ) - { - // don't factor in the course difficulty if we're including - // beginner steps -aj - new_dc = clamp( dc, Difficulty_Beginner, (Difficulty)(Difficulty_Edit-1) ); - } - else - { - new_dc = (Difficulty)(dc + cd - Difficulty_Medium); - new_dc = clamp( new_dc, (Difficulty)0, (Difficulty)(Difficulty_Edit-1) ); - } - */ - - bool bChangedDifficulty = false; - if( new_dc != dc ) - { - Steps* pNewSteps = SongUtil::GetStepsByDifficulty( resolved.pSong, st, new_dc ); - if( pNewSteps ) - { - dc = new_dc; - resolved.pSteps = pNewSteps; - bChangedDifficulty = true; - bCourseDifficultyIsSignificant = true; - } - } - - /* Hack: We used to adjust low_meter/high_meter above while searching for - * songs. However, that results in a different song being chosen for - * difficult courses, which is bad when LockCourseDifficulties is disabled; - * each player can end up with a different song. Instead, choose based - * on the original range, bump the steps based on course difficulty, and - * then retroactively tweak the low_meter/high_meter so course displays - * line up. */ - if( e->stepsCriteria.m_difficulty == Difficulty_Invalid && bChangedDifficulty ) - { - /* Minimum and maximum to add to make the meter range contain the actual - * meter: */ - int iMinDist = resolved.pSteps->GetMeter() - iHighMeter; - int iMaxDist = resolved.pSteps->GetMeter() - iLowMeter; - - /* Clamp the possible adjustments to try to avoid going under 1 or over - * MAX_BOTTOM_RANGE. */ - iMinDist = min( max( iMinDist, -iLowMeter + 1 ), iMaxDist ); - iMaxDist = max( min( iMaxDist, MAX_BOTTOM_RANGE - iHighMeter ), iMinDist ); - - int iAdd; - if ( iMaxDist == iMinDist ) - { - iAdd = iMaxDist; - } - else - { - iAdd = random_up_to(rnd, iMaxDist - iMinDist) + iMinDist; - } - iLowMeter += iAdd; - iHighMeter += iAdd; - } - } - - TrailEntry te; - te.pSong = resolved.pSong; - te.pSteps = resolved.pSteps; - te.Modifiers = e->sModifiers; - te.Attacks = e->attacks; - te.bSecret = e->bSecret; - te.iLowMeter = iLowMeter; - te.iHighMeter = iHighMeter; - - /* If we chose based on meter (not difficulty), then store Difficulty_Invalid, so - * other classes can tell that we used meter. */ - if( e->stepsCriteria.m_difficulty == Difficulty_Invalid ) - { - te.dc = Difficulty_Invalid; - } - else - { - /* Otherwise, store the actual difficulty we got (post-course-difficulty). - * This may or may not be the same as e.difficulty. */ - te.dc = dc; - } - - trail.m_vEntries.push_back( te ); - if( trail.m_vEntries.size() > 0 && te.dc != cd ) - { - trail.m_vEntries.reserve( trail.m_vEntries.size() - 1 ); - trail.m_vEntries.resize( trail.m_vEntries.size() - 1 ); - } - // LOG->Trace( "Chose: %s, %d", te.pSong->GetSongDir().c_str(), te.pSteps->GetMeter() ); - - if( IsAnEdit() && MAX_SONGS_IN_EDIT_COURSE > 0 && - static_cast( trail.m_vEntries.size() ) >= MAX_SONGS_IN_EDIT_COURSE ) - { - break; - } - } -} - -void Course::GetTrails( vector &AddTo, StepsType st ) const -{ - FOREACH_ShownCourseDifficulty( cd ) - { - Trail *pTrail = GetTrail( st, cd ); - if( pTrail == NULL ) - continue; - AddTo.push_back( pTrail ); - } -} - -void Course::GetAllTrails( vector &AddTo ) const -{ - vector vStepsTypesToShow; - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypesToShow ); - FOREACH( StepsType, vStepsTypesToShow, st ) - { - GetTrails( AddTo, *st ); - } -} - -int Course::GetMeter( StepsType st, CourseDifficulty cd ) const -{ - if( m_iCustomMeter[cd] != -1 ) - return m_iCustomMeter[cd]; - const Trail* pTrail = GetTrail( st ); - if( pTrail != NULL ) - return pTrail->GetMeter(); - return 0; -} - -bool Course::HasMods() const -{ - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - if( !e->attacks.empty() ) - return true; - } - - return false; -} - -bool Course::HasTimedMods() const -{ - // What makes this different from the SM4 implementation is that - // HasTimedMods now searches for bGlobal in the attacks; if one of - // them is false, it has timed mods. Also returning false will probably - // take longer than expected. -aj - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - if( !e->attacks.empty() ) - { - for( unsigned s=0; s < e->attacks.size(); s++ ) - { - const Attack attack = e->attacks[s]; - if(!attack.bGlobal) - return true; - } - } - } - return false; -} - -bool Course::AllSongsAreFixed() const -{ - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - if( !e->IsFixedSong() ) - return false; - } - return true; -} - -const Style *Course::GetCourseStyle( const Game *pGame, int iNumPlayers ) const -{ - vector vpStyles; - GAMEMAN->GetCompatibleStyles( pGame, iNumPlayers, vpStyles ); - - for( int s=0; s < (int) vpStyles.size(); ++s ) - { - const Style *pStyle = vpStyles[s]; - FOREACHS_CONST( RString, m_setStyles, style ) - { - if( !style->CompareNoCase(pStyle->m_szName) ) - return pStyle; - } - } - return NULL; -} - -void Course::InvalidateTrailCache() -{ - m_TrailCache.clear(); -} - -void Course::Invalidate( const Song *pStaleSong ) -{ - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - Song *pSong = e->songID.ToSong(); - if( pSong == pStaleSong ) // a fixed entry that references the stale Song - { - RevertFromDisk(); - return; - } - } - - // Invalidate any Trails that contain this song. - // If we find a Trail that contains this song, then it's part of a - // non-fixed entry. So, regenerating the Trail will force different - // songs to be chosen. - FOREACH_ENUM( StepsType,st ) - { - FOREACH_ShownCourseDifficulty( cd ) - { - TrailCache_t::iterator it = m_TrailCache.find( CacheEntry(st, cd) ); - if( it == m_TrailCache.end() ) - continue; - CacheData &cache = it->second; - if( !cache.null ) - if( GetTrail( st, cd )->ContainsSong( pStaleSong ) ) - m_TrailCache.erase( it ); - } - } -} - -void Course::RegenerateNonFixedTrails() const -{ - // Only need to regen Trails if the Course has a random entry. - // We can create these Trails on demand because we don't - // calculate RadarValues for Trails with one or more non-fixed - // entry. - if( AllSongsAreFixed() ) - return; - - FOREACHM( CacheEntry, CacheData, m_TrailCache, e ) - { - const CacheEntry &ce = e->first; - GetTrailForceRegenCache( ce.first, ce.second ); - } -} - -RageColor Course::GetColor() const -{ - // FIXME: Calculate the meter. - int iMeter = 5; - - switch( PREFSMAN->m_CourseSortOrder ) - { - case COURSE_SORT_PREFERRED: - return SORT_PREFERRED_COLOR; //This will also be used for autogen'd courses in some cases. - - case COURSE_SORT_SONGS: - if( m_vEntries.size() >= 7 ) return SORT_LEVEL2_COLOR; - else if( m_vEntries.size() >= 4 ) return SORT_LEVEL4_COLOR; - else return SORT_LEVEL5_COLOR; - - case COURSE_SORT_METER: - if( !AllSongsAreFixed() ) return SORT_LEVEL1_COLOR; - else if( iMeter > 9 ) return SORT_LEVEL2_COLOR; - else if( iMeter >= 7 ) return SORT_LEVEL3_COLOR; - else if( iMeter >= 5 ) return SORT_LEVEL4_COLOR; - else return SORT_LEVEL5_COLOR; - - case COURSE_SORT_METER_SUM: - if( !AllSongsAreFixed() ) return SORT_LEVEL1_COLOR; - if( m_SortOrder_TotalDifficulty >= 40 ) return SORT_LEVEL2_COLOR; - if( m_SortOrder_TotalDifficulty >= 30 ) return SORT_LEVEL3_COLOR; - if( m_SortOrder_TotalDifficulty >= 20 ) return SORT_LEVEL4_COLOR; - else return SORT_LEVEL5_COLOR; - - case COURSE_SORT_RANK: - if( m_SortOrder_Ranking == 3 ) return SORT_LEVEL1_COLOR; - else if( m_SortOrder_Ranking == 2 ) return SORT_LEVEL3_COLOR; - else if( m_SortOrder_Ranking == 1 ) return SORT_LEVEL5_COLOR; - else return SORT_LEVEL4_COLOR; - default: - FAIL_M( ssprintf("Invalid course sort %d.", int(PREFSMAN->m_CourseSortOrder)) ); - return RageColor(1,1,1,1); // white; should never reach here - } -} - -bool Course::GetTotalSeconds( StepsType st, float& fSecondsOut ) const -{ - if( !AllSongsAreFixed() ) - return false; - - Trail* trail = GetTrail( st, Difficulty_Medium ); - if(!trail) - { - for(int cd= 0; cd < NUM_CourseDifficulty; ++cd) - { - trail= GetTrail(st, (CourseDifficulty)cd); - if(trail) - { - break; - } - } - if(!trail) - { - return false; - } - } - - fSecondsOut = trail->GetLengthSeconds(); - return true; -} - -bool Course::CourseHasBestOrWorst() const -{ - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - if( e->songSort == SongSort_MostPlays && e->iChooseIndex != -1 ) - return true; - if( e->songSort == SongSort_FewestPlays && e->iChooseIndex != -1 ) - return true; - } - - return false; -} - -RString Course::GetBannerPath() const -{ - if( m_sBannerPath.empty() ) - return RString(); - if( m_sBannerPath[0] == '/' ) - return m_sBannerPath; - return Dirname(m_sPath) + m_sBannerPath; -} - -RString Course::GetBackgroundPath() const -{ - if( m_sBackgroundPath.empty() ) - return RString(); - if( m_sBackgroundPath[0] == '/' ) - return m_sBackgroundPath; - return Dirname(m_sPath) + m_sBackgroundPath; -} - -bool Course::HasBanner() const -{ - return GetBannerPath() != "" && IsAFile(GetBannerPath()); -} - -bool Course::HasBackground() const -{ - return GetBackgroundPath() != "" && IsAFile(GetBackgroundPath()); -} - -void Course::UpdateCourseStats( StepsType st ) -{ - m_SortOrder_TotalDifficulty = 0; - - // courses with random/players best-worst songs should go at the end - for(unsigned i = 0; i < m_vEntries.size(); i++) - { - Song *pSong = m_vEntries[i].songID.ToSong(); - if( pSong != NULL ) - continue; - - if ( m_SortOrder_Ranking == 2 ) - m_SortOrder_Ranking = 3; - m_SortOrder_TotalDifficulty = INT_MAX; - return; - } - - const Trail* pTrail = GetTrail( st, Difficulty_Medium ); - - m_SortOrder_TotalDifficulty += pTrail != NULL? pTrail->GetTotalMeter():0; - - // OPTIMIZATION: Ranking info isn't dependent on style, so call it - // sparingly. It's handled on startup and when themes change. - - LOG->Trace("%s: Total feet: %d", - this->m_sMainTitle.c_str(), - m_SortOrder_TotalDifficulty ); -} - -bool Course::IsRanking() const -{ - vector rankingsongs; - - split(THEME->GetMetric("ScreenRanking", "CoursesToShow"), ",", rankingsongs); - - for(unsigned i=0; i < rankingsongs.size(); i++) - if (rankingsongs[i].EqualsNoCase(m_sPath)) - return true; - - return false; -} - -const CourseEntry *Course::FindFixedSong( const Song *pSong ) const -{ - FOREACH_CONST( CourseEntry, m_vEntries, e ) - { - const CourseEntry &entry = *e; - Song *lSong = entry.songID.ToSong(); - if( pSong == lSong ) - return &entry; - } - - return NULL; -} - -void Course::GetAllCachedTrails( vector &out ) -{ - TrailCache_t::iterator it; - for( it = m_TrailCache.begin(); it != m_TrailCache.end(); ++it ) - { - CacheData &cd = it->second; - if( !cd.null ) - out.push_back( &cd.trail ); - } -} - -bool Course::ShowInDemonstrationAndRanking() const -{ - // Don't show endless courses in Ranking. - // todo: make this a metric of course types not to show? -aj - return !IsEndless(); -} - -void Course::CalculateRadarValues() -{ - FOREACH_ENUM( StepsType,st ) - { - FOREACH_ENUM( CourseDifficulty,cd ) - { - // For courses that aren't fixed, the radar values are meaningless. - // Makes non-fixed courses have unknown radar values. - if( AllSongsAreFixed() ) - { - Trail *pTrail = GetTrail( st, cd ); - if( pTrail == NULL ) - continue; - RadarValues rv = pTrail->GetRadarValues(); - m_RadarCache[CacheEntry(st, cd)] = rv; - } - else - { - m_RadarCache[CacheEntry(st, cd)] = RadarValues(); - } - } - } -} - -bool Course::Matches( const RString &sGroup, const RString &sCourse ) const -{ - if( sGroup.size() && sGroup.CompareNoCase(this->m_sGroupName) != 0) - return false; - - RString sFile = m_sPath; - if( !sFile.empty() ) - { - sFile.Replace("\\","/"); - vector bits; - split( sFile, "/", bits ); - const RString &sLastBit = bits[bits.size()-1]; - if( sCourse.EqualsNoCase(sLastBit) ) - return true; - } - - if( sCourse.EqualsNoCase(this->GetTranslitFullTitle()) ) - return true; - - return false; -} - -// lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the CourseEntry. */ -class LunaCourseEntry: public Luna -{ -public: - static int GetSong( T* p, lua_State *L ) - { - if( p->songID.ToSong() ) - p->songID.ToSong()->PushSelf(L); - else - lua_pushnil(L); - return 1; - } - DEFINE_METHOD( IsSecret, bSecret ); - DEFINE_METHOD( IsFixedSong, IsFixedSong() ); - DEFINE_METHOD( GetGainSeconds, fGainSeconds ); - DEFINE_METHOD( GetGainLives, iGainLives ); - DEFINE_METHOD( GetNormalModifiers, sModifiers ); - // GetTimedModifiers - table - DEFINE_METHOD( GetNumModChanges, GetNumModChanges() ); - DEFINE_METHOD( GetTextDescription, GetTextDescription() ); - - LunaCourseEntry() - { - ADD_METHOD( GetSong ); - // sm-ssc additions: - ADD_METHOD( IsSecret ); - ADD_METHOD( IsFixedSong ); - ADD_METHOD( GetGainSeconds ); - ADD_METHOD( GetGainLives ); - ADD_METHOD( GetNormalModifiers ); - //ADD_METHOD( GetTimedModifiers ); - ADD_METHOD( GetNumModChanges ); - ADD_METHOD( GetTextDescription ); - } -}; - -LUA_REGISTER_CLASS( CourseEntry ) - -// Now for the Course bindings: -/** @brief Allow Lua to have access to the Course. */ -class LunaCourse: public Luna -{ -public: - DEFINE_METHOD( GetPlayMode, GetPlayMode() ) - static int GetDisplayFullTitle( T* p, lua_State *L ) { lua_pushstring(L, p->GetDisplayFullTitle() ); return 1; } - static int GetTranslitFullTitle( T* p, lua_State *L ) { lua_pushstring(L, p->GetTranslitFullTitle() ); return 1; } - static int HasMods( T* p, lua_State *L ) { lua_pushboolean(L, p->HasMods() ); return 1; } - static int HasTimedMods( T* p, lua_State *L ) { lua_pushboolean( L, p->HasTimedMods() ); return 1; } - DEFINE_METHOD( GetCourseType, GetCourseType() ) - static int GetCourseEntry( T* p, lua_State *L ) { CourseEntry &ce = p->m_vEntries[IArg(1)]; ce.PushSelf(L); return 1; } - static int GetCourseEntries( T* p, lua_State *L ) - { - vector v; - for( unsigned i = 0; i < p->m_vEntries.size(); ++i ) - { - v.push_back(&p->m_vEntries[i]); - } - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - static int GetAllTrails( T* p, lua_State *L ) - { - vector v; - p->GetAllTrails( v ); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - static int GetBannerPath( T* p, lua_State *L ) { RString s = p->GetBannerPath(); if( s.empty() ) return 0; LuaHelpers::Push(L, s); return 1; } - static int GetBackgroundPath( T* p, lua_State *L ) { RString s = p->GetBackgroundPath(); if( s.empty() ) return 0; LuaHelpers::Push(L, s); return 1; } - static int GetCourseDir( T* p, lua_State *L ) { lua_pushstring(L, p->m_sPath ); return 1; } - static int GetGroupName( T* p, lua_State *L ) { lua_pushstring(L, p->m_sGroupName ); return 1; } - static int IsAutogen( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bIsAutogen ); return 1; } - static int GetEstimatedNumStages( T* p, lua_State *L ) { lua_pushnumber(L, p->GetEstimatedNumStages() ); return 1; } - static int GetScripter( T* p, lua_State *L ) { lua_pushstring(L, p->m_sScripter ); return 1; } - static int GetDescription( T* p, lua_State *L ) { lua_pushstring(L, p->m_sDescription ); return 1; } - static int GetTotalSeconds( T* p, lua_State *L ) - { - StepsType st = Enum::Check(L, 1); - float fTotalSeconds; - if( !p->GetTotalSeconds(st, fTotalSeconds) ) - lua_pushnil( L ); - else - lua_pushnumber( L, fTotalSeconds ); - return 1; - } - DEFINE_METHOD( IsEndless, IsEndless() ) - DEFINE_METHOD( IsNonstop, IsNonstop() ) - DEFINE_METHOD( IsOni, IsOni() ) - static int HasBanner( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBanner() ); return 1; } - static int HasBackground( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBackground() ); return 1; } - DEFINE_METHOD( IsAnEdit, IsAnEdit() ) - static int IsPlayableIn( T* p, lua_State *L ) - { - StepsType st = Enum::Check(L, 1); - lua_pushboolean(L, p->IsPlayableIn( st ) ); - return 1; - } - DEFINE_METHOD( IsRanking, IsRanking() ) - DEFINE_METHOD( AllSongsAreFixed, AllSongsAreFixed() ) - - LunaCourse() - { - ADD_METHOD( GetPlayMode ); - ADD_METHOD( GetDisplayFullTitle ); - ADD_METHOD( GetTranslitFullTitle ); - ADD_METHOD( HasMods ); - ADD_METHOD( HasTimedMods ); - ADD_METHOD( GetCourseType ); - ADD_METHOD( GetCourseEntry ); - ADD_METHOD( GetCourseEntries ); - ADD_METHOD( GetAllTrails ); - ADD_METHOD( GetBannerPath ); - ADD_METHOD( GetBackgroundPath ); - ADD_METHOD( GetCourseDir ); - ADD_METHOD( GetGroupName ); - ADD_METHOD( IsAutogen ); - ADD_METHOD( GetEstimatedNumStages ); - ADD_METHOD( GetScripter ); - ADD_METHOD( GetDescription ); - ADD_METHOD( GetTotalSeconds ); - ADD_METHOD( IsEndless ); - ADD_METHOD( IsNonstop ); - ADD_METHOD( IsOni ); - ADD_METHOD( HasBanner ); - ADD_METHOD( HasBackground ); - ADD_METHOD( IsAnEdit ); - ADD_METHOD( IsPlayableIn ); - ADD_METHOD( IsRanking ); - ADD_METHOD( AllSongsAreFixed ); - } -}; - -LUA_REGISTER_CLASS( Course ) -// lua end - - -/* - * (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. - */ diff --git a/src/Course.h b/src/Course.h index 39b2f3c360..e69de29bb2 100644 --- a/src/Course.h +++ b/src/Course.h @@ -1,235 +0,0 @@ -#ifndef COURSE_H -#define COURSE_H - -#include "GameConstantsAndTypes.h" -#include "Attack.h" -#include "EnumHelper.h" -#include "Trail.h" -#include "RageTypes.h" -#include "RageUtil_CachedObject.h" -#include "SongUtil.h" -#include "StepsUtil.h" -#include -#include - -struct lua_State; -class Style; -struct Game; - -const int MAX_EDIT_COURSE_TITLE_LENGTH = 16; - -inline PlayMode CourseTypeToPlayMode( CourseType ct ) { return (PlayMode)(PLAY_MODE_NONSTOP+ct); } -inline CourseType PlayModeToCourseType( PlayMode pm ) { return (CourseType)(pm-PLAY_MODE_NONSTOP); } - -enum SongSort -{ - SongSort_Randomize, - SongSort_MostPlays, - SongSort_FewestPlays, - SongSort_TopGrades, - SongSort_LowestGrades, - NUM_SongSort, -}; -/** @brief Loop through the various Song Sorts. */ -#define FOREACH_SongSort( i ) FOREACH_ENUM( SongSort, i ) -const RString& SongSortToString( SongSort ss ); -const RString& SongSortToLocalizedString( SongSort ss ); - -class CourseEntry -{ -public: - bool bSecret; // show "??????" instead of an exact song - - // filter criteria, applied from top to bottom - SongID songID; // don't filter if unset - SongCriteria songCriteria; - StepsCriteria stepsCriteria; - bool bNoDifficult; // if true, CourseDifficulty doesn't affect this entry - - SongSort songSort; // sort by this after filtering - int iChooseIndex; // - - RString sModifiers; // set player and song options using these - AttackArray attacks; // timed sModifiers - 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 - - CourseEntry(): bSecret(false), songID(), songCriteria(), - stepsCriteria(), bNoDifficult(false), - songSort(SongSort_Randomize), iChooseIndex(0), - sModifiers(RString("")), attacks(), fGainSeconds(0), - iGainLives(-1) {} - - bool IsFixedSong() const { return songID.IsValid(); } - - RString GetTextDescription() const; - int GetNumModChanges() const; - - // Lua - void PushSelf( lua_State *L ); -}; - -/** @brief A queue of songs and notes. */ -class Course -{ -public: - Course(); - - RString GetBannerPath() const; - RString GetBackgroundPath() const; - bool HasBanner() const; - bool HasBackground() const; - - /* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below. - * Otherwise, they return the main titles. */ - RString GetDisplayMainTitle() const; - RString GetDisplaySubTitle() const; - - // Returns the transliterated titles, if any; otherwise returns the main titles. - RString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; } - RString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; } - - // "title subtitle" - RString GetDisplayFullTitle() const; - RString GetTranslitFullTitle() const; - - // 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; - void GetTrails( vector &AddTo, StepsType st ) const; - void GetAllTrails( vector &AddTo ) const; - int GetMeter( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const; - bool HasMods() const; - bool HasTimedMods() const; - bool AllSongsAreFixed() const; - const Style *GetCourseStyle( const Game *pGame, int iNumPlayers ) const; - - 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; - - 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; - void SetCourseType( CourseType ct ); - PlayMode GetPlayMode() const; - - bool ShowInDemonstrationAndRanking() const; - - void RevertFromDisk(); - void Init(); - - bool IsRanking() const; - - void UpdateCourseStats( StepsType st ); - - // Call to regenerate Trails with random entries - void RegenerateNonFixedTrails() const; - - void InvalidateTrailCache(); - - // Call when a Song or its Steps are deleted/changed. - void Invalidate( const Song *pStaleSong ); - - void GetAllCachedTrails( vector &out ); - RString GetCacheFilePath() const; - - const CourseEntry *FindFixedSong( const Song *pSong ) const; - - ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; } - void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; } - - bool Matches(const RString &sGroup, const RString &sCourse) const; - - // Lua - void PushSelf( lua_State *L ); - - void CalculateRadarValues(); - - bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; - void GetTrailUnsortedEndless( const vector &entries, Trail &trail, StepsType &st, - CourseDifficulty &cd, RandomGen &rnd, bool &bCourseDifficultyIsSignificant ) const; - bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; - - 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_sScripter; - RString m_sDescription; - - RString m_sBannerPath; - RString m_sBackgroundPath; - RString m_sCDTitlePath; - RString m_sGroupName; - - bool m_bRepeat; // repeat after last song? "Endless" - bool m_bShuffle; - 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 m_vEntries; - - // sorting values - int m_SortOrder_TotalDifficulty; - int m_SortOrder_Ranking; - - ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if wasn't loaded from a profile - - typedef pair CacheEntry; - struct CacheData - { - Trail trail; - bool null; - - CacheData(): trail(), null(false) {} - }; - typedef map TrailCache_t; - mutable TrailCache_t m_TrailCache; - mutable int m_iTrailCacheSeed; - - typedef map RadarCache_t; - RadarCache_t m_RadarCache; - - // Preferred styles: - set m_setStyles; - - CachedObject m_CachedObject; -}; - -#endif - -/* - * (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. - */ diff --git a/src/CourseContentsList.cpp b/src/CourseContentsList.cpp index b320f1f282..e69de29bb2 100644 --- a/src/CourseContentsList.cpp +++ b/src/CourseContentsList.cpp @@ -1,191 +0,0 @@ -#include "global.h" -#include "CourseContentsList.h" -#include "GameConstantsAndTypes.h" -#include "RageLog.h" -#include "Course.h" -#include "Trail.h" -#include "GameState.h" -#include "XmlFile.h" -#include "ActorUtil.h" -#include "RageUtil.h" -#include "Steps.h" - -REGISTER_ACTOR_CLASS( CourseContentsList ); - -CourseContentsList::~CourseContentsList() -{ - FOREACH( Actor *, m_vpDisplay, d ) - delete *d; - m_vpDisplay.clear(); -} - -void CourseContentsList::LoadFromNode( const XNode* pNode ) -{ - int iMaxSongs = 5; - pNode->GetAttrValue( "MaxSongs", iMaxSongs ); - - const XNode *pDisplayNode = pNode->GetChild( "Display" ); - if( pDisplayNode == NULL ) - { - LuaHelpers::ReportScriptErrorFmt("%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str()); - return; - } - - for( int i=0; iSetUseZBuffer( true ); - m_vpDisplay.push_back( pDisplay ); - } - - ActorScroller::LoadFromNode( pNode ); -} - -void CourseContentsList::SetFromGameState() -{ - RemoveAllChildren(); - - if( GAMESTATE->GetMasterPlayerNumber() == PlayerNumber_Invalid ) - return; - const Trail *pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()]; - if( pMasterTrail == NULL ) - return; - unsigned uNumEntriesToShow = pMasterTrail->m_vEntries.size(); - CLAMP( uNumEntriesToShow, 0, m_vpDisplay.size() ); - - for( int i=0; i<(int)uNumEntriesToShow; i++ ) - { - Actor *pDisplay = m_vpDisplay[i]; - SetItemFromGameState( pDisplay, i ); - this->AddChild( pDisplay ); - } - - bool bLoop = pMasterTrail->m_vEntries.size() > uNumEntriesToShow; - - this->SetLoop( bLoop ); - this->Load2(); - this->SetTransformFromHeight( m_vpDisplay[0]->GetUnzoomedHeight() ); - this->EnableMask( m_vpDisplay[0]->GetUnzoomedWidth(), m_vpDisplay[0]->GetUnzoomedHeight() ); - - if( bLoop ) - { - SetPauseCountdownSeconds( 1.5f ); - this->SetDestinationItem( m_vpDisplay.size()+1 ); // loop forever - } -} - -void CourseContentsList::SetItemFromGameState( Actor *pActor, int iCourseEntryIndex ) -{ - const Course *pCourse = GAMESTATE->m_pCurCourse; - - FOREACH_HumanPlayer(pn) - { - const Trail *pTrail = GAMESTATE->m_pCurTrail[pn]; - if( pTrail == NULL - || iCourseEntryIndex >= (int) pTrail->m_vEntries.size() - || iCourseEntryIndex >= (int) pCourse->m_vEntries.size() ) - continue; - - const TrailEntry *te = &pTrail->m_vEntries[iCourseEntryIndex]; - const CourseEntry *ce = &pCourse->m_vEntries[iCourseEntryIndex]; - if( te == NULL ) - continue; - - RString s; - Difficulty dc; - if( te->bSecret ) - { - if( ce == NULL ) - continue; - - int iLow = ce->stepsCriteria.m_iLowMeter; - int iHigh = ce->stepsCriteria.m_iHighMeter; - - bool bLowIsSet = iLow != -1; - bool bHighIsSet = iHigh != -1; - - if( !bLowIsSet && !bHighIsSet ) - { - s = "?"; - } - if( !bLowIsSet && bHighIsSet ) - { - s = ssprintf( ">=%d", iHigh ); - } - else if( bLowIsSet && !bHighIsSet ) - { - s = ssprintf( "<=%d", iLow ); - } - else if( bLowIsSet && bHighIsSet ) - { - if( iLow == iHigh ) - s = ssprintf( "%d", iLow ); - else - s = ssprintf( "%d-%d", iLow, iHigh ); - } - - dc = te->dc; - if( dc == Difficulty_Invalid ) - dc = Difficulty_Edit; - } - else - { - s = ssprintf("%d", te->pSteps->GetMeter()); - dc = te->pSteps->GetDifficulty(); - } - - Message msg("SetSong"); - msg.SetParam( "PlayerNumber", pn ); - msg.SetParam( "Song", te->pSong ); - msg.SetParam( "Steps", te->pSteps ); - msg.SetParam( "Difficulty", dc ); - msg.SetParam( "Meter", s ); - msg.SetParam( "Number", iCourseEntryIndex+1 ); - msg.SetParam( "Modifiers", te->Modifiers ); - msg.SetParam( "Secret", te->bSecret ); - pActor->HandleMessage( msg ); - } -} - -// lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the CourseContentsList. */ -class LunaCourseContentsList: public Luna -{ -public: - static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(); COMMON_RETURN_SELF; } - - LunaCourseContentsList() - { - ADD_METHOD( SetFromGameState ); - } -}; - -LUA_REGISTER_DERIVED_CLASS( CourseContentsList, ActorScroller ) -// lua end - -/* - * (c) 2001-2004 Chris Danford - * 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. - */ diff --git a/src/CourseContentsList.h b/src/CourseContentsList.h index 11faae7443..e69de29bb2 100644 --- a/src/CourseContentsList.h +++ b/src/CourseContentsList.h @@ -1,51 +0,0 @@ -#ifndef COURSE_CONTENTS_LIST_H -#define COURSE_CONTENTS_LIST_H - -#include "ActorScroller.h" -class CourseEntryDisplay; -/** @brief Holds course name and banner. */ -class CourseContentsList : public ActorScroller -{ -public: - ~CourseContentsList(); - virtual CourseContentsList *Copy() const; - - void LoadFromNode( const XNode* pNode ); - - void SetFromGameState(); - - // Lua - void PushSelf( lua_State *L ); - -protected: - void SetItemFromGameState( Actor *pActor, int iCourseEntryIndex ); - - vector m_vpDisplay; -}; - -#endif - -/* - * (c) 2001-2004 Chris Danford - * 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. - */ diff --git a/src/CourseLoaderCRS.cpp b/src/CourseLoaderCRS.cpp index c180775720..e69de29bb2 100644 --- a/src/CourseLoaderCRS.cpp +++ b/src/CourseLoaderCRS.cpp @@ -1,525 +0,0 @@ -#include "global.h" -#include "CourseLoaderCRS.h" -#include "RageLog.h" -#include "Course.h" -#include "RageUtil.h" -#include "SongCacheIndex.h" -#include "PrefsManager.h" -#include "MsdFile.h" -#include "PlayerOptions.h" -#include "SongManager.h" -#include "TitleSubstitution.h" -#include "BannerCache.h" -#include "RageFileManager.h" -#include "CourseWriterCRS.h" -#include "RageUtil.h" -#include "CourseUtil.h" -#include - -/** @brief Edit courses can only be so big before they are rejected. */ -const int MAX_EDIT_COURSE_SIZE_BYTES = 32*1024; // 32KB - -/** @brief The list of difficulty names for courses. */ -const char *g_CRSDifficultyNames[] = -{ - "Beginner", - "Easy", - "Regular", - "Difficult", - "Challenge", - "Edit", -}; - -/** - * @brief Retrieve the course difficulty based on the string name. - * @param s the name of the difficulty. - * @return the course difficulty. - */ -static CourseDifficulty CRSStringToDifficulty( const RString& s ) -{ - FOREACH_ENUM( Difficulty,i) - if( !s.CompareNoCase(g_CRSDifficultyNames[i]) ) - return i; - return Difficulty_Invalid; -} - - -bool CourseLoaderCRS::LoadFromBuffer( const RString &sPath, const RString &sBuffer, Course &out ) -{ - MsdFile msd; - msd.ReadFromString( sBuffer, false ); // don't unescape - return LoadFromMsd( sPath, msd, out, true ); -} - -bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Course &out, bool bFromCache ) -{ - AttackArray attacks; - float fGainSeconds = 0; - for( unsigned i=0; iUserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() ); - continue; - } - out.m_iCustomMeter[cd] = max( StringToInt(sParams[2]), 0 ); - } - } - - else if( sValueName.EqualsNoCase("MODS") ) - { - Attack attack; - float end = -9999; - for( unsigned j = 1; j < sParams.params.size(); ++j ) - { - vector sBits; - split( sParams[j], "=", sBits, false ); - if( sBits.size() < 2 ) - continue; - - Trim( sBits[0] ); - if( !sBits[0].CompareNoCase("TIME") ) - attack.fStartSecond = max( StringToFloat(sBits[1]), 0.0f ); - else if( !sBits[0].CompareNoCase("LEN") ) - attack.fSecsRemaining = StringToFloat( sBits[1] ); - else if( !sBits[0].CompareNoCase("END") ) - end = StringToFloat( sBits[1] ); - else if( !sBits[0].CompareNoCase("MODS") ) - { - attack.sModifiers = sBits[1]; - - if( end != -9999 ) - { - attack.fSecsRemaining = end - attack.fStartSecond; - end = -9999; - } - - if( attack.fSecsRemaining <= 0.0f) - { - LOG->UserLog( "Course file", sPath, "has an attack with a nonpositive length: %s", sBits[1].c_str() ); - attack.fSecsRemaining = 0.0f; - } - - // warn on invalid so we catch typos on load - CourseUtil::WarnOnInvalidMods( attack.sModifiers ); - - attacks.push_back( attack ); - } - else - { - LOG->UserLog( "Course file", sPath, "has an unexpected value named '%s'", sBits[0].c_str() ); - } - } - - } - else if( sValueName.EqualsNoCase("SONG") ) - { - CourseEntry new_entry; - - // infer entry::Type from the first param - // todo: make sure these aren't generating bogus entries due - // to a lack of songs. -aj - int iNumSongs = SONGMAN->GetNumSongs(); - // most played - if( sParams[1].Left(strlen("BEST")) == "BEST" ) - { - int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1; - if( iChooseIndex > iNumSongs ) - { - // looking up a song that doesn't exist. - LOG->UserLog( "Course file", sPath, "is trying to load BEST%i with only %i songs installed. " - "This entry will be ignored.", iChooseIndex, iNumSongs); - out.m_bIncomplete = true; - continue; // skip this #SONG - } - - new_entry.iChooseIndex = iChooseIndex; - CLAMP( new_entry.iChooseIndex, 0, 500 ); - new_entry.songSort = SongSort_MostPlays; - } - // least played - else if( sParams[1].Left(strlen("WORST")) == "WORST" ) - { - int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1; - if( iChooseIndex > iNumSongs ) - { - // looking up a song that doesn't exist. - LOG->UserLog( "Course file", sPath, "is trying to load WORST%i with only %i songs installed. " - "This entry will be ignored.", iChooseIndex, iNumSongs); - out.m_bIncomplete = true; - continue; // skip this #SONG - } - - new_entry.iChooseIndex = iChooseIndex; - CLAMP( new_entry.iChooseIndex, 0, 500 ); - new_entry.songSort = SongSort_FewestPlays; - } - // best grades - else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" ) - { - new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1; - CLAMP( new_entry.iChooseIndex, 0, 500 ); - new_entry.songSort = SongSort_TopGrades; - } - // worst grades - else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" ) - { - new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1; - CLAMP( new_entry.iChooseIndex, 0, 500 ); - new_entry.songSort = SongSort_LowestGrades; - } - else if( sParams[1] == "*" ) - { - //new_entry.bSecret = true; - } - // group random - else if( sParams[1].Right(1) == "*" ) - { - //new_entry.bSecret = true; - RString sSong = sParams[1]; - sSong.Replace( "\\", "/" ); - vector bits; - split( sSong, "/", bits ); - if( bits.size() == 2 ) - { - new_entry.songCriteria.m_sGroupName = bits[0]; - } - else - { - LOG->UserLog( "Course file", sPath, "contains a random_within_group entry \"%s\" that is invalid. " - "Song should be in the format \"/*\".", sSong.c_str() ); - } - - if( !SONGMAN->DoesSongGroupExist(new_entry.songCriteria.m_sGroupName) ) - { - LOG->UserLog( "Course file", sPath, "random_within_group entry \"%s\" specifies a group that doesn't exist. " - "This entry will be ignored.", sSong.c_str() ); - out.m_bIncomplete = true; - continue; // skip this #SONG - } - } - else - { - RString sSong = sParams[1]; - sSong.Replace( "\\", "/" ); - vector bits; - split( sSong, "/", bits ); - - Song *pSong = NULL; - if( bits.size() == 2 ) - { - new_entry.songCriteria.m_sGroupName = bits[0]; - pSong = SONGMAN->FindSong( bits[0], bits[1] ); - } - else if( bits.size() == 1 ) - { - pSong = SONGMAN->FindSong( "", sSong ); - } - new_entry.songID.FromSong( pSong ); - - if( pSong == NULL ) - { - LOG->UserLog( "Course file", sPath, "contains a fixed song entry \"%s\" that does not exist. " - "This entry will be ignored.", sSong.c_str()); - out.m_bIncomplete = true; - continue; // skip this #SONG - } - } - - new_entry.stepsCriteria.m_difficulty = OldStyleStringToDifficulty( sParams[2] ); - //most CRS files use old-style difficulties, but Difficulty enum values can be used in SM5. Test for those too. - if( new_entry.stepsCriteria.m_difficulty == Difficulty_Invalid ) - new_entry.stepsCriteria.m_difficulty = StringToDifficulty( sParams[2] ); - if( new_entry.stepsCriteria.m_difficulty == Difficulty_Invalid ) - { - int retval = sscanf( sParams[2], "%d..%d", &new_entry.stepsCriteria.m_iLowMeter, &new_entry.stepsCriteria.m_iHighMeter ); - if( retval == 1 ) - new_entry.stepsCriteria.m_iHighMeter = new_entry.stepsCriteria.m_iLowMeter; - else if( retval != 2 ) - { - LOG->UserLog( "Course file", sPath, "contains an invalid difficulty setting: \"%s\", 3..6 used instead", - sParams[2].c_str() ); - new_entry.stepsCriteria.m_iLowMeter = 3; - new_entry.stepsCriteria.m_iHighMeter = 6; - } - new_entry.stepsCriteria.m_iLowMeter = max( new_entry.stepsCriteria.m_iLowMeter, 1 ); - new_entry.stepsCriteria.m_iHighMeter = max( new_entry.stepsCriteria.m_iHighMeter, new_entry.stepsCriteria.m_iLowMeter ); - } - - { - // If "showcourse" or "noshowcourse" is in the list, force - // new_entry.secret on or off. - vector mods; - split( sParams[3], ",", mods, true ); - for( int j = (int) mods.size()-1; j >= 0 ; --j ) - { - RString &sMod = mods[j]; - TrimLeft( sMod ); - TrimRight( sMod ); - if( !sMod.CompareNoCase("showcourse") ) - new_entry.bSecret = false; - else if( !sMod.CompareNoCase("noshowcourse") ) - new_entry.bSecret = true; - else if( !sMod.CompareNoCase("nodifficult") ) - new_entry.bNoDifficult = true; - else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") ) - new_entry.iGainLives = StringToInt( sMod.substr(5) ); - else - continue; - mods.erase( mods.begin() + j ); - } - new_entry.sModifiers = join( ",", mods ); - } - - new_entry.attacks = attacks; - new_entry.fGainSeconds = fGainSeconds; - attacks.clear(); - - out.m_vEntries.push_back( new_entry ); - } - else if( !sValueName.EqualsNoCase("DISPLAYCOURSE") || !sValueName.EqualsNoCase("COMBO") || - !sValueName.EqualsNoCase("COMBOMODE") ) - { - // Ignore - } - - else if( bFromCache && !sValueName.EqualsNoCase("RADAR") ) - { - StepsType st = (StepsType) StringToInt(sParams[1]); - CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] ); - - RadarValues rv; - rv.FromString( sParams[3] ); - out.m_RadarCache[Course::CacheEntry(st, cd)] = rv; - } - else if( sValueName.EqualsNoCase("STYLE") ) - { - RString sStyles = sParams[1]; - vector asStyles; - split( sStyles, ",", asStyles ); - FOREACH( RString, asStyles, s ) - out.m_setStyles.insert( *s ); - - } - else - { - LOG->UserLog( "Course file", sPath, "contains an unexpected value named \"%s\"", sValueName.c_str() ); - } - } - - if( out.m_sBannerPath.empty() ) - { - const RString sFName = SetExtension( out.m_sPath, "" ); - - vector arrayPossibleBanners; - GetDirListing( sFName + "*.png", arrayPossibleBanners, false, false ); - GetDirListing( sFName + "*.jpg", arrayPossibleBanners, false, false ); - GetDirListing( sFName + "*.jpeg", arrayPossibleBanners, false, false ); - GetDirListing( sFName + "*.bmp", arrayPossibleBanners, false, false ); - GetDirListing( sFName + "*.gif", arrayPossibleBanners, false, false ); - if( !arrayPossibleBanners.empty() ) - out.m_sBannerPath = arrayPossibleBanners[0]; - } - - static TitleSubst tsub("Courses"); - - TitleFields title; - title.Title = out.m_sMainTitle; - title.TitleTranslit = out.m_sMainTitleTranslit; - tsub.Subst( title ); - out.m_sMainTitle = title.Title; - out.m_sMainTitleTranslit = title.TitleTranslit; - - /* Cache and load the course banner. Only bother doing this if at least one - * song was found in the course. */ - if( out.m_vEntries.empty() ) - return true; - if( out.m_sBannerPath != "" ) - BANNERCACHE->CacheBanner( out.GetBannerPath() ); - - /* Cache each trail RadarValues that's slow to load, so we - * don't have to do it at runtime. */ - if( !bFromCache ) - out.CalculateRadarValues(); - - return true; -} - -bool CourseLoaderCRS::LoadFromCRSFile( const RString &_sPath, Course &out ) -{ - RString sPath = _sPath; - - out.Init(); - - out.m_sPath = sPath; // save path - - // save group name - { - vector parts; - split( sPath, "/", parts, false ); - if( parts.size() >= 4 ) // e.g. "/Courses/blah/fun.crs" - out.m_sGroupName = parts[parts.size()-2]; - } - - - bool bUseCache = true; - { - /* First look in the cache for this course. Don't bother honoring - * FastLoad for checking the course hash, since courses are normally - * grouped into a few directories, not one directory per course. */ - unsigned uHash = SONGINDEX->GetCacheHash( out.m_sPath ); - if( !DoesFileExist(out.GetCacheFilePath()) ) - bUseCache = false; - // XXX: if !FastLoad, regen cache if the used songs have changed - if( !PREFSMAN->m_bFastLoad && GetHashForFile(out.m_sPath) != uHash ) - bUseCache = false; // this cache is out of date - } - - if( bUseCache ) - { - RString sCacheFile = out.GetCacheFilePath(); - LOG->Trace( "CourseLoaderCRS::LoadFromCRSFile(\"%s\") (\"%s\")", sPath.c_str(), sCacheFile.c_str() ); - sPath = sCacheFile; - } - else - { - LOG->Trace( "CourseLoaderCRS::LoadFromCRSFile(\"%s\")", sPath.c_str() ); - } - - MsdFile msd; - if( !msd.ReadFile( sPath, false ) ) // don't unescape - { - LOG->UserLog( "Course file", sPath, "couldn't be opened: %s.", msd.GetError().c_str() ); - return false; - } - - if( !LoadFromMsd(sPath, msd, out, bUseCache) ) - return false; - - if( !bUseCache ) - { - // If we have any cache data, write the cache file. - if( out.m_RadarCache.size() ) - { - RString sCachePath = out.GetCacheFilePath(); - if( CourseWriterCRS::Write(out, sCachePath, true) ) - SONGINDEX->AddCacheIndex( out.m_sPath, GetHashForFile(out.m_sPath) ); - } - } - - return true; -} - -bool CourseLoaderCRS::LoadEditFromFile( const RString &sEditFilePath, ProfileSlot slot ) -{ - LOG->Trace( "CourseLoaderCRS::LoadEdit(%s)", sEditFilePath.c_str() ); - - int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath ); - if( iBytes > MAX_EDIT_COURSE_SIZE_BYTES ) - { - LOG->UserLog( "Edit file", sEditFilePath, "is unreasonably large. It won't be loaded." ); - return false; - } - - MsdFile msd; - if( !msd.ReadFile( sEditFilePath, false ) ) // don't unescape - { - LOG->UserLog( "Edit file", sEditFilePath, "couldn't be opened: %s", msd.GetError().c_str() ); - return false; - } - Course *pCourse = new Course; - - pCourse->m_sPath = sEditFilePath; - LoadFromMsd( sEditFilePath, msd, *pCourse, true ); - - pCourse->m_LoadedFromProfile = slot; - - SONGMAN->AddCourse( pCourse ); - return true; -} - -bool CourseLoaderCRS::LoadEditFromBuffer( const RString &sBuffer, const RString &sPath, ProfileSlot slot ) -{ - Course *pCourse = new Course; - if( !LoadFromBuffer(sPath, sBuffer, *pCourse) ) - { - delete pCourse; - return false; - } - - pCourse->m_LoadedFromProfile = slot; - - SONGMAN->AddCourse( pCourse ); - return true; -} - - -/* - * (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. - */ diff --git a/src/CourseLoaderCRS.h b/src/CourseLoaderCRS.h index 5bf8db4369..e69de29bb2 100644 --- a/src/CourseLoaderCRS.h +++ b/src/CourseLoaderCRS.h @@ -1,81 +0,0 @@ -/** @brief CourseLoaderCRS - Reads a Course from an .CRS file. */ - -#ifndef COURSE_LOADER_CRS_H -#define COURSE_LOADER_CRS_H - -#include "GameConstantsAndTypes.h" -class Course; -class MsdFile; - -/** @brief The Course Loader handles parsing the .crs files. */ -namespace CourseLoaderCRS -{ - /** - * @brief Attempt to load a course file from a particular path. - * @param sPath the path to the file. - * @param out the course file. - * @return its success or failure. - */ - bool LoadFromCRSFile( const RString &sPath, Course &out ); - /** - * @brief Attempt to load the course information from the msd context. - * @param sPath the path to the file. - * @param msd the MSD context. - * @param out the course file. - * @param bFromCache true if loading from the cache area. - * @return its success or failure. - */ - bool LoadFromMsd( const RString &sPath, const MsdFile &msd, Course &out, bool bFromCache ); - /** - * @brief Attempt to load the course file from the buffer. - * @param sPath the path to the file. - * @param sBuffer the path to the buffer. - * @param out the course file. - * @return its success or failure. - */ - bool LoadFromBuffer( const RString &sPath, const RString &sBuffer, Course &out ); - /** - * @brief Attempt to load an edit course from the hard drive. - * @param sEditFilePath a path on the hard drive to check. - * @param slot the Profile of the user with the edit course. - * @return its success or failure. - */ - bool LoadEditFromFile( const RString &sEditFilePath, ProfileSlot slot ); - /** - * @brief Attempt to load an edit course from the buffer. - * @param sBuffer the path to the buffer. - * @param sPath the path to the file. - * @param slot the individual's profile. - * @return its success or failure. - */ - bool LoadEditFromBuffer( const RString &sBuffer, const RString &sPath, ProfileSlot slot ); -} - -#endif - -/** - * @file - * @author Chris Danford (c) 2001-2004 - * @section LICENSE - * 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. - */ diff --git a/src/CourseUtil.cpp b/src/CourseUtil.cpp index 92d5d5b1f3..e69de29bb2 100644 --- a/src/CourseUtil.cpp +++ b/src/CourseUtil.cpp @@ -1,640 +0,0 @@ -#include "global.h" -#include "CourseUtil.h" -#include "Course.h" -#include "RageTimer.h" -#include "ProfileManager.h" -#include "Profile.h" -#include "SongManager.h" -#include "XmlFile.h" -#include "GameState.h" -#include "Style.h" -#include "Foreach.h" -#include "GameState.h" -#include "LocalizedString.h" -#include "RageLog.h" -#include "arch/Dialog/Dialog.h" -#include "RageFileManager.h" -#include "CourseWriterCRS.h" - -// Sorting stuff -static bool CompareCoursePointersByName( const Course* pCourse1, const Course* pCourse2 ) -{ - RString sName1 = pCourse1->GetDisplayFullTitle(); - RString sName2 = pCourse2->GetDisplayFullTitle(); - return sName1.CompareNoCase( sName2 ) < 0; -} - -static bool CompareCoursePointersByAutogen( const Course* pCourse1, const Course* pCourse2 ) -{ - int b1 = pCourse1->m_bIsAutogen; - int b2 = pCourse2->m_bIsAutogen; - if( b1 < b2 ) - return true; - else if( b1 > b2 ) - return false; - else - return CompareCoursePointersByName(pCourse1,pCourse2); -} - -static bool CompareCoursePointersByDifficulty( const Course* pCourse1, const Course* pCourse2 ) -{ - int iNum1 = pCourse1->GetEstimatedNumStages(); - int iNum2 = pCourse2->GetEstimatedNumStages(); - if( iNum1 < iNum2 ) - return true; - else if( iNum1 > iNum2 ) - return false; - else // iNum1 == iNum2 - return CompareCoursePointersByAutogen( pCourse1, pCourse2 ); -} - -static bool CompareCoursePointersByTotalDifficulty( const Course* pCourse1, const Course* pCourse2 ) -{ - int iNum1 = pCourse1->m_SortOrder_TotalDifficulty; - int iNum2 = pCourse2->m_SortOrder_TotalDifficulty; - - if( iNum1 == iNum2 ) - return CompareCoursePointersByAutogen( pCourse1, pCourse2 ); - return iNum1 < iNum2; -} - -static bool MovePlayersBestToEnd( const Course* pCourse1, const Course* pCourse2 ) -{ - bool C1HasBest = pCourse1->CourseHasBestOrWorst(); - bool C2HasBest = pCourse2->CourseHasBestOrWorst(); - if( !C1HasBest && !C2HasBest ) - return false; - if( C1HasBest && !C2HasBest ) - return false; - if( !C1HasBest && C2HasBest ) - return true; - - return CompareCoursePointersByName( pCourse1, pCourse2 ); -} - -static bool CompareRandom( const Course* pCourse1, const Course* pCourse2 ) -{ - return ( pCourse1->AllSongsAreFixed() && !pCourse2->AllSongsAreFixed() ); -} - -static bool CompareCoursePointersByRanking( const Course* pCourse1, const Course* pCourse2 ) -{ - int iNum1 = pCourse1->m_SortOrder_Ranking; - int iNum2 = pCourse2->m_SortOrder_Ranking; - - if( iNum1 == iNum2 ) - return CompareCoursePointersByAutogen( pCourse1, pCourse2 ); - return iNum1 < iNum2; -} - -void CourseUtil::SortCoursePointerArrayByDifficulty( vector &vpCoursesInOut ) -{ - sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByDifficulty ); -} - -void CourseUtil::SortCoursePointerArrayByRanking( vector &vpCoursesInOut ) -{ - for( unsigned i=0; iUpdateCourseStats( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType ); - sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByRanking ); -} - -void CourseUtil::SortCoursePointerArrayByTotalDifficulty( vector &vpCoursesInOut ) -{ - for( unsigned i=0; iUpdateCourseStats( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType ); - sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByTotalDifficulty ); -} - -// this code isn't ready yet!! -#if 0 -RString GetSectionNameFromCourseAndSort( const Course *pCourse, SortOrder so ) -{ - if( pCourse == NULL ) - return RString(); - // more code here -} - -void SortCoursePointerArrayBySectionName( vector &vpCoursesInOut, SortOrder so ) -{ - RString sOther = SORT_OTHER.GetValue(); - for(unsigned i = 0; i < vpCoursesInOut.size(); ++i) - { - RString val = GetSectionNameFromCourseAndSort( vpCoursesInOut[i], so ); - - /* Make sure 0-9 comes first and OTHER comes last. */ - if( val == "0-9" ) val = "0"; - else if( val == sOther ) val = "2"; - else val = "1" + MakeSortString(val); - - //g_mapSongSortVal[vpSongsInOut[i]] = val; - } -} -#endif -// ok real code begins again - -static bool CompareCoursePointersByType( const Course* pCourse1, const Course* pCourse2 ) -{ - return pCourse1->GetPlayMode() < pCourse2->GetPlayMode(); -} - -void CourseUtil::SortCoursePointerArrayByType( vector &vpCoursesInOut ) -{ - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByType ); -} - -void CourseUtil::MoveRandomToEnd( vector &vpCoursesInOut ) -{ - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareRandom ); -} - -static map course_sort_val; - -bool CompareCoursePointersBySortValueAscending( const Course *pSong1, const Course *pSong2 ) -{ - return course_sort_val[pSong1] < course_sort_val[pSong2]; -} - -bool CompareCoursePointersBySortValueDescending( const Course *pSong1, const Course *pSong2 ) -{ - return course_sort_val[pSong1] > course_sort_val[pSong2]; -} - -bool CompareCoursePointersByTitle( const Course *pCourse1, const Course *pCourse2 ) -{ - return CompareCoursePointersByName( pCourse1, pCourse2 ); -} - -void CourseUtil::SortCoursePointerArrayByTitle( vector &vpCoursesInOut ) -{ - sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByTitle ); -} - -void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector &vpCoursesInOut ) -{ - RageTimer foo; - course_sort_val.clear(); - for( unsigned i = 0; i < vpCoursesInOut.size(); ++i ) - { - int iMeter = vpCoursesInOut[i]->GetMeter( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, Difficulty_Medium ); - course_sort_val[vpCoursesInOut[i]] = ssprintf( "%06i", iMeter ); - } - sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByTitle ); - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending ); - - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), MovePlayersBestToEnd ); -} - -void CourseUtil::SortCoursePointerArrayByNumPlays( vector &vpCoursesInOut, ProfileSlot slot, bool bDescending ) -{ - if( !PROFILEMAN->IsPersistentProfile(slot) ) - return; // nothing to do since we don't have data - Profile* pProfile = PROFILEMAN->GetProfile(slot); - SortCoursePointerArrayByNumPlays( vpCoursesInOut, pProfile, bDescending ); -} - -void CourseUtil::SortCoursePointerArrayByNumPlays( vector &vpCoursesInOut, const Profile* pProfile, bool bDescending ) -{ - ASSERT( pProfile != NULL ); - for(unsigned i = 0; i < vpCoursesInOut.size(); ++i) - course_sort_val[vpCoursesInOut[i]] = ssprintf( "%09i", pProfile->GetCourseNumTimesPlayed(vpCoursesInOut[i]) ); - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), bDescending ? CompareCoursePointersBySortValueDescending : CompareCoursePointersBySortValueAscending ); - course_sort_val.clear(); -} - -void CourseUtil::SortByMostRecentlyPlayedForMachine( vector &vpCoursesInOut ) -{ - Profile *pProfile = PROFILEMAN->GetMachineProfile(); - - FOREACH_CONST( Course*, vpCoursesInOut, c ) - { - int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( *c ); - RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(*c).GetString() : "9999999999999"; - course_sort_val[*c] = val; - } - - stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending ); - course_sort_val.clear(); -} - -void CourseUtil::MakeDefaultEditCourseEntry( CourseEntry& out ) -{ - out.songID.FromSong( GAMESTATE->GetDefaultSong() ); - out.stepsCriteria.m_difficulty = Difficulty_Medium; -} - -////////////////////////////////// -// Autogen -////////////////////////////////// - -void CourseUtil::AutogenEndlessFromGroup( const RString &sGroupName, Difficulty diff, Course &out ) -{ - out.m_bIsAutogen = true; - out.m_bRepeat = true; - out.m_bShuffle = true; - out.m_iLives = -1; - FOREACH_ENUM( Difficulty,dc) - out.m_iCustomMeter[dc] = -1; - - if( sGroupName == "" ) - { - out.m_sMainTitle = "All Songs"; - // this sounds reasonable... -aj - out.m_sBannerPath = THEME->GetPathG("Banner","all music"); - } - else - { - out.m_sMainTitle = SONGMAN->ShortenGroupName( sGroupName ); - out.m_sBannerPath = SONGMAN->GetSongGroupBannerPath( sGroupName ); - } - - // We want multiple songs, so we can try to prevent repeats during - // gameplay. (We might still get a repeat at the repeat boundary, - // but that'd be rare.) -glenn - CourseEntry e; - e.songCriteria.m_sGroupName = sGroupName; - e.stepsCriteria.m_difficulty = diff; - e.bSecret = true; - - // Insert a copy of e for each song in the group. - out.m_vEntries.insert( out.m_vEntries.end(), SONGMAN->GetSongs(sGroupName).size(), e ); -} - -void CourseUtil::AutogenNonstopFromGroup( const RString &sGroupName, Difficulty diff, Course &out ) -{ - AutogenEndlessFromGroup( sGroupName, diff, out ); - - out.m_bRepeat = false; - - out.m_sMainTitle += " Random"; - - // resize to 4 - while( out.m_vEntries.size() < 4 ) - out.m_vEntries.push_back( out.m_vEntries[0] ); - while( out.m_vEntries.size() > 4 ) - out.m_vEntries.pop_back(); -} - -void CourseUtil::AutogenOniFromArtist( const RString &sArtistName, RString sArtistNameTranslit, vector aSongs, Difficulty dc, Course &out ) -{ - out.m_bIsAutogen = true; - out.m_bRepeat = false; - out.m_bShuffle = true; - out.m_bSortByMeter = true; - - out.m_iLives = 4; - FOREACH_ENUM( Difficulty,cd) - out.m_iCustomMeter[cd] = -1; - - ASSERT( sArtistName != "" ); - ASSERT( aSongs.size() > 0 ); - - /* "Artist Oni" is a little repetitive; "by Artist" stands out less, and - * lowercasing "by" puts more emphasis on the artist's name. It also sorts - * them together. */ - out.m_sMainTitle = "by " + sArtistName; - if( sArtistNameTranslit != sArtistName ) - out.m_sMainTitleTranslit = "by " + sArtistNameTranslit; - - // How would we handle Artist Oni course banners, anyways? -aj - // m_sBannerPath = ""; // XXX - - /* Shuffle the list to determine which songs we'll use. Shuffle it - * deterministically, so we always get the same set of songs unless the - * song set changes. */ - { - RandomGen rng( GetHashForString( sArtistName ) + aSongs.size() ); - std::shuffle( aSongs.begin(), aSongs.end(), rng ); - } - - // Only use up to four songs. - if( aSongs.size() > 4 ) - aSongs.erase( aSongs.begin()+4, aSongs.end() ); - - CourseEntry e; - e.stepsCriteria.m_difficulty = dc; - - for( unsigned i = 0; i < aSongs.size(); ++i ) - { - e.songID.FromSong( aSongs[i] ); - out.m_vEntries.push_back( e ); - } -} - -void CourseUtil::WarnOnInvalidMods( const RString &sMods ) -{ - PlayerOptions po; - SongOptions so; - vector vs; - split( sMods, ",", vs, true ); - FOREACH_CONST( RString, vs, s ) - { - bool bValid = false; - RString sErrorDetail; - bValid |= po.FromOneModString( *s, sErrorDetail ); - bValid |= so.FromOneModString( *s, sErrorDetail ); - /* ==Invalid options that used to be valid== - * all noteskins (solo, note, foon, &c.) - * protiming (done in Lua now) - * ==Things I've seen in real course files== - * 900% BRINK (damnit japan) - * TISPY - * 9000% OVERCOMING (what?) - * 9200% TORNADE (it's like a grenade but a tornado) - * 50% PROTIMING (HOW THE HELL DOES 50% PROTIMING EVEN WORK) - * BREAK - */ - if( !bValid ) - { - RString sFullError = ssprintf("Error processing '%s' in '%s'", (*s).c_str(), sMods.c_str() ); - if( !sErrorDetail.empty() ) - sFullError += ": " + sErrorDetail; - LOG->UserLog( "", "", "%s", sFullError.c_str() ); - Dialog::OK( sFullError, "INVALID_PLAYER_OPTION_WARNING" ); - } - } -} - -int EditCourseUtil::MAX_NAME_LENGTH = 16; -int EditCourseUtil::MAX_PER_PROFILE = 32; -int EditCourseUtil::MIN_WORKOUT_MINUTES = 4; -int EditCourseUtil::MAX_WORKOUT_MINUTES = 90; -bool EditCourseUtil::s_bNewCourseNeedsName = false; - -bool EditCourseUtil::Save( Course *pCourse ) -{ - return EditCourseUtil::RenameAndSave( pCourse, pCourse->GetDisplayFullTitle() ); -} - -bool EditCourseUtil::RenameAndSave( Course *pCourse, RString sNewName ) -{ - ASSERT( !sNewName.empty() ); - - EditCourseUtil::s_bNewCourseNeedsName = false; - - RString sNewFilePath; - if( pCourse->IsAnEdit() ) - { - sNewFilePath = PROFILEMAN->GetProfileDir(ProfileSlot_Machine) + EDIT_COURSES_SUBDIR + sNewName + ".crs"; - } - else - { - RString sDir, sName, sExt; - splitpath( pCourse->m_sPath, sDir, sName, sExt ); - sNewFilePath = sDir + sNewName + sExt; - } - - // remove the old file if the name is changing - if( !pCourse->m_sPath.empty() && sNewFilePath != pCourse->m_sPath ) - FILEMAN->Remove( pCourse->m_sPath ); // not fatal if this fails - - pCourse->m_sMainTitle = sNewName; - pCourse->m_sPath = sNewFilePath; - return CourseWriterCRS::Write( *pCourse, pCourse->m_sPath, false ); -} - -bool EditCourseUtil::RemoveAndDeleteFile( Course *pCourse ) -{ - if( !FILEMAN->Remove( pCourse->m_sPath ) ) - return false; - FILEMAN->Remove( pCourse->GetCacheFilePath() ); - if( pCourse->IsAnEdit() ) - { - PROFILEMAN->LoadMachineProfile(); - } - else - { - SONGMAN->DeleteCourse( pCourse ); - delete pCourse; - } - return true; -} - -static LocalizedString YOU_MUST_SUPPLY_NAME ( "CourseUtil", "You must supply a name for your course." ); -static LocalizedString EDIT_NAME_CONFLICTS ( "CourseUtil", "The name you chose conflicts with another course. Please use a different name." ); -static LocalizedString EDIT_NAME_CANNOT_CONTAIN ( "CourseUtil", "The course name cannot contain any of the following characters: %s" ); -bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut ) -{ - if( sAnswer.empty() ) - { - sErrorOut = YOU_MUST_SUPPLY_NAME; - return false; - } - - static const RString sInvalidChars = "\\/:*?\"<>|"; - if( strpbrk(sAnswer, sInvalidChars) != NULL ) - { - sErrorOut = ssprintf( EDIT_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() ); - return false; - } - - // Check for name conflicts - vector vpCourses; - EditCourseUtil::GetAllEditCourses( vpCourses ); - FOREACH_CONST( Course*, vpCourses, p ) - { - if( GAMESTATE->m_pCurCourse == *p ) - continue; // don't comepare name against ourself - - if( (*p)->GetDisplayFullTitle() == sAnswer ) - { - sErrorOut = EDIT_NAME_CONFLICTS; - return false; - } - } - - return true; -} - -void EditCourseUtil::UpdateAndSetTrail() -{ - ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL ); - StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType; - Trail *pTrail = NULL; - if( GAMESTATE->m_pCurCourse ) - pTrail = GAMESTATE->m_pCurCourse->GetTrailForceRegenCache( st ); - GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); -} - -void EditCourseUtil::PrepareForPlay() -{ - GAMESTATE->m_pCurSong.Set( NULL ); // CurSong will be set if we back out. Set it back to NULL so that ScreenStage won't show the last song. - GAMESTATE->m_PlayMode.Set( PLAY_MODE_ENDLESS ); - GAMESTATE->m_bSideIsJoined[0] = true; - - Course *pCourse = GAMESTATE->m_pCurCourse; -} - -void EditCourseUtil::GetAllEditCourses( vector &vpCoursesOut ) -{ - vector vpCoursesTemp; - SONGMAN->GetAllCourses( vpCoursesTemp, false ); - FOREACH_CONST( Course*, vpCoursesTemp, c ) - { - if( (*c)->GetLoadedFromProfileSlot() != ProfileSlot_Invalid ) - vpCoursesOut.push_back( *c ); - } -} - -void EditCourseUtil::LoadDefaults( Course &out ) -{ - out = Course(); - - // pick a default name - // XXX: Make this localizable - for( int i=0; i<10000; i++ ) - { - out.m_sMainTitle = ssprintf("Workout %d", i+1); - bool bNameInUse = false; - - vector vpCourses; - EditCourseUtil::GetAllEditCourses( vpCourses ); - FOREACH_CONST( Course*, vpCourses, p ) - { - if( out.m_sMainTitle == (*p)->m_sMainTitle ) - { - bNameInUse = true; - break; - } - } - - if( !bNameInUse ) - break; - } - - vector vpSongs; - SONGMAN->GetPreferredSortSongs( vpSongs ); - for( int i=0; i<(int)vpSongs.size() && i<6; i++ ) - { - CourseEntry ce; - ce.songID.FromSong( vpSongs[i] ); - ce.stepsCriteria.m_difficulty = Difficulty_Easy; - out.m_vEntries.push_back( ce ); - } -} - -////////////////////////////////// -// CourseID -////////////////////////////////// - -void CourseID::FromCourse( const Course *p ) -{ - if( p ) - { - if( p->m_bIsAutogen ) - { - sPath = ""; - sFullTitle = p->GetTranslitFullTitle(); - } - else - { - sPath = p->m_sPath; - sFullTitle = ""; - } - } - else - { - sPath = ""; - sFullTitle = ""; - } - - // HACK for backwards compatibility: - // Strip off leading "/". 2005/05/21 file layer changes added a leading slash. - if( sPath.Left(1) == "/" ) - sPath.erase( sPath.begin() ); - - m_Cache.Unset(); -} - -Course *CourseID::ToCourse() const -{ - Course *pCourse = NULL; - if(m_Cache.Get(&pCourse)) - { - return pCourse; - } - if(!sPath.empty()) - { - // HACK for backwards compatibility: - // Re-add the leading "/". 2005/05/21 file layer changes added a leading slash. - RString slash_path = sPath; - if(slash_path.Left(1) != "/") - { - slash_path = "/" + slash_path; - } - - if(pCourse == NULL) - { - pCourse = SONGMAN->GetCourseFromPath(slash_path); - } - } - - if( pCourse == NULL && !sFullTitle.empty() ) - { - pCourse = SONGMAN->GetCourseFromName( sFullTitle ); - } - m_Cache.Set( pCourse ); - - return pCourse; -} - -XNode* CourseID::CreateNode() const -{ - XNode* pNode = new XNode( "Course" );; - - if( !sPath.empty() ) - pNode->AppendAttr( "Path", sPath ); - if( !sFullTitle.empty() ) - pNode->AppendAttr( "FullTitle", sFullTitle ); - - return pNode; -} - -void CourseID::LoadFromNode( const XNode* pNode ) -{ - ASSERT( pNode->GetName() == "Course" ); - sFullTitle = RString(); - sPath = RString(); - if( !pNode->GetAttrValue("Path", sPath) ) - pNode->GetAttrValue( "FullTitle", sFullTitle ); - m_Cache.Unset(); -} - -RString CourseID::ToString() const -{ - if( !sPath.empty() ) - return sPath; - if( !sFullTitle.empty() ) - return sFullTitle; - return RString(); -} - -bool CourseID::IsValid() const -{ - return !sPath.empty() || !sFullTitle.empty(); -} - -/* - * (c) 2001-2004 Chris Danford - * 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. - */ diff --git a/src/CourseUtil.h b/src/CourseUtil.h index d1a4a9189e..e69de29bb2 100644 --- a/src/CourseUtil.h +++ b/src/CourseUtil.h @@ -1,125 +0,0 @@ -#ifndef COURSEUTIL_H -#define COURSEUTIL_H - -#include "GameConstantsAndTypes.h" -#include "Difficulty.h" -#include "RageUtil_CachedObject.h" - -class Course; -class Profile; -class XNode; -class CourseEntry; -class Song; - -bool CompareCoursePointersBySortValueAscending( const Course *pSong1, const Course *pSong2 ); -bool CompareCoursePointersBySortValueDescending( const Course *pSong1, const Course *pSong2 ); -bool CompareCoursePointersByTitle( const Course *pCourse1, const Course *pCourse2 ); - -/** @brief Utility functions that deal with Courses. */ -namespace CourseUtil -{ - void SortCoursePointerArrayByDifficulty( vector &vpCoursesInOut ); - void SortCoursePointerArrayByType( vector &vpCoursesInOut ); - void SortCoursePointerArrayByTitle( vector &vpCoursesInOut ); - void SortCoursePointerArrayByAvgDifficulty( vector &vpCoursesInOut ); - void SortCoursePointerArrayByTotalDifficulty( vector &vpCoursesInOut ); - void SortCoursePointerArrayByRanking( vector &vpCoursesInOut ); - void SortCoursePointerArrayByNumPlays( vector &vpCoursesInOut, ProfileSlot slot, bool bDescending ); - void SortCoursePointerArrayByNumPlays( vector &vpCoursesInOut, const Profile* pProfile, bool bDescending ); - void SortByMostRecentlyPlayedForMachine( vector &vpCoursesInOut ); - // sm-ssc sort additions: - //void SortCoursePointerArrayBySectionName( vector &vpCoursesInOut, SortOrder so ); - - void MoveRandomToEnd( vector &vpCoursesInOut ); - - void MakeDefaultEditCourseEntry( CourseEntry &out ); - - void AutogenEndlessFromGroup( const RString &sGroupName, Difficulty dc, Course &out ); - void AutogenNonstopFromGroup( const RString &sGroupName, Difficulty dc, Course &out ); - void AutogenOniFromArtist( const RString &sArtistName, RString sArtistNameTranslit, vector aSongs, Difficulty dc, Course &out ); - - bool ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut ); - - void WarnOnInvalidMods( const RString &sMods ); - - // sm-ssc additions: - //RString GetSectionNameFromCourseAndSort( const Course *pCourse, SortOrder so ); -}; - -/** @brief Utility functions that deal with Edit Courses. */ -namespace EditCourseUtil -{ - void UpdateAndSetTrail(); - void PrepareForPlay(); - void LoadDefaults( Course &out ); - bool RemoveAndDeleteFile( Course *pCourse ); - bool ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut ); - void GetAllEditCourses( vector &vpCoursesOut ); - bool Save( Course *pCourse ); - bool RenameAndSave( Course *pCourse, RString sName ); - - bool ValidateEditCourseNametName( const RString &sAnswer, RString &sErrorOut ); - - extern int MAX_NAME_LENGTH; - extern int MAX_PER_PROFILE; - extern int MIN_WORKOUT_MINUTES; - extern int MAX_WORKOUT_MINUTES; - - extern bool s_bNewCourseNeedsName; // if true, we are working with a Course that has never been named -}; - - -class CourseID -{ -public: - CourseID(): sPath(""), sFullTitle(""), m_Cache() { Unset(); } - void Unset() { FromCourse(NULL); } - void FromCourse( const Course *p ); - Course *ToCourse() const; - const RString &GetPath() const { return sPath; } - bool operator<( const CourseID &other ) const - { - if (sPath != other.sPath) - return sPath < other.sPath; - return sFullTitle < other.sFullTitle; - } - - XNode* CreateNode() const; - void LoadFromNode( const XNode* pNode ); - RString ToString() const; - bool IsValid() const; - -private: - RString sPath; - RString sFullTitle; - mutable CachedObjectPointer m_Cache; -}; - -#endif - -/** - * @file - * @author Chris Danford (c) 2001-2004 - * @section LICENSE - * 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. - */ diff --git a/src/CourseWriterCRS.cpp b/src/CourseWriterCRS.cpp index 8a52095667..e69de29bb2 100644 --- a/src/CourseWriterCRS.cpp +++ b/src/CourseWriterCRS.cpp @@ -1,207 +0,0 @@ -#include "global.h" -#include "CourseWriterCRS.h" -#include "Course.h" -#include "RageFile.h" -#include "RageLog.h" -#include "RageUtil.h" -#include "Song.h" -#include "RageFileDriverMemory.h" - -/** @brief Load the difficulty names from CourseLoaderCRS. */ -extern const char *g_CRSDifficultyNames[]; // in CourseLoaderCRS - -/** - * @brief Get the string of the course difficulty. - * @param iVal the course difficulty. - * @return the string. - */ -static RString DifficultyToCRSString( CourseDifficulty iVal ) -{ - return g_CRSDifficultyNames[iVal]; -} - -bool CourseWriterCRS::Write( const Course &course, const RString &sPath, bool bSavingCache ) -{ - RageFile f; - if( !f.Open( sPath, RageFile::WRITE ) ) - { - LOG->UserLog( "Course file", sPath, "couldn't be written: %s", f.GetError().c_str() ); - return false; - } - - return CourseWriterCRS::Write( course, f, bSavingCache ); -} - -void CourseWriterCRS::GetEditFileContents( const Course *pCourse, RString &sOut ) -{ - RageFileObjMem mem; - CourseWriterCRS::Write( *pCourse, mem, true ); - sOut = mem.GetString(); -} - -bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavingCache ) -{ - ASSERT( !course.m_bIsAutogen ); - - f.PutLine( ssprintf("#COURSE:%s;", course.m_sMainTitle.c_str()) ); - if( course.m_sMainTitleTranslit != "" ) - f.PutLine( ssprintf("#COURSETRANSLIT:%s;", course.m_sMainTitleTranslit.c_str()) ); - if( course.m_sScripter != "" ) - f.PutLine( ssprintf("#SCRIPTER:%s;", course.m_sScripter.c_str()) ); - if( course.m_bRepeat ) - f.PutLine( "#REPEAT:YES;" ); - if( course.m_iLives != -1 ) - f.PutLine( ssprintf("#LIVES:%i;", course.m_iLives) ); - if( !course.m_sBannerPath.empty() ) - f.PutLine( ssprintf("#BANNER:%s;", course.m_sBannerPath.c_str()) ); - - if( !course.m_setStyles.empty() ) - { - vector asStyles; - asStyles.insert( asStyles.begin(), course.m_setStyles.begin(), course.m_setStyles.end() ); - f.PutLine( ssprintf("#STYLE:%s;", join( ",", asStyles ).c_str()) ); - } - - FOREACH_ENUM( CourseDifficulty,cd ) - { - if( course.m_iCustomMeter[cd] == -1 ) - continue; - f.PutLine( ssprintf("#METER:%s:%i;", DifficultyToCRSString(cd).c_str(), course.m_iCustomMeter[cd]) ); - } - - if( bSavingCache ) - { - f.PutLine( "// cache tags:" ); - - Course::RadarCache_t::const_iterator it; - for( it = course.m_RadarCache.begin(); it != course.m_RadarCache.end(); ++it ) - { - // #RADAR:type:difficulty:value,value,value...; - const Course::CacheEntry &entry = it->first; - StepsType st = entry.first; - CourseDifficulty cd = entry.second; - - vector asRadarValues; - const RadarValues &rv = it->second; - for( int r=0; r < NUM_RadarCategory; r++ ) - asRadarValues.push_back( ssprintf("%.3f", rv[r]) ); - RString sLine = ssprintf( "#RADAR:%i:%i:", st, cd ); - sLine += join( ",", asRadarValues ) + ";"; - f.PutLine( sLine ); - } - f.PutLine( "// end cache tags" ); - } - - for( unsigned i=0; i 0 ) - f.PutLine( ssprintf("#GAINSECONDS:%f;", entry.fGainSeconds) ); - - if( entry.songSort == SongSort_MostPlays && entry.iChooseIndex != -1 ) - { - f.Write( ssprintf( "#SONG:BEST%d", entry.iChooseIndex+1 ) ); - } - else if( entry.songSort == SongSort_FewestPlays && entry.iChooseIndex != -1 ) - { - f.Write( ssprintf( "#SONG:WORST%d", entry.iChooseIndex+1 ) ); - } - else if( entry.songID.ToSong() ) - { - Song *pSong = entry.songID.ToSong(); - const RString &sSong = Basename( pSong->GetSongDir() ); - - f.Write( "#SONG:" ); - if( !entry.songCriteria.m_sGroupName.empty() ) - f.Write( entry.songCriteria.m_sGroupName + '/' ); - f.Write( sSong ); - } - else if( !entry.songCriteria.m_sGroupName.empty() ) - { - f.Write( ssprintf( "#SONG:%s/*", entry.songCriteria.m_sGroupName.c_str() ) ); - } - else - { - f.Write( "#SONG:*" ); - } - - f.Write( ":" ); - if( entry.stepsCriteria.m_difficulty != Difficulty_Invalid ) - f.Write( DifficultyToString(entry.stepsCriteria.m_difficulty) ); - else if( entry.stepsCriteria.m_iLowMeter != -1 && entry.stepsCriteria.m_iHighMeter != -1 ) - f.Write( ssprintf( "%d..%d", entry.stepsCriteria.m_iLowMeter, entry.stepsCriteria.m_iHighMeter ) ); - f.Write( ":" ); - - RString sModifiers = entry.sModifiers; - - if( entry.bSecret ) - { - if( sModifiers != "" ) - sModifiers += ","; - sModifiers += entry.bSecret? "noshowcourse":"showcourse"; - } - - if( entry.bNoDifficult ) - { - if( sModifiers != "" ) - sModifiers += ","; - sModifiers += "nodifficult"; - } - - if( entry.iGainLives > -1 ) - { - if( !sModifiers.empty() ) - sModifiers += ','; - sModifiers += ssprintf( "award%d", entry.iGainLives ); - } - - f.Write( sModifiers ); - - f.PutLine( ";" ); - } - - return true; -} - - -/* - * (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. - */ diff --git a/src/CourseWriterCRS.h b/src/CourseWriterCRS.h index 8a12096658..e69de29bb2 100644 --- a/src/CourseWriterCRS.h +++ b/src/CourseWriterCRS.h @@ -1,68 +0,0 @@ -/** @brief CourseWriterCRS - Writes a Course to an .CRS file. */ - -#ifndef COURSE_WRITER_CRS_H -#define COURSE_WRITER_CRS_H - -class Course; -class RageFileBasic; - -/** @brief The Course Writer handles writing the .crs files. */ -namespace CourseWriterCRS -{ - /** - * @brief Write the course to a file. - * @param course the course contents. - * @param f the file being built. - * @param bSavingCache is true if cache information is being saved as well. - * @return its success or failure. - */ - bool Write( const Course &course, RageFileBasic &f, bool bSavingCache ); - /** - * @brief Write the course to a file. - * @param course the course contents. - * @param sPath the path to the file. - * @param bSavingCache is true if cache information is being saved as well. - * @return its success or failure. - */ - bool Write( const Course &course, const RString &sPath, bool bSavingCache ); - /** - * @brief Retrieve course information from a file for eventual writing. - * @param pCourse the course file. - * @param sOut the path to the file. - */ - void GetEditFileContents( const Course *pCourse, RString &sOut ); - /** - * @brief Write the custom course to the machine's hard drive. - * @param pCourse the course file. - */ - void WriteEditFileToMachine( const Course *pCourse ); -} - -#endif - -/** - * @file - * @author Chris Danford (c) 2001-2005 - * @section LICENSE - * 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. - */ diff --git a/src/Difficulty.cpp b/src/Difficulty.cpp index a651a0c64d..2970846488 100644 --- a/src/Difficulty.cpp +++ b/src/Difficulty.cpp @@ -7,7 +7,6 @@ #include "GameConstantsAndTypes.h" #include "GameManager.h" #include "Steps.h" -#include "Trail.h" static const char *DifficultyNames[] = { "Beginner", @@ -21,32 +20,6 @@ XToString( Difficulty ); StringToX( Difficulty ); LuaXType( Difficulty ); -const RString &CourseDifficultyToLocalizedString( CourseDifficulty x ) -{ - static unique_ptr g_CourseDifficultyName[NUM_Difficulty]; - if( g_CourseDifficultyName[0].get() == NULL ) - { - FOREACH_ENUM( Difficulty,i) - { - unique_ptr ap(new LocalizedString("CourseDifficulty", DifficultyToString(i))); - g_CourseDifficultyName[i] = std::move(ap); - } - } - return g_CourseDifficultyName[x]->GetValue(); -} - -LuaFunction( CourseDifficultyToLocalizedString, CourseDifficultyToLocalizedString(Enum::Check(L, 1)) ); - -CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd ) -{ - for( CourseDifficulty d=(CourseDifficulty)(cd+1); dIsCourseDifficultyShown(d) ) - return d; - } - return Difficulty_Invalid; -} - struct OldStyleStringToDifficultyMapHolder { std::map conversion_map; @@ -90,7 +63,7 @@ LuaFunction( OldStyleStringToDifficulty, OldStyleStringToDifficulty(SArg(1)) ); static ThemeMetric NAMES("CustomDifficulty","Names"); -RString GetCustomDifficulty( StepsType st, Difficulty dc, CourseType ct ) +RString GetCustomDifficulty( StepsType st, Difficulty dc ) { /* XXX GAMEMAN->GetStepsTypeInfo( StepsType_Invalid ) will crash. I'm not * sure what the correct behavior in this case should be. Should we still @@ -122,12 +95,8 @@ RString GetCustomDifficulty( StepsType st, Difficulty dc, CourseType ct ) ThemeMetric DIFFICULTY("CustomDifficulty",(*sName)+"Difficulty"); if( DIFFICULTY == Difficulty_Invalid || dc == DIFFICULTY ) // match { - ThemeMetric COURSE_TYPE("CustomDifficulty",(*sName)+"CourseType"); - if( COURSE_TYPE == CourseType_Invalid || ct == COURSE_TYPE ) // match - { ThemeMetric STRING("CustomDifficulty",(*sName)+"String"); return STRING.GetValue(); - } } } } @@ -137,7 +106,7 @@ RString GetCustomDifficulty( StepsType st, Difficulty dc, CourseType ct ) return DifficultyToString( dc ); } -LuaFunction( GetCustomDifficulty, GetCustomDifficulty(Enum::Check(L,1), Enum::Check(L, 2), Enum::Check(L, 3, true)) ); +LuaFunction( GetCustomDifficulty, GetCustomDifficulty(Enum::Check(L,1), Enum::Check(L, 2)) ); RString CustomDifficultyToLocalizedString( const RString &sCustomDifficulty ) { @@ -149,18 +118,12 @@ LuaFunction( CustomDifficultyToLocalizedString, CustomDifficultyToLocalizedStrin RString StepsToCustomDifficulty( const Steps *pSteps ) { - return GetCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty(), CourseType_Invalid ); -} - -RString TrailToCustomDifficulty( const Trail *pTrail ) -{ - return GetCustomDifficulty( pTrail->m_StepsType, pTrail->m_CourseDifficulty, pTrail->m_CourseType ); + return GetCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty() ); } #include "LuaBinding.h" LuaFunction( StepsToCustomDifficulty, StepsToCustomDifficulty(Luna::check(L, 1)) ); -LuaFunction( TrailToCustomDifficulty, TrailToCustomDifficulty(Luna::check(L, 1)) ); /* * (c) 2001-2004 Chris Danford diff --git a/src/Difficulty.h b/src/Difficulty.h index 2d48263a21..3181225dd1 100644 --- a/src/Difficulty.h +++ b/src/Difficulty.h @@ -4,7 +4,6 @@ #include "EnumHelper.h" #include "GameConstantsAndTypes.h" class Steps; -class Trail; // Player number stuff enum Difficulty @@ -24,24 +23,12 @@ LuaDeclareType( Difficulty ); Difficulty OldStyleStringToDifficulty( const RString& sDC ); // compatibility -typedef Difficulty CourseDifficulty; -const int NUM_CourseDifficulty = NUM_Difficulty; -/** @brief Loop through the shown course difficulties. */ -#define FOREACH_ShownCourseDifficulty( cd ) \ -for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); \ - cd!=Difficulty_Invalid; cd=GetNextShownCourseDifficulty(cd) ) - -const RString& CourseDifficultyToLocalizedString( Difficulty dc ); - -Difficulty GetNextShownCourseDifficulty( Difficulty pn ); - // CustomDifficulty is a themeable difficulty name based on Difficulty, string matching on StepsType, and CourseType. // It is used to look up localized strings and look up colors. -RString GetCustomDifficulty( StepsType st, Difficulty dc, CourseType ct ); +RString GetCustomDifficulty( StepsType st, Difficulty dc); RString CustomDifficultyToLocalizedString( const RString &sCustomDifficulty ); RString StepsToCustomDifficulty( const Steps *pSteps ); -RString TrailToCustomDifficulty( const Trail *pTrail ); #endif diff --git a/src/DifficultyIcon.cpp b/src/DifficultyIcon.cpp index 06e935db9a..478b6daaaf 100644 --- a/src/DifficultyIcon.cpp +++ b/src/DifficultyIcon.cpp @@ -6,7 +6,6 @@ #include "Steps.h" #include "GameState.h" #include "RageDisplay.h" -#include "Trail.h" #include "ActorUtil.h" #include "XmlFile.h" #include "LuaManager.h" @@ -68,15 +67,6 @@ void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps ) SetFromDifficulty( pSteps->GetDifficulty() ); } -void DifficultyIcon::SetFromTrail( PlayerNumber pn, const Trail* pTrail ) -{ - SetPlayer( pn ); - if( pTrail == NULL ) - Unset(); - else - SetFromDifficulty( pTrail->m_CourseDifficulty ); -} - void DifficultyIcon::Unset() { m_bBlank = true; @@ -113,19 +103,6 @@ class LunaDifficultyIcon: public Luna } COMMON_RETURN_SELF; } - static int SetFromTrail( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) - { - p->Unset(); - } - else - { - Trail *pT = Luna::check(L,1); - p->SetFromTrail( PLAYER_1, pT ); - } - COMMON_RETURN_SELF; - } static int Unset( T* p, lua_State *L ) { p->Unset(); COMMON_RETURN_SELF; } static int SetPlayer( T* p, lua_State *L ) { p->SetPlayer( Enum::Check(L, 1) ); COMMON_RETURN_SELF; } static int SetFromDifficulty( T* p, lua_State *L ) { p->SetFromDifficulty( Enum::Check(L, 1) ); COMMON_RETURN_SELF; } @@ -135,7 +112,6 @@ class LunaDifficultyIcon: public Luna ADD_METHOD( Unset ); ADD_METHOD( SetPlayer ); ADD_METHOD( SetFromSteps ); - ADD_METHOD( SetFromTrail ); ADD_METHOD( SetFromDifficulty ); } }; diff --git a/src/DifficultyIcon.h b/src/DifficultyIcon.h index 6f6f0dd310..58c537437a 100644 --- a/src/DifficultyIcon.h +++ b/src/DifficultyIcon.h @@ -8,7 +8,6 @@ #include "GameConstantsAndTypes.h" #include "Difficulty.h" class Steps; -class Trail; class DifficultyIcon : public Sprite @@ -25,7 +24,6 @@ class DifficultyIcon : public Sprite void SetPlayer( PlayerNumber pn ); void Unset(); void SetFromSteps( PlayerNumber pn, const Steps* pSteps ); - void SetFromTrail( PlayerNumber pn, const Trail* pTrail ); void SetFromDifficulty( Difficulty dc ); // Lua diff --git a/src/DifficultyList.cpp b/src/DifficultyList.cpp index 1709f4fc8e..971cb91fee 100644 --- a/src/DifficultyList.cpp +++ b/src/DifficultyList.cpp @@ -277,7 +277,7 @@ void StepsDisplayList::SetFromGameState() FOREACH_CONST( Difficulty, difficulties, d ) { m_Rows[i].m_dc = *d; - m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, *d, CourseType_Invalid ); + m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, *d ); ++i; } } @@ -373,8 +373,7 @@ void StepsDisplayList::HandleMessage( const Message &msg ) { FOREACH_ENUM( PlayerNumber, pn ) { - if( msg.GetName() == MessageIDToString((MessageID)(Message_CurrentStepsP1Changed+pn)) || - msg.GetName() == MessageIDToString((MessageID)(Message_CurrentTrailP1Changed+pn)) ) + if( msg.GetName() == MessageIDToString((MessageID)(Message_CurrentStepsP1Changed+pn))) SetFromGameState(); } diff --git a/src/DifficultyList.h b/src/DifficultyList.h index 0d0817fa91..92d74a82c0 100644 --- a/src/DifficultyList.h +++ b/src/DifficultyList.h @@ -1,4 +1,4 @@ -/* StepsDisplayList - Shows all available difficulties for a Song/Course. */ +/* StepsDisplayList - Shows all available difficulties for a Song */ #ifndef DIFFICULTY_LIST_H #define DIFFICULTY_LIST_H diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index 59249630de..92e9939d1c 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -62,7 +62,6 @@ void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector &vpS switch( mode ) { case EditMode_Practice: - case EditMode_CourseMods: case EditMode_Home: for( int i=vpSongsOut.size()-1; i>=0; i-- ) { @@ -500,7 +499,6 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) switch( mode ) { case EditMode_Full: - case EditMode_CourseMods: case EditMode_Practice: { vector v; @@ -520,8 +518,6 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) switch( mode ) { case EditMode_Practice: - case EditMode_CourseMods: - break; case EditMode_Home: case EditMode_Full: m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit" @@ -542,11 +538,6 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) // don't allow selecting of non-edits in HomeMode break; case EditMode_Practice: - case EditMode_CourseMods: - // only show this difficulty if steps exist - if( pSteps ) - m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) ); - break; case EditMode_Full: // show this difficulty whether or not steps exist. m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) ); @@ -577,7 +568,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } else { - RString s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GetSelectedStepsType(), GetSelectedDifficulty(), CourseType_Invalid ) ); + RString s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GetSelectedStepsType(), GetSelectedDifficulty()) ); m_textValue[ROW_STEPS].SetText( s ); if( GetSelectedSteps() ) @@ -586,7 +577,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } else { - m_StepsDisplay.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GetSelectedSourceStepsType(), 0, GetSelectedDifficulty(), CourseType_Invalid ); + m_StepsDisplay.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GetSelectedSourceStepsType(), 0, GetSelectedDifficulty() ); } } // fall through @@ -646,7 +637,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } else { - s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GetSelectedSourceStepsType(), GetSelectedSourceDifficulty(), CourseType_Invalid ) ); + s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GetSelectedSourceStepsType(), GetSelectedSourceDifficulty() ) ); } m_textValue[ROW_SOURCE_STEPS].SetText( s ); } @@ -656,7 +647,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) else if( GetSelectedSourceSteps() ) m_StepsDisplaySource.SetFromSteps( GetSelectedSourceSteps() ); else - m_StepsDisplaySource.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GetSelectedSourceStepsType(), 0, GetSelectedSourceDifficulty(), CourseType_Invalid ); + m_StepsDisplaySource.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GetSelectedSourceStepsType(), 0, GetSelectedSourceDifficulty() ); m_StepsDisplaySource.SetVisible( !(bHideMeter || GetSelectedSteps()) ); m_Actions.clear(); @@ -671,9 +662,6 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) switch( mode ) { case EditMode_Practice: - case EditMode_CourseMods: - m_Actions.push_back( EditMenuAction_Practice ); - break; case EditMode_Home: case EditMode_Full: m_Actions.push_back( EditMenuAction_Edit ); diff --git a/src/FadingBanner.cpp b/src/FadingBanner.cpp index cd41ceebf3..693d1f8fa5 100644 --- a/src/FadingBanner.cpp +++ b/src/FadingBanner.cpp @@ -4,7 +4,6 @@ #include "BannerCache.h" #include "Song.h" #include "RageLog.h" -#include "Course.h" #include "PrefsManager.h" #include "ThemeManager.h" #include "SongManager.h" @@ -193,22 +192,6 @@ void FadingBanner::LoadFromSongGroup( const RString &sSongGroup ) LoadFromCachedBanner( sGroupBannerPath ); } -void FadingBanner::LoadFromCourse( const Course* pCourse ) -{ - if( pCourse == NULL ) - { - LoadFallback(); - return; - } - - /* Don't call HasBanner. That'll do disk access and cause the music wheel - * to skip. */ - RString sPath = pCourse->GetBannerPath(); - if( sPath.empty() ) - LoadCourseFallback(); - else - LoadFromCachedBanner( sPath ); -} void FadingBanner::LoadIconFromCharacter( Character* pCharacter ) { @@ -248,12 +231,6 @@ void FadingBanner::LoadFallback() m_Banner[m_iIndexLatest].LoadFallback(); } -void FadingBanner::LoadCourseFallback() -{ - BeforeChange(); - m_Banner[m_iIndexLatest].LoadCourseFallback(); -} - void FadingBanner::LoadCustom( const RString &sBanner ) { BeforeChange(); @@ -276,12 +253,6 @@ class LunaFadingBanner: public Luna else { Song *pS = Luna::check(L,1); p->LoadFromSong( pS ); } COMMON_RETURN_SELF; } - static int LoadFromCourse( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->LoadFromCourse( NULL ); } - else { Course *pC = Luna::check(L,1); p->LoadFromCourse( pC ); } - COMMON_RETURN_SELF; - } static int LoadIconFromCharacter( T* p, lua_State *L ) { if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); } @@ -297,7 +268,6 @@ class LunaFadingBanner: public Luna static int LoadFromSongGroup( T* p, lua_State *L ) { p->LoadFromSongGroup( SArg(1) ); COMMON_RETURN_SELF; } static int LoadRandom( T* p, lua_State *L ) { p->LoadRandom(); COMMON_RETURN_SELF; } static int LoadRoulette( T* p, lua_State *L ) { p->LoadRoulette(); COMMON_RETURN_SELF; } - static int LoadCourseFallback( T* p, lua_State *L ) { p->LoadCourseFallback(); COMMON_RETURN_SELF; } static int LoadFallback( T* p, lua_State *L ) { p->LoadFallback(); COMMON_RETURN_SELF; } static int LoadFromSortOrder( T* p, lua_State *L ) { @@ -317,12 +287,10 @@ class LunaFadingBanner: public Luna ADD_METHOD( ScaleToClipped ); ADD_METHOD( LoadFromSong ); ADD_METHOD( LoadFromSongGroup ); - ADD_METHOD( LoadFromCourse ); ADD_METHOD( LoadIconFromCharacter ); ADD_METHOD( LoadCardFromCharacter ); ADD_METHOD( LoadRandom ); ADD_METHOD( LoadRoulette ); - ADD_METHOD( LoadCourseFallback ); ADD_METHOD( LoadFallback ); ADD_METHOD( LoadFromSortOrder ); ADD_METHOD( GetLatestIndex ); diff --git a/src/FadingBanner.h b/src/FadingBanner.h index a54689e346..0741748425 100644 --- a/src/FadingBanner.h +++ b/src/FadingBanner.h @@ -21,14 +21,12 @@ class FadingBanner : public ActorFrame void LoadFromSong( const Song* pSong ); // NULL means no song void LoadMode(); void LoadFromSongGroup( const RString &sSongGroup ); - void LoadFromCourse( const Course* pCourse ); void LoadIconFromCharacter( Character* pCharacter ); void LoadBannerFromUnlockEntry( const UnlockEntry* pUE ); void LoadRoulette(); void LoadRandom(); void LoadFromSortOrder( SortOrder so ); void LoadFallback(); - void LoadCourseFallback(); void LoadCustom( const RString &sBanner ); bool LoadFromCachedBanner( const RString &path ); diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index 3c622ef442..bb7320a9f0 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -38,7 +38,6 @@ void GameCommand::Init() m_pStyle = NULL; m_pm = PlayMode_Invalid; m_dc = Difficulty_Invalid; - m_CourseDifficulty = Difficulty_Invalid; m_sPreferredModifiers = ""; m_sStageModifiers = ""; m_sAnnouncer = ""; @@ -46,8 +45,6 @@ void GameCommand::Init() m_LuaFunction.Unset(); m_pSong = NULL; m_pSteps = NULL; - m_pCourse = NULL; - m_pTrail = NULL; m_pCharacter = NULL; m_SortOrder = SortOrder_Invalid; m_sSoundPath = ""; @@ -128,10 +125,6 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const return false; if( m_pCharacter && GAMESTATE->m_pCurCharacters[pn] != m_pCharacter ) return false; - if( m_pCourse && GAMESTATE->m_pCurCourse.Get() != m_pCourse ) - return false; - if( m_pTrail && GAMESTATE->m_pCurTrail[pn].Get() != m_pTrail ) - return false; if( !m_sSongGroup.empty() && GAMESTATE->m_sPreferredSongGroup != m_sSongGroup ) return false; if( m_SortOrder != SortOrder_Invalid && GAMESTATE->m_PreferredSortOrder != m_SortOrder ) @@ -302,43 +295,6 @@ void GameCommand::LoadOne( const Command& cmd ) } } } - - else if( sName == "course" ) - { - CHECK_INVALID_COND(m_pCourse, SONGMAN->FindCourse("", sValue), - (SONGMAN->FindCourse("", sValue) == NULL), - (ssprintf( "Course \"%s\" not found", sValue.c_str()))); - } - - else if( sName == "trail" ) - { - RString sTrail = sValue; - - // This must be processed after "course" and "style" commands. - if( !m_bInvalid ) - { - Course *pCourse = (m_pCourse != NULL)? m_pCourse:GAMESTATE->m_pCurCourse; - const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()); - if( pCourse == NULL || pStyle == NULL ) - { - MAKE_INVALID("Must set Course and Style to set Trail."); - } - else - { - const CourseDifficulty cd = StringToDifficulty( sTrail ); - if(cd == Difficulty_Invalid) - { - MAKE_INVALID(ssprintf("Invalid difficulty '%s'", sTrail.c_str())); - } - else - { - Trail* tr = pCourse->GetTrail(pStyle->m_StepsType, cd); - CHECK_INVALID_COND(m_pTrail, tr, (tr == NULL), - ("Trail \"" + sTrail + "\" not found.")); - } - } - } - } else if( sName == "setenv" ) { @@ -584,22 +540,7 @@ bool GameCommand::IsPlayable( RString *why ) const } } - if( !m_sScreen.CompareNoCase("ScreenEditCoursesMenu") ) - { - vector vCourses; - SONGMAN->GetAllCourses( vCourses, false ); - - if( vCourses.size() == 0 ) - { - if( why ) - *why = "No courses are installed"; - return false; - } - } - - if( (!m_sScreen.CompareNoCase("ScreenJukeboxMenu") || - !m_sScreen.CompareNoCase("ScreenEditMenu") || - !m_sScreen.CompareNoCase("ScreenEditCoursesMenu")) ) + if( (!m_sScreen.CompareNoCase("ScreenJukeboxMenu") || !m_sScreen.CompareNoCase("ScreenEditMenu") )) { if( SONGMAN->GetNumSongs() == 0 ) { @@ -748,17 +689,6 @@ void GameCommand::ApplySelf( const vector &vpns ) const if( m_pSteps ) FOREACH_CONST( PlayerNumber, vpns, pn ) GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps ); - if( m_pCourse ) - { - GAMESTATE->m_pCurCourse.Set( m_pCourse ); - GAMESTATE->m_pPreferredCourse = m_pCourse; - } - if( m_pTrail ) - FOREACH_CONST( PlayerNumber, vpns, pn ) - GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail ); - if( m_CourseDifficulty != Difficulty_Invalid ) - FOREACH_CONST( PlayerNumber, vpns, pn ) - GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty ); if( m_pCharacter ) FOREACH_CONST( PlayerNumber, vpns, pn ) GAMESTATE->m_pCurCharacters[*pn] = m_pCharacter; @@ -832,17 +762,6 @@ void GameCommand::ApplySelf( const vector &vpns ) const GAMESTATE->GetDefaultSongOptions( so ); GAMESTATE->m_SongOptions.Assign( ModsLevel_Stage, so ); } - // HACK: Set life type to BATTERY just once here so it happens once and - // we don't override the user's changes if they back out. - FOREACH_PlayerNumber(pn) - { - if(GAMESTATE->m_PlayMode == PLAY_MODE_ONI && - GAMESTATE->m_PlayMode != OldPlayMode && - GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetStage().m_LifeType ==LifeType_Bar) - { - PO_GROUP_ASSIGN(GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Stage, m_LifeType, LifeType_Battery); - } - } } bool GameCommand::IsZero() const @@ -855,10 +774,7 @@ bool GameCommand::IsZero() const m_sStageModifiers != "" || m_pSong != NULL || m_pSteps != NULL || - m_pCourse != NULL || - m_pTrail != NULL || m_pCharacter != NULL || - m_CourseDifficulty != Difficulty_Invalid || !m_sSongGroup.empty() || m_SortOrder != SortOrder_Invalid || !m_sProfileID.empty() || @@ -887,8 +803,6 @@ class LunaGameCommand: public Luna static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; } static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; } static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps==NULL) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; } - static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse==NULL) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; } - static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail==NULL) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; } static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter==NULL) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; } static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; } static int GetUrl( T* p, lua_State *L ) { lua_pushstring(L, p->m_sUrl ); return 1; } @@ -896,7 +810,6 @@ class LunaGameCommand: public Luna static int GetPreferredModifiers( T* p, lua_State *L ) { lua_pushstring(L, p->m_sPreferredModifiers ); return 1; } static int GetStageModifiers( T* p, lua_State *L ) { lua_pushstring(L, p->m_sStageModifiers ); return 1; } - DEFINE_METHOD( GetCourseDifficulty, m_CourseDifficulty ) DEFINE_METHOD( GetDifficulty, m_dc ) DEFINE_METHOD( GetPlayMode, m_pm ) DEFINE_METHOD( GetSortOrder, m_SortOrder ) @@ -909,14 +822,11 @@ class LunaGameCommand: public Luna ADD_METHOD( GetMultiPlayer ); ADD_METHOD( GetStyle ); ADD_METHOD( GetDifficulty ); - ADD_METHOD( GetCourseDifficulty ); ADD_METHOD( GetScreen ); ADD_METHOD( GetPlayMode ); ADD_METHOD( GetProfileID ); ADD_METHOD( GetSong ); ADD_METHOD( GetSteps ); - ADD_METHOD( GetCourse ); - ADD_METHOD( GetTrail ); ADD_METHOD( GetCharacter ); ADD_METHOD( GetSongGroup ); ADD_METHOD( GetSortOrder ); diff --git a/src/GameCommand.h b/src/GameCommand.h index 324f22a710..3aa1c769ce 100644 --- a/src/GameCommand.h +++ b/src/GameCommand.h @@ -12,8 +12,6 @@ class Song; class Steps; -class Course; -class Trail; class Character; class Style; struct Game; @@ -30,11 +28,10 @@ class GameCommand m_iIndex(-1), m_MultiPlayer(MultiPlayer_Invalid), m_pStyle(NULL), m_pm(PlayMode_Invalid), m_dc(Difficulty_Invalid), - m_CourseDifficulty(Difficulty_Invalid), m_sAnnouncer(""), m_sPreferredModifiers(""), m_sStageModifiers(""), m_sScreen(""), m_LuaFunction(), - m_pSong(NULL), m_pSteps(NULL), m_pCourse(NULL), - m_pTrail(NULL), m_pCharacter(NULL), m_SetEnv(), m_SetPref(), + m_pSong(NULL), m_pSteps(NULL), + m_pCharacter(NULL), m_SetEnv(), m_SetPref(), m_sSongGroup(""), m_SortOrder(SortOrder_Invalid), m_sSoundPath(""), m_vsScreensToPrepare(), m_sProfileID(""), m_sUrl(""), m_bUrlExits(true), @@ -79,7 +76,6 @@ class GameCommand const Style* m_pStyle; PlayMode m_pm; Difficulty m_dc; - CourseDifficulty m_CourseDifficulty; RString m_sAnnouncer; RString m_sPreferredModifiers; RString m_sStageModifiers; @@ -87,8 +83,6 @@ class GameCommand LuaReference m_LuaFunction; Song* m_pSong; Steps* m_pSteps; - Course* m_pCourse; - Trail* m_pTrail; Character* m_pCharacter; std::map m_SetEnv; std::map m_SetPref; diff --git a/src/GameConstantsAndTypes.cpp b/src/GameConstantsAndTypes.cpp index 250a24f54c..724216793b 100644 --- a/src/GameConstantsAndTypes.cpp +++ b/src/GameConstantsAndTypes.cpp @@ -73,9 +73,6 @@ LuaXType( StepsType ); static const char *PlayModeNames[] = { "Regular", - "Nonstop", - "Oni", - "Endless", "Battle", "Rave", }; @@ -174,11 +171,6 @@ static const char *SortOrderNames[] = { "DoubleHardMeter", "DoubleChallengeMeter", "ModeMenu", - "AllCourses", - "Nonstop", - "Oni", - "Endless", - "Length", "Roulette", "Recent", "Favorites", @@ -456,7 +448,6 @@ LuaXType( StyleType ); static const char *EditModeNames[] = { "Practice", - "CourseMods", "Home", "Full" }; @@ -485,9 +476,6 @@ static const char *StageNames[] = { "Final", "Extra1", "Extra2", - "Nonstop", - "Oni", - "Endless", "Event", "Demo", }; @@ -513,18 +501,6 @@ static const char *MultiPlayerStatusNames[] = { }; XToString( MultiPlayerStatus ); - -static const char *CourseTypeNames[] = { - "Nonstop", - "Oni", - "Endless", - "Survival", -}; -XToString( CourseType ); -XToLocalizedString( CourseType ); -LuaXType( CourseType ); -LuaFunction( CourseTypeToLocalizedString, CourseTypeToLocalizedString( Enum::Check( L, 1 ) ) ); - static const char *FailTypeNames[] = { "Immediate", "ImmediateContinue", diff --git a/src/GameConstantsAndTypes.h b/src/GameConstantsAndTypes.h index 9584462985..b4ff88d625 100644 --- a/src/GameConstantsAndTypes.h +++ b/src/GameConstantsAndTypes.h @@ -136,9 +136,6 @@ LuaDeclareType( StepsType ); enum PlayMode { PLAY_MODE_REGULAR, /**< The normal game mode, often with a set number of stages. */ - PLAY_MODE_NONSTOP, /**< Play a set of songs without stopping. */ - PLAY_MODE_ONI, /**< Similar to Nonstop, only there is also the danger of lives or a clock. */ - PLAY_MODE_ENDLESS, /**< Keep playing until you get a game over. */ PLAY_MODE_BATTLE, /**< Choose when to send attacks to your opponent. */ PLAY_MODE_RAVE, /**< Have attacks launched during play automatically. */ NUM_PlayMode, @@ -165,9 +162,7 @@ PlayMode StringToPlayMode( const RString& s ); LuaDeclareType( PlayMode ); /** - * @brief The list of ways to sort songs and courses. - * - * All song sorts should be listed before course sorts. + * @brief The list of ways to sort songs */ enum SortOrder { @@ -191,12 +186,6 @@ enum SortOrder SORT_DOUBLE_CHALLENGE_METER, /**< Sort by the difficulty of the double challenge meter. */ // SORT_MODE_MENU, /**< Have access to the menu for choosing the sort. */ - // course sorts - SORT_ALL_COURSES, /**< Sort with all courses available. */ - SORT_NONSTOP_COURSES, /**< View only the nonstop courses. */ - SORT_ONI_COURSES, /**< View only the oni/survival courses. */ - SORT_ENDLESS_COURSES, /**< View only the endless courses. */ - SORT_LENGTH, /**< Sort the courses by how long they would last. */ SORT_ROULETTE, SORT_RECENT, SORT_FAVORITES, @@ -560,7 +549,7 @@ struct DisplayBpms */ bool IsSecret() const; /** - * @brief The list of the BPMs for the song or course. + * @brief The list of the BPMs for the song. */ vector vfBpms; }; @@ -583,7 +572,6 @@ LuaDeclareType( StyleType ); enum EditMode { EditMode_Practice, - EditMode_CourseMods, EditMode_Home, EditMode_Full, NUM_EditMode, @@ -637,9 +625,6 @@ enum Stage Stage_Final, /**< The last stage. */ Stage_Extra1, /**< The first bonus stage, AKA the extra stage. */ Stage_Extra2, /**< The last bonus stage, AKA the encore extra stage. */ - Stage_Nonstop, /**< Playing a nonstop course. */ - Stage_Oni, /**< Playing an oni or survival course. */ - Stage_Endless, /**< Playing an endless course. */ Stage_Event, /**< Playing in event mode. */ Stage_Demo, /**< Playing the demonstration. */ NUM_Stage, /**< The number of stage types. */ @@ -681,22 +666,6 @@ enum MultiPlayerStatus }; const RString& MultiPlayerStatusToString( MultiPlayerStatus i ); -/** @brief The different course types. */ -enum CourseType -{ - COURSE_TYPE_NONSTOP, /**< The life meter type is set to BAR. */ - COURSE_TYPE_ONI, /**< The life meter type is set to BATTERY. */ - COURSE_TYPE_ENDLESS, /**< The life meter type is set to REPEAT. */ - COURSE_TYPE_SURVIVAL, /**< The life meter type is set to TIME. */ - NUM_CourseType, - CourseType_Invalid -}; -/** @brief A special iterator for handling the CourseTypes. */ -#define FOREACH_CourseType( i ) FOREACH_ENUM( CourseType, i ) -const RString& CourseTypeToString( CourseType i ); -const RString& CourseTypeToLocalizedString( CourseType i ); -LuaDeclareType( CourseType ); - /** @brief How can the Player fail a song? */ enum FailType { diff --git a/src/GameState.cpp b/src/GameState.cpp index d4ee87745b..7aaf2bb365 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -7,7 +7,6 @@ #include "Character.h" #include "CharacterManager.h" #include "CommonMetrics.h" -#include "Course.h" #include "CryptManager.h" #include "Foreach.h" #include "Game.h" @@ -116,24 +115,18 @@ GameState::GameState() : m_PlayMode( Message_PlayModeChanged ), m_iCoins( Message_CoinsChanged ), m_sPreferredSongGroup( Message_PreferredSongGroupChanged ), - m_sPreferredCourseGroup( Message_PreferredCourseGroupChanged ), m_PreferredStepsType( Message_PreferredStepsTypeChanged ), m_PreferredDifficulty( Message_PreferredDifficultyP1Changed ), - m_PreferredCourseDifficulty( Message_PreferredCourseDifficultyP1Changed ), m_SortOrder( Message_SortOrderChanged ), m_pCurSong( Message_CurrentSongChanged ), m_pCurSteps( Message_CurrentStepsP1Changed ), - m_pCurCourse( Message_CurrentCourseChanged ), - m_pCurTrail( Message_CurrentTrailP1Changed ), m_bGameplayLeadIn( Message_GameplayLeadInChanged ), m_bDidModeChangeNoteSkin( false ), m_bIsUsingStepTiming( true ), m_bInStepEditor( false ), m_stEdit( Message_EditStepsTypeChanged ), - m_cdEdit( Message_EditCourseDifficultyChanged ), m_pEditSourceSteps( Message_EditSourceStepsChanged ), m_stEditSource( Message_EditSourceStepsTypeChanged ), - m_iEditCourseEntryIndex( Message_EditCourseEntryIndexChanged ), m_sEditLocalProfileID( Message_EditLocalProfileIDChanged ) { g_pImpl = new GameStateImpl; @@ -264,11 +257,9 @@ void GameState::ResetPlayer( PlayerNumber pn ) { m_PreferredStepsType.Set( StepsType_Invalid ); m_PreferredDifficulty[pn].Set( Difficulty_Invalid ); - m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium ); m_iPlayerStageTokens[pn] = 0; m_iAwardedExtraStages[pn] = 0; m_pCurSteps[pn].Set( NULL ); - m_pCurTrail[pn].Set( NULL ); m_pPlayerState[pn]->Reset(); PROFILEMAN->UnloadProfile( pn ); ResetPlayerOptions(pn); @@ -301,7 +292,6 @@ void GameState::Reset() m_iNumMultiplayerNoteFields = 1; *m_Environment = LuaTable(); m_sPreferredSongGroup.Set( GROUP_ALL ); - m_sPreferredCourseGroup.Set( GROUP_ALL ); m_bFailTypeWasExplicitlySet = false; m_SortOrder.Set( SortOrder_Invalid ); m_PreferredSortOrder = GetDefaultSort(); @@ -324,8 +314,6 @@ void GameState::Reset() m_pCurSong.Set( GetDefaultSong() ); m_pPreferredSong = NULL; - m_pCurCourse.Set( NULL ); - m_pPreferredCourse = NULL; FOREACH_MultiPlayer( p ) m_pMultiPlayerState[p]->Reset(); @@ -340,10 +328,6 @@ void GameState::Reset() SONGMAN->UpdatePopular(); SONGMAN->UpdateShuffled(); - /* We may have cached trails from before everything was loaded (eg. from - * before SongManager::UpdatePopular could be called). Erase the cache. */ - SONGMAN->RegenerateNonFixedCourses(); - STATSMAN->Reset(); FOREACH_PlayerNumber(p) @@ -362,7 +346,6 @@ void GameState::Reset() m_stEdit.Set( StepsType_Invalid ); m_pEditSourceSteps.Set( NULL ); m_stEditSource.Set( StepsType_Invalid ); - m_iEditCourseEntryIndex.Set( -1 ); m_sEditLocalProfileID.Set( "" ); m_bBackedOutOfFinalStage = false; @@ -689,27 +672,16 @@ int GameState::GetNumStagesMultiplierForSong( const Song* pSong ) return iNumStages; } -int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() const -{ - int iNumStagesOfThisSong = 1; - if( m_pCurSong ) - { - /* Extra stages need to only count as one stage in case a multi-stage - * song is chosen. */ - if( IsAnExtraStage() ) +int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() const { int iNumStagesOfThisSong = 1; if (m_pCurSong) { /* Extra stages need to only count as one stage in case a multi-stage * song is chosen. */ if (IsAnExtraStage()) iNumStagesOfThisSong = 1; else - iNumStagesOfThisSong = GameState::GetNumStagesMultiplierForSong( m_pCurSong ); + iNumStagesOfThisSong = GameState::GetNumStagesMultiplierForSong(m_pCurSong); } - else if( m_pCurCourse ) - iNumStagesOfThisSong = PREFSMAN->m_iSongsPerPlay; else return -1; - - iNumStagesOfThisSong = max( iNumStagesOfThisSong, 1 ); - - return iNumStagesOfThisSong; -} + iNumStagesOfThisSong = max(iNumStagesOfThisSong, 1); + return iNumStagesOfThisSong; +} // Called by ScreenGameplay. Set the length of the current song. void GameState::BeginStage() @@ -874,15 +846,11 @@ void GameState::LoadCurrentSettingsFromProfile( PlayerNumber pn ) m_PreferredSortOrder = pProfile->m_SortOrder; if( pProfile->m_LastDifficulty != Difficulty_Invalid ) m_PreferredDifficulty[pn].Set( pProfile->m_LastDifficulty ); - if( pProfile->m_LastCourseDifficulty != Difficulty_Invalid ) - m_PreferredCourseDifficulty[pn].Set( pProfile->m_LastCourseDifficulty ); // Only set the PreferredStepsType if it wasn't already set by a GameCommand (or by an earlier profile) if( m_PreferredStepsType == StepsType_Invalid && pProfile->m_LastStepsType != StepsType_Invalid ) m_PreferredStepsType.Set( pProfile->m_LastStepsType ); if( m_pPreferredSong == NULL ) m_pPreferredSong = pProfile->m_lastSong.ToSong(); - if( m_pPreferredCourse == NULL ) - m_pPreferredCourse = pProfile->m_lastCourse.ToCourse(); } void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn ) @@ -899,36 +867,21 @@ void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn ) pProfile->m_SortOrder = m_PreferredSortOrder; if( m_PreferredDifficulty[pn] != Difficulty_Invalid ) pProfile->m_LastDifficulty = m_PreferredDifficulty[pn]; - if( m_PreferredCourseDifficulty[pn] != Difficulty_Invalid ) - pProfile->m_LastCourseDifficulty = m_PreferredCourseDifficulty[pn]; if( m_PreferredStepsType != StepsType_Invalid ) pProfile->m_LastStepsType = m_PreferredStepsType; if( m_pPreferredSong ) pProfile->m_lastSong.FromSong( m_pPreferredSong ); - if( m_pPreferredCourse ) - pProfile->m_lastCourse.FromCourse( m_pPreferredCourse ); } bool GameState::CanSafelyEnterGameplay(RString& reason) { - if(!IsCourseMode()) - { - Song const* song= m_pCurSong; - if(song == NULL) - { - reason= "Current song is NULL."; - return false; - } - } - else + Song const* song= m_pCurSong; + if(song == NULL) { - Course const* song= m_pCurCourse; - if(song == NULL) - { - reason= "Current course is NULL."; - return false; - } + reason= "Current song is NULL."; + return false; } + FOREACH_EnabledPlayer(pn) { Style const* style= GetCurrentStyle(pn); @@ -937,8 +890,7 @@ bool GameState::CanSafelyEnterGameplay(RString& reason) reason= ssprintf("Style for player %d is NULL.", pn+1); return false; } - if(!IsCourseMode()) - { + Steps const* steps= m_pCurSteps[pn]; if(steps == NULL) { @@ -967,24 +919,7 @@ bool GameState::CanSafelyEnterGameplay(RString& reason) "columns.", pn+1, ndtemp.GetNumTracks(), style->m_iColsPerPlayer); return false; } - } - else - { - Trail const* steps= m_pCurTrail[pn]; - if(steps == NULL) - { - reason= ssprintf("Steps for player %d is NULL.", pn+1); - return false; - } - if(steps->m_StepsType != style->m_StepsType) - { - reason= ssprintf("Player %d StepsType %s for steps does not equal " - "StepsType %s for style.", pn+1, - GAMEMAN->GetStepsTypeInfo(steps->m_StepsType).szName, - GAMEMAN->GetStepsTypeInfo(style->m_StepsType).szName); - return false; - } - } + } return true; } @@ -992,26 +927,6 @@ bool GameState::CanSafelyEnterGameplay(RString& reason) void GameState::SetCompatibleStylesForPlayers() { bool style_set= false; - if(IsCourseMode()) - { - if(m_pCurCourse != NULL) - { - const Style* style= m_pCurCourse->GetCourseStyle(m_pCurGame, GetNumSidesJoined()); - if(style != NULL) - { - style_set= true; - SetCurrentStyle(style, PLAYER_INVALID); - } - } - else if(GetCurrentStyle(PLAYER_INVALID) == NULL) - { - vector vst; - GAMEMAN->GetStepsTypesForGame(m_pCurGame, vst); - const Style *style = GAMEMAN->GetFirstCompatibleStyle( - m_pCurGame, GetNumSidesJoined(), vst[0]); - SetCurrentStyle(style, PLAYER_INVALID); - } - } if(!style_set) { FOREACH_EnabledPlayer(pn) @@ -1021,10 +936,6 @@ void GameState::SetCompatibleStylesForPlayers() { st= m_pCurSteps[pn]->m_StepsType; } - else if(m_pCurTrail[pn] != NULL) - { - st= m_pCurTrail[pn]->m_StepsType; - } else { vector vst; @@ -1061,81 +972,42 @@ void GameState::ForceSharedSidesMatch() if(other_style->m_StyleType != StyleType_TwoPlayersSharedSides) { SetCurrentStyle(shared_style, other_pn); - if(IsCourseMode()) - { - m_pCurTrail[other_pn].Set(m_pCurTrail[pn_with_shared]); - } - else - { m_pCurSteps[other_pn].Set(m_pCurSteps[pn_with_shared]); - } } } } void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main) { - if(IsCourseMode()) + Steps* steps_to_match = m_pCurSteps[main].Get(); + if (steps_to_match == NULL) { return; } + int num_players = GAMESTATE->GetNumPlayersEnabled(); + StyleType styletype_to_match = GAMEMAN->GetFirstCompatibleStyle( + GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType) + ->m_StyleType; + RString music_to_match = steps_to_match->GetMusicFile(); + FOREACH_EnabledPlayer(pn) { - Trail* steps_to_match= m_pCurTrail[main].Get(); - if(steps_to_match == NULL) { return; } - int num_players= GAMESTATE->GetNumPlayersEnabled(); - StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle( - GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType) - ->m_StyleType; - FOREACH_EnabledPlayer(pn) + Steps* pn_steps = m_pCurSteps[pn].Get(); + bool match_failed = pn_steps == NULL; + if (steps_to_match != pn_steps && pn_steps != NULL) { - Trail* pn_steps= m_pCurTrail[pn].Get(); - bool match_failed= pn_steps == NULL; - if(steps_to_match != pn_steps && pn_steps != NULL) + StyleType pn_styletype = GAMEMAN->GetFirstCompatibleStyle( + GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType) + ->m_StyleType; + if (styletype_to_match == StyleType_TwoPlayersSharedSides || + pn_styletype == StyleType_TwoPlayersSharedSides) { - StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle( - GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType) - ->m_StyleType; - if(styletype_to_match == StyleType_TwoPlayersSharedSides || - pn_styletype == StyleType_TwoPlayersSharedSides) - { - match_failed= true; - } + match_failed = true; } - if(match_failed) + if (music_to_match != pn_steps->GetMusicFile()) { - m_pCurTrail[pn].Set(steps_to_match); + match_failed = true; } } - } - else - { - Steps* steps_to_match= m_pCurSteps[main].Get(); - if(steps_to_match == NULL) { return; } - int num_players= GAMESTATE->GetNumPlayersEnabled(); - StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle( - GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType) - ->m_StyleType; - RString music_to_match= steps_to_match->GetMusicFile(); - FOREACH_EnabledPlayer(pn) + if (match_failed) { - Steps* pn_steps= m_pCurSteps[pn].Get(); - bool match_failed= pn_steps == NULL; - if(steps_to_match != pn_steps && pn_steps != NULL) - { - StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle( - GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType) - ->m_StyleType; - if(styletype_to_match == StyleType_TwoPlayersSharedSides || - pn_styletype == StyleType_TwoPlayersSharedSides) - { - match_failed= true; - } - if(music_to_match != pn_steps->GetMusicFile()) - { - match_failed= true; - } - } - if(match_failed) - { - m_pCurSteps[pn].Set(steps_to_match); - } + m_pCurSteps[pn].Set(steps_to_match); } } } @@ -1323,7 +1195,7 @@ bool GameState::IsAnExtraStage() const { if( this->GetMasterPlayerNumber() == PlayerNumber_Invalid ) return false; - return !IsEventMode() && !IsCourseMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] > 0; + return !IsEventMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] > 0; } static ThemeMetric LOCK_EXTRA_STAGE_SELECTION("GameState","LockExtraStageSelection"); @@ -1336,14 +1208,14 @@ bool GameState::IsExtraStage() const { if( this->GetMasterPlayerNumber() == PlayerNumber_Invalid ) return false; - return !IsEventMode() && !IsCourseMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] == 1; + return !IsEventMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] == 1; } bool GameState::IsExtraStage2() const { if( this->GetMasterPlayerNumber() == PlayerNumber_Invalid ) return false; - return !IsEventMode() && !IsCourseMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] == 2; + return !IsEventMode() && m_iAwardedExtraStages[this->GetMasterPlayerNumber()] == 2; } Stage GameState::GetCurrentStage() const @@ -1351,9 +1223,6 @@ Stage GameState::GetCurrentStage() const if( m_bDemonstrationOrJukebox ) return Stage_Demo; // "event" has precedence else if( IsEventMode() ) return Stage_Event; - else if( m_PlayMode == PLAY_MODE_ONI ) return Stage_Oni; - else if( m_PlayMode == PLAY_MODE_NONSTOP ) return Stage_Nonstop; - else if( m_PlayMode == PLAY_MODE_ENDLESS ) return Stage_Endless; else if( IsExtraStage() ) return Stage_Extra1; else if( IsExtraStage2() ) return Stage_Extra2; // Previous logic did not factor in current song length, or the fact that @@ -1382,15 +1251,14 @@ int GameState::GetCourseSongIndex() const if( GAMESTATE->m_bMultiplayer ) { FOREACH_EnabledMultiPlayer(mp) - return STATSMAN->m_CurStageStats.m_multiPlayer[mp].m_iSongsPlayed-1; - FAIL_M("At least one MultiPlayer must be joined."); + return STATSMAN->m_CurStageStats.m_multiPlayer[mp].m_iSongsPlayed - 1; + FAIL_M("At least one MultiPlayer must be joined."); } else { - return STATSMAN->m_CurStageStats.m_player[this->GetMasterPlayerNumber()].m_iSongsPlayed-1; + return STATSMAN->m_CurStageStats.m_player[this->GetMasterPlayerNumber()].m_iSongsPlayed - 1; } } - /* Hack: when we're loading a new course song, we want to display the new song * number, even though we haven't started that song yet. */ int GameState::GetLoadingCourseSongIndex() const @@ -1674,20 +1542,6 @@ bool GameState::AnyPlayersAreCpu() const return false; } - -bool GameState::IsCourseMode() const -{ - switch(m_PlayMode) - { - case PLAY_MODE_ONI: - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ENDLESS: - return true; - default: - return false; - } -} - bool GameState::IsBattleMode() const { switch( m_PlayMode ) @@ -1825,12 +1679,6 @@ void GameState::ApplyStageModifiers( PlayerNumber pn, const RString &sModifiers m_SongOptions.FromString( ModsLevel_Stage, sModifiers ); } -void GameState::ClearStageModifiersIllegalForCourse() -{ - FOREACH_EnabledPlayer( pn ) - PO_GROUP_CALL( m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Stage, ResetSavedPrefsInvalidForCourse ); -} - bool GameState::CurrentOptionsDisqualifyPlayer( PlayerNumber pn ) { if( !PREFSMAN->m_bDisqualification ) @@ -1843,10 +1691,7 @@ bool GameState::CurrentOptionsDisqualifyPlayer( PlayerNumber pn ) // Check the stored player options for disqualify. Don't disqualify because // of mods that were forced. - if( IsCourseMode() ) - return po.IsEasierForCourseAndTrail( m_pCurCourse, m_pCurTrail[pn] ); - else - return po.IsEasierForSongAndSteps( m_pCurSong, m_pCurSteps[pn], pn); + return po.IsEasierForSongAndSteps( m_pCurSong, m_pCurSteps[pn], pn); } /* reset noteskins (?) @@ -1860,21 +1705,6 @@ void GameState::GetAllUsedNoteSkins( vector &out ) const FOREACH_EnabledPlayer( pn ) { out.push_back( m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_sNoteSkin ); - - // Add noteskins that are used in courses. - if( IsCourseMode() ) - { - const Trail *pTrail = m_pCurTrail[pn]; - ASSERT( pTrail != NULL ); - - FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) - { - PlayerOptions po; - po.FromString( e->Modifiers ); - if( !po.m_sNoteSkin.empty() ) - out.push_back( po.m_sNoteSkin ); - } - } } // Remove duplicates. @@ -1920,13 +1750,8 @@ FailType GameState::GetPlayerFailType( const PlayerState *pPlayerState ) const if( m_bFailTypeWasExplicitlySet ) return ft; - if( IsCourseMode() ) - { - if( PREFSMAN->m_bMinimum1FullSongInCourses && GetCourseSongIndex()==0 ) - ft = max( ft, FailType_ImmediateContinue ); // take the least harsh of the two FailTypes - } - else - { + + Difficulty dc = Difficulty_Invalid; if( m_pCurSteps[pn] ) dc = m_pCurSteps[pn]->GetDifficulty(); @@ -1949,7 +1774,6 @@ FailType GameState::GetPlayerFailType( const PlayerState *pPlayerState ) const if( dc == Difficulty_Beginner && PREFSMAN->m_bFailOffInBeginner ) setmax( ft, FailType_Off ); - } return ft; } @@ -1960,7 +1784,6 @@ bool GameState::ShowW1() const switch( pref ) { case ALLOW_W1_NEVER: return false; - case ALLOW_W1_COURSES_ONLY: return IsCourseMode(); case ALLOW_W1_EVERYWHERE: return true; default: FAIL_M(ssprintf("Invalid AllowW1 preference: %i", pref)); @@ -2138,67 +1961,6 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu } } break; - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ONI: - case PLAY_MODE_ENDLESS: - { - Course* pCourse = m_pCurCourse; - ASSERT( pCourse != NULL ); - Trail *pTrail = m_pCurTrail[pn]; - ASSERT( pTrail != NULL ); - CourseDifficulty cd = pTrail->m_CourseDifficulty; - - // Find Machine Records - { - Profile* pProfile = PROFILEMAN->GetMachineProfile(); - HighScoreList &hsl = pProfile->GetCourseHighScoreList( pCourse, pTrail ); - for( unsigned i=0; iGetDisplayFullTitle().c_str() ); - if( cd != Difficulty_Medium ) - feat.Feat += " " + CourseDifficultyToLocalizedString(cd); - feat.pStringToFill = hs.GetNameMutable(); - feat.grade = Grade_NoData; - feat.iScore = hs.GetScore(); - feat.fPercentDP = hs.GetPercentDP(); - if( pCourse->HasBanner() ) - feat.Banner = pCourse->GetBannerPath(); - asFeatsOut.push_back( feat ); - } - } - - // Find Personal Records - if( PROFILE_RECORD_FEATS && PROFILEMAN->IsPersistentProfile(pn) ) - { - HighScoreList &hsl = pProf->GetCourseHighScoreList( pCourse, pTrail ); - for( unsigned i=0; iGetDisplayFullTitle().c_str() ); - feat.pStringToFill = hs.GetNameMutable(); - feat.grade = Grade_NoData; - feat.iScore = hs.GetScore(); - feat.fPercentDP = hs.GetPercentDP(); - if( pCourse->HasBanner() ) - feat.Banner = pCourse->GetBannerPath(); - asFeatsOut.push_back( feat ); - } - } - } - break; default: FAIL_M(ssprintf("Invalid play mode: %i", int(m_PlayMode))); } @@ -2267,20 +2029,12 @@ void GameState::StoreRankingName( PlayerNumber pn, RString sName ) FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) iter2->second.hsl.RemoveAllButOneOfEachName(); - - FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter ) - FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 ) - iter2->second.hsl.RemoveAllButOneOfEachName(); } // clamp high score sizes FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) iter2->second.hsl.ClampSize( true ); - - FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter ) - FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 ) - iter2->second.hsl.ClampSize( true ); } bool GameState::AllAreInDangerOrWorse() const @@ -2334,8 +2088,6 @@ bool GameState::DifficultiesLocked() const { if( m_PlayMode == PLAY_MODE_RAVE ) return true; - if( IsCourseMode() ) - return PREFSMAN->m_bLockCourseDifficulties; if( GetCurrentStyle(PLAYER_INVALID)->m_bLockDifficulties ) return true; return false; @@ -2399,51 +2151,6 @@ Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const return iClosest; } -bool GameState::ChangePreferredCourseDifficultyAndStepsType( PlayerNumber pn, CourseDifficulty cd, StepsType st ) -{ - m_PreferredCourseDifficulty[pn].Set( cd ); - m_PreferredStepsType.Set( st ); - if( PREFSMAN->m_bLockCourseDifficulties ) - FOREACH_PlayerNumber( p ) - if( p != pn ) - m_PreferredCourseDifficulty[p].Set( m_PreferredCourseDifficulty[pn] ); - - return true; -} - -bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) -{ - /* If we have a course selected, only choose among difficulties available in the course. */ - const Course *pCourse = m_pCurCourse; - - const vector &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); - - CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; - for(;;) - { - cd = enum_add2( cd, dir ); - if( cd < 0 || cd >= NUM_Difficulty ) - { - return false; - } - if( find(v.begin(),v.end(),cd) == v.end() ) - { - continue; /* not available */ - } - if( !pCourse || pCourse->GetTrail( GetCurrentStyle(pn)->m_StepsType, cd ) ) - { - break; - } - } - return ChangePreferredCourseDifficulty( pn, cd ); -} - -bool GameState::IsCourseDifficultyShown( CourseDifficulty cd ) -{ - const vector &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); - return find(v.begin(), v.end(), cd) != v.end(); -} - Difficulty GameState::GetEasiestStepsDifficulty() const { Difficulty dc = Difficulty_Invalid; @@ -2663,37 +2370,6 @@ class LunaGameState: public Luna } COMMON_RETURN_SELF; } - static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; } - static int SetCurrentCourse( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->m_pCurCourse.Set( NULL ); } - else { Course *pC = Luna::check(L,1); p->m_pCurCourse.Set( pC ); } - COMMON_RETURN_SELF; - } - static int GetCurrentTrail( T* p, lua_State *L ) - { - PlayerNumber pn = Enum::Check(L, 1); - Trail *pTrail = p->m_pCurTrail[pn]; - if( pTrail ) { pTrail->PushSelf(L); } - else { lua_pushnil(L); } - return 1; - } - static int SetCurrentTrail( T* p, lua_State *L ) - { - PlayerNumber pn = Enum::Check(L, 1); - if(lua_isnil(L,2)) - { - p->m_pCurTrail[pn].Set(NULL); - } - else - { - Trail *pS = Luna::check(L,2); - SetCompatibleStyleOrError(p, L, pS->m_StepsType, pn); - p->m_pCurTrail[pn].Set(pS); - p->ForceOtherPlayersToCompatibleSteps(pn); - } - COMMON_RETURN_SELF; - } static int GetPreferredSong( T* p, lua_State *L ) { if(p->m_pPreferredSong) p->m_pPreferredSong->PushSelf(L); else lua_pushnil(L); return 1; } static int SetPreferredSong( T* p, lua_State *L ) { @@ -2719,14 +2395,12 @@ class LunaGameState: public Luna } DEFINE_METHOD( GetPreferredDifficulty, m_PreferredDifficulty[Enum::Check(L, 1)] ) DEFINE_METHOD( AnyPlayerHasRankingFeats, AnyPlayerHasRankingFeats() ) - DEFINE_METHOD( IsCourseMode, IsCourseMode() ) DEFINE_METHOD( IsBattleMode, IsBattleMode() ) DEFINE_METHOD( IsDemonstration, m_bDemonstrationOrJukebox ) DEFINE_METHOD( GetPlayMode, m_PlayMode ) DEFINE_METHOD( GetSortOrder, m_SortOrder ) DEFINE_METHOD( GetCurrentStageIndex, m_iCurrentStageIndex ) DEFINE_METHOD( PlayerIsUsingModifier, PlayerIsUsingModifier(Enum::Check(L, 1), SArg(2)) ) - DEFINE_METHOD( GetCourseSongIndex, GetCourseSongIndex() ) DEFINE_METHOD( GetLoadingCourseSongIndex, GetLoadingCourseSongIndex() ) DEFINE_METHOD( GetSmallestNumStagesLeftForAnyHumanPlayer, GetSmallestNumStagesLeftForAnyHumanPlayer() ) DEFINE_METHOD( IsAnExtraStage, IsAnExtraStage() ) @@ -2798,11 +2472,6 @@ class LunaGameState: public Luna p->ApplyPreferredModifiers( Enum::Check(L, 1), SArg(2) ); COMMON_RETURN_SELF; } - static int ClearStageModifiersIllegalForCourse( T* p, lua_State *L ) - { - p->ClearStageModifiersIllegalForCourse(); - COMMON_RETURN_SELF; - } static int SetSongOptions( T* p, lua_State *L ) { ModsLevel m = Enum::Check( L, 1 ); @@ -2829,7 +2498,6 @@ class LunaGameState: public Luna lua_pushboolean(L, p->GetStageResult(PLAYER_1)==RESULT_DRAW); return 1; } static int GetCurrentGame( T* p, lua_State *L ) { const_cast(p->GetCurrentGame())->PushSelf( L ); return 1; } - DEFINE_METHOD( GetEditCourseEntryIndex, m_iEditCourseEntryIndex ) DEFINE_METHOD( GetEditLocalProfileID, m_sEditLocalProfileID.Get() ) static int GetEditLocalProfile( T* p, lua_State *L ) { @@ -2862,7 +2530,7 @@ class LunaGameState: public Luna for( unsigned i=0; im_StepsType, pSteps->GetDifficulty(), CourseType_Invalid ) ); + RString sDifficulty = CustomDifficultyToLocalizedString( GetCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty() ) ); lua_pushstring( L, sDifficulty ); lua_pushstring( L, pSteps->GetDescription() ); @@ -3042,22 +2710,6 @@ class LunaGameState: public Luna return false; } - static void ClearIncompatibleStepsAndTrails( T *p, lua_State* L ) - { - FOREACH_HumanPlayer( pn ) - { - const Style *style = p->GetCurrentStyle(pn); - if( p->m_pCurSteps[pn] && ( !style || style->m_StepsType != p->m_pCurSteps[pn]->m_StepsType ) ) - { - p->m_pCurSteps[pn].Set( NULL ); - } - if( p->m_pCurTrail[pn] && ( !style || style->m_StepsType != p->m_pCurTrail[pn]->m_StepsType ) ) - { - p->m_pCurTrail[pn].Set( NULL ); - } - } - } - static int SetCurrentStyle( T* p, lua_State *L ) { const Style* pStyle = NULL; @@ -3094,7 +2746,6 @@ class LunaGameState: public Luna PlayerNumber pn= Enum::Check(L, 2, true, true); p->SetCurrentStyle(pStyle, pn); - ClearIncompatibleStepsAndTrails( p, L ); COMMON_RETURN_SELF; } @@ -3131,7 +2782,6 @@ class LunaGameState: public Luna p->m_pCurSteps[PLAYER_1].Set(steps); p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType( steps->m_StepsType), PLAYER_INVALID); - p->m_pCurCourse.Set(NULL); return 0; } StepsType stype= Enum::Check(L, 3); @@ -3158,7 +2808,6 @@ class LunaGameState: public Luna p->m_pCurSteps[PLAYER_1].Set(steps); p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType( steps->m_StepsType), PLAYER_INVALID); - p->m_pCurCourse.Set(NULL); return 0; } @@ -3208,11 +2857,7 @@ class LunaGameState: public Luna ADD_METHOD( SetCurrentSong ); ADD_METHOD( GetCurrentSteps ); ADD_METHOD( SetCurrentSteps ); - ADD_METHOD( GetCurrentCourse ); - ADD_METHOD( SetCurrentCourse ); - ADD_METHOD( GetCurrentTrail ); ADD_METHOD( GetSessionTime ); - ADD_METHOD( SetCurrentTrail ); ADD_METHOD( SetPreferredSong ); ADD_METHOD( GetPreferredSong ); ADD_METHOD( SetTemporaryEventMode ); @@ -3221,14 +2866,12 @@ class LunaGameState: public Luna ADD_METHOD( SetPreferredDifficulty ); ADD_METHOD( GetPreferredDifficulty ); ADD_METHOD( AnyPlayerHasRankingFeats ); - ADD_METHOD( IsCourseMode ); ADD_METHOD( IsBattleMode ); ADD_METHOD( IsDemonstration ); ADD_METHOD( GetPlayMode ); ADD_METHOD( GetSortOrder ); ADD_METHOD( GetCurrentStageIndex ); ADD_METHOD( PlayerIsUsingModifier ); - ADD_METHOD( GetCourseSongIndex ); ADD_METHOD( GetLoadingCourseSongIndex ); ADD_METHOD( GetSmallestNumStagesLeftForAnyHumanPlayer ); ADD_METHOD( IsAnExtraStage ); @@ -3241,11 +2884,6 @@ class LunaGameState: public Luna ADD_METHOD( GetHardestStepsDifficulty ); ADD_METHOD( IsEventMode ); ADD_METHOD( GetNumPlayersEnabled ); - /*ADD_METHOD( GetSongBeat ); - ADD_METHOD( GetSongBeatVisible ); - ADD_METHOD( GetSongBPS ); - ADD_METHOD( GetSongFreeze ); - ADD_METHOD( GetSongDelay );*/ ADD_METHOD( GetSongPosition ); ADD_METHOD( GetLastGameplayDuration ); ADD_METHOD( GetGameplayLeadIn ); @@ -3264,13 +2902,11 @@ class LunaGameState: public Luna ADD_METHOD( ApplyPreferredSongOptionsToOtherLevels ); ADD_METHOD( ApplyPreferredModifiers ); ADD_METHOD( ApplyStageModifiers ); - ADD_METHOD( ClearStageModifiersIllegalForCourse ); ADD_METHOD( SetSongOptions ); ADD_METHOD( GetStageResult ); ADD_METHOD( IsWinner ); ADD_METHOD( IsDraw ); ADD_METHOD( GetCurrentGame ); - ADD_METHOD( GetEditCourseEntryIndex ); ADD_METHOD( GetEditLocalProfileID ); ADD_METHOD( GetEditLocalProfile ); ADD_METHOD( GetCurrentStepsCredits ); diff --git a/src/GameState.h b/src/GameState.h index 55b5f3a8aa..56010dc9d0 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -18,7 +18,6 @@ #include class Character; -class Course; struct Game; struct lua_State; class LuaTable; @@ -30,7 +29,6 @@ class Steps; class StageStats; class Style; class TimingData; -class Trail; SortOrder GetDefaultSort(); @@ -113,9 +111,6 @@ class GameState bool DifficultiesLocked() const; bool ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st ); bool ChangePreferredDifficulty( PlayerNumber pn, int dir ); - bool ChangePreferredCourseDifficultyAndStepsType( PlayerNumber pn, CourseDifficulty cd, StepsType st ); - bool ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ); - bool IsCourseDifficultyShown( CourseDifficulty cd ); Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const; Difficulty GetEasiestStepsDifficulty() const; Difficulty GetHardestStepsDifficulty() const; @@ -178,7 +173,6 @@ class GameState * @param t the timing data. */ void SetProcessedTimingData(TimingData * t); - bool IsCourseMode() const; bool IsBattleMode() const; // not Rave /** @@ -187,11 +181,9 @@ class GameState bool ShowW1() const; BroadcastOnChange m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group - BroadcastOnChange m_sPreferredCourseGroup; // GROUP_ALL denotes no preferred group bool m_bFailTypeWasExplicitlySet; // true if FailType was changed in the song options screen BroadcastOnChange m_PreferredStepsType; BroadcastOnChange1D m_PreferredDifficulty; - BroadcastOnChange1D m_PreferredCourseDifficulty;// used in nonstop BroadcastOnChange m_SortOrder; // set by MusicWheel SortOrder m_PreferredSortOrder; // used by MusicWheel EditMode m_EditMode; @@ -221,7 +213,7 @@ class GameState static int GetNumStagesMultiplierForSong( const Song* pSong ); static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st ); - int GetNumStagesForCurrentSongAndStepsOrCourse() const; + int GetNumStagesForCurrentSongAndStepsOrCourse() const; void BeginStage(); void CancelStage(); @@ -240,7 +232,7 @@ class GameState RString GetPlayerDisplayName( PlayerNumber pn ) const; bool m_bLoadingNextSong; - int GetLoadingCourseSongIndex() const; + int GetLoadingCourseSongIndex() const; RString GetEtternaVersion() { return "0.54.2"; } bool CountNotesSeparately(); @@ -253,12 +245,6 @@ class GameState Song* m_pPreferredSong; BroadcastOnChangePtr1D m_pCurSteps; - // NULL on ScreenSelectMusic if the currently selected wheel item isn't a Course. - BroadcastOnChangePtr m_pCurCourse; - // The last Course that the user manually changed to. - Course* m_pPreferredCourse; - BroadcastOnChangePtr1D m_pCurTrail; - bool m_bBackedOutOfFinalStage; // Music statistics: @@ -321,7 +307,6 @@ class GameState void ResetToDefaultSongOptions( ModsLevel l ); void ApplyPreferredModifiers( PlayerNumber pn, const RString &sModifiers ); void ApplyStageModifiers( PlayerNumber pn, const RString &sModifiers ); - void ClearStageModifiersIllegalForCourse(); void ResetOptions(); bool CurrentOptionsDisqualifyPlayer( PlayerNumber pn ); @@ -338,10 +323,9 @@ class GameState // Ranking Stuff struct RankingFeat { - enum { SONG, COURSE, CATEGORY } Type; + enum { SONG, CATEGORY } Type; Song* pSong; // valid if Type == SONG Steps* pSteps; // valid if Type == SONG - Course* pCourse; // valid if Type == COURSE Grade grade; int iScore; float fPercentDP; @@ -396,10 +380,8 @@ class GameState * TODO: Find a better way to implement this. */ bool m_bInStepEditor; BroadcastOnChange m_stEdit; - BroadcastOnChange m_cdEdit; BroadcastOnChangePtr m_pEditSourceSteps; BroadcastOnChange m_stEditSource; - BroadcastOnChange m_iEditCourseEntryIndex; BroadcastOnChange m_sEditLocalProfileID; Profile* GetEditLocalProfile(); diff --git a/src/LifeMeterBar.cpp b/src/LifeMeterBar.cpp index ff077ff78d..f33985e1e3 100644 --- a/src/LifeMeterBar.cpp +++ b/src/LifeMeterBar.cpp @@ -14,7 +14,6 @@ #include "ActorUtil.h" #include "StreamDisplay.h" #include "Steps.h" -#include "Course.h" static RString LIFE_PERCENT_CHANGE_NAME( size_t i ) { return "LifePercentChange" + ScoreEventToString( (ScoreEvent)i ); } @@ -349,11 +348,6 @@ void LifeMeterBar::UpdateNonstopLifebar() iTotal = PREFSMAN->m_iSongsPerPlay; iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveStageLifebar; break; - case PLAY_MODE_NONSTOP: - iCleared = GAMESTATE->GetCourseSongIndex(); - iTotal = GAMESTATE->m_pCurCourse->GetEstimatedNumStages(); - iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveNonstopLifebar; - break; default: return; } diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp index 36520f7868..0ba0afed39 100644 --- a/src/LifeMeterBattery.cpp +++ b/src/LifeMeterBattery.cpp @@ -4,7 +4,6 @@ #include "ThemeManager.h" #include "Steps.h" #include "PlayerState.h" -#include "Course.h" #include "ActorUtil.h" LifeMeterBattery::LifeMeterBattery() @@ -33,7 +32,6 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats * MINES_SUBTRACT_LIVES.Load(sType, "MinesSubtractLives"); HELD_ADD_LIVES.Load(sType, "HeldAddLives"); LET_GO_SUBTRACT_LIVES.Load(sType, "LetGoSubtractLives"); - COURSE_SONG_REWARD_LIVES.Load(sType, "CourseSongRewardLives"); LIVES_FORMAT.Load(sType, "NumLivesFormat"); @@ -81,32 +79,26 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats * void LifeMeterBattery::OnSongEnded() { - if( m_pPlayerStageStats->m_bFailed || m_iLivesLeft == 0 ) + if (m_pPlayerStageStats->m_bFailed || m_iLivesLeft == 0) return; - if( m_iLivesLeft < m_pPlayerState->m_PlayerOptions.GetSong().m_BatteryLives ) + if (m_iLivesLeft < m_pPlayerState->m_PlayerOptions.GetSong().m_BatteryLives) { m_iTrailingLivesLeft = m_iLivesLeft; PlayerNumber pn = m_pPlayerState->m_PlayerNumber; - const Course *pCourse = GAMESTATE->m_pCurCourse; - if( pCourse && pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].iGainLives > -1 ) - m_iLivesLeft += pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].iGainLives; - else - { - Lua *L= LUA->Get(); - COURSE_SONG_REWARD_LIVES.PushSelf(L); - PushSelf(L); - LuaHelpers::Push(L, pn); - RString error= "Error running CourseSongRewardLives callback: "; - LuaHelpers::RunScriptOnStack(L, error, 2, 1, true); - m_iLivesLeft += luaL_optnumber(L, -1, 0); - lua_settop(L, 0); - LUA->Release(L); - } - m_iLivesLeft = min( m_iLivesLeft, m_pPlayerState->m_PlayerOptions.GetSong().m_BatteryLives ); - - if( m_iTrailingLivesLeft < m_iLivesLeft ) + Lua *L = LUA->Get(); + COURSE_SONG_REWARD_LIVES.PushSelf(L); + PushSelf(L); + LuaHelpers::Push(L, pn); + RString error = "Error running CourseSongRewardLives callback: "; + LuaHelpers::RunScriptOnStack(L, error, 2, 1, true); + m_iLivesLeft += luaL_optnumber(L, -1, 0); + lua_settop(L, 0); + LUA->Release(L); + m_iLivesLeft = min(m_iLivesLeft, m_pPlayerState->m_PlayerOptions.GetSong().m_BatteryLives); + + if (m_iTrailingLivesLeft < m_iLivesLeft) m_soundGainLife.Play(false); } diff --git a/src/LifeMeterTime.cpp b/src/LifeMeterTime.cpp index 2c144f3bfa..e406a2b188 100644 --- a/src/LifeMeterTime.cpp +++ b/src/LifeMeterTime.cpp @@ -4,7 +4,6 @@ #include "Song.h" #include "Steps.h" #include "ActorUtil.h" -#include "Course.h" #include "Preference.h" #include "StreamDisplay.h" #include "GameState.h" @@ -97,33 +96,25 @@ void LifeMeterTime::OnLoadSong() float fOldLife = m_fLifeTotalLostSeconds; float fGainSeconds = 0; - if(GAMESTATE->IsCourseMode()) - { - Course* pCourse = GAMESTATE->m_pCurCourse; - ASSERT( pCourse != NULL ); - fGainSeconds= pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds; - } - else + + // Placeholderish, at least this way it won't crash when someone tries it + // out in non-course mode. -Kyz + Song* song = GAMESTATE->m_pCurSong; + ASSERT(song != NULL); + float song_len = song->m_fMusicLengthSeconds; + Steps* steps = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]; + ASSERT(steps != NULL); + RadarValues radars = steps->GetRadarValues(m_pPlayerState->m_PlayerNumber); + float scorable_things = radars[RadarCategory_TapsAndHolds] + + radars[RadarCategory_Lifts]; + if (g_fTimeMeterSecondsChange[SE_Held] > 0.0f) { - // Placeholderish, at least this way it won't crash when someone tries it - // out in non-course mode. -Kyz - Song* song= GAMESTATE->m_pCurSong; - ASSERT(song != NULL); - float song_len= song->m_fMusicLengthSeconds; - Steps* steps= GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]; - ASSERT(steps != NULL); - RadarValues radars= steps->GetRadarValues(m_pPlayerState->m_PlayerNumber); - float scorable_things= radars[RadarCategory_TapsAndHolds] + - radars[RadarCategory_Lifts]; - if(g_fTimeMeterSecondsChange[SE_Held] > 0.0f) - { - scorable_things+= radars[RadarCategory_Holds] + - radars[RadarCategory_Rolls]; - } - // Calculate the amount of time to give for the player to need 80% W1. - float gainable_score_time= scorable_things * g_fTimeMeterSecondsChange[SE_W1]; - fGainSeconds= song_len - (gainable_score_time * INITIAL_VALUE); + scorable_things += radars[RadarCategory_Holds] + + radars[RadarCategory_Rolls]; } + // Calculate the amount of time to give for the player to need 80% W1. + float gainable_score_time = scorable_things * g_fTimeMeterSecondsChange[SE_W1]; + fGainSeconds = song_len - (gainable_score_time * INITIAL_VALUE); if( MIN_LIFE_TIME > fGainSeconds ) fGainSeconds = MIN_LIFE_TIME; diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index c5e2794e69..bf19e7d37c 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -10,13 +10,11 @@ #include "ThemeManager.h" #include "NetworkSyncManager.h" #include "Song.h" -#include "Course.h" #include "Steps.h" #include "UnlockManager.h" #include "GameCommand.h" #include "ActorUtil.h" #include "SongUtil.h" -#include "CourseUtil.h" #include "Foreach.h" #include "Style.h" #include "PlayerState.h" @@ -43,29 +41,6 @@ AutoScreenMessage( SM_SongChanged ); // TODO: Replace this with a Message and ME AutoScreenMessage( SM_SortOrderChanging ); AutoScreenMessage( SM_SortOrderChanged ); -static SortOrder ForceAppropriateSort( PlayMode pm, SortOrder so ) -{ - switch( pm ) - { - // in course modes, force a particular sort - case PLAY_MODE_ONI: return SORT_ONI_COURSES; - case PLAY_MODE_NONSTOP: return SORT_NONSTOP_COURSES; - case PLAY_MODE_ENDLESS: return SORT_ENDLESS_COURSES; - default: break; - } - - // If we're not in a course mode, don't start in a course sort. - switch( so ) - { - case SORT_ONI_COURSES: - case SORT_NONSTOP_COURSES: - case SORT_ENDLESS_COURSES: - so = SortOrder_Invalid; - default: - return so; - } -} - MusicWheelItem *MusicWheel::MakeItem() { return new MusicWheelItem; @@ -109,8 +84,6 @@ void MusicWheel::Load( const RString &sType ) WheelBase::Load( sType ); - SONGMAN->UpdateRankingCourses(); - m_soundChangeSort.Load( THEME->GetPathS(sType,"sort") ); m_soundExpand.Load( THEME->GetPathS(sType,"expand"), true ); m_soundCollapse.Load( THEME->GetPathS(sType,"collapse"), true ); @@ -178,7 +151,7 @@ void MusicWheel::BeginScreen() if( GAMESTATE->m_SortOrder == SORT_MODE_MENU ) GAMESTATE->m_SortOrder.Set( SortOrder_Invalid ); - GAMESTATE->m_SortOrder.Set( ForceAppropriateSort(GAMESTATE->m_PlayMode, GAMESTATE->m_SortOrder) ); + GAMESTATE->m_SortOrder.Set( GAMESTATE->m_SortOrder ); /* Only save the sort order if the player didn't already have one. * If he did, don't overwrite it. */ @@ -189,12 +162,6 @@ void MusicWheel::BeginScreen() { // If a preferred song group is set, open the group and select the // first song in the group. -aj - if(!GAMESTATE->IsCourseMode()) - { - vector vTemp = SONGMAN->GetSongs(GAMESTATE->m_sPreferredSongGroup); - ASSERT(vTemp.size() > 0); - GAMESTATE->m_pCurSong.Set(vTemp[0]); - }; SetOpenSection(GAMESTATE->m_sPreferredSongGroup); SelectSongOrCourse(); } @@ -312,10 +279,6 @@ bool MusicWheel::SelectSongOrCourse() return true; if( GAMESTATE->m_pCurSong && SelectSong( GAMESTATE->m_pCurSong ) ) return true; - if( GAMESTATE->m_pPreferredCourse && SelectCourse( GAMESTATE->m_pPreferredCourse ) ) - return true; - if( GAMESTATE->m_pCurCourse && SelectCourse( GAMESTATE->m_pCurCourse ) ) - return true; // Select the first selectable song based on the sort order... vector &wiWheelItems = getWheelItemsData(GAMESTATE->m_SortOrder); @@ -323,8 +286,6 @@ bool MusicWheel::SelectSongOrCourse() { if( wiWheelItems[i]->m_pSong ) return SelectSong( wiWheelItems[i]->m_pSong ); - else if ( wiWheelItems[i]->m_pCourse ) - return SelectCourse( wiWheelItems[i]->m_pCourse ); } LOG->Trace( "MusicWheel::MusicWheel() - No selectable songs or courses found in WheelData" ); @@ -374,35 +335,6 @@ bool MusicWheel::SelectSong( const Song *p ) return true; } -bool MusicWheel::SelectCourse( const Course *p ) -{ - if( p == NULL ) - return false; - - unsigned i; - vector &from = getWheelItemsData(GAMESTATE->m_SortOrder); - for( i=0; im_pCourse == p ) - { - // make its group the currently expanded group - SetOpenSection( from[i]->m_sText ); - break; - } - } - - if( i == from.size() ) - return false; - - for( i=0; im_pCourse == p ) - m_iSelection = i; // select it - } - - return true; -} - bool MusicWheel::SelectModeMenuItem() { // Select the last-chosen option. @@ -707,7 +639,7 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt split( MODE_MENU_CHOICE_NAMES, ",", vsNames ); for( unsigned i=0; i( new GameCommand ); wid.m_pAction->m_sName = vsNames[i]; wid.m_pAction->Load( i, ParseCommands(CHOICE.GetValue(vsNames[i])) ); @@ -739,7 +671,6 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt case SORT_DOUBLE_MEDIUM_METER: case SORT_DOUBLE_HARD_METER: case SORT_DOUBLE_CHALLENGE_METER: - case SORT_LENGTH: case SORT_RECENT: { // Make an array of Song*, then sort them @@ -805,9 +736,6 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt case SORT_GENRE: SongUtil::SortSongPointerArrayByGenre( arraySongs ); break; - case SORT_LENGTH: - SongUtil::SortSongPointerArrayByLength( arraySongs ); - break; case SORT_RECENT: SongUtil::SortByMostRecentlyPlayedForMachine( arraySongs ); if( (int) arraySongs.size() > RECENT_SONGS_TO_SHOW ) @@ -897,18 +825,18 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt // todo: preferred sort section color handling? -aj RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex); iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS; - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, sThisSection, NULL, colorSection, iSectionCount) ); + arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, sThisSection, colorSection, iSectionCount) ); sLastSection = sThisSection; } } - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, NULL, SONGMAN->GetSongColor(pSong), 0) ); + arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, SONGMAN->GetSongColor(pSong), 0) ); } if( so != SORT_ROULETTE ) { // todo: allow themers to change the order of the items. -aj if( SHOW_ROULETTE ) - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Roulette, NULL, "", NULL, ROULETTE_COLOR, 0) ); + arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Roulette, NULL, "", ROULETTE_COLOR, 0) ); // Only add WheelItemDataType_Random and WheelItemDataType_Portal if there's at least // one song on the list. @@ -918,17 +846,17 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt bFoundAnySong = true; if( SHOW_RANDOM && bFoundAnySong ) - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Random, NULL, "", NULL, RANDOM_COLOR, 0) ); + arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Random, NULL, "", RANDOM_COLOR, 0) ); if( SHOW_PORTAL && bFoundAnySong ) - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Portal, NULL, "", NULL, PORTAL_COLOR, 0) ); + arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Portal, NULL, "", PORTAL_COLOR, 0) ); // add custom wheel items vector vsNames; split( CUSTOM_WHEEL_ITEM_NAMES, ",", vsNames ); for( unsigned i=0; i( new GameCommand ); wid.m_pAction->m_sName = vsNames[i]; wid.m_pAction->Load( i, ParseCommands(CUSTOM_CHOICES.GetValue(vsNames[i])) ); @@ -959,110 +887,6 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt } break; } - case SORT_ALL_COURSES: - case SORT_NONSTOP_COURSES: - case SORT_ONI_COURSES: - case SORT_ENDLESS_COURSES: - { - bool bOnlyPreferred = PREFSMAN->m_CourseSortOrder == COURSE_SORT_PREFERRED; - - vector vct; - switch( so ) - { - case SORT_NONSTOP_COURSES: - vct.push_back( COURSE_TYPE_NONSTOP ); - break; - case SORT_ONI_COURSES: - vct.push_back( COURSE_TYPE_ONI ); - vct.push_back( COURSE_TYPE_SURVIVAL ); - break; - case SORT_ENDLESS_COURSES: - vct.push_back( COURSE_TYPE_ENDLESS ); - break; - case SORT_ALL_COURSES: - FOREACH_ENUM( CourseType, i ) - vct.push_back( i ); - break; - default: - FAIL_M(ssprintf("Wrong sort order: %i", so)); - } - - vector apCourses; - FOREACH_CONST( CourseType, vct, ct ) - { - if( bOnlyPreferred ) - SONGMAN->GetPreferredSortCourses( *ct, apCourses, PREFSMAN->m_bAutogenGroupCourses ); - else - SONGMAN->GetCourses( *ct, apCourses, PREFSMAN->m_bAutogenGroupCourses ); - } - - switch( PREFSMAN->m_CourseSortOrder ) - { - case COURSE_SORT_SONGS: - CourseUtil::SortCoursePointerArrayByDifficulty( apCourses ); - break; - case COURSE_SORT_PREFERRED: - break; - case COURSE_SORT_METER: - CourseUtil::SortCoursePointerArrayByAvgDifficulty( apCourses ); - break; - case COURSE_SORT_METER_SUM: - CourseUtil::SortCoursePointerArrayByTotalDifficulty( apCourses ); - break; - case COURSE_SORT_RANK: - CourseUtil::SortCoursePointerArrayByRanking( apCourses ); - break; - default: FAIL_M("Impossible to sort the courses! Aborting..."); - } - - // since we can't agree, make it an option - if( PREFSMAN->m_CourseSortOrder != COURSE_SORT_SONGS && g_bMoveRandomToEnd ) - CourseUtil::MoveRandomToEnd( apCourses ); - - if( so == SORT_ALL_COURSES ) - CourseUtil::SortCoursePointerArrayByType( apCourses ); - - arrayWheelItemDatas.clear(); // clear out the previous wheel items - - RString sLastSection = ""; - int iSectionColorIndex = 0; - for( unsigned i=0; iCourseIsLocked(pCourse) ) - continue; - - RString sThisSection = ""; - if( so == SORT_ALL_COURSES ) - { - switch( pCourse->GetPlayMode() ) - { - case PLAY_MODE_ONI: sThisSection = "Oni"; break; - case PLAY_MODE_NONSTOP: sThisSection = "Nonstop"; break; - case PLAY_MODE_ENDLESS: sThisSection = "Endless"; break; - default: break; - } - } - - // check that this course has at least one song playable in the current style - if( !pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType) ) - continue; - - if( sThisSection != sLastSection ) // new section, make a section item - { - RageColor c = SECTION_COLORS.GetValue(iSectionColorIndex); - iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS; - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, sThisSection, NULL, c, 0) ); - sLastSection = sThisSection; - } - - RageColor c = ( pCourse->m_sGroupName.size() == 0 ) ? pCourse->GetColor() : SONGMAN->GetCourseColor(pCourse); - arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Course, NULL, sThisSection, pCourse, c, 0) ); - } - break; - } default: break; } @@ -1081,12 +905,6 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt WID.m_Flags.bEdits |= WID.m_pSong->HasEdits( *st ); WID.m_Flags.iStagesForSong = GameState::GetNumStagesMultiplierForSong( WID.m_pSong ); } - else if( WID.m_pCourse != NULL ) - { - WID.m_Flags.bHasBeginnerOr1Meter = false; - WID.m_Flags.bEdits = WID.m_pCourse->IsAnEdit(); - WID.m_Flags.iStagesForSong = 1; - } } } @@ -1215,12 +1033,6 @@ void MusicWheel::FilterWheelItemDatas(vector &aUnFilteredD continue; } } - - if( WID.m_Type == WheelItemDataType_Course ) - { - if( !WID.m_pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType) ) - aiRemove[i] = true; - } } /* Filter out the songs we're removing. */ @@ -1274,7 +1086,7 @@ void MusicWheel::FilterWheelItemDatas(vector &aUnFilteredD // If we've filtered all items, insert a dummy. if( aFilteredData.empty() ) - aFilteredData.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, EMPTY_STRING, NULL, EMPTY_COLOR, 0) ); + aFilteredData.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, EMPTY_STRING, EMPTY_COLOR, 0) ); } void MusicWheel::UpdateSwitch() @@ -1599,17 +1411,6 @@ void MusicWheel::SetOpenSection( const RString &group ) continue; } - // If AUTO_SET_STYLE, hide courses that prefer a style that isn't available. - if( d.m_Type == WheelItemDataType_Course && CommonMetrics::AUTO_SET_STYLE ) - { - const Style *pStyle = d.m_pCourse->GetCourseStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined() ); - if( pStyle ) - { - if( find( vpPossibleStyles.begin(), vpPossibleStyles.end(), pStyle ) == vpPossibleStyles.end() ) - continue; - } - } - // Only show tutorial songs in arcade if( GAMESTATE->m_PlayMode!=PLAY_MODE_REGULAR && d.m_pSong && @@ -1889,16 +1690,6 @@ class LunaMusicWheel : public Luna } return 1; } - static int SelectCourse(T* p, lua_State *L) - { - if (lua_isnil(L, 1)) { lua_pushboolean(L, false); } - else - { - Course *pC = Luna::check(L, 1, true); - lua_pushboolean(L, p->SelectCourse(pC)); - } - return 1; - } static int SongSearch(T* p, lua_State *L) { p->ReloadSongList(true, SArg(1)); return 1; @@ -1928,7 +1719,6 @@ class LunaMusicWheel : public Luna ADD_METHOD( GetSelectedSection ); ADD_METHOD( IsRouletting ); ADD_METHOD( SelectSong ); - ADD_METHOD( SelectCourse ); ADD_METHOD( SongSearch ); ADD_METHOD( Move ); ADD_METHOD( MoveAndCheckType ); diff --git a/src/MusicWheel.h b/src/MusicWheel.h index 460b7ea802..f840a96194 100644 --- a/src/MusicWheel.h +++ b/src/MusicWheel.h @@ -9,7 +9,6 @@ #include "ThemeMetric.h" #include "WheelBase.h" -class Course; class Song; struct CompareSongPointerArrayBySectionName; @@ -32,13 +31,11 @@ class MusicWheel : public WheelBase virtual bool Select(); // return true if this selection ends the screen WheelItemDataType GetSelectedType() { return GetCurWheelItemData(m_iSelection)->m_Type; } Song *GetSelectedSong(); - Course *GetSelectedCourse() { return GetCurWheelItemData(m_iSelection)->m_pCourse; } RString GetSelectedSection() { return GetCurWheelItemData(m_iSelection)->m_sText; } Song *GetPreferredSelectionForRandomOrPortal(); bool SelectSong( const Song *p ); - bool SelectCourse( const Course *p ); bool SelectSection( const RString & SectionName ); void SetOpenSection( const RString &group ); SortOrder GetSortOrder() const { return m_SortOrder; } diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index 42513f2ae1..5e8b39d0c3 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -9,7 +9,6 @@ #include "ThemeManager.h" #include "Steps.h" #include "Song.h" -#include "Course.h" #include "ProfileManager.h" #include "Profile.h" #include "Style.h" @@ -26,7 +25,6 @@ static const char *MusicWheelItemTypeNames[] = { "SectionExpanded", "SectionCollapsed", "Roulette", - "Course", "Sort", "Mode", "Random", @@ -36,10 +34,10 @@ static const char *MusicWheelItemTypeNames[] = { XToString( MusicWheelItemType ); MusicWheelItemData::MusicWheelItemData( WheelItemDataType type, Song* pSong, - RString sSectionName, Course* pCourse, + RString sSectionName, RageColor color, int iSectionCount ): WheelItemBaseData(type, sSectionName, color), - m_pCourse(pCourse), m_pSong(pSong), m_Flags(WheelNotifyIcon::Flags()), + m_pSong(pSong), m_Flags(WheelNotifyIcon::Flags()), m_iSectionCount(iSectionCount), m_sLabel(""), m_pAction() {} MusicWheelItem::MusicWheelItem( RString sType ): @@ -116,8 +114,6 @@ MusicWheelItem::MusicWheelItem( RString sType ): this->SubscribeToMessage( Message_CurrentStepsP1Changed ); this->SubscribeToMessage( Message_CurrentStepsP2Changed ); - this->SubscribeToMessage( Message_CurrentTrailP1Changed ); - this->SubscribeToMessage( Message_CurrentTrailP2Changed ); this->SubscribeToMessage( Message_PreferredDifficultyP1Changed ); this->SubscribeToMessage( Message_PreferredDifficultyP2Changed ); } @@ -234,13 +230,6 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int m_pTextSectionCount->SetVisible( true ); } break; - case WheelItemDataType_Course: - sDisplayName = pWID->m_pCourse->GetDisplayFullTitle(); - sTranslitName = pWID->m_pCourse->GetTranslitFullTitle(); - type = MusicWheelItemType_Course; - m_WheelNotifyIcon.SetFlags( pWID->m_Flags ); - m_WheelNotifyIcon.SetVisible( true ); - break; case WheelItemDataType_Sort: sDisplayName = pWID->m_sLabel; // hack to get mode items working. -freem @@ -292,7 +281,6 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int { Message msg( "Set" ); msg.SetParam( "Song", pWID->m_pSong ); - msg.SetParam( "Course", pWID->m_pCourse ); msg.SetParam( "Index", iIndex ); msg.SetParam( "HasFocus", bHasFocus ); msg.SetParam( "Text", pWID->m_sText ); @@ -315,14 +303,12 @@ void MusicWheelItem::RefreshGrades() { m_pGradeDisplay[p]->SetVisible( false ); - if( pWID->m_pSong == NULL && pWID->m_pCourse == NULL ) + if( pWID->m_pSong == NULL) continue; Difficulty dc; if( GAMESTATE->m_pCurSteps[p] ) dc = GAMESTATE->m_pCurSteps[p]->GetDifficulty(); - else if( GAMESTATE->m_pCurTrail[p] ) - dc = GAMESTATE->m_pCurTrail[p]->m_CourseDifficulty; else dc = GAMESTATE->m_PreferredDifficulty[p]; @@ -337,8 +323,6 @@ void MusicWheelItem::RefreshGrades() StepsType st; if( GAMESTATE->m_pCurSteps[p] ) st = GAMESTATE->m_pCurSteps[p]->m_StepsType; - else if( GAMESTATE->m_pCurTrail[p] ) - st = GAMESTATE->m_pCurTrail[p]->m_StepsType; else st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType; diff --git a/src/MusicWheelItem.h b/src/MusicWheelItem.h index 6155e24d70..7e0cb3b6fd 100644 --- a/src/MusicWheelItem.h +++ b/src/MusicWheelItem.h @@ -11,7 +11,6 @@ #include "AutoActor.h" #include "ThemeMetric.h" -class Course; class Song; struct MusicWheelItemData; @@ -22,7 +21,6 @@ enum MusicWheelItemType MusicWheelItemType_SectionExpanded, MusicWheelItemType_SectionCollapsed, MusicWheelItemType_Roulette, - MusicWheelItemType_Course, MusicWheelItemType_Sort, MusicWheelItemType_Mode, MusicWheelItemType_Random, @@ -62,13 +60,12 @@ class MusicWheelItem : public WheelItemBase struct MusicWheelItemData : public WheelItemBaseData { - MusicWheelItemData() : m_pCourse(NULL), m_pSong(NULL), m_Flags(), + MusicWheelItemData() : m_pSong(NULL), m_Flags(), m_iSectionCount(0), m_sLabel(""), m_pAction() { } MusicWheelItemData( WheelItemDataType type, Song* pSong, - RString sSectionName, Course* pCourse, + RString sSectionName, RageColor color, int iSectionCount ); - Course* m_pCourse; Song* m_pSong; WheelNotifyIcon::Flags m_Flags; diff --git a/src/NetworkSyncManager.cpp b/src/NetworkSyncManager.cpp index 6e75d0f617..64fd55c31f 100644 --- a/src/NetworkSyncManager.cpp +++ b/src/NetworkSyncManager.cpp @@ -38,7 +38,6 @@ unsigned long NetworkSyncManager::GetCurrentSMBuild( LoadingWindow* ld ) { retur #include "RageLog.h" #include "ScreenManager.h" #include "Song.h" -#include "Course.h" #include "GameState.h" #include "StatsManager.h" #include "Steps.h" @@ -418,10 +417,7 @@ void NetworkSyncManager::StartRequest( short position ) m_packet.WriteNT( "" ); } - if( GAMESTATE->m_pCurCourse != NULL ) - m_packet.WriteNT( GAMESTATE->m_pCurCourse->GetDisplayFullTitle() ); - else - m_packet.WriteNT( RString() ); + m_packet.WriteNT( RString() ); //Send Player (and song) Options m_packet.WriteNT( GAMESTATE->m_SongOptions.GetCurrent().GetString() ); diff --git a/src/NoteField.cpp b/src/NoteField.cpp index fb2196125a..6c59ca13e2 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -17,7 +17,6 @@ #include "CommonMetrics.h" #include #include "BackgroundUtil.h" -#include "Course.h" #include "NoteData.h" #include "RageDisplay.h" @@ -839,28 +838,6 @@ void NoteField::DrawPrimitives() draw_all_segments(FloatToString(seg->GetLength()), Fake, FAKE); #undef draw_all_segments - // Course mods text - const Course *pCourse = GAMESTATE->m_pCurCourse; - if( pCourse ) - { - ASSERT_M( GAMESTATE->m_iEditCourseEntryIndex >= 0 && GAMESTATE->m_iEditCourseEntryIndex < (int)pCourse->m_vEntries.size(), - ssprintf("%i",GAMESTATE->m_iEditCourseEntryIndex.Get()) ); - const CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; - FOREACH_CONST( Attack, ce.attacks, a ) - { - float fSecond = a->fStartSecond; - float fBeat = timing.GetBeatFromElapsedTime( fSecond ); - - if( BeatToNoteRow(fBeat) >= m_FieldRenderArgs.first_row && - BeatToNoteRow(fBeat) <= m_FieldRenderArgs.last_row && - IS_ON_SCREEN(fBeat)) - { - DrawAttackText(fBeat, *a, text_glow); - } - } - } - else - { AttackArray &attacks = GAMESTATE->m_bIsUsingStepTiming ? GAMESTATE->m_pCurSteps[PLAYER_1]->m_Attacks : GAMESTATE->m_pCurSong->m_Attacks; @@ -878,7 +855,6 @@ void NoteField::DrawPrimitives() } } } - } if( !GAMESTATE->m_bIsUsingStepTiming ) { @@ -887,7 +863,6 @@ void NoteField::DrawPrimitives() switch( mode ) { case EditMode_Home: - case EditMode_CourseMods: case EditMode_Practice: break; case EditMode_Full: diff --git a/src/OptionRow.cpp b/src/OptionRow.cpp index 88a80fbc9f..4d9eafa25f 100644 --- a/src/OptionRow.cpp +++ b/src/OptionRow.cpp @@ -7,7 +7,6 @@ #include "CommonMetrics.h" #include "GameState.h" #include "Song.h" -#include "Course.h" #include "Style.h" #include "ActorUtil.h" @@ -201,15 +200,6 @@ RString OptionRow::GetRowTitle() const { bool bShowBpmInSpeedTitle = m_pParentType->SHOW_BPM_IN_SPEED_TITLE; - if( GAMESTATE->m_pCurCourse ) - { - const Trail* pTrail = GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()]; - ASSERT( pTrail != NULL ); - const int iNumCourseEntries = pTrail->m_vEntries.size(); - if( iNumCourseEntries > CommonMetrics::MAX_COURSE_ENTRIES_BEFORE_VARIOUS ) - bShowBpmInSpeedTitle = false; - } - if( bShowBpmInSpeedTitle ) { DisplayBpms bpms; @@ -218,14 +208,6 @@ RString OptionRow::GetRowTitle() const const Song* pSong = GAMESTATE->m_pCurSong; pSong->GetDisplayBpms( bpms ); } - else if( GAMESTATE->m_pCurCourse ) - { - const Course *pCourse = GAMESTATE->m_pCurCourse; - StepsType st = GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType; - const Trail* pTrail = pCourse->GetTrail( st ); - ASSERT( pTrail != NULL ); - pTrail->GetDisplayBpms( bpms ); - } if( bpms.IsSecret() ) sTitle += ssprintf( " (??" "?)" ); // split so gcc doesn't think this is a trigraph diff --git a/src/OptionRowHandler.cpp b/src/OptionRowHandler.cpp index 00969e3064..1ada5ed2d0 100644 --- a/src/OptionRowHandler.cpp +++ b/src/OptionRowHandler.cpp @@ -6,7 +6,6 @@ #include "RageUtil.h" #include "RageLog.h" #include "GameState.h" -#include "Course.h" #include "Steps.h" #include "Style.h" #include "Song.h" @@ -435,28 +434,6 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList m_Def.m_vsChoices.push_back( "" ); m_aListEntries.push_back( GameCommand() ); } - // TODO: Fix this OptionRow to fetch steps for all styles available. - // This is broken in kickbox game mode because kickbox uses separated - // styles. -Kyz - else if(GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()) && GAMESTATE->IsCourseMode() && GAMESTATE->m_pCurCourse) // playing a course - { - m_Def.m_bOneChoiceForAllPlayers = (bool)PREFSMAN->m_bLockCourseDifficulties; - m_Def.m_layoutType = StringToLayoutType( STEPS_ROW_LAYOUT_TYPE ); - - vector vTrails; - GAMESTATE->m_pCurCourse->GetTrails( vTrails, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType ); - for( unsigned i=0; im_CourseDifficulty ); - s += ssprintf( " %d", pTrail->GetMeter() ); - m_Def.m_vsChoices.push_back( s ); - GameCommand mc; - mc.m_pTrail = pTrail; - m_aListEntries.push_back( mc ); - } - } else if(GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()) && GAMESTATE->m_pCurSong) // playing a song { m_Def.m_layoutType = StringToLayoutType( STEPS_ROW_LAYOUT_TYPE ); @@ -493,7 +470,7 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList s = pSteps->GetDescription(); } else - s = CustomDifficultyToLocalizedString( GetCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty(), CourseType_Invalid ) ); + s = CustomDifficultyToLocalizedString( GetCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty() ) ); } } s += ssprintf( " %d", pSteps->GetMeter() ); @@ -606,7 +583,7 @@ class OptionRowHandlerSteps : public OptionRowHandler } else { - s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GAMESTATE->m_stEdit, dc, CourseType_Invalid ) ); + s = CustomDifficultyToLocalizedString( GetCustomDifficulty( GAMESTATE->m_stEdit, dc ) ); } m_Def.m_vsChoices.push_back( s ); } @@ -793,7 +770,7 @@ class OptionRowHandlerListDifficulties: public OptionRowHandlerList { // TODO: Is this the best thing we can do here? StepsType st = GAMEMAN->GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; - RString s = CustomDifficultyToLocalizedString( GetCustomDifficulty(st, *d, CourseType_Invalid) ); + RString s = CustomDifficultyToLocalizedString( GetCustomDifficulty(st, *d) ); m_Def.m_vsChoices.push_back( s ); GameCommand mc; diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 6d10fdcea1..9014416120 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -2,7 +2,6 @@ #include "OptionsList.h" #include "GameState.h" #include "RageLog.h" -#include "Course.h" #include "SongUtil.h" #include "StepsUtil.h" #include "Style.h" diff --git a/src/OptionsList.h b/src/OptionsList.h index da47274695..418a68bbe3 100644 --- a/src/OptionsList.h +++ b/src/OptionsList.h @@ -4,7 +4,6 @@ #include "ScreenWithMenuElements.h" #include "RageSound.h" #include "Steps.h" -#include "Trail.h" #include "OptionRowHandler.h" #include "BitmapText.h" #include "OptionsCursor.h" diff --git a/src/PaneDisplay.cpp b/src/PaneDisplay.cpp index 226797f96e..0fa38645dc 100644 --- a/src/PaneDisplay.cpp +++ b/src/PaneDisplay.cpp @@ -7,7 +7,6 @@ #include "RageLog.h" #include "ProfileManager.h" #include "Profile.h" -#include "Course.h" #include "Style.h" #include "ActorUtil.h" #include "Foreach.h" @@ -129,8 +128,6 @@ void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float { const Song *pSong = GAMESTATE->m_pCurSong; const Steps *pSteps = GAMESTATE->m_pCurSteps[m_PlayerNumber]; - const Course *pCourse = GAMESTATE->m_pCurCourse; - const Trail *pTrail = GAMESTATE->m_pCurTrail[m_PlayerNumber]; const Profile *pProfile = PROFILEMAN->IsPersistentProfile(m_PlayerNumber) ? PROFILEMAN->GetProfile(m_PlayerNumber) : NULL; bool bIsPlayerEdit = pSteps && pSteps->IsAPlayerEdit(); @@ -138,50 +135,8 @@ void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float sTextOut = NULL_COUNT_STRING; fLevelOut = 0; - if(GAMESTATE->IsCourseMode() && !pTrail) - { - if( (g_Contents[c].req&NEED_PROFILE) ) - sTextOut = NOT_AVAILABLE; - - { - switch( c ) - { - case PaneCategory_MachineHighName: - sTextOut = EMPTY_MACHINE_HIGH_SCORE_NAME; - break; - case PaneCategory_MachineHighScore: - case PaneCategory_ProfileHighScore: - sTextOut = NOT_AVAILABLE; - break; - default: break; - } - } - - return; - } - else if(!GAMESTATE->IsCourseMode() && !pSong) - { - if( (g_Contents[c].req&NEED_PROFILE) ) - sTextOut = NOT_AVAILABLE; - { - switch( c ) - { - case PaneCategory_MachineHighName: - sTextOut = EMPTY_MACHINE_HIGH_SCORE_NAME; - break; - case PaneCategory_MachineHighScore: - case PaneCategory_ProfileHighScore: - sTextOut = NOT_AVAILABLE; - break; - default: break; - } - } - - return; - } - - if( (g_Contents[c].req&NEED_NOTES) && !pSteps && !pTrail ) + if( (g_Contents[c].req&NEED_NOTES) && !pSteps ) return; if( (g_Contents[c].req&NEED_PROFILE) && !pProfile ) { @@ -205,11 +160,6 @@ void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float rv = pSteps->GetRadarValues( m_PlayerNumber ); pHSL = &PROFILEMAN->GetProfile(slot)->GetStepsHighScoreList(pSong, pSteps); } - else if( pTrail ) - { - rv = pTrail->GetRadarValues(); - pHSL = &PROFILEMAN->GetProfile(slot)->GetCourseHighScoreList(pCourse, pTrail); - } switch( c ) { diff --git a/src/PercentageDisplay.cpp b/src/PercentageDisplay.cpp index 120e60a16f..a977e698ca 100644 --- a/src/PercentageDisplay.cpp +++ b/src/PercentageDisplay.cpp @@ -9,7 +9,6 @@ #include "StageStats.h" #include "PlayerState.h" #include "XmlFile.h" -#include "Course.h" REGISTER_ACTOR_CLASS( PercentageDisplay ); diff --git a/src/Player.cpp b/src/Player.cpp index 82c76fa260..1a62fd4761 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -201,7 +201,7 @@ ThemeMetric CHECKPOINTS_TAPS_SEPARATE_JUDGMENT ( "Player", "CheckpointsTap * If set to true, missed holds and rolls are given LetGo judgments. * If set to false, missed holds and rolls are given no judgment on the hold side of things. */ ThemeMetric SCORE_MISSED_HOLDS_AND_ROLLS ( "Player", "ScoreMissedHoldsAndRolls" ); -/** @brief How much of the song/course must have gone by before a Player's combo is colored? */ +/** @brief How much of the song must have gone by before a Player's combo is colored? */ ThemeMetric PERCENT_UNTIL_COLOR_COMBO ( "Player", "PercentUntilColorCombo" ); /** @brief How much combo must be earned before the announcer says "Combo Stopped"? */ ThemeMetric COMBO_STOPPED_AT ( "Player", "ComboStoppedAt" ); @@ -426,16 +426,8 @@ void Player::Init( { DisplayBpms bpms; - if( GAMESTATE->IsCourseMode() ) - { - ASSERT( GAMESTATE->m_pCurTrail[pn] != NULL ); - GAMESTATE->m_pCurTrail[pn]->GetDisplayBpms( bpms ); - } - else - { - ASSERT( GAMESTATE->m_pCurSong != NULL ); - GAMESTATE->m_pCurSong->GetDisplayBpms( bpms ); - } + ASSERT( GAMESTATE->m_pCurSong != NULL ); + GAMESTATE->m_pCurSong->GetDisplayBpms( bpms ); float fMaxBPM = 0; @@ -447,7 +439,7 @@ void Player::Init( */ // all BPMs are listed and available, so try them first. - // get the maximum listed value for the song or course. + // get the maximum listed value for the song // if the BPMs are < 0, reset and get the actual values. if( !bpms.IsSecret() ) { @@ -462,25 +454,10 @@ void Player::Init( { float fThrowAway = 0; - if( GAMESTATE->IsCourseMode() ) - { - FOREACH_CONST( TrailEntry, GAMESTATE->m_pCurTrail[pn]->m_vEntries, e ) - { - float fMaxForEntry; - if (M_MOD_HIGH_CAP > 0) - e->pSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxForEntry, M_MOD_HIGH_CAP ); - else - e->pSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxForEntry ); - fMaxBPM = max( fMaxForEntry, fMaxBPM ); - } - } - else - { if (M_MOD_HIGH_CAP > 0) GAMESTATE->m_pCurSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxBPM, M_MOD_HIGH_CAP ); else GAMESTATE->m_pCurSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxBPM ); - } } ASSERT( fMaxBPM > 0 ); @@ -3316,18 +3293,8 @@ void Player::SetCombo( unsigned int iCombo, unsigned int iMisses ) * TODO: Add a metric that determines Course combo colors logic? * Or possibly move the logic to a Lua function? -aj */ bool bPastBeginning = false; - if( GAMESTATE->IsCourseMode() ) - { - int iSongIndexStartColoring = GAMESTATE->m_pCurCourse->GetEstimatedNumStages(); - iSongIndexStartColoring = - static_cast(floor(iSongIndexStartColoring*PERCENT_UNTIL_COLOR_COMBO)); - bPastBeginning = GAMESTATE->GetCourseSongIndex() >= iSongIndexStartColoring; - } - else - { - bPastBeginning = m_pPlayerState->m_Position.m_fMusicSeconds - > GAMESTATE->m_pCurSong->m_fMusicLengthSeconds * PERCENT_UNTIL_COLOR_COMBO; - } + + bPastBeginning = m_pPlayerState->m_Position.m_fMusicSeconds > GAMESTATE->m_pCurSong->m_fMusicLengthSeconds * PERCENT_UNTIL_COLOR_COMBO; if( m_bSendJudgmentAndComboMessages ) { diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index dcb79c6137..8a58417459 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -4,7 +4,6 @@ #include "GameState.h" #include "NoteSkinManager.h" #include "Song.h" -#include "Course.h" #include "Steps.h" #include "ThemeManager.h" #include "Foreach.h" @@ -921,15 +920,7 @@ bool PlayerOptions::IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerN // return true; DisplayBpms bpms; - if( GAMESTATE->IsCourseMode() ) - { - Trail *pTrail = GAMESTATE->m_pCurCourse->GetTrail( GAMESTATE->GetCurrentStyle(m_pn)->m_StepsType ); - pTrail->GetDisplayBpms( bpms ); - } - else - { - GAMESTATE->m_pCurSong->GetDisplayBpms( bpms ); - } + GAMESTATE->m_pCurSong->GetDisplayBpms( bpms ); pSong->GetDisplayBpms( bpms ); // maximum BPM is obfuscated, so M-mods will set a playable speed. @@ -940,19 +931,6 @@ bool PlayerOptions::IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerN return false; } -bool PlayerOptions::IsEasierForCourseAndTrail( Course* pCourse, Trail* pTrail ) const -{ - ASSERT( pCourse != NULL ); - ASSERT( pTrail != NULL ); - - FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) - { - if( e->pSong && IsEasierForSongAndSteps(e->pSong, e->pSteps, PLAYER_1) ) - return true; - } - return false; -} - void PlayerOptions::GetLocalizedMods( vector &AddTo ) const { vector vMods; @@ -1038,8 +1016,6 @@ void PlayerOptions::ResetPrefs( ResetPrefsType type ) CPY( m_fScrollBPM ); CPY( m_fMaxScrollBPM ); break; - case saved_prefs_invalid_for_course: - break; } CPY(m_LifeType); CPY(m_DrainType); @@ -1077,15 +1053,6 @@ class LunaPlayerOptions: public Luna lua_pushboolean(L, p->IsEasierForSongAndSteps(pSong, pSteps, pn) ); return 1; } - static int IsEasierForCourseAndTrail( T *p, lua_State *L ) - { - // course, trail - Course* pCourse = Luna::check(L,1); - Trail* pTrail = Luna::check(L,2); - lua_pushboolean(L, p->IsEasierForCourseAndTrail(pCourse, pTrail) ); - return 1; - } - // Direct control functions, for themes that can handle it. ENUM_INTERFACE(LifeSetting, LifeType, LifeType); @@ -1469,7 +1436,6 @@ class LunaPlayerOptions: public Luna LunaPlayerOptions() { ADD_METHOD( IsEasierForSongAndSteps ); - ADD_METHOD( IsEasierForCourseAndTrail ); ADD_METHOD(LifeSetting); ADD_METHOD(DrainSetting); diff --git a/src/PlayerOptions.h b/src/PlayerOptions.h index 8e54e683a0..15b359c1ca 100644 --- a/src/PlayerOptions.h +++ b/src/PlayerOptions.h @@ -1,10 +1,8 @@ #ifndef PLAYER_OPTIONS_H #define PLAYER_OPTIONS_H -class Course; class Song; class Steps; -class Trail; struct lua_State; #define ONE( arr ) { for( unsigned Z = 0; Z < ARRAYLEN(arr); ++Z ) arr[Z]=1.0f; } @@ -79,11 +77,9 @@ class PlayerOptions enum ResetPrefsType { saved_prefs, - saved_prefs_invalid_for_course }; void ResetPrefs( ResetPrefsType type ); void ResetSavedPrefs() { ResetPrefs(saved_prefs); }; - void ResetSavedPrefsInvalidForCourse() { ResetPrefs(saved_prefs_invalid_for_course); } void GetMods( vector &AddTo, bool bForceNoteSkin = false ) const; void GetLocalizedMods( vector &AddTo ) const; void FromString( const RString &sMultipleMods ); @@ -252,7 +248,6 @@ class PlayerOptions // return true if any mods being used will make the song(s) easier bool IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerNumber pn ) const; - bool IsEasierForCourseAndTrail( Course* pCourse, Trail* pTrail ) const; }; #endif diff --git a/src/PlayerStageStats.cpp b/src/PlayerStageStats.cpp index ce00f89f45..0508a03dcb 100644 --- a/src/PlayerStageStats.cpp +++ b/src/PlayerStageStats.cpp @@ -6,7 +6,6 @@ #include "LuaManager.h" #include #include "GameState.h" -#include "Course.h" #include "Steps.h" #include "NoteData.h" #include "ScoreKeeperNormal.h" @@ -209,7 +208,7 @@ Grade PlayerStageStats::GetGrade() const float fActual = 0; bool bIsBeginner = false; - if( m_iStepsPlayed > 0 && !GAMESTATE->IsCourseMode() ) + if( m_iStepsPlayed > 0 ) bIsBeginner = m_vpPossibleSteps[0]->GetDifficulty() == Difficulty_Beginner; FOREACH_ENUM( TapNoteScore, tns ) @@ -411,10 +410,6 @@ void PlayerStageStats::ResetScoreForLesson() void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond ) { - // Don't save life stats in endless courses, or could run OOM in a few hours. - if( GAMESTATE->m_pCurCourse && GAMESTATE->m_pCurCourse->IsEndless() ) - return; - if( fStepsSecond < 0 ) return; @@ -605,10 +600,6 @@ void PlayerStageStats::GetWifeRecord(float* WifeOut, int iNumSamples, float fSte * record the amount of the first combo that comes from the previous song. */ void PlayerStageStats::UpdateComboList( float fSecond, bool bRollover ) { - // Don't save combo stats in endless courses, or could run OOM in a few hours. - if( GAMESTATE->m_pCurCourse && GAMESTATE->m_pCurCourse->IsEndless() ) - return; - if( fSecond < 0 ) return; diff --git a/src/PrefsManager.cpp b/src/PrefsManager.cpp index 87b4c6fdb0..c99ce0cf6e 100644 --- a/src/PrefsManager.cpp +++ b/src/PrefsManager.cpp @@ -118,17 +118,6 @@ XToString( AttractSoundFrequency ); StringToX( AttractSoundFrequency ); LuaXType( AttractSoundFrequency ); -static const char *CourseSortOrdersNames[] = { - "Preferred", - "Songs", - "Meter", - "MeterSum", - "MeterRank", -}; -XToString( CourseSortOrders ); -StringToX( CourseSortOrders ); -LuaXType( CourseSortOrders ); - static const char *BackgroundFitModeNames[] = { "CoverDistort", "CoverPreserve", @@ -206,7 +195,6 @@ PrefsManager::PrefsManager() : m_iMaxRegenComboAfterMiss ( "MaxRegenComboAfterMiss", 5 ), // this was 10 by default in SM3.95 -dguzek m_bMercifulDrain ( "MercifulDrain", false ), // negative life deltas are scaled by the players life percentage m_HarshHotLifePenalty ( "HarshHotLifePenalty", true ), - m_bMinimum1FullSongInCourses ( "Minimum1FullSongInCourses", false ), // FEoS for 1st song, FailImmediate thereafter m_bFailOffInBeginner ( "FailOffInBeginner", false ), m_bFailOffForFirstStageEasy ( "FailOffForFirstStageEasy", false ), m_bMercifulBeginner ( "MercifulBeginner", false ), @@ -233,14 +221,11 @@ PrefsManager::PrefsManager() : m_bPercentageScoring ( "PercentageScoring", false ), // Wow, these preference names are *seriously* long -Colby m_fMinPercentageForMachineSongHighScore ( "MinPercentageForMachineSongHighScore", 0.0001f ), // This is for home, who cares how bad you do? - m_fMinPercentageForMachineCourseHighScore ( "MinPercentageForMachineCourseHighScore", 0.0001f ), // don't save course scores with 0 percentage m_bDisqualification ( "Disqualification", false ), m_bAutogenLights ("AutogenLights", false), m_bAutogenSteps ( "AutogenSteps", false ), - m_bAutogenGroupCourses ( "AutogenGroupCourses", true ), m_bOnlyPreferredDifficulties ( "OnlyPreferredDifficulties", false ), m_bBreakComboToGetItem ( "BreakComboToGetItem", false ), - m_bLockCourseDifficulties ( "LockCourseDifficulties", true ), m_ShowDancingCharacters ( "ShowDancingCharacters", SDC_Off ), m_bUseUnlockSystem ( "UseUnlockSystem", false ), m_fGlobalOffsetSeconds ( "GlobalOffsetSeconds", 0 ), @@ -265,20 +250,14 @@ PrefsManager::PrefsManager() : m_bCelShadeModels ( "CelShadeModels", false ), // Work-In-Progress.. disable by default. m_bPreferredSortUsesGroups ( "PreferredSortUsesGroups", true ), m_fDebounceCoinInputTime ( "DebounceCoinInputTime", 0 ), - m_fPadStickSeconds ( "PadStickSeconds", 0 ), m_EditRecordModeLeadIn ("EditRecordModeLeadIn", 1.0f ), m_EditClearPromptThreshold ("EditClearPromptThreshold", 50), m_bForceMipMaps ( "ForceMipMaps", false ), m_bTrilinearFiltering ( "TrilinearFiltering", false ), m_bAnisotropicFiltering ( "AnisotropicFiltering", false ), - m_bSignProfileData ( "SignProfileData", false ), - m_CourseSortOrder ( "CourseSortOrder", COURSE_SORT_SONGS ), - m_bSubSortByNumSteps ( "SubSortByNumSteps", false ), - m_GetRankingName ( "GetRankingName", RANKING_ON ), m_sAdditionalSongFolders ( "AdditionalSongFolders", "" ), - m_sAdditionalCourseFolders ( "AdditionalCourseFolders", "" ), m_sAdditionalFolders ( "AdditionalFolders", "" ), m_sDefaultTheme ( "DefaultTheme", "Til Death" ), m_sLastSeenVideoDriver ( "LastSeenVideoDriver", "" ), @@ -295,7 +274,6 @@ PrefsManager::PrefsManager() : m_bDebugLights ( "DebugLights", false ), m_bMonkeyInput ( "MonkeyInput", false ), m_sMachineName ( "MachineName", "" ), - m_sCoursesToShowRanking ( "CoursesToShowRanking", "" ), m_MuteActions ( "MuteActions", false ), m_bAllowSongDeletion ( "AllowSongDeletion", false ), diff --git a/src/PrefsManager.h b/src/PrefsManager.h index ccdda2f1e3..f5bc8d2c54 100644 --- a/src/PrefsManager.h +++ b/src/PrefsManager.h @@ -102,16 +102,6 @@ enum AttractSoundFrequency NUM_AttractSoundFrequency, AttractSoundFrequency_Invalid }; -enum CourseSortOrders -{ - COURSE_SORT_PREFERRED, - COURSE_SORT_SONGS, - COURSE_SORT_METER, - COURSE_SORT_METER_SUM, - COURSE_SORT_RANK, - NUM_CourseSortOrders, - CourseSortOrders_Invalid -}; enum BackgroundFitMode { BFM_CoverDistort, @@ -198,7 +188,6 @@ class PrefsManager Preference m_iMaxRegenComboAfterMiss; // caps RegenComboAfterMiss if multiple Misses occur in rapid succession Preference m_bMercifulDrain; // negative life deltas are scaled by the players life percentage Preference m_HarshHotLifePenalty; // See LifeMeterBar.cpp -Kyz - Preference m_bMinimum1FullSongInCourses; // FEoS for 1st song, FailImmediate thereafter Preference m_bFailOffInBeginner; Preference m_bFailOffForFirstStageEasy; Preference m_bMercifulBeginner; // don't subtract from percent score or grade DP, larger W5 window @@ -224,14 +213,11 @@ class PrefsManager Preference m_bDancePointsForOni; Preference m_bPercentageScoring; Preference m_fMinPercentageForMachineSongHighScore; - Preference m_fMinPercentageForMachineCourseHighScore; Preference m_bDisqualification; Preference m_bAutogenLights; Preference m_bAutogenSteps; - Preference m_bAutogenGroupCourses; Preference m_bOnlyPreferredDifficulties; Preference m_bBreakComboToGetItem; - Preference m_bLockCourseDifficulties; Preference m_ShowDancingCharacters; Preference m_bUseUnlockSystem; Preference m_fGlobalOffsetSeconds; @@ -278,13 +264,7 @@ class PrefsManager // profile's data will be discarded. Preference m_bSignProfileData; - // course ranking - Preference m_CourseSortOrder; - Preference m_bSubSortByNumSteps; - Preference m_GetRankingName; - Preference m_sAdditionalSongFolders; - Preference m_sAdditionalCourseFolders; Preference m_sAdditionalFolders; // failsafe @@ -304,7 +284,6 @@ class PrefsManager Preference m_bDebugLights; Preference m_bMonkeyInput; Preference m_sMachineName; - Preference m_sCoursesToShowRanking; Preference m_MuteActions; Preference m_bAllowSongDeletion; // Allow the user to remove songs from their collection through UI / keyboard shortcut diff --git a/src/Profile.cpp b/src/Profile.cpp index d07df5b4b0..1446c37967 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -10,7 +10,6 @@ #include "Song.h" #include "SongManager.h" #include "Steps.h" -#include "Course.h" #include "ThemeManager.h" #include "CryptManager.h" #include "ProfileManager.h" @@ -43,7 +42,6 @@ const RString DONT_SHARE_SIG = "DontShare.sig"; const RString PUBLIC_KEY_FILE = "public.key"; const RString SCREENSHOTS_SUBDIR = "Screenshots/"; const RString EDIT_STEPS_SUBDIR = "Edits/"; -const RString EDIT_COURSES_SUBDIR = "EditCourses/"; //const RString UPLOAD_SUBDIR = "Upload/"; const RString RIVAL_SUBDIR = "Rivals/"; const RString REPLAY_SUBDIR = "ReplayData/"; @@ -87,17 +85,6 @@ int Profile::HighScoresForASong::GetNumTimesPlayed() const return iCount; } -int Profile::HighScoresForACourse::GetNumTimesPlayed() const -{ - int iCount = 0; - FOREACHM_CONST( TrailID, HighScoresForATrail, m_TrailHighScores, i ) - { - iCount += i->second.hsl.GetNumTimesPlayed(); - } - return iCount; -} - - void Profile::InitEditableData() { m_sDisplayName = ""; @@ -130,10 +117,8 @@ void Profile::InitGeneralData() m_SortOrder = SortOrder_Invalid; m_LastDifficulty = Difficulty_Invalid; - m_LastCourseDifficulty = Difficulty_Invalid; m_LastStepsType = StepsType_Invalid; m_lastSong.Unset(); - m_lastCourse.Unset(); m_iCurrentCombo = 0; m_iTotalSessions = 0; m_iTotalSessionSeconds = 0; @@ -174,11 +159,6 @@ void Profile::InitSongScores() m_SongHighScores.clear(); } -void Profile::InitCourseScores() -{ - m_CourseHighScores.clear(); -} - void Profile::InitCategoryScores() { FOREACH_ENUM( StepsType,st ) @@ -256,35 +236,6 @@ int Profile::GetTotalStepsWithTopGrade( StepsType st, Difficulty d, Grade g ) co return iCount; } -int Profile::GetTotalTrailsWithTopGrade( StepsType st, CourseDifficulty d, Grade g ) const -{ - int iCount = 0; - - // add course high scores - vector vCourses; - SONGMAN->GetAllCourses( vCourses, false ); - FOREACH_CONST( Course*, vCourses, pCourse ) - { - // Don't count any course that has any entries that change over time. - if( !(*pCourse)->AllSongsAreFixed() ) - continue; - - vector vTrails; - Trail* pTrail = (*pCourse)->GetTrail( st, d ); - if( pTrail == NULL ) - continue; - - const HighScoreList &hsl = GetCourseHighScoreList( *pCourse, pTrail ); - if( hsl.vHighScores.empty() ) - continue; // skip - - if( hsl.vHighScores[0].GetGrade() == g ) - iCount++; - } - - return iCount; -} - float Profile::GetSongsPossible( StepsType st, Difficulty dc ) const { int iTotalSteps = 0; @@ -378,81 +329,6 @@ float Profile::GetSongsPercentComplete( StepsType st, Difficulty dc ) const return GetSongsActual(st,dc) / GetSongsPossible(st,dc); } -static void GetHighScoreCourses( vector &vpCoursesOut ) -{ - vpCoursesOut.clear(); - - vector vpCourses; - SONGMAN->GetAllCourses( vpCourses, false ); - FOREACH_CONST( Course*, vpCourses, c ) - { - // Don't count any course that has any entries that change over time. - if( !(*c)->AllSongsAreFixed() ) - continue; - - vpCoursesOut.push_back( *c ); - } -} - -float Profile::GetCoursesPossible( StepsType st, CourseDifficulty cd ) const -{ - int iTotalTrails = 0; - - vector vpCourses; - GetHighScoreCourses( vpCourses ); - FOREACH_CONST( Course*, vpCourses, c ) - { - Trail* pTrail = (*c)->GetTrail(st,cd); - if( pTrail == NULL ) - continue; - - iTotalTrails++; - } - - return (float) iTotalTrails; -} - -float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const -{ - float fTotalPercents = 0; - - vector vpCourses; - GetHighScoreCourses( vpCourses ); - FOREACH_CONST( Course*, vpCourses, c ) - { - Trail *pTrail = (*c)->GetTrail( st, cd ); - if( pTrail == NULL ) - continue; - - const HighScoreList& hsl = GetCourseHighScoreList( *c, pTrail ); - fTotalPercents += hsl.GetTopScore().GetPercentDP(); - } - - return fTotalPercents; -} - -float Profile::GetCoursesPercentComplete( StepsType st, CourseDifficulty cd ) const -{ - return GetCoursesActual(st,cd) / GetCoursesPossible(st,cd); -} - -float Profile::GetSongsAndCoursesPercentCompleteAllDifficulties( StepsType st ) const -{ - float fActual = 0; - float fPossible = 0; - FOREACH_ENUM( Difficulty, d ) - { - fActual += GetSongsActual(st,d); - fPossible += GetSongsPossible(st,d); - } - FOREACH_ENUM( CourseDifficulty, d ) - { - fActual += GetCoursesActual(st,d); - fPossible += GetCoursesPossible(st,d); - } - return fActual / fPossible; -} - int Profile::GetSongNumTimesPlayed( const Song* pSong ) const { SongID songID; @@ -526,23 +402,6 @@ Song *Profile::GetMostPopularSong() const return id.ToSong(); } -Course *Profile::GetMostPopularCourse() const -{ - int iMaxNumTimesPlayed = 0; - CourseID id; - FOREACHM_CONST( CourseID, HighScoresForACourse, m_CourseHighScores, i ) - { - int iNumTimesPlayed = i->second.GetNumTimesPlayed(); - if(i->first.ToCourse() != NULL && iNumTimesPlayed > iMaxNumTimesPlayed) - { - id = i->first; - iMaxNumTimesPlayed = iNumTimesPlayed; - } - } - - return id.ToCourse(); -} - // Steps high scores void Profile::AddStepsHighScore( const Song* pSong, const Steps* pSteps, HighScore hs, int &iIndexOut ) { @@ -650,82 +509,6 @@ void Profile::GetGrades( const Song* pSong, StepsType st, int iCounts[NUM_Grade] } } -// Course high scores -void Profile::AddCourseHighScore( const Course* pCourse, const Trail* pTrail, HighScore hs, int &iIndexOut ) -{ - GetCourseHighScoreList(pCourse,pTrail).AddHighScore( hs, iIndexOut, IsMachine() ); -} - -const HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, const Trail* pTrail ) const -{ - return ((Profile *)this)->GetCourseHighScoreList( pCourse, pTrail ); -} - -HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, const Trail* pTrail ) -{ - CourseID courseID; - courseID.FromCourse( pCourse ); - - TrailID trailID; - trailID.FromTrail( pTrail ); - - HighScoresForACourse &hsCourse = m_CourseHighScores[courseID]; // operator[] inserts into map - HighScoresForATrail &hsTrail = hsCourse.m_TrailHighScores[trailID]; // operator[] inserts into map - - return hsTrail.hsl; -} - -int Profile::GetCourseNumTimesPlayed( const Course* pCourse ) const -{ - CourseID courseID; - courseID.FromCourse( pCourse ); - - return GetCourseNumTimesPlayed( courseID ); -} - -int Profile::GetCourseNumTimesPlayed( const CourseID &courseID ) const -{ - const HighScoresForACourse *hsCourse = GetHighScoresForACourse( courseID ); - if( hsCourse == NULL ) - return 0; - - int iTotalNumTimesPlayed = 0; - FOREACHM_CONST( TrailID, HighScoresForATrail, hsCourse->m_TrailHighScores, j ) - { - const HighScoresForATrail &hsTrail = j->second; - - iTotalNumTimesPlayed += hsTrail.hsl.GetNumTimesPlayed(); - } - return iTotalNumTimesPlayed; -} - -DateTime Profile::GetCourseLastPlayedDateTime( const Course* pCourse ) const -{ - CourseID id; - id.FromCourse( pCourse ); - std::map::const_iterator iter = m_CourseHighScores.find( id ); - - // don't call this unless has been played once - ASSERT( iter != m_CourseHighScores.end() ); - ASSERT( !iter->second.m_TrailHighScores.empty() ); - - DateTime dtLatest; // starts out zeroed - FOREACHM_CONST( TrailID, HighScoresForATrail, iter->second.m_TrailHighScores, i ) - { - const HighScoreList &hsl = i->second.hsl; - if( hsl.GetNumTimesPlayed() == 0 ) - continue; - if( dtLatest < hsl.GetLastPlayed() ) - dtLatest = hsl.GetLastPlayed(); - } - return dtLatest; -} - -void Profile::IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail ) -{ - DateTime now = DateTime::GetNowDate(); - GetCourseHighScoreList(pCourse,pTrail).IncrementPlayCount( now ); -} void Profile::GetAllUsedHighScoreNames(std::set& names) { @@ -750,7 +533,6 @@ void Profile::GetAllUsedHighScoreNames(std::set& names) } \ } GET_NAMES_FROM_MAP(m_SongHighScores, SongID, HighScoresForASong, m_StepsHighScores, StepsID, HighScoresForASteps); - GET_NAMES_FROM_MAP(m_CourseHighScores, CourseID, HighScoresForACourse, m_TrailHighScores, TrailID, HighScoresForATrail); #undef GET_NAMES_FROM_MAP } @@ -834,7 +616,6 @@ void Profile::MergeScoresFromOtherProfile(Profile* other, bool skip_totals, } \ } MERGE_SCORES_IN_MEMBER(m_SongHighScores, SongID, HighScoresForASong, m_StepsHighScores, StepsID, HighScoresForASteps); - MERGE_SCORES_IN_MEMBER(m_CourseHighScores, CourseID, HighScoresForACourse, m_TrailHighScores, TrailID, HighScoresForATrail); #undef MERGE_SCORES_IN_MEMBER // I think the machine profile should not have screenshots merged into it // because the intended use case is someone whose profile scores were @@ -916,7 +697,6 @@ void Profile::swap(Profile& other) SWAP_ARRAY(m_iNumStagesPassedByGrade, NUM_Grade); SWAP_GENERAL(m_UserTable); SWAP_STR_MEMBER(m_SongHighScores); - SWAP_STR_MEMBER(m_CourseHighScores); for(int st= 0; st < NUM_StepsType; ++st) { SWAP_ARRAY(m_CategoryHighScores[st], NUM_RankingCategory); @@ -1008,10 +788,8 @@ void Profile::HandleStatsPrefixChange(RString dir, bool require_signature) map default_mods= m_sDefaultModifiers; SortOrder sort_order= m_SortOrder; Difficulty last_diff= m_LastDifficulty; - CourseDifficulty last_course_diff= m_LastCourseDifficulty; StepsType last_stepstype= m_LastStepsType; SongID last_song= m_lastSong; - CourseID last_course= m_lastCourse; int total_sessions= m_iTotalSessions; int total_session_seconds= m_iTotalSessionSeconds; int total_gameplay_seconds= m_iTotalGameplaySeconds; @@ -1035,7 +813,6 @@ void Profile::HandleStatsPrefixChange(RString dir, bool require_signature) m_sDefaultModifiers= default_mods; m_SortOrder= sort_order; m_LastDifficulty= last_diff; - m_LastCourseDifficulty= last_course_diff; m_LastStepsType= last_stepstype; m_lastSong= last_song; m_iTotalSessions= total_sessions; @@ -1246,7 +1023,6 @@ ProfileLoadResult Profile::LoadStatsXmlFromNode( const XNode *xml, bool bIgnoreE LOAD_NODE( GeneralData ); LOAD_NODE( SongScores ); - LOAD_NODE( CourseScores ); LOAD_NODE( CategoryScores ); LOAD_NODE( ScreenshotData ); @@ -1297,8 +1073,6 @@ bool Profile::SaveAllToDir( const RString &sDir, bool bSignData ) const // Empty directories if none exist. if( ProfileManager::m_bProfileStepEdits ) FILEMAN->CreateDir( sDir + EDIT_STEPS_SUBDIR ); - if( ProfileManager::m_bProfileCourseEdits ) - FILEMAN->CreateDir( sDir + EDIT_COURSES_SUBDIR ); FILEMAN->CreateDir( sDir + SCREENSHOTS_SUBDIR ); FILEMAN->CreateDir( sDir + RIVAL_SUBDIR ); FILEMAN->CreateDir( sDir + REPLAY_SUBDIR); @@ -1331,7 +1105,6 @@ XNode *Profile::SaveStatsXmlCreateNode() const xml->AppendChild( SaveGeneralDataCreateNode() ); xml->AppendChild( SaveSongScoresCreateNode() ); - xml->AppendChild( SaveCourseScoresCreateNode() ); xml->AppendChild( SaveCategoryScoresCreateNode() ); xml->AppendChild( SaveScreenshotDataCreateNode() ); if( SHOW_COIN_DATA.GetValue() && IsMachine() ) @@ -1486,11 +1259,9 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "Guid", m_sGuid ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); pGeneralDataNode->AppendChild( "LastDifficulty", DifficultyToString(m_LastDifficulty) ); - pGeneralDataNode->AppendChild( "LastCourseDifficulty", DifficultyToString(m_LastCourseDifficulty) ); if( m_LastStepsType != StepsType_Invalid ) pGeneralDataNode->AppendChild( "LastStepsType", GAMEMAN->GetStepsTypeInfo(m_LastStepsType).szName ); pGeneralDataNode->AppendChild( m_lastSong.CreateNode() ); - pGeneralDataNode->AppendChild( m_lastCourse.CreateNode() ); pGeneralDataNode->AppendChild( "CurrentCombo", m_iCurrentCombo ); pGeneralDataNode->AppendChild( "TotalSessions", m_iTotalSessions ); pGeneralDataNode->AppendChild( "TotalSessionSeconds", m_iTotalSessionSeconds ); @@ -1676,10 +1447,8 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) pNode->GetChildValue( "Guid", m_sGuid ); pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s ); pNode->GetChildValue( "LastDifficulty", s ); m_LastDifficulty = StringToDifficulty( s ); - pNode->GetChildValue( "LastCourseDifficulty", s ); m_LastCourseDifficulty = StringToDifficulty( s ); pNode->GetChildValue( "LastStepsType", s ); m_LastStepsType = GAMEMAN->StringToStepsType( s ); pTemp = pNode->GetChild( "Song" ); if( pTemp ) m_lastSong.LoadFromNode( pTemp ); - pTemp = pNode->GetChild( "Course" ); if( pTemp ) m_lastCourse.LoadFromNode( pTemp ); pNode->GetChildValue( "CurrentCombo", m_iCurrentCombo ); pNode->GetChildValue( "TotalSessions", m_iTotalSessions ); pNode->GetChildValue( "TotalSessionSeconds", m_iTotalSessionSeconds ); @@ -2248,116 +2017,6 @@ HighScore* Profile::GetTopSSRHighScore(unsigned int rank, int ss) { return NULL; } -XNode* Profile::SaveCourseScoresCreateNode() const -{ - CHECKPOINT_M("Getting the node to save course scores."); - - const Profile* pProfile = this; - ASSERT( pProfile != NULL ); - - XNode* pNode = new XNode( "CourseScores" ); - - FOREACHM_CONST( CourseID, HighScoresForACourse, m_CourseHighScores, i ) - { - const CourseID &courseID = i->first; - const HighScoresForACourse &hsCourse = i->second; - - // skip courses that have never been played - if( pProfile->GetCourseNumTimesPlayed(courseID) == 0 ) - continue; - - XNode* pCourseNode = pNode->AppendChild( courseID.CreateNode() ); - - FOREACHM_CONST( TrailID, HighScoresForATrail, hsCourse.m_TrailHighScores, j ) - { - const TrailID &trailID = j->first; - const HighScoresForATrail &hsTrail = j->second; - - const HighScoreList &hsl = hsTrail.hsl; - - // skip steps that have never been played - if( hsl.GetNumTimesPlayed() == 0 ) - continue; - - XNode* pTrailNode = pCourseNode->AppendChild( trailID.CreateNode() ); - - pTrailNode->AppendChild( hsl.CreateNode() ); - } - } - - return pNode; -} - -void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores ) -{ - CHECKPOINT_M("Loading the node that contains course scores."); - - ASSERT( pCourseScores->GetName() == "CourseScores" ); - - vector vpAllCourses; - SONGMAN->GetAllCourses( vpAllCourses, true ); - - FOREACH_CONST_Child( pCourseScores, pCourse ) - { - if( pCourse->GetName() != "Course" ) - continue; - - CourseID courseID; - courseID.LoadFromNode( pCourse ); - // Allow invalid courses so that scores aren't deleted for people that use - // AdditionalCoursesFolders and change it frequently. -Kyz - //if( !courseID.IsValid() ) - // WARN_AND_CONTINUE; - - - // Backward compatability hack to fix importing scores of old style - // courses that weren't in group folder but have now been moved into - // a group folder: - // If the courseID doesn't resolve, then take the file name part of sPath - // and search for matches of just the file name. - { - Course *pC = courseID.ToCourse(); - if( pC == NULL ) - { - RString sDir, sFName, sExt; - splitpath( courseID.GetPath(), sDir, sFName, sExt ); - RString sFullFileName = sFName + sExt; - - FOREACH_CONST( Course*, vpAllCourses, c ) - { - RString sOther = (*c)->m_sPath.Right(sFullFileName.size()); - - if( sFullFileName.CompareNoCase(sOther) == 0 ) - { - pC = *c; - courseID.FromCourse( pC ); - break; - } - } - } - } - - - FOREACH_CONST_Child( pCourse, pTrail ) - { - if( pTrail->GetName() != "Trail" ) - continue; - - TrailID trailID; - trailID.LoadFromNode( pTrail ); - if( !trailID.IsValid() ) - WARN_AND_CONTINUE; - - const XNode *pHighScoreListNode = pTrail->GetChild("HighScoreList"); - if( pHighScoreListNode == NULL ) - WARN_AND_CONTINUE; - - HighScoreList &hsl = m_CourseHighScores[courseID].m_TrailHighScores[trailID].hsl; - hsl.LoadFromNode( pHighScoreListNode ); - } - } -} - XNode* Profile::SaveCategoryScoresCreateNode() const { CHECKPOINT_M("Getting the node that saves category scores."); @@ -2492,15 +2151,6 @@ const Profile::HighScoresForASong *Profile::GetHighScoresForASong( const SongID& return &it->second; } -const Profile::HighScoresForACourse *Profile::GetHighScoresForACourse( const CourseID& courseID ) const -{ - map::const_iterator it; - it = m_CourseHighScores.find( courseID ); - if( it == m_CourseHighScores.end() ) - return NULL; - return &it->second; -} - bool Profile::IsMachine() const { // TODO: Think of a better way to handle this @@ -2643,16 +2293,8 @@ class LunaProfile : public Luna hsl.PushSelf(L); return 1; } - else if (LuaBinding::CheckLuaObjectType(L, 1, "Course")) - { - const Course *pCourse = Luna::check(L, 1); - const Trail *pTrail = Luna::check(L, 2); - HighScoreList &hsl = p->GetCourseHighScoreList(pCourse, pTrail); - hsl.PushSelf(L); - return 1; - } - luaL_typerror(L, 1, "Song or Course"); + luaL_typerror(L, 1, "Song"); COMMON_RETURN_SELF; } @@ -2723,11 +2365,7 @@ class LunaProfile : public Luna { GET_IF_EXISTS(Song, Steps); } - else if (LuaBinding::CheckLuaObjectType(L, 1, "Course")) - { - GET_IF_EXISTS(Course, Trail); - } - luaL_typerror(L, 1, "Song or Course"); + luaL_typerror(L, 1, "Song"); return 0; #undef GET_IF_EXISTS } @@ -2753,18 +2391,13 @@ class LunaProfile : public Luna static int GetTotalNumSongsPlayed(T* p, lua_State *L) { lua_pushnumber(L, p->m_iNumTotalSongsPlayed); return 1; } static int IsCodeUnlocked(T* p, lua_State *L) { lua_pushboolean(L, p->IsCodeUnlocked(SArg(1))); return 1; } static int GetSongsActual(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsActual(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } - static int GetCoursesActual(T* p, lua_State *L) { lua_pushnumber(L, p->GetCoursesActual(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } static int GetSongsPossible(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsPossible(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } - static int GetCoursesPossible(T* p, lua_State *L) { lua_pushnumber(L, p->GetCoursesPossible(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } static int GetSongsPercentComplete(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsPercentComplete(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } - static int GetCoursesPercentComplete(T* p, lua_State *L) { lua_pushnumber(L, p->GetCoursesPercentComplete(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } static int GetTotalStepsWithTopGrade(T* p, lua_State *L) { lua_pushnumber(L, p->GetTotalStepsWithTopGrade(Enum::Check(L, 1), Enum::Check(L, 2), Enum::Check(L, 3))); return 1; } - static int GetTotalTrailsWithTopGrade(T* p, lua_State *L) { lua_pushnumber(L, p->GetTotalTrailsWithTopGrade(Enum::Check(L, 1), Enum::Check(L, 2), Enum::Check(L, 3))); return 1; } static int GetNumTotalSongsPlayed(T* p, lua_State *L) { lua_pushnumber(L, p->m_iNumTotalSongsPlayed); return 1; } static int GetTotalSessions(T* p, lua_State *L) { lua_pushnumber(L, p->m_iTotalSessions); return 1; } static int GetTotalSessionSeconds(T* p, lua_State *L) { lua_pushnumber(L, p->m_iTotalSessionSeconds); return 1; } static int GetTotalGameplaySeconds(T* p, lua_State *L) { lua_pushnumber(L, p->m_iTotalGameplaySeconds); return 1; } - static int GetSongsAndCoursesPercentCompleteAllDifficulties(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsAndCoursesPercentCompleteAllDifficulties(Enum::Check(L, 1))); return 1; } static int GetPlayerRating(T* p, lua_State *L) { lua_pushnumber(L, p->m_fPlayerRating); return 1; } static int GetMostPopularSong(T* p, lua_State *L) { @@ -2775,15 +2408,6 @@ class LunaProfile : public Luna lua_pushnil(L); return 1; } - static int GetMostPopularCourse(T* p, lua_State *L) - { - Course *p2 = p->GetMostPopularCourse(); - if (p2) - p2->PushSelf(L); - else - lua_pushnil(L); - return 1; - } static int GetSongNumTimesPlayed(T* p, lua_State *L) { ASSERT(!lua_isnil(L, 1)); @@ -2884,20 +2508,14 @@ class LunaProfile : public Luna ADD_METHOD( GetTotalNumSongsPlayed ); ADD_METHOD( IsCodeUnlocked ); ADD_METHOD( GetSongsActual ); - ADD_METHOD( GetCoursesActual ); ADD_METHOD( GetSongsPossible ); - ADD_METHOD( GetCoursesPossible ); ADD_METHOD( GetSongsPercentComplete ); - ADD_METHOD( GetCoursesPercentComplete ); ADD_METHOD( GetTotalStepsWithTopGrade ); - ADD_METHOD( GetTotalTrailsWithTopGrade ); ADD_METHOD( GetNumTotalSongsPlayed ); ADD_METHOD( GetTotalSessions ); ADD_METHOD( GetTotalSessionSeconds ); ADD_METHOD( GetTotalGameplaySeconds ); - ADD_METHOD( GetSongsAndCoursesPercentCompleteAllDifficulties ); ADD_METHOD( GetMostPopularSong ); - ADD_METHOD( GetMostPopularCourse ); ADD_METHOD( GetSongNumTimesPlayed ); ADD_METHOD( HasPassedAnyStepsInSong ); ADD_METHOD( GetNumToasties ); diff --git a/src/Profile.h b/src/Profile.h index 49b17cafb5..5df3581607 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -10,8 +10,6 @@ #include "DateTime.h" #include "SongUtil.h" // for SongID #include "StepsUtil.h" // for StepsID -#include "CourseUtil.h" // for CourseID -#include "TrailUtil.h" // for TrailID #include "StyleUtil.h" // for StyleID #include "LuaReference.h" #include "ChartScores.h" @@ -48,7 +46,6 @@ extern const RString PUBLIC_KEY_FILE; extern const RString SCREENSHOTS_SUBDIR; extern const RString REPLAY_SUBDIR; extern const RString EDIT_STEPS_SUBDIR; -extern const RString EDIT_COURSES_SUBDIR; extern const RString LASTGOOD_SUBDIR; // extern const RString RIVAL_SUBDIR; @@ -60,7 +57,6 @@ class Style; class Song; class Steps; -class Course; struct Game; // Profile types exist for sorting the list of profiles. @@ -128,9 +124,8 @@ class Profile m_sGuid(MakeGuid()), m_sDefaultModifiers(), m_SortOrder(SortOrder_Invalid), m_LastDifficulty(Difficulty_Invalid), - m_LastCourseDifficulty(Difficulty_Invalid), - m_LastStepsType(StepsType_Invalid), m_lastSong(), - m_lastCourse(), m_iCurrentCombo(0), m_iTotalSessions(0), + m_LastStepsType(StepsType_Invalid), m_lastSong() + , m_iCurrentCombo(0), m_iTotalSessions(0), m_iTotalSessionSeconds(0), m_iTotalGameplaySeconds(0), m_iTotalDancePoints(0), m_iNumExtraStagesPassed(0), m_iNumExtraStagesFailed(0), @@ -140,11 +135,10 @@ class Profile m_UnlockedEntryIDs(), m_sLastPlayedMachineGuid(""), m_LastPlayedDate(),m_iNumSongsPlayedByStyle(), m_iNumTotalSongsPlayed(0), m_UserTable(), m_SongHighScores(), - m_CourseHighScores(), m_vScreenshots(), + m_vScreenshots(), profiledir(""), IsEtternaProfile(false) { m_lastSong.Unset(); - m_lastCourse.Unset(); m_LastPlayedDate.Init(); @@ -170,19 +164,14 @@ class Profile void SetCharacter(const RString &sCharacterID); int GetTotalNumSongsPassed() const; int GetTotalStepsWithTopGrade( StepsType st, Difficulty d, Grade g ) const; - int GetTotalTrailsWithTopGrade( StepsType st, CourseDifficulty d, Grade g ) const; float GetSongsPossible( StepsType st, Difficulty dc ) const; - float GetCoursesPossible( StepsType st, CourseDifficulty cd ) const; float GetSongsActual( StepsType st, Difficulty dc ) const; - float GetCoursesActual( StepsType st, CourseDifficulty cd ) const; float GetSongsPercentComplete( StepsType st, Difficulty dc ) const; - float GetCoursesPercentComplete( StepsType st, CourseDifficulty cd ) const; float GetSongsAndCoursesPercentCompleteAllDifficulties( StepsType st ) const; bool GetDefaultModifiers( const Game* pGameType, RString &sModifiersOut ) const; void SetDefaultModifiers( const Game* pGameType, const RString &sModifiers ); bool IsCodeUnlocked( const RString &sUnlockEntryID ) const; Song *GetMostPopularSong() const; - Course *GetMostPopularCourse() const; void AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumRolls, int iNumMines, int iNumHands, int iNumLifts ); @@ -210,10 +199,8 @@ class Profile map m_sDefaultModifiers; SortOrder m_SortOrder; Difficulty m_LastDifficulty; - CourseDifficulty m_LastCourseDifficulty; StepsType m_LastStepsType; SongID m_lastSong; - CourseID m_lastCourse; int m_iCurrentCombo; int m_iTotalSessions; int m_iTotalSessionSeconds; @@ -307,30 +294,6 @@ class Profile bool HasPassedSteps( const Song* pSong, const Steps* pSteps ) const; bool HasPassedAnyStepsInSong( const Song* pSong ) const; - // Course high scores - // struct was a typedef'd array of HighScores, but VC6 freaks out - // in processing the templates for map::operator[]. - struct HighScoresForATrail - { - HighScoreList hsl; - HighScoresForATrail(): hsl() {} - }; - struct HighScoresForACourse - { - std::map m_TrailHighScores; - int GetNumTimesPlayed() const; - HighScoresForACourse(): m_TrailHighScores() {} - }; - std::map m_CourseHighScores; - - void AddCourseHighScore( const Course* pCourse, const Trail* pTrail, HighScore hs, int &iIndexOut ); - HighScoreList& GetCourseHighScoreList( const Course* pCourse, const Trail* pTrail ); - const HighScoreList& GetCourseHighScoreList( const Course* pCourse, const Trail* pTrail ) const; - int GetCourseNumTimesPlayed( const Course* pCourse ) const; - int GetCourseNumTimesPlayed( const CourseID& courseID ) const; - DateTime GetCourseLastPlayedDateTime( const Course* pCourse ) const; - void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail ); - void GetAllUsedHighScoreNames(std::set& names); void MergeScoresFromOtherProfile(Profile* other, bool skip_totals, @@ -361,14 +324,12 @@ class Profile InitEditableData(); InitGeneralData(); InitSongScores(); - InitCourseScores(); InitCategoryScores(); InitScreenshotData(); } void InitEditableData(); void InitGeneralData(); void InitSongScores(); - void InitCourseScores(); void InitCategoryScores(); void InitScreenshotData(); void ClearStats(); @@ -388,7 +349,6 @@ class Profile void LoadGeneralDataFromNode( const XNode* pNode ); void LoadSongScoresFromNode( const XNode* pNode ); - void LoadCourseScoresFromNode( const XNode* pNode ); void LoadCategoryScoresFromNode( const XNode* pNode ); void LoadScreenshotDataFromNode( const XNode* pNode ); @@ -401,7 +361,6 @@ class Profile XNode* SaveGeneralDataCreateNode() const; XNode* SaveSongScoresCreateNode() const; - XNode* SaveCourseScoresCreateNode() const; XNode* SaveCategoryScoresCreateNode() const; XNode* SaveScreenshotDataCreateNode() const; @@ -438,7 +397,6 @@ class Profile private: const HighScoresForASong *GetHighScoresForASong( const SongID& songID ) const; - const HighScoresForACourse *GetHighScoresForACourse( const CourseID& courseID ) const; }; diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp index 03886af82b..94c30e6a70 100644 --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -11,7 +11,6 @@ #include "GameState.h" #include "Song.h" #include "Steps.h" -#include "Course.h" #include "GameManager.h" #include "ProductInfo.h" #include "RageUtil.h" @@ -41,7 +40,6 @@ static void DefaultLocalProfileIDInit( size_t /*PlayerNumber*/ i, RString &sName } Preference ProfileManager::m_bProfileStepEdits( "ProfileStepEdits", true ); -Preference ProfileManager::m_bProfileCourseEdits( "ProfileCourseEdits", true ); Preference1D ProfileManager::m_sDefaultLocalProfileID( DefaultLocalProfileIDInit, NUM_PLAYERS ); const RString NEW_MEM_CARD_NAME = ""; @@ -285,8 +283,6 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn, bool bLoadEdits if( m_bProfileStepEdits ) SONGMAN->LoadStepEditsFromProfileDir( sDir, (ProfileSlot) pn ); - if( m_bProfileCourseEdits ) - SONGMAN->LoadCourseEditsFromProfileDir( sDir, (ProfileSlot) pn ); } } @@ -694,7 +690,6 @@ void ProfileManager::LoadMachineProfileEdits() { SONGMAN->FreeAllLoadedFromProfile( ProfileSlot_Machine ); SONGMAN->LoadStepEditsFromProfileDir( MACHINE_PROFILE_DIR, ProfileSlot_Machine ); - SONGMAN->LoadCourseEditsFromProfileDir( MACHINE_PROFILE_DIR, ProfileSlot_Machine ); } bool ProfileManager::ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const @@ -912,51 +907,6 @@ void ProfileManager::IncrementStepsPlayCount( const Song* pSong, const Steps* pS GetMachineProfile()->IncrementStepsPlayCount( pSong, pSteps ); } -// Course stats -void ProfileManager::AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut ) -{ - HighScore hs = hs_; - hs.SetPercentDP(max( 0, hs.GetPercentDP()) ); // bump up negative scores - - iPersonalIndexOut = -1; - iMachineIndexOut = -1; - - // In event mode, set the score's name immediately to the Profile's last - // used name. If no profile last used name exists, use "EVNT". - if( GAMESTATE->IsEventMode() ) - { - Profile* pProfile = GetProfile(pn); - if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() ) - hs.SetName( pProfile->m_sLastUsedHighScoreName ); - else - hs.SetName( "EVNT" ); - } - else - { - hs.SetName( RANKING_TO_FILL_IN_MARKER[pn] ); - } - - // save high score - if( IsPersistentProfile(pn) ) - GetProfile(pn)->AddCourseHighScore( pCourse, pTrail, hs, iPersonalIndexOut ); - if( hs.GetPercentDP() >= PREFSMAN->m_fMinPercentageForMachineCourseHighScore ) - GetMachineProfile()->AddCourseHighScore( pCourse, pTrail, hs, iMachineIndexOut ); - - /* - // save recent score - if( IsPersistentProfile(pn) ) - GetProfile(pn)->SaveCourseRecentScore( pCourse, pTrail, hs ); - GetMachineProfile()->SaveCourseRecentScore( pCourse, pTrail, hs ); - */ -} - -void ProfileManager::IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn ) -{ - if( IsPersistentProfile(pn) ) - GetProfile(pn)->IncrementCoursePlayCount( pCourse, pTrail ); - GetMachineProfile()->IncrementCoursePlayCount( pCourse, pTrail ); -} - // Category stats void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut ) { diff --git a/src/ProfileManager.h b/src/ProfileManager.h index 90d0016231..966e6c3107 100644 --- a/src/ProfileManager.h +++ b/src/ProfileManager.h @@ -11,8 +11,6 @@ class Song; class Steps; class Style; -class Course; -class Trail; struct HighScore; struct lua_State; /** @brief Interface to machine and memory card profiles. */ @@ -95,10 +93,6 @@ class ProfileManager void AddStepsScore( const Song* pSong, const Steps* pSteps , PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut ); void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn ); - // Course stats - void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut ); - void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn ); - // Category stats void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut ); void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn ); diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 5f9df80a54..a47f10de68 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -6,7 +6,6 @@ #include "Steps.h" #include "ScreenManager.h" #include "GameState.h" -#include "Course.h" #include "SongManager.h" #include "NoteDataUtil.h" #include "NoteData.h" @@ -124,59 +123,13 @@ void ScoreKeeperNormal::Load( void ScoreKeeperNormal::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ) { -/* - Note on NONSTOP Mode scoring - - Nonstop mode requires the player to play 4 songs in succession, with the total maximum possible score for - the four song set being 100,000,000. This comes from the sum of the four stages' maximum possible scores, - which, regardless of song or difficulty is: - - 10,000,000 for the first song - 20,000,000 for the second song - 30,000,000 for the third song - 40,000,000 for the fourth song - - We extend this to work with nonstop courses of any length. - - We also keep track of this scoring type in endless, with 100mil per iteration - of all songs, though this score isn't actually seen anywhere right now. -*/ - // Calculate the score multiplier m_iMaxPossiblePoints = 0; - if( GAMESTATE->IsCourseMode() ) - { - const int numSongsInCourse = m_apSteps.size(); - ASSERT( numSongsInCourse != 0 ); - - const int iIndex = iSongInCourseIndex % numSongsInCourse; - m_bIsLastSongInCourse = (iIndex+1 == numSongsInCourse); - - if( numSongsInCourse < 10 ) - { - const int courseMult = (numSongsInCourse * (numSongsInCourse + 1)) / 2; - ASSERT(courseMult >= 0); - - m_iMaxPossiblePoints = (100000000 * (iIndex+1)) / courseMult; - } - else - { - /* When we have lots of songs, the scale above biases too much: in a - * course with 50 songs, the first song is worth 80k, the last 4mil, which - * is too much of a difference. - * - * With this, each song in a 50-song course will be worth 2mil. */ - m_iMaxPossiblePoints = 100000000 / numSongsInCourse; - } - } - else - { // long ver and marathon ver songs have higher max possible scores int iLengthMultiplier = GameState::GetNumStagesMultiplierForSong( GAMESTATE->m_pCurSong ); /* This is no longer just simple additive/subtractive scoring, * but start with capping the score at the size of the score counter. */ m_iMaxPossiblePoints = 10 * 10000000 * iLengthMultiplier; - } ASSERT( m_iMaxPossiblePoints >= 0 ); m_iMaxScoreSoFar += m_iMaxPossiblePoints; @@ -190,7 +143,7 @@ void ScoreKeeperNormal::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, /* MercifulBeginner shouldn't clamp weights in course mode, even if a beginner * song is in a course, since that makes PlayerStageStats::GetGrade hard. */ - m_bIsBeginner = pSteps->GetDifficulty() == Difficulty_Beginner && !GAMESTATE->IsCourseMode(); + m_bIsBeginner = pSteps->GetDifficulty() == Difficulty_Beginner; ASSERT( m_iPointBonus >= 0 ); diff --git a/src/ScreenDebugOverlay.cpp b/src/ScreenDebugOverlay.cpp index bfbea66323..9f63e7a221 100644 --- a/src/ScreenDebugOverlay.cpp +++ b/src/ScreenDebugOverlay.cpp @@ -681,7 +681,7 @@ class DebugLineAutosync : public IDebugLine virtual void DoAndLog( RString &sMessageOut ) { int as = GAMESTATE->m_SongOptions.GetSong().m_AutosyncType + 1; - bool bAllowSongAutosync = !GAMESTATE->IsCourseMode(); + bool bAllowSongAutosync = true; if( !bAllowSongAutosync && ( as == AutosyncType_Song || as == AutosyncType_Tempo ) ) as = AutosyncType_Machine; @@ -891,7 +891,6 @@ static HighScore MakeRandomHighScore( float fPercentDP ) static void FillProfileStats( Profile *pProfile ) { pProfile->InitSongScores(); - pProfile->InitCourseScores(); static int s_iCount = 0; // Choose a percent for all scores. This is useful for testing unlocks @@ -921,27 +920,6 @@ static void FillProfileStats( Profile *pProfile ) } } } - - vector vpAllCourses; - SONGMAN->GetAllCourses( vpAllCourses, true ); - FOREACH( Course*, vpAllCourses, pCourse ) - { - vector vpAllTrails; - (*pCourse)->GetAllTrails( vpAllTrails ); - FOREACH( Trail*, vpAllTrails, pTrail ) - { - if (random_up_to(5)) - { - pProfile->IncrementCoursePlayCount(*pCourse, *pTrail); - } - for( int i=0; iAddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex ); - } - } - } - SCREENMAN->ZeroNextUpdate(); } diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 09d8eaae69..b744a56991 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -86,9 +86,6 @@ AutoScreenMessage( SM_BackFromEditingAttackStart ); AutoScreenMessage( SM_BackFromEditingAttackLength ); AutoScreenMessage( SM_BackFromAddingAttackToChart ); AutoScreenMessage( SM_BackFromInsertStepAttackPlayerOptions ); -AutoScreenMessage( SM_BackFromInsertCourseAttack ); -AutoScreenMessage( SM_BackFromInsertCourseAttackPlayerOptions ); -AutoScreenMessage( SM_BackFromCourseModeMenu ); AutoScreenMessage( SM_BackFromKeysoundTrack ); AutoScreenMessage( SM_BackFromNewKeysound ); AutoScreenMessage( SM_DoRevertToLastSave ); @@ -187,8 +184,6 @@ void ScreenEdit::InitEditMappings() name_to_edit_button["OPEN_AREA_MENU"]= EDIT_BUTTON_OPEN_AREA_MENU; name_to_edit_button["OPEN_BGCHANGE_LAYER1_MENU"]= EDIT_BUTTON_OPEN_BGCHANGE_LAYER1_MENU; name_to_edit_button["OPEN_BGCHANGE_LAYER2_MENU"]= EDIT_BUTTON_OPEN_BGCHANGE_LAYER2_MENU; - name_to_edit_button["OPEN_COURSE_MENU"]= EDIT_BUTTON_OPEN_COURSE_MENU; - name_to_edit_button["OPEN_COURSE_ATTACK_MENU"]= EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU; name_to_edit_button["OPEN_STEP_ATTACK_MENU"]= EDIT_BUTTON_OPEN_STEP_ATTACK_MENU; name_to_edit_button["ADD_STEP_MODS"]= EDIT_BUTTON_ADD_STEP_MODS; @@ -241,8 +236,6 @@ void ScreenEdit::InitEditMappings() name_to_edit_button["UNDO"]= EDIT_BUTTON_UNDO; - name_to_edit_button["ADD_COURSE_MODS"]= EDIT_BUTTON_ADD_COURSE_MODS; - name_to_edit_button["SWITCH_PLAYERS"]= EDIT_BUTTON_SWITCH_PLAYERS; name_to_edit_button["SWITCH_TIMINGS"]= EDIT_BUTTON_SWITCH_TIMINGS; @@ -330,30 +323,6 @@ void ScreenEdit::InitEditMappings() m_PlayMappingsDeviceInput.button [EDIT_BUTTON_RETURN_TO_EDIT][1] = DeviceInput(DEVICE_KEYBOARD, KEY_ESC); m_PlayMappingsMenuButton.button [EDIT_BUTTON_RETURN_TO_EDIT][1] = GAME_BUTTON_BACK; return; - case EditMode_CourseMods: - // Left/Right = Snap to Next/Prev - m_EditMappingsDeviceInput.button[EDIT_BUTTON_SNAP_NEXT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_LEFT); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_SNAP_PREV][0] = DeviceInput(DEVICE_KEYBOARD, KEY_RIGHT); - - // v = course playback menu - // m_EditMappingsDeviceInput.button[EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Cv); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_ADD_COURSE_MODS][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_OPEN_COURSE_MENU][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Cv); - - // F1 = Show help popup - m_EditMappingsDeviceInput.button [EDIT_BUTTON_OPEN_INPUT_HELP][0] = DeviceInput(DEVICE_KEYBOARD, KEY_F1); - - // Esc = Show Edit Menu - m_EditMappingsDeviceInput.button [EDIT_BUTTON_OPEN_EDIT_MENU][0] = DeviceInput(DEVICE_KEYBOARD, KEY_ESC); - m_EditMappingsMenuButton.button [EDIT_BUTTON_OPEN_EDIT_MENU][0] = GAME_BUTTON_START; - m_EditMappingsMenuButton.button [EDIT_BUTTON_OPEN_EDIT_MENU][1] = GAME_BUTTON_BACK; - - // Escape, Enter = exit play/record - m_PlayMappingsDeviceInput.button [EDIT_BUTTON_RETURN_TO_EDIT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_ENTER); - m_PlayMappingsDeviceInput.button [EDIT_BUTTON_RETURN_TO_EDIT][1] = DeviceInput(DEVICE_KEYBOARD, KEY_ESC); - m_PlayMappingsMenuButton.button [EDIT_BUTTON_RETURN_TO_EDIT][0] = GAME_BUTTON_START; - return; - case EditMode_Full: // F4 = Show timing menu m_EditMappingsDeviceInput.button[EDIT_BUTTON_OPEN_TIMING_MENU][0] = DeviceInput(DEVICE_KEYBOARD, KEY_F4); @@ -939,9 +908,6 @@ static MenuDef g_AreaMenu( "Clear clipboard", true, EditMode_Practice, true, true, 0, NULL ), - MenuRowDef(ScreenEdit::modify_attacks_at_row, - "Modify Attacks at current beat", - true, EditMode_CourseMods, true, true, 0, NULL), MenuRowDef(ScreenEdit::modify_keysounds_at_row, "Modify Keysounds at current beat", true, EditMode_Full, true, true, 0, NULL) @@ -1340,19 +1306,6 @@ static MenuDef g_InsertTapAttack( true, EditMode_Practice, true, true, 0, "Press Start" ) ); -static MenuDef g_InsertCourseAttack( - "ScreenMiniMenuInsertCourseAttack", - MenuRowDef(ScreenEdit::duration, - "Duration seconds", - true, EditMode_Practice, true, false, 3, "5","10","15","20","25","30","35","40","45" ), - MenuRowDef(ScreenEdit::set_mods, - "Set modifiers", - true, EditMode_Practice, true, true, 0, "Press Start" ), - MenuRowDef(ScreenEdit::remove, - "Remove", - true, EditMode_Practice, true, true, 0, "Press Start" ) -); - static MenuDef g_InsertStepAttack( "ScreenMiniMenuInsertCourseAttack", MenuRowDef(ScreenEdit::sa_duration, @@ -1365,11 +1318,6 @@ static MenuDef g_InsertStepAttack( "Remove", true, EditMode_Practice, true, true, 0, "Press Start" )); -static MenuDef g_CourseMode( - "ScreenMiniMenuCourseDisplay", - MenuRowDef( -1, "Play mods from course", true, EditMode_Practice, true, false, 0, NULL ) -); - // HACK: need to remember the track we're inserting on so that we can lay the // attack note after coming back from menus. static int g_iLastInsertTapAttackTrack = -1; @@ -1887,7 +1835,6 @@ void ScreenEdit::UpdateTextInfo() DEFAULT_FAIL( EDIT_MODE.GetValue() ); case EditMode_Practice: break; - case EditMode_CourseMods: case EditMode_Home: case EditMode_Full: sText += ssprintf( SNAP_TO_FORMAT.GetValue(), SNAP_TO.GetValue().c_str(), sNoteType.c_str() ); @@ -1978,7 +1925,6 @@ void ScreenEdit::UpdateTextInfo() { DEFAULT_FAIL( EDIT_MODE.GetValue() ); case EditMode_Practice: - case EditMode_CourseMods: case EditMode_Home: break; case EditMode_Full: @@ -2801,74 +2747,11 @@ bool ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB ) SCREENMAN->PlayInvalidSound(); } return true; - - case EDIT_BUTTON_OPEN_COURSE_MENU: - { - g_CourseMode.rows[0].choices.clear(); - g_CourseMode.rows[0].choices.push_back( CommonMetrics::LocalizeOptionItem("Off",false) ); - g_CourseMode.rows[0].iDefaultChoice = 0; - - vector courses; - SONGMAN->GetAllCourses( courses, false ); - for( unsigned i = 0; i < courses.size(); ++i ) - { - const Course *crs = courses[i]; - - bool bUsesThisSong = false; - for( unsigned e = 0; e < crs->m_vEntries.size(); ++e ) - { - if( crs->m_vEntries[e].songID.ToSong() != m_pSong ) - continue; - bUsesThisSong = true; - } - - if( bUsesThisSong ) - { - g_CourseMode.rows[0].choices.push_back( crs->GetDisplayFullTitle() ); - if( crs == GAMESTATE->m_pCurCourse ) - g_CourseMode.rows[0].iDefaultChoice = g_CourseMode.rows[0].choices.size()-1; - } - } - - EditMiniMenu( &g_CourseMode, SM_BackFromCourseModeMenu ); - } - return true; case EDIT_BUTTON_OPEN_STEP_ATTACK_MENU: { this->DoStepAttackMenu(); return true; } - case EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU: - { - // TODO: Give Song/Step Timing switches/functions here? - Course *pCourse = GAMESTATE->m_pCurCourse; - if( pCourse == NULL ) - return false; - CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; - float fStartTime = m_pSteps->GetTimingData()->GetElapsedTimeFromBeat( GAMESTATE->m_pPlayerState[PLAYER_1]->m_Position.m_fSongBeat ); - int iAttack = FindAttackAtTime( ce.attacks, fStartTime ); - - if( iAttack >= 0 ) - { - const RString sDuration = FloatToString(ce.attacks[iAttack].fSecsRemaining ); - - g_InsertCourseAttack.rows[remove].bEnabled = true; - if( g_InsertCourseAttack.rows[duration].choices.size() == 9 ) - g_InsertCourseAttack.rows[duration].choices.push_back( sDuration ); - else - g_InsertCourseAttack.rows[duration].choices.back() = sDuration; - g_InsertCourseAttack.rows[duration].iDefaultChoice = 9; - } - else - { - if( g_InsertCourseAttack.rows[duration].choices.size() == 10 ) - g_InsertCourseAttack.rows[duration].choices.pop_back(); - g_InsertCourseAttack.rows[duration].iDefaultChoice = 3; - } - - EditMiniMenu( &g_InsertCourseAttack, SM_BackFromInsertCourseAttack ); - } - return true; case EDIT_BUTTON_ADD_STEP_MODS: { float start = -1; @@ -2909,43 +2792,6 @@ bool ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB ) SCREENMAN->AddNewScreenToTop( SET_MOD_SCREEN, SM_BackFromInsertStepAttackPlayerOptions ); return true; } - case EDIT_BUTTON_ADD_COURSE_MODS: - { - float fStart, fEnd; - PlayerOptions po; - const Course *pCourse = GAMESTATE->m_pCurCourse; - if( pCourse == NULL ) - return false; - const CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; - - if( m_NoteFieldEdit.m_iBeginMarker == -1 ) - { - fStart = -1; - fEnd = -1; - po.FromString( ce.sModifiers ); - } - else - { - // TODO: Give Song/Step Timing switches/functions here? - TimingData *timing = m_pSteps->GetTimingData(); - fStart = timing->GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) ); - int iAttack = FindAttackAtTime( ce.attacks, fStart ); - - if( iAttack >= 0 ) - po.FromString( ce.attacks[iAttack].sModifiers ); - - if( m_NoteFieldEdit.m_iEndMarker == -1 ) - fEnd = m_pSong->m_fMusicLengthSeconds; - else - fEnd = timing->GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker) ); - } - g_fLastInsertAttackPositionSeconds = fStart; - g_fLastInsertAttackDurationSeconds = fEnd - fStart; - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.Assign( ModsLevel_Stage, po ); - SCREENMAN->AddNewScreenToTop( SET_MOD_SCREEN, SM_BackFromInsertCourseAttackPlayerOptions ); - - } - return true; case EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP: case EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE: { @@ -3419,7 +3265,6 @@ void ScreenEdit::TransitionEditState( EditState em ) { case STATE_PLAYING: // If we're in course display mode, set that up. - SetupCourseAttacks(); m_Player.Load( m_NoteDataEdit ); @@ -3823,29 +3668,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) HandleBGChangeChoice( (BGChangeChoice)ScreenMiniMenu::s_iLastRowCode, ScreenMiniMenu::s_viLastAnswers ); SetDirty( true ); } - else if( SM == SM_BackFromCourseModeMenu ) - { - const int num = ScreenMiniMenu::s_viLastAnswers[0]; - GAMESTATE->m_pCurCourse.Set( NULL ); - if( num != 0 ) - { - const RString name = g_CourseMode.rows[0].choices[num]; - Course *pCourse = SONGMAN->FindCourse( name ); - - int iCourseEntryIndex = -1; - FOREACH_CONST( CourseEntry, pCourse->m_vEntries, i ) - { - if( i->songID.ToSong() == GAMESTATE->m_pCurSong.Get() ) - iCourseEntryIndex = i - pCourse->m_vEntries.begin(); - } - - ASSERT( iCourseEntryIndex != -1 ); - - GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntryIndex ); - ASSERT( GAMESTATE->m_pCurCourse != NULL ); - } - } else if (SM == SM_BackFromKeysoundTrack) { const int track = ScreenMiniMenu::s_iLastRowCode; @@ -4112,49 +3934,17 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) Attack &attack = attacks[attackInProcess]; g_IndividualAttack.rows.clear(); - g_IndividualAttack.rows.push_back(MenuRowDef(0, - "Starting Time", - true, - EditMode_CourseMods, - true, - true, - 0, - NULL)); + g_IndividualAttack.rows[0].SetOneUnthemedChoice(FloatToString(attack.fStartSecond)); - g_IndividualAttack.rows.push_back(MenuRowDef(1, - "Secs Remaining", - true, - EditMode_CourseMods, - true, - true, - 0, - NULL)); g_IndividualAttack.rows[1].SetOneUnthemedChoice(FloatToString(attack.fSecsRemaining)); vector mods; split(attack.sModifiers, ",", mods); for (unsigned i = 0; i < mods.size(); ++i) { unsigned col = i + 2; - g_IndividualAttack.rows.push_back(MenuRowDef(col, - ssprintf("Attack %d", i + 1), - true, - EditMode_CourseMods, - false, - true, - 0, - NULL)); g_IndividualAttack.rows[col].SetOneUnthemedChoice(mods[i].c_str()); } - g_IndividualAttack.rows.push_back(MenuRowDef(mods.size() + 2, - "Add Mod", - true, - EditMode_CourseMods, - true, - true, - 0, - NULL)); - EditMiniMenu(&g_IndividualAttack, SM_BackFromInsertStepAttack); } } @@ -4168,7 +3958,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) AttackArray &attacks = GAMESTATE->m_bIsUsingStepTiming ? m_pSteps->m_Attacks : m_pSong->m_Attacks; int iAttack = FindAttackAtTime(attacks, g_fLastInsertAttackPositionSeconds); - if (ScreenMiniMenu::s_iLastRowCode == ScreenEdit::remove ) + if (ScreenMiniMenu::s_iLastRowCode == true ) { if (iAttack > 0) attacks.erase(attacks.begin() + iAttack); @@ -4186,35 +3976,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) } SetDirty(true); } - else if( SM == SM_BackFromInsertCourseAttack ) - { - int iDurationChoice = ScreenMiniMenu::s_viLastAnswers[0]; - Course *pCourse = GAMESTATE->m_pCurCourse; - CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; - int iAttack; - - // TODO: Handle Song/Step Timing functions/switches here? - - g_fLastInsertAttackPositionSeconds = m_pSteps->GetTimingData()->GetElapsedTimeFromBeat( GAMESTATE->m_Position.m_fSongBeat ); - g_fLastInsertAttackDurationSeconds = StringToFloat( g_InsertCourseAttack.rows[0].choices[iDurationChoice] ); - iAttack = FindAttackAtTime( ce.attacks, g_fLastInsertAttackPositionSeconds ); - - if( ScreenMiniMenu::s_iLastRowCode == ScreenEdit::remove ) - { - ASSERT( iAttack >= 0 ); - ce.attacks.erase( ce.attacks.begin() + iAttack ); - } - else - { - PlayerOptions po; - - if( iAttack >= 0 ) - po.FromString( ce.attacks[iAttack].sModifiers ); - - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.Assign( ModsLevel_Preferred, po ); - SCREENMAN->AddNewScreenToTop( SET_MOD_SCREEN, SM_BackFromInsertCourseAttackPlayerOptions ); - } - } else if (SM == SM_BackFromInsertStepAttackPlayerOptions) { ModsGroup &toRestore = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions; @@ -4238,34 +3999,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) } toRestore.Assign(ModsLevel_Preferred, this->originalPlayerOptions.GetPreferred()); } - else if( SM == SM_BackFromInsertCourseAttackPlayerOptions ) - { - PlayerOptions poChosen = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred(); - RString sMods = poChosen.GetString(); - - Course *pCourse = GAMESTATE->m_pCurCourse; - CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; - if( g_fLastInsertAttackPositionSeconds < 0 ) - { - ce.sModifiers = sMods; - } - else - { - Attack a( - ATTACK_LEVEL_1, - g_fLastInsertAttackPositionSeconds, - g_fLastInsertAttackDurationSeconds, - sMods, - false, - false ); - int iAttack = FindAttackAtTime( ce.attacks, g_fLastInsertAttackPositionSeconds ); - - if( iAttack >= 0 ) - ce.attacks[iAttack] = a; - else - ce.attacks.push_back( a ); - } - } else if( SM == SM_DoRevertToLastSave ) { if( ScreenPrompt::s_LastAnswer == ANSWER_YES ) @@ -4504,7 +4237,6 @@ void ScreenEdit::PerformSave(bool autosave) HandleScreenMessage(save_message); } break; - case EditMode_CourseMods: case EditMode_Practice: break; } @@ -4865,7 +4597,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns g_StepsInformation.rows[difficulty].choices.clear(); FOREACH_ENUM( Difficulty, dc ) { - g_StepsInformation.rows[difficulty].choices.push_back( "|" + CustomDifficultyToLocalizedString( GetCustomDifficulty(pSteps->m_StepsType, dc, CourseType_Invalid) ) ); + g_StepsInformation.rows[difficulty].choices.push_back( "|" + CustomDifficultyToLocalizedString( GetCustomDifficulty(pSteps->m_StepsType, dc) ) ); } g_StepsInformation.rows[difficulty].iDefaultChoice = pSteps->GetDifficulty(); g_StepsInformation.rows[difficulty].bEnabled = (EDIT_MODE.GetValue() >= EditMode_Full); @@ -4994,9 +4726,6 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns SCREENMAN->SendMessageToTopScreen( SM_DoExit ); break; case EditMode_Practice: - case EditMode_CourseMods: - SCREENMAN->SendMessageToTopScreen( SM_DoExit ); - break; } break; }; @@ -6082,67 +5811,6 @@ void ScreenEdit::HandleBGChangeChoice( BGChangeChoice c, const vector &iAns g_CurrentBGChangeLayer = BACKGROUND_LAYER_Invalid; } -void ScreenEdit::SetupCourseAttacks() -{ - /* This is the first beat that can be changed without it being visible. Until - * we draw for the first time, any beat can be changed. */ - GAMESTATE->m_pPlayerState[PLAYER_1]->m_fLastDrawnBeat = -100; - - // Put course options into effect. - GAMESTATE->m_pPlayerState[PLAYER_1]->m_ModsToApply.clear(); - GAMESTATE->m_pPlayerState[PLAYER_1]->RemoveActiveAttacks(); - - - if( GAMESTATE->m_pCurCourse ) - { - AttackArray Attacks; - - if( EDIT_MODE == EditMode_CourseMods ) - { - Attacks = GAMESTATE->m_pCurCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex].attacks; - } - else - { - GAMESTATE->m_pCurCourse->RevertFromDisk(); // Remove this and have a separate reload key? - - for( unsigned e = 0; e < GAMESTATE->m_pCurCourse->m_vEntries.size(); ++e ) - { - if( GAMESTATE->m_pCurCourse->m_vEntries[e].songID.ToSong() != m_pSong ) - continue; - - Attacks = GAMESTATE->m_pCurCourse->m_vEntries[e].attacks; - break; - } - } - - FOREACH( Attack, Attacks, attack ) - GAMESTATE->m_pPlayerState[PLAYER_1]->LaunchAttack( *attack ); - } - else - { - const PlayerOptions &p = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent(); - if (GAMESTATE->m_pCurSong && p.m_fNoAttack == 0 && p.m_fRandAttack == 0 ) - { - AttackArray &attacks = GAMESTATE->m_bIsUsingStepTiming ? - GAMESTATE->m_pCurSteps[PLAYER_1]->m_Attacks : - GAMESTATE->m_pCurSong->m_Attacks; - - if (attacks.size() > 0) - { - FOREACH(Attack, attacks, attack) - { - // LaunchAttack is actually a misnomer. The function actually adds - // the attack to a list in the PlayerState which is checked and - // updated every tick to see which ones to actually activate. -Kyz - GAMESTATE->m_pPlayerState[PLAYER_1]->LaunchAttack( *attack ); - } - } - } - } - - GAMESTATE->m_pPlayerState[PLAYER_1]->RebuildPlayerOptionsFromActiveAttacks(); -} - void ScreenEdit::CopyToLastSave() { ASSERT( GAMESTATE->m_pCurSong != NULL ); @@ -6272,7 +5940,6 @@ float ScreenEdit::GetMaximumBeatForNewNote() const { DEFAULT_FAIL( EDIT_MODE.GetValue() ); case EditMode_Practice: - case EditMode_CourseMods: case EditMode_Home: { Song &s = *GAMESTATE->m_pCurSong; @@ -6446,25 +6113,7 @@ void ScreenEdit::DoStepAttackMenu() RString desc = ssprintf("%g -> %g (%d mod[s])", startTime, startTime + attack.fSecsRemaining, attack.GetNumAttacks()); - - g_AttackAtTimeMenu.rows.push_back(MenuRowDef(index++, - desc, - true, - EditMode_CourseMods, - false, - false, - 0, - "Modify", - "Delete")); - } - g_AttackAtTimeMenu.rows.push_back(MenuRowDef(index, - "Add Attack", - true, - EditMode_CourseMods, - true, - true, - 0, - NULL)); + } EditMiniMenu(&g_AttackAtTimeMenu, SM_BackFromAttackAtTime); } diff --git a/src/ScreenEdit.h b/src/ScreenEdit.h index 1872bc9ecf..7864da4ae6 100644 --- a/src/ScreenEdit.h +++ b/src/ScreenEdit.h @@ -97,8 +97,6 @@ enum EditButton EDIT_BUTTON_OPEN_AREA_MENU, EDIT_BUTTON_OPEN_BGCHANGE_LAYER1_MENU, EDIT_BUTTON_OPEN_BGCHANGE_LAYER2_MENU, - EDIT_BUTTON_OPEN_COURSE_MENU, - EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU, EDIT_BUTTON_OPEN_STEP_ATTACK_MENU, /**< Open up the Step Attacks menu. */ EDIT_BUTTON_ADD_STEP_MODS, /**< Add a mod attack to the row. */ @@ -151,8 +149,6 @@ enum EditButton EDIT_BUTTON_UNDO, /**< Undo a recent change. */ - EDIT_BUTTON_ADD_COURSE_MODS, - EDIT_BUTTON_SWITCH_PLAYERS, /**< Allow entering notes for a different Player. */ EDIT_BUTTON_SWITCH_TIMINGS, /**< Allow switching between Song and Step TimingData. */ @@ -375,7 +371,6 @@ class ScreenEdit : public ScreenWithMenuElements bool m_bRemoveNoteButtonDown; // for MODE_PLAY - void SetupCourseAttacks(); PlayerPlus m_Player; Background m_Background; Foreground m_Foreground; @@ -687,14 +682,6 @@ class ScreenEdit : public ScreenWithMenuElements * @param iAnswers the other settings involving the change. */ void HandleBGChangeChoice( BGChangeChoice c, const vector &iAnswers ); - enum CourseAttackChoice - { - duration, - set_mods, - remove, - NUM_CourseAttackChoice - }; - enum StepAttackChoice { sa_duration, diff --git a/src/ScreenEditMenu.cpp b/src/ScreenEditMenu.cpp index 548329a9b8..af5527b536 100644 --- a/src/ScreenEditMenu.cpp +++ b/src/ScreenEditMenu.cpp @@ -216,7 +216,6 @@ bool ScreenEditMenu::MenuStart( const InputEventPlus & ) } GAMESTATE->m_pCurSong.Set( pSong ); - GAMESTATE->m_pCurCourse.Set( NULL ); GAMESTATE->SetCurrentStyle( GAMEMAN->GetEditorStyleForStepsType(st), PLAYER_INVALID ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps ); @@ -327,7 +326,6 @@ bool ScreenEditMenu::MenuStart( const InputEventPlus & ) GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps ); - GAMESTATE->m_pCurCourse.Set( NULL ); } break; default: diff --git a/src/ScreenEnding.cpp b/src/ScreenEnding.cpp index 99eeb0c4fe..4f2746aeba 100644 --- a/src/ScreenEnding.cpp +++ b/src/ScreenEnding.cpp @@ -34,7 +34,6 @@ ScreenEnding::ScreenEnding() GAMESTATE->JoinPlayer( PLAYER_1 ); GAMESTATE->JoinPlayer( PLAYER_2 ); GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() ); - GAMESTATE->m_pCurCourse.Set( SONGMAN->GetRandomCourse() ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] ); GAMESTATE->m_pCurSteps[PLAYER_2].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] ); STATSMAN->m_CurStageStats.m_player[PLAYER_1].m_vpPossibleSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] ); diff --git a/src/ScreenEvaluation.cpp b/src/ScreenEvaluation.cpp index af1b46e97c..06d6db5f02 100644 --- a/src/ScreenEvaluation.cpp +++ b/src/ScreenEvaluation.cpp @@ -13,7 +13,6 @@ #include "ThemeManager.h" #include "GameSoundManager.h" #include "ActorUtil.h" -#include "Course.h" #include "LightsManager.h" #include "ProfileManager.h" #include "Profile.h" @@ -113,7 +112,6 @@ void ScreenEvaluation::Init() GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() ); ss.m_vpPlayedSongs.push_back( GAMESTATE->m_pCurSong ); ss.m_vpPossibleSongs.push_back( GAMESTATE->m_pCurSong ); - GAMESTATE->m_pCurCourse.Set( SONGMAN->GetRandomCourse() ); GAMESTATE->m_iCurrentStageIndex = 0; FOREACH_ENUM( PlayerNumber, p ) GAMESTATE->m_iPlayerStageTokens[p] = 1; @@ -127,13 +125,6 @@ void ScreenEvaluation::Init() GAMESTATE->JoinPlayer( p ); GAMESTATE->m_pCurSteps[p].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] ); - if( GAMESTATE->m_pCurCourse ) - { - vector apTrails; - GAMESTATE->m_pCurCourse->GetAllTrails( apTrails ); - if( apTrails.size() ) - GAMESTATE->m_pCurTrail[p].Set( apTrails[0] ); - } ss.m_player[p].m_vpPossibleSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] ); ss.m_player[p].m_iStepsPlayed = 1; @@ -284,10 +275,7 @@ void ScreenEvaluation::Init() } else { - if( GAMESTATE->IsCourseMode() ) - m_LargeBanner.LoadFromCourse( GAMESTATE->m_pCurCourse ); - else - m_LargeBanner.LoadFromSong( GAMESTATE->m_pCurSong ); + m_LargeBanner.LoadFromSong( GAMESTATE->m_pCurSong ); m_LargeBanner.ScaleToClipped( BANNER_WIDTH, BANNER_HEIGHT ); m_LargeBanner.SetName( "LargeBanner" ); ActorUtil::LoadAllCommands( m_LargeBanner, m_sName ); @@ -389,8 +377,6 @@ void ScreenEvaluation::Init() { // In course mode, we need to make sure the bar doesn't overflow. -aj float fDivider = 1.0f; - if( GAMESTATE->IsCourseMode() ) - fDivider = fDivider / GAMESTATE->m_pCurCourse->m_vEntries.size(); FOREACH_EnabledPlayer( p ) { @@ -687,7 +673,7 @@ void ScreenEvaluation::Init() } else { - if( SUMMARY || GAMESTATE->IsCourseMode() ) + if( SUMMARY ) { SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("evaluation final "+GradeToOldString(best_grade)) ); } diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 21131e3bc3..37b033cad9 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -30,7 +30,6 @@ #include "GameSoundManager.h" #include "CombinedLifeMeterTug.h" #include "Inventory.h" -#include "Course.h" #include "NoteDataUtil.h" #include "UnlockManager.h" #include "LightsManager.h" @@ -66,7 +65,6 @@ #define SHOW_LIFE_METER_FOR_DISABLED_PLAYERS THEME->GetMetricB(m_sName,"ShowLifeMeterForDisabledPlayers") #define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave") #define SONG_POSITION_METER_WIDTH THEME->GetMetricF(m_sName,"SongPositionMeterWidth") -#define STOP_COURSE_EARLY THEME->GetMetricB(m_sName,"StopCourseEarly") // evaluate this every time it's used static ThemeMetric INITIAL_BACKGROUND_BRIGHTNESS ("ScreenGameplay","InitialBackgroundBrightness"); static ThemeMetric SECONDS_BETWEEN_COMMENTS ("ScreenGameplay","SecondsBetweenComments"); @@ -102,7 +100,7 @@ PlayerInfo::PlayerInfo(): m_pn(PLAYER_INVALID), m_mp(MultiPlayer_Invalid), m_bPlayerEnabled(false), m_PlayerStateDummy(), m_PlayerStageStatsDummy(), m_SoundEffectControl(), m_vpStepsQueue(), m_asModifiersQueue(), m_pLifeMeter(NULL), - m_ptextCourseSongNumber(NULL), m_ptextStepsDescription(NULL), + m_ptextStepsDescription(NULL), m_pPrimaryScoreDisplay(NULL), m_pSecondaryScoreDisplay(NULL), m_pPrimaryScoreKeeper(NULL), m_pSecondaryScoreKeeper(NULL), m_ptextPlayerOptions(NULL), m_pActiveAttackList(NULL), @@ -117,7 +115,6 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int m_bIsDummy = false; m_iAddToDifficulty = iAddToDifficulty; m_pLifeMeter = NULL; - m_ptextCourseSongNumber = NULL; m_ptextStepsDescription = NULL; if( !IsMultiPlayer() ) @@ -126,7 +123,6 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int switch( mode ) { case PLAY_MODE_REGULAR: - case PLAY_MODE_NONSTOP: case PLAY_MODE_BATTLE: case PLAY_MODE_RAVE: if( PREFSMAN->m_bPercentageScoring ) @@ -134,13 +130,6 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int else m_pPrimaryScoreDisplay = new ScoreDisplayNormal; break; - case PLAY_MODE_ONI: - case PLAY_MODE_ENDLESS: - if( GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetStage().m_LifeType == LifeType_Time ) - m_pPrimaryScoreDisplay = new ScoreDisplayLifeTime; - else - m_pPrimaryScoreDisplay = new ScoreDisplayOni; - break; default: FAIL_M(ssprintf("Invalid PlayMode: %i", mode)); } @@ -204,7 +193,6 @@ void PlayerInfo::LoadDummyP1( int iDummyIndex, int iAddToDifficulty ) PlayerInfo::~PlayerInfo() { SAFE_DELETE( m_pLifeMeter ); - SAFE_DELETE( m_ptextCourseSongNumber ); SAFE_DELETE( m_ptextStepsDescription ); SAFE_DELETE( m_pPrimaryScoreDisplay ); SAFE_DELETE( m_pSecondaryScoreDisplay ); @@ -342,7 +330,6 @@ void ScreenGameplay::Init() GIVE_UP_SECONDS.Load( m_sName, "GiveUpSeconds" ); MUSIC_FADE_OUT_SECONDS.Load( m_sName, "MusicFadeOutSeconds" ); OUT_TRANSITION_LENGTH.Load( m_sName, "OutTransitionLength" ); - COURSE_TRANSITION_LENGTH.Load( m_sName, "CourseTransitionLength" ); BEGIN_FAILED_DELAY.Load( m_sName, "BeginFailedDelay" ); MIN_SECONDS_TO_STEP.Load( m_sName, "MinSecondsToStep" ); MIN_SECONDS_TO_MUSIC.Load( m_sName, "MinSecondsToMusic" ); @@ -403,7 +390,7 @@ void ScreenGameplay::Init() m_pCombinedLifeMeter = NULL; - if( GAMESTATE->m_pCurSong == NULL && GAMESTATE->m_pCurCourse == NULL ) + if( GAMESTATE->m_pCurSong == NULL) return; // ScreenDemonstration will move us to the next screen. We just need to survive for one update without crashing. /* Save settings to the profile now. Don't do this on extra stages, since the @@ -442,7 +429,7 @@ void ScreenGameplay::Init() player++; } - if(!GAMESTATE->IsCourseMode() && !GAMESTATE->m_bDemonstrationOrJukebox) + if(!GAMESTATE->m_bDemonstrationOrJukebox) { // fill in difficulty of CPU players with that of the first human player // this should not need to worry about step content. @@ -460,11 +447,6 @@ void ScreenGameplay::Init() ASSERT( GAMESTATE->m_pCurSteps[p].Get() != NULL ); } - /* Increment the course play count. */ - if( GAMESTATE->IsCourseMode() && !GAMESTATE->m_bDemonstrationOrJukebox ) - FOREACH_EnabledPlayer(p) - PROFILEMAN->IncrementCoursePlayCount( GAMESTATE->m_pCurCourse, GAMESTATE->m_pCurTrail[p], p ); - STATSMAN->m_CurStageStats.m_Stage = GAMESTATE->GetCurrentStage(); STATSMAN->m_CurStageStats.m_iStageIndex = GAMESTATE->m_iCurrentStageIndex; STATSMAN->m_CurStageStats.m_playMode = GAMESTATE->m_PlayMode; @@ -657,31 +639,6 @@ void ScreenGameplay::Init() switch( GAMESTATE->m_PlayMode ) { case PLAY_MODE_REGULAR: - case PLAY_MODE_ONI: - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ENDLESS: - FOREACH_PlayerNumberInfo( m_vPlayerInfo, pi ) - { - if( !GAMESTATE->IsPlayerEnabled(pi->m_pn) && !SHOW_LIFE_METER_FOR_DISABLED_PLAYERS ) - continue; // skip - - pi->m_pLifeMeter = LifeMeter::MakeLifeMeter( pi->GetPlayerState()->m_PlayerOptions.GetStage().m_LifeType ); - pi->m_pLifeMeter->Load( pi->GetPlayerState(), pi->GetPlayerStageStats() ); - pi->m_pLifeMeter->SetName( ssprintf("Life%s",pi->GetName().c_str()) ); - LOAD_ALL_COMMANDS_AND_SET_XY( pi->m_pLifeMeter ); - this->AddChild( pi->m_pLifeMeter ); - - // HACK: When SHOW_LIFE_METER_FOR_DISABLED_PLAYERS is enabled, - // we don't want to have any life in the disabled player's life - // meter. I think this only happens with LifeMeterBars, but I'm - // not 100% sure of that. -freem - if( !GAMESTATE->IsPlayerEnabled(pi->m_pn) && SHOW_LIFE_METER_FOR_DISABLED_PLAYERS ) - { - if(pi->GetPlayerState()->m_PlayerOptions.GetStage().m_LifeType == LifeType_Bar) - static_cast(pi->m_pLifeMeter)->ChangeLife(-1.0f); - } - } - break; case PLAY_MODE_BATTLE: case PLAY_MODE_RAVE: default: @@ -735,19 +692,6 @@ void ScreenGameplay::Init() // Add stage / SongNumber FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) { - if( GAMESTATE->IsCourseMode() ) - { - ASSERT( pi->m_ptextCourseSongNumber == NULL ); - SONG_NUMBER_FORMAT.Load( m_sName, "SongNumberFormat" ); - pi->m_ptextCourseSongNumber = new BitmapText; - pi->m_ptextCourseSongNumber->LoadFromFont( THEME->GetPathF(m_sName,"SongNum") ); - pi->m_ptextCourseSongNumber->SetName( ssprintf("SongNumber%s",pi->GetName().c_str()) ); - LOAD_ALL_COMMANDS_AND_SET_XY( pi->m_ptextCourseSongNumber ); - pi->m_ptextCourseSongNumber->SetText( "" ); - //pi->m_ptextCourseSongNumber->SetDiffuse( RageColor(0,0.5f,1,1) ); // light blue - this->AddChild( pi->m_ptextCourseSongNumber ); - } - ASSERT( pi->m_ptextStepsDescription == NULL ); pi->m_ptextStepsDescription = new BitmapText; pi->m_ptextStepsDescription->LoadFromFont( THEME->GetPathF(m_sName,"StepsDescription") ); @@ -924,94 +868,48 @@ bool ScreenGameplay::Center1Player() const // fill in m_apSongsQueue, m_vpStepsQueue, m_asModifiersQueue void ScreenGameplay::InitSongQueues() { - if( GAMESTATE->IsCourseMode() ) + m_apSongsQueue.push_back(GAMESTATE->m_pCurSong); + FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi) { - Course* pCourse = GAMESTATE->m_pCurCourse; - ASSERT( pCourse != NULL ); + Steps *pSteps = GAMESTATE->m_pCurSteps[pi->GetStepsAndTrailIndex()]; + pi->m_vpStepsQueue.push_back(pSteps); + const PlayerOptions &p = pi->GetPlayerState()->m_PlayerOptions.GetCurrent(); - m_apSongsQueue.clear(); - PlayerNumber pnMaster = GAMESTATE->GetMasterPlayerNumber(); - Trail *pTrail = GAMESTATE->m_pCurTrail[pnMaster]; - ASSERT( pTrail != NULL ); - FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) + if (p.m_fNoAttack == 0 && p.m_fRandAttack == 0 && + pSteps->m_Attacks.size() > 0) { - ASSERT( e->pSong != NULL ); - m_apSongsQueue.push_back( e->pSong ); + pi->m_asModifiersQueue.push_back(pSteps->m_Attacks); } - - FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) - { - Trail *lTrail = GAMESTATE->m_pCurTrail[ pi->GetStepsAndTrailIndex() ]; - ASSERT( lTrail != NULL ); - - pi->m_vpStepsQueue.clear(); - pi->m_asModifiersQueue.clear(); - FOREACH_CONST( TrailEntry, lTrail->m_vEntries, e ) - { - ASSERT( e->pSteps != NULL ); - pi->m_vpStepsQueue.push_back( e->pSteps ); - AttackArray a; - e->GetAttackArray( a ); - pi->m_asModifiersQueue.push_back( a ); - } - - // In a survival course, override stored mods - if( pCourse->GetCourseType() == COURSE_TYPE_SURVIVAL && SURVIVAL_MOD_OVERRIDE ) - { - pi->GetPlayerState()->m_PlayerOptions.FromString( ModsLevel_Stage, - "clearall," - + CommonMetrics::DEFAULT_NOTESKIN_NAME.GetValue() - + "," - + CommonMetrics::DEFAULT_MODIFIERS.GetValue() ); - pi->GetPlayerState()->RebuildPlayerOptionsFromActiveAttacks(); - } - } - } - else - { - m_apSongsQueue.push_back( GAMESTATE->m_pCurSong ); - FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + else { - Steps *pSteps = GAMESTATE->m_pCurSteps[ pi->GetStepsAndTrailIndex() ]; - pi->m_vpStepsQueue.push_back( pSteps ); - const PlayerOptions &p = pi->GetPlayerState()->m_PlayerOptions.GetCurrent(); - - if (p.m_fNoAttack == 0 && p.m_fRandAttack == 0 && - pSteps->m_Attacks.size() > 0 ) - { - pi->m_asModifiersQueue.push_back( pSteps->m_Attacks ); - } - else - { - AttackArray aa; - pi->m_asModifiersQueue.push_back( aa ); - } + AttackArray aa; + pi->m_asModifiersQueue.push_back(aa); } } - if( GAMESTATE->m_bMultiplayer ) + if (GAMESTATE->m_bMultiplayer) { - for( int i=0; i<(int)m_apSongsQueue.size(); i++ ) + for (int i = 0; i<(int)m_apSongsQueue.size(); i++) { Song *pSong = m_apSongsQueue[i]; - FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi) { Steps *pOldSteps = pi->m_vpStepsQueue[i]; vector vpSteps; - SongUtil::GetSteps( pSong, vpSteps, pOldSteps->m_StepsType ); - StepsUtil::SortNotesArrayByDifficulty( vpSteps ); - vector::iterator iter = find( vpSteps.begin(), vpSteps.end(), pOldSteps ); + SongUtil::GetSteps(pSong, vpSteps, pOldSteps->m_StepsType); + StepsUtil::SortNotesArrayByDifficulty(vpSteps); + vector::iterator iter = find(vpSteps.begin(), vpSteps.end(), pOldSteps); int iIndexBase = 0; - if( iter != vpSteps.end() ) + if (iter != vpSteps.end()) { iIndexBase = iter - vpSteps.begin(); - CLAMP( iIndexBase, 0, vpSteps.size() - GAMESTATE->m_iNumMultiplayerNoteFields ); + CLAMP(iIndexBase, 0, vpSteps.size() - GAMESTATE->m_iNumMultiplayerNoteFields); } int iIndexToUse = iIndexBase + pi->m_iAddToDifficulty; - CLAMP( iIndexToUse, 0, vpSteps.size()-1 ); + CLAMP(iIndexToUse, 0, vpSteps.size() - 1); Steps *pSteps = vpSteps[iIndexToUse]; pi->m_vpStepsQueue[i] = pSteps; @@ -1049,13 +947,6 @@ ScreenGameplay::~ScreenGameplay() NSMAN->ReportSongOver(); } -bool ScreenGameplay::IsLastSong() -{ - if( GAMESTATE->m_pCurCourse && GAMESTATE->m_pCurCourse->m_bRepeat ) - return false; - return GAMESTATE->GetCourseSongIndex() >= (int)m_apSongsQueue.size()-1; // GetCourseSongIndex() is 0-based -} - void ScreenGameplay::SetupSong( int iSongIndex ) { FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) @@ -1636,10 +1527,7 @@ void ScreenGameplay::GetMusicEndTiming( float &fSecondsToStartFadingOutMusic, fl fLastStepSeconds += Player::GetMaxStepDistanceSeconds(); float fTransitionLength; - if( !GAMESTATE->IsCourseMode() || IsLastSong() ) - fTransitionLength = OUT_TRANSITION_LENGTH; - else - fTransitionLength = COURSE_TRANSITION_LENGTH; + fTransitionLength = OUT_TRANSITION_LENGTH; fSecondsToStartTransitioningOut = fLastStepSeconds; @@ -1995,11 +1883,6 @@ void ScreenGameplay::Update( float fDeltaTime ) else PlayAnnouncer( "gameplay comment good", SECONDS_BETWEEN_COMMENTS ); break; - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ONI: - case PLAY_MODE_ENDLESS: - PlayAnnouncer( "gameplay comment oni", SECONDS_BETWEEN_COMMENTS ); - break; default: FAIL_M(ssprintf("Invalid PlayMode: %i", mode)); } @@ -2464,22 +2347,6 @@ bool ScreenGameplay::Input( const InputEventPlus &input ) bHoldingGiveUp |= ( START_GIVES_UP && input.MenuI == GAME_BUTTON_START ); bHoldingGiveUp |= ( BACK_GIVES_UP && input.MenuI == GAME_BUTTON_BACK ); } - // Allow holding SELECT to skip the current song in course mode. -Kyz - if(GAMESTATE->IsCourseMode() && SELECT_SKIPS_SONG && - input.MenuI == GAME_BUTTON_SELECT) - { - if(input.type == IET_RELEASE) - { - AbortSkipSong(true); - } - else if(input.type == IET_FIRST_PRESS && m_SkipSongTimer.IsZero()) - { - m_textDebug.SetText(SKIP_SONG_TEXT); - m_textDebug.PlayCommand("StartOn"); - m_SkipSongTimer.Touch(); - } - return true; - } if( bHoldingGiveUp ) { @@ -2647,20 +2514,6 @@ void ScreenGameplay::SongFinished() void ScreenGameplay::StageFinished( bool bBackedOut ) { - if( GAMESTATE->IsCourseMode() && GAMESTATE->m_PlayMode != PLAY_MODE_ENDLESS ) - { - LOG->Trace("Stage finished at index %i/%i", GAMESTATE->GetCourseSongIndex(), (int) m_apSongsQueue.size() ); - // +1 to skip the current song; that song has already passed. - for( unsigned i = GAMESTATE->GetCourseSongIndex()+1; i < m_apSongsQueue.size(); ++i ) - { - LOG->Trace("Running stats for %i", i ); - SetupSong( i ); - FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) - pi->m_pPlayer->ApplyWaitingTransforms(); - SongFinished(); - } - } - if( bBackedOut ) { GAMESTATE->CancelStage(); @@ -2782,12 +2635,11 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) /* If all players have *really* failed (bFailed, not the life meter or * bFailedEarlier): */ const bool bAllReallyFailed = STATSMAN->m_CurStageStats.AllFailed(); - const bool bStopCourseEarly = STOP_COURSE_EARLY; - const bool bIsLastSong = IsLastSong(); + const bool bIsLastSong = true; - LOG->Trace( "bAllReallyFailed = %d, bStopCourseEarly = %d, " + LOG->Trace( "bAllReallyFailed = %d " "bIsLastSong = %d, m_gave_up = %d, m_skipped_song = %d", - bAllReallyFailed, bStopCourseEarly, bIsLastSong, m_gave_up, + bAllReallyFailed, bIsLastSong, m_gave_up, m_skipped_song); if(!bIsLastSong && m_skipped_song) @@ -2796,7 +2648,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) HandleScreenMessage( SM_StartLoadingNextSong ); return; } - if( bStopCourseEarly || bAllReallyFailed || bIsLastSong || m_gave_up ) + if( bAllReallyFailed || bIsLastSong || m_gave_up ) { // Time to leave from ScreenGameplay HandleScreenMessage( SM_LeaveGameplay ); @@ -2877,71 +2729,6 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) pi->m_pLifeMeter->OnSongEnded(); } - // If this is a repeating course, and we're at the end of it, repick and - // add new songs to the players' step and song queues. - if(GAMESTATE->IsCourseMode() && GAMESTATE->m_pCurCourse && - GAMESTATE->m_pCurCourse->m_bRepeat && - GAMESTATE->GetCourseSongIndex() >= (int)m_apSongsQueue.size()-1) - { - Course* course= GAMESTATE->m_pCurCourse; - ASSERT(course != NULL); - // Need to store these so they can be used to refetch the players' - // trails after they're invalidated. - vector trail_sts; - vector trail_cds; - FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi) - { - Trail* trail= GAMESTATE->m_pCurTrail[pi->GetStepsAndTrailIndex()]; - ASSERT(trail != NULL); - trail_sts.push_back(trail->m_StepsType); - trail_cds.push_back(trail->m_CourseDifficulty); - } - // Set a new stage seed so the order will be different. - GAMESTATE->SetNewStageSeed(); - course->InvalidateTrailCache(); - course->RegenerateNonFixedTrails(); - size_t info_id= 0; // Can't use the player number in the playerinfo - // because it won't match up in 2-player. - FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi) - { - Trail* trail= course->GetTrail(trail_sts[info_id], trail_cds[info_id]); - ASSERT(trail != NULL); - GAMESTATE->m_pCurTrail[pi->m_pn].Set(trail); - ++info_id; - } - PlayerNumber master_pn = GAMESTATE->GetMasterPlayerNumber(); - Trail *master_trail= GAMESTATE->m_pCurTrail[master_pn]; - ASSERT(master_trail != NULL); - FOREACH_CONST(TrailEntry, master_trail->m_vEntries, entry) - { - ASSERT(entry->pSong != NULL); - m_apSongsQueue.push_back(entry->pSong); - STATSMAN->m_CurStageStats.m_vpPossibleSongs.push_back(entry->pSong); - } - FOREACH_EnabledPlayerInfo(m_vPlayerInfo, pi) - { - Trail* trail= GAMESTATE->m_pCurTrail[pi->GetStepsAndTrailIndex()]; - ASSERT(trail != NULL); - FOREACH_CONST(TrailEntry, trail->m_vEntries, entry) - { - ASSERT(entry->pSteps != NULL); - pi->m_vpStepsQueue.push_back(entry->pSteps); - AttackArray a; - entry->GetAttackArray(a); - pi->m_asModifiersQueue.push_back(a); - pi->GetPlayerStageStats()->m_vpPossibleSteps.push_back(entry->pSteps); - } - // In a survival course, override stored mods - if(course->GetCourseType() == COURSE_TYPE_SURVIVAL && - SURVIVAL_MOD_OVERRIDE) - { - pi->GetPlayerState()->m_PlayerOptions.FromString(ModsLevel_Stage, - "clearall," + CommonMetrics::DEFAULT_NOTESKIN_NAME.GetValue() + - "," + CommonMetrics::DEFAULT_MODIFIERS.GetValue()); - pi->GetPlayerState()->RebuildPlayerOptionsFromActiveAttacks(); - } - } - } GAMESTATE->m_bLoadingNextSong = true; MESSAGEMAN->Broadcast( "BeforeLoadingNextCourseSong" ); @@ -3058,17 +2845,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) ON_COMMAND( m_textSurviveTime ); } - if( GAMESTATE->IsCourseMode() ) - { - if( GAMESTATE->GetCourseSongIndex() >= int(m_apSongsQueue.size() / 2) ) - SOUND->PlayOnceFromAnnouncer( "gameplay oni failed halfway" ); - else - SOUND->PlayOnceFromAnnouncer( "gameplay oni failed" ); - } - else - { - SOUND->PlayOnceFromAnnouncer( "gameplay failed" ); - } + SOUND->PlayOnceFromAnnouncer( "gameplay failed" ); } else if( SM == SM_Pause ) { @@ -3127,16 +2904,6 @@ void ScreenGameplay::Cancel( ScreenMessage smSendWhenDone ) ScreenWithMenuElements::Cancel( smSendWhenDone ); } -Song *ScreenGameplay::GetNextCourseSong() const -{ - ASSERT( GAMESTATE->IsCourseMode() ); - - int iPlaySongIndex = GAMESTATE->GetCourseSongIndex()+1; - iPlaySongIndex %= m_apSongsQueue.size(); - - return m_apSongsQueue[iPlaySongIndex]; -} - PlayerInfo *ScreenGameplay::GetPlayerInfo( PlayerNumber pn ) { FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) @@ -3246,7 +3013,6 @@ bool ScreenGameplay::LoadReplay() class LunaScreenGameplay: public Luna { public: - static int GetNextCourseSong( T* p, lua_State *L ) { p->GetNextCourseSong()->PushSelf(L); return 1; } static int Center1Player( T* p, lua_State *L ) { lua_pushboolean( L, p->Center1Player() ); return 1; } static int GetLifeMeter( T* p, lua_State *L ) { @@ -3332,7 +3098,6 @@ class LunaScreenGameplay: public Luna LunaScreenGameplay() { - ADD_METHOD( GetNextCourseSong ); ADD_METHOD( Center1Player ); ADD_METHOD( GetLifeMeter ); ADD_METHOD( GetPlayerInfo ); diff --git a/src/ScreenGameplay.h b/src/ScreenGameplay.h index d1989ca2f0..bf9200be20 100644 --- a/src/ScreenGameplay.h +++ b/src/ScreenGameplay.h @@ -214,7 +214,6 @@ class ScreenGameplay : public ScreenWithMenuElements ThemeMetric SONG_NUMBER_FORMAT; ThemeMetric SURVIVAL_MOD_OVERRIDE; - bool IsLastSong(); void SetupSong( int iSongIndex ); void ReloadCurrentSong(); virtual void LoadNextSong(); diff --git a/src/ScreenHighScores.cpp b/src/ScreenHighScores.cpp index a5432e9386..5198a37c85 100644 --- a/src/ScreenHighScores.cpp +++ b/src/ScreenHighScores.cpp @@ -42,32 +42,6 @@ static void GetAllSongsToShow( vector &vpOut, int iNumMostRecentScoresToS } } -static void GetAllCoursesToShow( vector &vpOut, CourseType ct, int iNumMostRecentScoresToShow ) -{ - vpOut.clear(); - vector vpCourses; - if( ct == CourseType_Invalid ) - SONGMAN->GetAllCourses( vpCourses, false ); - else - SONGMAN->GetCourses( ct, vpCourses, false ); - - FOREACH_CONST( Course*, vpCourses, c) - { - if( UNLOCKMAN->CourseIsLocked(*c) ) - continue; // skip - if( !(*c)->ShowInDemonstrationAndRanking() ) - continue; // skip - vpOut.push_back( *c ); - } - if( (int)vpOut.size() > iNumMostRecentScoresToShow ) - { - CourseUtil::SortCoursePointerArrayByTitle( vpOut ); - CourseUtil::SortByMostRecentlyPlayedForMachine( vpOut ); - if( (int) vpOut.size() > iNumMostRecentScoresToShow ) - vpOut.erase( vpOut.begin()+iNumMostRecentScoresToShow, vpOut.end() ); - } -} - ///////////////////////////////////////////// ScoreScroller::ScoreScroller() @@ -141,12 +115,6 @@ void ScoreScroller::ConfigureActor( Actor *pActor, int iItem ) pSteps = NULL; LuaHelpers::Push( L, pSteps ); } - else if( data.m_pCourse != NULL ) - { - const Course* pCourse = data.m_pCourse; - Trail *pTrail = pCourse->GetTrail( st, dc ); - LuaHelpers::Push( L, pTrail ); - } // Because pSteps or pTrail can be NULL, what we're creating in Lua is not an array. // It must be iterated using pairs(), not ipairs(). lua_setfield( L, -2, ssprintf("%d",i+1) ); @@ -168,15 +136,6 @@ void ScoreScroller::LoadSongs( int iNumRecentScores ) m_vScoreRowItemData[i].m_pSong = vpSongs[i]; } -void ScoreScroller::LoadCourses( CourseType ct, int iNumRecentScores ) -{ - vector vpCourses; - GetAllCoursesToShow( vpCourses, ct, iNumRecentScores ); - m_vScoreRowItemData.resize( vpCourses.size() ); - for( unsigned i=0; i DifficultyAndStepsType; @@ -25,7 +24,6 @@ class ScoreScroller: public DynamicActorScroller public: ScoreScroller(); void LoadSongs( int iNumRecentScores ); - void LoadCourses( CourseType ct, int iNumRecentScores ); void Load( const RString &sClassName ); void SetDisplay( const vector &DifficultiesToShow ); bool Scroll( int iDir ); @@ -40,7 +38,7 @@ class ScoreScroller: public DynamicActorScroller ScoreRowItemData() { m_pSong = NULL; m_pCourse = NULL; } Song *m_pSong; - Course *m_pCourse; + Song *m_pCourse; }; vector m_vScoreRowItemData; diff --git a/src/ScreenJukebox.cpp b/src/ScreenJukebox.cpp index a25649d546..ea85c6b342 100644 --- a/src/ScreenJukebox.cpp +++ b/src/ScreenJukebox.cpp @@ -10,7 +10,6 @@ #include "ScreenAttract.h" #include "RageUtil.h" #include "UnlockManager.h" -#include "Course.h" #include "ThemeManager.h" #include "Style.h" #include "PlayerState.h" @@ -31,14 +30,6 @@ void ScreenJukebox::SetSong() vector vSongs; - /* Check to see if there is a theme course. If there is a course that has - * the exact same name as the theme, then we pick a song from this course. */ - Course *pCourse = SONGMAN->GetCourseFromName( THEME->GetCurThemeName() ); - if( pCourse != NULL ) - for ( unsigned i = 0; i < pCourse->m_vEntries.size(); i++ ) - if( pCourse->m_vEntries[i].IsFixedSong() ) - vSongs.push_back( pCourse->m_vEntries[i].songID.ToSong() ); - if ( vSongs.size() == 0 ) vSongs = SONGMAN->GetSongs( GAMESTATE->m_sPreferredSongGroup ); // Still nothing? @@ -98,66 +89,6 @@ void ScreenJukebox::SetSong() FOREACH_PlayerNumber( p ) GAMESTATE->m_pCurSteps[p].Set( pSteps ); - bool bShowModifiers = randomf(0,1) <= SHOW_COURSE_MODIFIERS_PROBABILITY; - if( bShowModifiers ) - { - /* If we have a modifier course containing this song, apply its - * modifiers. Only check fixed course entries. */ - vector apCourses; - SONGMAN->GetAllCourses( apCourses, false ); - vector apOptions; - vector apPossibleCourses; - for( unsigned j = 0; j < apCourses.size(); ++j ) - { - Course *lCourse = apCourses[j]; - const CourseEntry *pEntry = lCourse->FindFixedSong( pSong ); - if( pEntry == NULL || pEntry->attacks.size() == 0 ) - continue; - - if( !ALLOW_ADVANCED_MODIFIERS ) - { - // There are some confusing mods that we don't want to show in demonstration. - bool bModsAreOkToShow = true; - AttackArray aAttacks = pEntry->attacks; - if( !pEntry->sModifiers.empty() ) - aAttacks.push_back( Attack::FromGlobalCourseModifier( pEntry->sModifiers ) ); - FOREACH_CONST( Attack, aAttacks, a ) - { - RString s = a->sModifiers; - s.MakeLower(); - // todo: allow themers to modify this list? -aj - if( s.find("dark") != string::npos || - s.find("stealth") != string::npos ) - { - bModsAreOkToShow = false; - break; - } - } - if( !bModsAreOkToShow ) - continue; // skip - } - - apOptions.push_back( pEntry ); - apPossibleCourses.push_back( pCourse ); - } - - if( !apOptions.empty() ) - { - int iIndex = RandomInt( apOptions.size() ); - m_pCourseEntry = apOptions[iIndex]; - Course *lCourse = apPossibleCourses[iIndex]; - - PlayMode pm = CourseTypeToPlayMode( lCourse->GetCourseType() ); - GAMESTATE->m_PlayMode.Set( pm ); - GAMESTATE->m_pCurCourse.Set( lCourse ); - FOREACH_PlayerNumber( p ) - { - GAMESTATE->m_pCurTrail[p].Set( lCourse->GetTrail( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType ) ); - ASSERT( GAMESTATE->m_pCurTrail[p] != NULL ); - } - } - } - return; // done looking } diff --git a/src/ScreenNameEntry.cpp b/src/ScreenNameEntry.cpp index 1d9c27cab7..feb34b1482 100644 --- a/src/ScreenNameEntry.cpp +++ b/src/ScreenNameEntry.cpp @@ -8,7 +8,6 @@ #include "GameSoundManager.h" #include "GameState.h" #include "ThemeManager.h" -#include "Course.h" #include "AnnouncerManager.h" #include "ProfileManager.h" #include "Profile.h" @@ -212,17 +211,6 @@ void ScreenNameEntry::Init() return; } - bool IsOnRanking = ( (GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP || GAMESTATE->m_PlayMode == PLAY_MODE_ONI) - && !(GAMESTATE->m_pCurCourse->IsRanking()) ); - - if( PREFSMAN->m_GetRankingName == RANKING_OFF || - (PREFSMAN->m_GetRankingName == RANKING_LIST && !IsOnRanking) ) - { - // don't collect score due to ranking setting - PostScreenMessage( SM_GoToNextScreen, 0 ); - return; - } - GAMESTATE->m_bGameplayLeadIn.Set( false ); // enable the gray arrows FOREACH_PlayerNumber( p ) diff --git a/src/ScreenNetSelectMusic.cpp b/src/ScreenNetSelectMusic.cpp index d141b34924..cd29c4e28d 100644 --- a/src/ScreenNetSelectMusic.cpp +++ b/src/ScreenNetSelectMusic.cpp @@ -577,7 +577,7 @@ void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn ) { if( GAMESTATE->m_pCurSong == NULL ) { - m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid ); + m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner); //m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); // It will blank it out return; } @@ -590,7 +590,7 @@ void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn ) if( ( m_DC[pn] < NUM_Difficulty ) && ( m_DC[pn] >= Difficulty_Beginner ) ) m_StepsDisplays[pn].SetFromSteps( pSteps ); else - m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid ); + m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner ); } void ScreenNetSelectMusic::MusicChanged() diff --git a/src/ScreenOptionsCourseOverview.cpp b/src/ScreenOptionsCourseOverview.cpp index fec1bc31d7..e69de29bb2 100644 --- a/src/ScreenOptionsCourseOverview.cpp +++ b/src/ScreenOptionsCourseOverview.cpp @@ -1,279 +0,0 @@ -#include "global.h" - -#include "ScreenOptionsCourseOverview.h" -#include "ScreenManager.h" -#include "RageUtil.h" -#include "GameState.h" -#include "OptionRowHandler.h" -#include "ProfileManager.h" -#include "ScreenMiniMenu.h" -#include "LocalizedString.h" -#include "SongManager.h" -#include "SongUtil.h" -#include "ScreenTextEntry.h" -#include "GameManager.h" -#include "Profile.h" -#include "ScreenPrompt.h" -#include "PlayerState.h" -#include "Style.h" -#include "PrefsManager.h" - -enum CourseOverviewRow -{ - CourseOverviewRow_Play, - CourseOverviewRow_Edit, - CourseOverviewRow_Shuffle, - CourseOverviewRow_Rename, - CourseOverviewRow_Delete, - CourseOverviewRow_Save, - NUM_CourseOverviewRow -}; - -static bool CurrentCourseIsSaved() -{ - Course *pCourse = GAMESTATE->m_pCurCourse; - if( pCourse == NULL ) - return false; - return !pCourse->m_sPath.empty(); -} - -static const MenuRowDef g_MenuRows[] = -{ - MenuRowDef( -1, "Play", true, EditMode_Practice, true, false, 0, NULL ), - MenuRowDef( -1, "Edit Course", true, EditMode_Practice, true, false, 0, NULL ), - MenuRowDef( -1, "Shuffle", true, EditMode_Practice, true, false, 0, NULL ), - MenuRowDef( -1, "Rename", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, NULL ), - MenuRowDef( -1, "Delete", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, NULL ), - MenuRowDef( -1, "Save", true, EditMode_Practice, true, false, 0, NULL ), -}; - -REGISTER_SCREEN_CLASS( ScreenOptionsCourseOverview ); - -static LocalizedString ENTER_COURSE_NAME ("ScreenOptionsCourseOverview", "Enter a name for the course."); -static LocalizedString ERROR_SAVING_COURSE ("ScreenOptionsCourseOverview", "Error saving course."); -static LocalizedString COURSE_SAVED ("ScreenOptionsCourseOverview", "Course saved successfully."); -static LocalizedString ERROR_RENAMING ("ScreenOptionsCourseOverview", "Error renaming file."); -static LocalizedString ERROR_DELETING_FILE ("ScreenOptionsCourseOverview", "Error deleting the file '%s'."); -static LocalizedString COURSE_WILL_BE_LOST ("ScreenOptionsCourseOverview", "This course will be lost permanently."); -static LocalizedString CONTINUE_WITH_DELETE ("ScreenOptionsCourseOverview", "Continue with delete?"); - -AutoScreenMessage( SM_BackFromEnterName ); -AutoScreenMessage( SM_BackFromRename ); -AutoScreenMessage( SM_BackFromDelete ); - -void ScreenOptionsCourseOverview::Init() -{ - if( PREFSMAN->m_iArcadeOptionsNavigation ) - SetNavigation( NAV_THREE_KEY_MENU ); - - ScreenOptions::Init(); - - m_soundSave.Load( THEME->GetPathS(m_sName,"Save") ); - PLAY_SCREEN.Load(m_sName,"PlayScreen"); - EDIT_SCREEN.Load(m_sName,"EditScreen"); -} - -void ScreenOptionsCourseOverview::BeginScreen() -{ - vector vHands; - FOREACH_ENUM( CourseOverviewRow, rowIndex ) - { - const MenuRowDef &mr = g_MenuRows[rowIndex]; - OptionRowHandler *pHand = OptionRowHandlerUtil::MakeSimple( mr ); - vHands.push_back( pHand ); - } - - ScreenOptions::InitMenu( vHands ); - - ScreenOptions::BeginScreen(); - - // clear the current song in case it's set when we back out from gameplay - GAMESTATE->m_pCurSong.Set( NULL ); -} - -ScreenOptionsCourseOverview::~ScreenOptionsCourseOverview() -{ - -} - -void ScreenOptionsCourseOverview::ImportOptions( int iRow, const vector &vpns ) -{ - //OptionRow &row = *m_pRows[iRow]; -} - -void ScreenOptionsCourseOverview::ExportOptions( int iRow, const vector &vpns ) -{ - OptionRow &row = *m_pRows[iRow]; - int iIndex = row.GetOneSharedSelection( true ); - RString sValue; - if( iIndex >= 0 ) - sValue = row.GetRowDef().m_vsChoices[ iIndex ]; -} - -void ScreenOptionsCourseOverview::HandleScreenMessage( const ScreenMessage SM ) -{ - if( SM == SM_GoToPrevScreen ) - { - // If we're pointing to an unsaved course, it will be inaccessible once we're back on ScreenOptionsManageCourses. - GAMESTATE->m_pCurCourse.Set( NULL ); - } - else if( SM == SM_GoToNextScreen ) - { - int iRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - switch( iRow ) - { - case CourseOverviewRow_Play: - EditCourseUtil::PrepareForPlay(); - SCREENMAN->SetNewScreen( PLAY_SCREEN ); - return; // handled - case CourseOverviewRow_Edit: - SCREENMAN->SetNewScreen( EDIT_SCREEN ); - return; // handled - } - } - else if( SM == SM_BackFromEnterName ) - { - if( !ScreenTextEntry::s_bCancelledLast ) - { - ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this - - if( EditCourseUtil::RenameAndSave( GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer ) ) - { - m_soundSave.Play(true); - SCREENMAN->SystemMessage( COURSE_SAVED ); - } - } - } - else if( SM == SM_BackFromRename ) - { - if( !ScreenTextEntry::s_bCancelledLast ) - { - ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this - - if( !EditCourseUtil::RenameAndSave(GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer) ) - { - ScreenPrompt::Prompt( SM_None, ERROR_RENAMING ); - return; - } - - SCREENMAN->SetNewScreen( this->m_sName ); // reload - } - } - else if( SM == SM_BackFromDelete ) - { - if( ScreenPrompt::s_LastAnswer == ANSWER_YES ) - { - if( !EditCourseUtil::RemoveAndDeleteFile(GAMESTATE->m_pCurCourse) ) - { - ScreenPrompt::Prompt( SM_None, ssprintf(ERROR_DELETING_FILE.GetValue(), GAMESTATE->m_pCurCourse->m_sPath.c_str()) ); - return; - } - - GAMESTATE->m_pCurCourse.Set( NULL ); - GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL ); - - /* Our course is gone, so back out. */ - StartTransitioningScreen( SM_GoToPrevScreen ); - } - } - - ScreenOptions::HandleScreenMessage( SM ); -} - -void ScreenOptionsCourseOverview::AfterChangeValueInRow( int iRow, PlayerNumber pn ) -{ - ScreenOptions::AfterChangeValueInRow( iRow, pn ); -} - - -void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input ) -{ - if( IsTransitioning() ) - return; - - int iRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - switch( iRow ) - { - case CourseOverviewRow_Play: - case CourseOverviewRow_Edit: - SCREENMAN->PlayStartSound(); - this->BeginFadingOut(); - return; // handled - case CourseOverviewRow_Shuffle: - { - Course *pCourse = GAMESTATE->m_pCurCourse; - std::shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end(), g_RandomNumberGenerator ); - Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->GetCurrentStyle(input.pn)->m_StepsType ); - GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); - SCREENMAN->PlayStartSound(); - MESSAGEMAN->Broadcast("CurrentCourseChanged"); - } - return; // handled - case CourseOverviewRow_Rename: - ScreenTextEntry::TextEntry( - SM_BackFromRename, - ENTER_COURSE_NAME, - GAMESTATE->m_pCurCourse->GetDisplayFullTitle(), - EditCourseUtil::MAX_NAME_LENGTH, - EditCourseUtil::ValidateEditCourseName ); - break; - case CourseOverviewRow_Delete: - ScreenPrompt::Prompt( SM_BackFromDelete, COURSE_WILL_BE_LOST.GetValue()+"\n\n"+CONTINUE_WITH_DELETE.GetValue(), PROMPT_YES_NO, ANSWER_NO ); - break; - case CourseOverviewRow_Save: - { - bool bPromptForName = EditCourseUtil::s_bNewCourseNeedsName; - if( bPromptForName ) - { - ScreenTextEntry::TextEntry( - SM_BackFromEnterName, - ENTER_COURSE_NAME, - GAMESTATE->m_pCurCourse->GetDisplayFullTitle(), - EditCourseUtil::MAX_NAME_LENGTH, - EditCourseUtil::ValidateEditCourseName ); - } - else - { - if( EditCourseUtil::Save( GAMESTATE->m_pCurCourse ) ) - { - m_soundSave.Play(true); - SCREENMAN->SystemMessage( COURSE_SAVED ); - } - else - { - SCREENMAN->PlayInvalidSound(); - SCREENMAN->SystemMessage( ERROR_SAVING_COURSE ); - } - } - } - return; // handled - } - - ScreenOptions::ProcessMenuStart( input ); -} - - -/* - * (c) 2003-2004 Chris Danford - * 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. - */ diff --git a/src/ScreenOptionsCourseOverview.h b/src/ScreenOptionsCourseOverview.h index 47b8e960eb..e69de29bb2 100644 --- a/src/ScreenOptionsCourseOverview.h +++ b/src/ScreenOptionsCourseOverview.h @@ -1,53 +0,0 @@ -#ifndef ScreenOptionsCourseOverview_H -#define ScreenOptionsCourseOverview_H - -#include "ScreenOptions.h" - -class ScreenOptionsCourseOverview : public ScreenOptions -{ -public: - virtual ~ScreenOptionsCourseOverview(); - - virtual void Init(); - virtual void BeginScreen(); - -protected: -private: - virtual void ImportOptions( int row, const vector &vpns ); - virtual void ExportOptions( int row, const vector &vpns ); - - virtual void HandleScreenMessage( const ScreenMessage SM ); - virtual void AfterChangeValueInRow( int iRow, PlayerNumber pn ); - virtual void ProcessMenuStart( const InputEventPlus &input ); - - RageSound m_soundSave; - ThemeMetric PLAY_SCREEN; - ThemeMetric EDIT_SCREEN; -}; - -#endif - -/* - * (c) 2003-2004 Chris Danford - * 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. - */ diff --git a/src/ScreenOptionsEditCourse.cpp b/src/ScreenOptionsEditCourse.cpp index 6afdf62bef..e69de29bb2 100644 --- a/src/ScreenOptionsEditCourse.cpp +++ b/src/ScreenOptionsEditCourse.cpp @@ -1,523 +0,0 @@ -#include "global.h" - -#include "ScreenOptionsEditCourse.h" -#include "ScreenMiniMenu.h" -#include "SongUtil.h" -#include "SongManager.h" -#include "OptionRowHandler.h" -#include "Song.h" -#include "GameState.h" -#include "ScreenPrompt.h" -#include "LocalizedString.h" -#include "CourseUtil.h" -#include "Song.h" -#include "Style.h" -#include "Steps.h" - -static void GetStepsForSong( Song *pSong, vector &vpStepsOut ) -{ - SongUtil::GetSteps( pSong, vpStepsOut, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType ); - // xxx: If the StepsType isn't valid for the current game, this will cause - // a crash when changing songs. -aj - StepsUtil::RemoveLockedSteps( pSong, vpStepsOut ); - StepsUtil::SortNotesArrayByDifficulty( vpStepsOut ); -} - -// XXX: very similar to OptionRowHandlerSteps -class EditCourseOptionRowHandlerSteps : public OptionRowHandler -{ -public: - void Load( int iEntryIndex ) - { - m_iEntryIndex = iEntryIndex; - } - virtual ReloadChanged Reload() - { - m_Def.m_vsChoices.clear(); - m_vpSteps.clear(); - - Song *pSong = GAMESTATE->m_pCurSong; - if( pSong ) // playing a song - { - GetStepsForSong( pSong, m_vpSteps ); - FOREACH_CONST( Steps*, m_vpSteps, steps ) - { - RString s; - if( (*steps)->GetDifficulty() == Difficulty_Edit ) - s = (*steps)->GetDescription(); - else - s = CustomDifficultyToLocalizedString( StepsToCustomDifficulty(*steps) ); - s += ssprintf( " %d", (*steps)->GetMeter() ); - m_Def.m_vsChoices.push_back( s ); - } - m_Def.m_vEnabledForPlayers.clear(); - m_Def.m_vEnabledForPlayers.insert( PLAYER_1 ); - } - else - { - m_Def.m_vsChoices.push_back( "n/a" ); - m_vpSteps.push_back( NULL ); - m_Def.m_vEnabledForPlayers.clear(); - } - - - return RELOAD_CHANGED_ALL; - } - virtual void ImportOption( OptionRow *pRow, const vector &vpns, vector vbSelectedOut[NUM_PLAYERS] ) const - { - Trail *pTrail = GAMESTATE->m_pCurTrail[PLAYER_1]; - Steps *pSteps; - if( pTrail ) - { - if( m_iEntryIndex < (int)pTrail->m_vEntries.size() ) - pSteps = pTrail->m_vEntries[ m_iEntryIndex ].pSteps; - } - - vector::const_iterator iter = find( m_vpSteps.begin(), m_vpSteps.end(), pSteps ); - if( iter == m_vpSteps.end() ) - { - pRow->SetOneSharedSelection( 0 ); - } - else - { - int index = iter - m_vpSteps.begin(); - pRow->SetOneSharedSelection( index ); - } - - } - virtual int ExportOption( const vector &vpns, const vector vbSelected[NUM_PLAYERS] ) const - { - return 0; - } - Steps *GetSteps( int iStepsIndex ) const - { - return m_vpSteps[iStepsIndex]; - } - -protected: - int m_iEntryIndex; - vector m_vpSteps; -}; - - - -const int NUM_SONG_ROWS = 20; - -REGISTER_SCREEN_CLASS( ScreenOptionsEditCourse ); - -enum EditCourseRow -{ - EditCourseRow_Minutes, - NUM_EditCourseRow -}; - -enum RowType -{ - RowType_Song, - RowType_Steps, - NUM_RowType, - RowType_Invalid, -}; -static int RowToEntryIndex( int iRow ) -{ - if( iRow < NUM_EditCourseRow ) - return -1; - - return (iRow-NUM_EditCourseRow)/NUM_RowType; -} -static RowType RowToRowType( int iRow ) -{ - if( iRow < NUM_EditCourseRow ) - return RowType_Invalid; - return (RowType)((iRow-NUM_EditCourseRow) % NUM_RowType); -} -static int EntryIndexAndRowTypeToRow( int iEntryIndex, RowType rowType ) -{ - return NUM_EditCourseRow + iEntryIndex*NUM_RowType + rowType; -} - -void ScreenOptionsEditCourse::Init() -{ - ScreenOptions::Init(); - - SongCriteria sc; - sc.m_Selectable = SongCriteria::Selectable_Yes; - sc.m_Tutorial = SongCriteria::Tutorial_No; - sc.m_Locked = SongCriteria::Locked_Unlocked; - - SongUtil::FilterSongs( sc, SONGMAN->GetAllSongs(), m_vpSongs, true ); - - SongUtil::SortSongPointerArrayByTitle( m_vpSongs ); -} - -const MenuRowDef g_MenuRows[] = -{ - MenuRowDef( -1, "Max Minutes", true, EditMode_Practice, true, false, 0, NULL ), -}; - -static LocalizedString EMPTY ("ScreenOptionsEditCourse","-Empty-"); -static LocalizedString SONG ("ScreenOptionsEditCourse","Song"); -static LocalizedString STEPS ("ScreenOptionsEditCourse","Steps"); -static LocalizedString MINUTES ("ScreenOptionsEditCourse","minutes"); - -static RString MakeMinutesString( int mins ) -{ - if( mins == 0 ) - return "No Cut-off"; - return ssprintf( "%d", mins ) + " " + MINUTES.GetValue(); -} - -void ScreenOptionsEditCourse::BeginScreen() -{ - vector vHands; - - FOREACH_ENUM( EditCourseRow, rowIndex ) - { - const MenuRowDef &mr = g_MenuRows[rowIndex]; - OptionRowHandler *pHand = OptionRowHandlerUtil::MakeSimple( mr ); - - pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - pHand->m_Def.m_vsChoices.clear(); - - switch( rowIndex ) - { - DEFAULT_FAIL(rowIndex); - case EditCourseRow_Minutes: - pHand->m_Def.m_vsChoices.push_back( MakeMinutesString(0) ); - for( int i=EditCourseUtil::MIN_WORKOUT_MINUTES; i<=20; i+=2 ) - pHand->m_Def.m_vsChoices.push_back( MakeMinutesString(i) ); - for( int i=20; i<=EditCourseUtil::MAX_WORKOUT_MINUTES; i+=5 ) - pHand->m_Def.m_vsChoices.push_back( MakeMinutesString(i) ); - break; - } - - pHand->m_Def.m_bExportOnChange = true; - vHands.push_back( pHand ); - } - - - - for( int i=0; iGetDisplayFullTitle() ); - mrd.sName = ssprintf(SONG.GetValue() + " %d",i+1); - OptionRowHandler *pHand = OptionRowHandlerUtil::MakeSimple( mrd ); - pHand->m_Def.m_bAllowThemeTitle = false; // already themed - pHand->m_Def.m_sExplanationName = "Choose Song"; - pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - pHand->m_Def.m_bExportOnChange = true; - vHands.push_back( pHand ); - } - - { - EditCourseOptionRowHandlerSteps *pHand = new EditCourseOptionRowHandlerSteps; - pHand->Load( i ); - pHand->m_Def.m_vsChoices.push_back( "n/a" ); - pHand->m_Def.m_sName = ssprintf(STEPS.GetValue() + " %d",i+1); - pHand->m_Def.m_bAllowThemeTitle = false; // already themed - pHand->m_Def.m_bAllowThemeItems = false; // already themed - pHand->m_Def.m_sExplanationName = "Choose Steps"; - pHand->m_Def.m_bOneChoiceForAllPlayers = true; - pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - pHand->m_Def.m_bExportOnChange = true; - vHands.push_back( pHand ); - } - - } - - ScreenOptions::InitMenu( vHands ); - - ScreenOptions::BeginScreen(); - - - for( int i=0; i<(int)m_pRows.size(); i++ ) - { - OptionRow *pRow = m_pRows[i]; - m_iCurrentRow[PLAYER_1] = i; - this->SetCurrentSong(); - pRow->Reload(); - } - m_iCurrentRow[PLAYER_1] = 0; - - this->SetCurrentSong(); - - //this->AfterChangeRow( PLAYER_1 ); -} - -ScreenOptionsEditCourse::~ScreenOptionsEditCourse() -{ - -} - -void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector &vpns ) -{ - OptionRow &row = *m_pRows[iRow]; - if( row.GetRowType() == OptionRow::RowType_Exit ) - return; - - switch( iRow ) - { - case EditCourseRow_Minutes: - row.SetOneSharedSelection( 0 ); - break; - default: - { - int iEntryIndex = RowToEntryIndex( iRow ); - RowType rowType = RowToRowType( iRow ); - - switch( rowType ) - { - DEFAULT_FAIL( rowType ); - case RowType_Song: - { - Song *pSong = NULL; - if( iEntryIndex < (int)GAMESTATE->m_pCurCourse->m_vEntries.size() ) - pSong = GAMESTATE->m_pCurCourse->m_vEntries[iEntryIndex].songID.ToSong(); - - vector::iterator iter = find( m_vpSongs.begin(), m_vpSongs.end(), pSong ); - if( iter == m_vpSongs.end() ) - row.SetOneSharedSelection( 0 ); - else - row.SetOneSharedSelection( 1 + iter - m_vpSongs.begin() ); - } - break; - case RowType_Steps: - // the OptionRowHandler does its own importing - break; - } - } - break; - } -} - -void ScreenOptionsEditCourse::ExportOptions( int iRow, const vector &vpns ) -{ - FOREACH_ENUM( EditCourseRow, i ) - { - OptionRow &row = *m_pRows[i]; - int iIndex = row.GetOneSharedSelection( true ); - RString sValue; - if( iIndex >= 0 ) - sValue = row.GetRowDef().m_vsChoices[ iIndex ]; - - switch( i ) - { - DEFAULT_FAIL(i); - case EditCourseRow_Minutes: - break; - } - } - - GAMESTATE->m_pCurCourse->m_vEntries.clear(); - - for( int i=NUM_EditCourseRow; i<(int)m_pRows.size(); i++ ) - { - OptionRow &row = *m_pRows[i]; - if( row.GetRowType() == OptionRow::RowType_Exit ) - continue; - - RowType rowType = RowToRowType( i ); - int iEntryIndex = RowToEntryIndex( i ); - - switch( rowType ) - { - case RowType_Song: - { - Song *pSong = this->GetSongForEntry( iEntryIndex ); - if( pSong ) - { - Steps *pSteps = this->GetStepsForEntry( iEntryIndex ); - ASSERT_M( pSteps != NULL, "No Steps for this Song!" ); - CourseEntry ce; - ce.songID.FromSong( pSong ); - ce.stepsCriteria.m_difficulty = pSteps->GetDifficulty(); - GAMESTATE->m_pCurCourse->m_vEntries.push_back( ce ); - } - } - break; - case RowType_Steps: - // push each CourseEntry when we handle each RowType_Song above - break; - default: - break; - } - } - - EditCourseUtil::UpdateAndSetTrail(); -} - -void ScreenOptionsEditCourse::GoToNextScreen() -{ -} - -void ScreenOptionsEditCourse::GoToPrevScreen() -{ -} - -void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM ) -{ - if( SM == SM_ExportOptions ) - { - //g_Workout.m_vpSongs.clear(); - } - - ScreenOptions::HandleScreenMessage( SM ); -} - -void ScreenOptionsEditCourse::SetCurrentSong() -{ - int iRow = m_iCurrentRow[PLAYER_1]; - OptionRow &row = *m_pRows[iRow]; - - if( row.GetRowType() == OptionRow::RowType_Exit ) - { - GAMESTATE->m_pCurSong.Set( NULL ); - GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL ); - } - else - { - iRow = m_iCurrentRow[PLAYER_1]; - int iEntryIndex = RowToEntryIndex( iRow ); - Song *pSong = NULL; - if( iEntryIndex != -1 ) - { - int iCurrentSongRow = EntryIndexAndRowTypeToRow(iEntryIndex,RowType_Song); - OptionRow &oRow = *m_pRows[ iCurrentSongRow ]; - int index = oRow.GetOneSelection(PLAYER_1); - if( index != 0 ) - pSong = m_vpSongs[ index - 1 ]; - } - if ( pSong != NULL ) - { - GAMESTATE->m_pCurSong.Set( pSong ); - } - } -} - -void ScreenOptionsEditCourse::SetCurrentSteps() -{ - Song *pSong = GAMESTATE->m_pCurSong; - if( pSong ) - { - int iRow = m_iCurrentRow[PLAYER_1]; - int iEntryIndex = RowToEntryIndex( iRow ); - OptionRow &row = *m_pRows[ EntryIndexAndRowTypeToRow(iEntryIndex, RowType_Steps) ]; - int iStepsIndex = row.GetOneSharedSelection(); - const EditCourseOptionRowHandlerSteps *pHand = dynamic_cast( row.GetHandler() ); - ASSERT( pHand != NULL ); - Steps *pSteps = pHand->GetSteps( iStepsIndex ); - GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps ); - } - else - { - GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL ); - } -} - -Song *ScreenOptionsEditCourse::GetSongForEntry( int iEntryIndex ) -{ - int iRow = EntryIndexAndRowTypeToRow( iEntryIndex, RowType_Song ); - OptionRow &row = *m_pRows[iRow]; - - int index = row.GetOneSharedSelection(); - if( index == 0 ) - return NULL; - return m_vpSongs[ index - 1 ]; -} - -Steps *ScreenOptionsEditCourse::GetStepsForEntry( int iEntryIndex ) -{ - int iRow = EntryIndexAndRowTypeToRow( iEntryIndex, RowType_Steps ); - OptionRow &row = *m_pRows[iRow]; - int index = row.GetOneSharedSelection(); - Song *pSong = GetSongForEntry( iEntryIndex ); - vector vpSteps; - GetStepsForSong( pSong, vpSteps ); - return vpSteps[index]; -} - -void ScreenOptionsEditCourse::AfterChangeRow( PlayerNumber pn ) -{ - ScreenOptions::AfterChangeRow( pn ); - - const int iCurRow = m_iCurrentRow[pn]; - // only do this if it's not the first row. -aj - if( iCurRow > 0 ) - { - SetCurrentSong(); - SetCurrentSteps(); - } -} - -void ScreenOptionsEditCourse::AfterChangeValueInRow( int iRow, PlayerNumber pn ) -{ - ScreenOptions::AfterChangeValueInRow( iRow, pn ); - - int iEntryIndex = RowToEntryIndex( iRow ); - RowType rowType = RowToRowType( iRow ); - switch( rowType ) - { - case RowType_Song: - { - SetCurrentSong(); - OptionRow &row = *m_pRows[ EntryIndexAndRowTypeToRow(iEntryIndex, RowType_Steps) ]; - row.Reload(); - } - break; - case RowType_Steps: - SetCurrentSteps(); - break; - default: - break; - } -} - -const int MIN_ENABLED_SONGS = 2; - -static LocalizedString MUST_ENABLE_AT_LEAST("ScreenOptionsEditCourse","You must enable at least %d songs."); -void ScreenOptionsEditCourse::ProcessMenuStart( const InputEventPlus &input ) -{ - if( IsTransitioning() ) - return; - - int iRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - - unsigned iSongCount = GAMESTATE->m_pCurCourse->m_vEntries.size(); - - if( m_pRows[iRow]->GetRowType() == OptionRow::RowType_Exit && iSongCount < unsigned(MIN_ENABLED_SONGS) ) - { - ScreenPrompt::Prompt( SM_None, ssprintf(MUST_ENABLE_AT_LEAST.GetValue(),MIN_ENABLED_SONGS) ); - return; - } - - ScreenOptions::ProcessMenuStart( input ); -} - - -/* - * (c) 2003-2004 Chris Danford - * 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. - */ diff --git a/src/ScreenOptionsEditCourse.h b/src/ScreenOptionsEditCourse.h index cd21e23fe4..e69de29bb2 100644 --- a/src/ScreenOptionsEditCourse.h +++ b/src/ScreenOptionsEditCourse.h @@ -1,62 +0,0 @@ -#ifndef ScreenOptionsEditCourse_H -#define ScreenOptionsEditCourse_H - -#include "ScreenOptions.h" -class Song; -class Steps; - -class ScreenOptionsEditCourse : public ScreenOptions -{ -public: - virtual ~ScreenOptionsEditCourse(); - - virtual void Init(); - virtual void BeginScreen(); - -protected: -private: - virtual void ImportOptions( int row, const vector &vpns ); - virtual void ExportOptions( int row, const vector &vpns ); - - virtual void GoToNextScreen(); - virtual void GoToPrevScreen(); - - virtual void HandleScreenMessage( const ScreenMessage SM ); - virtual void AfterChangeRow( PlayerNumber pn ); - virtual void AfterChangeValueInRow( int iRow, PlayerNumber pn ); - virtual void ProcessMenuStart( const InputEventPlus &input ); - - void SetCurrentSong(); - void SetCurrentSteps(); - Song *GetSongForEntry( int iEntryIndex ); - Steps *GetStepsForEntry( int iEntryIndex ); - - vector m_vpSongs; -}; - -#endif - -/* - * (c) 2003-2004 Chris Danford - * 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. - */ diff --git a/src/ScreenOptionsExportPackage.cpp b/src/ScreenOptionsExportPackage.cpp index 976ad418f0..b51828a947 100644 --- a/src/ScreenOptionsExportPackage.cpp +++ b/src/ScreenOptionsExportPackage.cpp @@ -120,20 +120,6 @@ void ScreenOptionsExportPackageSubPage::BeginScreen() FOREACH_CONST( RString, vs, s ) GetDirListing( *s + "*", m_vsPossibleDirsToExport, true, true ); } - else if( *s_packageType == "Courses" ) - { - // Add courses. Only support courses that are in a group folder. - // Support for courses not in a group folder should be phased out. - vector vs; - GetDirListing( SpecialFiles::COURSES_DIR + "*", vs, true, true ); - StripCvsAndSvn( vs ); - StripMacResourceForks( vs ); - FOREACH_CONST( RString, vs, s ) - { - m_vsPossibleDirsToExport.push_back( *s ); - GetDirListing( *s + "/*", m_vsPossibleDirsToExport, true, true ); - } - } else if( *s_packageType == "Songs" ) { // Add song groups diff --git a/src/ScreenOptionsExportPackage.h b/src/ScreenOptionsExportPackage.h index 80e6c1059c..768239883e 100644 --- a/src/ScreenOptionsExportPackage.h +++ b/src/ScreenOptionsExportPackage.h @@ -4,8 +4,6 @@ #include "ScreenOptions.h" #include "ScreenMiniMenu.h" -class Course; - // Can this be done any better? -aj namespace ExportPackages { diff --git a/src/ScreenOptionsManageCourses.cpp b/src/ScreenOptionsManageCourses.cpp index becc2584b2..e69de29bb2 100644 --- a/src/ScreenOptionsManageCourses.cpp +++ b/src/ScreenOptionsManageCourses.cpp @@ -1,306 +0,0 @@ -#include "global.h" -#include "ScreenOptionsManageCourses.h" -#include "ScreenManager.h" -#include "RageLog.h" -#include "GameState.h" -#include "SongManager.h" -#include "CommonMetrics.h" -#include "ScreenTextEntry.h" -#include "ScreenPrompt.h" -#include "ScreenMiniMenu.h" -#include "GameManager.h" -#include "Difficulty.h" -#include "CourseUtil.h" -#include "LocalizedString.h" -#include "OptionRowHandler.h" -#include "ProfileManager.h" -#include "Profile.h" -#include "CourseWriterCRS.h" -#include "RageFileManager.h" -#include "PrefsManager.h" - -REGISTER_SCREEN_CLASS( ScreenOptionsManageCourses ); - -struct StepsTypeAndDifficulty -{ - StepsType st; - Difficulty cd; - - StepsTypeAndDifficulty( const StepsType &s, const Difficulty &d ) : st( s ), cd( d ) { } -}; - -inline bool operator==(StepsTypeAndDifficulty const &lhs, StepsTypeAndDifficulty const &rhs) -{ - return lhs.st == rhs.st && lhs.cd == rhs.cd; -} -inline bool operator!=(StepsTypeAndDifficulty const &lhs, StepsTypeAndDifficulty const &rhs) -{ - return !operator==(lhs,rhs); -} - -static void SetNextCombination() -{ - vector v; - { - FOREACH_CONST( StepsType, CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue(), st ) - { - FOREACH_CONST( CourseDifficulty, CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(), cd ) - v.push_back( StepsTypeAndDifficulty(*st, *cd) ); - } - } - - StepsTypeAndDifficulty curVal( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ); - vector::const_iterator iter = find( v.begin(), v.end(), curVal ); - if( iter == v.end() || ++iter == v.end() ) - iter = v.begin(); - - curVal = *iter; - - GAMESTATE->m_stEdit.Set( curVal.st ); - GAMESTATE->m_cdEdit.Set( curVal.cd ); - - EditCourseUtil::UpdateAndSetTrail(); -} - -void ScreenOptionsManageCourses::Init() -{ - if( PREFSMAN->m_iArcadeOptionsNavigation ) - SetNavigation( NAV_THREE_KEY_MENU ); - - ScreenOptions::Init(); - - m_soundDifficultyChanged.Load( THEME->GetPathS("ScreenEditCourseSubmenu", "difficulty changed") ); - EDIT_MODE.Load( m_sName,"EditMode" ); - CREATE_NEW_SCREEN.Load( m_sName, "CreateNewScreen" ); -} - -void ScreenOptionsManageCourses::BeginScreen() -{ - vector vpStyles; - GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vpStyles ); - const Style *pStyle = vpStyles[0]; - GAMESTATE->SetCurrentStyle( pStyle, PLAYER_INVALID ); - - if( GAMESTATE->m_stEdit == StepsType_Invalid || - GAMESTATE->m_cdEdit == Difficulty_Invalid ) - { - SetNextCombination(); - } - - // Remember the current course. All Course pointers will be invalidated when - // we load the machine profile below. - CourseID cidLast; - cidLast.FromCourse( GAMESTATE->m_pCurCourse ); - - vector vHands; - - int iIndex = 0; - - { - vHands.push_back( OptionRowHandlerUtil::MakeNull() ); - OptionRowDefinition &def = vHands.back()->m_Def; - def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.m_bOneChoiceForAllPlayers = true; - def.m_sName = "Create New Course"; - def.m_sExplanationName = "Create New Course"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "" ); - iIndex++; - } - - m_vpCourses.clear(); - // XXX: Why are we flushing here? - FILEMAN->FlushDirCache(); - PROFILEMAN->LoadMachineProfileEdits(); - - switch( EDIT_MODE.GetValue() ) - { - DEFAULT_FAIL( EDIT_MODE.GetValue() ); - case EditMode_Home: - EditCourseUtil::GetAllEditCourses( m_vpCourses ); - break; - case EditMode_Practice: - case EditMode_Full: - SONGMAN->GetAllCourses( m_vpCourses, false ); - break; - } - - FOREACH_CONST( Course*, m_vpCourses, p ) - { - vHands.push_back( OptionRowHandlerUtil::MakeNull() ); - OptionRowDefinition &def = vHands.back()->m_Def; - - def.m_sName = (*p)->GetDisplayFullTitle(); - def.m_bAllowThemeTitle = false; // not themable - def.m_sExplanationName = "Select Course"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "" ); - def.m_bAllowThemeItems = false; // already themed - iIndex++; - } - - ScreenOptions::InitMenu( vHands ); - - ScreenOptions::BeginScreen(); - - // select the last chosen course - GAMESTATE->m_pCurCourse.Set( cidLast.ToCourse() ); - if( GAMESTATE->m_pCurCourse ) - { - EditCourseUtil::UpdateAndSetTrail(); - vector::const_iterator iter = find( m_vpCourses.begin(), m_vpCourses.end(), GAMESTATE->m_pCurCourse ); - if( iter != m_vpCourses.end() ) - { - iIndex = iter - m_vpCourses.begin(); - this->MoveRowAbsolute( GAMESTATE->GetMasterPlayerNumber(), 1 + iIndex ); - } - } - - AfterChangeRow( GAMESTATE->GetMasterPlayerNumber() ); -} - -void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM ) -{ - if( SM == SM_GoToNextScreen ) - { - int iCurRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - - if( iCurRow == 0 ) // "create new" - { - /* Allocate the Course now, but don't save the file until the user explicitly chooses Save */ - Course *pCourse = new Course; - EditCourseUtil::LoadDefaults( *pCourse ); - pCourse->m_LoadedFromProfile = ProfileSlot_Machine; - SONGMAN->AddCourse( pCourse ); - GAMESTATE->m_pCurCourse.Set( pCourse ); - EditCourseUtil::s_bNewCourseNeedsName = true; - EditCourseUtil::UpdateAndSetTrail(); - - SCREENMAN->SetNewScreen( CREATE_NEW_SCREEN ); - return; // don't call base - } - else if( m_pRows[iCurRow]->GetRowType() == OptionRow::RowType_Exit ) - { - this->HandleScreenMessage( SM_GoToPrevScreen ); - return; // don't call base - } - else - { - // do base behavior - } - } - else if( SM == SM_LoseFocus ) - { - this->PlayCommand( "ScreenLoseFocus" ); - } - else if( SM == SM_GainFocus ) - { - this->PlayCommand( "ScreenGainFocus" ); - } - - ScreenOptions::HandleScreenMessage( SM ); -} - -void ScreenOptionsManageCourses::AfterChangeRow( PlayerNumber pn ) -{ - Course *pCourse = GetCourseWithFocus(); - Trail *pTrail = pCourse ? pCourse->GetTrail( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ) : NULL; - - GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); - - ScreenOptions::AfterChangeRow( pn ); -} - -bool ScreenOptionsManageCourses::MenuSelect( const InputEventPlus &input ) -{ - if( input.type != IET_FIRST_PRESS ) - return false; - SetNextCombination(); - m_soundDifficultyChanged.Play(true); - return true; -} - -static LocalizedString YOU_HAVE_MAX( "ScreenOptionsManageCourses", "You have %d, the maximum number allowed." ); -static LocalizedString YOU_MUST_DELETE( "ScreenOptionsManageCourses", "You must delete an existing before creating a new." ); -void ScreenOptionsManageCourses::ProcessMenuStart( const InputEventPlus & ) -{ - if( IsTransitioning() ) - return; - - int iCurRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - - if( iCurRow == 0 ) // "create new" - { - vector vpCourses; - EditCourseUtil::GetAllEditCourses( vpCourses ); - if( vpCourses.size() >= (size_t)EditCourseUtil::MAX_PER_PROFILE ) - { - RString s = ssprintf( YOU_HAVE_MAX.GetValue()+"\n\n"+YOU_MUST_DELETE.GetValue(), EditCourseUtil::MAX_PER_PROFILE ); - ScreenPrompt::Prompt( SM_None, s ); - return; - } - SCREENMAN->PlayStartSound(); - this->BeginFadingOut(); - } - else if( m_pRows[iCurRow]->GetRowType() == OptionRow::RowType_Exit ) - { - SCREENMAN->PlayStartSound(); - this->BeginFadingOut(); - } - else // a course - { - GAMESTATE->m_pCurCourse.Set( GetCourseWithFocus() ); - EditCourseUtil::UpdateAndSetTrail(); - EditCourseUtil::s_bNewCourseNeedsName = false; - ScreenOptions::BeginFadingOut(); - } -} - -void ScreenOptionsManageCourses::ImportOptions( int iRow, const vector &vpns ) -{ - -} - -void ScreenOptionsManageCourses::ExportOptions( int iRow, const vector &vpns ) -{ - -} - -Course *ScreenOptionsManageCourses::GetCourseWithFocus() const -{ - int iCurRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; - if( iCurRow == 0 ) - return NULL; - else if( m_pRows[iCurRow]->GetRowType() == OptionRow::RowType_Exit ) - return NULL; - - // a course - int index = iCurRow - 1; - return m_vpCourses[index]; -} - -/* - * (c) 2002-2004 Chris Danford - * 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. - */ diff --git a/src/ScreenOptionsManageCourses.h b/src/ScreenOptionsManageCourses.h index 3db071997a..e69de29bb2 100644 --- a/src/ScreenOptionsManageCourses.h +++ b/src/ScreenOptionsManageCourses.h @@ -1,59 +0,0 @@ -#ifndef ScreenOptionsManageCourses_H -#define ScreenOptionsManageCourses_H - -#include "ScreenOptions.h" -#include "GameConstantsAndTypes.h" -#include "RageSound.h" - -class Course; - -class ScreenOptionsManageCourses : public ScreenOptions -{ -public: - void Init(); - virtual void BeginScreen(); - virtual void HandleScreenMessage( const ScreenMessage SM ); - virtual bool MenuSelect( const InputEventPlus &input ); - -protected: - virtual void ImportOptions( int iRow, const vector &vpns ); - virtual void ExportOptions( int iRow, const vector &vpns ); - - virtual void AfterChangeRow( PlayerNumber pn ); - virtual void ProcessMenuStart( const InputEventPlus &input ); - -private: - Course *GetCourseWithFocus() const; - - RageSound m_soundDifficultyChanged; - vector m_vpCourses; - ThemeMetric EDIT_MODE; - ThemeMetric CREATE_NEW_SCREEN; -}; - -#endif - -/* - * (c) 2003-2006 Chris Danford, Steve Checkoway - * 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. - */ diff --git a/src/ScreenOptionsManageEditSteps.cpp b/src/ScreenOptionsManageEditSteps.cpp index b34b3332aa..6c82a93ad4 100644 --- a/src/ScreenOptionsManageEditSteps.cpp +++ b/src/ScreenOptionsManageEditSteps.cpp @@ -60,7 +60,6 @@ void ScreenOptionsManageEditSteps::BeginScreen() // Reload so that we're consistent with the disk in case the user has been dinking around with their edits. SONGMAN->FreeAllLoadedFromProfile( ProfileSlot_Machine ); SONGMAN->LoadStepEditsFromProfileDir( PROFILEMAN->GetProfileDir(ProfileSlot_Machine), ProfileSlot_Machine ); - SONGMAN->LoadCourseEditsFromProfileDir( PROFILEMAN->GetProfileDir(ProfileSlot_Machine), ProfileSlot_Machine ); GAMESTATE->m_pCurSong.Set( NULL ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL ); diff --git a/src/ScreenOptionsManageProfiles.h b/src/ScreenOptionsManageProfiles.h index 5bd6f1b7e4..8d92998b75 100644 --- a/src/ScreenOptionsManageProfiles.h +++ b/src/ScreenOptionsManageProfiles.h @@ -4,7 +4,6 @@ #include "ScreenOptions.h" #include "ScreenMiniMenu.h" -class Course; class ScreenOptionsManageProfiles : public ScreenOptions { diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 2ed8bcc8f7..d68aa08add 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -740,7 +740,6 @@ static void InitializeConfOptions() ADD( ConfOption( "ShowCaution", MovePref, "Skip","Show") ); ADD( ConfOption( "DancePointsForOni", MovePref, "Percent","Dance Points") ); ADD( ConfOption( "MusicWheelUsesSections", MovePref, "Never","Always","Title Only") ); - ADD( ConfOption( "CourseSortOrder", MovePref, "Num Songs","Average Feet","Total Feet","Ranking") ); ADD( ConfOption( "MoveRandomToEnd", MovePref, "No","Yes") ); ADD( ConfOption( "ShowNativeLanguage", MovePref, "Romanization","Native Language") ); ADD( ConfOption( "ShowLyrics", MovePref, "Hide","Show") ); @@ -750,7 +749,6 @@ static void InitializeConfOptions() ADD( ConfOption( "OnlyPreferredDifficulties", MovePref, "Off","On" ) ); g_ConfOptions.back().m_iEffects = OPT_APPLY_SONG; - ADD( ConfOption( "AutogenGroupCourses", MovePref, "Off","On" ) ); ADD( ConfOption( "FastLoad", MovePref, "Off","On" ) ); ADD( ConfOption( "FastLoadAdditionalSongs", MovePref, "Off","On" ) ); { @@ -804,7 +802,6 @@ static void InitializeConfOptions() ADD( ConfOption( "HarshHotLifePenalty", MovePref, "Off", "On") ); ADD( ConfOption( "FailOffForFirstStageEasy", MovePref, "Off","On" ) ); ADD( ConfOption( "FailOffInBeginner", MovePref, "Off","On" ) ); - ADD( ConfOption( "LockCourseDifficulties", MovePref, "Off", "On" ) ); ADD( ConfOption( "PickExtraStage", MovePref, "Off","On" ) ); ADD( ConfOption( "UseUnlockSystem", MovePref, "Off","On" ) ); ADD( ConfOption( "AllowSongDeletion", MovePref, "Off","On" ) ); diff --git a/src/ScreenRanking.cpp b/src/ScreenRanking.cpp index 3b78fbf86d..c84ade7d98 100644 --- a/src/ScreenRanking.cpp +++ b/src/ScreenRanking.cpp @@ -48,7 +48,6 @@ void ScreenRanking::Init() RANKING_TYPE.Load ( m_sName,"RankingType"); - COURSES_TO_SHOW.Load ( m_sName,"CoursesToShow"); SECONDS_PER_PAGE.Load ( m_sName,"SecondsPerPage" ); NO_SCORE_NAME.Load( m_sName,"NoScoreName" ); @@ -88,41 +87,6 @@ void ScreenRanking::Init() } } - if( RANKING_TYPE == RankingType_SpecificTrail ) - { - m_Banner.SetName( "Banner" ); - this->AddChild( &m_Banner ); - LOAD_ALL_COMMANDS( m_Banner ); - - m_textCourseTitle.SetName( "CourseTitle" ); - m_textCourseTitle.LoadFromFont( THEME->GetPathF(m_sName,"course title") ); - //m_textCourseTitle.SetShadowLength( 0 ); - this->AddChild( &m_textCourseTitle ); - LOAD_ALL_COMMANDS( m_textCourseTitle ); - - vector asCoursePaths; - split( COURSES_TO_SHOW, ",", asCoursePaths, true ); - for( unsigned i=0; iGetCourseFromPath( asCoursePaths[c] ); - if( pts.pCourse == NULL ) - continue; - - pts.pTrail = pts.pCourse->GetTrail( st ); - if( pts.pTrail == NULL ) - continue; - - m_vPagesToShow.push_back( pts ); - } - } - } - for( int l=0; lGetPathG( m_sName, ssprintf("bullets 1x%d",NUM_RANKING_LINES) ) ); @@ -197,7 +161,7 @@ void ScreenRanking::HandleScreenMessage( const ScreenMessage SM ) ScreenAttract::HandleScreenMessage( SM ); } -float ScreenRanking::SetPage( const PageToShow &pts ) +float ScreenRanking::SetPage(const PageToShow &pts) { // This is going to take a while to load. Possibly longer than one frame. // So, zero the next update so we don't skip. @@ -205,133 +169,78 @@ float ScreenRanking::SetPage( const PageToShow &pts ) // init page StepsType st = pts.aTypes.front().second; - m_textStepsType.SetText( GAMEMAN->GetStepsTypeInfo(st).GetLocalizedString() ); + m_textStepsType.SetText(GAMEMAN->GetStepsTypeInfo(st).GetLocalizedString()); bool bShowScores = false; bool bShowPoints = false; bool bShowTime = false; - switch( RANKING_TYPE ) + switch (RANKING_TYPE) { - case RankingType_Category: - bShowScores = true; - break; - case RankingType_SpecificTrail: - bShowScores = !pts.pCourse->IsOni(); - bShowPoints = pts.pCourse->IsOni(); - bShowTime = pts.pCourse->IsOni(); - break; - default: break; + case RankingType_Category: + bShowScores = true; + break; + default: break; } - for( int l=0; lGetMachineProfile()->GetCategoryHighScoreList(st, pts.category); + HighScore hs; + bool bRecentHighScore = false; + if (l < (int)hsl.vHighScores.size()) { - // No need to shadow at this point. - st = pts.aTypes.front().second; - HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetCategoryHighScoreList(st, pts.category); - HighScore hs; - bool bRecentHighScore = false; - if( l < (int)hsl.vHighScores.size() ) - { - hs = hsl.vHighScores[l]; - RString *psName = hsl.vHighScores[l].GetNameMutable(); - bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); - } - else - { - hs.SetName( NO_SCORE_NAME ); - } - - m_textNames[l].SetText( hs.GetDisplayName() ); - m_textScores[l].SetText( ssprintf("%09i",hs.GetScore()) ); - m_textNames[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - m_textScores[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - - if( bRecentHighScore ) - { - m_textNames[l].SetEffectGlowBlink(0.1f, RageColor(1,1,1,0.2f), RageColor(1,1,1,0.8f)); - m_textScores[l].SetEffectGlowBlink(0.1f, RageColor(1,1,1,0.2f), RageColor(1,1,1,0.8f)); - } - else - { - m_textNames[l].StopEffect(); - m_textScores[l].StopEffect(); - } + hs = hsl.vHighScores[l]; + RString *psName = hsl.vHighScores[l].GetNameMutable(); + bRecentHighScore = find(GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName) != GAMESTATE->m_vpsNamesThatWereFilled.end(); + } + else + { + hs.SetName(NO_SCORE_NAME); } - } - return SECONDS_PER_PAGE; - case RankingType_SpecificTrail: - { - m_textCourseTitle.SetText( pts.pCourse->GetDisplayFullTitle() ); - m_Banner.LoadFromCourse( pts.pCourse ); + m_textNames[l].SetText(hs.GetDisplayName()); + m_textScores[l].SetText(ssprintf("%09i", hs.GetScore())); + m_textNames[l].SetDiffuseColor(STEPS_TYPE_COLOR.GetValue(pts.colorIndex)); + m_textScores[l].SetDiffuseColor(STEPS_TYPE_COLOR.GetValue(pts.colorIndex)); - const HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList( pts.pCourse, pts.pTrail ); - for( int l=0; lm_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); - } - else - { - hs.SetName( NO_SCORE_NAME ); - } - - m_textNames[l].SetText( hs.GetDisplayName() ); - if( pts.pCourse->IsOni() ) - { - m_textPoints[l].SetText( ssprintf("%04d",hs.GetScore()) ); - m_textTime[l].SetText( SecondsToMMSSMsMs(hs.GetSurviveSeconds()) ); - m_textScores[l].SetText( "" ); - } else { - m_textPoints[l].SetText( "" ); - m_textTime[l].SetText( "" ); - m_textScores[l].SetText( ssprintf("%09d",hs.GetScore()) ); - } - m_textNames[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - m_textPoints[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - m_textTime[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - m_textScores[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - - if( bRecentHighScore ) - { - m_textNames[l].SetEffectGlowBlink(0.1f, RageColor(1,1,1,0.2f), RageColor(1,1,1,0.8f)); - m_textScores[l].SetEffectGlowBlink(0.1f, RageColor(1,1,1,0.2f), RageColor(1,1,1,0.8f)); - } - else - { - m_textNames[l].StopEffect(); - m_textScores[l].StopEffect(); - } + m_textNames[l].SetEffectGlowBlink(0.1f, RageColor(1, 1, 1, 0.2f), RageColor(1, 1, 1, 0.8f)); + m_textScores[l].SetEffectGlowBlink(0.1f, RageColor(1, 1, 1, 0.2f), RageColor(1, 1, 1, 0.8f)); + } + else + { + m_textNames[l].StopEffect(); + m_textScores[l].StopEffect(); } } - return SECONDS_PER_PAGE; + } + return SECONDS_PER_PAGE; + return SECONDS_PER_PAGE; default: FAIL_M(ssprintf("Invalid RankingType: %i", rtype)); } diff --git a/src/ScreenRanking.h b/src/ScreenRanking.h index 628fc410af..4de9a110a5 100644 --- a/src/ScreenRanking.h +++ b/src/ScreenRanking.h @@ -7,8 +7,6 @@ #include "Difficulty.h" #include "CommonMetrics.h" -class Course; -class Trail; typedef pair DifficultyAndStepsType; const int NUM_RANKING_LINES = 5; @@ -35,8 +33,6 @@ class ScreenRanking : public ScreenAttract { PageToShow() { - pCourse = NULL; - pTrail = NULL; } int colorIndex; @@ -44,10 +40,6 @@ class ScreenRanking : public ScreenAttract // RankingPageType_Category RankingCategory category; - - // RankingPageType_SpecificCourses - Course* pCourse; - Trail* pTrail; }; virtual float SetPage( const PageToShow &pts ); diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index f7841e5667..996367a1aa 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -15,7 +15,6 @@ #include "Steps.h" #include "ActorUtil.h" #include "RageTextureManager.h" -#include "Course.h" #include "ProfileManager.h" #include "Profile.h" #include "MenuTimer.h" @@ -986,9 +985,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) { if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) m_soundLocked.Play(true); - else if( !GAMESTATE->IsCourseMode() ) - // Only change sorts in non-course mode - m_MusicWheel.NextSort(); + m_MusicWheel.NextSort(); } else if( !GAMESTATE->IsAnExtraStageAndSelectionLocked() && CodeDetector::DetectAndAdjustMusicOptions(input.GameI.controller) ) { @@ -1082,23 +1079,6 @@ void ScreenSelectMusic::ChangeSteps( PlayerNumber pn, int dir ) Steps *pSteps = m_vpSteps[ m_iSelection[pn] ]; GAMESTATE->ChangePreferredDifficultyAndStepsType( pn, pSteps->GetDifficulty(), pSteps->m_StepsType ); } - else if( GAMESTATE->m_pCurCourse ) - { - m_iSelection[pn] += dir; - if( WRAP_CHANGE_STEPS ) - { - wrap( m_iSelection[pn], m_vpTrails.size() ); - } - else - { - if( CLAMP(m_iSelection[pn],0,m_vpTrails.size()-1) ) - return; - } - - // the user explicity switched difficulties. Update the preferred Difficulty and StepsType - Trail *pTrail = m_vpTrails[ m_iSelection[pn] ]; - GAMESTATE->ChangePreferredCourseDifficultyAndStepsType( pn, pTrail->m_CourseDifficulty, pTrail->m_StepsType ); - } else { // If we're showing multiple StepsTypes in the list, don't allow @@ -1176,13 +1156,6 @@ void ScreenSelectMusic::HandleMessage( const Message &msg ) } m_iSelection[pn] = iSel; - if( GAMESTATE->IsCourseMode() ) - { - Trail* pTrail = m_vpTrails.empty()? NULL: m_vpTrails[m_iSelection[pn]]; - GAMESTATE->m_pCurTrail[pn].Set( pTrail ); - } - else - { Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]]; // handle changing rave difficulty on join @@ -1190,7 +1163,6 @@ void ScreenSelectMusic::HandleMessage( const Message &msg ) pSteps = m_vpSteps[m_iSelection[master_pn]]; GAMESTATE->m_pCurSteps[pn].Set( pSteps ); - } } ScreenWithMenuElements::HandleMessage( msg ); @@ -1210,7 +1182,7 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) m_MenuTimer->SetSeconds( ROULETTE_TIMER_SECONDS ); m_MenuTimer->Start(); } - else if( DO_ROULETTE_ON_MENU_TIMER && m_MusicWheel.GetSelectedSong() == NULL && m_MusicWheel.GetSelectedCourse() == NULL ) + else if( DO_ROULETTE_ON_MENU_TIMER && m_MusicWheel.GetSelectedSong() == NULL ) { m_MusicWheel.StartRoulette(); m_MenuTimer->SetSeconds( ROULETTE_TIMER_SECONDS ); @@ -1221,7 +1193,7 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) // Finish sort changing so that the wheel can respond immediately to // our request to choose random. m_MusicWheel.FinishChangingSorts(); - if( m_MusicWheel.GetSelectedSong() == NULL && m_MusicWheel.GetSelectedCourse() == NULL ) + if( m_MusicWheel.GetSelectedSong() == NULL ) m_MusicWheel.StartRandom(); MenuStart( InputEventPlus() ); @@ -1351,35 +1323,6 @@ bool ScreenSelectMusic::SelectCurrent(PlayerNumber pn) else SOUND->PlayOnceFromAnnouncer("select music comment general"); - /* If we're in event mode, we may have just played a course (putting - * us in course mode). Make sure we're in a single song mode. */ - if (GAMESTATE->IsCourseMode()) - GAMESTATE->m_PlayMode.Set(PLAY_MODE_REGULAR); - } - else if (m_MusicWheel.GetSelectedCourse() != NULL) - { - SOUND->PlayOnceFromAnnouncer("select course comment general"); - - Course *pCourse = m_MusicWheel.GetSelectedCourse(); - ASSERT(pCourse != NULL); - GAMESTATE->m_PlayMode.Set(pCourse->GetPlayMode()); - - // apply #LIVES - if (pCourse->m_iLives != -1) - { - FOREACH_EnabledPlayer(pn) - { - PO_GROUP_ASSIGN(GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Stage, m_LifeType, LifeType_Battery); - PO_GROUP_ASSIGN(GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Stage, m_BatteryLives, pCourse->m_iLives); - } - } - if (pCourse->GetCourseType() == COURSE_TYPE_SURVIVAL) - { - FOREACH_EnabledPlayer(pn) - { - PO_GROUP_ASSIGN(GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Stage, m_LifeType, LifeType_Time); - } - } } else { @@ -1406,87 +1349,6 @@ bool ScreenSelectMusic::SelectCurrent(PlayerNumber pn) if (TWO_PART_CONFIRMS_ONLY) bAllPlayersDoneSelectingSteps = true; - /* TRICKY: if we have a Routine chart selected, we need to ensure - * the following: - * 1. Both players must select the same Routine steps. - * 2. If the other player picks non-Routine steps, this player - * cannot pick Routine. - * 3. If the other player picked Routine steps, and we pick - * non-Routine steps, the other player's steps must be unselected. - * 4. If time runs out, and both players don't have the same Routine - * chart selected, we need to bump the player with a Routine - * chart selection to a playable chart. - * (Right now, we bump them to Beginner... Can we come up with - * something better?) - */ - - if (!GAMESTATE->IsCourseMode() && GAMESTATE->GetNumSidesJoined() == 2) - { - bool bSelectedRoutineSteps[NUM_PLAYERS], bAnySelectedRoutine = false; - bool bSelectedSameSteps = GAMESTATE->m_pCurSteps[PLAYER_1] == GAMESTATE->m_pCurSteps[PLAYER_2]; - - FOREACH_HumanPlayer(p) - { - const Steps *pSteps = GAMESTATE->m_pCurSteps[p]; - const StepsTypeInfo &sti = GAMEMAN->GetStepsTypeInfo(pSteps->m_StepsType); - - bSelectedRoutineSteps[p] = sti.m_StepsTypeCategory == StepsTypeCategory_Routine; - bAnySelectedRoutine |= bSelectedRoutineSteps[p]; - } - - if (bAnySelectedRoutine) - { - /* Timer ran out. If we haven't agreed on steps, move players with - * Routine steps down to Beginner. I'll admit that's annoying, - * but at least they won't lose more stages. */ - if (bInitiatedByMenuTimer && !bSelectedSameSteps) - { - /* Since m_vpSteps is sorted by Difficulty, the first - * entry should be the easiest. */ - ASSERT(m_vpSteps.size() != 0); - Steps *pSteps = m_vpSteps[0]; - - FOREACH_PlayerNumber(p) - { - if (bSelectedRoutineSteps[p]) - GAMESTATE->m_pCurSteps[p].Set(pSteps); - } - - break; - } - - // If the steps don't match up, we need to check some more conditions... - if (!bSelectedSameSteps) - { - const PlayerNumber other = OPPOSITE_PLAYER[pn]; - - if (m_bStepsChosen[other]) - { - /* Unready the other player if they selected Routine - * steps, but we didn't. */ - if (bSelectedRoutineSteps[other]) - { - m_bStepsChosen[other] = false; - bAllPlayersDoneSelectingSteps = false; // if the timer ran out, we handled it earlier - - // HACK: send an event to Input to tell it to unready. - InputEventPlus event; - event.MenuI = GAME_BUTTON_SELECT; - event.pn = other; - - this->Input(event); - } - else if (bSelectedRoutineSteps[pn]) - { - /* They selected non-Routine steps, so we can't - * select Routine steps. */ - return false; - } - } - } - } - } - if (!bAllPlayersDoneSelectingSteps) { m_bStepsChosen[pn] = true; @@ -1643,7 +1505,6 @@ void ScreenSelectMusic::AfterStepsOrTrailChange( const vector &vpn Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]]; GAMESTATE->m_pCurSteps[pn].Set( pSteps ); - GAMESTATE->m_pCurTrail[pn].Set( NULL ); int iScore = 0; if( pSteps ) @@ -1654,25 +1515,6 @@ void ScreenSelectMusic::AfterStepsOrTrailChange( const vector &vpn m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); } - else if( GAMESTATE->m_pCurCourse ) - { - CLAMP( m_iSelection[pn], 0, m_vpTrails.size()-1 ); - - Course* pCourse = GAMESTATE->m_pCurCourse; - Trail* pTrail = m_vpTrails.empty()? NULL: m_vpTrails[m_iSelection[pn]]; - - GAMESTATE->m_pCurSteps[pn].Set( NULL ); - GAMESTATE->m_pCurTrail[pn].Set( pTrail ); - - int iScore = 0; - if( pTrail ) - { - const Profile *pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); - iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().GetScore(); - } - - m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); - } else { // The numbers shouldn't stay if the current selection is NULL. @@ -1683,8 +1525,7 @@ void ScreenSelectMusic::AfterStepsOrTrailChange( const vector &vpn void ScreenSelectMusic::SwitchToPreferredDifficulty() { - if( !GAMESTATE->m_pCurCourse ) - { + FOREACH_HumanPlayer( pn ) { // Find the closest match to the user's preferred difficulty and StepsType. @@ -1719,42 +1560,7 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty() CLAMP( iSelection, 0, m_vpSteps.size()-1 ); } - } - else - { - FOREACH_HumanPlayer( pn ) - { - // Find the closest match to the user's preferred difficulty. - int iCurDifference = -1; - int &iSelection = m_iSelection[pn]; - FOREACH_CONST( Trail*, m_vpTrails, t ) - { - int i = t - m_vpTrails.begin(); - - // If the current trail is listed, use it. - if( GAMESTATE->m_pCurTrail[pn] == m_vpTrails[i] ) - { - iSelection = i; - break; - } - - if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid ) - { - int iDifficultyDifference = abs( (*t)->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] ); - int iStepsTypeDifference = abs( (*t)->m_StepsType - GAMESTATE->m_PreferredStepsType ); - int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference; - - if( iCurDifference == -1 || iTotalDifference < iCurDifference ) - { - iSelection = i; - iCurDifference = iTotalDifference; - } - } - } - CLAMP( iSelection, 0, m_vpTrails.size()-1 ); - } - } if( GAMESTATE->DifficultiesLocked() ) { @@ -1773,11 +1579,6 @@ void ScreenSelectMusic::AfterMusicChange() if( pSong ) GAMESTATE->m_pPreferredSong = pSong; - Course* pCourse = m_MusicWheel.GetSelectedCourse(); - GAMESTATE->m_pCurCourse.Set( pCourse ); - if( pCourse ) - GAMESTATE->m_pPreferredCourse = pCourse; - m_vpSteps.clear(); m_vpTrails.clear(); @@ -1938,40 +1739,6 @@ void ScreenSelectMusic::AfterMusicChange() SwitchToPreferredDifficulty(); break; - - case WheelItemDataType_Course: - { - const Course *lCourse = m_MusicWheel.GetSelectedCourse(); - const Style *pStyle = NULL; - if(CommonMetrics::AUTO_SET_STYLE) - { - pStyle = pCourse->GetCourseStyle(GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled()); - if(pStyle == NULL) - { - lCourse->GetAllTrails(m_vpTrails); - } - else - { - lCourse->GetTrails(m_vpTrails, pStyle->m_StepsType); - } - } - else - { - pStyle = GAMESTATE->GetCurrentStyle(PLAYER_INVALID); - lCourse->GetTrails(m_vpTrails, pStyle->m_StepsType); - } - - m_sSampleMusicToPlay = m_sCourseMusicPath; - m_fSampleStartSeconds = 0; - m_fSampleLengthSeconds = -1; - - g_sBannerPath = lCourse->GetBannerPath(); - if( g_sBannerPath.empty() ) - m_Banner.LoadFallback(); - - SwitchToPreferredDifficulty(); - break; - } default: FAIL_M(ssprintf("Invalid WheelItemDataType: %i", wtype)); } diff --git a/src/ScreenSelectMusic.h b/src/ScreenSelectMusic.h index 8614e669d0..b365e9010f 100644 --- a/src/ScreenSelectMusic.h +++ b/src/ScreenSelectMusic.h @@ -72,7 +72,6 @@ class ScreenSelectMusic : public ScreenWithMenuElements bool DetectCodes( const InputEventPlus &input ); vector m_vpSteps; - vector m_vpTrails; int m_iSelection[NUM_PLAYERS]; RageTimer m_timerIdleComment; diff --git a/src/ScreenServiceAction.cpp b/src/ScreenServiceAction.cpp index 71bc884c04..0e311ccba9 100644 --- a/src/ScreenServiceAction.cpp +++ b/src/ScreenServiceAction.cpp @@ -42,7 +42,6 @@ static RString ClearMachineEdits() vector vsEditFiles; GetDirListing( PROFILEMAN->GetProfileDir(ProfileSlot_Machine)+EDIT_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true ); - GetDirListing( PROFILEMAN->GetProfileDir(ProfileSlot_Machine)+EDIT_COURSES_SUBDIR+"*.crs", vsEditFiles, false, true ); FOREACH_CONST( RString, vsEditFiles, i ) { iNumAttempted++; @@ -91,7 +90,6 @@ static RString ClearMemoryCardEdits() RString sDir = MEM_CARD_MOUNT_POINT[pn] + (RString)PREFSMAN->m_sMemoryCardProfileSubdir + "/"; vector vsEditFiles; GetDirListing( sDir+EDIT_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true ); - GetDirListing( sDir+EDIT_COURSES_SUBDIR+"*.crs", vsEditFiles, false, true ); FOREACH_CONST( RString, vsEditFiles, i ) { iNumAttempted++; @@ -205,26 +203,6 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile } } } - - // TODO: Seprarate copying stats for steps and courses - - { - RString sFromDir = sFromProfileDir + EDIT_COURSES_SUBDIR; - RString sToDir = sToProfileDir + EDIT_COURSES_SUBDIR; - - vector vsFiles; - GetDirListing( sFromDir+"*.crs", vsFiles, false, false ); - FOREACH_CONST( RString, vsFiles, i ) - { - if( DoesFileExist(sToDir+*i) ) - iNumOverwritten++; - bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i ); - if( bSuccess ) - iNumSucceeded++; - else - iNumErrored++; - } - } } static LocalizedString EDITS_NOT_COPIED ( "ScreenServiceAction", "Edits not copied - No memory cards ready." ); @@ -305,7 +283,6 @@ static void SyncEdits( const RString &sFromDir, const RString &sToDir, int &iNum iNumFailed = 0; SyncFiles( sFromDir + EDIT_STEPS_SUBDIR, sToDir + EDIT_STEPS_SUBDIR, "*.edit", iNumAdded, iNumDeleted, iNumOverwritten, iNumFailed ); - SyncFiles( sFromDir + EDIT_COURSES_SUBDIR, sToDir + EDIT_COURSES_SUBDIR, "*.crs", iNumAdded, iNumDeleted, iNumOverwritten, iNumFailed ); } static RString CopyEditsMachineToMemoryCard() diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index e07adef8cd..c6167be63e 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -87,7 +87,7 @@ void ScreenSyncOverlay::UpdateText() FAIL_M(ssprintf("Invalid autosync type: %i", type)); } - if( GAMESTATE->m_pCurSong != NULL && !GAMESTATE->IsCourseMode() && pc == 0) // sync controls available (don't turn on for autoplay) - Mina. + if( GAMESTATE->m_pCurSong != NULL && pc == 0) // sync controls available (don't turn on for autoplay) - Mina. { AdjustSync::GetSyncChangeTextGlobal( vs ); AdjustSync::GetSyncChangeTextSong( vs ); @@ -160,7 +160,7 @@ bool ScreenSyncOverlay::Input( const InputEventPlus &input ) return Screen::Input(input); } - if( GAMESTATE->IsCourseMode() && a != ChangeGlobalOffset ) + if( a != ChangeGlobalOffset ) { SCREENMAN->SystemMessage( CANT_SYNC_WHILE_PLAYING_A_COURSE ); return true; diff --git a/src/ScreenUnlockStatus.cpp b/src/ScreenUnlockStatus.cpp index 0aa9e6a776..c05e0242a7 100644 --- a/src/ScreenUnlockStatus.cpp +++ b/src/ScreenUnlockStatus.cpp @@ -8,7 +8,6 @@ #include "SongManager.h" #include "ActorUtil.h" #include "Song.h" -#include "Course.h" #define UNLOCK_TEXT_SCROLL_X THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollX"); #define UNLOCK_TEXT_SCROLL_START_Y THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollStartY") @@ -115,16 +114,6 @@ void ScreenUnlockStatus::Init() text->SetText( title ); } break; - case UnlockRewardType_Course: - { - const Course *pCourse = entry.m_Course.ToCourse(); - ASSERT( pCourse != NULL ); - - text->SetMaxWidth( MaxWidth ); - text->SetText( pCourse->GetDisplayFullTitle() ); - text->SetDiffuse( RageColor(0,1,0,1) ); - } - break; default: text->SetText( "" ); text->SetDiffuse( RageColor(0.5f,0,0,1) ); diff --git a/src/ScreenUnlockStatus.h b/src/ScreenUnlockStatus.h index 4a41aab64b..933237adb1 100644 --- a/src/ScreenUnlockStatus.h +++ b/src/ScreenUnlockStatus.h @@ -5,8 +5,6 @@ #include "Sprite.h" #include "BitmapText.h" -class Course; - class ScreenUnlockStatus : public ScreenAttract { public: diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 70680d9d5c..3ab9826a69 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -6,9 +6,6 @@ #include "BackgroundUtil.h" #include "BannerCache.h" #include "CommonMetrics.h" -#include "Course.h" -#include "CourseLoaderCRS.h" -#include "CourseUtil.h" #include "Foreach.h" #include "GameManager.h" #include "GameState.h" @@ -41,7 +38,6 @@ SongManager* SONGMAN = NULL; // global and accessible from anywhere in our program const RString ADDITIONAL_SONGS_DIR = "/AdditionalSongs/"; -const RString ADDITIONAL_COURSES_DIR = "/AdditionalCourses/"; const RString EDIT_SUBDIR = "Edits/"; /** @brief The file that contains various random attacks. */ @@ -56,10 +52,8 @@ static const ThemeMetric MOVE_UNLOCKS_TO_BOTTOM_OF_PREFERRED_SORT ( "Song static const ThemeMetric EXTRA_STAGE2_DIFFICULTY_MAX ( "SongManager", "ExtraStage2DifficultyMax" ); static Preference g_sDisabledSongs( "DisabledSongs", "" ); -static Preference g_bHideIncompleteCourses( "HideIncompleteCourses", false ); RString SONG_GROUP_COLOR_NAME( size_t i ) { return ssprintf( "SongGroupColor%i", (int) i+1 ); } -RString COURSE_GROUP_COLOR_NAME( size_t i ) { return ssprintf( "CourseGroupColor%i", (int) i+1 ); } static const float next_loading_window_update= 0.02f; @@ -76,8 +70,6 @@ SongManager::SongManager() NUM_SONG_GROUP_COLORS .Load( "SongManager", "NumSongGroupColors" ); SONG_GROUP_COLOR .Load( "SongManager", SONG_GROUP_COLOR_NAME, NUM_SONG_GROUP_COLORS ); - NUM_COURSE_GROUP_COLORS .Load( "SongManager", "NumCourseGroupColors" ); - COURSE_GROUP_COLOR .Load( "SongManager", COURSE_GROUP_COLOR_NAME, NUM_COURSE_GROUP_COLORS ); } SongManager::~SongManager() @@ -87,7 +79,6 @@ SongManager::~SongManager() // Courses depend on Songs and Songs don't depend on Courses. // So, delete the Courses first. - FreeCourses(); FreeSongs(); } @@ -101,22 +92,17 @@ void SongManager::InitAll( LoadingWindow *ld ) m_GroupsToNeverCache.insert(*group); } InitSongsFromDisk( ld ); - InitCoursesFromDisk( ld ); - InitAutogenCourses(); InitRandomAttacks(); } static LocalizedString RELOADING ( "SongManager", "Reloading..." ); static LocalizedString UNLOADING_SONGS ( "SongManager", "Unloading songs..." ); -static LocalizedString UNLOADING_COURSES ( "SongManager", "Unloading courses..." ); static LocalizedString SANITY_CHECKING_GROUPS("SongManager", "Sanity checking groups..."); void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) { FILEMAN->FlushDirCache( SpecialFiles::SONGS_DIR ); FILEMAN->FlushDirCache( ADDITIONAL_SONGS_DIR ); - FILEMAN->FlushDirCache( SpecialFiles::COURSES_DIR ); - FILEMAN->FlushDirCache( ADDITIONAL_COURSES_DIR ); FILEMAN->FlushDirCache( EDIT_SUBDIR ); if( ld ) @@ -125,11 +111,6 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) // save scores before unloading songs, or the scores will be lost PROFILEMAN->SaveMachineProfile(); - if( ld ) - ld->SetText( UNLOADING_COURSES ); - - FreeCourses(); - if( ld ) ld->SetText( UNLOADING_SONGS ); @@ -552,18 +533,6 @@ void SongManager::PreloadSongImages() const RageTextureID ID = Sprite::SongBannerTexture( songs[i]->GetBannerPath() ); preload.Load( ID ); } - - vector courses; - GetAllCourses( courses, false ); - for( unsigned i = 0; i < courses.size(); ++i ) - { - if( !courses[i]->HasBanner() ) - continue; - - const RageTextureID ID = Sprite::SongBannerTexture( courses[i]->GetBannerPath() ); - preload.Load( ID ); - } - preload.Swap( m_TexturePreload ); } @@ -745,87 +714,14 @@ RageColor SongManager::GetSongColor( const Song* pSong ) const } } -RString SongManager::GetCourseGroupBannerPath( const RString &sCourseGroup ) const -{ - map::const_iterator iter = m_mapCourseGroupToInfo.find( sCourseGroup ); - if( iter == m_mapCourseGroupToInfo.end() ) - { - ASSERT_M( 0, ssprintf("requested banner for course group '%s' that doesn't exist",sCourseGroup.c_str()) ); - return RString(); - } - else - { - return iter->second.m_sBannerPath; - } -} - -void SongManager::GetCourseGroupNames( vector &AddTo ) const -{ - FOREACHM_CONST( RString, CourseGroupInfo, m_mapCourseGroupToInfo, iter ) - AddTo.push_back( iter->first ); -} - -bool SongManager::DoesCourseGroupExist( const RString &sCourseGroup ) const -{ - return m_mapCourseGroupToInfo.find( sCourseGroup ) != m_mapCourseGroupToInfo.end(); -} - -RageColor SongManager::GetCourseGroupColor( const RString &sCourseGroup ) const -{ - int iIndex = 0; - FOREACHM_CONST( RString, CourseGroupInfo, m_mapCourseGroupToInfo, iter ) - { - if( iter->first == sCourseGroup ) - return SONG_GROUP_COLOR.GetValue( iIndex%NUM_SONG_GROUP_COLORS ); - iIndex++; - } - - ASSERT_M( 0, ssprintf("requested color for course group '%s' that doesn't exist",sCourseGroup.c_str()) ); - return RageColor(1,1,1,1); -} - -RageColor SongManager::GetCourseColor( const Course* pCourse ) const -{ - // Use unlock color if applicable - if( USE_UNLOCK_COLOR.GetValue() && UNLOCKMAN->FindCourse(pCourse) ) - return UNLOCK_COLOR.GetValue(); - - if( USE_PREFERRED_SORT_COLOR ) - { - FOREACH_CONST( CoursePointerVector, m_vPreferredCourseSort, v ) - { - FOREACH_CONST( Course*, *v, s ) - { - if( *s == pCourse ) - { - int i = v - m_vPreferredCourseSort.begin(); - CHECKPOINT_M( ssprintf( "%i, NUM_COURSE_GROUP_COLORS = %i", i, NUM_COURSE_GROUP_COLORS.GetValue()) ); - return COURSE_GROUP_COLOR.GetValue( i % NUM_COURSE_GROUP_COLORS ); - } - } - } - - int i = m_vPreferredCourseSort.size(); - CHECKPOINT_M( ssprintf( "%i, NUM_COURSE_GROUP_COLORS = %i", i, NUM_COURSE_GROUP_COLORS.GetValue()) ); - return COURSE_GROUP_COLOR.GetValue( i % NUM_COURSE_GROUP_COLORS ); - } - else - { - return GetCourseGroupColor( pCourse->m_sGroupName ); - } -} - void SongManager::ResetGroupColors() { // Reload song/course group colors to prevent a crash when switching // themes in-game. (apparently not, though.) -aj SONG_GROUP_COLOR.Clear(); - COURSE_GROUP_COLOR.Clear(); NUM_SONG_GROUP_COLORS .Load( "SongManager", "NumSongGroupColors" ); SONG_GROUP_COLOR .Load( "SongManager", SONG_GROUP_COLOR_NAME, NUM_SONG_GROUP_COLORS ); - NUM_COURSE_GROUP_COLORS .Load( "SongManager", "NumCourseGroupColors" ); - COURSE_GROUP_COLOR .Load( "SongManager", COURSE_GROUP_COLOR_NAME, NUM_COURSE_GROUP_COLORS ); } const vector &SongManager::GetSongs( const RString &sGroupName ) const @@ -872,25 +768,6 @@ RString SongManager::SongToPreferredSortSectionName( const Song *pSong ) const return RString(); } -void SongManager::GetPreferredSortCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ) const -{ - if( m_vPreferredCourseSort.empty() ) - { - GetCourses( ct, AddTo, bIncludeAutogen ); - return; - } - - FOREACH_CONST( CoursePointerVector, m_vPreferredCourseSort, v ) - { - FOREACH_CONST( Course*, *v, c ) - { - Course *pCourse = *c; - if( pCourse->GetCourseType() == ct ) - AddTo.push_back( pCourse ); - } - } -} - int SongManager::GetNumSongs() const { return m_pSongs.size(); @@ -950,27 +827,6 @@ int SongManager::GetNumSongGroups() const return m_sSongGroupNames.size(); } -int SongManager::GetNumCourses() const -{ - return m_pCourses.size(); -} - -int SongManager::GetNumAdditionalCourses() const -{ - int iNum = 0; - FOREACH_CONST( Course*, m_pCourses, i ) - { - if( WasLoadedFromAdditionalCourses( *i ) ) - ++iNum; - } - return iNum; -} - -int SongManager::GetNumCourseGroups() const -{ - return m_mapCourseGroupToInfo.size(); -} - RString SongManager::ShortenGroupName( const RString &sLongGroupName ) { static TitleSubst tsub("Groups"); @@ -981,160 +837,6 @@ RString SongManager::ShortenGroupName( const RString &sLongGroupName ) return title.Title; } -static LocalizedString LOADING_COURSES ( "SongManager", "Loading courses..." ); -void SongManager::InitCoursesFromDisk( LoadingWindow *ld ) -{ - LOG->Trace( "Loading courses." ); - RageTimer loading_window_last_update_time; - loading_window_last_update_time.Touch(); - - vector vsCourseDirs; - vsCourseDirs.push_back( SpecialFiles::COURSES_DIR ); - vsCourseDirs.push_back( ADDITIONAL_COURSES_DIR ); - - vector vsCourseGroupNames; - FOREACH_CONST( RString, vsCourseDirs, sDir ) - { - // Find all group directories in Courses dir - GetDirListing( *sDir + "*", vsCourseGroupNames, true, true ); - StripCvsAndSvn( vsCourseGroupNames ); - StripMacResourceForks( vsCourseGroupNames ); - } - - // Search for courses both in COURSES_DIR and in subdirectories - vsCourseGroupNames.push_back( SpecialFiles::COURSES_DIR ); - SortRStringArray( vsCourseGroupNames ); - - int courseIndex = 0; - FOREACH_CONST( RString, vsCourseGroupNames, sCourseGroup ) // for each dir in /Courses/ - { - // Find all CRS files in this group directory - vector vsCoursePaths; - GetDirListing( *sCourseGroup + "/*.crs", vsCoursePaths, false, true ); - SortRStringArray( vsCoursePaths ); - - if( ld ) - { - ld->SetIndeterminate( false ); - ld->SetTotalWork( vsCoursePaths.size() ); - } - - RString base_course_group= Basename(*sCourseGroup); - FOREACH_CONST( RString, vsCoursePaths, sCoursePath ) - { - if(ld && loading_window_last_update_time.Ago() > next_loading_window_update) - { - loading_window_last_update_time.Touch(); - ld->SetProgress(courseIndex); - ld->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s", - base_course_group.c_str(), - Basename(*sCoursePath).c_str())); - } - - Course* pCourse = new Course; - CourseLoaderCRS::LoadFromCRSFile( *sCoursePath, *pCourse ); - - if( g_bHideIncompleteCourses.Get() && pCourse->m_bIncomplete ) - { - delete pCourse; - continue; - } - - m_pCourses.push_back( pCourse ); - courseIndex++; - } - } - - if( ld ) { - ld->SetIndeterminate( true ); - } - - RefreshCourseGroupInfo(); -} - -void SongManager::InitAutogenCourses() -{ - if ( PREFSMAN->m_bAutogenGroupCourses ) - { - // Create group courses for Endless and Nonstop - vector saGroupNames; - this->GetSongGroupNames(saGroupNames); - Course* pCourse; - for (unsigned g = 0; gm_sScripter = "Autogen"; - m_pCourses.push_back(pCourse); - - pCourse = new Course; - CourseUtil::AutogenNonstopFromGroup(sGroupName, Difficulty_Medium, *pCourse); - pCourse->m_sScripter = "Autogen"; - m_pCourses.push_back(pCourse); - } - - vector apCourseSongs = GetAllSongs(); - - // Generate "All Songs" endless course. - pCourse = new Course; - CourseUtil::AutogenEndlessFromGroup("", Difficulty_Medium, *pCourse); - pCourse->m_sScripter = "Autogen"; - m_pCourses.push_back(pCourse); - - /* Generate Oni courses from artists. Only create courses if we have at least - * four songs from an artist; create 3- and 4-song courses. */ - { - /* We normally sort by translit artist. However, display artist is more - * consistent. For example, transliterated Japanese names are alternately - * spelled given- and family-name first, but display titles are more consistent. */ - vector apSongs = this->GetAllSongs(); - SongUtil::SortSongPointerArrayByDisplayArtist(apSongs); - - RString sCurArtist = ""; - RString sCurArtistTranslit = ""; - int iCurArtistCount = 0; - - vector aSongs; - unsigned i = 0; - do { - RString sArtist = i >= apSongs.size() ? RString("") : apSongs[i]->GetDisplayArtist(); - RString sTranslitArtist = i >= apSongs.size() ? RString("") : apSongs[i]->GetTranslitArtist(); - if (i < apSongs.size() && !sCurArtist.CompareNoCase(sArtist)) - { - aSongs.push_back(apSongs[i]); - ++iCurArtistCount; - continue; - } - - /* Different artist, or we're at the end. If we have enough entries for - * the last artist, add it. Skip blanks and "Unknown artist". */ - if (iCurArtistCount >= 3 && sCurArtistTranslit != "" && - sCurArtistTranslit.CompareNoCase("Unknown artist") && - sCurArtist.CompareNoCase("Unknown artist")) - { - pCourse = new Course; - CourseUtil::AutogenOniFromArtist(sCurArtist, sCurArtistTranslit, aSongs, Difficulty_Hard, *pCourse); - pCourse->m_sScripter = "Autogen"; - m_pCourses.push_back(pCourse); - } - - aSongs.clear(); - - if (i < apSongs.size()) - { - sCurArtist = sArtist; - sCurArtistTranslit = sTranslitArtist; - iCurArtistCount = 1; - aSongs.push_back(apSongs[i]); - } - } while (i++ < apSongs.size()); - } - } -} - void SongManager::InitRandomAttacks() { GAMESTATE->m_RandomAttacks.clear(); @@ -1174,67 +876,6 @@ void SongManager::InitRandomAttacks() } } -void SongManager::FreeCourses() -{ - for( unsigned i=0; i vNewCourses; - for( vector::iterator it = m_pCourses.begin(); it != m_pCourses.end(); ++it ) - { - if( (*it)->m_bIsAutogen ) - { - delete *it; - } - else - { - vNewCourses.push_back( *it ); - } - } - m_pCourses.swap( vNewCourses ); - UpdatePopular(); - UpdateShuffled(); - RefreshCourseGroupInfo(); -} - -void SongManager::AddCourse( Course *pCourse ) -{ - m_pCourses.push_back( pCourse ); - UpdatePopular(); - UpdateShuffled(); - m_mapCourseGroupToInfo[ pCourse->m_sGroupName ]; // insert -} - -void SongManager::DeleteCourse( Course *pCourse ) -{ - vector::iterator iter = find( m_pCourses.begin(), m_pCourses.end(), pCourse ); - ASSERT( iter != m_pCourses.end() ); - m_pCourses.erase( iter ); - UpdatePopular(); - UpdateShuffled(); - RefreshCourseGroupInfo(); -} - -void SongManager::InvalidateCachedTrails() -{ - FOREACH_CONST( Course *, m_pCourses, pCourse ) - { - const Course &c = **pCourse; - - if( c.IsAnEdit() ) - c.m_TrailCache.clear(); - } -} /* Called periodically to wipe out cached NoteData. This is called when we * change screens. */ @@ -1261,26 +902,8 @@ void SongManager::Cleanup() * Courses and Songs is in Edit Mode, which updates the other pointers it needs. */ void SongManager::Invalidate( const Song *pStaleSong ) { - // TODO: This is unnecessarily expensive. - // Can we regenerate only the autogen courses that are affected? - DeleteAutogenCourses(); - - FOREACH( Course*, this->m_pCourses, pCourse ) - { - (*pCourse)->Invalidate( pStaleSong ); - } - - InitAutogenCourses(); - UpdatePopular(); UpdateShuffled(); - RefreshCourseGroupInfo(); -} - -void SongManager::RegenerateNonFixedCourses() -{ - for( unsigned i=0; i < m_pCourses.size(); i++ ) - m_pCourses[i]->RegenerateNonFixedTrails(); } void SongManager::SetPreferences() @@ -1346,61 +969,6 @@ bool SongManager::WasLoadedFromAdditionalSongs( const Song *pSong ) const return BeginsWith( sDir, ADDITIONAL_SONGS_DIR ); } -bool SongManager::WasLoadedFromAdditionalCourses( const Course *pCourse ) const -{ - RString sDir = pCourse->m_sPath; - return BeginsWith( sDir, ADDITIONAL_COURSES_DIR ); -} - -void SongManager::GetAllCourses( vector &AddTo, bool bIncludeAutogen ) const -{ - for( unsigned i=0; im_bIsAutogen ) - AddTo.push_back( m_pCourses[i] ); -} - -void SongManager::GetCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ) const -{ - for( unsigned i=0; iGetCourseType() == ct ) - if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) - AddTo.push_back( m_pCourses[i] ); -} - -void SongManager::GetCoursesInGroup( vector &AddTo, const RString &sCourseGroup, bool bIncludeAutogen ) const -{ - for( unsigned i=0; im_sGroupName == sCourseGroup ) - if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) - AddTo.push_back( m_pCourses[i] ); -} - -bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, const RString &sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut, StepsType stype ) -{ - const RString sCourseSuffix = sPreferredGroup + (bExtra2 ? "/extra2.crs" : "/extra1.crs"); - RString sCoursePath = SpecialFiles::SONGS_DIR + sCourseSuffix; - - // Couldn't find course in DWI path or alternative song folders - if( !DoesFileExist(sCoursePath) ) - { - sCoursePath = ADDITIONAL_SONGS_DIR + sCourseSuffix; - if( !DoesFileExist(sCoursePath) ) - return false; - } - - Course course; - CourseLoaderCRS::LoadFromCRSFile( sCoursePath, course ); - if( course.GetEstimatedNumStages() <= 0 ) return false; - - Trail *pTrail = course.GetTrail(stype); - if( pTrail->m_vEntries.empty() ) - return false; - - pSongOut = pTrail->m_vEntries[0].pSong; - pStepsOut = pTrail->m_vEntries[0].pSteps; - return true; -} - // Return true if n1 < n2. bool CompareNotesPointersForExtra(const Steps *n1, const Steps *n2) { @@ -1438,14 +1006,6 @@ void SongManager::GetExtraStageInfo( bool bExtra2, const Style *sd, Song*& pSong GAMESTATE->m_pCurSong? GAMESTATE->m_pCurSong->GetSongDir().c_str():"", GAMESTATE->m_pCurSong? GAMESTATE->m_pCurSong->m_sGroupName.c_str():"") ); - // Check preferred group - if( GetExtraStageInfoFromCourse(bExtra2, sGroup, pSongOut, pStepsOut, sd->m_StepsType) ) - return; - - // Optionally, check the Songs folder for extra1/2.crs files. - if( GetExtraStageInfoFromCourse(bExtra2, "", pSongOut, pStepsOut, sd->m_StepsType) ) - return; - // Choose a hard song for the extra stage Song* pExtra1Song = NULL; // the absolute hardest Song and Steps. Use this for extra stage 1. Steps* pExtra1Notes = NULL; @@ -1517,29 +1077,6 @@ Song* SongManager::GetRandomSong() return NULL; } -Course* SongManager::GetRandomCourse() -{ - if( m_pShuffledCourses.empty() ) - return NULL; - - static int i = 0; - - for( int iThrowAway=0; iThrowAway<100; iThrowAway++ ) - { - i++; - wrap( i, m_pShuffledCourses.size() ); - Course *pCourse = m_pShuffledCourses[ i ]; - if( pCourse->m_bIsAutogen && !PREFSMAN->m_bAutogenGroupCourses ) - continue; - if( pCourse->GetCourseType() == COURSE_TYPE_ENDLESS ) - continue; - if( UNLOCKMAN->CourseIsLocked(pCourse) ) - continue; - return pCourse; - } - - return NULL; -} Song* SongManager::GetSongFromDir(RString dir) const { @@ -1556,33 +1093,6 @@ Song* SongManager::GetSongFromDir(RString dir) const return NULL; } -Course* SongManager::GetCourseFromPath( const RString &sPath ) const -{ - if( sPath == "" ) - return NULL; - - FOREACH_CONST( Course*, m_pCourses, c ) - { - if( sPath.CompareNoCase((*c)->m_sPath) == 0 ) - return *c; - } - - return NULL; -} - -Course* SongManager::GetCourseFromName( const RString &sName ) const -{ - if( sName == "" ) - return NULL; - - for( unsigned int i=0; iGetDisplayFullTitle()) == 0 ) - return m_pCourses[i]; - - return NULL; -} - - /* GetSongDir() contains a path to the song, possibly a full path, eg: * Songs\Group\SongName or * My Other Song Folder\Group\SongName or @@ -1623,31 +1133,6 @@ Song *SongManager::FindSong( RString sGroup, RString sSong ) const return NULL; } -Course *SongManager::FindCourse( RString sPath ) const -{ - sPath.Replace( '\\', '/' ); - vector bits; - split( sPath, "/", bits ); - - if( bits.size() == 1 ) - return FindCourse( "", bits[0] ); - else if( bits.size() == 2 ) - return FindCourse( bits[0], bits[1] ); - - return NULL; -} - -Course *SongManager::FindCourse( RString sGroup, RString sName ) const -{ - FOREACH_CONST( Course*, m_pCourses, c ) - { - if( (*c)->Matches(sGroup, sName) ) - return *c; - } - - return NULL; -} - void SongManager::UpdatePopular() { // update players best @@ -1668,23 +1153,6 @@ void SongManager::UpdatePopular() } SongUtil::SortSongPointerArrayByTitle( apBestSongs ); - - vector apBestCourses[NUM_CourseType]; - FOREACH_ENUM( CourseType, ct ) - { - GetCourses( ct, apBestCourses[ct], PREFSMAN->m_bAutogenGroupCourses ); - CourseUtil::SortCoursePointerArrayByTitle( apBestCourses[ct] ); - } - - m_pPopularSongs = apBestSongs; - SongUtil::SortSongPointerArrayByNumPlays( m_pPopularSongs, ProfileSlot_Machine, true ); - - FOREACH_CourseType( ct ) - { - vector &vpCourses = m_pPopularCourses[ct]; - vpCourses = apBestCourses[ct]; - CourseUtil::SortCoursePointerArrayByNumPlays( vpCourses, ProfileSlot_Machine, true ); - } } void SongManager::UpdateShuffled() @@ -1692,9 +1160,6 @@ void SongManager::UpdateShuffled() // update shuffled m_pShuffledSongs = m_pSongs; std::shuffle( m_pShuffledSongs.begin(), m_pShuffledSongs.end(), g_RandomNumberGenerator ); - - m_pShuffledCourses = m_pCourses; - std::shuffle( m_pShuffledCourses.begin(), m_pShuffledCourses.end(), g_RandomNumberGenerator ); } void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RString &sPreferredCourses) @@ -1804,80 +1269,6 @@ void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RStr FOREACH( Song*, i->vpSongs, j ) ASSERT( *j != NULL ); } - - { - m_vPreferredCourseSort.clear(); - - vector asLines; - RString sFile = THEME->GetPathO( "SongManager", sPreferredCourses ); - if( !GetFileContents(sFile, asLines) ) - return; - - vector vpCourses; - - FOREACH( RString, asLines, s ) - { - RString sLine = *s; - bool bSectionDivider = BeginsWith( sLine, "---" ); - if( bSectionDivider ) - { - if( !vpCourses.empty() ) - { - m_vPreferredCourseSort.push_back( vpCourses ); - vpCourses.clear(); - } - continue; - } - - Course *pCourse = FindCourse( sLine ); - if( pCourse == NULL ) - continue; - if( UNLOCKMAN->CourseIsLocked(pCourse) & LOCKED_SELECTABLE ) - continue; - vpCourses.push_back( pCourse ); - } - - if( !vpCourses.empty() ) - { - m_vPreferredCourseSort.push_back( vpCourses ); - vpCourses.clear(); - } - - if( MOVE_UNLOCKS_TO_BOTTOM_OF_PREFERRED_SORT.GetValue() ) - { - // move all unlock Courses to a group at the bottom - vector vpUnlockCourses; - FOREACH( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) - { - if( ue->m_Type == UnlockRewardType_Course ) - if( ue->m_Course.IsValid() ) - vpUnlockCourses.push_back( ue->m_Course.ToCourse() ); - } - - FOREACH( CoursePointerVector, m_vPreferredCourseSort, v ) - { - for( int i=v->size()-1; i>=0; i-- ) - { - Course *pCourse = (*v)[i]; - if( find(vpUnlockCourses.begin(),vpUnlockCourses.end(),pCourse) != vpUnlockCourses.end() ) - { - v->erase( v->begin()+i ); - } - } - } - - m_vPreferredCourseSort.push_back( vpUnlockCourses ); - } - - // prune empty groups - for( int i=m_vPreferredCourseSort.size()-1; i>=0; i-- ) - if( m_vPreferredCourseSort[i].empty() ) - m_vPreferredCourseSort.erase( m_vPreferredCourseSort.begin()+i ); - - FOREACH( CoursePointerVector, m_vPreferredCourseSort, i ) - FOREACH( Course*, *i, j ) - ASSERT( *j != NULL ); - } } void SongManager::SortSongs() @@ -1885,38 +1276,6 @@ void SongManager::SortSongs() SongUtil::SortSongPointerArrayByTitle( m_pSongs ); } -void SongManager::UpdateRankingCourses() -{ - /* Updating the ranking courses data is fairly expensive since it involves - * comparing strings. Do so sparingly. */ - vector RankingCourses; - split( THEME->GetMetric("ScreenRanking","CoursesToShow"),",", RankingCourses); - - FOREACH( Course*, m_pCourses, c ) - { - bool bLotsOfStages = (*c)->GetEstimatedNumStages() > 7; - (*c)->m_SortOrder_Ranking = bLotsOfStages? 3 : 2; - - for( unsigned j = 0; j < RankingCourses.size(); j++ ) - if( !RankingCourses[j].CompareNoCase((*c)->m_sPath) ) - (*c)->m_SortOrder_Ranking = 1; - } -} - -void SongManager::RefreshCourseGroupInfo() -{ - m_mapCourseGroupToInfo.clear(); - - FOREACH_CONST( Course*, m_pCourses, c ) - { - m_mapCourseGroupToInfo[(*c)->m_sGroupName]; // insert - } - - // TODO: Search for course group banners - FOREACHM( RString, CourseGroupInfo, m_mapCourseGroupToInfo, iter ) - { - } -} void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot ) { @@ -1998,25 +1357,6 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi } } -void SongManager::LoadCourseEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot ) -{ - // Load all edit courses - RString sDir = sProfileDir + EDIT_COURSES_SUBDIR; - - vector vsFiles; - GetDirListing( sDir+"*.crs", vsFiles, false, true ); - - int iNumEditsLoaded = GetNumEditsLoadedFromProfile( slot ); - int size = min( (int) vsFiles.size(), MAX_EDIT_COURSES_PER_PROFILE - iNumEditsLoaded ); - - for( int i=0; i apToDelete; - FOREACH( Course*, m_pCourses, c ) - { - Course *pCourse = *c; - if( pCourse->GetLoadedFromProfileSlot() == ProfileSlot_Invalid ) - continue; - - if( slot == ProfileSlot_Invalid || pCourse->GetLoadedFromProfileSlot() == slot ) - apToDelete.push_back( *c ); - } - - /* We don't use DeleteCourse here, so we don't UpdatePopular and - * UpdateShuffled repeatedly. */ - for( unsigned i = 0; i < apToDelete.size(); ++i ) - { - vector::iterator iter = find( m_pCourses.begin(), m_pCourses.end(), apToDelete[i] ); - ASSERT( iter != m_pCourses.end() ); - m_pCourses.erase( iter ); - delete apToDelete[i]; - } - // Popular and Shuffled may refer to courses that we just freed. UpdatePopular(); UpdateShuffled(); - RefreshCourseGroupInfo(); // Free profile steps. set setInUse; @@ -2099,29 +1416,6 @@ int SongManager::GetNumStepsLoadedFromProfile() return iCount; } -template -int FindCourseIndexOfSameMode( T begin, T end, const Course *p ) -{ - const PlayMode pm = p->GetPlayMode(); - - int n = 0; - for( T it = begin; it != end; ++it ) - { - if( *it == p ) - return n; - - /* If it's not playable in this mode, don't increment. It might result in - * different output in different modes, but that's better than having holes. */ - if( !(*it)->IsPlayableIn( GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType ) ) - continue; - if( (*it)->GetPlayMode() != pm ) - continue; - ++n; - } - - return -1; -} - int SongManager::GetSongRank(Song* pSong) { const int index = FindIndex( m_pPopularSongs.begin(), m_pPopularSongs.end(), pSong ); @@ -2140,26 +1434,12 @@ class LunaSongManager: public Luna p->UpdatePreferredSort( SArg(1), "PreferredCourses.txt" ); COMMON_RETURN_SELF; } - - static int SetPreferredCourses( T* p, lua_State *L ) - { - p->UpdatePreferredSort( "PreferredSongs.txt", SArg(1) ); - COMMON_RETURN_SELF; - } static int GetAllSongs( T* p, lua_State *L ) { const vector &v = p->GetAllSongs(); LuaHelpers::CreateTableFromArray( v, L ); return 1; } - static int GetAllCourses( T* p, lua_State *L ) - { - vector v; - p->GetAllCourses( v, BArg(1) ); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - static int GetPreferredSortSongs( T* p, lua_State *L ) { vector v; @@ -2167,28 +1447,15 @@ class LunaSongManager: public Luna LuaHelpers::CreateTableFromArray( v, L ); return 1; } - static int GetPreferredSortCourses( T* p, lua_State *L ) - { - vector v; - CourseType ct = Enum::Check(L,1); - p->GetPreferredSortCourses( ct, v, BArg(2) ); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } static int FindSong( T* p, lua_State *L ) { Song *pS = p->FindSong(SArg(1)); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } - static int FindCourse( T* p, lua_State *L ) { Course *pC = p->FindCourse(SArg(1)); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; } static int GetRandomSong( T* p, lua_State *L ) { Song *pS = p->GetRandomSong(); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } - static int GetRandomCourse( T* p, lua_State *L ) { Course *pC = p->GetRandomCourse(); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; } static int GetNumSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongs() ); return 1; } static int GetNumLockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumLockedSongs() ); return 1; } static int GetNumUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlockedSongs() ); return 1; } static int GetNumSelectableAndUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSelectableAndUnlockedSongs() ); return 1; } static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; } static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; } - static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; } - static int GetNumAdditionalCourses( T* p, lua_State *L ){ lua_pushnumber( L, p->GetNumAdditionalCourses() ); return 1; } - static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; } /* Note: this could now be implemented as Luna::GetSong */ static int GetSongFromSteps( T* p, lua_State *L ) { @@ -2215,7 +1482,6 @@ class LunaSongManager: public Luna } DEFINE_METHOD( GetSongColor, GetSongColor( Luna::check(L,1) ) ) DEFINE_METHOD( GetSongGroupColor, GetSongGroupColor( SArg(1) ) ) - DEFINE_METHOD( GetCourseColor, GetCourseColor( Luna::check(L,1) ) ) static int GetSongRank( T* p, lua_State *L ) { @@ -2249,28 +1515,9 @@ class LunaSongManager: public Luna return 1; } - static int GetCoursesInGroup( T* p, lua_State *L ) - { - vector v; - p->GetCoursesInGroup(v,SArg(1),BArg(2)); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - DEFINE_METHOD( ShortenGroupName, ShortenGroupName( SArg(1) ) ) - - static int GetCourseGroupNames( T* p, lua_State *L ) - { - vector v; - p->GetCourseGroupNames( v ); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - DEFINE_METHOD( GetSongGroupBannerPath, GetSongGroupBannerPath(SArg(1)) ); - DEFINE_METHOD( GetCourseGroupBannerPath, GetCourseGroupBannerPath(SArg(1)) ); DEFINE_METHOD( DoesSongGroupExist, DoesSongGroupExist(SArg(1)) ); - DEFINE_METHOD( DoesCourseGroupExist, DoesCourseGroupExist(SArg(1)) ); static int GetPopularSongs( T* p, lua_State *L ) { @@ -2278,13 +1525,6 @@ class LunaSongManager: public Luna LuaHelpers::CreateTableFromArray( v, L ); return 1; } - static int GetPopularCourses( T* p, lua_State *L ) - { - CourseType ct = Enum::Check(L,1); - const vector &v = p->GetPopularCourses(ct); - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } static int SongToPreferredSortSectionName( T* p, lua_State *L ) { const Song* pSong = Luna::check(L,1); @@ -2297,12 +1537,6 @@ class LunaSongManager: public Luna lua_pushboolean(L, p->WasLoadedFromAdditionalSongs(pSong)); return 1; } - static int WasLoadedFromAdditionalCourses( T* p, lua_State *L ) - { - const Course* pCourse = Luna::check(L,1); - lua_pushboolean(L, p->WasLoadedFromAdditionalCourses(pCourse)); - return 1; - } static int GetSongByChartKey(T* p, lua_State *L) { RString ck = SArg(1); @@ -2327,44 +1561,29 @@ class LunaSongManager: public Luna LunaSongManager() { ADD_METHOD( GetAllSongs ); - ADD_METHOD( GetAllCourses ); ADD_METHOD( FindSong ); - ADD_METHOD( FindCourse ); ADD_METHOD( GetRandomSong ); - ADD_METHOD( GetRandomCourse ); - ADD_METHOD( GetCourseGroupNames ); ADD_METHOD( GetNumSongs ); ADD_METHOD( GetNumLockedSongs ); ADD_METHOD( GetNumUnlockedSongs ); ADD_METHOD( GetNumSelectableAndUnlockedSongs ); ADD_METHOD( GetNumAdditionalSongs ); ADD_METHOD( GetNumSongGroups ); - ADD_METHOD( GetNumCourses ); - ADD_METHOD( GetNumAdditionalCourses ); - ADD_METHOD( GetNumCourseGroups ); ADD_METHOD( GetSongFromSteps ); ADD_METHOD( GetExtraStageInfo ); ADD_METHOD( GetSongColor ); ADD_METHOD( GetSongGroupColor ); - ADD_METHOD( GetCourseColor ); ADD_METHOD( GetSongRank ); ADD_METHOD( GetSongGroupNames ); ADD_METHOD( GetSongsInGroup ); - ADD_METHOD( GetCoursesInGroup ); ADD_METHOD( ShortenGroupName ); ADD_METHOD( SetPreferredSongs ); - ADD_METHOD( SetPreferredCourses ); ADD_METHOD( GetPreferredSortSongs ); - ADD_METHOD( GetPreferredSortCourses ); ADD_METHOD( GetSongGroupBannerPath ); - ADD_METHOD( GetCourseGroupBannerPath ); ADD_METHOD( DoesSongGroupExist ); - ADD_METHOD( DoesCourseGroupExist ); ADD_METHOD( GetPopularSongs ); - ADD_METHOD( GetPopularCourses ); ADD_METHOD( SongToPreferredSortSectionName ); ADD_METHOD( WasLoadedFromAdditionalSongs ); - ADD_METHOD( WasLoadedFromAdditionalCourses ); ADD_METHOD( GetSongByChartKey ); ADD_METHOD( GetStepsByChartKey ); } diff --git a/src/SongManager.h b/src/SongManager.h index 0d62621188..19de41f1dd 100644 --- a/src/SongManager.h +++ b/src/SongManager.h @@ -14,14 +14,12 @@ struct lua_State; #include "PlayerOptions.h" #include "PlayerNumber.h" #include "Difficulty.h" -#include "Course.h" #include "ThemeMetric.h" #include "RageTexturePreloader.h" #include "RageUtil.h" #include "Profile.h" RString SONG_GROUP_COLOR_NAME( size_t i ); -RString COURSE_GROUP_COLOR_NAME( size_t i ); bool CompareNotesPointersForExtra(const Steps *n1, const Steps *n2); /** @brief The max number of edit steps a profile can have. */ @@ -49,21 +47,13 @@ class SongManager void LoadEnabledSongsFromPref(); void LoadStepEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot ); - void LoadCourseEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot ); int GetNumStepsLoadedFromProfile(); void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_Invalid ); void LoadGroupSymLinks( const RString &sDir, const RString &sGroupFolder ); - void InitCoursesFromDisk( LoadingWindow *ld ); void InitAutogenCourses(); void InitRandomAttacks(); - void FreeCourses(); - void AddCourse( Course *pCourse ); // transfers ownership of pCourse - void DeleteCourse( Course *pCourse ); // transfers ownership of pCourse - /** @brief Remove all of the auto generated courses. */ - void DeleteAutogenCourses(); - void InvalidateCachedTrails(); void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything. void Reload( bool bAllowFastLoad, LoadingWindow *ld=NULL ); // songs, courses, groups - everything. @@ -80,13 +70,6 @@ class SongManager RageColor GetSongGroupColor( const RString &sSongGroupName ) const; RageColor GetSongColor( const Song* pSong ) const; - RString GetCourseGroupBannerPath( const RString &sCourseGroup ) const; - //RString GetCourseGroupBackgroundPath( const RString &sCourseGroup ) const; - void GetCourseGroupNames( vector &AddTo ) const; - bool DoesCourseGroupExist( const RString &sCourseGroup ) const; - RageColor GetCourseGroupColor( const RString &sCourseGroupName ) const; - RageColor GetCourseColor( const Course* pCourse ) const; - // temporary solution to reorganizing the entire songid/stepsid system - mina map> StepsIDsByChartkey; map> SongIDsByChartkey; @@ -133,11 +116,8 @@ class SongManager void GetFavoriteSongs(vector& songs) const; void GetPreferredSortSongs( vector &AddTo ) const; RString SongToPreferredSortSectionName( const Song *pSong ) const; - const vector &GetPopularCourses( CourseType ct ) const { return m_pPopularCourses[ct]; } Song *FindSong( RString sPath ) const; Song *FindSong( RString sGroup, RString sSong ) const; - Course *FindCourse( RString sPath ) const; - Course *FindCourse( RString sGroup, RString sName ) const; /** * @brief Retrieve the number of songs in the game. * @return the number of songs. */ @@ -154,7 +134,6 @@ class SongManager int GetNumAdditionalCourses() const; int GetNumCourseGroups() const; Song* GetRandomSong(); - Course* GetRandomCourse(); // sm-ssc addition: RString GetSongGroupByIndex(unsigned index) { return m_sSongGroupNames[index]; } int GetSongRank(Song* pSong); @@ -162,26 +141,15 @@ class SongManager void GetStepsLoadedFromProfile( vector &AddTo, ProfileSlot slot ) const; void DeleteSteps( Steps *pSteps ); // transfers ownership of pSteps bool WasLoadedFromAdditionalSongs( const Song *pSong ) const; - bool WasLoadedFromAdditionalCourses( const Course *pCourse ) const; - - void GetAllCourses( vector &AddTo, bool bIncludeAutogen ) const; - void GetCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ) const; - void GetCoursesInGroup( vector &AddTo, const RString &sCourseGroup, bool bIncludeAutogen ) const; - void GetPreferredSortCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ) const; void GetExtraStageInfo( bool bExtra2, const Style *s, Song*& pSongOut, Steps*& pStepsOut ); Song* GetSongFromDir( RString sDir ) const; - Course* GetCourseFromPath( const RString &sPath ) const; // path to .crs file, or path to song group dir - Course* GetCourseFromName( const RString &sName ) const; void UpdatePopular(); void UpdateShuffled(); // re-shuffle songs and courses void UpdatePreferredSort(const RString &sPreferredSongs = "PreferredSongs.txt", const RString &sPreferredCourses = "PreferredCourses.txt"); void SortSongs(); // sort m_pSongs by CompareSongPointersByTitle - void UpdateRankingCourses(); // courses shown on the ranking screen - void RefreshCourseGroupInfo(); - // Lua void PushSelf( lua_State *L ); @@ -218,24 +186,10 @@ class SongManager typedef vector SongPointerVector; map m_mapSongGroupIndex; - vector m_pCourses; - vector m_pPopularCourses[NUM_CourseType]; - vector m_pShuffledCourses; // used by GetRandomCourse - struct CourseGroupInfo - { - RString m_sBannerPath; - //RString m_sBackgroundPath; - }; - map m_mapCourseGroupToInfo; - typedef vector CoursePointerVector; - vector m_vPreferredCourseSort; - RageTexturePreloader m_TexturePreload; ThemeMetric NUM_SONG_GROUP_COLORS; ThemeMetric1D SONG_GROUP_COLOR; - ThemeMetric NUM_COURSE_GROUP_COLORS; - ThemeMetric1D COURSE_GROUP_COLOR; }; extern SongManager* SONGMAN; // global and accessible from anywhere in our program diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index debf32898c..c79320f810 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -614,19 +614,6 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so else return RString(); } - case SORT_LENGTH: - { - if( SHOW_SECTIONS_IN_LENGTH_SORT ) - { - const int iSortLengthSize = SORT_LENGTH_DIVISION; - int iMaxLength = (int)pSong->m_fMusicLengthSeconds; - iMaxLength += (iSortLengthSize - (iMaxLength%iSortLengthSize) - 1); - int iMinLength = iMaxLength - (iSortLengthSize-1); - return ssprintf( "%s-%s", SecondsToMMSS(iMinLength).c_str(), SecondsToMMSS(iMaxLength).c_str() ); - } - else - return RString(); - } case SORT_POPULARITY: case SORT_RECENT: return RString(); @@ -664,10 +651,6 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so } case SORT_MODE_MENU: return RString(); - case SORT_ALL_COURSES: - case SORT_NONSTOP_COURSES: - case SORT_ONI_COURSES: - case SORT_ENDLESS_COURSES: default: FAIL_M(ssprintf("Invalid SortOrder: %i", so)); } @@ -710,9 +693,6 @@ void SongUtil::SortSongPointerArrayByStepsTypeAndMeter( vector &vpSongsIn * well. That way, we'll always put Medium 5s before Hard 5s. If all * songs are using the preferred difficulty (dc), this will be a no-op. */ s += ssprintf( "%c", (pSteps? pSteps->GetDifficulty():0) + '0' ); - - if( PREFSMAN->m_bSubSortByNumSteps ) - s += ssprintf("%06.0f",pSteps ? pSteps->GetRadarValues(PLAYER_1)[RadarCategory_TapsAndHolds] : 0); } stable_sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersBySortValueAscending ); } diff --git a/src/SpecialFiles.cpp b/src/SpecialFiles.cpp index 5f6d5c50e8..89fb969940 100644 --- a/src/SpecialFiles.cpp +++ b/src/SpecialFiles.cpp @@ -17,7 +17,6 @@ const RString SpecialFiles::DEFAULTS_INI_PATH = "Data/Defaults.ini"; const RString SpecialFiles::STATIC_INI_PATH = "Data/Static.ini"; const RString SpecialFiles::TYPE_TXT_FILE = "Data/Type.txt"; const RString SpecialFiles::SONGS_DIR = "Songs/"; -const RString SpecialFiles::COURSES_DIR = "Courses/"; const RString SpecialFiles::NOTESKINS_DIR = "NoteSkins/"; diff --git a/src/SpecialFiles.h b/src/SpecialFiles.h index dc6782d0d5..b82bcd2ee0 100644 --- a/src/SpecialFiles.h +++ b/src/SpecialFiles.h @@ -35,8 +35,6 @@ namespace SpecialFiles extern const RString TYPE_TXT_FILE; /** @brief The default Songs directory. */ extern const RString SONGS_DIR; - /** @brief The default courses directory. */ - extern const RString COURSES_DIR; /** @brief The default noteskins directory. */ extern const RString NOTESKINS_DIR; } diff --git a/src/StageStats.cpp b/src/StageStats.cpp index df4f742adb..8511891672 100644 --- a/src/StageStats.cpp +++ b/src/StageStats.cpp @@ -291,15 +291,6 @@ void StageStats::FinalizeScores( bool bSummary ) // TRICKY: Increment play count here, and not on ScreenGameplay like the others. PROFILEMAN->IncrementCategoryPlayCount( st, m_player[p].m_rc, p ); } - else if( GAMESTATE->IsCourseMode() ) - { - // Save this stage to recent scores - Course* pCourse = GAMESTATE->m_pCurCourse; - ASSERT( pCourse != NULL ); - Trail* pTrail = GAMESTATE->m_pCurTrail[p]; - - PROFILEMAN->AddCourseScore( pCourse, pTrail, p, hs, m_player[p].m_iPersonalHighScoreIndex, m_player[p].m_iMachineHighScoreIndex ); - } else { ASSERT( pSteps != NULL ); @@ -330,14 +321,6 @@ void StageStats::FinalizeScores( bool bSummary ) { pHSL = &pProfile->GetCategoryHighScoreList( st, m_player[p].m_rc ); } - else if( GAMESTATE->IsCourseMode() ) - { - Course* pCourse = GAMESTATE->m_pCurCourse; - ASSERT( pCourse != NULL ); - Trail *pTrail = GAMESTATE->m_pCurTrail[p]; - ASSERT( pTrail != NULL ); - pHSL = &pProfile->GetCourseHighScoreList( pCourse, pTrail ); - } else { Song* pSong = GAMESTATE->m_pCurSong; @@ -359,17 +342,12 @@ bool StageStats::PlayerHasHighScore( PlayerNumber pn ) const { const Song *pSong = m_vpPlayedSongs[0]; const Steps *pSteps = m_player[pn].m_vpPossibleSteps[0]; - const Course *pCourse = GAMESTATE->m_pCurCourse; - const Trail *pTrail = GAMESTATE->m_pCurTrail[pn]; // Don't show high scores for tutorial songs. if( pSong->IsTutorial() == Song::SHOW_NEVER ) return false; - const HighScoreList &hsl = - GAMESTATE->IsCourseMode() ? - PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, pTrail) : - PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong, pSteps); + const HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong, pSteps); int iScore = m_player[pn].m_iScore; float fPercentDP = m_player[pn].GetPercentDancePoints(); diff --git a/src/StatsManager.cpp b/src/StatsManager.cpp index a2564442f8..093919fbb8 100644 --- a/src/StatsManager.cpp +++ b/src/StatsManager.cpp @@ -17,7 +17,6 @@ StatsManager* STATSMAN = NULL; // global object accessible from anywhere in the program void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNumber pn ); -XNode* MakeRecentScoreNode( const StageStats &ss, Trail *pTrail, const PlayerStageStats &pss, MultiPlayer mp ); StatsManager::StatsManager() { @@ -149,45 +148,6 @@ void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNum } -XNode* MakeRecentScoreNode( const StageStats &ss, Trail *pTrail, const PlayerStageStats &pss, MultiPlayer mp ) -{ - XNode* pNode = NULL; - if( GAMESTATE->IsCourseMode() ) - { - pNode = new XNode( "HighScoreForACourseAndTrail" ); - - CourseID courseID; - courseID.FromCourse(GAMESTATE->m_pCurCourse ); - pNode->AppendChild( courseID.CreateNode() ); - - TrailID trailID; - trailID.FromTrail( pTrail ); - pNode->AppendChild( trailID.CreateNode() ); - - } - else - { - pNode = new XNode( "HighScoreForASongAndSteps" ); - - SongID songID; - songID.FromSong( ss.m_vpPossibleSongs[0] ); - pNode->AppendChild( songID.CreateNode() ); - - StepsID stepsID; - stepsID.FromSteps( pss.m_vpPossibleSteps[0] ); - pNode->AppendChild( stepsID.CreateNode() ); - } - - XNode* pHighScore = pss.m_HighScore.CreateNode(); - pHighScore->AppendChild("Pad", mp); - pHighScore->AppendChild("StageGuid", GAMESTATE->m_sStageGUID); - pHighScore->AppendChild("Guid", CryptManager::GenerateRandomUUID()); - - pNode->AppendChild( pHighScore ); - - return pNode; -} - void StatsManager::CommitStatsToProfiles( const StageStats *pSS ) { // Add step totals. Use radarActual, since the player might have failed part way @@ -234,58 +194,6 @@ void StatsManager::CommitStatsToProfiles( const StageStats *pSS ) } } } - - // Not sure what the Save/Upload folder was originally for, but the files - // in it just accumulate uselessly, wasting several seconds when finishing - // a song. So this pref disables it. -Kyz - if(!PREFSMAN->m_DisableUploadDir) - { - // Save recent scores - unique_ptr xml( new XNode("Stats") ); - xml->AppendChild( "MachineGuid", PROFILEMAN->GetMachineProfile()->m_sGuid ); - - XNode *recent = NULL; - if( GAMESTATE->IsCourseMode() ) - recent = xml->AppendChild( new XNode("RecentCourseScores") ); - else - recent = xml->AppendChild( new XNode("RecentSongScores") ); - - if(!GAMESTATE->m_bMultiplayer) - { - FOREACH_HumanPlayer( p ) - { - if( pSS->m_player[p].m_HighScore.IsEmpty() ) - continue; - recent->AppendChild( MakeRecentScoreNode( *pSS, GAMESTATE->m_pCurTrail[p], pSS->m_player[p], MultiPlayer_Invalid ) ); - } - } - else - { - FOREACH_EnabledMultiPlayer( mp ) - { - if( pSS->m_multiPlayer[mp].m_HighScore.IsEmpty() ) - continue; - recent->AppendChild( MakeRecentScoreNode( *pSS, GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()], pSS->m_multiPlayer[mp], mp ) ); - } - } - - RString sDate = DateTime::GetNowDate().GetString(); - sDate.Replace(":","-"); - - const RString UPLOAD_DIR = "/Save/Upload/"; - RString sFileNameNoExtension = Profile::MakeUniqueFileNameNoExtension(UPLOAD_DIR, sDate + " " ); - RString fn = UPLOAD_DIR + sFileNameNoExtension + ".xml"; - - bool bSaved = XmlFileUtil::SaveToFile( xml.get(), fn, "", false ); - - if( bSaved ) - { - RString sStatsXmlSigFile = fn + SIGNATURE_APPEND; - CryptManager::SignFileToFile(fn, sStatsXmlSigFile); - } - } - - //FileCopy( "Data/TempTestGroups.xml", "Save/Upload/data.xml" ); } void StatsManager::UnjoinPlayer( PlayerNumber pn ) diff --git a/src/StepMania.cpp b/src/StepMania.cpp index d669c77b32..5cfd5c8f19 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1042,13 +1042,6 @@ int sm_main(int argc, char* argv[]) for( unsigned i=0; i < dirs.size(); i++) FILEMAN->Mount( "dir", dirs[i], "/AdditionalSongs" ); } - if( PREFSMAN->m_sAdditionalCourseFolders.Get() != "" ) - { - vector dirs; - split( PREFSMAN->m_sAdditionalCourseFolders, ",", dirs, true ); - for( unsigned i=0; i < dirs.size(); i++) - FILEMAN->Mount( "dir", dirs[i], "/AdditionalCourses" ); - } MountTreeOfZips( SpecialFiles::PACKAGES_DIR ); MountTreeOfZips( SpecialFiles::USER_PACKAGES_DIR ); @@ -1185,9 +1178,6 @@ int sm_main(int argc, char* argv[]) FILTERMAN = new FilterManager; - // Initialize which courses are ranking courses here. - SONGMAN->UpdateRankingCourses(); - SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display /* If the user has tried to quit during the loading, do it before creating diff --git a/src/StepsDisplay.cpp b/src/StepsDisplay.cpp index 6996e7f0e5..e6e23dcd90 100644 --- a/src/StepsDisplay.cpp +++ b/src/StepsDisplay.cpp @@ -5,7 +5,6 @@ #include "GameState.h" #include "ThemeManager.h" #include "Steps.h" -#include "Course.h" #include "SongManager.h" #include "ActorUtil.h" #include "Style.h" @@ -129,23 +128,11 @@ void StepsDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlaye void StepsDisplay::SetFromGameState( PlayerNumber pn ) { - if( GAMESTATE->IsCourseMode() ) - { - // figure out what course type is selected somehow. - const Trail* pTrail = GAMESTATE->m_pCurTrail[pn]; - if( pTrail ) - SetFromTrail( pTrail ); - else - SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, GAMESTATE->m_PreferredCourseDifficulty[pn], CourseType_Invalid ); - } - else - { const Steps* pSteps = GAMESTATE->m_pCurSteps[pn]; if( pSteps ) SetFromSteps( pSteps ); else - SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, GAMESTATE->m_PreferredDifficulty[pn], CourseType_Invalid ); - } + SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, GAMESTATE->m_PreferredDifficulty[pn] ); } void StepsDisplay::SetFromSteps( const Steps* pSteps ) @@ -156,30 +143,19 @@ void StepsDisplay::SetFromSteps( const Steps* pSteps ) return; } - SetParams params = { pSteps, NULL, pSteps->GetMeter(), pSteps->m_StepsType, pSteps->GetDifficulty(), CourseType_Invalid }; + SetParams params = { pSteps, pSteps->GetMeter(), pSteps->m_StepsType, pSteps->GetDifficulty() }; SetInternal( params ); } -void StepsDisplay::SetFromTrail( const Trail* pTrail ) -{ - if( pTrail == NULL ) - { - Unset(); - return; - } - - SetParams params = { NULL, pTrail, pTrail->GetMeter(), pTrail->m_StepsType, pTrail->m_CourseDifficulty, pTrail->m_CourseType }; - SetInternal( params ); -} void StepsDisplay::Unset() { this->SetVisible( false ); } -void StepsDisplay::SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType st, int iMeter, Difficulty dc, CourseType ct ) +void StepsDisplay::SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType st, int iMeter, Difficulty dc ) { - SetParams params = { NULL, NULL, iMeter, st, dc, ct }; + SetParams params = { NULL, iMeter, st, dc }; SetInternal( params ); } @@ -191,10 +167,8 @@ void StepsDisplay::SetInternal( const SetParams ¶ms ) RString sCustomDifficulty; if( params.pSteps ) sCustomDifficulty = StepsToCustomDifficulty(params.pSteps); - else if( params.pTrail ) - sCustomDifficulty = TrailToCustomDifficulty(params.pTrail); else - sCustomDifficulty = GetCustomDifficulty( params.st, params.dc, params.ct ); + sCustomDifficulty = GetCustomDifficulty( params.st, params.dc); msg.SetParam( "CustomDifficulty", sCustomDifficulty ); RString sDisplayDescription; @@ -212,8 +186,6 @@ void StepsDisplay::SetInternal( const SetParams ¶ms ) if( params.pSteps ) msg.SetParam( "Steps", LuaReference::CreateFromPush(*(Steps*)params.pSteps) ); - if( params.pTrail ) - msg.SetParam( "Trail", LuaReference::CreateFromPush(*(Trail*)params.pTrail) ); msg.SetParam( "Meter", params.iMeter ); msg.SetParam( "StepsType", params.st ); @@ -302,19 +274,6 @@ class LunaStepsDisplay: public Luna } COMMON_RETURN_SELF; } - static int SetFromTrail( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) - { - p->SetFromTrail( NULL ); - } - else - { - Trail *pT = Luna::check(L,1); - p->SetFromTrail( pT ); - } - COMMON_RETURN_SELF; - } static int SetFromGameState( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check(L, 1); @@ -326,7 +285,6 @@ class LunaStepsDisplay: public Luna { ADD_METHOD( Load ); ADD_METHOD( SetFromSteps ); - ADD_METHOD( SetFromTrail ); ADD_METHOD( SetFromGameState ); } }; diff --git a/src/StepsDisplay.h b/src/StepsDisplay.h index c3af3063a9..d9708869b0 100644 --- a/src/StepsDisplay.h +++ b/src/StepsDisplay.h @@ -12,7 +12,6 @@ #include "Sprite.h" class Steps; -class Trail; class PlayerState; /** * @brief A graphical representation of a Steps or a Trail. @@ -28,9 +27,8 @@ class StepsDisplay : public ActorFrame virtual StepsDisplay *Copy() const; void SetFromGameState( PlayerNumber pn ); - void SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType st, int iMeter, Difficulty dc, CourseType ct ); + void SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType st, int iMeter, Difficulty dc); void SetFromSteps( const Steps* pSteps ); - void SetFromTrail( const Trail* pTrail ); void Unset(); // Lua @@ -40,11 +38,9 @@ class StepsDisplay : public ActorFrame struct SetParams { const Steps *pSteps; - const Trail *pTrail; int iMeter; StepsType st; // pass because there may be a StepType icon Difficulty dc; - CourseType ct; }; void SetInternal( const SetParams ¶ms ); diff --git a/src/Trail.cpp b/src/Trail.cpp index f481332fa2..e69de29bb2 100644 --- a/src/Trail.cpp +++ b/src/Trail.cpp @@ -1,335 +0,0 @@ -#include "global.h" -#include "Trail.h" -#include "Foreach.h" -#include "GameState.h" -#include "Steps.h" -#include "Song.h" -#include "PlayerOptions.h" -#include "NoteData.h" -#include "NoteDataUtil.h" -#include "CommonMetrics.h" - -void TrailEntry::GetAttackArray( AttackArray &out ) const -{ - if( !Modifiers.empty() ) - out.push_back( Attack::FromGlobalCourseModifier( Modifiers ) ); - - out.insert( out.end(), Attacks.begin(), Attacks.end() ); -} - -bool TrailEntry::operator== ( const TrailEntry &rhs ) const -{ -#define EQUAL(a) (a==rhs.a) - return - EQUAL(pSong) && - EQUAL(pSteps) && - EQUAL(Modifiers) && - EQUAL(Attacks) && - EQUAL(bSecret) && - EQUAL(iLowMeter) && - EQUAL(iHighMeter) && - EQUAL(dc); -} - -bool TrailEntry::ContainsTransformOrTurn() const -{ - PlayerOptions po; - po.FromString( Modifiers ); - if( po.ContainsTransformOrTurn() ) - return true; - if( Attacks.ContainsTransformOrTurn() ) - return true; - return false; -} - -// TrailEntry lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the TrailEntry. */ -class LunaTrailEntry: public Luna -{ -public: - static int GetSong( T* p, lua_State *L ) - { - if( p->pSong ) - p->pSong->PushSelf(L); - else - lua_pushnil(L); - return 1; - } - static int GetSteps( T* p, lua_State *L ) - { - if( p->pSteps ) - p->pSteps->PushSelf(L); - else - lua_pushnil(L); - return 1; - } - DEFINE_METHOD( IsSecret, bSecret ); - DEFINE_METHOD( GetNormalModifiers, Modifiers ); - - LunaTrailEntry() - { - ADD_METHOD( GetSong ); - ADD_METHOD( GetSteps ); - ADD_METHOD( IsSecret ); - ADD_METHOD( GetNormalModifiers ); - } -}; - -LUA_REGISTER_CLASS( TrailEntry ) -// TrailEntry lua end - -void Trail::SetRadarValues( const RadarValues &rv ) -{ - m_CachedRadarValues = rv; - m_bRadarValuesCached = true; -} - -const RadarValues &Trail::GetRadarValues() const -{ - if( m_bRadarValuesCached ) - { - return m_CachedRadarValues; - } - if( IsSecret() ) - { - // Don't calculate RadarValues for a non-fixed Course. They values are - // worthless because they'll change every time this Trail is - // regenerated. - m_CachedRadarValues = RadarValues(); - return m_CachedRadarValues; - } - else - { - RadarValues rv; - rv.Zero(); - - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - const Steps *pSteps = e->pSteps; - ASSERT( pSteps != NULL ); - // Hack: don't calculate for autogen entries - if( !pSteps->IsAutogen() && e->ContainsTransformOrTurn() ) - { - NoteData nd; - pSteps->GetNoteData( nd, false ); - RadarValues rv_orig; - GAMESTATE->SetProcessedTimingData(const_cast(pSteps->GetTimingData())); - NoteDataUtil::CalculateRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv_orig ); - PlayerOptions po; - po.FromString( e->Modifiers ); - if( po.ContainsTransformOrTurn() ) - { - NoteDataUtil::TransformNoteData(nd, *(pSteps->GetTimingData()), po, pSteps->m_StepsType); - } - NoteDataUtil::TransformNoteData(nd, *(pSteps->GetTimingData()), e->Attacks, pSteps->m_StepsType, e->pSong); - RadarValues transformed_rv; - NoteDataUtil::CalculateRadarValues( nd, e->pSong->m_fMusicLengthSeconds, transformed_rv ); - GAMESTATE->SetProcessedTimingData(NULL); - rv += transformed_rv; - } - else - { - rv += pSteps->GetRadarValues( PLAYER_1 ); - } - } - - /* Hack: SetRadarValues is non-const (a const setter doesn't - * make sense), but it only modifies a mutable value. Just - * cast away const. */ - const_cast(this)->SetRadarValues( rv ); - - return m_CachedRadarValues; - } -} - -int Trail::GetMeter() const -{ - if( m_iSpecifiedMeter != -1 ) - return m_iSpecifiedMeter; - - if( m_vEntries.empty() ) - return 0; - - float fMeter = GetTotalMeter() / (float)m_vEntries.size(); - - return lround( fMeter ); -} - -int Trail::GetTotalMeter() const -{ - int iTotalMeter = 0; - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - iTotalMeter += e->pSteps->GetMeter(); - } - - return iTotalMeter; -} - -float Trail::GetLengthSeconds() const -{ - float fSecs = 0; - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - fSecs += e->pSong->m_fMusicLengthSeconds; - } - return fSecs; -} - -void Trail::GetDisplayBpms( DisplayBpms &AddTo ) const -{ - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - if( e->bSecret ) - { - AddTo.Add( -1 ); - continue; - } - - Song *pSong = e->pSong; - ASSERT( pSong != NULL ); - switch( pSong->m_DisplayBPMType ) - { - case DISPLAY_BPM_ACTUAL: - case DISPLAY_BPM_SPECIFIED: - pSong->GetDisplayBpms( AddTo ); - break; - case DISPLAY_BPM_RANDOM: - AddTo.Add( -1 ); - break; - DEFAULT_FAIL( pSong->m_DisplayBPMType ); - } - } -} - -bool Trail::IsSecret() const -{ - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - if( e->bSecret ) - return true; - } - return false; -} - -bool Trail::ContainsSong( const Song *pSong ) const -{ - FOREACH_CONST( TrailEntry, m_vEntries, e ) - { - if( e->pSong == pSong ) - return true; - } - return false; -} - -// lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the Trail. */ -class LunaTrail: public Luna -{ -public: - static int GetDifficulty( T* p, lua_State *L ) { LuaHelpers::Push(L, p->m_CourseDifficulty ); return 1; } - static int GetMeter( T* p, lua_State *L ) { LuaHelpers::Push(L, p->GetMeter() ); return 1; } - static int GetTotalMeter( T* p, lua_State *L ) { LuaHelpers::Push(L, p->GetTotalMeter() ); return 1; } - static int GetStepsType( T* p, lua_State *L ) { LuaHelpers::Push(L, p->m_StepsType ); return 1; } - static int GetRadarValues( T* p, lua_State *L ) - { - RadarValues &rv = const_cast(p->GetRadarValues()); - rv.PushSelf(L); - return 1; - } - static int GetArtists( T* p, lua_State *L ) - { - vector asArtists, asAltArtists; - FOREACH_CONST( TrailEntry, p->m_vEntries, e ) - { - if( e->bSecret ) - { - asArtists.push_back( "???" ); - asAltArtists.push_back( "???" ); - } - else - { - asArtists.push_back( e->pSong->GetDisplayArtist() ); - asAltArtists.push_back( e->pSong->GetTranslitArtist() ); - } - } - - if( (int) asArtists.size() > CommonMetrics::MAX_COURSE_ENTRIES_BEFORE_VARIOUS ) - { - asArtists.clear(); - asAltArtists.clear(); - asArtists.push_back( "Various Artists" ); - asAltArtists.push_back( "Various Artists" ); - } - - LuaHelpers::CreateTableFromArray( asArtists, L ); - LuaHelpers::CreateTableFromArray( asAltArtists, L ); - return 2; - } - static int GetTrailEntry( T* p, lua_State *L ) { TrailEntry &te = p->m_vEntries[IArg(1)]; te.PushSelf(L); return 1; } - static int GetTrailEntries( T* p, lua_State *L ) - { - vector v; - for( unsigned i = 0; i < p->m_vEntries.size(); ++i ) - { - v.push_back(&p->m_vEntries[i]); - } - LuaHelpers::CreateTableFromArray( v, L ); - return 1; - } - DEFINE_METHOD( GetLengthSeconds, GetLengthSeconds() ) - DEFINE_METHOD( IsSecret, IsSecret() ) - static int ContainsSong( T* p, lua_State *L ) - { - const Song *pS = Luna::check(L,1); - lua_pushboolean(L, p->ContainsSong(pS)); - return 1; - } - - LunaTrail() - { - ADD_METHOD( GetDifficulty ); - ADD_METHOD( GetMeter ); - ADD_METHOD( GetTotalMeter ); - ADD_METHOD( GetStepsType ); - ADD_METHOD( GetRadarValues ); - ADD_METHOD( GetArtists ); - ADD_METHOD( GetTrailEntry ); - ADD_METHOD( GetTrailEntries ); - ADD_METHOD( GetLengthSeconds ); - ADD_METHOD( IsSecret ); - ADD_METHOD( ContainsSong ); - } -}; - -LUA_REGISTER_CLASS( Trail ) -// lua end - -/* - * (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. - */ diff --git a/src/Trail.h b/src/Trail.h index 8c9b8a1095..e69de29bb2 100644 --- a/src/Trail.h +++ b/src/Trail.h @@ -1,129 +0,0 @@ -#ifndef TRAIL_H -#define TRAIL_H - -#include "Attack.h" -#include "RadarValues.h" -#include "Difficulty.h" -#include "RageUtil_CachedObject.h" - -class Song; -class Steps; -struct lua_State; - -/** @brief One such Song and - * Step in the entire Trail. */ -struct TrailEntry -{ - TrailEntry(): - pSong(NULL), - pSteps(NULL), - Modifiers(""), - Attacks(), - bSecret(false), - iLowMeter(-1), - iHighMeter(-1), - dc(Difficulty_Invalid) - { - } - void GetAttackArray( AttackArray &out ) const; - - /** @brief The Song involved in the entry. */ - Song* pSong; - /** @brief The Step involved in the entry. */ - Steps* pSteps; - /** @brief The Modifiers applied for the whole Song. */ - RString Modifiers; - /** @brief The Attacks that will take place durring the Song. */ - AttackArray Attacks; - /** - * @brief Is this Song and its Step meant to be a secret? - * If so, it will show text such as "???" to indicate that it's a mystery. */ - bool bSecret; - - /* These represent the meter and difficulty used by the course to pick the - * steps; if you want the real difficulty and meter, look at pSteps. */ - int iLowMeter; - int iHighMeter; - Difficulty dc; - bool operator== ( const TrailEntry &rhs ) const; - bool operator!= ( const TrailEntry &rhs ) const { return !(*this==rhs); } - bool ContainsTransformOrTurn() const; - - // Lua - void PushSelf( lua_State *L ); -}; - -/** @brief A queue of Songs and Steps that are generated from a Course. */ -class Trail -{ -public: - StepsType m_StepsType; - CourseType m_CourseType; - CourseDifficulty m_CourseDifficulty; - vector m_vEntries; - int m_iSpecifiedMeter; // == -1 if no meter specified - mutable bool m_bRadarValuesCached; - mutable RadarValues m_CachedRadarValues; - - /** - * @brief Set up the Trail with default values. - * - * This used to call Init(), which is still available. */ - Trail(): m_StepsType(StepsType_Invalid), - m_CourseType(CourseType_Invalid), - m_CourseDifficulty(Difficulty_Invalid), - m_vEntries(), m_iSpecifiedMeter(-1), - m_bRadarValuesCached(false), m_CachedRadarValues(), - m_CachedObject() {} - void Init() - { - m_StepsType = StepsType_Invalid; - m_CourseDifficulty = Difficulty_Invalid; - m_iSpecifiedMeter = -1; - m_vEntries.clear(); - m_bRadarValuesCached = false; - } - - const RadarValues &GetRadarValues() const; - void SetRadarValues( const RadarValues &rv ); // for pre-populating cache - int GetMeter() const; - int GetTotalMeter() const; - float GetLengthSeconds() const; - void GetDisplayBpms( DisplayBpms &AddTo ) const; - bool IsSecret() const; - bool ContainsSong( const Song *pSong ) const; - - CachedObject m_CachedObject; - - // Lua - void PushSelf( lua_State *L ); -}; - -#endif - -/** - * @file - * @author Chris Danford, Glenn Maynard (c) 2001-2004 - * @section LICENSE - * 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. - */ diff --git a/src/TrailUtil.cpp b/src/TrailUtil.cpp index 0ea7864a3e..e69de29bb2 100644 --- a/src/TrailUtil.cpp +++ b/src/TrailUtil.cpp @@ -1,157 +0,0 @@ -#include "global.h" -#include "TrailUtil.h" -#include "Trail.h" -#include "Course.h" -#include "XmlFile.h" -#include "GameManager.h" -#include "Song.h" - - -int TrailUtil::GetNumSongs( const Trail *pTrail ) -{ - return pTrail->m_vEntries.size(); -} - -float TrailUtil::GetTotalSeconds( const Trail *pTrail ) -{ - float fSecs = 0; - FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) - fSecs += e->pSong->m_fMusicLengthSeconds; - return fSecs; -} - -/////////////////////////////////////////////////////////////////////// - -void TrailID::FromTrail( const Trail *p ) -{ - if( p == NULL ) - { - st = StepsType_Invalid; - cd = Difficulty_Invalid; - } - else - { - st = p->m_StepsType; - cd = p->m_CourseDifficulty; - } - m_Cache.Unset(); -} - -Trail *TrailID::ToTrail( const Course *p, bool bAllowNull ) const -{ - ASSERT( p != NULL ); - - Trail *pRet = NULL; - if( !m_Cache.Get(&pRet) ) - { - if( st != StepsType_Invalid && cd != Difficulty_Invalid ) - pRet = p->GetTrail( st, cd ); - m_Cache.Set( pRet ); - } - - if( !bAllowNull && pRet == NULL ) - RageException::Throw( "%i, %i, \"%s\"", st, cd, p->GetDisplayFullTitle().c_str() ); - - return pRet; -} - -XNode* TrailID::CreateNode() const -{ - XNode* pNode = new XNode( "Trail" ); - - pNode->AppendAttr( "StepsType", GAMEMAN->GetStepsTypeInfo(st).szName ); - pNode->AppendAttr( "CourseDifficulty", DifficultyToString(cd) ); - - return pNode; -} - -void TrailID::LoadFromNode( const XNode* pNode ) -{ - ASSERT( pNode->GetName() == "Trail" ); - - RString sTemp; - - pNode->GetAttrValue( "StepsType", sTemp ); - st = GAMEMAN->StringToStepsType( sTemp ); - - pNode->GetAttrValue( "CourseDifficulty", sTemp ); - cd = StringToDifficulty( sTemp ); - m_Cache.Unset(); -} - -RString TrailID::ToString() const -{ - RString s = GAMEMAN->GetStepsTypeInfo(st).szName; - s += " " + DifficultyToString( cd ); - return s; -} - -bool TrailID::IsValid() const -{ - return st != StepsType_Invalid && cd != Difficulty_Invalid; -} - -bool TrailID::operator<( const TrailID &rhs ) const -{ -#define COMP(a) if(arhs.a) return false; - COMP(st); - COMP(cd); -#undef COMP - return false; -} - - -// lua start -#include "LuaBinding.h" - -namespace -{ - int GetNumSongs( lua_State *L ) - { - Trail *pTrail = Luna::check( L, 1, true ); - int iNum = TrailUtil::GetNumSongs( pTrail ); - LuaHelpers::Push( L, iNum ); - return 1; - } - int GetTotalSeconds( lua_State *L ) - { - Trail *pTrail = Luna::check( L, 1, true ); - float fSecs = TrailUtil::GetTotalSeconds( pTrail ); - LuaHelpers::Push( L, fSecs ); - return 1; - } - - const luaL_Reg TrailUtilTable[] = - { - LIST_METHOD( GetNumSongs ), - LIST_METHOD( GetTotalSeconds ), - { NULL, NULL } - }; -} - -LUA_REGISTER_NAMESPACE( TrailUtil ) - -/* - * (c) 2004 Chris Danford - * 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. - */ diff --git a/src/TrailUtil.h b/src/TrailUtil.h index 12c4a7dd76..41bbef1844 100644 --- a/src/TrailUtil.h +++ b/src/TrailUtil.h @@ -5,49 +5,6 @@ #include "Difficulty.h" #include "RageUtil_CachedObject.h" -class Song; -class Trail; -class Course; -class XNode; - -/** @brief Utility functions for dealing with the Trail. */ -namespace TrailUtil -{ - /** - * @brief Retrieve the number of - * Songs in the Trail. - * @param pTrail the Trail itself. - * @return the number of Songs. */ - int GetNumSongs( const Trail *pTrail ); - /** - * @brief Retrieve how long the Trail will last in seconds. - * @param pTrail the Trail itself. - * @return the total run time of the Trail. */ - float GetTotalSeconds( const Trail *pTrail ); -}; - -class TrailID -{ - StepsType st; - CourseDifficulty cd; - mutable CachedObjectPointer m_Cache; - -public: - TrailID(): st(StepsType_Invalid), cd(Difficulty_Invalid), - m_Cache() { m_Cache.Unset(); } - void Unset() { FromTrail(NULL); } - void FromTrail( const Trail *p ); - Trail *ToTrail( const Course *p, bool bAllowNull ) const; - bool operator<( const TrailID &rhs ) const; - bool MatchesStepsType( StepsType s ) const { return st == s; } - - XNode* CreateNode() const; - void LoadFromNode( const XNode* pNode ); - RString ToString() const; - bool IsValid() const; - static void Invalidate( Song* pStaleSong ); -}; - #endif /* diff --git a/src/UnlockManager.cpp b/src/UnlockManager.cpp index 3e55cf61ee..dae877e01a 100644 --- a/src/UnlockManager.cpp +++ b/src/UnlockManager.cpp @@ -3,7 +3,6 @@ #include "PrefsManager.h" #include "RageLog.h" #include "Song.h" -#include "Course.h" #include "RageUtil.h" #include "SongManager.h" #include "GameState.h" @@ -48,7 +47,6 @@ static const char *UnlockRewardTypeNames[] = "Song", "Steps", "StepsType", - "Course", "Modifier", }; XToString( UnlockRewardType ); @@ -96,10 +94,6 @@ RString UnlockManager::FindEntryID( const RString &sName ) const const Song *pSong = SONGMAN->FindSong( sName ); if( pSong != NULL ) pEntry = FindSong( pSong ); - - const Course *pCourse = SONGMAN->FindCourse( sName ); - if( pCourse != NULL ) - pEntry = FindCourse( pCourse ); if( pEntry == NULL ) pEntry = FindModifier( sName ); @@ -113,34 +107,6 @@ RString UnlockManager::FindEntryID( const RString &sName ) const return pEntry->m_sEntryID; } -int UnlockManager::CourseIsLocked( const Course *pCourse ) const -{ - int iRet = 0; - - if( PREFSMAN->m_bUseUnlockSystem ) - { - const UnlockEntry *p = FindCourse( pCourse ); - if( p == NULL ) - return false; - if( p->IsLocked() ) - iRet |= LOCKED_LOCK; - } - - /* If a course uses a song that is disabled, disable the course too. */ - FOREACH_CONST( CourseEntry, pCourse->m_vEntries, e ) - { - const CourseEntry &ce = *e; - const Song *pSong = ce.songID.ToSong(); - if( pSong == NULL ) - continue; - int iSongLock = SongIsLocked( pSong ); - if( iSongLock & LOCKED_DISABLED ) - iRet |= LOCKED_DISABLED; - } - - return iRet; -} - int UnlockManager::SongIsLocked( const Song *pSong ) const { int iRet = 0; @@ -229,14 +195,6 @@ const UnlockEntry *UnlockManager::FindStepsType(const Song *pSong, return NULL; } -const UnlockEntry *UnlockManager::FindCourse( const Course *pCourse ) const -{ - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if( e->m_Course.ToCourse() == pCourse ) - return &(*e); - return NULL; -} - const UnlockEntry *UnlockManager::FindModifier( const RString &sOneMod ) const { FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) @@ -263,21 +221,6 @@ static float GetArcadePoints( const Profile *pProfile ) break; } } - - FOREACH_ENUM( PlayMode, pm ) - { - switch(pm) - { - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ONI: - case PLAY_MODE_ENDLESS: - { - fAP += pProfile->m_iNumSongsPlayedByPlayMode[pm]; - } - default: break; - } - } - return fAP; } @@ -304,22 +247,6 @@ static float GetSongPoints( const Profile *pProfile ) break; } } - - FOREACH_ENUM( PlayMode, pm ) - { - switch(pm) - { - case PLAY_MODE_NONSTOP: - case PLAY_MODE_ONI: - case PLAY_MODE_ENDLESS: - { - fSP += pProfile->m_iNumSongsPlayedByPlayMode[pm]; - } - default: break; - } - - } - return fSP; } @@ -347,9 +274,6 @@ bool UnlockEntry::IsValid() const { return m_Song.IsValid() && m_dc != Difficulty_Invalid && m_StepsType != StepsType_Invalid; } - - case UnlockRewardType_Course: - return m_Course.IsValid(); case UnlockRewardType_Modifier: return true; @@ -424,16 +348,14 @@ RString UnlockEntry::GetDescription() const case UnlockRewardType_Steps: { StepsType st = GAMEMAN->GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; // TODO: Is this the best thing we can do here? - return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + CustomDifficultyToLocalizedString( GetCustomDifficulty(st, m_dc, CourseType_Invalid) ); + return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + CustomDifficultyToLocalizedString( GetCustomDifficulty(st, m_dc) ); } case UnlockRewardType_Steps_Type: { RString ret = (pSong ? pSong->GetDisplayFullTitle() : ""); - ret += "," + CustomDifficultyToLocalizedString( GetCustomDifficulty(m_StepsType, m_dc, CourseType_Invalid) ); + ret += "," + CustomDifficultyToLocalizedString( GetCustomDifficulty(m_StepsType, m_dc) ); return ret + "," + StringConversion::ToString(m_StepsType); // yeah, bit strange. } - case UnlockRewardType_Course: - return m_Course.IsValid() ? m_Course.ToCourse()->GetDisplayFullTitle() : ""; case UnlockRewardType_Modifier: return CommonMetrics::LocalizeOptionItem( GetModifier(), false ); } @@ -450,8 +372,6 @@ RString UnlockEntry::GetBannerFile() const case UnlockRewardType_Steps: case UnlockRewardType_Steps_Type: return pSong ? pSong->GetBannerPath() : ""; - case UnlockRewardType_Course: - return m_Course.ToCourse() ? m_Course.ToCourse()->GetBannerPath() : ""; case UnlockRewardType_Modifier: return ""; } @@ -468,8 +388,6 @@ RString UnlockEntry::GetBackgroundFile() const case UnlockRewardType_Steps: case UnlockRewardType_Steps_Type: return pSong ? pSong->GetBackgroundPath() : ""; - case UnlockRewardType_Course: - return ""; case UnlockRewardType_Modifier: return ""; } @@ -620,11 +538,6 @@ void UnlockManager::Load() } break; } - case UnlockRewardType_Course: - e->m_Course.FromCourse( SONGMAN->FindCourse(e->m_cmd.GetArg(0).s) ); - if( !e->m_Course.IsValid() ) - LuaHelpers::ReportScriptErrorFmt( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; case UnlockRewardType_Modifier: // nothing to cache break; @@ -649,8 +562,6 @@ void UnlockManager::Load() str += e->IsLocked()? "locked":"unlocked"; if( e->m_Song.IsValid() ) str += ( " (found song)" ); - if( e->m_Course.IsValid() ) - str += ( " (found course)" ); LOG->Trace( "%s", str.c_str() ); } @@ -686,7 +597,6 @@ float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const void UnlockManager::UnlockEntryID( const RString &sEntryID ) { PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( sEntryID ); - SONGMAN->InvalidateCachedTrails(); } void UnlockManager::UnlockEntryIndex( int iEntryIndex ) @@ -698,7 +608,6 @@ void UnlockManager::UnlockEntryIndex( int iEntryIndex ) void UnlockManager::LockEntryID( RString entryID ) { PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.erase( entryID ); - SONGMAN->InvalidateCachedTrails(); } void UnlockManager::LockEntryIndex( int entryIndex ) @@ -717,8 +626,6 @@ void UnlockManager::PreferUnlockEntryID( const RString &sUnlockEntryID ) if( pEntry.m_Song.ToSong() != NULL ) GAMESTATE->m_pPreferredSong = pEntry.m_Song.ToSong(); - if( pEntry.m_Course.ToCourse() ) - GAMESTATE->m_pPreferredCourse = pEntry.m_Course.ToCourse(); } } @@ -848,12 +755,6 @@ class LunaUnlockEntry: public Luna return 0; } - static int GetCourse( T* p, lua_State *L ) - { - Course *pCourse = p->m_Course.ToCourse(); - if( pCourse ) { pCourse->PushSelf(L); return 1; } - return 0; - } static int GetCode( T* p, lua_State *L ) { lua_pushstring( L, p->m_sEntryID ); @@ -873,7 +774,6 @@ class LunaUnlockEntry: public Luna static int song( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Song; return 0; } static int steps( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Steps; return 0; } static int steps_type(T* p, lua_State *L) { GetArgs(p, L); p->m_Type = UnlockRewardType_Steps_Type; return 0; } - static int course( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Course; return 0; } static int mod( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Modifier; return 0; } static int code( T* p, lua_State *L ) { p->m_sEntryID = SArg(1); return 0; } static int roulette( T* p, lua_State *L ) { p->m_bRoulette = true; return 0; } @@ -897,13 +797,11 @@ class LunaUnlockEntry: public Luna ADD_METHOD( GetRequirePassHardSteps ); ADD_METHOD( GetRequirePassChallengeSteps ); ADD_METHOD( GetSong ); - ADD_METHOD( GetCourse ); ADD_METHOD( GetStepOfAllTypes ); ADD_METHOD( GetStepByStepsType ); ADD_METHOD( song ); ADD_METHOD( steps ); ADD_METHOD( steps_type ); - ADD_METHOD( course ); ADD_METHOD( mod ); ADD_METHOD( code ); ADD_METHOD( roulette ); diff --git a/src/UnlockManager.h b/src/UnlockManager.h index 0ad8fcb305..00c05db643 100644 --- a/src/UnlockManager.h +++ b/src/UnlockManager.h @@ -8,10 +8,8 @@ #include #include "Difficulty.h" #include "SongUtil.h" -#include "CourseUtil.h" class Song; -class Course; class Steps; class Profile; struct lua_State; @@ -37,7 +35,6 @@ enum UnlockRewardType { UnlockRewardType_Song, /**< A song is unlocked. */ UnlockRewardType_Steps, /**< A step pattern for all styles is unlocked. */ UnlockRewardType_Steps_Type, /**< A step pattern for a specific style is unlocked. */ - UnlockRewardType_Course, /**< A course is unlocked. */ UnlockRewardType_Modifier, /**< A modifier is unlocked. */ NUM_UnlockRewardType, UnlockRewardType_Invalid @@ -61,7 +58,7 @@ class UnlockEntry * m_sEntryID starts as an empty string. It will be filled automatically * if not specified. */ UnlockEntry(): m_Type(UnlockRewardType_Invalid), m_cmd(), - m_Song(), m_dc(Difficulty_Invalid), m_Course(), + m_Song(), m_dc(Difficulty_Invalid), m_StepsType(StepsType_Invalid), m_bRequirePassHardSteps(false), m_bRequirePassChallengeSteps(false), m_bRoulette(false), m_sEntryID(RString("")) @@ -76,7 +73,6 @@ class UnlockEntry * these will be non-NULL. */ SongID m_Song; Difficulty m_dc; - CourseID m_Course; StepsType m_StepsType; float m_fRequirement[NUM_UnlockRequirement]; // unlocked if any of of these are met @@ -125,7 +121,6 @@ class UnlockManager int SongIsLocked( const Song *pSong ) const; bool StepsIsLocked( const Song *pSong, const Steps *pSteps ) const; bool StepsTypeIsLocked( const Song *pSong, const Steps *pSteps, const StepsType *pSType ) const; - int CourseIsLocked( const Course *course ) const; bool ModifierIsLocked( const RString &sOneMod ) const; // Gets number of unlocks for title screen @@ -166,7 +161,6 @@ class UnlockManager const UnlockEntry *FindSong( const Song *pSong ) const; const UnlockEntry *FindSteps( const Song *pSong, const Steps *pSteps ) const; const UnlockEntry *FindStepsType( const Song *pSong, const Steps *pSteps, const StepsType *pSType ) const; - const UnlockEntry *FindCourse( const Course *pCourse ) const; const UnlockEntry *FindModifier( const RString &sOneMod ) const; // Lua diff --git a/src/WorkoutGraph.cpp b/src/WorkoutGraph.cpp index 0d00555a35..e69de29bb2 100644 --- a/src/WorkoutGraph.cpp +++ b/src/WorkoutGraph.cpp @@ -1,161 +0,0 @@ -#include "global.h" -#include "WorkoutGraph.h" -#include "RageUtil.h" -#include "ActorUtil.h" -#include "Sprite.h" -#include "Trail.h" -#include "Steps.h" -#include "GameState.h" -#include "ThemeManager.h" -#include "StatsManager.h" -#include "Foreach.h" -#include "Course.h" -#include "Style.h" - -const int MAX_METERS_TO_SHOW = 50; - -REGISTER_ACTOR_CLASS( WorkoutGraph ); - -WorkoutGraph::WorkoutGraph() -{ - m_iSongsChoppedOffAtBeginning = 0; -} - -WorkoutGraph::~WorkoutGraph() -{ - FOREACH( Sprite*, m_vpBars, a ) - delete *a; - m_vpBars.clear(); -} - -void WorkoutGraph::Load() -{ - m_sprEmpty.Load( THEME->GetPathG("WorkoutGraph","empty") ); - this->AddChild( &m_sprEmpty ); -} - -void WorkoutGraph::LoadFromNode( const XNode* pNode ) -{ - ActorFrame::LoadFromNode( pNode ); - - Load(); -} - -void WorkoutGraph::SetFromCurrentWorkout() -{ - SetInternal( 0 ); -} - -void WorkoutGraph::SetInternal( int iMinSongsPlayed ) -{ - FOREACH( Sprite*, m_vpBars, p ) - { - this->RemoveChild( *p ); - delete *p; - } - m_vpBars.clear(); - - Trail *pTrail = GAMESTATE->m_pCurTrail[PLAYER_1]; - if( pTrail == NULL ) - return; - - vector viMeters; - FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) - { - ASSERT( e->pSteps != NULL ); - viMeters.push_back( e->pSteps->GetMeter() ); - } - - int iBlocksWide = viMeters.size(); - int iBlocksHigh = MAX_METER; - - const float fMaxWidth = 300; - float fTotalWidth = SCALE( iBlocksWide, 1.0f, 10.0f, 50.0f, fMaxWidth ); - CLAMP( fTotalWidth, 50, fMaxWidth ); - - const float fMaxHeight = 130; - float fTotalHeight = SCALE( iBlocksHigh, 1.0f, 10.0f, 50.0f, fMaxHeight ); - CLAMP( fTotalHeight, 50, fMaxHeight ); - - float fBlockSize = min( fTotalWidth / iBlocksWide, fTotalHeight / iBlocksHigh ); - - m_sprEmpty.SetVertAlign( align_bottom ); - m_sprEmpty.SetCustomImageRect( RectF(0,0,(float)iBlocksWide,(float)iBlocksHigh) ); - m_sprEmpty.ZoomToWidth( iBlocksWide * fBlockSize ); - m_sprEmpty.ZoomToHeight( iBlocksHigh * fBlockSize ); - - FOREACH_CONST( int, viMeters, iter ) - { - int iIndex = iter - viMeters.begin(); - float fOffsetFromCenter = iIndex - (iBlocksWide-1)/2.0f; - Sprite *p = new Sprite; - p->Load( THEME->GetPathG("WorkoutGraph","bar") ); - p->SetVertAlign( align_bottom ); - p->ZoomToWidth( fBlockSize ); - int iMetersToCover = (MAX_METER - *iter); - p->SetCustomImageRect( RectF(0,(float)iMetersToCover/(float)iBlocksHigh,1,1) ); - p->ZoomToHeight( *iter * fBlockSize ); - p->SetX( fOffsetFromCenter * fBlockSize ); - m_vpBars.push_back( p ); - this->AddChild( p ); - } -} - -void WorkoutGraph::SetFromGameStateAndHighlightSong( int iSongIndex ) -{ - SetInternal( iSongIndex+1 ); - - FOREACH( Sprite*, m_vpBars, spr ) - (*spr)->StopEffect(); - - int iBarIndex = iSongIndex - m_iSongsChoppedOffAtBeginning; - - if( iBarIndex < (int)m_vpBars.size() ) - m_vpBars[iBarIndex]->SetEffectGlowBlink(0.3f, RageColor(1,1,1,0.2f), RageColor(1,1,1,0.8f)); -} - - -// lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the WorkoutGraph. */ -class LunaWorkoutGraph: public Luna -{ -public: - static int SetFromCurrentWorkout( T* p, lua_State *L ) { p->SetFromCurrentWorkout(); COMMON_RETURN_SELF; } - static int SetFromGameStateAndHighlightSong( T* p, lua_State *L ) { p->SetFromGameStateAndHighlightSong(IArg(1)); COMMON_RETURN_SELF; } - - LunaWorkoutGraph() - { - ADD_METHOD( SetFromCurrentWorkout ); - ADD_METHOD( SetFromGameStateAndHighlightSong ); - } -}; - -LUA_REGISTER_DERIVED_CLASS( WorkoutGraph, ActorFrame ) -// lua end - -/* - * (c) 2001-2004 Chris Danford - * 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. - */ diff --git a/src/WorkoutGraph.h b/src/WorkoutGraph.h index bc193ad3ea..e69de29bb2 100644 --- a/src/WorkoutGraph.h +++ b/src/WorkoutGraph.h @@ -1,60 +0,0 @@ -/* WorkoutGraph - A bar graph of the Steps in a Trail. */ - -#ifndef WorkoutGraph_H -#define WorkoutGraph_H - -#include "ActorFrame.h" -#include "Sprite.h" -class Trail; - -class WorkoutGraph : public ActorFrame -{ -public: - WorkoutGraph(); - ~WorkoutGraph(); - virtual WorkoutGraph *Copy() const; - - void Load(); - void LoadFromNode( const XNode* pNode ); - void SetFromCurrentWorkout(); - void SetFromGameStateAndHighlightSong( int iSongIndex ); - - // Lua - void PushSelf( lua_State *L ); - -protected: - void SetInternal( int iNumSongsToShowForCurrentStage ); - void HighlightSong( int iSongIndex ); - - Sprite m_sprEmpty; - vector m_vpBars; - - int m_iSongsChoppedOffAtBeginning; -}; - -#endif - -/* - * (c) 2001-2004 Chris Danford - * 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. - */