2024-09-03 16:49:50 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2024-02-24 12:32:35 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2024-09-04 18:28:07 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2024-02-24 12:32:35 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2024-09-04 17:35:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-02-24 12:32:35 +08:00
|
|
|
|
using osu.Game.Replays;
|
2024-09-04 18:28:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Configuration;
|
2024-02-24 12:32:35 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Replays;
|
2024-09-04 19:07:31 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI.ReplayAnalysis;
|
2024-02-24 12:32:35 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI
|
|
|
|
|
{
|
2024-09-04 17:43:33 +08:00
|
|
|
|
public partial class ReplayAnalysisOverlay : CompositeDrawable
|
2024-02-24 12:32:35 +08:00
|
|
|
|
{
|
2024-09-04 18:28:07 +08:00
|
|
|
|
private BindableBool hitMarkersEnabled { get; } = new BindableBool();
|
|
|
|
|
private BindableBool aimMarkersEnabled { get; } = new BindableBool();
|
|
|
|
|
private BindableBool aimLinesEnabled { get; } = new BindableBool();
|
|
|
|
|
|
2024-09-04 17:35:27 +08:00
|
|
|
|
protected readonly HitMarkersContainer HitMarkers;
|
|
|
|
|
protected readonly AimMarkersContainer AimMarkers;
|
|
|
|
|
protected readonly AimLinesContainer AimLines;
|
2024-09-03 12:59:42 +08:00
|
|
|
|
|
2024-09-04 17:35:27 +08:00
|
|
|
|
private readonly Replay replay;
|
2024-02-24 12:32:35 +08:00
|
|
|
|
|
2024-09-04 18:28:07 +08:00
|
|
|
|
public ReplayAnalysisOverlay(Replay replay)
|
2024-02-24 12:32:35 +08:00
|
|
|
|
{
|
2024-09-04 19:07:31 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2024-09-04 17:35:27 +08:00
|
|
|
|
this.replay = replay;
|
|
|
|
|
|
2024-02-24 12:32:35 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2024-02-28 10:51:54 +08:00
|
|
|
|
HitMarkers = new HitMarkersContainer(),
|
2024-09-04 17:35:27 +08:00
|
|
|
|
AimLines = new AimLinesContainer(),
|
|
|
|
|
AimMarkers = new AimMarkersContainer(),
|
2024-02-24 12:32:35 +08:00
|
|
|
|
};
|
2024-09-03 12:59:42 +08:00
|
|
|
|
}
|
2024-02-24 12:32:35 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2024-09-04 18:28:07 +08:00
|
|
|
|
private void load(OsuRulesetConfigManager config)
|
2024-02-24 12:32:35 +08:00
|
|
|
|
{
|
2024-09-04 18:09:23 +08:00
|
|
|
|
loadReplay();
|
2024-09-04 18:28:07 +08:00
|
|
|
|
|
|
|
|
|
config.BindWith(OsuRulesetSetting.ReplayHitMarkersEnabled, hitMarkersEnabled);
|
|
|
|
|
config.BindWith(OsuRulesetSetting.ReplayAimMarkersEnabled, aimMarkersEnabled);
|
|
|
|
|
config.BindWith(OsuRulesetSetting.ReplayAimLinesEnabled, aimLinesEnabled);
|
2024-09-03 12:59:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-04 17:35:27 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2024-09-04 18:28:07 +08:00
|
|
|
|
hitMarkersEnabled.BindValueChanged(enabled => HitMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
|
|
|
|
|
aimMarkersEnabled.BindValueChanged(enabled => AimMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
|
|
|
|
|
aimLinesEnabled.BindValueChanged(enabled => AimLines.FadeTo(enabled.NewValue ? 1 : 0), true);
|
2024-09-04 17:35:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-04 18:09:23 +08:00
|
|
|
|
private void loadReplay()
|
2024-09-03 12:59:42 +08:00
|
|
|
|
{
|
2024-02-24 12:32:35 +08:00
|
|
|
|
bool leftHeld = false;
|
|
|
|
|
bool rightHeld = false;
|
2024-02-28 10:51:54 +08:00
|
|
|
|
|
2024-09-04 17:35:27 +08:00
|
|
|
|
foreach (var frame in replay.Frames)
|
2024-02-24 12:32:35 +08:00
|
|
|
|
{
|
|
|
|
|
var osuFrame = (OsuReplayFrame)frame;
|
|
|
|
|
|
2024-02-28 10:51:54 +08:00
|
|
|
|
AimMarkers.Add(new AimPointEntry(osuFrame.Time, osuFrame.Position));
|
|
|
|
|
AimLines.Add(new AimPointEntry(osuFrame.Time, osuFrame.Position));
|
2024-02-24 12:32:35 +08:00
|
|
|
|
|
|
|
|
|
bool leftButton = osuFrame.Actions.Contains(OsuAction.LeftButton);
|
|
|
|
|
bool rightButton = osuFrame.Actions.Contains(OsuAction.RightButton);
|
|
|
|
|
|
|
|
|
|
if (leftHeld && !leftButton)
|
|
|
|
|
leftHeld = false;
|
|
|
|
|
else if (!leftHeld && leftButton)
|
|
|
|
|
{
|
2024-02-28 10:51:54 +08:00
|
|
|
|
HitMarkers.Add(new HitMarkerEntry(osuFrame.Time, osuFrame.Position, true));
|
2024-02-24 12:32:35 +08:00
|
|
|
|
leftHeld = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rightHeld && !rightButton)
|
|
|
|
|
rightHeld = false;
|
|
|
|
|
else if (!rightHeld && rightButton)
|
|
|
|
|
{
|
2024-02-28 10:51:54 +08:00
|
|
|
|
HitMarkers.Add(new HitMarkerEntry(osuFrame.Time, osuFrame.Position, false));
|
2024-02-24 12:32:35 +08:00
|
|
|
|
rightHeld = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|