1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 06:12:55 +08:00

Simplify lifetime entries and stuff

This commit is contained in:
Dean Herbert 2024-09-04 20:25:29 +09:00
parent 7f9a98a7aa
commit a4a37c5ba6
No known key found for this signature in database
9 changed files with 61 additions and 104 deletions

View File

@ -6,15 +6,18 @@ using osuTK;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class AimPointEntry : LifetimeEntry
public partial class AnalysisFrameEntry : LifetimeEntry
{
public OsuAction? Action { get; }
public Vector2 Position { get; }
public AimPointEntry(double time, Vector2 position)
public AnalysisFrameEntry(double time, Vector2 position, OsuAction? action = null)
{
LifetimeStart = time;
LifetimeEnd = time + 1_000;
Position = position;
Action = action;
}
}
}

View File

@ -6,23 +6,15 @@ using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class ClickMarkerContainer : PooledDrawableWithLifetimeContainer<HitMarkerEntry, HitMarker>
public partial class ClickMarkerContainer : PooledDrawableWithLifetimeContainer<AnalysisFrameEntry, HitMarker>
{
private readonly DrawablePool<HitMarkerLeftClick> leftPool;
private readonly DrawablePool<HitMarkerRightClick> rightPool;
private readonly DrawablePool<HitMarkerClick> clickMarkerPool;
public ClickMarkerContainer()
{
AddInternal(leftPool = new DrawablePool<HitMarkerLeftClick>(15));
AddInternal(rightPool = new DrawablePool<HitMarkerRightClick>(15));
AddInternal(clickMarkerPool = new DrawablePool<HitMarkerClick>(30));
}
protected override HitMarker GetDrawable(HitMarkerEntry entry)
{
if (entry.IsLeftMarker)
return leftPool.Get(d => d.Apply(entry));
return rightPool.Get(d => d.Apply(entry));
}
protected override HitMarker GetDrawable(AnalysisFrameEntry entry) => clickMarkerPool.Get(d => d.Apply(entry));
}
}

View File

@ -6,14 +6,14 @@ using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class HitMarker : PoolableDrawableWithLifetime<AimPointEntry>
public partial class HitMarker : PoolableDrawableWithLifetime<AnalysisFrameEntry>
{
public HitMarker()
{
Origin = Anchor.Centre;
}
protected override void OnApply(AimPointEntry entry)
protected override void OnApply(AnalysisFrameEntry entry)
{
Position = entry.Position;

View File

@ -1,17 +1,18 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class HitMarkerLeftClick : HitMarker
public partial class HitMarkerClick : HitMarker
{
public HitMarkerLeftClick()
public HitMarkerClick()
{
const float length = 20;
Colour = Color4.OrangeRed;
const float border_size = 3;
InternalChildren = new Drawable[]
{
@ -19,14 +20,14 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(3, length),
Size = new Vector2(border_size, length + border_size),
Colour = Colour4.Black.Opacity(0.5F)
},
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(3, length),
Size = new Vector2(border_size, length + border_size),
Rotation = 90,
Colour = Colour4.Black.Opacity(0.5F)
},
@ -45,5 +46,27 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
}
};
}
[Resolved]
private OsuColour colours { get; set; } = null!;
protected override void OnApply(AnalysisFrameEntry entry)
{
base.OnApply(entry);
switch (entry.Action)
{
case OsuAction.LeftButton:
Colour = colours.BlueLight;
break;
case OsuAction.RightButton:
Colour = colours.YellowLight;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}

View File

@ -1,18 +0,0 @@
// 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.
using osuTK;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class HitMarkerEntry : AimPointEntry
{
public bool IsLeftMarker { get; }
public HitMarkerEntry(double lifetimeStart, Vector2 position, bool isLeftMarker)
: base(lifetimeStart, position)
{
IsLeftMarker = isLeftMarker;
}
}
}

View File

@ -1,49 +0,0 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class HitMarkerRightClick : HitMarker
{
public HitMarkerRightClick()
{
const float length = 20;
Colour = Color4.GreenYellow;
InternalChildren = new Drawable[]
{
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(3, length),
Colour = Colour4.Black.Opacity(0.5F)
},
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(3, length),
Rotation = 90,
Colour = Colour4.Black.Opacity(0.5F)
},
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(1, length),
},
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(1, length),
Rotation = 90,
}
};
}
}
}

View File

@ -6,7 +6,7 @@ using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class MovementMarkerContainer : PooledDrawableWithLifetimeContainer<AimPointEntry, HitMarker>
public partial class MovementMarkerContainer : PooledDrawableWithLifetimeContainer<AnalysisFrameEntry, HitMarker>
{
private readonly DrawablePool<HitMarkerMovement> pool;
@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
AddInternal(pool = new DrawablePool<HitMarkerMovement>(80));
}
protected override HitMarker GetDrawable(AimPointEntry entry) => pool.Get(d => d.Apply(entry));
protected override HitMarker GetDrawable(AnalysisFrameEntry entry) => pool.Get(d => d.Apply(entry));
}
}

View File

@ -3,16 +3,17 @@
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Performance;
using osuTK.Graphics;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class MovementPathContainer : Path
{
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
private readonly SortedSet<AimPointEntry> aliveEntries = new SortedSet<AimPointEntry>(new AimLinePointComparator());
private readonly SortedSet<AnalysisFrameEntry> aliveEntries = new SortedSet<AnalysisFrameEntry>(new AimLinePointComparator());
public MovementPathContainer()
{
@ -20,7 +21,12 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
lifetimeManager.EntryBecameDead += entryBecameDead;
PathRadius = 1f;
Colour = new Color4(255, 255, 255, 127);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Pink2;
}
protected override void Update()
@ -30,17 +36,17 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
lifetimeManager.Update(Time.Current);
}
public void Add(AimPointEntry entry) => lifetimeManager.AddEntry(entry);
public void Add(AnalysisFrameEntry entry) => lifetimeManager.AddEntry(entry);
private void entryBecameAlive(LifetimeEntry entry)
{
aliveEntries.Add((AimPointEntry)entry);
aliveEntries.Add((AnalysisFrameEntry)entry);
updateVertices();
}
private void entryBecameDead(LifetimeEntry entry)
{
aliveEntries.Remove((AimPointEntry)entry);
aliveEntries.Remove((AnalysisFrameEntry)entry);
updateVertices();
}
@ -54,9 +60,9 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
}
}
private sealed class AimLinePointComparator : IComparer<AimPointEntry>
private sealed class AimLinePointComparator : IComparer<AnalysisFrameEntry>
{
public int Compare(AimPointEntry? x, AimPointEntry? y)
public int Compare(AnalysisFrameEntry? x, AnalysisFrameEntry? y)
{
ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y);

View File

@ -66,8 +66,8 @@ namespace osu.Game.Rulesets.Osu.UI
{
var osuFrame = (OsuReplayFrame)frame;
MovementMarkers.Add(new AimPointEntry(osuFrame.Time, osuFrame.Position));
MovementPath.Add(new AimPointEntry(osuFrame.Time, osuFrame.Position));
MovementMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position));
MovementPath.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position));
bool leftButton = osuFrame.Actions.Contains(OsuAction.LeftButton);
bool rightButton = osuFrame.Actions.Contains(OsuAction.RightButton);
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.UI
leftHeld = false;
else if (!leftHeld && leftButton)
{
ClickMarkers.Add(new HitMarkerEntry(osuFrame.Time, osuFrame.Position, true));
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.LeftButton));
leftHeld = true;
}
@ -84,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
rightHeld = false;
else if (!rightHeld && rightButton)
{
ClickMarkers.Add(new HitMarkerEntry(osuFrame.Time, osuFrame.Position, false));
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.RightButton));
rightHeld = true;
}
}