2023-01-10 04:59:48 +08:00
|
|
|
// 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;
|
2023-01-18 14:31:55 +08:00
|
|
|
using osu.Framework.Bindables;
|
2023-01-10 04:59:48 +08:00
|
|
|
using osu.Framework.Graphics;
|
2023-01-17 21:16:47 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-01-18 14:31:55 +08:00
|
|
|
using osu.Game.Configuration;
|
2023-01-10 04:59:48 +08:00
|
|
|
using osu.Game.Graphics;
|
2023-02-03 14:34:57 +08:00
|
|
|
using osu.Game.Localisation.HUD;
|
2023-01-10 04:59:48 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
|
|
|
public partial class ArgonSongProgress : SongProgress
|
|
|
|
{
|
|
|
|
private readonly SongProgressInfo info;
|
|
|
|
private readonly ArgonSongProgressGraph graph;
|
|
|
|
private readonly ArgonSongProgressBar bar;
|
2023-01-17 21:16:47 +08:00
|
|
|
private readonly Container graphContainer;
|
2023-01-10 04:59:48 +08:00
|
|
|
|
|
|
|
private const float bar_height = 10;
|
|
|
|
|
2023-02-02 07:44:00 +08:00
|
|
|
[SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowGraph), nameof(SongProgressStrings.ShowGraphDescription))]
|
2023-01-18 14:31:55 +08:00
|
|
|
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
|
|
|
|
2023-01-10 04:59:48 +08:00
|
|
|
[Resolved]
|
|
|
|
private Player? player { get; set; }
|
|
|
|
|
|
|
|
public ArgonSongProgress()
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
Origin = Anchor.BottomCentre;
|
2023-01-17 21:16:47 +08:00
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
2023-01-10 04:59:48 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
info = new SongProgressInfo
|
|
|
|
{
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Name = "Info",
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
ShowProgress = false
|
|
|
|
},
|
|
|
|
bar = new ArgonSongProgressBar(bar_height)
|
|
|
|
{
|
|
|
|
Name = "Seek bar",
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
OnSeek = time => player?.Seek(time),
|
2023-01-17 21:16:47 +08:00
|
|
|
},
|
|
|
|
graphContainer = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 5,
|
|
|
|
Child = graph = new ArgonSongProgressGraph
|
|
|
|
{
|
|
|
|
Name = "Difficulty graph",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Blending = BlendingParameters.Additive
|
|
|
|
},
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
},
|
2023-01-10 04:59:48 +08:00
|
|
|
};
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
info.TextColour = Colour4.White;
|
|
|
|
info.Font = OsuFont.Torus.With(size: 18, weight: FontWeight.Bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
2023-01-18 13:55:41 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
Interactive.BindValueChanged(_ => bar.Interactive = Interactive.Value, true);
|
2023-01-10 04:59:48 +08:00
|
|
|
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 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;
|
2023-01-17 21:16:47 +08:00
|
|
|
graphContainer.Height = bar.Height;
|
2023-01-10 04:59:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateProgress(double progress, bool isIntro)
|
|
|
|
{
|
2023-01-18 15:29:42 +08:00
|
|
|
bar.TrackTime = GameplayClock.CurrentTime;
|
2023-01-10 04:59:48 +08:00
|
|
|
|
|
|
|
if (isIntro)
|
|
|
|
bar.CurrentTime = 0;
|
|
|
|
else
|
2023-01-18 15:29:42 +08:00
|
|
|
bar.CurrentTime = FrameStableClock.CurrentTime;
|
2023-01-10 04:59:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|