1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Hook up beatmap object density to progress display.

This commit is contained in:
Dean Herbert 2017-04-14 17:58:30 +09:00
parent 6421f040dd
commit acd7a5b254
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
5 changed files with 40 additions and 15 deletions

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Testing;
using osu.Game.Modes.Objects;
using osu.Game.Screens.Play;
namespace osu.Desktop.VisualTests.Tests
@ -35,13 +36,11 @@ namespace osu.Desktop.VisualTests.Tests
private void displayNewValues()
{
List<int> newValues = new List<int>();
for (int i = 0; i < 1000; i++)
{
newValues.Add(RNG.Next(0, 6));
}
List<HitObject> objects = new List<HitObject>();
for (double i = 0; i < 2000; i += RNG.NextDouble() * 10 + i / 1000)
objects.Add(new HitObject { StartTime = i });
progress.Values = newValues.ToArray();
progress.Objects = objects;
progress.Progress = RNG.NextDouble();
}
}

View File

@ -58,6 +58,8 @@ namespace osu.Game.Modes.UI
/// </summary>
public bool HasReplayLoaded => InputManager.ReplayInputHandler != null;
public abstract IEnumerable<HitObject> Objects { get; }
/// <summary>
/// Whether all the HitObjects have been judged.
/// </summary>
@ -185,6 +187,8 @@ namespace osu.Game.Modes.UI
private readonly Container content;
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
protected HitRenderer(WorkingBeatmap beatmap)
: base(beatmap)
{

View File

@ -57,8 +57,6 @@ namespace osu.Game.Modes.UI
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Depth = -2, //todo: find out why this doesn't put progress on top of PauseOverlay
Values = new[] { 3 }, //todo: removeme
};
}
}

View File

@ -63,9 +63,7 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
{
var beatmap = Beatmap.Beatmap;
if (beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
if (Beatmap.Beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
{
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
Exit();
@ -125,7 +123,8 @@ namespace osu.Game.Screens.Play
hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys());
hudOverlay.BindProcessor(scoreProcessor);
hudOverlay.BindHitRenderer(HitRenderer);
hudOverlay.Progress.Hide();
hudOverlay.Progress.Objects = HitRenderer.Objects;
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
HitRenderer.OnAllJudged += onCompletion;

View File

@ -6,8 +6,12 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using System;
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using System.Linq;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Types;
namespace osu.Game.Screens.Play
{
@ -37,10 +41,31 @@ namespace osu.Game.Screens.Play
}
}
public int[] Values
public IEnumerable<HitObject> Objects
{
get { return graph.Values; }
set { graph.Values = value; }
set
{
var objects = value;
const int granularity = 200;
var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
var interval = lastHit / granularity;
var values = new int[granularity];
foreach (var h in objects)
{
IHasEndTime end = h as IHasEndTime;
int startRange = (int)(h.StartTime / interval);
int endRange = (int)((end?.EndTime ?? h.StartTime) / interval);
for (int i = startRange; i <= endRange; i++)
values[i]++;
}
graph.Values = values;
}
}
[BackgroundDependencyLoader]