1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

Make SongProgress a skinnable component

This commit is contained in:
Dean Herbert 2021-05-17 18:26:15 +09:00
parent 1f3ae901ce
commit da0913ca2d
6 changed files with 36 additions and 21 deletions

View File

@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void seekToBreak(int breakIndex)
{
AddStep($"seek to break {breakIndex}", () => Player.GameplayClockContainer.Seek(destBreak().StartTime));
AddUntilStep("wait for seek to complete", () => Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= destBreak().StartTime);
AddUntilStep("wait for seek to complete", () => Player.DrawableRuleset.FrameStableClock.CurrentTime >= destBreak().StartTime);
BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex);
}

View File

@ -358,11 +358,6 @@ namespace osu.Game.Screens.Play
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
IsCounting = false
},
RequestSeek = time =>
{
GameplayClockContainer.Seek(time);
GameplayClockContainer.Start();
},
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},

View File

@ -14,10 +14,11 @@ using osu.Framework.Timing;
using osu.Game.Configuration;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
namespace osu.Game.Screens.Play
{
public class SongProgress : OverlayContainer
public class SongProgress : OverlayContainer, ISkinnableDrawable
{
private const int info_height = 20;
private const int bottom_bar_height = 5;
@ -39,9 +40,6 @@ namespace osu.Game.Screens.Play
public readonly Bindable<bool> ShowGraph = new Bindable<bool>();
//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;
public override bool HandleNonPositionalInput => AllowSeeking.Value;
public override bool HandlePositionalInput => AllowSeeking.Value;
@ -49,6 +47,9 @@ namespace osu.Game.Screens.Play
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
@ -67,10 +68,12 @@ namespace osu.Game.Screens.Play
public IClock ReferenceClock;
private IClock gameplayClock;
public SongProgress()
{
RelativeSizeAxes = Axes.X;
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
Children = new Drawable[]
{
new SongProgressDisplay
@ -96,20 +99,34 @@ namespace osu.Game.Screens.Play
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
OnSeek = time => RequestSeek?.Invoke(time),
OnSeek = seek,
},
}
},
};
}
private void seek(double time)
{
if (gameplayClock == null)
return;
// TODO: implement
}
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, GameplayClock clock, OsuConfigManager config)
private void load(OsuColour colours, OsuConfigManager config, DrawableRuleset drawableRuleset)
{
base.LoadComplete();
if (clock != null)
gameplayClock = clock;
if (drawableRuleset != null)
{
AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded);
Objects = drawableRuleset.Objects;
}
config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph);
@ -124,11 +141,6 @@ namespace osu.Game.Screens.Play
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
}
public void BindDrawableRuleset(DrawableRuleset drawableRuleset)
{
AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded);
}
protected override void PopIn()
{
this.FadeIn(500, Easing.OutQuint);

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Graphics;
@ -86,6 +87,7 @@ namespace osu.Game.Skinning
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)),
}
};
@ -109,6 +111,9 @@ namespace osu.Game.Skinning
case HUDSkinComponents.HealthDisplay:
return new DefaultHealthDisplay();
case HUDSkinComponents.SongProgress:
return new SongProgress();
}
break;

View File

@ -9,5 +9,6 @@ namespace osu.Game.Skinning
ScoreCounter,
AccuracyCounter,
HealthDisplay,
SongProgress,
}
}

View File

@ -17,6 +17,7 @@ using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osuTK.Graphics;
@ -350,6 +351,7 @@ namespace osu.Game.Skinning
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)) ?? new DefaultScoreCounter(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)) ?? new DefaultAccuracyCounter(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)) ?? new DefaultHealthDisplay(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)) ?? new SongProgress(),
}
};