mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Split results screen to allow for extensibility
This commit is contained in:
parent
e3308010c0
commit
daa6292e08
@ -8,7 +8,9 @@ using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Pages;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -23,8 +25,8 @@ namespace osu.Game.Tests.Visual
|
||||
typeof(ScoreInfo),
|
||||
typeof(Results),
|
||||
typeof(ResultsPage),
|
||||
typeof(ResultsPageScore),
|
||||
typeof(ResultsPageRanking)
|
||||
typeof(ScoreResultsPage),
|
||||
typeof(RankingResultsPage)
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -41,7 +43,7 @@ namespace osu.Game.Tests.Visual
|
||||
if (beatmapInfo != null)
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
|
||||
|
||||
Add(new Results(new ScoreInfo
|
||||
Add(new SoloResults(new ScoreInfo
|
||||
{
|
||||
TotalScore = 2845370,
|
||||
Accuracy = 0.98,
|
||||
|
@ -28,7 +28,6 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
|
||||
@ -288,7 +287,7 @@ namespace osu.Game.Screens.Play
|
||||
if (RulesetContainer.Replay == null)
|
||||
scoreManager.Import(score, true);
|
||||
|
||||
Push(new Results(score));
|
||||
Push(new SoloResults(score));
|
||||
|
||||
onCompletionEvent = null;
|
||||
});
|
||||
|
24
osu.Game/Screens/Play/SoloResults.cs
Normal file
24
osu.Game/Screens/Play/SoloResults.cs
Normal 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)
|
||||
};
|
||||
}
|
||||
}
|
@ -3,18 +3,19 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
namespace osu.Game.Screens.Ranking.Pages
|
||||
{
|
||||
public class ResultsPage : Container
|
||||
{
|
@ -4,36 +4,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
namespace osu.Game.Screens.Ranking.Pages
|
||||
{
|
||||
public class ResultsPageScore : ResultsPage
|
||||
public class ScoreResultsPage : ResultsPage
|
||||
{
|
||||
private Container scoreContainer;
|
||||
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;
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -10,30 +10,21 @@ using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Screens.Ranking.Types;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public class ResultModeButton : TabItem<ResultMode>
|
||||
public class ResultModeButton : TabItem<IResultType>
|
||||
{
|
||||
private readonly FontAwesome icon;
|
||||
private Color4 activeColour;
|
||||
private Color4 inactiveColour;
|
||||
private CircularContainer colouredPart;
|
||||
|
||||
public ResultModeButton(ResultMode mode) : base(mode)
|
||||
public ResultModeButton(IResultType mode)
|
||||
: base(mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case ResultMode.Summary:
|
||||
icon = FontAwesome.fa_asterisk;
|
||||
break;
|
||||
case ResultMode.Ranking:
|
||||
icon = FontAwesome.fa_list;
|
||||
break;
|
||||
case ResultMode.Share:
|
||||
icon = FontAwesome.fa_camera;
|
||||
break;
|
||||
}
|
||||
icon = mode.Icon;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -3,11 +3,12 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Ranking.Types;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public class ResultModeTabControl : TabControl<ResultMode>
|
||||
public class ResultModeTabControl : TabControl<IResultType>
|
||||
{
|
||||
public ResultModeTabControl()
|
||||
{
|
||||
@ -19,9 +20,9 @@ namespace osu.Game.Screens.Ranking
|
||||
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,
|
||||
Origin = TabContainer.Origin
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
@ -18,12 +19,12 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking.Types;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public class Results : OsuScreen
|
||||
public abstract class Results : OsuScreen
|
||||
{
|
||||
private readonly ScoreInfo score;
|
||||
private Container circleOuterBackground;
|
||||
private Container circleOuter;
|
||||
private Container circleInner;
|
||||
@ -34,6 +35,8 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
public override bool AllowBeatmapRulesetChange => false;
|
||||
|
||||
protected readonly ScoreInfo Score;
|
||||
|
||||
private Container currentPage;
|
||||
|
||||
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;
|
||||
|
||||
public Results(ScoreInfo score)
|
||||
protected Results(ScoreInfo score)
|
||||
{
|
||||
this.score = score;
|
||||
Score = score;
|
||||
}
|
||||
|
||||
private const float transition_time = 800;
|
||||
@ -67,7 +70,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
backgroundParallax.FadeOut();
|
||||
modeChangeButtons.FadeOut();
|
||||
currentPage.FadeOut();
|
||||
currentPage?.FadeOut();
|
||||
|
||||
circleOuterBackground
|
||||
.FadeIn(transition_time, Easing.OutQuint)
|
||||
@ -90,7 +93,7 @@ namespace osu.Game.Screens.Ranking
|
||||
using (BeginDelayedSequence(transition_time * 0.4f, true))
|
||||
{
|
||||
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
|
||||
{
|
||||
Text = $"{score.MaxCombo}x",
|
||||
Text = $"{Score.MaxCombo}x",
|
||||
TextSize = 40,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Font = @"Exo2.0-Bold",
|
||||
@ -209,7 +212,7 @@ namespace osu.Game.Screens.Ranking
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $"{score.Accuracy:P2}",
|
||||
Text = $"{Score.Accuracy:P2}",
|
||||
TextSize = 40,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Font = @"Exo2.0-Bold",
|
||||
@ -262,30 +265,22 @@ namespace osu.Game.Screens.Ranking
|
||||
},
|
||||
};
|
||||
|
||||
modeChangeButtons.AddItem(ResultMode.Summary);
|
||||
modeChangeButtons.AddItem(ResultMode.Ranking);
|
||||
//modeChangeButtons.AddItem(ResultMode.Share);
|
||||
foreach (var t in CreateResultTypes())
|
||||
modeChangeButtons.AddItem(t);
|
||||
modeChangeButtons.Current.Value = modeChangeButtons.Items.FirstOrDefault();
|
||||
|
||||
modeChangeButtons.Current.ValueChanged += mode =>
|
||||
modeChangeButtons.Current.BindValueChanged(m =>
|
||||
{
|
||||
currentPage?.FadeOut();
|
||||
currentPage?.Expire();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ResultMode.Summary:
|
||||
currentPage = new ResultsPageScore(score, Beatmap.Value);
|
||||
break;
|
||||
case ResultMode.Ranking:
|
||||
currentPage = new ResultsPageRanking(score, Beatmap.Value);
|
||||
break;
|
||||
}
|
||||
currentPage = m?.CreatePage();
|
||||
|
||||
if (currentPage != null)
|
||||
circleInner.Add(currentPage);
|
||||
};
|
||||
|
||||
modeChangeButtons.Current.TriggerChange();
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected abstract IEnumerable<IResultType> CreateResultTypes();
|
||||
}
|
||||
}
|
||||
|
15
osu.Game/Screens/Ranking/Types/IResultType.cs
Normal file
15
osu.Game/Screens/Ranking/Types/IResultType.cs
Normal 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();
|
||||
}
|
||||
}
|
26
osu.Game/Screens/Ranking/Types/RankingResultType.cs
Normal file
26
osu.Game/Screens/Ranking/Types/RankingResultType.cs
Normal 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);
|
||||
}
|
||||
}
|
26
osu.Game/Screens/Ranking/Types/ScoreResultType.cs
Normal file
26
osu.Game/Screens/Ranking/Types/ScoreResultType.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
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)]
|
||||
|
Loading…
Reference in New Issue
Block a user