2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-27 10:29:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-03-02 10:40:32 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
2020-06-02 11:32:52 +00:00
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Overlays.Notifications;
|
2020-05-04 05:04:30 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2020-03-17 08:43:16 +00:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2019-04-12 20:54:35 +00:00
|
|
|
|
using osu.Game.Users;
|
2018-12-12 04:21:44 +00:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class PlaySongSelect : SongSelect
|
|
|
|
|
{
|
|
|
|
|
private bool removeAutoModOnResume;
|
2018-12-12 04:21:44 +00:00
|
|
|
|
private OsuScreen player;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-06-02 14:01:01 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2020-06-02 11:32:52 +00:00
|
|
|
|
private NotificationOverlay notifications { get; set; }
|
|
|
|
|
|
2019-02-14 04:28:21 +00:00
|
|
|
|
public override bool AllowExternalScreenChange => true;
|
|
|
|
|
|
2019-06-12 07:33:15 +00:00
|
|
|
|
protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap();
|
2019-04-12 20:54:35 +00:00
|
|
|
|
|
2018-12-12 04:21:44 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-04-02 10:55:24 +00:00
|
|
|
|
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () =>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
ValidForResume = false;
|
2018-10-29 04:04:51 +00:00
|
|
|
|
Edit();
|
2019-10-04 21:32:43 +00:00
|
|
|
|
}, Key.Number4);
|
2020-02-12 10:52:47 +00:00
|
|
|
|
|
2020-05-04 05:04:30 +00:00
|
|
|
|
((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += PresentScore;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 05:04:30 +00:00
|
|
|
|
protected void PresentScore(ScoreInfo score) =>
|
2020-05-26 08:00:41 +00:00
|
|
|
|
FinaliseSelection(score.Beatmap, score.Ruleset, () => this.Push(new SoloResultsScreen(score)));
|
2020-05-04 05:04:30 +00:00
|
|
|
|
|
2020-02-12 10:52:47 +00:00
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
|
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
public override void OnResuming(IScreen last)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-02-03 07:04:32 +00:00
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
player = null;
|
|
|
|
|
|
|
|
|
|
if (removeAutoModOnResume)
|
|
|
|
|
{
|
2020-06-01 15:41:04 +00:00
|
|
|
|
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod()?.GetType();
|
|
|
|
|
|
|
|
|
|
if (autoType != null)
|
|
|
|
|
ModSelect.DeselectTypes(new[] { autoType }, true);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
removeAutoModOnResume = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-02 10:40:32 +00:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Enter:
|
2020-03-23 18:25:40 +00:00
|
|
|
|
case Key.KeypadEnter:
|
2020-03-02 10:40:32 +00: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 06:44:35 +00:00
|
|
|
|
protected override bool OnStart()
|
2018-04-13 09:19:50 +00: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();
|
2020-06-01 15:41:04 +00:00
|
|
|
|
var autoType = auto?.GetType();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-06-02 11:32:52 +00:00
|
|
|
|
var mods = Mods.Value;
|
2020-06-01 15:41:04 +00:00
|
|
|
|
|
2020-06-02 11:32:52 +00:00
|
|
|
|
if (autoType == null)
|
|
|
|
|
{
|
2020-06-02 14:01:01 +00:00
|
|
|
|
notifications?.Post(new SimpleNotification
|
2020-06-01 15:41:04 +00:00
|
|
|
|
{
|
2020-06-02 11:32:52 +00:00
|
|
|
|
Text = "The current ruleset doesn't have an autoplay mod avalaible!"
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mods.All(m => m.GetType() != autoType))
|
|
|
|
|
{
|
|
|
|
|
Mods.Value = mods.Append(auto).ToArray();
|
|
|
|
|
removeAutoModOnResume = true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-12 04:21:44 +00:00
|
|
|
|
SampleConfirm?.Play();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-01-31 10:10:44 +00:00
|
|
|
|
this.Push(player = new PlayerLoader(() => new Player()));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|