|
@@ -101,7 +101,7 @@ namespace SongBrowserPlugin
|
|
|
// Update song Infos
|
|
|
this.UpdateSongInfos(gameplayMode);
|
|
|
|
|
|
- this.ProcessSongList();
|
|
|
+ this.ProcessSongList(gameplayMode);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -123,7 +123,7 @@ namespace SongBrowserPlugin
|
|
|
/// <summary>
|
|
|
/// Sort the song list based on the settings.
|
|
|
/// </summary>
|
|
|
- private void ProcessSongList()
|
|
|
+ private void ProcessSongList(GameplayMode gameplayMode)
|
|
|
{
|
|
|
_log.Trace("ProcessSongList()");
|
|
|
|
|
@@ -158,6 +158,8 @@ namespace SongBrowserPlugin
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
+ PlayerDynamicData playerData = GameDataModel.instance.gameDynamicData.GetCurrentPlayerDynamicData();
|
|
|
+
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
|
switch (_settings.sortMode)
|
|
@@ -195,6 +197,17 @@ namespace SongBrowserPlugin
|
|
|
.ThenBy(x => x.songName)
|
|
|
.ToList();
|
|
|
break;
|
|
|
+ case SongSortMode.PlayCount:
|
|
|
+ _log.Info("Sorting song list by playcount");
|
|
|
+ // Build a map of levelId to sum of all playcounts and sort.
|
|
|
+ IEnumerable<LevelDifficulty> difficultyIterator = Enum.GetValues(typeof(LevelDifficulty)).Cast<LevelDifficulty>();
|
|
|
+ Dictionary<string, int> _levelIdToPlayCount = _originalSongs.ToDictionary(x => x.levelID, x => difficultyIterator.Sum(difficulty => playerData.GetPlayerLevelStatsData(x.levelID, difficulty, gameplayMode).playCount));
|
|
|
+ _sortedSongs = _originalSongs
|
|
|
+ .AsQueryable()
|
|
|
+ .OrderByDescending(x => _levelIdToPlayCount[x.levelID])
|
|
|
+ .ThenBy(x => x.songName)
|
|
|
+ .ToList();
|
|
|
+ break;
|
|
|
case SongSortMode.Default:
|
|
|
default:
|
|
|
_log.Info("Sorting song list as default (songName)");
|