mirror of
https://github.com/ppy/osu
synced 2025-02-24 06:37:03 +00:00
Merge branch 'master' into fix-summary-kiai-ranges
This commit is contained in:
commit
2500e5c533
@ -1,161 +1,76 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSongProgress : OsuTestScene
|
||||
public class TestSceneSongProgress : SkinnableHUDComponentTestScene
|
||||
{
|
||||
private SongProgress progress;
|
||||
private TestSongProgressGraph graph;
|
||||
private readonly Container progressContainer;
|
||||
private GameplayClockContainer gameplayClockContainer = null!;
|
||||
|
||||
private readonly StopwatchClock clock;
|
||||
private readonly FramedClock framedClock;
|
||||
private const double skip_target_time = -2000;
|
||||
|
||||
[Cached]
|
||||
private readonly GameplayClock gameplayClock;
|
||||
|
||||
public TestSceneSongProgress()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
clock = new StopwatchClock();
|
||||
gameplayClock = new GameplayClock(framedClock = new FramedClock(clock));
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
Add(progressContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Height = 100,
|
||||
Y = -100,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(1),
|
||||
}
|
||||
});
|
||||
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
||||
|
||||
Dependencies.CacheAs(gameplayClockContainer.GameplayClock);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetupSteps()
|
||||
{
|
||||
AddStep("add new song progress", () =>
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Expire();
|
||||
progress = null;
|
||||
}
|
||||
|
||||
progressContainer.Add(progress = new SongProgress
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("add new big graph", () =>
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
graph.Expire();
|
||||
graph = null;
|
||||
}
|
||||
|
||||
Add(graph = new TestSongProgressGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 200,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("reset clock", clock.Reset);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGraphRecreation()
|
||||
{
|
||||
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
||||
AddStep("display values", displayRandomValues);
|
||||
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||
AddRepeatStep("new values", displayRandomValues, 5);
|
||||
AddWaitStep("wait some", 5);
|
||||
AddAssert("ensure recreation debounced", () => graph.CreationCount == 2);
|
||||
AddStep("reset clock", () => gameplayClockContainer.Reset());
|
||||
AddStep("set hit objects", setHitObjects);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDisplay()
|
||||
{
|
||||
AddStep("display max values", displayMaxValues);
|
||||
AddUntilStep("wait for graph", () => graph.CreationCount == 1);
|
||||
AddStep("start", clock.Start);
|
||||
AddStep("allow seeking", () => progress.AllowSeeking.Value = true);
|
||||
AddStep("hide graph", () => progress.ShowGraph.Value = false);
|
||||
AddStep("disallow seeking", () => progress.AllowSeeking.Value = false);
|
||||
AddStep("allow seeking", () => progress.AllowSeeking.Value = true);
|
||||
AddStep("show graph", () => progress.ShowGraph.Value = true);
|
||||
AddStep("stop", clock.Stop);
|
||||
AddStep("seek to intro", () => gameplayClockContainer.Seek(skip_target_time));
|
||||
AddStep("start", gameplayClockContainer.Start);
|
||||
AddStep("stop", gameplayClockContainer.Stop);
|
||||
}
|
||||
|
||||
private void displayRandomValues()
|
||||
[Test]
|
||||
public void TestToggleSeeking()
|
||||
{
|
||||
var objects = new List<HitObject>();
|
||||
for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000)
|
||||
objects.Add(new HitObject { StartTime = i });
|
||||
DefaultSongProgress getDefaultProgress() => this.ChildrenOfType<DefaultSongProgress>().Single();
|
||||
|
||||
replaceObjects(objects);
|
||||
AddStep("allow seeking", () => getDefaultProgress().AllowSeeking.Value = true);
|
||||
AddStep("hide graph", () => getDefaultProgress().ShowGraph.Value = false);
|
||||
AddStep("disallow seeking", () => getDefaultProgress().AllowSeeking.Value = false);
|
||||
AddStep("allow seeking", () => getDefaultProgress().AllowSeeking.Value = true);
|
||||
AddStep("show graph", () => getDefaultProgress().ShowGraph.Value = true);
|
||||
}
|
||||
|
||||
private void displayMaxValues()
|
||||
private void setHitObjects()
|
||||
{
|
||||
var objects = new List<HitObject>();
|
||||
for (double i = 0; i < 5000; i++)
|
||||
objects.Add(new HitObject { StartTime = i });
|
||||
|
||||
replaceObjects(objects);
|
||||
this.ChildrenOfType<SongProgress>().ForEach(progress => progress.Objects = objects);
|
||||
}
|
||||
|
||||
private void replaceObjects(List<HitObject> objects)
|
||||
{
|
||||
progress.Objects = objects;
|
||||
graph.Objects = objects;
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();
|
||||
|
||||
progress.RequestSeek = pos => clock.Seek(pos);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
framedClock.ProcessFrame();
|
||||
}
|
||||
|
||||
private class TestSongProgressGraph : SongProgressGraph
|
||||
{
|
||||
public int CreationCount { get; private set; }
|
||||
|
||||
protected override void RecreateGraph()
|
||||
{
|
||||
base.RecreateGraph();
|
||||
CreationCount++;
|
||||
}
|
||||
}
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
|
||||
}
|
||||
}
|
||||
|
73
osu.Game.Tests/Visual/Gameplay/TestSceneSongProgressGraph.cs
Normal file
73
osu.Game.Tests/Visual/Gameplay/TestSceneSongProgressGraph.cs
Normal file
@ -0,0 +1,73 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSongProgressGraph : OsuTestScene
|
||||
{
|
||||
private TestSongProgressGraph graph;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetupSteps()
|
||||
{
|
||||
AddStep("add new big graph", () =>
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
graph.Expire();
|
||||
graph = null;
|
||||
}
|
||||
|
||||
Add(graph = new TestSongProgressGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 200,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGraphRecreation()
|
||||
{
|
||||
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
||||
AddStep("display values", displayRandomValues);
|
||||
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||
AddRepeatStep("new values", displayRandomValues, 5);
|
||||
AddWaitStep("wait some", 5);
|
||||
AddAssert("ensure recreation debounced", () => graph.CreationCount == 2);
|
||||
}
|
||||
|
||||
private void displayRandomValues()
|
||||
{
|
||||
var objects = new List<HitObject>();
|
||||
for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000)
|
||||
objects.Add(new HitObject { StartTime = i });
|
||||
|
||||
graph.Objects = objects;
|
||||
}
|
||||
|
||||
private class TestSongProgressGraph : SongProgressGraph
|
||||
{
|
||||
public int CreationCount { get; private set; }
|
||||
|
||||
protected override void RecreateGraph()
|
||||
{
|
||||
base.RecreateGraph();
|
||||
CreationCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -35,6 +35,15 @@ namespace osu.Game.Screens.Play
|
||||
UnderlyingClock = underlyingClock;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If not set, a value of zero will be used.
|
||||
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
||||
/// </remarks>
|
||||
public double? StartTime { get; internal set; }
|
||||
|
||||
public double CurrentTime => UnderlyingClock.CurrentTime;
|
||||
|
||||
public double Rate => UnderlyingClock.Rate;
|
||||
|
@ -16,7 +16,6 @@ namespace osu.Game.Screens.Play
|
||||
/// <summary>
|
||||
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
||||
/// </summary>
|
||||
[Cached]
|
||||
public abstract class GameplayClockContainer : Container, IAdjustableClock
|
||||
{
|
||||
/// <summary>
|
||||
@ -44,6 +43,8 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public event Action OnSeek;
|
||||
|
||||
private double? startTime;
|
||||
|
||||
/// <summary>
|
||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="Reset"/>.
|
||||
/// </summary>
|
||||
@ -51,7 +52,17 @@ namespace osu.Game.Screens.Play
|
||||
/// If not set, a value of zero will be used.
|
||||
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
||||
/// </remarks>
|
||||
public double? StartTime { get; set; }
|
||||
public double? StartTime
|
||||
{
|
||||
get => startTime;
|
||||
set
|
||||
{
|
||||
startTime = value;
|
||||
|
||||
if (GameplayClock != null)
|
||||
GameplayClock.StartTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GameplayClockContainer"/>.
|
||||
@ -72,6 +83,8 @@ namespace osu.Game.Screens.Play
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
dependencies.CacheAs(GameplayClock = CreateGameplayClock(AdjustableSource));
|
||||
|
||||
GameplayClock.StartTime = StartTime;
|
||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
||||
|
||||
return dependencies;
|
||||
|
@ -1,16 +1,10 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -18,12 +12,10 @@ using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SongProgress : OverlayContainer, ISkinnableDrawable
|
||||
public class DefaultSongProgress : SongProgress
|
||||
{
|
||||
public const float MAX_HEIGHT = info_height + bottom_bar_height + graph_height + handle_height;
|
||||
|
||||
private const float info_height = 20;
|
||||
private const float bottom_bar_height = 5;
|
||||
private const float graph_height = SquareGraph.Column.WIDTH * 6;
|
||||
@ -37,8 +29,6 @@ namespace osu.Game.Screens.Play
|
||||
private readonly SongProgressGraph graph;
|
||||
private readonly SongProgressInfo info;
|
||||
|
||||
public Action<double> RequestSeek;
|
||||
|
||||
/// <summary>
|
||||
/// Whether seeking is allowed and the progress bar should be shown.
|
||||
/// </summary>
|
||||
@ -52,41 +42,19 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override bool BlockScrollInput => false;
|
||||
|
||||
private double firstHitTime => objects.First().StartTime;
|
||||
|
||||
//TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list).
|
||||
private double lastHitTime => objects.Last().GetEndTime() + 1;
|
||||
|
||||
private IEnumerable<HitObject> objects;
|
||||
|
||||
public IEnumerable<HitObject> Objects
|
||||
{
|
||||
set
|
||||
{
|
||||
graph.Objects = objects = value;
|
||||
|
||||
info.StartTime = firstHitTime;
|
||||
info.EndTime = lastHitTime;
|
||||
|
||||
bar.StartTime = firstHitTime;
|
||||
bar.EndTime = lastHitTime;
|
||||
}
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private Player player { get; set; }
|
||||
[Resolved]
|
||||
private Player? player { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private GameplayClock gameplayClock { get; set; }
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DrawableRuleset drawableRuleset { get; set; }
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; } = null!;
|
||||
|
||||
private IClock referenceClock;
|
||||
[Resolved]
|
||||
private SkinManager skinManager { get; set; } = null!;
|
||||
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
public SongProgress()
|
||||
public DefaultSongProgress()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Anchor = Anchor.BottomRight;
|
||||
@ -127,9 +95,6 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (player?.Configuration.AllowUserInteraction == true)
|
||||
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
|
||||
|
||||
referenceClock = drawableRuleset.FrameStableClock;
|
||||
Objects = drawableRuleset.Objects;
|
||||
}
|
||||
|
||||
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
||||
@ -137,20 +102,12 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Show();
|
||||
|
||||
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
|
||||
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||
|
||||
migrateSettingFromConfig();
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private SkinManager skinManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This setting has been migrated to a per-component level.
|
||||
/// Only take the value from the config if it is in a non-default state (then reset it to default so it only applies once).
|
||||
@ -166,29 +123,26 @@ namespace osu.Game.Screens.Play
|
||||
ShowGraph.Value = configShowGraph.Value;
|
||||
|
||||
// This is pretty ugly, but the only way to make this stick...
|
||||
if (skinManager != null)
|
||||
var skinnableTarget = this.FindClosestParent<ISkinnableTarget>();
|
||||
|
||||
if (skinnableTarget != null)
|
||||
{
|
||||
var skinnableTarget = this.FindClosestParent<ISkinnableTarget>();
|
||||
// If the skin is not mutable, a mutable instance will be created, causing this migration logic to run again on the correct skin.
|
||||
// Therefore we want to avoid resetting the config value on this invocation.
|
||||
if (skinManager.EnsureMutableSkin())
|
||||
return;
|
||||
|
||||
if (skinnableTarget != null)
|
||||
// If `EnsureMutableSkin` actually changed the skin, default layout may take a frame to apply.
|
||||
// See `SkinnableTargetComponentsContainer`'s use of ScheduleAfterChildren.
|
||||
ScheduleAfterChildren(() =>
|
||||
{
|
||||
// If the skin is not mutable, a mutable instance will be created, causing this migration logic to run again on the correct skin.
|
||||
// Therefore we want to avoid resetting the config value on this invocation.
|
||||
if (skinManager.EnsureMutableSkin())
|
||||
return;
|
||||
var skin = skinManager.CurrentSkin.Value;
|
||||
skin.UpdateDrawableTarget(skinnableTarget);
|
||||
|
||||
// If `EnsureMutableSkin` actually changed the skin, default layout may take a frame to apply.
|
||||
// See `SkinnableTargetComponentsContainer`'s use of ScheduleAfterChildren.
|
||||
ScheduleAfterChildren(() =>
|
||||
{
|
||||
var skin = skinManager.CurrentSkin.Value;
|
||||
skin.UpdateDrawableTarget(skinnableTarget);
|
||||
skinManager.Save(skin);
|
||||
});
|
||||
|
||||
skinManager.Save(skin);
|
||||
});
|
||||
|
||||
configShowGraph.SetDefault();
|
||||
}
|
||||
configShowGraph.SetDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,21 +157,29 @@ namespace osu.Game.Screens.Play
|
||||
this.FadeOut(100);
|
||||
}
|
||||
|
||||
protected override void UpdateObjects(IEnumerable<HitObject> objects)
|
||||
{
|
||||
graph.Objects = objects;
|
||||
|
||||
info.StartTime = FirstHitTime;
|
||||
info.EndTime = LastHitTime;
|
||||
bar.StartTime = FirstHitTime;
|
||||
bar.EndTime = LastHitTime;
|
||||
}
|
||||
|
||||
protected override void UpdateProgress(double progress, bool isIntro)
|
||||
{
|
||||
bar.CurrentTime = GameplayClock.CurrentTime;
|
||||
|
||||
if (isIntro)
|
||||
graph.Progress = 0;
|
||||
else
|
||||
graph.Progress = (int)(graph.ColumnCount * progress);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (objects == null)
|
||||
return;
|
||||
|
||||
double gameplayTime = gameplayClock?.CurrentTime ?? Time.Current;
|
||||
double frameStableTime = referenceClock?.CurrentTime ?? gameplayTime;
|
||||
|
||||
double progress = Math.Min(1, (frameStableTime - firstHitTime) / (lastHitTime - firstHitTime));
|
||||
|
||||
bar.CurrentTime = gameplayTime;
|
||||
graph.Progress = (int)(graph.ColumnCount * progress);
|
||||
|
||||
Height = bottom_bar_height + graph_height + handle_size.Y + info_height - graph.Y;
|
||||
}
|
||||
|
95
osu.Game/Screens/Play/HUD/SongProgress.cs
Normal file
95
osu.Game/Screens/Play/HUD/SongProgress.cs
Normal file
@ -0,0 +1,95 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public abstract class SongProgress : OverlayContainer, ISkinnableDrawable
|
||||
{
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected GameplayClock GameplayClock { get; private set; } = null!;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
private IClock? referenceClock;
|
||||
private IEnumerable<HitObject>? objects;
|
||||
|
||||
public IEnumerable<HitObject> Objects
|
||||
{
|
||||
set
|
||||
{
|
||||
objects = value;
|
||||
FirstHitTime = objects.FirstOrDefault()?.StartTime ?? 0;
|
||||
//TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list).
|
||||
LastHitTime = objects.LastOrDefault()?.GetEndTime() ?? 0;
|
||||
UpdateObjects(objects);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
protected double FirstHitTime { get; private set; }
|
||||
|
||||
protected double LastHitTime { get; private set; }
|
||||
|
||||
protected abstract void UpdateProgress(double progress, bool isIntro);
|
||||
protected virtual void UpdateObjects(IEnumerable<HitObject> objects) { }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
Objects = drawableRuleset.Objects;
|
||||
referenceClock = drawableRuleset.FrameStableClock;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (objects == null)
|
||||
return;
|
||||
|
||||
// The reference clock is used to accurately tell the playfield's time. This is obtained from the drawable ruleset.
|
||||
// However, if no drawable ruleset is available (i.e. used in tests), we fall back to the gameplay clock.
|
||||
double currentTime = referenceClock?.CurrentTime ?? GameplayClock.CurrentTime;
|
||||
|
||||
bool isInIntro = currentTime < FirstHitTime;
|
||||
|
||||
if (isInIntro)
|
||||
{
|
||||
double introStartTime = GameplayClock.StartTime ?? 0;
|
||||
|
||||
double introOffsetCurrent = currentTime - introStartTime;
|
||||
double introDuration = FirstHitTime - introStartTime;
|
||||
|
||||
UpdateProgress(introOffsetCurrent / introDuration, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
double objectOffsetCurrent = currentTime - FirstHitTime;
|
||||
|
||||
double objectDuration = LastHitTime - FirstHitTime;
|
||||
UpdateProgress(objectOffsetCurrent / objectDuration, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Threading;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SongProgressBar : SliderBar<double>
|
||||
{
|
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SongProgressGraph : SquareGraph
|
||||
{
|
@ -10,7 +10,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SongProgressInfo : Container
|
||||
{
|
@ -16,7 +16,6 @@ using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
using osuTK;
|
||||
@ -147,7 +146,7 @@ namespace osu.Game.Skinning
|
||||
new DefaultScoreCounter(),
|
||||
new DefaultAccuracyCounter(),
|
||||
new DefaultHealthDisplay(),
|
||||
new SongProgress(),
|
||||
new DefaultSongProgress(),
|
||||
new BarHitErrorMeter(),
|
||||
new BarHitErrorMeter(),
|
||||
new PerformancePointsCounter()
|
||||
|
@ -16,10 +16,10 @@ using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
using osuTK.Graphics;
|
||||
@ -337,14 +337,21 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
var score = container.OfType<LegacyScoreCounter>().FirstOrDefault();
|
||||
var accuracy = container.OfType<GameplayAccuracyCounter>().FirstOrDefault();
|
||||
var combo = container.OfType<LegacyComboCounter>().FirstOrDefault();
|
||||
|
||||
if (score != null && accuracy != null)
|
||||
{
|
||||
accuracy.Y = container.ToLocalSpace(score.ScreenSpaceDrawQuad.BottomRight).Y;
|
||||
}
|
||||
|
||||
var songProgress = container.OfType<SongProgress>().FirstOrDefault();
|
||||
var songProgress = container.OfType<LegacySongProgress>().FirstOrDefault();
|
||||
|
||||
if (songProgress != null && accuracy != null)
|
||||
{
|
||||
songProgress.Anchor = Anchor.TopRight;
|
||||
songProgress.Origin = Anchor.CentreRight;
|
||||
songProgress.X = -accuracy.ScreenSpaceDeltaToParentSpace(accuracy.ScreenSpaceDrawQuad.Size).X - 10;
|
||||
songProgress.Y = container.ToLocalSpace(accuracy.ScreenSpaceDrawQuad.TopLeft).Y + (accuracy.ScreenSpaceDeltaToParentSpace(accuracy.ScreenSpaceDrawQuad.Size).Y / 2);
|
||||
}
|
||||
|
||||
var hitError = container.OfType<HitErrorMeter>().FirstOrDefault();
|
||||
|
||||
@ -354,12 +361,6 @@ namespace osu.Game.Skinning
|
||||
hitError.Origin = Anchor.CentreLeft;
|
||||
hitError.Rotation = -90;
|
||||
}
|
||||
|
||||
if (songProgress != null)
|
||||
{
|
||||
if (hitError != null) hitError.Y -= SongProgress.MAX_HEIGHT;
|
||||
if (combo != null) combo.Y -= SongProgress.MAX_HEIGHT;
|
||||
}
|
||||
})
|
||||
{
|
||||
Children = new Drawable[]
|
||||
@ -368,7 +369,7 @@ namespace osu.Game.Skinning
|
||||
new LegacyScoreCounter(),
|
||||
new LegacyAccuracyCounter(),
|
||||
new LegacyHealthDisplay(),
|
||||
new SongProgress(),
|
||||
new LegacySongProgress(),
|
||||
new BarHitErrorMeter(),
|
||||
}
|
||||
};
|
||||
|
87
osu.Game/Skinning/LegacySongProgress.cs
Normal file
87
osu.Game/Skinning/LegacySongProgress.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class LegacySongProgress : SongProgress
|
||||
{
|
||||
private CircularProgress circularProgress = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Size = new Vector2(33);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.92f),
|
||||
Child = circularProgress = new CircularProgress
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderColour = Colour4.White,
|
||||
BorderThickness = 2,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0,
|
||||
}
|
||||
},
|
||||
new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = Colour4.White,
|
||||
Size = new Vector2(4),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.FadeOut(100);
|
||||
}
|
||||
|
||||
protected override void UpdateProgress(double progress, bool isIntro)
|
||||
{
|
||||
if (isIntro)
|
||||
{
|
||||
circularProgress.Scale = new Vector2(-1, 1);
|
||||
circularProgress.Anchor = Anchor.TopRight;
|
||||
circularProgress.Colour = new Colour4(199, 255, 47, 153);
|
||||
circularProgress.Current.Value = 1 - progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
circularProgress.Scale = new Vector2(1);
|
||||
circularProgress.Anchor = Anchor.TopLeft;
|
||||
circularProgress.Colour = new Colour4(255, 255, 255, 153);
|
||||
circularProgress.Current.Value = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user