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