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

74 lines
2.1 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Screens.Play;
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
[BackgroundDependencyLoader]
private void load(OsuColour colours)
2018-04-13 17:19:50 +08:00
{
2018-09-15 22:30:11 +08:00
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
2018-04-13 17:19:50 +08:00
{
ValidForResume = false;
Edit();
2018-04-13 17:19:50 +08:00
}, Key.Number3);
}
protected override void OnResuming(Screen last)
{
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();
var mods = SelectedMods.Value;
2018-04-13 17:19:50 +08:00
if (mods.All(m => m.GetType() != autoType))
{
SelectedMods.Value = mods.Append(auto);
2018-04-13 17:19:50 +08:00
removeAutoModOnResume = true;
}
}
Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true;
SampleConfirm?.Play();
2018-04-13 17:19:50 +08:00
LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
{
if (IsCurrentScreen) Push(player);
});
return true;
}
}
}