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
|
|
|
|
|
2022-03-29 22:06:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-18 07:55:21 +00:00
|
|
|
|
using System.Linq;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
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;
|
2017-03-14 08:58:34 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2020-06-02 11:32:52 +00:00
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Overlays.Notifications;
|
2021-01-05 07:17:42 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-05-04 05:04:30 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2017-03-14 08:58:34 +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;
|
2022-03-29 22:06:35 +00:00
|
|
|
|
using osu.Game.Utils;
|
2018-12-12 04:21:44 +00:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-14 08:58:34 +00:00
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class PlaySongSelect : SongSelect
|
|
|
|
|
{
|
2021-05-25 09:37:04 +00:00
|
|
|
|
private OsuScreen playerLoader;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-06-02 14:01:01 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2022-04-18 10:59:57 +00:00
|
|
|
|
private INotificationOverlay notifications { get; set; }
|
2020-06-02 11:32:52 +00:00
|
|
|
|
|
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)
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
2020-11-01 21:50:38 +00:00
|
|
|
|
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit());
|
2020-02-12 10:52:47 +00:00
|
|
|
|
|
2020-05-04 05:04:30 +00:00
|
|
|
|
((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += PresentScore;
|
2017-03-16 03:34:21 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-05-04 05:04:30 +00:00
|
|
|
|
protected void PresentScore(ScoreInfo score) =>
|
2021-10-04 08:35:53 +00:00
|
|
|
|
FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score, false)));
|
2020-05-04 05:04:30 +00:00
|
|
|
|
|
2020-02-12 10:52:47 +00:00
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 22:06:35 +00:00
|
|
|
|
private IReadOnlyList<Mod> modsAtGameplayStart;
|
|
|
|
|
|
|
|
|
|
private ModAutoplay getAutoplayMod() => Ruleset.Value.CreateInstance().GetAutoplayMod();
|
|
|
|
|
|
2018-05-30 06:44:35 +00:00
|
|
|
|
protected override bool OnStart()
|
2017-03-14 08:58:34 +00:00
|
|
|
|
{
|
2021-05-25 09:37:04 +00:00
|
|
|
|
if (playerLoader != null) return false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-03-29 22:06:35 +00:00
|
|
|
|
modsAtGameplayStart = Mods.Value;
|
|
|
|
|
|
2017-12-15 03:08:11 +00:00
|
|
|
|
// Ctrl+Enter should start map with autoplay enabled.
|
|
|
|
|
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
|
|
|
|
{
|
2021-05-25 09:37:04 +00:00
|
|
|
|
var autoInstance = getAutoplayMod();
|
2020-06-01 15:41:04 +00:00
|
|
|
|
|
2021-05-25 09:37:04 +00:00
|
|
|
|
if (autoInstance == null)
|
2020-06-02 11:32:52 +00:00
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 22:06:35 +00:00
|
|
|
|
var mods = Mods.Value.Append(autoInstance).ToArray();
|
2021-01-05 07:17:42 +00:00
|
|
|
|
|
2022-03-29 22:06:35 +00:00
|
|
|
|
if (!ModUtils.CheckCompatibleSet(mods, out var invalid))
|
|
|
|
|
mods = mods.Except(invalid).Append(autoInstance).ToArray();
|
|
|
|
|
|
|
|
|
|
Mods.Value = mods;
|
2017-12-15 03:08:11 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
2021-05-25 09:37:04 +00:00
|
|
|
|
this.Push(playerLoader = new PlayerLoader(createPlayer));
|
2017-12-28 12:07:19 +00:00
|
|
|
|
return true;
|
2021-05-25 09:37:04 +00:00
|
|
|
|
|
|
|
|
|
Player createPlayer()
|
|
|
|
|
{
|
2022-03-29 07:45:21 +00:00
|
|
|
|
var replayGeneratingMod = Mods.Value.OfType<ICreateReplayData>().FirstOrDefault();
|
|
|
|
|
|
2021-06-01 05:22:16 +00:00
|
|
|
|
if (replayGeneratingMod != null)
|
2022-03-29 07:45:21 +00:00
|
|
|
|
{
|
2022-03-30 20:03:51 +00:00
|
|
|
|
return new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods));
|
2022-03-29 07:45:21 +00:00
|
|
|
|
}
|
2021-05-25 09:37:04 +00:00
|
|
|
|
|
|
|
|
|
return new SoloPlayer();
|
|
|
|
|
}
|
2017-03-14 08:58:34 +00:00
|
|
|
|
}
|
2022-03-29 22:06:35 +00:00
|
|
|
|
|
2022-04-21 15:52:44 +00:00
|
|
|
|
public override void OnResuming(ScreenTransitionEvent e)
|
2022-03-29 22:06:35 +00:00
|
|
|
|
{
|
2022-04-21 15:52:44 +00:00
|
|
|
|
base.OnResuming(e);
|
2022-03-29 22:06:35 +00:00
|
|
|
|
|
|
|
|
|
if (playerLoader != null)
|
|
|
|
|
{
|
|
|
|
|
Mods.Value = modsAtGameplayStart;
|
|
|
|
|
playerLoader = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-14 08:58:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|