2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
2023-05-25 16:15:31 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2023-01-18 14:45:16 +08:00
|
|
|
|
public partial class DefaultSongProgressGraph : SquareGraph
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private IEnumerable<HitObject> objects;
|
|
|
|
|
|
|
|
|
|
public IEnumerable<HitObject> Objects
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
objects = value;
|
|
|
|
|
|
|
|
|
|
const int granularity = 200;
|
|
|
|
|
Values = new int[granularity];
|
|
|
|
|
|
|
|
|
|
if (!objects.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
2023-05-25 16:15:31 +08:00
|
|
|
|
(double firstHit, double lastHit) = BeatmapExtensions.CalculatePlayableBounds(objects);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
if (lastHit == 0)
|
|
|
|
|
lastHit = objects.Last().StartTime;
|
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
double interval = (lastHit - firstHit + 1) / granularity;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
foreach (var h in objects)
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
double endTime = h.GetEndTime();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
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]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|