1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00
osu-lazer/osu.Game/Screens/Select/PlaySongSelect.cs

80 lines
2.3 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
2018-04-13 17:19:50 +08:00
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Screens.Play;
using osu.Game.Users;
using osuTK.Input;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Select
{
public class PlaySongSelect : SongSelect
{
private bool removeAutoModOnResume;
private OsuScreen player;
2018-04-13 17:19:50 +08:00
public override bool AllowExternalScreenChange => true;
protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap();
[BackgroundDependencyLoader]
private void load(OsuColour colours)
2018-04-13 17:19:50 +08:00
{
2019-04-02 18:55:24 +08:00
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () =>
2018-04-13 17:19:50 +08:00
{
ValidForResume = false;
Edit();
}, Key.Number4);
2018-04-13 17:19:50 +08:00
}
2019-01-23 19:52:00 +08:00
public override void OnResuming(IScreen last)
2018-04-13 17:19:50 +08:00
{
player = null;
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
2018-12-06 18:29:18 +08:00
ModSelect.DeselectTypes(new[] { autoType }, true);
2018-04-13 17:19:50 +08:00
removeAutoModOnResume = false;
}
base.OnResuming(last);
}
protected override bool OnStart()
2018-04-13 17:19:50 +08: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 11:03:57 +08:00
var mods = Mods.Value;
2019-04-01 11:16:05 +08:00
2018-04-13 17:19:50 +08:00
if (mods.All(m => m.GetType() != autoType))
{
Mods.Value = mods.Append(auto).ToArray();
2018-04-13 17:19:50 +08:00
removeAutoModOnResume = true;
}
}
Beatmap.Value.Track.Looping = false;
SampleConfirm?.Play();
2018-04-13 17:19:50 +08:00
2018-12-26 21:16:35 +08:00
LoadComponentAsync(player = new PlayerLoader(() => new Player()), l =>
2018-04-13 17:19:50 +08:00
{
2019-02-28 12:31:40 +08:00
if (this.IsCurrentScreen()) this.Push(player);
2018-04-13 17:19:50 +08:00
});
return true;
}
}
}