2022-05-12 18:26:34 +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
|
|
|
|
|
2022-05-12 18:26:34 +08:00
|
|
|
using osu.Framework.Allocation;
|
2022-11-08 17:07:06 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-05-12 18:26:34 +08:00
|
|
|
using osu.Framework.Graphics;
|
2022-11-08 17:07:06 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-05-12 18:26:34 +08:00
|
|
|
using osu.Framework.Utils;
|
2022-11-08 17:07:06 +08:00
|
|
|
using osu.Game.Configuration;
|
2022-05-12 18:26:34 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
|
|
|
|
{
|
|
|
|
public partial class HitCircleOverlapMarker : BlueprintPiece<HitCircle>
|
|
|
|
{
|
2022-05-12 18:42:35 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Hit objects are intentionally made to fade out at a constant slower rate than in gameplay.
|
|
|
|
/// This allows a mapper to gain better historical context and use recent hitobjects as reference / snap points.
|
|
|
|
/// </summary>
|
|
|
|
public const double FADE_OUT_EXTENSION = 700;
|
|
|
|
|
2022-05-12 18:26:34 +08:00
|
|
|
private readonly RingPiece ring;
|
|
|
|
|
2022-11-08 17:07:06 +08:00
|
|
|
private readonly Container content;
|
|
|
|
|
2022-05-12 18:26:34 +08:00
|
|
|
[Resolved]
|
|
|
|
private EditorClock editorClock { get; set; }
|
|
|
|
|
2022-11-08 17:07:06 +08:00
|
|
|
private Bindable<bool> showHitMarkers;
|
|
|
|
|
2022-05-12 18:26:34 +08:00
|
|
|
public HitCircleOverlapMarker()
|
|
|
|
{
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
2023-09-20 11:48:15 +08:00
|
|
|
Size = OsuHitObject.OBJECT_DIMENSIONS;
|
2022-05-12 18:26:34 +08:00
|
|
|
|
2022-11-08 17:07:06 +08:00
|
|
|
InternalChild = content = new Container
|
2022-05-12 18:26:34 +08:00
|
|
|
{
|
2022-11-08 17:07:06 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
2022-05-12 18:26:34 +08:00
|
|
|
{
|
2022-11-08 17:07:06 +08:00
|
|
|
ring = new RingPiece
|
|
|
|
{
|
|
|
|
BorderThickness = 4,
|
|
|
|
}
|
2022-05-12 18:26:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-08 17:07:06 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
{
|
|
|
|
showHitMarkers = config.GetBindable<bool>(OsuSetting.EditorShowHitMarkers);
|
|
|
|
}
|
|
|
|
|
2022-05-12 18:26:34 +08:00
|
|
|
[Resolved]
|
|
|
|
private ISkinSource skin { get; set; }
|
|
|
|
|
|
|
|
public override void UpdateFrom(HitCircle hitObject)
|
|
|
|
{
|
|
|
|
base.UpdateFrom(hitObject);
|
|
|
|
|
|
|
|
Scale = new Vector2(hitObject.Scale);
|
|
|
|
|
2022-05-12 18:42:35 +08:00
|
|
|
double editorTime = editorClock.CurrentTime;
|
|
|
|
double hitObjectTime = hitObject.StartTime;
|
|
|
|
bool hasReachedObject = editorTime >= hitObjectTime;
|
2022-05-12 18:26:34 +08:00
|
|
|
|
2022-11-08 17:07:06 +08:00
|
|
|
if (hasReachedObject && showHitMarkers.Value)
|
2022-05-12 18:26:34 +08:00
|
|
|
{
|
2022-05-12 18:42:35 +08:00
|
|
|
float alpha = Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION, Easing.In);
|
|
|
|
float ringScale = MathHelper.Clamp(Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION / 2, Easing.OutQuint), 0, 1);
|
|
|
|
|
|
|
|
ring.Scale = new Vector2(1 + 0.1f * ringScale);
|
2022-11-08 17:07:06 +08:00
|
|
|
content.Alpha = 0.9f * (1 - alpha);
|
2024-02-20 01:55:43 +08:00
|
|
|
|
|
|
|
// TODO: should only update colour on skin/combo/object change.
|
|
|
|
if (hitObject is IHasComboInformation combo && content.Alpha > 0)
|
|
|
|
ring.BorderColour = combo.GetComboColour(skin);
|
2022-05-12 18:26:34 +08:00
|
|
|
}
|
|
|
|
else
|
2022-11-08 17:07:06 +08:00
|
|
|
content.Alpha = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
{
|
|
|
|
// intentional no op so SelectionBlueprint Selection/Deselection logic doesn't touch us.
|
2022-05-12 18:26:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Hide()
|
|
|
|
{
|
2022-11-08 17:07:06 +08:00
|
|
|
// intentional no op so SelectionBlueprint Selection/Deselection logic doesn't touch us.
|
2022-05-12 18:26:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|