1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 12:42:54 +08:00

Split results screen to allow for extensibility

This commit is contained in:
smoogipoo 2018-12-21 16:28:33 +09:00 committed by Dean Herbert
parent e3308010c0
commit daa6292e08
14 changed files with 147 additions and 76 deletions

View File

@ -8,7 +8,9 @@ using osu.Framework.Allocation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Screens.Ranking.Pages;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -23,8 +25,8 @@ namespace osu.Game.Tests.Visual
typeof(ScoreInfo), typeof(ScoreInfo),
typeof(Results), typeof(Results),
typeof(ResultsPage), typeof(ResultsPage),
typeof(ResultsPageScore), typeof(ScoreResultsPage),
typeof(ResultsPageRanking) typeof(RankingResultsPage)
}; };
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -41,7 +43,7 @@ namespace osu.Game.Tests.Visual
if (beatmapInfo != null) if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo); Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
Add(new Results(new ScoreInfo Add(new SoloResults(new ScoreInfo
{ {
TotalScore = 2845370, TotalScore = 2845370,
Accuracy = 0.98, Accuracy = 0.98,

View File

@ -28,7 +28,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Storyboards.Drawables; using osu.Game.Storyboards.Drawables;
@ -288,7 +287,7 @@ namespace osu.Game.Screens.Play
if (RulesetContainer.Replay == null) if (RulesetContainer.Replay == null)
scoreManager.Import(score, true); scoreManager.Import(score, true);
Push(new Results(score)); Push(new SoloResults(score));
onCompletionEvent = null; onCompletionEvent = null;
}); });

View File

@ -0,0 +1,24 @@
// 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.Collections.Generic;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Ranking.Types;
namespace osu.Game.Screens.Play
{
public class SoloResults : Results
{
public SoloResults(ScoreInfo score)
: base(score)
{
}
protected override IEnumerable<IResultType> CreateResultTypes() => new IResultType[]
{
new ScoreResultType(Score, Beatmap),
new RankingResultType(Score, Beatmap)
};
}
}

View File

@ -3,18 +3,19 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
using osuTK; using osuTK;
using osu.Framework.Graphics.Shapes;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking.Pages
{ {
public class ResultsPageRanking : ResultsPage public class RankingResultsPage : ResultsPage
{ {
public ResultsPageRanking(ScoreInfo score, WorkingBeatmap beatmap = null) : base(score, beatmap) public RankingResultsPage(ScoreInfo score, WorkingBeatmap beatmap = null)
: base(score, beatmap)
{ {
} }

View File

@ -12,7 +12,7 @@ using osu.Game.Scoring;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking.Pages
{ {
public class ResultsPage : Container public class ResultsPage : Container
{ {

View File

@ -4,36 +4,39 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Users; using osu.Game.Users;
using osu.Framework.Graphics.Shapes; using osuTK;
using osu.Framework.Extensions; using osuTK.Graphics;
using osu.Framework.Localisation;
using osu.Game.Online.Leaderboards;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking.Pages
{ {
public class ResultsPageScore : ResultsPage public class ScoreResultsPage : ResultsPage
{ {
private Container scoreContainer; private Container scoreContainer;
private ScoreCounter scoreCounter; private ScoreCounter scoreCounter;
public ResultsPageScore(ScoreInfo score, WorkingBeatmap beatmap) : base(score, beatmap) { } public ScoreResultsPage(ScoreInfo score, WorkingBeatmap beatmap)
: base(score, beatmap)
{
}
private FillFlowContainer<DrawableScoreStatistic> statisticsContainer; private FillFlowContainer<DrawableScoreStatistic> statisticsContainer;

View File

@ -1,12 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Ranking
{
public enum ResultMode
{
Summary,
Ranking,
Share
}
}

View File

@ -10,30 +10,21 @@ using osu.Game.Graphics;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Screens.Ranking.Types;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
public class ResultModeButton : TabItem<ResultMode> public class ResultModeButton : TabItem<IResultType>
{ {
private readonly FontAwesome icon; private readonly FontAwesome icon;
private Color4 activeColour; private Color4 activeColour;
private Color4 inactiveColour; private Color4 inactiveColour;
private CircularContainer colouredPart; private CircularContainer colouredPart;
public ResultModeButton(ResultMode mode) : base(mode) public ResultModeButton(IResultType mode)
: base(mode)
{ {
switch (mode) icon = mode.Icon;
{
case ResultMode.Summary:
icon = FontAwesome.fa_asterisk;
break;
case ResultMode.Ranking:
icon = FontAwesome.fa_list;
break;
case ResultMode.Share:
icon = FontAwesome.fa_camera;
break;
}
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -3,11 +3,12 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Screens.Ranking.Types;
using osuTK; using osuTK;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
public class ResultModeTabControl : TabControl<ResultMode> public class ResultModeTabControl : TabControl<IResultType>
{ {
public ResultModeTabControl() public ResultModeTabControl()
{ {
@ -19,9 +20,9 @@ namespace osu.Game.Screens.Ranking
TabContainer.Padding = new MarginPadding(5); TabContainer.Padding = new MarginPadding(5);
} }
protected override Dropdown<ResultMode> CreateDropdown() => null; protected override Dropdown<IResultType> CreateDropdown() => null;
protected override TabItem<ResultMode> CreateTabItem(ResultMode value) => new ResultModeButton(value) protected override TabItem<IResultType> CreateTabItem(IResultType value) => new ResultModeButton(value)
{ {
Anchor = TabContainer.Anchor, Anchor = TabContainer.Anchor,
Origin = TabContainer.Origin Origin = TabContainer.Origin

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
@ -18,12 +19,12 @@ using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Types;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
public class Results : OsuScreen public abstract class Results : OsuScreen
{ {
private readonly ScoreInfo score;
private Container circleOuterBackground; private Container circleOuterBackground;
private Container circleOuter; private Container circleOuter;
private Container circleInner; private Container circleInner;
@ -34,6 +35,8 @@ namespace osu.Game.Screens.Ranking
public override bool AllowBeatmapRulesetChange => false; public override bool AllowBeatmapRulesetChange => false;
protected readonly ScoreInfo Score;
private Container currentPage; private Container currentPage;
private static readonly Vector2 background_blur = new Vector2(20); private static readonly Vector2 background_blur = new Vector2(20);
@ -44,9 +47,9 @@ namespace osu.Game.Screens.Ranking
private const float circle_outer_scale = 0.96f; private const float circle_outer_scale = 0.96f;
public Results(ScoreInfo score) protected Results(ScoreInfo score)
{ {
this.score = score; Score = score;
} }
private const float transition_time = 800; private const float transition_time = 800;
@ -67,7 +70,7 @@ namespace osu.Game.Screens.Ranking
backgroundParallax.FadeOut(); backgroundParallax.FadeOut();
modeChangeButtons.FadeOut(); modeChangeButtons.FadeOut();
currentPage.FadeOut(); currentPage?.FadeOut();
circleOuterBackground circleOuterBackground
.FadeIn(transition_time, Easing.OutQuint) .FadeIn(transition_time, Easing.OutQuint)
@ -90,7 +93,7 @@ namespace osu.Game.Screens.Ranking
using (BeginDelayedSequence(transition_time * 0.4f, true)) using (BeginDelayedSequence(transition_time * 0.4f, true))
{ {
modeChangeButtons.FadeIn(transition_time, Easing.OutQuint); modeChangeButtons.FadeIn(transition_time, Easing.OutQuint);
currentPage.FadeIn(transition_time, Easing.OutQuint); currentPage?.FadeIn(transition_time, Easing.OutQuint);
} }
} }
} }
@ -188,7 +191,7 @@ namespace osu.Game.Screens.Ranking
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = $"{score.MaxCombo}x", Text = $"{Score.MaxCombo}x",
TextSize = 40, TextSize = 40,
RelativePositionAxes = Axes.X, RelativePositionAxes = Axes.X,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
@ -209,7 +212,7 @@ namespace osu.Game.Screens.Ranking
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = $"{score.Accuracy:P2}", Text = $"{Score.Accuracy:P2}",
TextSize = 40, TextSize = 40,
RelativePositionAxes = Axes.X, RelativePositionAxes = Axes.X,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
@ -262,30 +265,22 @@ namespace osu.Game.Screens.Ranking
}, },
}; };
modeChangeButtons.AddItem(ResultMode.Summary); foreach (var t in CreateResultTypes())
modeChangeButtons.AddItem(ResultMode.Ranking); modeChangeButtons.AddItem(t);
//modeChangeButtons.AddItem(ResultMode.Share); modeChangeButtons.Current.Value = modeChangeButtons.Items.FirstOrDefault();
modeChangeButtons.Current.ValueChanged += mode => modeChangeButtons.Current.BindValueChanged(m =>
{ {
currentPage?.FadeOut(); currentPage?.FadeOut();
currentPage?.Expire(); currentPage?.Expire();
switch (mode) currentPage = m?.CreatePage();
{
case ResultMode.Summary:
currentPage = new ResultsPageScore(score, Beatmap.Value);
break;
case ResultMode.Ranking:
currentPage = new ResultsPageRanking(score, Beatmap.Value);
break;
}
if (currentPage != null) if (currentPage != null)
circleInner.Add(currentPage); circleInner.Add(currentPage);
}; }, true);
}
modeChangeButtons.Current.TriggerChange(); protected abstract IEnumerable<IResultType> CreateResultTypes();
}
} }
} }

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Graphics;
using osu.Game.Screens.Ranking.Pages;
namespace osu.Game.Screens.Ranking.Types
{
public interface IResultType
{
FontAwesome Icon { get; }
ResultsPage CreatePage();
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Pages;
namespace osu.Game.Screens.Ranking.Types
{
public class RankingResultType : IResultType
{
private readonly ScoreInfo score;
private readonly WorkingBeatmap beatmap;
public RankingResultType(ScoreInfo score, WorkingBeatmap beatmap)
{
this.score = score;
this.beatmap = beatmap;
}
public FontAwesome Icon => FontAwesome.fa_list;
public ResultsPage CreatePage() => new RankingResultsPage(score, beatmap);
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Pages;
namespace osu.Game.Screens.Ranking.Types
{
public class ScoreResultType : IResultType
{
private readonly ScoreInfo score;
private readonly WorkingBeatmap beatmap;
public ScoreResultType(ScoreInfo score, WorkingBeatmap beatmap)
{
this.score = score;
this.beatmap = beatmap;
}
public FontAwesome Icon => FontAwesome.fa_asterisk;
public ResultsPage CreatePage() => new ScoreResultsPage(score, beatmap);
}
}

View File

@ -28,7 +28,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Play;
using osu.Game.Screens.Select.Options; using osu.Game.Screens.Select.Options;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -210,7 +210,7 @@ namespace osu.Game.Screens.Select
}); });
} }
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s)); BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new SoloResults(s));
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]