From dda77894e84f8557a070a9311532faacf3a721ec Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 27 Jun 2005 04:41:36 +0000 Subject: [PATCH] Remove CourseEntryType. Instead, treat each CourseEntry property as a filter. --- stepmania/src/Course.cpp | 534 ++++++++++++------------ stepmania/src/Course.h | 65 ++- stepmania/src/EditCoursesMenu.cpp | 531 ----------------------- stepmania/src/EditCoursesMenu.h | 135 ------ stepmania/src/EditCoursesSongMenu.cpp | 359 ---------------- stepmania/src/EditCoursesSongMenu.h | 113 ----- stepmania/src/Makefile.am | 4 +- stepmania/src/ScreenEdit.cpp | 4 - stepmania/src/ScreenEditCourseEntry.cpp | 43 +- stepmania/src/ScreenEditCoursesMenu.cpp | 120 ------ stepmania/src/ScreenEditCoursesMenu.h | 56 --- stepmania/src/ScreenJukebox.cpp | 4 +- stepmania/src/StepMania.dsp | 28 +- stepmania/src/StepMania.vcproj | 18 - 14 files changed, 302 insertions(+), 1712 deletions(-) delete mode 100644 stepmania/src/EditCoursesMenu.cpp delete mode 100644 stepmania/src/EditCoursesMenu.h delete mode 100644 stepmania/src/EditCoursesSongMenu.cpp delete mode 100644 stepmania/src/EditCoursesSongMenu.h delete mode 100644 stepmania/src/ScreenEditCoursesMenu.cpp delete mode 100644 stepmania/src/ScreenEditCoursesMenu.h diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 724a6c7541..9ea7de705b 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -23,20 +23,6 @@ #include -static const CString CourseEntryTypeNames[] = { - "Fixed", - "Random", - "RandomWithinGroup", - "Best", - "Worst", -}; -XToString( CourseEntryType, NUM_CourseEntryType ); -XToThemedString( CourseEntryType, NUM_CourseEntryType ); - - -/* Amount to increase meter ranges to make them difficult: */ -const int COURSE_DIFFICULTY_CLASS_CHANGE[NUM_DIFFICULTIES] = { -1, -1, 0, 1, 1 }; - /* Maximum lower value of ranges when difficult: */ const int MAX_BOTTOM_RANGE = 10; @@ -225,36 +211,32 @@ void Course::LoadFromCRSFile( CString sPath ) // infer entry::Type from the first param if( sParams[1].Left(strlen("BEST")) == "BEST" ) { - new_entry.type = COURSE_ENTRY_BEST; - new_entry.players_index = atoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1; - CLAMP( new_entry.players_index, 0, 500 ); + new_entry.iMostPopularIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1; + CLAMP( new_entry.iMostPopularIndex, 0, 500 ); } else if( sParams[1].Left(strlen("WORST")) == "WORST" ) { - new_entry.type = COURSE_ENTRY_WORST; - new_entry.players_index = atoi( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1; - CLAMP( new_entry.players_index, 0, 500 ); + new_entry.iLeastPopularIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1; + CLAMP( new_entry.iLeastPopularIndex, 0, 500 ); } else if( sParams[1] == "*" ) { new_entry.bSecret = true; - new_entry.type = COURSE_ENTRY_RANDOM; } else if( sParams[1].Right(1) == "*" ) { new_entry.bSecret = true; - new_entry.type = COURSE_ENTRY_RANDOM_WITHIN_GROUP; CString sSong = sParams[1]; sSong.Replace( "\\", "/" ); CStringArray bits; split( sSong, "/", bits ); if( bits.size() == 2 ) - new_entry.group_name = bits[0]; + new_entry.sSongGroup = bits[0]; else LOG->Warn( "Course file '%s' contains a random_within_group entry '%s' that is invalid. " "Song should be in the format '/*'.", sPath.c_str(), sSong.c_str()); - if( !SONGMAN->DoesSongGroupExist(new_entry.group_name) ) + if( !SONGMAN->DoesSongGroupExist(new_entry.sSongGroup) ) { /* XXX: We need a place to put "user warnings". This is too loud for info.txt-- * it obscures important warnings--and regular users never look there, anyway. */ @@ -266,8 +248,6 @@ void Course::LoadFromCRSFile( CString sPath ) } else { - new_entry.type = COURSE_ENTRY_FIXED; - CString sSong = sParams[1]; new_entry.pSong = SONGMAN->FindSong( sSong ); @@ -282,18 +262,18 @@ void Course::LoadFromCRSFile( CString sPath ) } } - new_entry.difficulty = StringToDifficulty( sParams[2] ); - if( new_entry.difficulty == DIFFICULTY_INVALID ) + new_entry.baseDifficulty = StringToDifficulty( sParams[2] ); + if( new_entry.baseDifficulty == DIFFICULTY_INVALID ) { - int retval = sscanf( sParams[2], "%d..%d", &new_entry.low_meter, &new_entry.high_meter ); + int retval = sscanf( sParams[2], "%d..%d", &new_entry.iLowMeter, &new_entry.iHighMeter ); if( retval == 1 ) - new_entry.high_meter = new_entry.low_meter; + new_entry.iHighMeter = new_entry.iLowMeter; else if( retval != 2 ) { LOG->Warn("Course file '%s' contains an invalid difficulty setting: \"%s\", 3..6 used instead", sPath.c_str(), sParams[2].c_str()); - new_entry.low_meter = 3; - new_entry.high_meter = 6; + new_entry.iLowMeter = 3; + new_entry.iHighMeter = 6; } } @@ -312,12 +292,12 @@ void Course::LoadFromCRSFile( CString sPath ) else if( !sMod.CompareNoCase("noshowcourse") ) new_entry.bSecret = true; else if( !sMod.CompareNoCase("nodifficult") ) - new_entry.no_difficult = true; + new_entry.bNoDifficult = true; else continue; mods.erase(mods.begin() + j); } - new_entry.modifiers = join( ",", mods ); + new_entry.sModifiers = join( ",", mods ); } new_entry.attacks = attacks; @@ -468,78 +448,73 @@ void Course::Save( CString sPath, bool bSavingCache ) if( j == 0 ) f.PutLine( "#MODS:" ); - CString line; const Attack &a = entry.attacks[j]; - line += ssprintf( " TIME=%.2f:LEN=%.2f:MODS=%s", - a.fStartSecond, a.fSecsRemaining, a.sModifiers.c_str() ); + f.Write( ssprintf( " TIME=%.2f:LEN=%.2f:MODS=%s", + a.fStartSecond, a.fSecsRemaining, a.sModifiers.c_str() ) ); if( j+1 < entry.attacks.size() ) - line += ":"; + f.Write( ":" ); else - line += ";"; - f.PutLine( line ); + f.Write( ";" ); + f.PutLine( "" ); } if( entry.fGainSeconds > 0 ) f.PutLine( ssprintf("#GAINSECONDS:%f;", entry.fGainSeconds) ); - CString line; - switch( entry.type ) + if( entry.iMostPopularIndex != -1 ) { - case COURSE_ENTRY_FIXED: - { - // strip off everything but the group name and song dir - CStringArray as; - ASSERT( entry.pSong != NULL ); - split( entry.pSong->GetSongDir(), "/", as ); - ASSERT( as.size() >= 2 ); - CString sGroup = as[ as.size()-2 ]; - CString sSong = as[ as.size()-1 ]; - line += "#SONG:" + sGroup + '/' + sSong; - } - break; - case COURSE_ENTRY_RANDOM: - line += "#SONG:*"; - break; - case COURSE_ENTRY_RANDOM_WITHIN_GROUP: - line += ssprintf( "#SONG:%s/*", entry.group_name.c_str() ); - break; - case COURSE_ENTRY_BEST: - line += ssprintf( "#SONG:BEST%d", entry.players_index+1 ); - break; - case COURSE_ENTRY_WORST: - line += ssprintf( "#SONG:WORST%d", entry.players_index+1 ); - break; - default: - ASSERT(0); + f.Write( ssprintf( "#SONG:BEST%d", entry.iMostPopularIndex+1 ) ); + } + else if( entry.iLeastPopularIndex != -1 ) + { + f.Write( ssprintf( "#SONG:WORST%d", entry.iLeastPopularIndex+1 ) ); + } + else if( entry.pSong ) + { + // strip off everything but the group name and song dir + CStringArray as; + ASSERT( entry.pSong != NULL ); + split( entry.pSong->GetSongDir(), "/", as ); + ASSERT( as.size() >= 2 ); + CString sGroup = as[ as.size()-2 ]; + CString sSong = as[ as.size()-1 ]; + f.Write( "#SONG:" + sGroup + '/' + sSong ); + } + else if( !entry.sSongGroup.empty() ) + { + f.Write( ssprintf( "#SONG:%s/*", entry.sSongGroup.c_str() ) ); + } + else + { + f.Write( "#SONG:*" ); } - line += ":"; - if( entry.difficulty != DIFFICULTY_INVALID ) - line += DifficultyToString(entry.difficulty); - else if( entry.low_meter != -1 && entry.high_meter != -1 ) - line += ssprintf( "%d..%d", entry.low_meter, entry.high_meter ); - line += ":"; + f.Write( ":" ); + if( entry.baseDifficulty != DIFFICULTY_INVALID ) + f.Write( DifficultyToString(entry.baseDifficulty) ); + else if( entry.iLowMeter != -1 && entry.iHighMeter != -1 ) + f.Write( ssprintf( "%d..%d", entry.iLowMeter, entry.iHighMeter ) ); + f.Write( ":" ); - CString modifiers = entry.modifiers; - bool default_secret = (entry.type == COURSE_ENTRY_RANDOM || entry.type == COURSE_ENTRY_RANDOM_WITHIN_GROUP); - if( default_secret != entry.bSecret ) + CString sModifiers = entry.sModifiers; + bool bDefaultSecret = entry.IsRandomSong(); + if( bDefaultSecret != entry.bSecret ) { - if( modifiers != "" ) - modifiers += ","; - modifiers += entry.bSecret? "noshowcourse":"showcourse"; + if( sModifiers != "" ) + sModifiers += ","; + sModifiers += entry.bSecret? "noshowcourse":"showcourse"; } - if( entry.no_difficult ) + if( entry.bNoDifficult ) { - if( modifiers != "" ) - modifiers += ","; - modifiers += "nodifficult"; + if( sModifiers != "" ) + sModifiers += ","; + sModifiers += "nodifficult"; } - line += modifiers; + f.Write( sModifiers ); - line += ";"; - f.PutLine( line ); + f.PutLine( ";" ); } } @@ -568,17 +543,12 @@ void Course::AutogenEndlessFromGroup( CString sGroupName, Difficulty diff ) // gameplay. (We might still get a repeat at the repeat boundary, // but that'd be rare.) -glenn CourseEntry e; - if( sGroupName != "" ) - e.type = COURSE_ENTRY_RANDOM_WITHIN_GROUP; - else - e.type = COURSE_ENTRY_RANDOM; - - e.group_name = sGroupName; - e.difficulty = diff; + e.sSongGroup = sGroupName; + e.baseDifficulty = diff; e.bSecret = true; vector vSongs; - SONGMAN->GetSongs( vSongs, e.group_name ); + SONGMAN->GetSongs( vSongs, e.sSongGroup ); for( unsigned i = 0; i < vSongs.size(); ++i) m_entries.push_back( e ); } @@ -633,8 +603,7 @@ void Course::AutogenOniFromArtist( CString sArtistName, CString sArtistNameTrans aSongs.erase( aSongs.begin()+4, aSongs.end() ); CourseEntry e; - e.type = COURSE_ENTRY_FIXED; - e.difficulty = dc; + e.baseDifficulty = dc; for( unsigned i = 0; i < aSongs.size(); ++i ) { @@ -648,45 +617,6 @@ bool Course::IsPlayableIn( StepsType st ) const return GetTrail( st ) != NULL; } -static vector GetFilteredBestSongs( StepsType st ) -{ - const vector &vSongsByMostPlayed = SONGMAN->GetBestSongs(); - vector ret; - ret.reserve( vSongsByMostPlayed.size() ); - - for( unsigned i=0; i < vSongsByMostPlayed.size(); ++i ) - { - // filter out long songs and songs that don't have both medium and hard steps - Song* pSong = vSongsByMostPlayed[i]; - if( SONGMAN->GetNumStagesForSong(pSong) > 1 ) - continue; - - const vector& vpSteps = pSong->GetAllSteps(); - - bool FoundMedium = false, FoundHard = false; - FOREACH_CONST( Steps*, vpSteps, pSteps ) - { - if( (*pSteps)->m_StepsType != st ) - continue; - if( !PREFSMAN->m_bAutogenSteps && (*pSteps)->IsAutogen() ) - continue; - - if( (*pSteps)->GetDifficulty() == DIFFICULTY_MEDIUM ) - FoundMedium = true; - else if( (*pSteps)->GetDifficulty() == DIFFICULTY_HARD ) - FoundHard = true; - - if( FoundMedium && FoundHard ) - break; - } - if( !FoundMedium || !FoundHard ) - continue; - - ret.push_back( pSong ); - } - - return ret; -} struct SortTrailEntry { @@ -742,10 +672,14 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const { /* If we have any random entries (so that the seed matters), invalidate the cache. */ bool bHaveRandom = false; - for( unsigned i=0; !bHaveRandom && iIsRandomSong() ) + { bHaveRandom = true; + break; + } + } if( bHaveRandom ) m_TrailCache.clear(); @@ -878,135 +812,189 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) /* Set to true if CourseDifficulty is able to change something. */ bool bCourseDifficultyIsSignificant = (cd == DIFFICULTY_MEDIUM); - for( unsigned i=0; i vpPossibleSongs; + + if( e->pSong ) { - case COURSE_ENTRY_FIXED: - pSong = e.pSong; - if( pSong ) + // Choose an exact song + vpPossibleSongs.push_back( e->pSong ); + } + else + { + vpPossibleSongs = SONGMAN->GetAllSongs(); + + FOREACH( Song*, vpPossibleSongs, song ) { - if( e.difficulty != DIFFICULTY_INVALID ) - pSteps = pSong->GetStepsByDifficulty( st, e.difficulty ); - else if( e.low_meter != -1 && e.high_meter != -1 ) - pSteps = pSong->GetStepsByMeter( st, low_meter, high_meter ); - else - pSteps = pSong->GetStepsByDifficulty( st, DIFFICULTY_MEDIUM ); - } - break; - case COURSE_ENTRY_RANDOM: - case COURSE_ENTRY_RANDOM_WITHIN_GROUP: - { - if( !bShuffledSet ) + // Ignore locked songs when choosing randomly + // TODO: Move Course initialization after UNLOCKMAN is created + if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(*song) ) { - AllSongsShuffled = SONGMAN->GetAllSongs(); - random_shuffle( AllSongsShuffled.begin(), AllSongsShuffled.end(), rnd ); - bShuffledSet = true; + vector::iterator eraseme = song; + song--; + vpPossibleSongs.erase( eraseme ); + continue; } - // find a song with the notes we want - for( unsigned j=0; jIsTutorial() ) { - /* See if the first song matches what we want. */ - ASSERT( unsigned(CurSong) < AllSongsShuffled.size() ); - pSong = AllSongsShuffled[CurSong]; - ASSERT( pSong ); - CurSong = (CurSong+1) % AllSongsShuffled.size(); + vector::iterator eraseme = song; + song--; + vpPossibleSongs.erase( eraseme ); + continue; + } - // Ignore locked songs when choosing randomly - if( UNLOCKMAN->SongIsLocked(pSong) ) - continue; - - // Ignore boring tutorial songs - if( pSong->IsTutorial() ) - continue; - - if( e.type == COURSE_ENTRY_RANDOM_WITHIN_GROUP && - pSong->m_sGroupName.CompareNoCase(e.group_name)) - continue; /* wrong group */ - - if( e.difficulty == DIFFICULTY_INVALID ) - pSteps = pSong->GetStepsByMeter( st, low_meter, high_meter ); - else - pSteps = pSong->GetStepsByDifficulty( st, e.difficulty ); - - if( pSteps ) // found a match - break; // stop searching - - pSong = NULL; - pSteps = NULL; + // Don't allow long songs + if( SONGMAN->GetNumStagesForSong(*song) > 1 ) + { + vector::iterator eraseme = song; + song--; + vpPossibleSongs.erase( eraseme ); + continue; } } - break; - case COURSE_ENTRY_BEST: - case COURSE_ENTRY_WORST: - { - if( !bMostPlayedSet ) - { - bMostPlayedSet = true; - vSongsByMostPlayed = GetFilteredBestSongs( st ); - } - - if( e.players_index >= (int)vSongsByMostPlayed.size() ) - break; - - switch( e.type ) - { - case COURSE_ENTRY_BEST: - pSong = vSongsByMostPlayed[e.players_index]; - break; - case COURSE_ENTRY_WORST: - pSong = vSongsByMostPlayed[vSongsByMostPlayed.size()-1-e.players_index]; - break; - default: - ASSERT(0); - } - - if( e.difficulty == DIFFICULTY_INVALID ) - pSteps = pSong->GetStepsByMeter( st, low_meter, high_meter ); - else - pSteps = pSong->GetStepsByDifficulty( st, e.difficulty ); - - if( pSteps == NULL ) - pSteps = pSong->GetClosestNotes( st, DIFFICULTY_MEDIUM ); - } - break; - default: - ASSERT(0); } - if( !pSong || !pSteps ) + + // Filter out all songs that don't have matching steps + // At the same time, create a list of matching song/steps. + typedef vector StepsVector; + map mapSongToSteps; + FOREACH( Song*, vpPossibleSongs, song ) + { + // Apply song group filter + if( !e->sSongGroup.empty() && (*song)->m_sGroupName != e->sSongGroup ) + { + vector::iterator eraseme = song; + song--; + vpPossibleSongs.erase( eraseme ); + continue; + } + + vector vpMatchingSteps; + (*song)->GetSteps( vpMatchingSteps, st ); + + FOREACH( Steps*, vpMatchingSteps, steps ) + { + if( e->baseDifficulty != DIFFICULTY_INVALID ) + { + Difficulty dc = e->baseDifficulty; + if( (*steps)->GetDifficulty() != dc ) + { + vector::iterator eraseme = steps; + steps--; + vpMatchingSteps.erase( eraseme ); + continue; + } + } + + if( e->iLowMeter != -1 ) + { + if( (*steps)->GetMeter() < e->iLowMeter ) + { + vector::iterator eraseme = steps; + steps--; + vpMatchingSteps.erase( eraseme ); + continue; + } + } + + if( e->iHighMeter != -1 ) + { + if( (*steps)->GetMeter() > e->iHighMeter ) + { + vector::iterator eraseme = steps; + steps--; + vpMatchingSteps.erase( eraseme ); + continue; + } + } + } + + if( vpMatchingSteps.empty() ) + { + vector::iterator eraseme = song; + song--; + vpPossibleSongs.erase( eraseme ); + continue; + } + + mapSongToSteps[*song] = vpMatchingSteps; + } + + + // TODO: Move Course initialization after PROFILEMAN is created + if( PROFILEMAN && e->iMostPopularIndex != -1 ) + { + SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), true ); // descending + if( e->iMostPopularIndex < vpPossibleSongs.size() ) + { + pResolvedSong = vpPossibleSongs[e->iMostPopularIndex]; + vector &vpPossibleSteps = mapSongToSteps[pResolvedSong]; + pResolvedSteps = vpPossibleSteps[0]; + } + } + else if( PROFILEMAN && e->iLeastPopularIndex != -1 ) + { + SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), false ); // ascending + if( e->iLeastPopularIndex < vpPossibleSongs.size() ) + { + pResolvedSong = vpPossibleSongs[e->iLeastPopularIndex]; + vector &vpPossibleSteps = mapSongToSteps[pResolvedSong]; + pResolvedSteps = vpPossibleSteps[0]; + } + } + else + { + if( !vpPossibleSongs.empty() ) + { + random_shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); + pResolvedSong = vpPossibleSongs[0]; + vector &vpPossibleSteps = mapSongToSteps[pResolvedSong]; + if( !vpPossibleSteps.empty() ) + { + random_shuffle( vpPossibleSteps.begin(), vpPossibleSteps.end(), rnd ); + pResolvedSteps = vpPossibleSteps[0]; + } + } + } + + + if( pResolvedSong == NULL || pResolvedSteps == NULL ) continue; // this song entry isn't playable. Skip. - Difficulty dc = pSteps->GetDifficulty(); - if( entry_difficulty != DIFFICULTY_MEDIUM ) + + /* 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 = pResolvedSteps->GetDifficulty(); + int iLowMeter = e->iLowMeter; + int iHighMeter = e->iHighMeter; + if( cd != DIFFICULTY_MEDIUM && !e->bNoDifficult ) { - /* See if we can find a NoteData after adjusting the difficulty by COURSE_DIFFICULTY_CLASS_CHANGE. - * If we can't, just use the one we already have. */ - Difficulty new_dc = Difficulty( dc + COURSE_DIFFICULTY_CLASS_CHANGE[entry_difficulty] ); - new_dc = clamp( new_dc, DIFFICULTY_BEGINNER, DIFFICULTY_CHALLENGE ); + Difficulty 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 = pSong->GetStepsByDifficulty( st, new_dc ); + Steps* pNewSteps = pResolvedSong->GetStepsByDifficulty( st, new_dc ); if( pNewSteps ) { dc = new_dc; - pSteps = pNewSteps; + pResolvedSteps = pNewSteps; bChangedDifficulty = true; bCourseDifficultyIsSignificant = true; } @@ -1019,40 +1007,43 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) * 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.difficulty == DIFFICULTY_INVALID && bChangedDifficulty ) + if( e->baseDifficulty == DIFFICULTY_INVALID && bChangedDifficulty ) { /* Minimum and maximum to add to make the meter range contain the actual * meter: */ - int iMinDist = pSteps->GetMeter() - high_meter; - int iMaxDist = pSteps->GetMeter() - low_meter; + int iMinDist = pResolvedSteps->GetMeter() - iHighMeter; + int iMaxDist = pResolvedSteps->GetMeter() - iLowMeter; /* Clamp the possible adjustments to try to avoid going under 1 or over * MAX_BOTTOM_RANGE. */ - iMinDist = min( max( iMinDist, -low_meter+1 ), iMaxDist ); - iMaxDist = max( min( iMaxDist, MAX_BOTTOM_RANGE-high_meter ), iMinDist ); + 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 = rnd(iMaxDist-iMinDist) + iMinDist; - low_meter += iAdd; - high_meter += iAdd; + iLowMeter += iAdd; + iHighMeter += iAdd; } } TrailEntry te; - te.pSong = pSong; - te.pSteps = pSteps; - te.Modifiers = e.modifiers; - te.Attacks = e.attacks; - te.bSecret = e.bSecret; - te.iLowMeter = low_meter; - te.iHighMeter = high_meter; + te.pSong = pResolvedSong; + te.pSteps = pResolvedSteps; + 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.difficulty == DIFFICULTY_INVALID ) + if( e->baseDifficulty == DIFFICULTY_INVALID ) + { te.dc = DIFFICULTY_INVALID; + } else { /* Otherwise, store the actual difficulty we got (post-course-difficulty). @@ -1107,7 +1098,7 @@ bool Course::HasMods() const { FOREACH_CONST( CourseEntry, m_entries, e ) { - if( !e->modifiers.empty() || !e->attacks.empty() ) + if( !e->sModifiers.empty() || !e->attacks.empty() ) return true; } @@ -1118,7 +1109,7 @@ bool Course::AllSongsAreFixed() const { FOREACH_CONST( CourseEntry, m_entries, e ) { - if( e->type != COURSE_ENTRY_FIXED ) + if( e->pSong == NULL ) return false; } return true; @@ -1203,7 +1194,7 @@ bool Course::IsFixed() const { for(unsigned i = 0; i < m_entries.size(); i++) { - if ( m_entries[i].type == COURSE_ENTRY_FIXED ) + if ( m_entries[i].pSong == NULL ) continue; return false; @@ -1226,14 +1217,12 @@ bool Course::GetTotalSeconds( StepsType st, float& fSecondsOut ) const bool Course::CourseHasBestOrWorst() const { - for(unsigned i = 0; i < m_entries.size(); i++) + FOREACH_CONST( CourseEntry, m_entries, e ) { - switch( m_entries[i].type ) - { - case COURSE_ENTRY_BEST: - case COURSE_ENTRY_WORST: + if( e->iMostPopularIndex != -1 ) + return true; + if( e->iLeastPopularIndex != -1 ) return true; - } } return false; @@ -1251,7 +1240,7 @@ void Course::UpdateCourseStats( StepsType st ) // courses with random/players best-worst songs should go at the end for(unsigned i = 0; i < m_entries.size(); i++) { - if ( m_entries[i].type == COURSE_ENTRY_FIXED ) + if ( m_entries[i].pSong != NULL ) continue; if ( m_SortOrder_Ranking == 2 ) @@ -1288,11 +1277,10 @@ bool Course::IsRanking() const const CourseEntry *Course::FindFixedSong( const Song *pSong ) const { - for( unsigned i = 0; i < m_entries.size(); ++i ) + FOREACH_CONST( CourseEntry, m_entries, e ) { - const CourseEntry *pEntry = &m_entries[i]; - if( pEntry->type == COURSE_ENTRY_FIXED && pEntry->pSong == pSong ) - return pEntry; + if( e->pSong == pSong ) + return e; } return NULL; diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index b247cda2cd..3111a12053 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -32,50 +32,49 @@ inline PlayMode CourseTypeToPlayMode( CourseType ct ) { return (PlayMode)(PLAY_M inline CourseType PlayModeToCourseType( PlayMode pm ) { return (CourseType)(pm-PLAY_MODE_NONSTOP); } -enum CourseEntryType -{ - COURSE_ENTRY_FIXED, - COURSE_ENTRY_RANDOM, - COURSE_ENTRY_RANDOM_WITHIN_GROUP, - COURSE_ENTRY_BEST, - COURSE_ENTRY_WORST, - NUM_CourseEntryType // leave this at the end -}; -#define FOREACH_CourseEntryType( i ) FOREACH_ENUM( CourseEntryType, NUM_CourseEntryType, i ) -const CString &CourseEntryTypeToString( CourseEntryType cet ); -const CString &CourseEntryTypeToThemedString( CourseEntryType cet ); - - class CourseEntry { public: - CourseEntryType type; - bool bSecret; // show "??????" - Song* pSong; // used in type=fixed - CString group_name; // used in type=random_within_group - Difficulty difficulty; // = DIFFICULTY_INVALID if no difficulty specified - bool no_difficult; // if true, difficult course setting doesn't affect this entry - int low_meter; // = -1 if no meter range specified - int high_meter; // = -1 if no meter range specified - int players_index; // ignored if type isn't 'best' or 'worst' - CString modifiers; // set player and song options using these - AttackArray attacks; // timed modifiers + bool bSecret; // show "??????" instead of an exact song + + // filter criteria, applied from top to bottom + Song* pSong; // don't filter if NULL + CString sSongGroup; // don't filter if empty + Difficulty baseDifficulty; // don't filter if DIFFICULTY_INVALID + bool bNoDifficult; // if true, CourseDifficulty doesn't affect this entry + int iLowMeter; // don't filter if -1 + int iHighMeter; // don't filter if -1 + int iMostPopularIndex; // don't filter if -1 + int iLeastPopularIndex; // don't filter if -1 + + CString 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. CourseEntry() { - type = (CourseEntryType)0; bSecret = false; + pSong = NULL; - group_name = ""; - difficulty = DIFFICULTY_INVALID; - no_difficult = false; - low_meter = -1; - high_meter = -1; - players_index = 0; - modifiers = ""; + sSongGroup = ""; + baseDifficulty = DIFFICULTY_INVALID; + bNoDifficult = false; + iLowMeter = -1; + iHighMeter = -1; + iMostPopularIndex = -1; + iLeastPopularIndex = -1; + + sModifiers = ""; fGainSeconds = 0; } + + bool IsRandomSong() const + { + return + iMostPopularIndex == -1 && + iLeastPopularIndex == -1 && + pSong == NULL; + } }; class Course diff --git a/stepmania/src/EditCoursesMenu.cpp b/stepmania/src/EditCoursesMenu.cpp deleted file mode 100644 index f4927f727c..0000000000 --- a/stepmania/src/EditCoursesMenu.cpp +++ /dev/null @@ -1,531 +0,0 @@ -#include "global.h" -#include "EditCoursesMenu.h" -#include "RageLog.h" -#include "SongManager.h" -#include "GameState.h" -#include "ThemeManager.h" -#include "GameManager.h" -#include "Steps.h" -#include "song.h" -#include "Course.h" -#include "ScreenMiniMenu.h" -#include "ScreenManager.h" -#include "PlayerState.h" -#include "ScreenPlayerOptions.h" // for SM_BackFromPlayerOptions -#include "ScreenSongOptions.h" // for SM_BackFromSongOptions - -// -// Defines specific to EditCoursesMenu -// -#define ARROWS_X( i ) THEME->GetMetricF("EditCoursesMenu",ssprintf("Arrows%dX",i+1)) -#define COURSE_BANNER_X THEME->GetMetricF("EditCoursesMenu","CourseBannerX") -#define COURSE_BANNER_Y THEME->GetMetricF("EditCoursesMenu","CourseBannerY") -#define COURSE_BANNER_WIDTH THEME->GetMetricF("EditCoursesMenu","CourseBannerWidth") -#define COURSE_BANNER_HEIGHT THEME->GetMetricF("EditCoursesMenu","CourseBannerHeight") -#define COURSE_TEXT_BANNER_X THEME->GetMetricF("EditCoursesMenu","CourseTextBannerX") -#define COURSE_TEXT_BANNER_Y THEME->GetMetricF("EditCoursesMenu","CourseTextBannerY") -#define ENTRY_BANNER_X THEME->GetMetricF("EditCoursesMenu","EntryBannerX") -#define ENTRY_BANNER_Y THEME->GetMetricF("EditCoursesMenu","EntryBannerY") -#define ENTRY_BANNER_WIDTH THEME->GetMetricF("EditCoursesMenu","EntryBannerWidth") -#define ENTRY_BANNER_HEIGHT THEME->GetMetricF("EditCoursesMenu","EntryBannerHeight") -#define ENTRY_TEXT_BANNER_X THEME->GetMetricF("EditCoursesMenu","EntryTextBannerX") -#define ENTRY_TEXT_BANNER_Y THEME->GetMetricF("EditCoursesMenu","EntryTextBannerY") -#define ROW_LABELS_X THEME->GetMetricF("EditCoursesMenu","RowLabelsX") -#define ROW_VALUE_X( i ) THEME->GetMetricF("EditCoursesMenu",ssprintf("RowValue%dX",i+1)) -#define ROW_Y( i ) THEME->GetMetricF("EditCoursesMenu",ssprintf("Row%dY",i+1)) - -AutoScreenMessage( SM_BackFromCourseOptionsMenu ) - -enum CourseEntryMenuRow -{ - repeat, - randomize, - lives, -}; - -static Menu g_CourseOptionsMenu( - "ScreenMiniMenuCourseOptions", - MenuRow( repeat, "Repeat", true, EDIT_MODE_FULL, 0, "NO","YES" ), - MenuRow( randomize, "Randomize", true, EDIT_MODE_FULL, 0, "NO","YES" ), - MenuRow( lives, "Lives", true, EDIT_MODE_FULL, 4, "Use Bar Life","1","2","3","4","5","6","7","8","9","10" ) -); - -enum CourseOptionsMenuRow -{ - song, - group, - difficulty, - low_meter, - high_meter, - best_worst_value, - NUM_ENTRY_OPTIONS_MENU_ROWS -}; - - - -const bool g_bRowEnabledForType[NUM_CourseEntryType][NUM_ENTRY_OPTIONS_MENU_ROWS] = -{ // song, group, difficulty, low_meter, high_meter, best_worst - /* fixed */ { true, false, true, true, true, false }, - /* random */ { false, false, true, true, true, false }, - /* random_group */{ false, true, true, true, true, false }, - /* best */ { false, false, false, false, false, true }, - /* worst */ { false, false, false, false, false, true } -}; - - -EditCoursesMenu::EditCoursesMenu() -{ - LOG->Trace( "ScreenEditCoursesMenu::ScreenEditCoursesMenu()" ); - - m_bInSongMenu = false; - - for( int i=0; i<2; i++ ) - { - m_sprArrows[i].Load( THEME->GetPathG("EditCoursesMenu",i==0?"left":"right") ); - m_sprArrows[i].SetX( ARROWS_X(i) ); - this->AddChild( &m_sprArrows[i] ); - } - - m_SelectedRow = (Row)0; - - ZERO( m_iSelection ); - - - for( int i=0; iGetPathF("Common","title") ); - m_textLabel[i].SetXY( ROW_LABELS_X, ROW_Y(i) ); - m_textLabel[i].SetText( RowToString((Row)i) ); - m_textLabel[i].SetZoom( 0.8f ); - m_textLabel[i].SetHorizAlign( Actor::align_left ); - this->AddChild( &m_textLabel[i] ); - - m_textValue[i].LoadFromFont( THEME->GetPathF("Common","normal") ); - m_textValue[i].SetXY( ROW_VALUE_X(i), ROW_Y(i) ); - m_textValue[i].SetText( "blah" ); - m_textValue[i].SetZoom( 0.6f ); - this->AddChild( &m_textValue[i] ); - } - - m_CourseBanner.SetXY( COURSE_BANNER_X, COURSE_BANNER_Y ); - this->AddChild( &m_CourseBanner ); - - m_EntryBanner.SetXY( ENTRY_BANNER_X, ENTRY_BANNER_Y ); - this->AddChild( &m_EntryBanner ); - - m_EntryTextBanner.SetName( "TextBanner" ); - m_EntryTextBanner.SetXY( ENTRY_TEXT_BANNER_X, ENTRY_TEXT_BANNER_Y ); - this->AddChild( &m_EntryTextBanner ); - - - m_soundChangeRow.Load( THEME->GetPathS("EditCoursesMenu","row") ); - m_soundChangeValue.Load( THEME->GetPathS("EditCoursesMenu","value") ); - m_soundSave.Load( THEME->GetPathS("EditCoursesMenu","save") ); - - - // fill in data structures - SONGMAN->GetAllCourses( m_pCourses, false ); - - ChangeToRow( (Row)0 ); - OnRowValueChanged( (Row)0 ); -} - -EditCoursesMenu::~EditCoursesMenu() -{ - -} - -void EditCoursesMenu::DrawPrimitives() -{ - if( m_bInSongMenu ) - m_SongMenu.Draw(); - else - ActorFrame::DrawPrimitives(); -} - -void EditCoursesMenu::Update( float fDeltaTime ) -{ - if( m_bInSongMenu ) - m_SongMenu.Update( fDeltaTime ); - else - ActorFrame::Update( fDeltaTime ); -} - -bool EditCoursesMenu::CanGoUp() -{ - return m_SelectedRow != 0; -} - -bool EditCoursesMenu::CanGoDown() -{ - return m_SelectedRow != NUM_ROWS-1; -} - -bool EditCoursesMenu::CanGoLeft() -{ - return m_iSelection[m_SelectedRow] != 0; -} - -bool EditCoursesMenu::CanGoRight() -{ - int num_values[NUM_ROWS] = - { - m_pCourses.size(), - 1, - NUM_ACTIONS, - (int)GetSelectedCourse()->m_entries.size(), - NUM_CourseEntryType, - 1, - 1, - 1 - }; - - return m_iSelection[m_SelectedRow] != (num_values[m_SelectedRow]-1); -} - -void EditCoursesMenu::Up() -{ - if( m_bInSongMenu ) - { - m_SongMenu.Up(); - return; - } - - if( CanGoUp() ) - { - ChangeToRow( Row(m_SelectedRow-1) ); - m_soundChangeRow.Play(); - } -} - -void EditCoursesMenu::Down() -{ - if( m_bInSongMenu ) - { - m_SongMenu.Down(); - return; - } - - if( CanGoDown() ) - { - ChangeToRow( Row(m_SelectedRow+1) ); - m_soundChangeRow.Play(); - } -} - -void EditCoursesMenu::Left() -{ - if( m_bInSongMenu ) - { - m_SongMenu.Left(); - return; - } - - if( CanGoLeft() ) - { - m_iSelection[m_SelectedRow]--; - - switch( m_SelectedRow ) - { - case ROW_ENTRY_TYPE: - GetSelectedEntry()->type = GetSelectedEntryType(); - break; - } - - OnRowValueChanged( m_SelectedRow ); - m_soundChangeValue.Play(); - } -} - -void EditCoursesMenu::Right() -{ - if( m_bInSongMenu ) - { - m_SongMenu.Right(); - return; - } - - if( CanGoRight() ) - { - m_iSelection[m_SelectedRow]++; - - switch( m_SelectedRow ) - { - case ROW_ENTRY_TYPE: - GetSelectedEntry()->type = GetSelectedEntryType(); - break; - } - - OnRowValueChanged( m_SelectedRow ); - m_soundChangeValue.Play(); - } -} - -void EditCoursesMenu::Start() -{ - if( m_bInSongMenu ) - { - m_SongMenu.SaveToCourseEntry( GetSelectedEntry() ); - m_bInSongMenu = false; - OnRowValueChanged( ROW_ENTRY ); - return; - } - - Course* pCourse = GetSelectedCourse(); - CourseEntry* pEntry = GetSelectedEntry(); - - switch( m_SelectedRow ) - { - case ROW_COURSE_OPTIONS: - g_CourseOptionsMenu.rows[repeat].iDefaultChoice = pCourse->m_bRepeat ? 1 : 0; - g_CourseOptionsMenu.rows[randomize].iDefaultChoice = pCourse->m_bRandomize ? 1 : 0; - g_CourseOptionsMenu.rows[lives].iDefaultChoice = pCourse->m_iLives; - if( g_CourseOptionsMenu.rows[lives].iDefaultChoice == -1 ) - g_CourseOptionsMenu.rows[lives].iDefaultChoice = 0; - SCREENMAN->MiniMenu( &g_CourseOptionsMenu, SM_BackFromCourseOptionsMenu ); - break; - case ROW_ACTION: - switch( GetSelectedAction() ) - { - case save: - m_soundSave.Play(); - pCourse->Save(); - SCREENMAN->SystemMessage( "Course saved." ); - break; - case add_entry: - SCREENMAN->PlayStartSound(); - pCourse->m_entries.insert( pCourse->m_entries.begin()+m_iSelection[ROW_ENTRY], pCourse->m_entries[m_iSelection[ROW_ENTRY]] ); - OnRowValueChanged( ROW_ENTRY ); - break; - case delete_selected_entry: - if( pCourse->m_entries.size() == 1 ) - { - SCREENMAN->PlayInvalidSound(); - SCREENMAN->SystemMessage( "Cannot delete the last entry from a course" ); - break; - } - - SCREENMAN->PlayStartSound(); - pCourse->m_entries.erase( pCourse->m_entries.begin()+m_iSelection[ROW_ENTRY] ); - CLAMP( m_iSelection[ROW_ENTRY], 0, (int) pCourse->m_entries.size()-1 ); - OnRowValueChanged( ROW_ENTRY ); - break; - default: - ASSERT(0); - } - - OnRowValueChanged( ROW_ENTRY ); - break; - case ROW_ENTRY_OPTIONS: - m_SongMenu.LoadFromCourseEntry( GetSelectedEntry() ); - m_bInSongMenu = true; - break; - case ROW_ENTRY_PLAYER_OPTIONS: - SCREENMAN->PlayStartSound(); - - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions = PlayerOptions(); - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.FromString( pEntry->modifiers ); - - SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions" ); - break; - case ROW_ENTRY_SONG_OPTIONS: - SCREENMAN->PlayStartSound(); - - GAMESTATE->m_SongOptions = SongOptions(); - GAMESTATE->m_SongOptions.FromString( pEntry->modifiers ); - - SCREENMAN->AddNewScreenToTop( "ScreenSongOptions" ); - break; - default: - SCREENMAN->PlayInvalidSound(); - return; - } -} - - -void EditCoursesMenu::HandleScreenMessage( const ScreenMessage SM ) -{ - Course* pCourse = GetSelectedCourse(); - CourseEntry* pEntry = GetSelectedEntry(); - - if( SM == SM_BackFromCourseOptionsMenu ) - { - pCourse->m_bRepeat = !!ScreenMiniMenu::s_viLastAnswers[repeat]; - pCourse->m_bRandomize = !!ScreenMiniMenu::s_viLastAnswers[randomize]; - pCourse->m_iLives = ScreenMiniMenu::s_viLastAnswers[lives]; - if( pCourse->m_iLives == 0 ) - pCourse->m_iLives = -1; - - OnRowValueChanged( ROW_COURSE_OPTIONS ); - } - else if( - SM == SM_BackFromPlayerOptions || - SM == SM_BackFromSongOptions ) - { - // coming back from PlayerOptions or SongOptions - pEntry->modifiers = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetString() + "," + GAMESTATE->m_SongOptions.GetString(); - OnRowValueChanged( ROW_ENTRY_PLAYER_OPTIONS ); - } -} - -void EditCoursesMenu::ChangeToRow( Row newRow ) -{ - m_SelectedRow = newRow; - - for( int i=0; i<2; i++ ) - m_sprArrows[i].SetY( ROW_Y(newRow) ); - m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[0].EnableAnimation( CanGoLeft() ); - m_sprArrows[1].EnableAnimation( CanGoRight() ); -} - -void EditCoursesMenu::OnRowValueChanged( Row row ) -{ - LOG->Trace( "EditCoursesMenu::OnRowValueChanged(%i)", row ); - - m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[0].EnableAnimation( CanGoLeft() ); - m_sprArrows[1].EnableAnimation( CanGoRight() ); - - Course* pCourse = GetSelectedCourse(); - CourseEntry* pEntry = GetSelectedEntry(); - - switch( row ) - { - case ROW_COURSE: - CHECKPOINT; - m_textValue[ROW_COURSE].SetText( pCourse->GetDisplayFullTitle() ); - m_CourseBanner.LoadFromCourse( pCourse ); - m_CourseBanner.ScaleToClipped( COURSE_BANNER_WIDTH, COURSE_BANNER_HEIGHT ); - m_iSelection[ROW_ENTRY] = 0; - pEntry = GetSelectedEntry(); - if( pEntry == NULL ) - { - CourseEntry ce; - const vector &apSongs = SONGMAN->GetAllSongs(); - ASSERT( !apSongs.empty() ); - ce.pSong = apSongs[0]; - pCourse->m_entries.push_back( ce ); - pEntry = GetSelectedEntry(); - } - // fall through - case ROW_COURSE_OPTIONS: - CHECKPOINT; - m_textValue[ROW_COURSE_OPTIONS].SetText( - ssprintf( - "(START) %s, %s, ", - pCourse->m_bRepeat ? "repeat" : "no repeat", - pCourse->m_bRandomize ? "randomize" : "no randomize" ) + - ssprintf( - (pCourse->m_iLives==-1) ? "use bar life" : "%d lives", - pCourse->m_iLives ) ); - // fall through - case ROW_ACTION: - CHECKPOINT; - m_textValue[ROW_ACTION].SetText( "(START) " + ActionToString(GetSelectedAction()) ); - // fall through - case ROW_ENTRY: - CHECKPOINT; - m_textValue[ROW_ENTRY].SetText( ssprintf("%d of %d",m_iSelection[ROW_ENTRY]+1, (int)GetSelectedCourse()->m_entries.size()) ); - m_iSelection[ROW_ENTRY_TYPE] = pEntry->type; - // fall through - case ROW_ENTRY_TYPE: - CHECKPOINT; - m_textValue[ROW_ENTRY_TYPE].SetText( pEntry ? CourseEntryTypeToString(pEntry->type) : CString("(none)") ); - // fall through - case ROW_ENTRY_OPTIONS: - CHECKPOINT; - { - CStringArray as; - const bool *bShow = g_bRowEnabledForType[GetSelectedEntry()->type]; - - if( bShow[song] ) - as.push_back( pEntry->pSong ? pEntry->pSong->GetTranslitFullTitle() : CString("(missing song)") ); - if( bShow[group] ) - as.push_back( pEntry->group_name.empty() ? CString("(no group)") : pEntry->group_name ); - if( bShow[difficulty] ) - if( pEntry->difficulty != DIFFICULTY_INVALID ) - as.push_back( DifficultyToString(pEntry->difficulty) ); - if( bShow[low_meter] ) - if( pEntry->low_meter > 0 ) - as.push_back( ssprintf("low meter %d", pEntry->low_meter) ); - if( bShow[high_meter] ) - if( pEntry->high_meter > 0 ) - as.push_back( ssprintf("high meter %d", pEntry->high_meter) ); - if( bShow[best_worst_value] ) - if( pEntry->players_index != -1 ) - as.push_back( ssprintf("rank %d", pEntry->players_index+1) ); - - m_textValue[ROW_ENTRY_OPTIONS].SetText( "(START) " + join(", ",as) ); - } - // fall through - case ROW_ENTRY_PLAYER_OPTIONS: - CHECKPOINT; - { - CString s = "(START) "; - - PlayerOptions po; - po.FromString( pEntry->modifiers ); - if( po.GetString().empty() ) - s += "(none)"; - else - s += po.GetString(); - - m_textValue[ROW_ENTRY_PLAYER_OPTIONS].SetText( s ); - } - // fall through - case ROW_ENTRY_SONG_OPTIONS: - CHECKPOINT; - { - CString s = "(START) "; - - SongOptions so; - so.FromString( pEntry->modifiers ); - if( so.GetString().empty() ) - s += "(none)"; - else - s += so.GetString(); - - m_textValue[ROW_ENTRY_SONG_OPTIONS].SetText( s ); - } - break; - default: - ASSERT(0); // invalid row - } -} - -CourseEntry* EditCoursesMenu::GetSelectedEntry() -{ - Course* pCourse = GetSelectedCourse(); - if( m_iSelection[ROW_ENTRY] < int(pCourse->m_entries.size()) ) - return &pCourse->m_entries[m_iSelection[ROW_ENTRY]]; - else - return NULL; -} - -/* - * (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/stepmania/src/EditCoursesMenu.h b/stepmania/src/EditCoursesMenu.h deleted file mode 100644 index 9911668baf..0000000000 --- a/stepmania/src/EditCoursesMenu.h +++ /dev/null @@ -1,135 +0,0 @@ -/* EditCoursesMenu - UI on Edit Courses screen. */ - -#ifndef EDIT_COURSES_MENU_H -#define EDIT_COURSES_MENU_H - -#include "ActorFrame.h" -#include "Banner.h" -#include "TextBanner.h" -#include "GameConstantsAndTypes.h" -#include "RageSound.h" -#include "Course.h" -#include "ScreenMessage.h" -#include "EditCoursesSongMenu.h" - -class EditCoursesMenu: public ActorFrame -{ -public: - EditCoursesMenu(); - ~EditCoursesMenu(); - virtual void DrawPrimitives(); - virtual void Update( float fDeltaTime ); - - bool CanGoUp(); - bool CanGoDown(); - bool CanGoLeft(); - bool CanGoRight(); - - void Up(); - void Down(); - void Left(); - void Right(); - void Start(); - void HandleScreenMessage( const ScreenMessage SM ); - - enum Row - { - ROW_COURSE, - ROW_COURSE_OPTIONS, - ROW_ACTION, - ROW_ENTRY, - ROW_ENTRY_TYPE, - ROW_ENTRY_OPTIONS, - ROW_ENTRY_PLAYER_OPTIONS, - ROW_ENTRY_SONG_OPTIONS, - NUM_ROWS - } m_SelectedRow; - CString RowToString( Row r ) - { - const CString s[NUM_ROWS] = - { - "Course", - "Course Options", - "Action", - "Entry", - "Entry Type", - "Entry Options", - "Entry Player Options", - "Entry Song Options" - }; - return s[r]; - } - - enum Action - { - save, - add_entry, - delete_selected_entry, - NUM_ACTIONS - }; - CString ActionToString( Action a ) - { - switch( a ) - { - case save: return "Save Current Course"; - case add_entry: return "Duplicate Current Entry/Add Entry"; - case delete_selected_entry: return "Delete Selected Entry"; - default: ASSERT(0); return ""; - } - } - - Course* GetSelectedCourse() { return m_pCourses[m_iSelection[ROW_COURSE]]; } - CourseEntry* GetSelectedEntry(); - Action GetSelectedAction() { return (Action)m_iSelection[ROW_ACTION]; } - CourseEntryType GetSelectedEntryType() { return (CourseEntryType)m_iSelection[ROW_ENTRY_TYPE]; } - -private: - Sprite m_sprArrows[2]; - - int m_iSelection[NUM_ROWS]; - BitmapText m_textLabel[NUM_ROWS]; - BitmapText m_textValue[NUM_ROWS]; - - Banner m_CourseBanner; - Banner m_EntryBanner; - TextBanner m_EntryTextBanner; - - vector m_pCourses; - - void OnRowValueChanged( Row row ); - void ChangeToRow( Row newRow ); - - RageSound m_soundChangeRow; - RageSound m_soundChangeValue; - RageSound m_soundSave; - - EditCoursesSongMenu m_SongMenu; - bool m_bInSongMenu; -}; - -#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/stepmania/src/EditCoursesSongMenu.cpp b/stepmania/src/EditCoursesSongMenu.cpp deleted file mode 100644 index ea7b818586..0000000000 --- a/stepmania/src/EditCoursesSongMenu.cpp +++ /dev/null @@ -1,359 +0,0 @@ -#include "global.h" -#include "EditCoursesSongMenu.h" -#include "RageLog.h" -#include "SongManager.h" -#include "GameState.h" -#include "ThemeManager.h" -#include "GameManager.h" -#include "Steps.h" -#include "song.h" -#include "Course.h" -#include "ScreenManager.h" - -#define ARROWS_X( i ) THEME->GetMetricF("EditCoursesSongMenu",ssprintf("Arrows%dX",i+1)) -#define ROW_LABELS_X THEME->GetMetricF("EditCoursesSongMenu","RowLabelsX") -#define ROW_VALUE_X( i ) THEME->GetMetricF("EditCoursesSongMenu",ssprintf("RowValue%dX",i+1)) -#define ROW_Y( i ) THEME->GetMetricF("EditCoursesSongMenu",ssprintf("Row%dY",i+1)) - - -const bool g_bRowEnabledForType[NUM_CourseEntryType][EditCoursesSongMenu::NUM_ROWS] = -{ // group, song, type, difficulty, low_meter, high_meter, best_worst - /* fixed */ { true, true, true, true, true, true, false }, - /* random */ { false, false, true, true, true, true, false }, - /* random_group */{ true, false, true, true, true, true, false }, - /* best */ { false, false, true, false, false, false, true }, - /* worst */ { false, false, true, false, false, false, true } -}; - -EditCoursesSongMenu::EditCoursesSongMenu() -{ - LOG->Trace( "ScreenEditCoursesSongMenu::ScreenEditCoursesSongMenu()" ); - - for( int i=0; i<2; i++ ) - { - m_sprArrows[i].Load( THEME->GetPathG("EditCoursesSongMenu",i==0?"left":"right") ); - m_sprArrows[i].SetX( ARROWS_X(i) ); - this->AddChild( &m_sprArrows[i] ); - } - - for( int i=0; iGetPathF("Common","title") ); - m_textLabel[i].SetXY( ROW_LABELS_X, ROW_Y(i) ); - m_textLabel[i].SetText( RowToString((Row)i) ); - m_textLabel[i].SetZoom( 0.8f ); - m_textLabel[i].SetHorizAlign( Actor::align_left ); - this->AddChild( &m_textLabel[i] ); - - m_textValue[i].LoadFromFont( THEME->GetPathF("Common","normal") ); - m_textValue[i].SetXY( ROW_VALUE_X(i), ROW_Y(i) ); - m_textValue[i].SetText( "blah" ); - m_textValue[i].SetZoom( 0.6f ); - this->AddChild( &m_textValue[i] ); - } - - - m_soundChangeRow.Load( THEME->GetPathS("EditCoursesSongMenu","row") ); - m_soundChangeValue.Load( THEME->GetPathS("EditCoursesSongMenu","value") ); - - // fill in data structures - SONGMAN->GetSongGroupNames( m_aGroups ); - - m_SelectedRow = (Row)0; -} - - -EditCoursesSongMenu::~EditCoursesSongMenu() -{ - -} - -bool EditCoursesSongMenu::CanGoLeft() -{ - return m_iSelection[m_SelectedRow] != 0; -} - -bool EditCoursesSongMenu::CanGoRight() -{ - int num_values[NUM_ROWS] = - { - m_aGroups.size(), - m_aSongs.size(), - NUM_CourseEntryType, - NUM_DIFFICULTIES+1, - 11, - 11, - 40, - }; - - return m_iSelection[m_SelectedRow] != (num_values[m_SelectedRow]-1); -} - -bool EditCoursesSongMenu::ChangeRow( int add ) -{ - Row dest = m_SelectedRow; - do - { - dest = (Row) (dest+add); - } - while( dest >= 0 && dest < NUM_ROWS && !g_bRowEnabledForType[GetSelectedType()][dest] ); - - if( dest < 0 || dest >= NUM_ROWS ) - return false; - - ChangeToRow( dest ); - return true; -} - -void EditCoursesSongMenu::Up() -{ - if( ChangeRow( -1 ) ) - m_soundChangeRow.Play(); -} - -void EditCoursesSongMenu::Down() -{ - if( ChangeRow( +1 ) ) - m_soundChangeRow.Play(); -} - -void EditCoursesSongMenu::SaveToCourseEntry( CourseEntry *pEntry ) -{ - *pEntry = CourseEntry(); - pEntry->type = (CourseEntryType) m_iSelection[ROW_TYPE]; - - /* Only set things relevant to this type. */ - if( g_bRowEnabledForType[pEntry->type][ROW_GROUP] ) - pEntry->group_name = GetSelectedGroup(); - if( g_bRowEnabledForType[pEntry->type][ROW_SONG] ) - pEntry->pSong = GetSelectedSong(); - if( g_bRowEnabledForType[pEntry->type][ROW_DIFFICULTY] ) - pEntry->difficulty = GetSelectedDifficulty(); - if( g_bRowEnabledForType[pEntry->type][ROW_LOW_METER] ) - pEntry->low_meter = GetLowMeter(); - if( g_bRowEnabledForType[pEntry->type][ROW_HIGH_METER] ) - pEntry->high_meter = GetHighMeter(); - if( g_bRowEnabledForType[pEntry->type][ROW_BEST_WORST_VALUE] ) - pEntry->players_index = GetBestWorst(); - - if( pEntry->high_meter < pEntry->low_meter ) - swap( pEntry->low_meter, pEntry->high_meter ); -} - -//void EditCoursesSongMenu::SetSongsFromGroup( const CourseEntry *pEntry ) - -void EditCoursesSongMenu::SetGroupByName( CString sGroup ) -{ - unsigned i; - for( i = 0; i < m_aGroups.size(); ++i ) - if( !sGroup.CompareNoCase( m_aGroups[i] ) ) - break; - ASSERT_M( i < m_aGroups.size(), ssprintf("%s", sGroup.c_str() ) ); - m_iSelection[ROW_GROUP] = i; - - UpdateSongList(); -} - -void EditCoursesSongMenu::UpdateSongList() -{ - CString sGroup = GetSelectedGroup(); - - m_aSongs.clear(); - const vector &aSongs = SONGMAN->GetAllSongs(); - for( unsigned i = 0; i < aSongs.size(); ++i ) - if( !aSongs[i]->m_sGroupName.CompareNoCase(sGroup) ) - m_aSongs.push_back( aSongs[i] ); - - m_iSelection[ROW_SONG] = 0; -} - -void EditCoursesSongMenu::LoadFromCourseEntry( const CourseEntry *pEntry ) -{ - ZERO( m_iSelection ); - - if( pEntry->pSong ) - { - /* Set this song's group. */ - SetGroupByName( pEntry->pSong->m_sGroupName ); - - unsigned i; - for( i = 0; i < m_aSongs.size(); ++i ) - if( m_aSongs[i] == pEntry->pSong ) - break; - ASSERT_M( i < m_aSongs.size(), ssprintf("%s", pEntry->pSong->GetTranslitMainTitle().c_str()) ); - - m_iSelection[ROW_SONG] = i; - } - else if( pEntry->group_name != "" ) - { - SetGroupByName( pEntry->group_name ); - } - - m_iSelection[ROW_TYPE] = pEntry->type; - m_iSelection[ROW_DIFFICULTY] = (pEntry->difficulty == DIFFICULTY_INVALID)? 0:pEntry->difficulty+1; - m_iSelection[ROW_LOW_METER] = (pEntry->low_meter == -1)? 0:pEntry->low_meter; - m_iSelection[ROW_HIGH_METER] = (pEntry->high_meter == -1)? 0:pEntry->high_meter; - m_iSelection[ROW_BEST_WORST_VALUE] = pEntry->players_index; - - /* Make sure we're on an active row. */ - if( !g_bRowEnabledForType[GetSelectedType()][m_SelectedRow] ) - ChangeRow( -1 ); - if( !g_bRowEnabledForType[GetSelectedType()][m_SelectedRow] ) - ChangeRow( +1 ); - ASSERT( g_bRowEnabledForType[GetSelectedType()][m_SelectedRow] ); - - ChangeToRow( m_SelectedRow ); - OnRowValueChanged( (Row)0 ); -} - -void EditCoursesSongMenu::Left() -{ - if( CanGoLeft() ) - { - m_iSelection[m_SelectedRow]--; - - OnRowValueChanged( m_SelectedRow ); - m_soundChangeValue.Play(); - } -} - -void EditCoursesSongMenu::Right() -{ - if( CanGoRight() ) - { - m_iSelection[m_SelectedRow]++; - - OnRowValueChanged( m_SelectedRow ); - m_soundChangeValue.Play(); - } -} - -void EditCoursesSongMenu::Start() -{ - // XXX - // SCREENMAN->PopTopScreen( m_SMSendOnOK ); -} - - -void EditCoursesSongMenu::HandleScreenMessage( const ScreenMessage SM ) -{ -} - -void EditCoursesSongMenu::ChangeToRow( Row newRow ) -{ - m_SelectedRow = newRow; - - for( int i=0; i<2; i++ ) - m_sprArrows[i].SetY( ROW_Y(newRow) ); - m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[0].EnableAnimation( CanGoLeft() ); - m_sprArrows[1].EnableAnimation( CanGoRight() ); -} - -void EditCoursesSongMenu::OnRowValueChanged( Row row ) -{ - LOG->Trace( "EditCoursesSongMenu::OnRowValueChanged(%i)", row ); - - m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); - m_sprArrows[0].EnableAnimation( CanGoLeft() ); - m_sprArrows[1].EnableAnimation( CanGoRight() ); - - CString sGroup = GetSelectedGroup(); - Song *pSong = GetSelectedSong(); - - switch( row ) - { - case ROW_GROUP: - { - CHECKPOINT; - m_textValue[ROW_GROUP].SetText( sGroup ); - - UpdateSongList(); - - pSong = GetSelectedSong(); - } - // fall through - case ROW_SONG: - CHECKPOINT; - m_textValue[ROW_SONG].SetText( pSong? pSong->GetTranslitMainTitle():CString("") ); - // fall through - - case ROW_TYPE: - CHECKPOINT; - m_textValue[ROW_TYPE].SetText( CourseEntryTypeToString(GetSelectedType()) ); - for( int i = 0; i < NUM_ROWS; ++i ) - m_textValue[i].SetDiffuse( - g_bRowEnabledForType[GetSelectedType()][i]? - RageColor(1,1,1,1):RageColor(0.4f,0.4f,0.4f,1) ); - // fall through - - case ROW_DIFFICULTY: - { - CHECKPOINT; - Difficulty dc = GetSelectedDifficulty(); - if( dc == DIFFICULTY_INVALID ) - m_textValue[ROW_DIFFICULTY].SetText( "(any)" ); - else - m_textValue[ROW_DIFFICULTY].SetText( DifficultyToString(dc) ); - // fall through - } - case ROW_LOW_METER: - CHECKPOINT; - if( GetLowMeter() == -1 ) - m_textValue[ROW_LOW_METER].SetText( "(any)" ); - else - m_textValue[ROW_LOW_METER].SetText( ssprintf("%d",GetLowMeter()) ); - // fall through - - case ROW_HIGH_METER: - CHECKPOINT; - if( GetHighMeter() == -1 ) - m_textValue[ROW_HIGH_METER].SetText( "(any)" ); - else - m_textValue[ROW_HIGH_METER].SetText( ssprintf("%d",GetHighMeter()) ); - // fall through - - case ROW_BEST_WORST_VALUE: - CHECKPOINT; - m_textValue[ROW_BEST_WORST_VALUE].SetText( ssprintf("%d",GetBestWorst()+1) ); - break; - - default: - ASSERT(0); // invalid row - } -} - -Song *EditCoursesSongMenu::GetSelectedSong() const -{ - if( m_iSelection[ROW_SONG] < (int) m_aSongs.size() ) - return m_aSongs[ m_iSelection[ROW_SONG] ]; - else - return NULL; -} - -/* - * (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/stepmania/src/EditCoursesSongMenu.h b/stepmania/src/EditCoursesSongMenu.h deleted file mode 100644 index 44522b42c7..0000000000 --- a/stepmania/src/EditCoursesSongMenu.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Class: EditCoursesSongMenu - Song selection subscreen for EditCoursesMenu */ - -#ifndef EDIT_COURSES_SONG_MENU_H -#define EDIT_COURSES_SONG_MENU_H - -#include "ActorFrame.h" -#include "BitmapText.h" -#include "GameConstantsAndTypes.h" -#include "RageSound.h" -#include "Course.h" -#include "ScreenMessage.h" -#include "song.h" -#include "Sprite.h" - - -class EditCoursesSongMenu: public ActorFrame -{ -public: - EditCoursesSongMenu(); - ~EditCoursesSongMenu(); - void SaveToCourseEntry( CourseEntry *pEntry ); - void LoadFromCourseEntry( const CourseEntry *pEntry ); - - bool CanGoLeft(); - bool CanGoRight(); - - void Up(); - void Down(); - void Left(); - void Right(); - void Start(); - void HandleScreenMessage( const ScreenMessage SM ); - - enum Row - { - ROW_GROUP, - ROW_SONG, - ROW_TYPE, - ROW_DIFFICULTY, - ROW_LOW_METER, - ROW_HIGH_METER, - ROW_BEST_WORST_VALUE, - NUM_ROWS - } m_SelectedRow; - CString RowToString( Row r ) - { - const CString s[NUM_ROWS] = - { - "Group", - "Song", - "Type", - "Difficulty", - "Low Meter", - "High Meter", - "Best/Worst Value", - }; - return s[r]; - } - - CString GetSelectedGroup() const { return m_aGroups[ m_iSelection[ROW_GROUP] ]; } - Song *GetSelectedSong() const; - Difficulty GetSelectedDifficulty() const { if( m_iSelection[ROW_DIFFICULTY] == 0 ) return DIFFICULTY_INVALID; else return (Difficulty) (m_iSelection[ROW_DIFFICULTY]-1); } - CourseEntryType GetSelectedType() const { return (CourseEntryType) m_iSelection[ROW_TYPE]; } - int GetLowMeter() const { return m_iSelection[ROW_LOW_METER] == 0? -1:m_iSelection[ROW_LOW_METER]; } // any, 1, 2, 3 ... - int GetHighMeter() const { return m_iSelection[ROW_HIGH_METER] == 0? -1:m_iSelection[ROW_HIGH_METER]; } - int GetBestWorst() const { return m_iSelection[ROW_BEST_WORST_VALUE]; } - -private: - void SetGroupByName( CString sGroup ); - void UpdateSongList(); - bool ChangeRow( int add ); - Sprite m_sprArrows[2]; - - int m_iSelection[NUM_ROWS]; - BitmapText m_textLabel[NUM_ROWS]; - BitmapText m_textValue[NUM_ROWS]; - - vector m_aSongs; - vector m_aGroups; - - void OnRowValueChanged( Row row ); - void ChangeToRow( Row newRow ); - - RageSound m_soundChangeRow; - RageSound m_soundChangeValue; -}; - -#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/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index ba1be40a12..e21dbe1b4a 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -25,10 +25,12 @@ Screens = \ Screen.cpp Screen.h ScreenAttract.cpp ScreenAttract.h \ ScreenBookkeeping.cpp ScreenBookkeeping.h ScreenBranch.cpp ScreenBranch.h \ ScreenCenterImage.cpp ScreenCenterImage.h ScreenCredits.cpp ScreenCredits.h \ +ScreenCourseManager.cpp ScreenCourseManager.h \ ScreenDebugOverlay.cpp ScreenDebugOverlay.h \ ScreenDemonstration.cpp ScreenDemonstration.h ScreenDimensions.h \ ScreenEdit.cpp ScreenEdit.h \ -ScreenEditCoursesMenu.cpp ScreenEditCoursesMenu.h EditCoursesSongMenu.cpp EditCoursesSongMenu.h \ +ScreenEditCourse.cpp ScreenEditCourse.h \ +ScreenEditCourseEntry.cpp ScreenEditCourseEntry.h \ ScreenEditMenu.cpp ScreenEditMenu.h ScreenEnding.cpp ScreenEnding.h \ ScreenEndlessBreak.cpp ScreenEndlessBreak.h ScreenEvaluation.cpp ScreenEvaluation.h ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNetSelectBase.h ScreenNetRoom.cpp ScreenNetRoom.h \ diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index cf2d359ef5..8c7888825d 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -1392,8 +1392,6 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ bool bUsesThisSong = false; for( unsigned e = 0; e < crs->m_entries.size(); ++e ) { - if( crs->m_entries[e].type != COURSE_ENTRY_FIXED ) - continue; if( crs->m_entries[e].pSong != m_pSong ) continue; bUsesThisSong = true; @@ -2816,8 +2814,6 @@ void ScreenEdit::SetupCourseAttacks() AttackArray Attacks; for( unsigned e = 0; e < m_pAttacksFromCourse->m_entries.size(); ++e ) { - if( m_pAttacksFromCourse->m_entries[e].type != COURSE_ENTRY_FIXED ) - continue; if( m_pAttacksFromCourse->m_entries[e].pSong != m_pSong ) continue; diff --git a/stepmania/src/ScreenEditCourseEntry.cpp b/stepmania/src/ScreenEditCourseEntry.cpp index 3e145eed7d..4e4b2d5872 100644 --- a/stepmania/src/ScreenEditCourseEntry.cpp +++ b/stepmania/src/ScreenEditCourseEntry.cpp @@ -9,7 +9,6 @@ enum EditCourseEntryRow { - ROW_ENTRY_TYPE, ROW_SONG_GROUP, ROW_SONG, ROW_BASE_DIFFICULTY, @@ -22,19 +21,6 @@ enum EditCourseEntryRow }; #define FOREACH_EditCourseEntryRow( i ) FOREACH_ENUM( EditCourseEntryRow, NUM_EditCourseEntryRow, i ) -const bool g_bRowEnabledForEntryType[NUM_EditCourseEntryRow][NUM_CourseEntryType] = -{ // fixed, random, random_group, best, worst - /* entry type */ { true, true, true, true, true }, - /* song group */ { true, false, true, false, false }, - /* song */ { true, false, false, false, false }, - /* base difficulty */ { true, true, true, false, false }, - /* low meter */ { true, true, true, false, false }, - /* high meter */ { true, true, true, false, false }, - /* best worst */ { false, false, false, true, true }, - /* set mods */ { true, true, true, true, true }, - /* done */ { true, true, true, true, true }, -}; - REGISTER_SCREEN_CLASS( ScreenEditCourseEntry ); ScreenEditCourseEntry::ScreenEditCourseEntry( CString sName ) : ScreenOptions( sName ) { @@ -51,13 +37,6 @@ void ScreenEditCourseEntry::Init() OptionRowDefinition def; def.layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.name = "Entry Type"; - def.choices.clear(); - FOREACH_CourseEntryType( i ) - def.choices.push_back( CourseEntryTypeToThemedString(i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); - def.name = "Song Group"; def.choices.clear(); vector vsSongGroups; @@ -73,7 +52,7 @@ void ScreenEditCourseEntry::Init() vDefs.push_back( def ); vHands.push_back( NULL ); - def.name = "Difficulty"; + def.name = "Base Difficulty"; def.choices.clear(); FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), dc ) def.choices.push_back( DifficultyToThemedString(*dc) ); @@ -126,22 +105,6 @@ void ScreenEditCourseEntry::AfterChangeValueInRow( PlayerNumber pn ) switch( m_iCurrentRow[pn] ) { - case ROW_ENTRY_TYPE: - // export entry type - { - OptionRow &row = *m_pRows[ROW_ENTRY_TYPE]; - int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber ); - sSongGroup = row.GetRowDef().choices[ iChoice ]; - CourseEntryType cet = (CourseEntryType)iChoice; - - FOREACH_EditCourseEntryRow( i ) - { - OptionRow &row = *m_pRows[i]; - bool bEnabled = g_bRowEnabledForEntryType[i][cet]; - row.SetEnabledRowForAllPlayers( bEnabled ); - } - } - // fall through case ROW_SONG_GROUP: // export song group { @@ -184,7 +147,7 @@ void ScreenEditCourseEntry::AfterChangeValueInRow( PlayerNumber pn ) { OptionRow &row = *m_pRows[ROW_BASE_DIFFICULTY]; int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber ); - ce.difficulty = DIFFICULTIES_TO_SHOW.GetValue()[iChoice]; + ce.baseDifficulty = DIFFICULTIES_TO_SHOW.GetValue()[iChoice]; } // fall through case ROW_LOW_METER: @@ -247,7 +210,6 @@ void ScreenEditCourseEntry::GoToNextScreen() { switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] ) { - case ROW_ENTRY_TYPE: case ROW_SONG_GROUP: case ROW_SONG: case ROW_BASE_DIFFICULTY: @@ -273,7 +235,6 @@ void ScreenEditCourseEntry::ProcessMenuStart( PlayerNumber pn, const InputEventT { switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] ) { - case ROW_ENTRY_TYPE: case ROW_SONG_GROUP: case ROW_SONG: case ROW_BASE_DIFFICULTY: diff --git a/stepmania/src/ScreenEditCoursesMenu.cpp b/stepmania/src/ScreenEditCoursesMenu.cpp deleted file mode 100644 index f63a7842ac..0000000000 --- a/stepmania/src/ScreenEditCoursesMenu.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "global.h" -#include "ScreenEditCoursesMenu.h" -#include "SongManager.h" -#include "ScreenManager.h" -#include "GameConstantsAndTypes.h" -#include "RageUtil.h" -#include "GameManager.h" -#include "RageLog.h" -#include "GameState.h" -#include "GameSoundManager.h" -#include "ThemeManager.h" -#include "Steps.h" - - -#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen") -#define EXPLANATION_TEXT THEME->GetMetric (m_sName,"ExplanationText") -#define HELP_TEXT THEME->GetMetric (m_sName,"HelpText") - -AutoScreenMessage( SM_RefreshSelector ) - -REGISTER_SCREEN_CLASS( ScreenEditCoursesMenu ); -ScreenEditCoursesMenu::ScreenEditCoursesMenu( CString sName ) : ScreenWithMenuElements( sName ) -{ - LOG->Trace( "ScreenEditCoursesMenu::ScreenEditCoursesMenu()" ); - - /* Enable all players. */ - FOREACH_PlayerNumber( pn ) - GAMESTATE->m_bSideIsJoined[pn] = true; - -} - -void ScreenEditCoursesMenu::Init() -{ - ScreenWithMenuElements::Init(); - - m_Selector.SetXY( 0, 0 ); -// m_Selector.AllowNewNotes(); - this->AddChild( &m_Selector ); - - m_textExplanation.SetName( "Explanation" ); - m_textExplanation.LoadFromFont( THEME->GetPathF("Common","normal") ); - SET_XY_AND_ON_COMMAND( m_textExplanation ); - m_textExplanation.SetText( EXPLANATION_TEXT ); - this->AddChild( &m_textExplanation ); - - this->SortByDrawOrder(); -} - -void ScreenEditCoursesMenu::HandleScreenMessage( const ScreenMessage SM ) -{ - m_Selector.HandleScreenMessage( SM ); - - switch( SM ) - { - case SM_GoToPrevScreen: - case SM_GoToNextScreen: - SCREENMAN->SetNewScreen( NEXT_SCREEN ); - break; - } -} - -void ScreenEditCoursesMenu::MenuUp( PlayerNumber pn ) -{ - m_Selector.Up(); -} - -void ScreenEditCoursesMenu::MenuDown( PlayerNumber pn ) -{ - m_Selector.Down(); -} - -void ScreenEditCoursesMenu::MenuLeft( PlayerNumber pn, const InputEventType type ) -{ - m_Selector.Left(); -} - -void ScreenEditCoursesMenu::MenuRight( PlayerNumber pn, const InputEventType type ) -{ - m_Selector.Right(); -} - -void ScreenEditCoursesMenu::MenuStart( PlayerNumber pn ) -{ - if( IsTransitioning() ) - return; - - m_Selector.Start(); -} - -void ScreenEditCoursesMenu::MenuBack( PlayerNumber pn ) -{ - Cancel( SM_GoToPrevScreen ); - - SOUND->StopMusic(); -} - -/* - * (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/stepmania/src/ScreenEditCoursesMenu.h b/stepmania/src/ScreenEditCoursesMenu.h deleted file mode 100644 index 8252ebc949..0000000000 --- a/stepmania/src/ScreenEditCoursesMenu.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef SCREEN_EDIT_COURSES_MENU_H -#define SCREEN_EDIT_COURSES_MENU_H - -#include "ScreenWithMenuElements.h" -#include "EditCoursesMenu.h" -#include "BitmapText.h" - -class ScreenEditCoursesMenu : public ScreenWithMenuElements -{ -public: - ScreenEditCoursesMenu( CString sName ); - - void Init(); - - virtual void HandleScreenMessage( const ScreenMessage SM ); - -private: - - void MenuUp( PlayerNumber pn ); - void MenuDown( PlayerNumber pn ); - void MenuLeft( PlayerNumber pn, const InputEventType type ); - void MenuRight( PlayerNumber pn, const InputEventType type ); - void MenuBack( PlayerNumber pn ); - void MenuStart( PlayerNumber pn ); - - EditCoursesMenu m_Selector; - - BitmapText m_textExplanation; -}; - -#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/stepmania/src/ScreenJukebox.cpp b/stepmania/src/ScreenJukebox.cpp index 2015035c1e..4a033adce4 100644 --- a/stepmania/src/ScreenJukebox.cpp +++ b/stepmania/src/ScreenJukebox.cpp @@ -122,8 +122,8 @@ void ScreenJukebox::SetSong() // There are some confusing mods that we don't want to show in demonstration. bool bModsAreOkToShow = true; AttackArray aAttacks = pEntry->attacks; - if( !pEntry->modifiers.empty() ) - aAttacks.push_back( Attack::FromGlobalCourseModifier( pEntry->modifiers ) ); + if( !pEntry->sModifiers.empty() ) + aAttacks.push_back( Attack::FromGlobalCourseModifier( pEntry->sModifiers ) ); FOREACH_CONST( Attack, aAttacks, a ) { CString s = a->sModifiers; diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 19f3eae7c0..4e2b13f84f 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -62,7 +62,7 @@ IntDir=.\../Debug6 TargetDir=\cvs\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,7 +99,7 @@ IntDir=.\../Release6 TargetDir=\cvs\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -2242,22 +2242,6 @@ SOURCE=.\DualScrollBar.h # End Source File # Begin Source File -SOURCE=.\EditCoursesMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\EditCoursesMenu.h -# End Source File -# Begin Source File - -SOURCE=.\EditCoursesSongMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\EditCoursesSongMenu.h -# End Source File -# Begin Source File - SOURCE=.\EditMenu.cpp # End Source File # Begin Source File @@ -2574,14 +2558,6 @@ SOURCE=.\ScreenEditCourseEntry.h # End Source File # Begin Source File -SOURCE=.\ScreenEditCoursesMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\ScreenEditCoursesMenu.h -# End Source File -# Begin Source File - SOURCE=.\ScreenEditMenu.cpp !IF "$(CFG)" == "StepMania - Win32 Debug" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index f13e9cd9fa..d23fe45e3b 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -307,12 +307,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ - - - - @@ -1569,18 +1563,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ - - - - - - - -