diff --git a/OpenRA.Mods.RA/Widgets/Delegates/MusicPlayerDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/MusicPlayerDelegate.cs index 398f4781b0..f29d12fffc 100644 --- a/OpenRA.Mods.RA/Widgets/Delegates/MusicPlayerDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/MusicPlayerDelegate.cs @@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates }; var ml = bg.GetWidget("MUSIC_LIST"); - var itemTemplate = ml.GetWidget("MUSIC_TEMPLATE"); + var itemTemplate = ml.GetWidget("MUSIC_TEMPLATE"); if (!Rules.Music.Where(m => m.Value.Exists).Any()) { @@ -114,23 +114,11 @@ namespace OpenRA.Mods.RA.Widgets.Delegates var song = kv.Key; if (CurrentSong == null) CurrentSong = song; - - var template = itemTemplate.Clone() as LabelWidget; - template.Id = "SONG_{0}".F(song); - template.GetBackground = () => ((song == CurrentSong) ? "dialog2" : null); - template.OnMouseDown = mi => - { - if (mi.Button != MouseButton.Left) return false; - CurrentSong = song; - bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi); - return true; - }; - - template.IsVisible = () => true; - template.GetWidget("TITLE").GetText = () => " " + Rules.Music[song].Title; - template.GetWidget("LENGTH").GetText = () => "{0:D1}:{1:D2}".F(Rules.Music[song].Length / 60, Rules.Music[song].Length % 60); - - ml.AddChild(template); + + var item = ScrollItemWidget.Setup(itemTemplate, () => CurrentSong == song, () => { CurrentSong = song; bg.GetWidget("BUTTON_PLAY").OnMouseUp(new MouseInput()); }); + item.GetWidget("TITLE").GetText = () => Rules.Music[song].Title; + item.GetWidget("LENGTH").GetText = () => "{0:D1}:{1:D2}".F(Rules.Music[song].Length / 60, Rules.Music[song].Length % 60); + ml.AddChild(item); } } diff --git a/mods/ra/chrome/mainmenu.yaml b/mods/ra/chrome/mainmenu.yaml index bd34b96b0e..e7e308e4a2 100644 --- a/mods/ra/chrome/mainmenu.yaml +++ b/mods/ra/chrome/mainmenu.yaml @@ -245,9 +245,9 @@ Background@MUSIC_MENU: Width:280 Height:140 Children: - Label@MUSIC_TEMPLATE: + ScrollItem@MUSIC_TEMPLATE: Id:MUSIC_TEMPLATE - Width:PARENT_RIGHT-28 + Width:PARENT_RIGHT-27 Height:25 X:2 Y:0