mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
feat(hud/gameplay): implement Argon variant of SongProgress
This commit is contained in:
parent
5952cd08a2
commit
91cde5ffbf
139
osu.Game/Screens/Play/HUD/ArgonSongProgress.cs
Normal file
139
osu.Game/Screens/Play/HUD/ArgonSongProgress.cs
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
// 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 osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public partial class ArgonSongProgress : SongProgress
|
||||||
|
{
|
||||||
|
private readonly SongProgressInfo info;
|
||||||
|
private readonly ArgonSongProgressGraph graph;
|
||||||
|
private readonly ArgonSongProgressBar bar;
|
||||||
|
|
||||||
|
private const float bar_height = 10;
|
||||||
|
|
||||||
|
public readonly Bindable<bool> AllowSeeking = new BindableBool();
|
||||||
|
|
||||||
|
[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
|
||||||
|
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private DrawableRuleset? drawableRuleset { get; set; }
|
||||||
|
|
||||||
|
private IClock referenceClock => drawableRuleset?.FrameStableClock ?? GameplayClock;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Player? player { get; set; }
|
||||||
|
|
||||||
|
public ArgonSongProgress()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre;
|
||||||
|
Origin = Anchor.BottomCentre;
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
info = new SongProgressInfo
|
||||||
|
{
|
||||||
|
Origin = Anchor.TopLeft,
|
||||||
|
Name = "Info",
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
ShowProgress = false
|
||||||
|
},
|
||||||
|
graph = new ArgonSongProgressGraph
|
||||||
|
{
|
||||||
|
Name = "Difficulty graph",
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 5,
|
||||||
|
},
|
||||||
|
bar = new ArgonSongProgressBar(bar_height)
|
||||||
|
{
|
||||||
|
Name = "Seek bar",
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
OnSeek = time => player?.Seek(time),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (drawableRuleset != null)
|
||||||
|
{
|
||||||
|
if (player?.Configuration.AllowUserInteraction == true)
|
||||||
|
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
info.ShowProgress = false;
|
||||||
|
info.TextColour = Colour4.White;
|
||||||
|
info.Font = OsuFont.Torus.With(size: 18, weight: FontWeight.Bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
|
||||||
|
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateObjects(IEnumerable<HitObject> objects)
|
||||||
|
{
|
||||||
|
graph.Objects = objects;
|
||||||
|
|
||||||
|
info.StartTime = bar.StartTime = FirstHitTime;
|
||||||
|
info.EndTime = bar.EndTime = LastHitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBarVisibility()
|
||||||
|
{
|
||||||
|
bar.Interactive = AllowSeeking.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGraphVisibility()
|
||||||
|
{
|
||||||
|
graph.FadeTo(ShowGraph.Value ? 1 : 0, 200, Easing.In);
|
||||||
|
bar.ShowBackground = !ShowGraph.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
Height = bar.Height + bar_height + info.Height;
|
||||||
|
graph.Height = bar.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
this.FadeIn(500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
this.FadeOut(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateProgress(double progress, bool isIntro)
|
||||||
|
{
|
||||||
|
bar.ReferenceTime = GameplayClock.CurrentTime;
|
||||||
|
|
||||||
|
if (isIntro)
|
||||||
|
bar.CurrentTime = 0;
|
||||||
|
else
|
||||||
|
bar.CurrentTime = referenceClock.CurrentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -108,6 +108,7 @@ namespace osu.Game.Skinning
|
|||||||
var accuracy = container.OfType<DefaultAccuracyCounter>().FirstOrDefault();
|
var accuracy = container.OfType<DefaultAccuracyCounter>().FirstOrDefault();
|
||||||
var combo = container.OfType<DefaultComboCounter>().FirstOrDefault();
|
var combo = container.OfType<DefaultComboCounter>().FirstOrDefault();
|
||||||
var ppCounter = container.OfType<PerformancePointsCounter>().FirstOrDefault();
|
var ppCounter = container.OfType<PerformancePointsCounter>().FirstOrDefault();
|
||||||
|
var songProgress = container.OfType<ArgonSongProgress>().FirstOrDefault();
|
||||||
|
|
||||||
if (score != null)
|
if (score != null)
|
||||||
{
|
{
|
||||||
@ -158,6 +159,12 @@ namespace osu.Game.Skinning
|
|||||||
// origin flipped to match scale above.
|
// origin flipped to match scale above.
|
||||||
hitError2.Origin = Anchor.CentreLeft;
|
hitError2.Origin = Anchor.CentreLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (songProgress != null)
|
||||||
|
{
|
||||||
|
songProgress.Position = new Vector2(0, -10);
|
||||||
|
songProgress.Scale = new Vector2(0.9f, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
@ -167,7 +174,7 @@ namespace osu.Game.Skinning
|
|||||||
new DefaultScoreCounter(),
|
new DefaultScoreCounter(),
|
||||||
new DefaultAccuracyCounter(),
|
new DefaultAccuracyCounter(),
|
||||||
new DefaultHealthDisplay(),
|
new DefaultHealthDisplay(),
|
||||||
new DefaultSongProgress(),
|
new ArgonSongProgress(),
|
||||||
new BarHitErrorMeter(),
|
new BarHitErrorMeter(),
|
||||||
new BarHitErrorMeter(),
|
new BarHitErrorMeter(),
|
||||||
new PerformancePointsCounter()
|
new PerformancePointsCounter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user