1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 22:47:26 +08:00

Merge remote-tracking branch 'refs/remotes/ppy/master' into user-best-score

This commit is contained in:
Andrei Zavatski 2019-07-10 19:39:41 +03:00
commit a041421e0d
7 changed files with 36 additions and 16 deletions

View File

@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Online
}); });
channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel); channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel);
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue.ToString(); channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue;
AddStep("Add random private channel", addRandomPrivateChannel); AddStep("Add random private channel", addRandomPrivateChannel);
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2); AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);

View File

@ -14,8 +14,6 @@ namespace osu.Game.Tests.Visual.UserInterface
{ {
public class TestSceneBackButton : OsuTestScene public class TestSceneBackButton : OsuTestScene
{ {
private readonly BackButton button;
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(TwoLayerButton) typeof(TwoLayerButton)
@ -23,6 +21,8 @@ namespace osu.Game.Tests.Visual.UserInterface
public TestSceneBackButton() public TestSceneBackButton()
{ {
BackButton button;
Child = new Container Child = new Container
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -40,11 +40,12 @@ namespace osu.Game.Tests.Visual.UserInterface
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Action = () => button.Hide(),
} }
} }
}; };
button.Action = () => button.Hide();
AddStep("show button", () => button.Show()); AddStep("show button", () => button.Show());
AddStep("hide button", () => button.Hide()); AddStep("hide button", () => button.Hide());
} }

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
}, },
}; };
breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue.ToString()}"; breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue}";
breadcrumbs.Current.TriggerChange(); breadcrumbs.Current.TriggerChange();
waitForCurrent(); waitForCurrent();

View File

@ -55,6 +55,8 @@ namespace osu.Game.Overlays
private Container dragContainer; private Container dragContainer;
private Container playerContainer; private Container playerContainer;
public bool IsUserPaused { get; private set; }
[Resolved] [Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; } private Bindable<WorkingBeatmap> beatmap { get; set; }
@ -157,7 +159,7 @@ namespace osu.Game.Overlays
Origin = Anchor.Centre, Origin = Anchor.Centre,
Scale = new Vector2(1.4f), Scale = new Vector2(1.4f),
IconScale = new Vector2(1.4f), IconScale = new Vector2(1.4f),
Action = play, Action = togglePause,
Icon = FontAwesome.Regular.PlayCircle, Icon = FontAwesome.Regular.PlayCircle,
}, },
nextButton = new MusicIconButton nextButton = new MusicIconButton
@ -276,7 +278,7 @@ namespace osu.Game.Overlays
} }
} }
private void play() private void togglePause()
{ {
var track = current?.Track; var track = current?.Track;
@ -288,9 +290,15 @@ namespace osu.Game.Overlays
} }
if (track.IsRunning) if (track.IsRunning)
{
IsUserPaused = true;
track.Stop(); track.Stop();
}
else else
{
track.Start(); track.Start();
IsUserPaused = false;
}
} }
private void prev() private void prev()

View File

@ -224,30 +224,32 @@ namespace osu.Game.Screens.Edit
public override void OnResuming(IScreen last) public override void OnResuming(IScreen last)
{ {
Beatmap.Value.Track?.Stop();
base.OnResuming(last); base.OnResuming(last);
Beatmap.Value.Track?.Stop();
} }
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500); Background.FadeColour(Color4.DarkGray, 500);
Beatmap.Value.Track?.Stop(); resetTrack();
} }
public override bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)
{ {
Background.FadeColour(Color4.White, 500); Background.FadeColour(Color4.White, 500);
resetTrack();
if (Beatmap.Value.Track != null)
{
Beatmap.Value.Track.Tempo.Value = 1;
Beatmap.Value.Track.Start();
}
return base.OnExiting(next); return base.OnExiting(next);
} }
private void resetTrack()
{
Beatmap.Value.Track?.ResetSpeedAdjustments();
Beatmap.Value.Track?.Stop();
}
private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save()); private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e) private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)

View File

@ -42,6 +42,9 @@ namespace osu.Game.Screens.Menu
[Resolved] [Resolved]
private GameHost host { get; set; } private GameHost host { get; set; }
[Resolved(canBeNull: true)]
private MusicController music { get; set; }
private BackgroundScreenDefault background; private BackgroundScreenDefault background;
protected override BackgroundScreen CreateBackground() => background; protected override BackgroundScreen CreateBackground() => background;
@ -189,6 +192,9 @@ namespace osu.Game.Screens.Menu
//we may have consumed our preloaded instance, so let's make another. //we may have consumed our preloaded instance, so let's make another.
preloadSongSelect(); preloadSongSelect();
if (Beatmap.Value.Track != null && music?.IsUserPaused != true)
Beatmap.Value.Track.Start();
} }
public override bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)

View File

@ -87,6 +87,9 @@ namespace osu.Game.Screens.Select
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>(); private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
[Resolved(canBeNull: true)]
private MusicController music { get; set; }
[Cached] [Cached]
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))] [Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
@ -570,7 +573,7 @@ namespace osu.Game.Screens.Select
{ {
Track track = Beatmap.Value.Track; Track track = Beatmap.Value.Track;
if (!track.IsRunning || restart) if ((!track.IsRunning || restart) && music?.IsUserPaused != true)
{ {
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Restart(); track.Restart();