2023-01-10 04:58:53 +08:00
|
|
|
// 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.Collections.Generic;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Linq;
|
2023-06-12 14:52:25 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2023-01-10 04:58:53 +08:00
|
|
|
using osu.Framework.Graphics;
|
2023-05-25 16:15:31 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2023-06-12 14:52:25 +08:00
|
|
|
using osu.Game.Graphics;
|
2023-01-10 04:58:53 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
|
|
|
public partial class ArgonSongProgressGraph : SegmentedGraph<int>
|
|
|
|
{
|
2023-06-12 14:52:25 +08:00
|
|
|
private const int tier_count = 5;
|
|
|
|
|
|
|
|
private const int display_granularity = 200;
|
|
|
|
|
2023-01-10 04:58:53 +08:00
|
|
|
private IEnumerable<HitObject>? objects;
|
|
|
|
|
|
|
|
public IEnumerable<HitObject> Objects
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
objects = value;
|
|
|
|
|
2023-06-12 14:52:25 +08:00
|
|
|
int[] values = new int[display_granularity];
|
2023-01-10 04:58:53 +08:00
|
|
|
|
|
|
|
if (!objects.Any())
|
|
|
|
return;
|
|
|
|
|
2023-05-25 16:15:31 +08:00
|
|
|
(double firstHit, double lastHit) = BeatmapExtensions.CalculatePlayableBounds(objects);
|
2023-01-10 04:58:53 +08:00
|
|
|
|
|
|
|
if (lastHit == 0)
|
|
|
|
lastHit = objects.Last().StartTime;
|
|
|
|
|
2023-06-12 14:52:25 +08:00
|
|
|
double interval = (lastHit - firstHit + 1) / display_granularity;
|
2023-01-10 04:58:53 +08:00
|
|
|
|
|
|
|
foreach (var h in objects)
|
|
|
|
{
|
|
|
|
double endTime = h.GetEndTime();
|
|
|
|
|
|
|
|
Debug.Assert(endTime >= h.StartTime);
|
|
|
|
|
|
|
|
int startRange = (int)((h.StartTime - firstHit) / interval);
|
|
|
|
int endRange = (int)((endTime - firstHit) / interval);
|
|
|
|
for (int i = startRange; i <= endRange; i++)
|
|
|
|
values[i]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Values = values;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArgonSongProgressGraph()
|
2023-06-12 14:52:25 +08:00
|
|
|
: base(tier_count)
|
2023-01-10 04:58:53 +08:00
|
|
|
{
|
2023-01-17 17:07:11 +08:00
|
|
|
var colours = new List<Colour4>();
|
|
|
|
|
2023-06-12 14:52:25 +08:00
|
|
|
for (int i = 0; i < tier_count; i++)
|
|
|
|
colours.Add(OsuColour.Gray(0.2f).Opacity(0.1f));
|
2023-01-17 17:07:11 +08:00
|
|
|
|
|
|
|
TierColours = colours;
|
2023-01-10 04:58:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|