Merge branch 'master' into multiple-chat-channels

This commit is contained in:
Dan Balasescu 2017-05-12 19:35:12 +09:00 committed by GitHub
commit 8ec79f788a
5 changed files with 128 additions and 7 deletions

View File

@ -18,10 +18,14 @@ namespace osu.Desktop.VisualTests.Tests
private SongProgress progress; private SongProgress progress;
private SongProgressGraph graph; private SongProgressGraph graph;
private StopwatchClock clock;
public override void Reset() public override void Reset()
{ {
base.Reset(); base.Reset();
clock = new StopwatchClock(true);
Add(progress = new SongProgress Add(progress = new SongProgress
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -55,6 +59,9 @@ namespace osu.Desktop.VisualTests.Tests
progress.Objects = objects; progress.Objects = objects;
graph.Objects = objects; graph.Objects = objects;
progress.AudioClock = clock;
progress.OnSeek = pos => clock.Seek(pos);
} }
} }
} }

View File

@ -28,10 +28,12 @@ namespace osu.Game.Screens.Play
private readonly SongProgressBar bar; private readonly SongProgressBar bar;
private readonly SongProgressGraph graph; private readonly SongProgressGraph graph;
private readonly SongProgressInfo info;
public Action<double> OnSeek; public Action<double> OnSeek;
public IClock AudioClock; private IClock audioClock;
public IClock AudioClock { set { audioClock = info.AudioClock = value; } }
private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
@ -44,6 +46,9 @@ namespace osu.Game.Screens.Play
set set
{ {
graph.Objects = objects = value; graph.Objects = objects = value;
info.StartTime = firstHitTime;
info.EndTime = lastHitTime;
} }
} }
@ -62,6 +67,14 @@ namespace osu.Game.Screens.Play
Children = new Drawable[] Children = new Drawable[]
{ {
info = new SongProgressInfo
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = bottom_bar_height + graph_height },
},
graph = new SongProgressGraph graph = new SongProgressGraph
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -130,10 +143,13 @@ namespace osu.Game.Screens.Play
if (objects == null) if (objects == null)
return; return;
double progress = ((AudioClock?.CurrentTime ?? Time.Current) - firstHitTime) / lastHitTime; double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime);
bar.UpdatePosition((float)progress); if(progress < 1)
graph.Progress = (int)(graph.ColumnCount * progress); {
bar.UpdatePosition((float)progress);
graph.Progress = (int)(graph.ColumnCount * progress);
}
} }
} }
} }

View File

@ -20,12 +20,13 @@ namespace osu.Game.Screens.Play
const int granularity = 200; const int granularity = 200;
var firstHit = objects.First().StartTime;
var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0; var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0;
if (lastHit == 0) if (lastHit == 0)
lastHit = objects.Last().StartTime; lastHit = objects.Last().StartTime;
var interval = (lastHit + 1) / granularity; var interval = (lastHit - firstHit + 1) / granularity;
var values = new int[granularity]; var values = new int[granularity];
@ -33,8 +34,8 @@ namespace osu.Game.Screens.Play
{ {
IHasEndTime end = h as IHasEndTime; IHasEndTime end = h as IHasEndTime;
int startRange = (int)(h.StartTime / interval); int startRange = (int)((h.StartTime - firstHit)/ interval);
int endRange = (int)((end?.EndTime > 0 ? end.EndTime : h.StartTime) / interval); int endRange = (int)(((end?.EndTime > 0 ? end.EndTime : h.StartTime) - firstHit) / interval);
for (int i = startRange; i <= endRange; i++) for (int i = startRange; i <= endRange; i++)
values[i]++; values[i]++;
} }

View File

@ -0,0 +1,96 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using System;
namespace osu.Game.Screens.Play
{
public class SongProgressInfo : Container
{
private OsuSpriteText timeCurrent;
private OsuSpriteText timeLeft;
private OsuSpriteText progress;
private double startTime;
private double endTime;
private int? previousPercent;
private int? previousSecond;
private double songLength => endTime - startTime;
private const int margin = 10;
public IClock AudioClock;
public double StartTime { set { startTime = value; } }
public double EndTime { set { endTime = value; } }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Children = new Drawable[]
{
timeCurrent = new OsuSpriteText
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Colour = colours.BlueLighter,
Font = @"Venera",
Margin = new MarginPadding
{
Left = margin,
},
},
progress = new OsuSpriteText
{
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Colour = colours.BlueLighter,
Font = @"Venera",
},
timeLeft = new OsuSpriteText
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
Colour = colours.BlueLighter,
Font = @"Venera",
Margin = new MarginPadding
{
Right = margin,
},
}
};
}
protected override void Update()
{
base.Update();
double songCurrentTime = AudioClock.CurrentTime - startTime;
int currentPercent = Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100)));
int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0);
if (currentPercent != previousPercent)
{
progress.Text = currentPercent.ToString() + @"%";
previousPercent = currentPercent;
}
if (currentSecond != previousSecond && songCurrentTime < songLength)
{
timeCurrent.Text = TimeSpan.FromSeconds(currentSecond).ToString(songCurrentTime < 0 ? @"\-m\:ss" : @"m\:ss");
timeLeft.Text = TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"\-m\:ss");
previousSecond = currentSecond;
}
}
}
}

View File

@ -227,6 +227,7 @@
<Compile Include="Screens\Charts\ChartInfo.cs" /> <Compile Include="Screens\Charts\ChartInfo.cs" />
<Compile Include="Screens\Edit\Editor.cs" /> <Compile Include="Screens\Edit\Editor.cs" />
<Compile Include="Screens\Play\HotkeyRetryOverlay.cs" /> <Compile Include="Screens\Play\HotkeyRetryOverlay.cs" />
<Compile Include="Screens\Play\SongProgressInfo.cs" />
<Compile Include="Screens\Play\HUD\ModDisplay.cs" /> <Compile Include="Screens\Play\HUD\ModDisplay.cs" />
<Compile Include="Screens\Play\SquareGraph.cs" /> <Compile Include="Screens\Play\SquareGraph.cs" />
<Compile Include="Screens\Play\StandardHUDOverlay.cs" /> <Compile Include="Screens\Play\StandardHUDOverlay.cs" />