Add Top Grades sort per profile. This allows each player to see their top grades based on the currently used profile.
The present implementation adds 2 new sorts for this, TOP_P1_Grades and TOP_P2_GRADES following the naming convention of TOP_GRADES which returns the machine grades. I named the sort TopP1Grades rather than TopGradesP1 to prevent the "conflicting" banner error. Eventually, I'd like to condense this to be 1 sort fed a playernumber or profile parameter in the future. (cherry picked from commit 731ae501d8a14a196984bf7578afaa9351c22c5c)
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Common fallback banner
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Common fallback banner
|
||||||
@@ -309,6 +309,8 @@ PreferredText=Preferred
|
|||||||
TitleText=Title
|
TitleText=Title
|
||||||
RecentText=Recent
|
RecentText=Recent
|
||||||
TopGradesText=Top Grades
|
TopGradesText=Top Grades
|
||||||
|
TopP1GradesText=P1 Top Grades
|
||||||
|
TopP2GradesText=P2 Top Grades
|
||||||
|
|
||||||
CoursesText=Courses
|
CoursesText=Courses
|
||||||
AllCoursesText=All Courses
|
AllCoursesText=All Courses
|
||||||
|
|||||||
@@ -965,7 +965,7 @@ RecentSongsToShow=30
|
|||||||
|
|
||||||
UseEasyMarkerFlag=false
|
UseEasyMarkerFlag=false
|
||||||
|
|
||||||
ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,EasyMeter,MediumMeter,HardMeter,ChallengeMeter,DoubleEasyMeter,DoubleMediumMeter,DoubleHardMeter,DoubleChallengeMeter,Genre,Length,Recent"
|
ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,TopP1Grades,TopP2Grades,Artist,EasyMeter,MediumMeter,HardMeter,ChallengeMeter,DoubleEasyMeter,DoubleMediumMeter,DoubleHardMeter,DoubleChallengeMeter,Genre,Length,Recent"
|
||||||
# ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,EasyMeter,MediumMeter,HardMeter,ChallengeMeter,DoubleEasyMeter,DoubleMediumMeter,DoubleHardMeter,DoubleChallengeMeter,Genre,Length,Recent,NormalMode,BattleMode"
|
# ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,EasyMeter,MediumMeter,HardMeter,ChallengeMeter,DoubleEasyMeter,DoubleMediumMeter,DoubleHardMeter,DoubleChallengeMeter,Genre,Length,Recent,NormalMode,BattleMode"
|
||||||
ChoicePreferred="sort,Preferred"
|
ChoicePreferred="sort,Preferred"
|
||||||
ChoiceGroup="sort,Group"
|
ChoiceGroup="sort,Group"
|
||||||
@@ -973,6 +973,8 @@ ChoiceTitle="sort,Title"
|
|||||||
ChoiceBpm="sort,BPM"
|
ChoiceBpm="sort,BPM"
|
||||||
ChoicePopularity="sort,Popularity"
|
ChoicePopularity="sort,Popularity"
|
||||||
ChoiceTopGrades="sort,TopGrades"
|
ChoiceTopGrades="sort,TopGrades"
|
||||||
|
ChoiceTopP1Grades="sort,TopP1Grades"
|
||||||
|
ChoiceTopP2Grades="sort,TopP2Grades"
|
||||||
ChoiceArtist="sort,Artist"
|
ChoiceArtist="sort,Artist"
|
||||||
ChoiceGenre="sort,Genre"
|
ChoiceGenre="sort,Genre"
|
||||||
ChoiceEasyMeter="sort,EasyMeter"
|
ChoiceEasyMeter="sort,EasyMeter"
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ static const char *SortOrderNames[] = {
|
|||||||
"BPM",
|
"BPM",
|
||||||
"Popularity",
|
"Popularity",
|
||||||
"TopGrades",
|
"TopGrades",
|
||||||
|
"TopP1Grades",
|
||||||
|
"TopP2Grades",
|
||||||
"Artist",
|
"Artist",
|
||||||
"Genre",
|
"Genre",
|
||||||
"BeginnerMeter",
|
"BeginnerMeter",
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ enum SortOrder
|
|||||||
SORT_BPM, /**< Sort by the Song's BPM. */
|
SORT_BPM, /**< Sort by the Song's BPM. */
|
||||||
SORT_POPULARITY, /**< Sort by how popular the Song is. */
|
SORT_POPULARITY, /**< Sort by how popular the Song is. */
|
||||||
SORT_TOP_GRADES, /**< Sort by the highest grades earned on a Song. */
|
SORT_TOP_GRADES, /**< Sort by the highest grades earned on a Song. */
|
||||||
|
SORT_TOP_GRADES_P1, /**< Sort by the highest grades earned on a Song for P1. */
|
||||||
|
SORT_TOP_GRADES_P2, /**< Sort by the highest grades earned on a Song for P2. */
|
||||||
SORT_ARTIST, /**< Sort by the name of the artist of the Song. */
|
SORT_ARTIST, /**< Sort by the name of the artist of the Song. */
|
||||||
SORT_GENRE, /**< Sort by the Song's genre. */
|
SORT_GENRE, /**< Sort by the Song's genre. */
|
||||||
SORT_BEGINNER_METER, /**< Sort by the difficulty of the single beginner meter. */
|
SORT_BEGINNER_METER, /**< Sort by the difficulty of the single beginner meter. */
|
||||||
|
|||||||
+19
-1
@@ -544,6 +544,8 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
case SORT_BPM:
|
case SORT_BPM:
|
||||||
case SORT_POPULARITY:
|
case SORT_POPULARITY:
|
||||||
case SORT_TOP_GRADES:
|
case SORT_TOP_GRADES:
|
||||||
|
case SORT_TOP_GRADES_P1:
|
||||||
|
case SORT_TOP_GRADES_P2:
|
||||||
case SORT_ARTIST:
|
case SORT_ARTIST:
|
||||||
case SORT_GENRE:
|
case SORT_GENRE:
|
||||||
case SORT_BEGINNER_METER:
|
case SORT_BEGINNER_METER:
|
||||||
@@ -600,7 +602,21 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
bUseSections = false;
|
bUseSections = false;
|
||||||
break;
|
break;
|
||||||
case SORT_TOP_GRADES:
|
case SORT_TOP_GRADES:
|
||||||
SongUtil::SortSongPointerArrayByGrades( arraySongs, true );
|
SongUtil::SortSongPointerArrayByGrades( arraySongs, true );
|
||||||
|
break;
|
||||||
|
case SORT_TOP_GRADES_P1:
|
||||||
|
// Check if master player profile is persistent
|
||||||
|
if( PROFILEMAN->IsPersistentProfile(PLAYER_1) )
|
||||||
|
SongUtil::SortSongPointerArrayByProfileGrades( arraySongs, true, PLAYER_1);
|
||||||
|
else
|
||||||
|
SongUtil::SortSongPointerArrayByGrades( arraySongs, true );
|
||||||
|
break;
|
||||||
|
case SORT_TOP_GRADES_P2:
|
||||||
|
if( PROFILEMAN->IsPersistentProfile(PLAYER_2) )
|
||||||
|
SongUtil::SortSongPointerArrayByProfileGrades( arraySongs, true, PLAYER_2);
|
||||||
|
else
|
||||||
|
SongUtil::SortSongPointerArrayByGrades( arraySongs, true );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SORT_ARTIST:
|
case SORT_ARTIST:
|
||||||
SongUtil::SortSongPointerArrayByArtist( arraySongs );
|
SongUtil::SortSongPointerArrayByArtist( arraySongs );
|
||||||
@@ -665,6 +681,8 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
{
|
{
|
||||||
case SORT_PREFERRED:
|
case SORT_PREFERRED:
|
||||||
case SORT_TOP_GRADES:
|
case SORT_TOP_GRADES:
|
||||||
|
case SORT_TOP_GRADES_P1:
|
||||||
|
case SORT_TOP_GRADES_P2:
|
||||||
case SORT_BPM:
|
case SORT_BPM:
|
||||||
case SORT_LENGTH:
|
case SORT_LENGTH:
|
||||||
break; // don't sort by section
|
break; // don't sort by section
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include "CommonMetrics.h"
|
#include "CommonMetrics.h"
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
#include "EnumHelper.h"
|
#include "EnumHelper.h"
|
||||||
|
#include "PlayerNumber.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@@ -495,6 +497,35 @@ void SongUtil::SortSongPointerArrayByGrades( std::vector<Song*> &vpSongsInOut, b
|
|||||||
vpSongsInOut[i] = vals[i].first;
|
vpSongsInOut[i] = vals[i].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SongUtil::SortSongPointerArrayByProfileGrades( std::vector<Song*> &vpSongsInOut, bool bDescending, PlayerNumber pn )
|
||||||
|
{
|
||||||
|
/* Optimize by pre-writing a string to compare, since doing
|
||||||
|
* GetNumNotesWithGrade inside the sort is too slow. */
|
||||||
|
typedef std::pair<Song*, RString> val;
|
||||||
|
std::vector<val> vals;
|
||||||
|
vals.reserve( vpSongsInOut.size() );
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < vpSongsInOut.size(); ++i )
|
||||||
|
{
|
||||||
|
Song *pSong = vpSongsInOut[i];
|
||||||
|
|
||||||
|
int iCounts[NUM_Grade];
|
||||||
|
const Profile *pProfile = PROFILEMAN->GetProfile(pn);
|
||||||
|
ASSERT( pProfile != nullptr );
|
||||||
|
pProfile->GetGrades( pSong, GAMESTATE->GetCurrentStyle(pn)->m_StepsType, iCounts );
|
||||||
|
|
||||||
|
RString foo;
|
||||||
|
foo.reserve(256);
|
||||||
|
for( int g=Grade_Tier01; g<NUM_Grade; ++g )
|
||||||
|
AppendOctal( iCounts[g], 3, foo );
|
||||||
|
vals.push_back( val(pSong, foo) );
|
||||||
|
}
|
||||||
|
|
||||||
|
sort( vals.begin(), vals.end(), bDescending ? CompDescending : CompAscending );
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < vpSongsInOut.size(); ++i )
|
||||||
|
vpSongsInOut[i] = vals[i].first;
|
||||||
|
}
|
||||||
|
|
||||||
void SongUtil::SortSongPointerArrayByArtist( std::vector<Song*> &vpSongsInOut )
|
void SongUtil::SortSongPointerArrayByArtist( std::vector<Song*> &vpSongsInOut )
|
||||||
{
|
{
|
||||||
@@ -631,6 +662,32 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
|
|||||||
case SORT_POPULARITY:
|
case SORT_POPULARITY:
|
||||||
case SORT_RECENT:
|
case SORT_RECENT:
|
||||||
return RString();
|
return RString();
|
||||||
|
case SORT_TOP_GRADES_P1:
|
||||||
|
{
|
||||||
|
int iCounts[NUM_Grade];
|
||||||
|
PROFILEMAN->GetProfile(PLAYER_1)->GetGrades( pSong, GAMESTATE->GetCurrentStyle(PLAYER_1)->m_StepsType, iCounts );
|
||||||
|
|
||||||
|
for( int i=Grade_Tier01; i<NUM_Grade; ++i )
|
||||||
|
{
|
||||||
|
Grade g = (Grade)i;
|
||||||
|
if( iCounts[i] > 0 )
|
||||||
|
return ssprintf( "%4s x %d", GradeToLocalizedString(g).c_str(), iCounts[i] );
|
||||||
|
}
|
||||||
|
return GradeToLocalizedString( Grade_NoData );
|
||||||
|
}
|
||||||
|
case SORT_TOP_GRADES_P2:
|
||||||
|
{
|
||||||
|
int iCounts[NUM_Grade];
|
||||||
|
PROFILEMAN->GetProfile(PLAYER_2)->GetGrades( pSong, GAMESTATE->GetCurrentStyle(PLAYER_2)->m_StepsType, iCounts );
|
||||||
|
|
||||||
|
for( int i=Grade_Tier01; i<NUM_Grade; ++i )
|
||||||
|
{
|
||||||
|
Grade g = (Grade)i;
|
||||||
|
if( iCounts[i] > 0 )
|
||||||
|
return ssprintf( "%4s x %d", GradeToLocalizedString(g).c_str(), iCounts[i] );
|
||||||
|
}
|
||||||
|
return GradeToLocalizedString( Grade_NoData );
|
||||||
|
}
|
||||||
case SORT_TOP_GRADES:
|
case SORT_TOP_GRADES:
|
||||||
{
|
{
|
||||||
int iCounts[NUM_Grade];
|
int iCounts[NUM_Grade];
|
||||||
|
|||||||
+2
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#ifndef SONG_UTIL_H
|
#ifndef SONG_UTIL_H
|
||||||
#define SONG_UTIL_H
|
#define SONG_UTIL_H
|
||||||
|
#include "PlayerNumber.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "Difficulty.h"
|
#include "Difficulty.h"
|
||||||
|
|
||||||
@@ -138,6 +138,7 @@ namespace SongUtil
|
|||||||
void SortSongPointerArrayByTitle( std::vector<Song*> &vpSongsInOut );
|
void SortSongPointerArrayByTitle( std::vector<Song*> &vpSongsInOut );
|
||||||
void SortSongPointerArrayByBPM( std::vector<Song*> &vpSongsInOut );
|
void SortSongPointerArrayByBPM( std::vector<Song*> &vpSongsInOut );
|
||||||
void SortSongPointerArrayByGrades( std::vector<Song*> &vpSongsInOut, bool bDescending );
|
void SortSongPointerArrayByGrades( std::vector<Song*> &vpSongsInOut, bool bDescending );
|
||||||
|
void SortSongPointerArrayByProfileGrades( std::vector<Song*> &vpSongsInOut, bool bDescending, PlayerNumber pn );
|
||||||
void SortSongPointerArrayByArtist( std::vector<Song*> &vpSongsInOut );
|
void SortSongPointerArrayByArtist( std::vector<Song*> &vpSongsInOut );
|
||||||
void SortSongPointerArrayByDisplayArtist( std::vector<Song*> &vpSongsInOut );
|
void SortSongPointerArrayByDisplayArtist( std::vector<Song*> &vpSongsInOut );
|
||||||
void SortSongPointerArrayByGenre( std::vector<Song*> &vpSongsInOut );
|
void SortSongPointerArrayByGenre( std::vector<Song*> &vpSongsInOut );
|
||||||
|
|||||||
Reference in New Issue
Block a user