fixed #995 - remove duplication in next/prev song in MusicPlayerLogic.cs
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
@@ -109,11 +110,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetNextSong()
|
string ChooseSong( IEnumerable<string> songs )
|
||||||
{
|
{
|
||||||
var songs = Rules.Music.Where(a => a.Value.Exists)
|
|
||||||
.Select(a => a.Key);
|
|
||||||
|
|
||||||
if (!songs.Any())
|
if (!songs.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -122,22 +120,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
return songs.SkipWhile(m => m != CurrentSong)
|
return songs.SkipWhile(m => m != CurrentSong)
|
||||||
.Skip(1).FirstOrDefault() ?? songs.FirstOrDefault();
|
.Skip(1).FirstOrDefault() ?? songs.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetNextSong()
|
||||||
|
{
|
||||||
|
return ChooseSong( Rules.Music.Where( a => a.Value.Exists ).Select( a => a.Key ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetPrevSong()
|
string GetPrevSong()
|
||||||
{
|
{
|
||||||
var songs = Rules.Music.Where(a => a.Value.Exists)
|
return ChooseSong( Rules.Music.Where( a => a.Value.Exists ).Select( a => a.Key ).Reverse() );
|
||||||
.Select(a => a.Key).Reverse();
|
|
||||||
|
|
||||||
if (!songs.Any())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (Game.Settings.Sound.Shuffle)
|
|
||||||
return songs.Random(Game.CosmeticRandom);
|
|
||||||
|
|
||||||
return songs.SkipWhile(m => m != CurrentSong)
|
|
||||||
.Skip(1).FirstOrDefault() ?? songs.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user