1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 00:42:55 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/DefaultSongProgressBar.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

111 lines
3.6 KiB
C#
Raw Normal View History

// 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
2017-06-23 00:42:29 +08:00
using System;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2017-03-22 19:54:21 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
2020-01-09 12:43:44 +08:00
using osu.Framework.Utils;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Play.HUD
2017-03-22 19:54:21 +08:00
{
public partial class DefaultSongProgressBar : SongProgressBar
2017-03-22 19:54:21 +08:00
{
public Color4 FillColour
{
set => fill.Colour = value;
}
2018-04-13 17:19:50 +08:00
private readonly Box fill;
private readonly Container handleBase;
private readonly Container handleContainer;
public DefaultSongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
2017-06-23 00:42:29 +08:00
{
RelativeSizeAxes = Axes.X;
Height = barHeight + handleBarHeight + handleSize.Y;
2018-04-13 17:19:50 +08:00
2024-01-29 00:49:34 +08:00
InternalChildren = new Drawable[]
{
2017-06-24 16:15:53 +08:00
new Box
2017-03-22 19:54:21 +08:00
{
2017-06-23 00:42:29 +08:00
Name = "Background",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = barHeight,
Colour = Color4.Black,
Alpha = 0.5f,
Depth = 1,
},
fill = new Box
{
Name = "Fill",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Height = barHeight,
},
handleBase = new Container
{
Name = "HandleBar container",
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Width = 2,
Alpha = 0,
2017-06-23 00:42:29 +08:00
Colour = Color4.White,
Position = new Vector2(2, 0),
Children = new Drawable[]
2017-03-22 19:54:21 +08:00
{
2017-06-23 00:42:29 +08:00
new Box
2017-03-22 19:54:21 +08:00
{
2017-06-23 00:42:29 +08:00
Name = "HandleBar box",
RelativeSizeAxes = Axes.Both,
},
handleContainer = new Container
2017-06-23 00:42:29 +08:00
{
Name = "Handle container",
Origin = Anchor.BottomCentre,
Anchor = Anchor.TopCentre,
Size = handleSize,
CornerRadius = 5,
Masking = true,
Children = new Drawable[]
2017-03-22 19:54:21 +08:00
{
2017-06-23 00:42:29 +08:00
new Box
{
Name = "Handle box",
RelativeSizeAxes = Axes.Both,
Colour = Color4.White
}
2017-03-22 19:54:21 +08:00
}
}
}
}
2017-06-23 00:42:29 +08:00
};
2017-03-22 19:54:21 +08:00
}
2018-04-13 17:19:50 +08:00
2024-01-29 01:13:39 +08:00
public override bool Interactive
2017-06-23 00:42:29 +08:00
{
2024-01-29 01:13:39 +08:00
get => base.Interactive;
set
{
base.Interactive = value;
handleBase.FadeTo(value ? 1 : 0, 200);
}
2019-05-09 17:05:28 +08:00
}
protected override void Update()
{
base.Update();
handleBase.Height = Height - handleContainer.Height;
float newX = (float)Interpolation.Lerp(handleBase.X, AudioProgress * DrawWidth, Math.Clamp(Time.Elapsed / 40, 0, 1));
2019-05-09 17:05:28 +08:00
fill.Width = newX;
handleBase.X = newX;
2017-06-23 00:42:29 +08:00
}
2017-03-22 19:54:21 +08:00
}
}