2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-08 01:26:17 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-03-23 18:15:53 +08:00
|
|
|
|
using System.Linq;
|
2017-02-07 13:49:41 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-09-14 11:58:32 +08:00
|
|
|
|
using System.Diagnostics;
|
2017-04-18 17:40:02 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-02-04 03:22:02 +08:00
|
|
|
|
|
2017-03-02 19:20:27 +08:00
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
2017-04-18 17:40:02 +08:00
|
|
|
|
public class SongProgressGraph : SquareGraph
|
2017-02-04 03:22:02 +08:00
|
|
|
|
{
|
2017-04-18 17:40:02 +08:00
|
|
|
|
private IEnumerable<HitObject> objects;
|
2017-02-07 13:49:41 +08:00
|
|
|
|
|
2017-04-18 17:40:02 +08:00
|
|
|
|
public IEnumerable<HitObject> Objects
|
2017-03-24 11:41:14 +08:00
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-04-18 17:40:02 +08:00
|
|
|
|
objects = value;
|
2017-07-08 17:04:55 +08:00
|
|
|
|
|
2017-04-18 17:40:02 +08:00
|
|
|
|
const int granularity = 200;
|
2017-07-07 20:05:55 +08:00
|
|
|
|
Values = new int[granularity];
|
|
|
|
|
|
|
|
|
|
if (!objects.Any())
|
|
|
|
|
return;
|
2017-02-10 06:51:05 +08:00
|
|
|
|
|
2017-05-08 06:23:51 +08:00
|
|
|
|
var firstHit = objects.First().StartTime;
|
2017-07-21 09:08:39 +08:00
|
|
|
|
var lastHit = objects.Max(o => (o as IHasEndTime)?.EndTime ?? o.StartTime);
|
2017-02-10 06:51:05 +08:00
|
|
|
|
|
2017-04-19 15:02:51 +08:00
|
|
|
|
if (lastHit == 0)
|
|
|
|
|
lastHit = objects.Last().StartTime;
|
|
|
|
|
|
2017-05-08 06:23:51 +08:00
|
|
|
|
var interval = (lastHit - firstHit + 1) / granularity;
|
2017-02-10 07:08:23 +08:00
|
|
|
|
|
2017-04-18 17:40:02 +08:00
|
|
|
|
foreach (var h in objects)
|
2017-03-23 17:37:12 +08:00
|
|
|
|
{
|
2017-09-14 12:42:58 +08:00
|
|
|
|
var endTime = (h as IHasEndTime)?.EndTime ?? h.StartTime;
|
2017-09-14 11:58:32 +08:00
|
|
|
|
|
2017-09-14 12:13:54 +08:00
|
|
|
|
Debug.Assert(endTime >= h.StartTime);
|
2017-03-23 17:37:12 +08:00
|
|
|
|
|
2017-06-08 14:48:42 +08:00
|
|
|
|
int startRange = (int)((h.StartTime - firstHit) / interval);
|
2017-09-14 11:58:32 +08:00
|
|
|
|
int endRange = (int)((endTime - firstHit) / interval);
|
2017-04-18 17:40:02 +08:00
|
|
|
|
for (int i = startRange; i <= endRange; i++)
|
2017-07-07 20:05:55 +08:00
|
|
|
|
Values[i]++;
|
2017-03-23 17:37:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-02 19:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|