fuckin merges

This commit is contained in:
Flameshadowxeroshin
2011-03-14 19:24:41 -05:00
4 changed files with 180 additions and 236 deletions
+159 -195
View File
@@ -113,31 +113,25 @@ void MusicWheel::Load( RString sType )
* stable_sort) from its output, and title will be the secondary sort, without having * stable_sort) from its output, and title will be the secondary sort, without having
* to re-sort by title each time. */ * to re-sort by title each time. */
SONGMAN->SortSongs(); SONGMAN->SortSongs();
}
void MusicWheel::BeginScreen()
{
RageTimer timer; RageTimer timer;
RString times; RString times;
/* Build all of the wheel item data. Do this after selecting the extra stage, /* Build all of the wheel item data. Do this after selecting the extra stage,
* so it knows to always display it. */ * so it knows to always display it. */
FOREACH_ENUM( SortOrder, so ) FOREACH_ENUM( SortOrder, so )
{ {
BuildWheelItemDatas( m_UnfilteredWheelItemDatas[so], so ); BuildWheelItemDatas( m_WheelItemDatas[so], so );
times += ssprintf( "%i:%.3f ", so, timer.GetDeltaTime() ); times += ssprintf( "%i:%.3f ", so, timer.GetDeltaTime() );
} }
LOG->Trace( "MusicWheel sorting took: %s", times.c_str() ); LOG->Trace( "MusicWheel sorting took: %s", times.c_str() );
}
void MusicWheel::BeginScreen()
{
FOREACH_ENUM( SortOrder, so )
{
m_UnfilteredWheelItemDatas[so] = m_UnfilteredWheelItemDatas[so];
UpdateWheelItemDatas( so );
}
/* Set m_LastModeMenuItem to the first item that matches the current mode. (Do this /* Set m_LastModeMenuItem to the first item that matches the current mode. (Do this
* after building wheel item data.) */ * after building wheel item data.) */
{ {
const vector<MusicWheelItemData *> &from = m_UnfilteredWheelItemDatas[SORT_MODE_MENU]; const vector<MusicWheelItemData *> &from = m_WheelItemDatas[SORT_MODE_MENU];
for( unsigned i=0; i<from.size(); i++ ) for( unsigned i=0; i<from.size(); i++ )
{ {
ASSERT( &*from[i]->m_pAction ); ASSERT( &*from[i]->m_pAction );
@@ -234,7 +228,7 @@ void MusicWheel::BeginScreen()
MusicWheel::~MusicWheel() MusicWheel::~MusicWheel()
{ {
FOREACH_ENUM( SortOrder, so ) FOREACH_ENUM( SortOrder, so )
FOREACH( MusicWheelItemData*, m_UnfilteredWheelItemDatas[so], i ) FOREACH( MusicWheelItemData*, m_WheelItemDatas[so], i )
delete *i; delete *i;
} }
@@ -253,7 +247,7 @@ bool MusicWheel::SelectSongOrCourse()
return true; return true;
// Select the first selectable song based on the sort order... // Select the first selectable song based on the sort order...
vector<MusicWheelItemData *> &wiWheelItems = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; vector<MusicWheelItemData *> &wiWheelItems = m_WheelItemDatas[GAMESTATE->m_SortOrder];
for( unsigned i = 0; i < wiWheelItems.size(); i++ ) for( unsigned i = 0; i < wiWheelItems.size(); i++ )
{ {
if( wiWheelItems[i]->m_pSong ) if( wiWheelItems[i]->m_pSong )
@@ -286,7 +280,7 @@ bool MusicWheel::SelectSong( const Song *p )
return false; return false;
unsigned i; unsigned i;
vector<MusicWheelItemData *> &from = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; vector<MusicWheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
for( i=0; i<from.size(); i++ ) for( i=0; i<from.size(); i++ )
{ {
if( from[i]->m_pSong == p ) if( from[i]->m_pSong == p )
@@ -314,7 +308,7 @@ bool MusicWheel::SelectCourse( const Course *p )
return false; return false;
unsigned i; unsigned i;
vector<MusicWheelItemData *> &from = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; vector<MusicWheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
for( i=0; i<from.size(); i++ ) for( i=0; i<from.size(); i++ )
{ {
if( from[i]->m_pCourse == p ) if( from[i]->m_pCourse == p )
@@ -339,9 +333,9 @@ bool MusicWheel::SelectCourse( const Course *p )
bool MusicWheel::SelectModeMenuItem() bool MusicWheel::SelectModeMenuItem()
{ {
/* Select the last-chosen option. */ // Select the last-chosen option.
ASSERT( GAMESTATE->m_SortOrder == SORT_MODE_MENU ); ASSERT( GAMESTATE->m_SortOrder == SORT_MODE_MENU );
const vector<MusicWheelItemData *> &from = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; const vector<MusicWheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
unsigned i; unsigned i;
for( i=0; i<from.size(); i++ ) for( i=0; i<from.size(); i++ )
{ {
@@ -366,12 +360,120 @@ bool MusicWheel::SelectModeMenuItem()
return true; return true;
} }
void MusicWheel::GetSongList( vector<Song*> &arraySongs, SortOrder so )
{
vector<Song*> apAllSongs;
switch( so )
{
case SORT_PREFERRED:
SONGMAN->GetPreferredSortSongs( apAllSongs );
break;
case SORT_POPULARITY:
apAllSongs = SONGMAN->GetPopularSongs();
break;
case SORT_GROUP:
// if we're not using sections with a preferred song group, and there
// is a group to load, only load those songs. -aj
if(GAMESTATE->m_sPreferredSongGroup != GROUP_ALL && !USE_SECTIONS_WITH_PREFERRED_GROUP )
{
apAllSongs = SONGMAN->GetSongs(GAMESTATE->m_sPreferredSongGroup);
break;
}
// otherwise fall through
default:
apAllSongs = SONGMAN->GetAllSongs();
break;
}
// filter songs that we don't have enough stages to play
{
vector<Song*> vTempSongs;
SongCriteria sc;
sc.m_iMaxStagesForSong = GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer();
SongUtil::FilterSongs( sc, apAllSongs, vTempSongs );
apAllSongs = vTempSongs;
}
// copy only songs that have at least one Steps for the current GameMode
for( unsigned i=0; i<apAllSongs.size(); i++ )
{
Song* pSong = apAllSongs[i];
int iLocked = UNLOCKMAN->SongIsLocked( pSong );
if( iLocked & LOCKED_DISABLED )
continue;
// If we're on an extra stage, and this song is selected, ignore #SELECTABLE.
if( pSong != GAMESTATE->m_pCurSong || !GAMESTATE->IsAnExtraStage() )
{
// Hide songs that asked to be hidden via #SELECTABLE.
if( iLocked & LOCKED_SELECTABLE )
continue;
if( so != SORT_ROULETTE && iLocked & LOCKED_ROULETTE )
continue;
}
/* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette
* and Random, too. */
if( (so!=SORT_ROULETTE || !RANDOM_PICKS_LOCKED_SONGS) && iLocked )
continue;
if( PREFSMAN->m_bOnlyPreferredDifficulties )
{
// if the song has steps that fit the preferred difficulty of the default player
if( pSong->HasStepsTypeAndDifficulty( GAMESTATE->GetCurrentStyle()->m_StepsType,GAMESTATE->m_PreferredDifficulty[GAMESTATE->GetFirstHumanPlayer()] ) )
arraySongs.push_back( pSong );
}
else
{
if(CommonMetrics::AUTO_SET_STYLE)
{
// with AUTO_SET_STYLE on and Autogen off, some songs may get
// hidden. Search through every playable StepsType until you
// find one, then add the song.
// see Issue 147 for more information. -aj
// http://ssc.ajworld.net/sm-ssc/bugtracker/view.php?id=147
set<StepsType> vStepsType;
SongUtil::GetPlayableStepsTypes( pSong, vStepsType );
FOREACHS( StepsType, vStepsType, st )
{
if(pSong->HasStepsType(*st))
{
arraySongs.push_back( pSong );
break;
}
}
}
else
{
// If the song has at least one steps, add it.
if( pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) )
arraySongs.push_back( pSong );
}
}
}
/* Hack: Add extra stage item if it was eliminated for any reason
* (eg. it's a long song). */
if( GAMESTATE->IsAnExtraStage() )
{
Song* pSong;
Steps* pSteps;
SONGMAN->GetExtraStageInfo( GAMESTATE->IsExtraStage2(), GAMESTATE->GetCurrentStyle(), pSong, pSteps );
if( find( arraySongs.begin(), arraySongs.end(), pSong ) == arraySongs.end() )
arraySongs.push_back( pSong );
}
}
void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelItemDatas, SortOrder so ) void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelItemDatas, SortOrder so )
{ {
switch( so ) switch( so )
{ {
case SORT_MODE_MENU: case SORT_MODE_MENU:
{ {
arrayWheelItemDatas.clear(); // clear out the previous wheel items
vector<RString> vsNames; vector<RString> vsNames;
split( MODE_MENU_CHOICE_NAMES, ",", vsNames ); split( MODE_MENU_CHOICE_NAMES, ",", vsNames );
for( unsigned i=0; i<vsNames.size(); ++i ) for( unsigned i=0; i<vsNames.size(); ++i )
@@ -406,21 +508,9 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
case SORT_LENGTH: case SORT_LENGTH:
case SORT_RECENT: case SORT_RECENT:
{ {
// Get all songs that can be shown in this sort. Filtering songs // Make an array of Song*, then sort them
// that can't be played will happen later, in UpdateWheelItemDatas.
vector<Song*> arraySongs; vector<Song*> arraySongs;
switch( so ) GetSongList( arraySongs, so );
{
case SORT_PREFERRED:
SONGMAN->GetPreferredSortSongs( arraySongs );
break;
case SORT_POPULARITY:
arraySongs = SONGMAN->GetPopularSongs();
break;
default:
arraySongs = SONGMAN->GetAllSongs();
break;
}
bool bUseSections = true; bool bUseSections = true;
@@ -543,6 +633,16 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
if( sThisSection != sLastSection ) if( sThisSection != sLastSection )
{ {
int iSectionCount = 0;
// Count songs in this section
unsigned j;
for( j=i; j < arraySongs.size(); j++ )
{
if( SongUtil::GetSectionNameFromSongAndSort( arraySongs[j], so ) != sThisSection )
break;
}
iSectionCount = j-i;
// new section, make a section item // new section, make a section item
// todo: preferred sort section color handling? -aj // todo: preferred sort section color handling? -aj
RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex); RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex);
@@ -550,7 +650,7 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
// In certain situations (e.g. simulating Pump it Up), themes may // In certain situations (e.g. simulating Pump it Up), themes may
// want to only show one group at a time. // want to only show one group at a time.
if( !HIDE_INACTIVE_SECTIONS ) if( !HIDE_INACTIVE_SECTIONS )
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection, 0) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection, iSectionCount) );
sLastSection = sThisSection; sLastSection = sThisSection;
} }
} }
@@ -562,10 +662,17 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
if( SHOW_ROULETTE ) if( SHOW_ROULETTE )
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_ROULETTE, NULL, "", NULL, ROULETTE_COLOR, 0) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_ROULETTE, NULL, "", NULL, ROULETTE_COLOR, 0) );
if( SHOW_RANDOM ) // Only add TYPE_RANDOM and TYPE_PORTAL if there's at least
// one song on the list.
bool bFoundAnySong = false;
for( unsigned i=0; !bFoundAnySong && i < arrayWheelItemDatas.size(); i++ )
if( arrayWheelItemDatas[i]->m_Type == TYPE_SONG )
bFoundAnySong = true;
if( SHOW_RANDOM && bFoundAnySong )
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_RANDOM, NULL, "", NULL, RANDOM_COLOR, 0) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_RANDOM, NULL, "", NULL, RANDOM_COLOR, 0) );
if( SHOW_PORTAL ) if( SHOW_PORTAL && bFoundAnySong )
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_PORTAL, NULL, "", NULL, PORTAL_COLOR, 0) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_PORTAL, NULL, "", NULL, PORTAL_COLOR, 0) );
// add custom wheel items // add custom wheel items
@@ -666,6 +773,8 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
if( so == SORT_ALL_COURSES ) if( so == SORT_ALL_COURSES )
CourseUtil::SortCoursePointerArrayByType( apCourses ); CourseUtil::SortCoursePointerArrayByType( apCourses );
arrayWheelItemDatas.clear(); // clear out the previous wheel items
RString sLastSection = ""; RString sLastSection = "";
int iSectionColorIndex = 0; int iSectionColorIndex = 0;
for( unsigned i=0; i<apCourses.size(); i++ ) // foreach course for( unsigned i=0; i<apCourses.size(); i++ ) // foreach course
@@ -687,6 +796,10 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
} }
} }
// check that this course has at least one song playable in the current style
if( !pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyle()->m_StepsType) )
continue;
if( sThisSection != sLastSection ) // new section, make a section item if( sThisSection != sLastSection ) // new section, make a section item
{ {
RageColor c = SECTION_COLORS.GetValue(iSectionColorIndex); RageColor c = SECTION_COLORS.GetValue(iSectionColorIndex);
@@ -708,6 +821,7 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
MusicWheelItemData& WID = *arrayWheelItemDatas[i]; MusicWheelItemData& WID = *arrayWheelItemDatas[i];
if( WID.m_pSong != NULL ) if( WID.m_pSong != NULL )
{ {
WID.m_Flags.bHasBeginnerOr1Meter = WID.m_pSong->IsEasy( GAMESTATE->GetCurrentStyle()->m_StepsType ) && SHOW_EASY_FLAG;
WID.m_Flags.bEdits = false; WID.m_Flags.bEdits = false;
set<StepsType> vStepsType; set<StepsType> vStepsType;
SongUtil::GetPlayableStepsTypes( WID.m_pSong, vStepsType ); SongUtil::GetPlayableStepsTypes( WID.m_pSong, vStepsType );
@@ -717,175 +831,25 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
} }
else if( WID.m_pCourse != NULL ) else if( WID.m_pCourse != NULL )
{ {
WID.m_Flags.bHasBeginnerOr1Meter = false;
WID.m_Flags.bEdits = WID.m_pCourse->IsAnEdit(); WID.m_Flags.bEdits = WID.m_pCourse->IsAnEdit();
WID.m_Flags.iStagesForSong = 1; WID.m_Flags.iStagesForSong = 1;
} }
} }
}
/* The screen is starting. Take m_UnfilteredWheelItemDatas created on load by // Update the popularity and init icons.
* BuildWheelItemDatas and update them for the current state. Output the
* results into m_WheelItemDatas. */
void MusicWheel::UpdateWheelItemDatas( SortOrder so )
{
vector<MusicWheelItemData *> &aWheelItemDatas = m_UnfilteredWheelItemDatas[so];
// Only add TYPE_PORTAL if there's at least one song on the list.
bool bFoundAnySong = false;
for( unsigned i=0; !bFoundAnySong && i < aWheelItemDatas.size(); i++ )
if( aWheelItemDatas[i]->m_Type == TYPE_SONG )
bFoundAnySong = true;
vector<bool> aiRemove;
aiRemove.insert( aiRemove.begin(), aWheelItemDatas.size(), false );
const int iMaxStagesForSong = GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer();
Song *pExtraStageSong = NULL;
if( GAMESTATE->IsAnExtraStage() )
{
Steps *pSteps;
SONGMAN->GetExtraStageInfo( GAMESTATE->IsExtraStage2(), GAMESTATE->GetCurrentStyle(), pExtraStageSong, pSteps );
}
// Mark any songs that aren't playable in aiRemove.
for( unsigned i=0; i< aWheelItemDatas.size(); i++ )
{
MusicWheelItemData& WID = *aWheelItemDatas[i];
// If we have no songs, remove Random and Portal.
if( WID.m_Type == TYPE_RANDOM || WID.m_Type == TYPE_PORTAL )
{
if( !bFoundAnySong )
aiRemove[i] = true;
continue;
}
// Filter songs that we don't have enough stages to play.
if( WID.m_Type == TYPE_SONG )
{
Song* pSong = WID.m_pSong;
// Never remove the extra stage song.
if( pExtraStageSong && WID.m_pSong == pExtraStageSong )
continue;
// Check that we have enough stages to play this song, and that it's not disabled.
if( GAMESTATE->GetNumStagesMultiplierForSong(WID.m_pSong) > iMaxStagesForSong )
{
aiRemove[i] = true;
continue;
}
int iLocked = UNLOCKMAN->SongIsLocked( pSong );
if( UNLOCKMAN->SongIsLocked(pSong) & LOCKED_DISABLED )
{
aiRemove[i] = true;
continue;
}
// If we're on an extra stage, and this song is selected, ignore #SELECTABLE.
if( pSong != GAMESTATE->m_pCurSong || !GAMESTATE->IsAnExtraStage() )
{
// Hide songs that asked to be hidden via #SELECTABLE.
if( iLocked & LOCKED_SELECTABLE )
{
aiRemove[i] = true;
continue;
}
if( so != SORT_ROULETTE && iLocked & LOCKED_ROULETTE )
{
aiRemove[i] = true;
continue;
}
}
/* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette
* and Random, too. */
if( (so!=SORT_ROULETTE || !RANDOM_PICKS_LOCKED_SONGS) && iLocked )
{
aiRemove[i] = true;
continue;
}
// If the song has no steps for the current style, remove it.
if( !pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) )
{
aiRemove[i] = true;
continue;
}
}
if( WID.m_Type == TYPE_COURSE )
{
if( !WID.m_pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyle()->m_StepsType) )
aiRemove[i] = true;
}
}
// Filter out the songs we're removing.
vector<MusicWheelItemData *> &aFilteredData = m_WheelItemDatas[so];
aFilteredData.reserve( aWheelItemDatas.size() );
for( unsigned i=0; i< aWheelItemDatas.size(); i++ )
{
if( aiRemove[i] )
continue;
aFilteredData.push_back( aWheelItemDatas[i] );
}
// Update the song count in each section header.
for( unsigned i=0; i < aFilteredData.size(); )
{
MusicWheelItemData& WID = *aFilteredData[i];
++i;
if( WID.m_Type != TYPE_SECTION )
continue;
// Count songs in this section
WID.m_iSectionCount = 0;
for( ; i < aFilteredData.size() && aFilteredData[i]->m_sText == WID.m_sText; ++i )
++WID.m_iSectionCount;
}
// If we have any section headers with no songs, then we filtered all of
// the songs in that group, so remove it. This isn't optimized like the
// above since this is a rare case.
for( unsigned i=0; i < aFilteredData.size(); ++i )
{
MusicWheelItemData& WID = *aFilteredData[i];
if( WID.m_Type != TYPE_SECTION )
continue;
if( WID.m_iSectionCount > 0 )
continue;
aFilteredData.erase( aFilteredData.begin()+i, aFilteredData.begin()+i+1 );
--i;
}
// Update the popularity. This is affected by filtering.
if( so == SORT_POPULARITY ) if( so == SORT_POPULARITY )
{ {
for( unsigned i=0; i< min(3u,aFilteredData.size()); i++ ) for( unsigned i=0; i< min(3u,arrayWheelItemDatas.size()); i++ )
{ {
MusicWheelItemData& WID = *aFilteredData[i]; MusicWheelItemData& WID = *arrayWheelItemDatas[i];
WID.m_Flags.iPlayersBestNumber = i+1; WID.m_Flags.iPlayersBestNumber = i+1;
} }
} }
// Update the easy status. This is affected by the steps type.
if( SHOW_EASY_FLAG )
{
for( unsigned i=0; i<aFilteredData.size(); i++ )
{
MusicWheelItemData& WID = *aFilteredData[i];
if( WID.m_pSong == NULL )
continue;
WID.m_Flags.bHasBeginnerOr1Meter = WID.m_pSong->IsEasy( GAMESTATE->GetCurrentStyle()->m_StepsType );
}
}
// If we've filtered all items, insert a dummy. // If we've filtered all items, insert a dummy.
if( aFilteredData.empty() ) if( arrayWheelItemDatas.empty() )
aFilteredData.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, "- EMPTY -", NULL, RageColor(1,0,0,1), 0) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, "- EMPTY -", NULL, RageColor(1,0,0,1), 0) );
} }
void MusicWheel::UpdateSwitch() void MusicWheel::UpdateSwitch()
@@ -1013,7 +977,7 @@ bool MusicWheel::ChangeSort( SortOrder new_so ) // return true if change success
return false; return false;
// Don't change to SORT_MODE_MENU if it doesn't have at least two choices. // Don't change to SORT_MODE_MENU if it doesn't have at least two choices.
if( new_so == SORT_MODE_MENU && m_UnfilteredWheelItemDatas[new_so].size() < 2 ) if( new_so == SORT_MODE_MENU && m_WheelItemDatas[new_so].size() < 2 )
return false; return false;
switch( m_WheelState ) switch( m_WheelState )
@@ -1149,7 +1113,7 @@ void MusicWheel::StartRandom()
{ {
// Shuffle and use the roulette wheel. // Shuffle and use the roulette wheel.
RandomGen rnd; RandomGen rnd;
random_shuffle( m_UnfilteredWheelItemDatas[SORT_ROULETTE].begin(), m_UnfilteredWheelItemDatas[SORT_ROULETTE].end(), rnd ); random_shuffle( m_WheelItemDatas[SORT_ROULETTE].begin(), m_WheelItemDatas[SORT_ROULETTE].end(), rnd );
GAMESTATE->m_SortOrder.Set( SORT_ROULETTE ); GAMESTATE->m_SortOrder.Set( SORT_ROULETTE );
} }
else else
@@ -1187,7 +1151,7 @@ void MusicWheel::SetOpenSection( RString group )
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled(), vpPossibleStyles ); GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled(), vpPossibleStyles );
m_CurWheelItemData.clear(); m_CurWheelItemData.clear();
vector<MusicWheelItemData *> &from = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; vector<MusicWheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
m_CurWheelItemData.reserve( from.size() ); m_CurWheelItemData.reserve( from.size() );
for( unsigned i = 0; i < from.size(); ++i ) for( unsigned i = 0; i < from.size(); ++i )
{ {
@@ -1349,7 +1313,7 @@ void MusicWheel::PlayerJoined()
// We need to rebuild the wheel item data in this situation. -aj // We need to rebuild the wheel item data in this situation. -aj
if( !GAMESTATE->IsCourseMode() && !PREFSMAN->m_bAutogenSteps ) if( !GAMESTATE->IsCourseMode() && !PREFSMAN->m_bAutogenSteps )
{ {
BuildWheelItemDatas( m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder], GAMESTATE->m_SortOrder ); BuildWheelItemDatas( m_WheelItemDatas[GAMESTATE->m_SortOrder], GAMESTATE->m_SortOrder );
} }
SetOpenSection( m_sExpandedSectionName ); SetOpenSection( m_sExpandedSectionName );
@@ -1399,7 +1363,7 @@ Song *MusicWheel::GetPreferredSelectionForRandomOrPortal()
} }
RString sPreferredGroup = m_sExpandedSectionName; RString sPreferredGroup = m_sExpandedSectionName;
vector<MusicWheelItemData *> &wid = m_UnfilteredWheelItemDatas[GAMESTATE->m_SortOrder]; vector<MusicWheelItemData *> &wid = m_WheelItemDatas[GAMESTATE->m_SortOrder];
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
+1 -2
View File
@@ -52,15 +52,14 @@ public:
protected: protected:
MusicWheelItem *MakeItem(); MusicWheelItem *MakeItem();
void GetSongList( vector<Song*> &arraySongs, SortOrder so );
void BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelItems, SortOrder so ); void BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelItems, SortOrder so );
void UpdateWheelItemDatas( SortOrder so );
bool SelectSongOrCourse(); bool SelectSongOrCourse();
bool SelectCourse( const Course *p ); bool SelectCourse( const Course *p );
bool SelectModeMenuItem(); bool SelectModeMenuItem();
virtual void UpdateSwitch(); virtual void UpdateSwitch();
vector<MusicWheelItemData *> m_UnfilteredWheelItemDatas[NUM_SortOrder];
vector<MusicWheelItemData *> m_WheelItemDatas[NUM_SortOrder]; // aliases into m_UnfilteredWheelItemDatas vector<MusicWheelItemData *> m_WheelItemDatas[NUM_SortOrder]; // aliases into m_UnfilteredWheelItemDatas
RString m_sLastModeMenuItem; RString m_sLastModeMenuItem;
+8 -27
View File
@@ -460,10 +460,6 @@ static bool CompAscending( const pair<Song *, RString> &a, const pair<Song *, RS
void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool bDescending ) void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool bDescending )
{ {
StepsType st;
Difficulty dc;
SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SORT_EASY_METER, st, dc );
/* Optimize by pre-writing a string to compare, since doing /* Optimize by pre-writing a string to compare, since doing
* GetNumNotesWithGrade inside the sort is too slow. */ * GetNumNotesWithGrade inside the sort is too slow. */
typedef pair< Song *, RString > val; typedef pair< Song *, RString > val;
@@ -477,7 +473,7 @@ void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool b
int iCounts[NUM_Grade]; int iCounts[NUM_Grade];
const Profile *pProfile = PROFILEMAN->GetMachineProfile(); const Profile *pProfile = PROFILEMAN->GetMachineProfile();
ASSERT( pProfile ); ASSERT( pProfile );
pProfile->GetGrades( pSong, st, iCounts ); pProfile->GetGrades( pSong, GAMESTATE->GetCurrentStyle()->m_StepsType, iCounts );
RString foo; RString foo;
foo.reserve(256); foo.reserve(256);
@@ -621,12 +617,8 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
return RString(); return RString();
case SORT_TOP_GRADES: case SORT_TOP_GRADES:
{ {
StepsType st;
Difficulty dc;
SongUtil::GetStepsTypeAndDifficultyFromSortOrder( so, st, dc );
int iCounts[NUM_Grade]; int iCounts[NUM_Grade];
PROFILEMAN->GetMachineProfile()->GetGrades( pSong, st, iCounts ); PROFILEMAN->GetMachineProfile()->GetGrades( pSong, GAMESTATE->GetCurrentStyle()->m_StepsType, iCounts );
for( int i=Grade_Tier01; i<NUM_Grade; ++i ) for( int i=Grade_Tier01; i<NUM_Grade; ++i )
{ {
@@ -973,7 +965,6 @@ bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &
return false; return false;
} }
bool bDoubles = false;
switch( so ) switch( so )
{ {
DEFAULT_FAIL( so ); DEFAULT_FAIL( so );
@@ -982,38 +973,28 @@ bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &
case SORT_MEDIUM_METER: case SORT_MEDIUM_METER:
case SORT_HARD_METER: case SORT_HARD_METER:
case SORT_CHALLENGE_METER: case SORT_CHALLENGE_METER:
bDoubles = false; stOut = GAMESTATE->GetCurrentStyle()->m_StepsType;
break; break;
case SORT_DOUBLE_EASY_METER: case SORT_DOUBLE_EASY_METER:
case SORT_DOUBLE_MEDIUM_METER: case SORT_DOUBLE_MEDIUM_METER:
case SORT_DOUBLE_HARD_METER: case SORT_DOUBLE_HARD_METER:
case SORT_DOUBLE_CHALLENGE_METER: case SORT_DOUBLE_CHALLENGE_METER:
bDoubles = true; stOut = GAMESTATE->GetCurrentStyle()->m_StepsType; // in case we don't find any matches below
break;
}
stOut = StepsType_Invalid;
vector<const Style*> vpStyles; vector<const Style*> vpStyles;
GAMEMAN->GetStylesForGame(GAMESTATE->m_pCurGame,vpStyles); GAMEMAN->GetStylesForGame(GAMESTATE->m_pCurGame,vpStyles);
FOREACH_CONST( const Style*, vpStyles, i ) FOREACH_CONST( const Style*, vpStyles, i )
{ {
if( !(*i)->m_bUsedForGameplay ) if( (*i)->m_StyleType == StyleType_OnePlayerTwoSides )
continue; {
if( bDoubles && (*i)->m_StyleType != StyleType_OnePlayerTwoSides )
continue;
if( !bDoubles && (*i)->m_StyleType != StyleType_OnePlayerOneSide && (*i)->m_StyleType != StyleType_TwoPlayersTwoSides )
continue;
// Ugly hack to ignore pump's half-double. // Ugly hack to ignore pump's half-double.
bool bContainsHalf = ((RString)(*i)->m_szName).find("half") != RString::npos; bool bContainsHalf = ((RString)(*i)->m_szName).find("half") != RString::npos;
if( bContainsHalf ) if( bContainsHalf )
continue; continue;
stOut = (*i)->m_StepsType; stOut = (*i)->m_StepsType;
break; break;
} }
}
}
return true; return true;
} }