Make music stop button behave as expected
This commit is contained in:
@@ -28,13 +28,17 @@ namespace OpenRA.GameRules
|
|||||||
this.clips = clips;
|
this.clips = clips;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetNext() {
|
public string GetNext()
|
||||||
|
{
|
||||||
playing = (playing + 1) % clips.Length;
|
playing = (playing + 1) % clips.Length;
|
||||||
return clips[playing];
|
return clips[playing];
|
||||||
}
|
}
|
||||||
public string GetPrev() {
|
public string GetPrev()
|
||||||
|
{
|
||||||
playing = (playing + clips.Length - 1) % clips.Length;
|
playing = (playing + clips.Length - 1) % clips.Length;
|
||||||
return clips[playing];
|
return clips[playing];
|
||||||
}
|
}
|
||||||
|
public string GetCurrent(){ return clips[playing];}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
||||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => {
|
||||||
|
if (Sound.MusicStopped)
|
||||||
|
Sound.PlayMusic(GetSong());
|
||||||
|
Sound.MusicStopped = false;
|
||||||
Sound.MusicPaused = false;
|
Sound.MusicPaused = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
@@ -39,11 +42,13 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => {
|
||||||
Sound.MusicStopped = true;
|
Sound.MusicStopped = true;
|
||||||
bg.Visible = false;
|
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||||
|
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => {
|
||||||
Sound.PlayMusic(GetNextSong());
|
Sound.PlayMusic(GetNextSong());
|
||||||
|
Sound.MusicStopped = false;
|
||||||
Sound.MusicPaused = false;
|
Sound.MusicPaused = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
@@ -51,6 +56,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => {
|
||||||
Sound.PlayMusic(GetPrevSong());
|
Sound.PlayMusic(GetPrevSong());
|
||||||
|
Sound.MusicStopped = false;
|
||||||
Sound.MusicPaused = false;
|
Sound.MusicPaused = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
@@ -60,5 +66,6 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
string GetNextSong() { return Rules.Music["allmusic"].Pool.GetNext(); }
|
string GetNextSong() { return Rules.Music["allmusic"].Pool.GetNext(); }
|
||||||
string GetPrevSong() { return Rules.Music["allmusic"].Pool.GetPrev(); }
|
string GetPrevSong() { return Rules.Music["allmusic"].Pool.GetPrev(); }
|
||||||
|
string GetSong() { return Rules.Music["allmusic"].Pool.GetCurrent(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user