2021-06-22 11:30:09 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-06-22 11:30:09 +08:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TimeSpanOutline : CompositeDrawable
|
2021-06-22 11:30:09 +08:00
|
|
|
{
|
|
|
|
private const float border_width = 4;
|
|
|
|
|
2021-06-23 09:26:01 +08:00
|
|
|
private const float opacity_when_empty = 0.5f;
|
|
|
|
|
2021-06-22 11:30:09 +08:00
|
|
|
private bool isEmpty = true;
|
|
|
|
|
|
|
|
public TimeSpanOutline()
|
|
|
|
{
|
2021-06-23 09:19:39 +08:00
|
|
|
Anchor = Origin = Anchor.BottomLeft;
|
2021-06-22 11:30:09 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
BorderThickness = border_width;
|
2021-06-23 09:26:01 +08:00
|
|
|
Alpha = opacity_when_empty;
|
2021-06-22 11:30:09 +08:00
|
|
|
|
2021-06-23 09:19:39 +08:00
|
|
|
// A box is needed to make the border visible.
|
2021-06-22 11:30:09 +08:00
|
|
|
InternalChild = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Transparent
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour osuColour)
|
|
|
|
{
|
|
|
|
BorderColour = osuColour.Yellow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, BananaShower hitObject)
|
|
|
|
{
|
|
|
|
float startY = hitObjectContainer.PositionAtTime(hitObject.StartTime);
|
|
|
|
float endY = hitObjectContainer.PositionAtTime(hitObject.EndTime);
|
|
|
|
|
|
|
|
Y = Math.Max(startY, endY);
|
|
|
|
float height = Math.Abs(startY - endY);
|
|
|
|
|
|
|
|
bool wasEmpty = isEmpty;
|
|
|
|
isEmpty = height == 0;
|
|
|
|
if (wasEmpty != isEmpty)
|
2021-06-23 09:26:01 +08:00
|
|
|
this.FadeTo(isEmpty ? opacity_when_empty : 1f, 150);
|
2021-06-22 11:30:09 +08:00
|
|
|
|
|
|
|
Height = Math.Max(height, border_width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|