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