2019-01-24 17:43:03 +09:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-27 19:29:27 +09:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Screens.Play;
|
2019-04-12 22:54:35 +02:00
|
|
|
|
using osu.Game.Users;
|
2018-12-12 13:21:44 +09:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class PlaySongSelect : SongSelect
|
|
|
|
|
{
|
|
|
|
|
private bool removeAutoModOnResume;
|
2018-12-12 13:21:44 +09:00
|
|
|
|
private OsuScreen player;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-02-14 13:28:21 +09:00
|
|
|
|
public override bool AllowExternalScreenChange => true;
|
|
|
|
|
|
2019-06-12 16:33:15 +09:00
|
|
|
|
protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap();
|
2019-04-12 22:54:35 +02:00
|
|
|
|
|
2018-12-12 13:21:44 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2019-04-02 19:55:24 +09:00
|
|
|
|
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () =>
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
ValidForResume = false;
|
2018-10-29 00:04:51 -04:00
|
|
|
|
Edit();
|
2019-10-04 14:32:43 -07:00
|
|
|
|
}, Key.Number4);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 20:52:00 +09:00
|
|
|
|
public override void OnResuming(IScreen last)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
player = null;
|
|
|
|
|
|
|
|
|
|
if (removeAutoModOnResume)
|
|
|
|
|
{
|
|
|
|
|
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
|
2018-12-06 19:29:18 +09:00
|
|
|
|
ModSelect.DeselectTypes(new[] { autoType }, true);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
removeAutoModOnResume = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 15:44:35 +09:00
|
|
|
|
protected override bool OnStart()
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
if (player != null) return false;
|
|
|
|
|
|
|
|
|
|
// Ctrl+Enter should start map with autoplay enabled.
|
|
|
|
|
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
|
|
|
|
{
|
|
|
|
|
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
|
|
|
|
var autoType = auto.GetType();
|
|
|
|
|
|
2019-04-10 12:03:57 +09:00
|
|
|
|
var mods = Mods.Value;
|
2019-04-01 12:16:05 +09:00
|
|
|
|
|
2018-04-13 18:19:50 +09:00
|
|
|
|
if (mods.All(m => m.GetType() != autoType))
|
|
|
|
|
{
|
2019-04-10 17:13:12 +09:00
|
|
|
|
Mods.Value = mods.Append(auto).ToArray();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
removeAutoModOnResume = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Beatmap.Value.Track.Looping = false;
|
|
|
|
|
|
2018-12-12 13:21:44 +09:00
|
|
|
|
SampleConfirm?.Play();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-12-26 22:16:35 +09:00
|
|
|
|
LoadComponentAsync(player = new PlayerLoader(() => new Player()), l =>
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2019-02-28 13:31:40 +09:00
|
|
|
|
if (this.IsCurrentScreen()) this.Push(player);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|