2019-01-24 17:43:03 +09: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.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-04-14 17:58:30 +09:00
|
|
|
|
using System.Collections.Generic;
|
2022-04-27 18:10:58 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-04-27 18:10:58 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-07-04 11:59:38 +02:00
|
|
|
|
using osu.Game.Configuration;
|
2022-04-27 18:10:58 +09:00
|
|
|
|
using osu.Game.Graphics;
|
2017-04-18 16:05:58 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-01-17 17:37:14 +09:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2022-04-27 18:10:58 +09:00
|
|
|
|
using osuTK;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2017-03-02 20:20:27 +09:00
|
|
|
|
{
|
2022-07-27 15:19:21 +08:00
|
|
|
|
public partial class DefaultSongProgress : SongProgress
|
2017-03-02 20:20:27 +09:00
|
|
|
|
{
|
2021-05-18 15:50:40 +09:00
|
|
|
|
private const float bottom_bar_height = 5;
|
2019-07-04 11:59:38 +02:00
|
|
|
|
private const float graph_height = SquareGraph.Column.WIDTH * 6;
|
2021-05-18 15:50:40 +09:00
|
|
|
|
private const float handle_height = 18;
|
|
|
|
|
|
|
|
|
|
private static readonly Vector2 handle_size = new Vector2(10, handle_height);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-03-23 07:15:53 -03:00
|
|
|
|
private const float transition_duration = 200;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-03-24 00:41:56 -03:00
|
|
|
|
private readonly SongProgressBar bar;
|
|
|
|
|
private readonly SongProgressGraph graph;
|
2017-04-28 04:56:34 +03:00
|
|
|
|
private readonly SongProgressInfo info;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-07-05 08:48:40 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether seeking is allowed and the progress bar should be shown.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly Bindable<bool> AllowSeeking = new Bindable<bool>();
|
|
|
|
|
|
2022-04-29 11:56:46 +09:00
|
|
|
|
[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
|
2022-03-20 13:36:18 -07:00
|
|
|
|
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-07-05 08:48:40 +02:00
|
|
|
|
public override bool HandleNonPositionalInput => AllowSeeking.Value;
|
|
|
|
|
public override bool HandlePositionalInput => AllowSeeking.Value;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-07-28 18:37:17 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private Player? player { get; set; }
|
2021-05-17 18:41:56 +09:00
|
|
|
|
|
2022-07-28 18:37:17 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private DrawableRuleset? drawableRuleset { get; set; }
|
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
public DefaultSongProgress()
|
2017-03-02 20:20:27 +09:00
|
|
|
|
{
|
2021-05-17 18:26:15 +09:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
|
|
|
|
|
2017-03-02 20:20:27 +09:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-05-17 18:55:18 +09:00
|
|
|
|
info = new SongProgressInfo
|
2017-03-02 20:20:27 +09:00
|
|
|
|
{
|
2021-05-17 18:55:18 +09:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
graph = new SongProgressGraph
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Height = graph_height,
|
|
|
|
|
Margin = new MarginPadding { Bottom = bottom_bar_height },
|
|
|
|
|
},
|
|
|
|
|
bar = new SongProgressBar(bottom_bar_height, graph_height, handle_size)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
OnSeek = time => player?.Seek(time),
|
2017-03-23 08:13:03 -03:00
|
|
|
|
},
|
2017-02-09 19:08:23 -04:00
|
|
|
|
};
|
2017-03-02 20:20:27 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-07-04 11:59:38 +02:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-03-20 13:36:18 -07:00
|
|
|
|
private void load(OsuColour colours)
|
2017-04-14 14:40:52 +09:00
|
|
|
|
{
|
2019-10-28 18:34:58 +09:00
|
|
|
|
base.LoadComplete();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-05-17 18:26:15 +09:00
|
|
|
|
if (drawableRuleset != null)
|
|
|
|
|
{
|
2021-08-16 16:48:40 +09:00
|
|
|
|
if (player?.Configuration.AllowUserInteraction == true)
|
2021-08-16 16:27:19 +09:00
|
|
|
|
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
|
2021-05-17 18:26:15 +09:00
|
|
|
|
}
|
2020-01-24 14:21:22 +09:00
|
|
|
|
|
2019-07-04 11:59:38 +02:00
|
|
|
|
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
2018-01-17 17:37:14 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-07-04 11:59:38 +02:00
|
|
|
|
protected override void LoadComplete()
|
2017-03-23 06:37:12 -03:00
|
|
|
|
{
|
2019-07-05 08:48:40 +02:00
|
|
|
|
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
|
2019-07-05 09:16:50 +02:00
|
|
|
|
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
2017-04-14 14:40:52 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-04-14 14:40:52 +09:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-07-22 20:50:25 +02:00
|
|
|
|
this.FadeIn(500, Easing.OutQuint);
|
2017-03-23 06:37:12 -03:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-03-23 06:37:12 -03:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-07-14 19:18:12 +03:00
|
|
|
|
this.FadeOut(100);
|
2017-03-23 06:37:12 -03:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
protected override void UpdateObjects(IEnumerable<HitObject> objects)
|
2017-04-07 15:20:39 +09:00
|
|
|
|
{
|
2022-07-28 18:37:17 +09:00
|
|
|
|
graph.Objects = objects;
|
2022-07-28 15:30:45 +08:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
info.StartTime = FirstHitTime;
|
|
|
|
|
info.EndTime = LastHitTime;
|
|
|
|
|
bar.StartTime = FirstHitTime;
|
|
|
|
|
bar.EndTime = LastHitTime;
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-07-28 15:12:49 +08:00
|
|
|
|
protected override void UpdateProgress(double progress, bool isIntro)
|
2022-07-27 15:19:21 +08:00
|
|
|
|
{
|
2022-07-29 16:17:25 +03:00
|
|
|
|
bar.CurrentTime = GameplayClock.CurrentTime;
|
2022-07-28 15:12:49 +08:00
|
|
|
|
|
2022-07-28 18:25:24 +09:00
|
|
|
|
if (isIntro)
|
|
|
|
|
graph.Progress = 0;
|
|
|
|
|
else
|
2022-07-28 15:12:49 +08:00
|
|
|
|
graph.Progress = (int)(graph.ColumnCount * progress);
|
2022-07-27 15:19:21 +08:00
|
|
|
|
}
|
2020-10-14 18:15:58 +09:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2022-08-02 17:03:02 +01:00
|
|
|
|
Height = bottom_bar_height + graph_height + handle_size.Y + info.Height - graph.Y;
|
2017-04-07 15:20:39 +09:00
|
|
|
|
}
|
2019-07-04 11:59:38 +02:00
|
|
|
|
|
|
|
|
|
private void updateBarVisibility()
|
|
|
|
|
{
|
2020-01-24 14:21:22 +09:00
|
|
|
|
bar.ShowHandle = AllowSeeking.Value;
|
2019-07-04 11:59:38 +02:00
|
|
|
|
|
|
|
|
|
updateInfoMargin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateGraphVisibility()
|
|
|
|
|
{
|
|
|
|
|
float barHeight = bottom_bar_height + handle_size.Y;
|
|
|
|
|
|
2019-07-05 09:16:50 +02:00
|
|
|
|
bar.ResizeHeightTo(ShowGraph.Value ? barHeight + graph_height : barHeight, transition_duration, Easing.In);
|
2021-07-29 23:41:01 -07:00
|
|
|
|
graph.FadeTo(ShowGraph.Value ? 1 : 0, transition_duration, Easing.In);
|
2019-07-04 11:59:38 +02:00
|
|
|
|
|
|
|
|
|
updateInfoMargin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateInfoMargin()
|
|
|
|
|
{
|
2019-07-05 09:16:50 +02:00
|
|
|
|
float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0);
|
2019-07-04 11:59:38 +02:00
|
|
|
|
info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In);
|
|
|
|
|
}
|
2017-03-02 20:20:27 +09:00
|
|
|
|
}
|
|
|
|
|
}
|