1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 23:50:42 +08:00
Files
osu-lazer/osu.Game/Screens/Select/BeatmapMetadataWedge.RatingSpreadDisplay.cs
T
Dan Balasescu 0988552567 Implement ranked play (#36819)
I don't really have much to say here. Instead, I'll give a brief history
rundown that lists many pages of documentation you can read, if
interested.

- Started off as BTMC + Happy24 (Vivi)'s ["The
Vision"](https://docs.google.com/document/d/1p1IpPmd2RICp8G4OqkCSs7u8Ug8FbFv8qqP0mfSrHf0/edit?tab=t.0#heading=h.fol093d9f9xi)
- Initial
[designs](https://www.figma.com/design/f5qqC57t9jFlgpzhRqUNVX/The-Vision?node-id=0-1&p=f)
were led by Vivi.
- Designs
[morphed](https://www.figma.com/design/vtFmLrXKvWNyYiRjTezFTM/Untitled--Copy-?node-id=0-1&p=f)
during development into what's currently present, led by @minetoblend.
- There is some more ongoing work creating a [game design
document](https://docs.google.com/document/d/1iffJFCsIBfYF0D4ogItSBEj6YBmbp-rdCpItAeaJiTA/edit?tab=t.0).

**tl;dr:** Create something with the mechanics of a trading card game
within osu!. The name of this is "ranked play".

---

To be frank, a lot of stuff is missing here. Some of it I don't want to
mention, because the point of this exercise is to get the system into
the hands of players, gather feedback especially around mechanics, and
discuss any further direction with the team.

I am expecting a blanket approval on all of the new code, with
particular attention to changes in existing components that I'll point
out in a self review.

There is also some [ongoing
work](https://github.com/smoogipoo/osu/pulls) that may arrive in this
branch prior to being merged.

---------

Co-authored-by: maarvin <minetoblend@gmail.com>
Co-authored-by: Marvin <m.schuerz@hautzy.com>
Co-authored-by: Jamie Taylor <me@nekodex.net>
Co-authored-by: ArijanJ <arijanj@proton.me>
Co-authored-by: Dean Herbert <pe@ppy.sh>
Co-authored-by: Tim Oliver <git@tim.dev>
Co-authored-by: Joseph Madamba <madamba.joehu@outlook.com>
Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
Co-authored-by: nil <25884226+voidstar0@users.noreply.github.com>
Co-authored-by: Ботников Максим <mr.botnikoff@ya.ru>
Co-authored-by: Denis Titovets <den232titovets@yandex.ru>
Co-authored-by: Michael Middlezong <119022671+mmiddlezong@users.noreply.github.com>
Co-authored-by: SupDos <6813986+SupDos@users.noreply.github.com>
Co-authored-by: failaip12 <86018517+failaip12@users.noreply.github.com>
2026-03-07 02:30:50 +09:00

124 lines
4.7 KiB
C#

// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Resources.Localisation.Web;
using osuTK;
namespace osu.Game.Screens.Select
{
public partial class BeatmapMetadataWedge
{
public partial class RatingSpreadDisplay : CompositeDrawable
{
private const float min_height = 4f;
private const float max_height = 32f;
private const int rating_range = 10;
private readonly GraphBar[] graph;
public int[] Data
{
set
{
if (!value.Any())
{
foreach (var bar in graph)
bar.ResizeHeightTo(min_height, 300, Easing.OutQuint);
}
else
{
var usableRange = value.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
int maxRating = usableRange.Max();
for (int i = 0; i < graph.Length; i++)
graph[i].ResizeHeightTo(min_height + (max_height - min_height) * (maxRating == 0 ? 0 : usableRange.ElementAt(i) / (float)maxRating), 300, Easing.OutQuint);
}
}
}
public RatingSpreadDisplay()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
graph = Enumerable.Range(0, rating_range).Select(_ => new GraphBar()).ToArray();
InternalChildren = new[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0f, 1f),
Children = new Drawable[]
{
new OsuSpriteText
{
Text = BeatmapsetsStrings.ShowStatsRatingSpread,
Font = OsuFont.Style.Caption1.With(weight: FontWeight.SemiBold),
},
new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, max_height) },
ColumnDimensions = graph.SkipLast(1).Select(_ => new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 1f),
}).SelectMany(d => d).Append(new Dimension()).ToArray(),
Content = new[]
{
graph.SkipLast(1).Select(g => new[]
{
g,
Empty()
}).SelectMany(g => g).Append(graph[^1]).ToArray()
},
}
},
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
for (int i = 0; i < 10; i++)
{
var left = Interpolation.ValueAt(i, colours.Blue4, colours.Blue0, 0, 10);
var right = Interpolation.ValueAt(i + 1, colours.Blue4, colours.Blue0, 0, 10);
graph[i].Colour = ColourInfo.GradientHorizontal(left, right);
}
}
private partial class GraphBar : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load()
{
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
RelativeSizeAxes = Axes.X;
CornerRadius = 2f;
Masking = true;
InternalChild = new Box { RelativeSizeAxes = Axes.Both };
}
}
}
}
}