1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 20:53:04 +08:00

Avoid showing time of play on results screen when autoplay

Closes https://github.com/ppy/osu/issues/13940.
This commit is contained in:
Dean Herbert 2021-07-20 14:46:22 +09:00
parent 6cc81c24b4
commit 662822a40c
7 changed files with 183 additions and 142 deletions

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -226,11 +227,13 @@ namespace osu.Game.Tests.Visual.Playlists
private MultiplayerScore createUserResponse([NotNull] ScoreInfo userScore) private MultiplayerScore createUserResponse([NotNull] ScoreInfo userScore)
{ {
Debug.Assert(userScore.Date != null);
var multiplayerUserScore = new MultiplayerScore var multiplayerUserScore = new MultiplayerScore
{ {
ID = (int)(userScore.OnlineScoreID ?? currentScoreId++), ID = (int)(userScore.OnlineScoreID ?? currentScoreId++),
Accuracy = userScore.Accuracy, Accuracy = userScore.Accuracy,
EndedAt = userScore.Date, EndedAt = userScore.Date.Value,
Passed = userScore.Passed, Passed = userScore.Passed,
Rank = userScore.Rank, Rank = userScore.Rank,
Position = 200, Position = 200,
@ -251,7 +254,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
ID = currentScoreId++, ID = currentScoreId++,
Accuracy = userScore.Accuracy, Accuracy = userScore.Accuracy,
EndedAt = userScore.Date, EndedAt = userScore.Date.Value,
Passed = true, Passed = true,
Rank = userScore.Rank, Rank = userScore.Rank,
MaxCombo = userScore.MaxCombo, MaxCombo = userScore.MaxCombo,
@ -269,7 +272,7 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
ID = currentScoreId++, ID = currentScoreId++,
Accuracy = userScore.Accuracy, Accuracy = userScore.Accuracy,
EndedAt = userScore.Date, EndedAt = userScore.Date.Value,
Passed = true, Passed = true,
Rank = userScore.Rank, Rank = userScore.Rank,
MaxCombo = userScore.MaxCombo, MaxCombo = userScore.MaxCombo,

View File

@ -12,6 +12,7 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
@ -50,9 +51,33 @@ namespace osu.Game.Tests.Visual.Ranking
AddAssert("mapped by text not present", () => AddAssert("mapped by text not present", () =>
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by"))); this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));
AddAssert("play time displayed", () => this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
} }
private void showPanel(ScoreInfo score) => Child = new ExpandedPanelMiddleContentContainer(score); [Test]
public void TestWithNullDate()
{
AddStep("show autoplay score", () =>
{
var ruleset = new OsuRuleset();
var mods = new Mod[] { ruleset.GetAutoplayMod() };
var beatmap = createTestBeatmap(null);
showPanel(new TestScoreInfo(ruleset.RulesetInfo)
{
Mods = mods,
Beatmap = beatmap,
Date = null,
});
});
AddAssert("play time not displayed", () => !this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
}
private void showPanel(ScoreInfo score) =>
Child = new ExpandedPanelMiddleContentContainer(score);
private BeatmapInfo createTestBeatmap(User author) private BeatmapInfo createTestBeatmap(User author)
{ {

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -136,9 +137,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
set set
{ {
Debug.Assert(value.Date != null);
avatar.User = value.User; avatar.User = value.User;
flag.Country = value.User.Country; flag.Country = value.User.Country;
achievedOn.Date = value.Date; achievedOn.Date = value.Date.Value;
usernameText.Clear(); usernameText.Clear();
usernameText.AddUserLink(value.User); usernameText.AddUserLink(value.User);

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -44,6 +45,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Debug.Assert(Score.Date != null);
AddInternal(new ProfileItemContainer AddInternal(new ProfileItemContainer
{ {
Children = new Drawable[] Children = new Drawable[]
@ -92,7 +95,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
Colour = colours.Yellow Colour = colours.Yellow
}, },
new DrawableDate(Score.Date, 12) new DrawableDate(Score.Date.Value, 12)
{ {
Colour = colourProvider.Foreground1 Colour = colourProvider.Foreground1
} }

View File

@ -59,7 +59,7 @@ namespace osu.Game.Scoring.Legacy
sw.Write((int)score.ScoreInfo.Ruleset.CreateInstance().ConvertToLegacyMods(score.ScoreInfo.Mods)); sw.Write((int)score.ScoreInfo.Ruleset.CreateInstance().ConvertToLegacyMods(score.ScoreInfo.Mods));
sw.Write(getHpGraphFormatted()); sw.Write(getHpGraphFormatted());
sw.Write(score.ScoreInfo.Date.DateTime); sw.Write((score.ScoreInfo.Date ?? DateTimeOffset.Now).DateTime);
sw.WriteByteArray(createReplayData()); sw.WriteByteArray(createReplayData());
sw.Write((long)0); sw.Write((long)0);
writeModSpecificData(score.ScoreInfo, sw); writeModSpecificData(score.ScoreInfo, sw);

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -155,7 +156,8 @@ namespace osu.Game.Scoring
public long? OnlineScoreID { get; set; } public long? OnlineScoreID { get; set; }
[JsonIgnore] [JsonIgnore]
public DateTimeOffset Date { get; set; } [CanBeNull] // may be null in cases of autoplay.
public DateTimeOffset? Date { get; set; }
[JsonProperty("statistics")] [JsonProperty("statistics")]
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>(); public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -79,162 +80,155 @@ namespace osu.Game.Screens.Ranking.Expanded
var starDifficulty = beatmapDifficultyCache.GetDifficultyAsync(beatmap, score.Ruleset, score.Mods).Result; var starDifficulty = beatmapDifficultyCache.GetDifficultyAsync(beatmap, score.Ruleset, score.Mods).Result;
InternalChildren = new Drawable[] AddInternal(new FillFlowContainer
{ {
new FillFlowContainer RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, new FillFlowContainer
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Children = new Drawable[]
{ {
new FillFlowContainer Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{ {
Anchor = Anchor.TopCentre, new OsuSpriteText
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{ {
new OsuSpriteText Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = new RomanisableString(metadata.TitleUnicode, metadata.Title),
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 40 },
RelativeSizeAxes = Axes.X,
Height = 230,
Child = new AccuracyCircle(score, withFlair)
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.Centre,
Origin = Anchor.TopCentre, Origin = Anchor.Centre,
Text = new RomanisableString(metadata.TitleUnicode, metadata.Title), RelativeSizeAxes = Axes.Both,
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), FillMode = FillMode.Fit,
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2, }
Truncate = true, },
}, scoreCounter = new TotalScoreCounter
new OsuSpriteText {
Margin = new MarginPadding { Top = 0, Bottom = 5 },
Current = { Value = 0 },
Alpha = 0,
AlwaysPresent = true
},
starAndModDisplay = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{ {
Anchor = Anchor.TopCentre, new StarRatingDisplay(starDifficulty)
Origin = Anchor.TopCentre,
Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
Truncate = true,
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 40 },
RelativeSizeAxes = Axes.X,
Height = 230,
Child = new AccuracyCircle(score, withFlair)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre, Origin = Anchor.CentreLeft
RelativeSizeAxes = Axes.Both, },
FillMode = FillMode.Fit, }
} },
}, new FillFlowContainer
scoreCounter = new TotalScoreCounter {
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
Margin = new MarginPadding { Top = 0, Bottom = 5 }, new OsuSpriteText
Current = { Value = 0 },
Alpha = 0,
AlwaysPresent = true
},
starAndModDisplay = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{ {
new StarRatingDisplay(starDifficulty) Anchor = Anchor.TopCentre,
{ Origin = Anchor.TopCentre,
Anchor = Anchor.CentreLeft, Text = beatmap.Version,
Origin = Anchor.CentreLeft Font = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold),
}, },
} new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12))
},
new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
new OsuSpriteText Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
}.With(t =>
{
if (!string.IsNullOrEmpty(creator))
{ {
Anchor = Anchor.TopCentre, t.AddText("mapped by ");
Origin = Anchor.TopCentre, t.AddText(creator, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
Text = beatmap.Version, }
Font = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold), })
}, }
new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12)) },
{ }
Anchor = Anchor.TopCentre, },
Origin = Anchor.TopCentre, new FillFlowContainer
AutoSizeAxes = Axes.Both, {
Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X,
}.With(t => AutoSizeAxes = Axes.Y,
{ Direction = FillDirection.Vertical,
if (!string.IsNullOrEmpty(creator)) Spacing = new Vector2(0, 5),
{ Children = new Drawable[]
t.AddText("mapped by ");
t.AddText(creator, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
}
})
}
},
}
},
new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, new GridContainer
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{ {
new GridContainer RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[] { topStatistics.Cast<Drawable>().ToArray() },
RowDimensions = new[]
{ {
RelativeSizeAxes = Axes.X, new Dimension(GridSizeMode.AutoSize),
AutoSizeAxes = Axes.Y, }
Content = new[] { topStatistics.Cast<Drawable>().ToArray() }, },
RowDimensions = new[] new GridContainer
{ {
new Dimension(GridSizeMode.AutoSize), RelativeSizeAxes = Axes.X,
} AutoSizeAxes = Axes.Y,
}, Content = new[] { bottomStatistics.Where(s => s.Result <= HitResult.Perfect).ToArray() },
new GridContainer RowDimensions = new[]
{ {
RelativeSizeAxes = Axes.X, new Dimension(GridSizeMode.AutoSize),
AutoSizeAxes = Axes.Y, }
Content = new[] { bottomStatistics.Where(s => s.Result <= HitResult.Perfect).ToArray() }, },
RowDimensions = new[] new GridContainer
{ {
new Dimension(GridSizeMode.AutoSize), RelativeSizeAxes = Axes.X,
} AutoSizeAxes = Axes.Y,
}, Content = new[] { bottomStatistics.Where(s => s.Result > HitResult.Perfect).ToArray() },
new GridContainer RowDimensions = new[]
{ {
RelativeSizeAxes = Axes.X, new Dimension(GridSizeMode.AutoSize),
AutoSizeAxes = Axes.Y,
Content = new[] { bottomStatistics.Where(s => s.Result > HitResult.Perfect).ToArray() },
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
}
} }
} }
} }
} }
},
new OsuSpriteText
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
Text = $"Played on {score.Date.ToLocalTime():d MMMM yyyy HH:mm}"
} }
}; });
if (score.Date != null)
AddInternal(new PlayedOnText(score.Date.Value));
if (score.Mods.Any()) if (score.Mods.Any())
{ {
@ -276,5 +270,16 @@ namespace osu.Game.Screens.Ranking.Expanded
FinishTransforms(true); FinishTransforms(true);
}); });
} }
public class PlayedOnText : OsuSpriteText
{
public PlayedOnText(DateTimeOffset time)
{
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold);
Text = $"Played on {time.ToLocalTime():d MMMM yyyy HH:mm}";
}
}
} }
} }