2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-04-27 17:10:58 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2022-04-27 17:10:58 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class DefaultSongProgress : SongProgress
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-18 14:50:40 +08:00
|
|
|
|
private const float bottom_bar_height = 5;
|
2019-07-04 17:59:38 +08:00
|
|
|
|
private const float graph_height = SquareGraph.Column.WIDTH * 6;
|
2021-05-18 14:50:40 +08:00
|
|
|
|
private const float handle_height = 18;
|
|
|
|
|
|
|
|
|
|
private static readonly Vector2 handle_size = new Vector2(10, handle_height);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private const float transition_duration = 200;
|
|
|
|
|
|
|
|
|
|
private readonly SongProgressBar bar;
|
|
|
|
|
private readonly SongProgressGraph graph;
|
|
|
|
|
private readonly SongProgressInfo info;
|
|
|
|
|
|
2022-07-28 17:37:17 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private Player? player { get; set; }
|
2021-05-17 17:41:56 +08:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
public DefaultSongProgress()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-17 17:26:15 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-05-17 17:55:18 +08:00
|
|
|
|
info = new SongProgressInfo
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-17 17:55:18 +08: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),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-18 13:55:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-03-21 04:36:18 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-07-04 17:59:38 +08:00
|
|
|
|
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 17:59:38 +08:00
|
|
|
|
protected override void LoadComplete()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2023-01-18 13:55:41 +08:00
|
|
|
|
Interactive.BindValueChanged(_ => updateBarVisibility(), true);
|
2019-07-05 15:16:50 +08:00
|
|
|
|
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-01-18 13:55:41 +08:00
|
|
|
|
base.LoadComplete();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
protected override void UpdateObjects(IEnumerable<HitObject> objects)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-07-28 17:37:17 +08: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 17:19:50 +08: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 21:17:25 +08:00
|
|
|
|
bar.CurrentTime = GameplayClock.CurrentTime;
|
2022-07-28 15:12:49 +08:00
|
|
|
|
|
2022-07-28 17:25:24 +08: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 17:15:58 +08:00
|
|
|
|
|
2022-07-27 15:19:21 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2022-08-03 00:03:02 +08:00
|
|
|
|
Height = bottom_bar_height + graph_height + handle_size.Y + info.Height - graph.Y;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-07-04 17:59:38 +08:00
|
|
|
|
|
|
|
|
|
private void updateBarVisibility()
|
|
|
|
|
{
|
2023-01-18 13:55:41 +08:00
|
|
|
|
bar.Interactive = Interactive.Value;
|
2019-07-04 17:59:38 +08:00
|
|
|
|
|
|
|
|
|
updateInfoMargin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateGraphVisibility()
|
|
|
|
|
{
|
|
|
|
|
float barHeight = bottom_bar_height + handle_size.Y;
|
|
|
|
|
|
2019-07-05 15:16:50 +08:00
|
|
|
|
bar.ResizeHeightTo(ShowGraph.Value ? barHeight + graph_height : barHeight, transition_duration, Easing.In);
|
2021-07-30 14:41:01 +08:00
|
|
|
|
graph.FadeTo(ShowGraph.Value ? 1 : 0, transition_duration, Easing.In);
|
2019-07-04 17:59:38 +08:00
|
|
|
|
|
|
|
|
|
updateInfoMargin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateInfoMargin()
|
|
|
|
|
{
|
2023-01-18 13:55:41 +08:00
|
|
|
|
float finalMargin = bottom_bar_height + (Interactive.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0);
|
2019-07-04 17:59:38 +08:00
|
|
|
|
info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|