fixed #996 -- Rules.InstalledMusic

This commit is contained in:
Chris Forbes
2011-07-08 21:25:43 +12:00
committed by Paul Chote
parent 1a2dc8ec1c
commit 99b8c765c7
2 changed files with 6 additions and 11 deletions

View File

@@ -48,5 +48,7 @@ namespace OpenRA
var yy = y.ToDictionary( x => x.Key, x => x.Value ); var yy = y.ToDictionary( x => x.Key, x => x.Value );
return y.ToDictionary(kv => kv.Key.ToLowerInvariant(), kv => f(kv, yy)); return y.ToDictionary(kv => kv.Key.ToLowerInvariant(), kv => f(kv, yy));
} }
public static IEnumerable<KeyValuePair<string,MusicInfo>> InstalledMusic { get { return Music.Where( m => m.Value.Exists ); } }
} }
} }

View File

@@ -88,14 +88,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var ml = bg.GetWidget<ScrollPanelWidget>("MUSIC_LIST"); var ml = bg.GetWidget<ScrollPanelWidget>("MUSIC_LIST");
var itemTemplate = ml.GetWidget<ScrollItemWidget>("MUSIC_TEMPLATE"); var itemTemplate = ml.GetWidget<ScrollItemWidget>("MUSIC_TEMPLATE");
if (!Rules.Music.Where(m => m.Value.Exists).Any()) if (!Rules.InstalledMusic.Any())
{ {
itemTemplate.IsVisible = () => true; itemTemplate.IsVisible = () => true;
itemTemplate.GetWidget<LabelWidget>("TITLE").GetText = () => "No Music Installed"; itemTemplate.GetWidget<LabelWidget>("TITLE").GetText = () => "No Music Installed";
itemTemplate.GetWidget<LabelWidget>("TITLE").Align = LabelWidget.TextAlign.Center; itemTemplate.GetWidget<LabelWidget>("TITLE").Align = LabelWidget.TextAlign.Center;
} }
foreach (var kv in Rules.Music.Where(m => m.Value.Exists)) foreach (var kv in Rules.InstalledMusic)
{ {
var song = kv.Key; var song = kv.Key;
if (CurrentSong == null) if (CurrentSong == null)
@@ -122,14 +122,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
.Skip(1).FirstOrDefault() ?? songs.FirstOrDefault(); .Skip(1).FirstOrDefault() ?? songs.FirstOrDefault();
} }
string GetNextSong() string GetNextSong() { return ChooseSong( Rules.InstalledMusic.Select( a => a.Key ) ); }
{ string GetPrevSong() { return ChooseSong( Rules.InstalledMusic.Select( a => a.Key ).Reverse() ); }
return ChooseSong( Rules.Music.Where( a => a.Value.Exists ).Select( a => a.Key ) );
}
string GetPrevSong()
{
return ChooseSong( Rules.Music.Where( a => a.Value.Exists ).Select( a => a.Key ).Reverse() );
}
} }
} }