2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-03-02 18:40:32 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Screens.Play;
|
2020-03-17 16:43:16 +08:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2019-04-13 04:54:35 +08:00
|
|
|
|
using osu.Game.Users;
|
2018-12-12 12:21:44 +08:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class PlaySongSelect : SongSelect
|
|
|
|
|
{
|
|
|
|
|
private bool removeAutoModOnResume;
|
2018-12-12 12:21:44 +08:00
|
|
|
|
private OsuScreen player;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-14 12:28:21 +08:00
|
|
|
|
public override bool AllowExternalScreenChange => true;
|
|
|
|
|
|
2019-06-12 15:33:15 +08:00
|
|
|
|
protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap();
|
2019-04-13 04:54:35 +08:00
|
|
|
|
|
2018-12-12 12:21:44 +08:00
|
|
|
|
[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;
|
2018-10-29 12:04:51 +08:00
|
|
|
|
Edit();
|
2019-10-05 05:32:43 +08:00
|
|
|
|
}, Key.Number4);
|
2020-02-12 18:52:47 +08:00
|
|
|
|
|
2020-03-17 16:43:16 +08:00
|
|
|
|
((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += score => this.Push(new ResultsScreen(score));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 18:52:47 +08:00
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnResuming(IScreen last)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-02-03 15:04:32 +08:00
|
|
|
|
base.OnResuming(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-02 18:40:32 +08:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Enter:
|
2020-03-24 02:25:40 +08:00
|
|
|
|
case Key.KeypadEnter:
|
2020-03-02 18:40:32 +08:00
|
|
|
|
// this is a special hard-coded case; we can't rely on OnPressed (of SongSelect) as GlobalActionContainer is
|
|
|
|
|
// matching with exact modifier consideration (so Ctrl+Enter would be ignored).
|
|
|
|
|
FinaliseSelection();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 14:44:35 +08:00
|
|
|
|
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))
|
|
|
|
|
{
|
2019-04-10 16:13:12 +08:00
|
|
|
|
Mods.Value = mods.Append(auto).ToArray();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
removeAutoModOnResume = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-12 12:21:44 +08:00
|
|
|
|
SampleConfirm?.Play();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-01-31 18:10:44 +08:00
|
|
|
|
this.Push(player = new PlayerLoader(() => new Player()));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|