diff --git a/OpenRA.Game/GameRules/MusicInfo.cs b/OpenRA.Game/GameRules/MusicInfo.cs index c1c2833aee..faff0bd58c 100644 --- a/OpenRA.Game/GameRules/MusicInfo.cs +++ b/OpenRA.Game/GameRules/MusicInfo.cs @@ -28,13 +28,17 @@ namespace OpenRA.GameRules this.clips = clips; } - public string GetNext() { + public string GetNext() + { playing = (playing + 1) % clips.Length; return clips[playing]; } - public string GetPrev() { + public string GetPrev() + { playing = (playing + clips.Length - 1) % clips.Length; return clips[playing]; } + public string GetCurrent(){ return clips[playing];} + } } diff --git a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs index 28c21c35e0..a4d2db5459 100644 --- a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs @@ -26,6 +26,9 @@ namespace OpenRA.Widgets.Delegates { var bg = Chrome.rootWidget.GetWidget("MUSIC_BG"); bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => { + if (Sound.MusicStopped) + Sound.PlayMusic(GetSong()); + Sound.MusicStopped = false; Sound.MusicPaused = false; bg.GetWidget("BUTTON_PLAY").Visible = false; bg.GetWidget("BUTTON_PAUSE").Visible = true; @@ -39,11 +42,13 @@ namespace OpenRA.Widgets.Delegates }; bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => { Sound.MusicStopped = true; - bg.Visible = false; + bg.GetWidget("BUTTON_PAUSE").Visible = false; + bg.GetWidget("BUTTON_PLAY").Visible = true; return true; }; bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => { Sound.PlayMusic(GetNextSong()); + Sound.MusicStopped = false; Sound.MusicPaused = false; bg.GetWidget("BUTTON_PLAY").Visible = false; bg.GetWidget("BUTTON_PAUSE").Visible = true; @@ -51,6 +56,7 @@ namespace OpenRA.Widgets.Delegates }; bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => { Sound.PlayMusic(GetPrevSong()); + Sound.MusicStopped = false; Sound.MusicPaused = false; bg.GetWidget("BUTTON_PLAY").Visible = false; bg.GetWidget("BUTTON_PAUSE").Visible = true; @@ -60,5 +66,6 @@ namespace OpenRA.Widgets.Delegates string GetNextSong() { return Rules.Music["allmusic"].Pool.GetNext(); } string GetPrevSong() { return Rules.Music["allmusic"].Pool.GetPrev(); } + string GetSong() { return Rules.Music["allmusic"].Pool.GetCurrent(); } } }