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

replace Play with Score

This commit is contained in:
Jorolf 2017-07-29 00:31:52 +02:00
parent 7b8997cfc2
commit 0fc36065f4
6 changed files with 32 additions and 52 deletions

View File

@ -41,12 +41,11 @@ namespace osu.Desktop.VisualTests.Tests
}
});
AddStep("Add First Place", () => ranks.FirstPlacePlays = new[]
AddStep("Add First Place", () => ranks.FirstPlaceScores = new[]
{
new Play
new Score
{
Rank = ScoreRank.A,
PerformancePoints = 666,
Accuracy = 0.735,
Date = DateTimeOffset.UtcNow,
Mods = new Mod[] { new ModAutoplay(), new ModDoubleTime() },
@ -65,18 +64,17 @@ namespace osu.Desktop.VisualTests.Tests
AddStep("Add Best Performances", () =>
{
List<Play> plays = new List<Play>();
List<Score> scores = new List<Score>();
Mod[] availableMods = { new OsuModHidden(), new OsuModFlashlight(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModPerfect() };
List<Mod> selectedMods = new List<Mod>(availableMods);
for (int i = 0; i <= availableMods.Length; i++)
{
plays.Add(new Play
scores.Add(new Score
{
Rank = (ScoreRank) Enum.GetValues(typeof(ScoreRank)).GetValue(Enum.GetValues(typeof(ScoreRank)).Length - 1 - i),
PerformancePoints = (int)(Math.Pow(0.50, i) * 800),
Accuracy = Math.Pow(0.99, i),
Date = DateTimeOffset.UtcNow.AddDays(-Math.Pow(i, 2)),
Mods = selectedMods.ToList(),
Mods = selectedMods.ToArray(),
Beatmap = new BeatmapInfo
{
Metadata = new BeatmapMetadata
@ -91,7 +89,7 @@ namespace osu.Desktop.VisualTests.Tests
if(i < availableMods.Length)
selectedMods.Remove(availableMods[i]);
}
ranks.BestPlays = plays;
ranks.BestScores = scores;
});
}
}

View File

@ -17,25 +17,26 @@ using System.Diagnostics;
using osu.Framework.Input;
using osu.Framework.Localisation;
using System.Globalization;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
public class DrawablePlay : Container
public class DrawableScore : Container
{
private readonly FillFlowContainer<OsuSpriteText> stats;
private readonly FillFlowContainer metadata;
private readonly ModContainer modContainer;
private readonly Play play;
private readonly Score score;
private readonly double weight;
public DrawablePlay(Play play, double weight = -1)
public DrawableScore(Score score, double weight = -1)
{
this.play = play;
this.score = score;
this.weight = weight;
Children = new Drawable[]
{
new DrawableRank(play.Rank)
new DrawableRank(score.Rank)
{
RelativeSizeAxes = Axes.Y,
Width = 60,
@ -59,7 +60,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Direction = FillDirection.Vertical,
Child = new OsuSpriteText
{
Text = play.Date.LocalDateTime.ToShortDateString(),
Text = score.Date.LocalDateTime.ToShortDateString(),
TextSize = 11,
Colour = OsuColour.Gray(0xAA),
Depth = -1,
@ -80,7 +81,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
private void load(OsuColour colour, LocalisationEngine locale)
{
stats.Add(new OsuSpriteText {
Text = play.PerformancePoints + "pp",
Text = score.PP + "pp",
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
TextSize = 18,
@ -90,7 +91,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
stats.Add(new OsuSpriteText
{
Text = $"weighted: {(int)(play.PerformancePoints * weight)}pp ({weight.ToString("0%", CultureInfo.CurrentCulture)})",
Text = $"weighted: {(int)(score.PP * weight)}pp ({weight.ToString("0%", CultureInfo.CurrentCulture)})",
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Colour = colour.GrayA,
@ -99,7 +100,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
});
}
stats.Add(new OsuSpriteText {
Text = "accuracy: " + play.Accuracy.ToString("0.00%"),
Text = "accuracy: " + score.Accuracy.ToString("0.00%"),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Colour = colour.GrayA,
@ -110,7 +111,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
metadata.Add(new LinkContainer
{
AutoSizeAxes = Axes.Both,
Url = $"https://osu.ppy.sh/beatmaps/{play.Beatmap.OnlineBeatmapID}",
Url = $"https://osu.ppy.sh/beatmaps/{score.Beatmap.OnlineBeatmapID}",
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
@ -118,13 +119,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
new OsuSpriteText
{
Current = locale.GetUnicodePreference($"{play.Beatmap.Metadata.TitleUnicode ?? play.Beatmap.Metadata.Title} [{play.Beatmap.Version}] ", $"{play.Beatmap.Metadata.Title ?? play.Beatmap.Metadata.TitleUnicode} [{play.Beatmap.Version}] "),
Current = locale.GetUnicodePreference($"{score.Beatmap.Metadata.TitleUnicode ?? score.Beatmap.Metadata.Title} [{score.Beatmap.Version}] ", $"{score.Beatmap.Metadata.Title ?? score.Beatmap.Metadata.TitleUnicode} [{score.Beatmap.Version}] "),
TextSize = 15,
Font = "Exo2.0-SemiBoldItalic",
},
new OsuSpriteText
{
Current = locale.GetUnicodePreference(play.Beatmap.Metadata.ArtistUnicode, play.Beatmap.Metadata.Artist),
Current = locale.GetUnicodePreference(score.Beatmap.Metadata.ArtistUnicode, score.Beatmap.Metadata.Artist),
TextSize = 12,
Padding = new MarginPadding { Top = 3 },
Font = "Exo2.0-RegularItalic",
@ -133,7 +134,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
},
});
foreach (Mod mod in play.Mods)
foreach (Mod mod in score.Mods)
modContainer.Add(new ModIcon(mod.Icon, colour.Yellow));
}

View File

@ -1,21 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Database;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using System;
using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
public class Play
{
public ScoreRank Rank;
public BeatmapInfo Beatmap;
public DateTimeOffset Date;
public IEnumerable<Mod> Mods;
public int PerformancePoints;
public double Accuracy;
}
}

View File

@ -5,6 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Profile.Sections.Ranks;
using osu.Game.Rulesets.Scoring;
using System;
using System.Collections.Generic;
@ -16,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Sections
public override string Identifier => "top_ranks";
private readonly FillFlowContainer<DrawablePlay> best, firstPlace;
private readonly FillFlowContainer<DrawableScore> best, firstPlace;
public RanksSection()
{
@ -27,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections
Text = "Best Performance",
Font = "Exo2.0-RegularItalic",
},
best = new FillFlowContainer<DrawablePlay>
best = new FillFlowContainer<DrawableScore>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Profile.Sections
Text = "First Place Ranks",
Font = "Exo2.0-RegularItalic",
},
firstPlace = new FillFlowContainer<DrawablePlay>
firstPlace = new FillFlowContainer<DrawableScore>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -47,14 +48,14 @@ namespace osu.Game.Overlays.Profile.Sections
};
}
public IEnumerable<Play> BestPlays
public IEnumerable<Score> BestScores
{
set
{
int i = 0;
foreach (Play play in value)
foreach (Score score in value)
{
best.Add(new DrawablePlay(play, Math.Pow(0.95, i))
best.Add(new DrawableScore(score, Math.Pow(0.95, i))
{
RelativeSizeAxes = Axes.X,
Height = 60,
@ -64,12 +65,12 @@ namespace osu.Game.Overlays.Profile.Sections
}
}
public IEnumerable<Play> FirstPlacePlays
public IEnumerable<Score> FirstPlaceScores
{
set
{
foreach (Play play in value)
firstPlace.Add(new DrawablePlay(play)
foreach (Score score in value)
firstPlace.Add(new DrawableScore(score)
{
RelativeSizeAxes = Axes.X,
Height = 60,

View File

@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Scoring
public double Health { get; set; } = 1;
public double PP { get; set; }
[JsonProperty(@"max_combo")]
public int MaxCombo { get; set; }

View File

@ -99,7 +99,6 @@
<Compile Include="Overlays\OnScreenDisplay.cs" />
<Compile Include="Graphics\Containers\SectionsContainer.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\DrawablePlay.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\Play.cs" />
<Compile Include="Overlays\Settings\SettingsHeader.cs" />
<Compile Include="Overlays\Settings\Sections\Audio\MainMenuSettings.cs" />
<Compile Include="Overlays\Toolbar\ToolbarChatButton.cs" />