2021-05-18 13:19:11 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2024-07-04 02:17:39 +08:00
|
|
|
|
using System;
|
2022-05-12 18:26:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-05-18 13:19:11 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-07-04 02:17:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2019-09-27 17:45:22 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
2018-03-12 16:18:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-07 15:08:56 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
2018-02-20 17:01:45 +08:00
|
|
|
|
{
|
2021-05-18 13:19:11 +08:00
|
|
|
|
public partial class SliderCircleOverlay : CompositeDrawable
|
2018-02-20 17:01:45 +08:00
|
|
|
|
{
|
2024-08-27 12:13:22 +08:00
|
|
|
|
public SliderEndDragMarker? EndDragMarker { get; }
|
|
|
|
|
|
2024-07-04 02:17:39 +08:00
|
|
|
|
public RectangleF VisibleQuad
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var result = CirclePiece.ScreenSpaceDrawQuad.AABBFloat;
|
|
|
|
|
|
|
|
|
|
if (endDragMarkerContainer == null) return result;
|
|
|
|
|
|
|
|
|
|
var size = result.Size * 1.4f;
|
|
|
|
|
var location = result.TopLeft - result.Size * 0.2f;
|
|
|
|
|
return new RectangleF(location, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
|
protected readonly HitCirclePiece CirclePiece;
|
|
|
|
|
|
2024-07-04 02:17:39 +08:00
|
|
|
|
private readonly Slider slider;
|
2023-12-20 07:05:32 +08:00
|
|
|
|
private readonly SliderPosition position;
|
2024-06-19 19:18:56 +08:00
|
|
|
|
private readonly HitCircleOverlapMarker? marker;
|
2024-07-04 02:17:39 +08:00
|
|
|
|
private readonly Container? endDragMarkerContainer;
|
2019-09-27 17:45:22 +08:00
|
|
|
|
|
2021-05-18 13:19:11 +08:00
|
|
|
|
public SliderCircleOverlay(Slider slider, SliderPosition position)
|
2018-02-20 17:01:45 +08:00
|
|
|
|
{
|
2024-07-04 02:17:39 +08:00
|
|
|
|
this.slider = slider;
|
2019-09-27 17:45:22 +08:00
|
|
|
|
this.position = position;
|
2020-01-24 16:50:36 +08:00
|
|
|
|
|
2024-06-19 19:18:56 +08:00
|
|
|
|
if (position == SliderPosition.Start)
|
|
|
|
|
AddInternal(marker = new HitCircleOverlapMarker());
|
|
|
|
|
|
|
|
|
|
AddInternal(CirclePiece = new HitCirclePiece());
|
2024-07-04 02:17:39 +08:00
|
|
|
|
|
|
|
|
|
if (position == SliderPosition.End)
|
|
|
|
|
{
|
|
|
|
|
AddInternal(endDragMarkerContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Padding = new MarginPadding(-2.5f),
|
|
|
|
|
Child = EndDragMarker = new SliderEndDragMarker()
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-02-20 17:01:45 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-09-27 17:45:22 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2024-07-04 02:17:39 +08:00
|
|
|
|
var circle = position == SliderPosition.Start ? (HitCircle)slider.HeadCircle :
|
|
|
|
|
slider.RepeatCount % 2 == 0 ? slider.TailCircle : slider.LastRepeat!;
|
2022-05-12 18:26:34 +08:00
|
|
|
|
|
|
|
|
|
CirclePiece.UpdateFrom(circle);
|
2024-06-19 19:18:56 +08:00
|
|
|
|
marker?.UpdateFrom(circle);
|
2024-07-04 02:17:39 +08:00
|
|
|
|
|
|
|
|
|
if (endDragMarkerContainer != null)
|
|
|
|
|
{
|
2024-09-17 14:23:46 +08:00
|
|
|
|
endDragMarkerContainer.Position = circle.Position + slider.StackOffset;
|
2024-07-04 02:17:39 +08:00
|
|
|
|
endDragMarkerContainer.Scale = CirclePiece.Scale * 1.2f;
|
|
|
|
|
var diff = slider.Path.PositionAt(1) - slider.Path.PositionAt(0.99f);
|
|
|
|
|
endDragMarkerContainer.Rotation = float.RadiansToDegrees(MathF.Atan2(diff.Y, diff.X));
|
|
|
|
|
}
|
2022-05-12 18:26:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Hide()
|
|
|
|
|
{
|
|
|
|
|
CirclePiece.Hide();
|
2024-07-04 02:17:39 +08:00
|
|
|
|
endDragMarkerContainer?.Hide();
|
2022-05-12 18:26:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
|
{
|
|
|
|
|
CirclePiece.Show();
|
2024-07-04 02:17:39 +08:00
|
|
|
|
endDragMarkerContainer?.Show();
|
|
|
|
|
}
|
2018-02-20 17:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|