Make music stop button behave as expected

This commit is contained in:
alzeih
2010-05-06 23:46:50 +12:00
parent 3c539daf20
commit 1c862832ed
2 changed files with 14 additions and 3 deletions

View File

@@ -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];}
}
}

View File

@@ -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(); }
}
}