Create abstract implementation

This commit is contained in:
smoogipoo 2020-05-26 17:00:41 +09:00
parent c86a003ef9
commit de0b6ec9f1
5 changed files with 49 additions and 16 deletions

View File

@ -479,7 +479,7 @@ protected virtual ScoreInfo CreateScore()
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !GameplayClockContainer.IsPaused.Value;
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new ResultsScreen(score);
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score);
#region Fail Logic

View File

@ -30,7 +30,7 @@ protected override void GotoRanking()
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
}
protected override ResultsScreen CreateResults(ScoreInfo score) => new ResultsScreen(score, false);
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
protected override ScoreInfo CreateScore() => score.ScoreInfo;
}

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -12,8 +12,6 @@
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
@ -21,7 +19,7 @@
namespace osu.Game.Screens.Ranking
{
public class ResultsScreen : OsuScreen
public abstract class ResultsScreen : OsuScreen
{
protected const float BACKGROUND_BLUR = 20;
@ -38,9 +36,6 @@ public class ResultsScreen : OsuScreen
[Resolved]
private IAPIProvider api { get; set; }
[Resolved]
private RulesetStore rulesets { get; set; }
public readonly ScoreInfo Score;
private readonly bool allowRetry;
@ -133,22 +128,28 @@ protected override void LoadComplete()
{
base.LoadComplete();
var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset);
req.Success += r => Schedule(() =>
var req = FetchScores(scores => Schedule(() =>
{
foreach (var s in r.Scores.Select(s => s.CreateScoreInfo(rulesets)))
foreach (var s in scores)
{
if (s.OnlineScoreID == Score.OnlineScoreID)
continue;
panels.AddScore(s);
}
});
}));
api.Queue(req);
if (req != null)
api.Queue(req);
}
/// <summary>
/// Performs a fetch/refresh of scores to be displayed.
/// </summary>
/// <param name="scoresCallback">A callback which should be called when fetching is completed. Scheduling is not required.</param>
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
protected virtual APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
public override void OnEntering(IScreen last)
{
base.OnEntering(last);

View File

@ -0,0 +1,32 @@
// 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.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Rulesets;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking
{
public class SoloResultsScreen : ResultsScreen
{
[Resolved]
private RulesetStore rulesets { get; set; }
public SoloResultsScreen(ScoreInfo score, bool allowRetry = true)
: base(score, allowRetry)
{
}
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{
var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset);
req.Success += r => scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
return req;
}
}
}

View File

@ -37,7 +37,7 @@ private void load(OsuColour colours)
}
protected void PresentScore(ScoreInfo score) =>
FinaliseSelection(score.Beatmap, score.Ruleset, () => this.Push(new ResultsScreen(score)));
FinaliseSelection(score.Beatmap, score.Ruleset, () => this.Push(new SoloResultsScreen(score)));
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();