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