mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:18:22 +08:00
Split out classes and avoid weird configuration stuff
This commit is contained in:
parent
6a309725ed
commit
dcb463acaf
@ -1,74 +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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
{
|
||||
public partial class HitMarker : CompositeDrawable
|
||||
{
|
||||
public HitMarker(OsuAction? action)
|
||||
{
|
||||
var (colour, length, hasBorder) = getConfig(action);
|
||||
|
||||
if (hasBorder)
|
||||
{
|
||||
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)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(1, length),
|
||||
Colour = colour
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(1, length),
|
||||
Rotation = 90,
|
||||
Colour = colour
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private (Colour4 colour, float length, bool hasBorder) getConfig(OsuAction? action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case OsuAction.LeftButton:
|
||||
return (Colour4.Orange, 20, true);
|
||||
|
||||
case OsuAction.RightButton:
|
||||
return (Colour4.LightGreen, 20, true);
|
||||
|
||||
default:
|
||||
return (Colour4.Gray.Opacity(0.5F), 8, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
70
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AimLinesContainer.cs
Normal file
70
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AimLinesContainer.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class AimLinesContainer : Path
|
||||
{
|
||||
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
|
||||
private readonly SortedSet<AimPointEntry> aliveEntries = new SortedSet<AimPointEntry>(new AimLinePointComparator());
|
||||
|
||||
public AimLinesContainer()
|
||||
{
|
||||
lifetimeManager.EntryBecameAlive += entryBecameAlive;
|
||||
lifetimeManager.EntryBecameDead += entryBecameDead;
|
||||
|
||||
PathRadius = 1f;
|
||||
Colour = new Color4(255, 255, 255, 127);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
lifetimeManager.Update(Time.Current);
|
||||
}
|
||||
|
||||
public void Add(AimPointEntry entry) => lifetimeManager.AddEntry(entry);
|
||||
|
||||
public void Clear() => lifetimeManager.ClearEntries();
|
||||
|
||||
private void entryBecameAlive(LifetimeEntry entry)
|
||||
{
|
||||
aliveEntries.Add((AimPointEntry)entry);
|
||||
updateVertices();
|
||||
}
|
||||
|
||||
private void entryBecameDead(LifetimeEntry entry)
|
||||
{
|
||||
aliveEntries.Remove((AimPointEntry)entry);
|
||||
updateVertices();
|
||||
}
|
||||
|
||||
private void updateVertices()
|
||||
{
|
||||
ClearVertices();
|
||||
|
||||
foreach (var entry in aliveEntries)
|
||||
{
|
||||
AddVertex(entry.Position);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AimLinePointComparator : IComparer<AimPointEntry>
|
||||
{
|
||||
public int Compare(AimPointEntry? x, AimPointEntry? y)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return x.LifetimeStart.CompareTo(y.LifetimeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// 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 osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class AimMarkersContainer : PooledDrawableWithLifetimeContainer<AimPointEntry, HitMarker>
|
||||
{
|
||||
private readonly DrawablePool<HitMarkerMovement> pool;
|
||||
|
||||
public AimMarkersContainer()
|
||||
{
|
||||
AddInternal(pool = new DrawablePool<HitMarkerMovement>(80));
|
||||
}
|
||||
|
||||
protected override HitMarker GetDrawable(AimPointEntry entry) => pool.Get(d => d.Apply(entry));
|
||||
}
|
||||
}
|
20
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AimPointEntry.cs
Normal file
20
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AimPointEntry.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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 osu.Framework.Graphics.Performance;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class AimPointEntry : LifetimeEntry
|
||||
{
|
||||
public Vector2 Position { get; }
|
||||
|
||||
public AimPointEntry(double time, Vector2 position)
|
||||
{
|
||||
LifetimeStart = time;
|
||||
LifetimeEnd = time + 1_000;
|
||||
Position = position;
|
||||
}
|
||||
}
|
||||
}
|
27
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarker.cs
Normal file
27
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarker.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class HitMarker : PoolableDrawableWithLifetime<AimPointEntry>
|
||||
{
|
||||
public HitMarker()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
protected override void OnApply(AimPointEntry entry)
|
||||
{
|
||||
Position = entry.Position;
|
||||
|
||||
using (BeginAbsoluteSequence(LifetimeStart))
|
||||
Show();
|
||||
|
||||
using (BeginAbsoluteSequence(LifetimeEnd - 200))
|
||||
this.FadeOut(200);
|
||||
}
|
||||
}
|
||||
}
|
18
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarkerEntry.cs
Normal file
18
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarkerEntry.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class HitMarkerLeftClick : HitMarker
|
||||
{
|
||||
public HitMarkerLeftClick()
|
||||
{
|
||||
const float length = 20;
|
||||
|
||||
Colour = Color4.OrangeRed;
|
||||
|
||||
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,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
50
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarkerMovement.cs
Normal file
50
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/HitMarkerMovement.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class HitMarkerMovement : HitMarker
|
||||
{
|
||||
public HitMarkerMovement()
|
||||
{
|
||||
const float length = 5;
|
||||
|
||||
Colour = Color4.Gray.Opacity(0.4f);
|
||||
|
||||
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,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
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,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// 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 osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
|
||||
{
|
||||
public partial class HitMarkersContainer : PooledDrawableWithLifetimeContainer<HitMarkerEntry, HitMarker>
|
||||
{
|
||||
private readonly DrawablePool<HitMarkerLeftClick> leftPool;
|
||||
private readonly DrawablePool<HitMarkerRightClick> rightPool;
|
||||
|
||||
public HitMarkersContainer()
|
||||
{
|
||||
AddInternal(leftPool = new DrawablePool<HitMarkerLeftClick>(15));
|
||||
AddInternal(rightPool = new DrawablePool<HitMarkerRightClick>(15));
|
||||
}
|
||||
|
||||
protected override HitMarker GetDrawable(HitMarkerEntry entry)
|
||||
{
|
||||
if (entry.IsLeftMarker)
|
||||
return leftPool.Get(d => d.Apply(entry));
|
||||
|
||||
return rightPool.Get(d => d.Apply(entry));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,14 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Rulesets.Osu.UI.ReplayAnalysis;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
@ -34,6 +26,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
public ReplayAnalysisOverlay(Replay replay)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
this.replay = replay;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
@ -95,153 +89,5 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected partial class HitMarkersContainer : PooledDrawableWithLifetimeContainer<HitMarkerEntry, HitMarkerDrawable>
|
||||
{
|
||||
private readonly HitMarkerPool leftPool;
|
||||
private readonly HitMarkerPool rightPool;
|
||||
|
||||
public HitMarkersContainer()
|
||||
{
|
||||
AddInternal(leftPool = new HitMarkerPool(OsuAction.LeftButton, 15));
|
||||
AddInternal(rightPool = new HitMarkerPool(OsuAction.RightButton, 15));
|
||||
}
|
||||
|
||||
protected override HitMarkerDrawable GetDrawable(HitMarkerEntry entry) => (entry.IsLeftMarker ? leftPool : rightPool).Get(d => d.Apply(entry));
|
||||
}
|
||||
|
||||
protected partial class AimMarkersContainer : PooledDrawableWithLifetimeContainer<AimPointEntry, HitMarkerDrawable>
|
||||
{
|
||||
private readonly HitMarkerPool pool;
|
||||
|
||||
public AimMarkersContainer()
|
||||
{
|
||||
AddInternal(pool = new HitMarkerPool(null, 80));
|
||||
}
|
||||
|
||||
protected override HitMarkerDrawable GetDrawable(AimPointEntry entry) => pool.Get(d => d.Apply(entry));
|
||||
}
|
||||
|
||||
protected partial class AimLinesContainer : Path
|
||||
{
|
||||
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
|
||||
private readonly SortedSet<AimPointEntry> aliveEntries = new SortedSet<AimPointEntry>(new AimLinePointComparator());
|
||||
|
||||
public AimLinesContainer()
|
||||
{
|
||||
lifetimeManager.EntryBecameAlive += entryBecameAlive;
|
||||
lifetimeManager.EntryBecameDead += entryBecameDead;
|
||||
|
||||
PathRadius = 1f;
|
||||
Colour = new Color4(255, 255, 255, 127);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
lifetimeManager.Update(Time.Current);
|
||||
}
|
||||
|
||||
public void Add(AimPointEntry entry) => lifetimeManager.AddEntry(entry);
|
||||
|
||||
public void Clear() => lifetimeManager.ClearEntries();
|
||||
|
||||
private void entryBecameAlive(LifetimeEntry entry)
|
||||
{
|
||||
aliveEntries.Add((AimPointEntry)entry);
|
||||
updateVertices();
|
||||
}
|
||||
|
||||
private void entryBecameDead(LifetimeEntry entry)
|
||||
{
|
||||
aliveEntries.Remove((AimPointEntry)entry);
|
||||
updateVertices();
|
||||
}
|
||||
|
||||
private void updateVertices()
|
||||
{
|
||||
ClearVertices();
|
||||
|
||||
foreach (var entry in aliveEntries)
|
||||
{
|
||||
AddVertex(entry.Position);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AimLinePointComparator : IComparer<AimPointEntry>
|
||||
{
|
||||
public int Compare(AimPointEntry? x, AimPointEntry? y)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return x.LifetimeStart.CompareTo(y.LifetimeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected partial class HitMarkerDrawable : PoolableDrawableWithLifetime<AimPointEntry>
|
||||
{
|
||||
/// <summary>
|
||||
/// This constructor only exists to meet the <c>new()</c> type constraint of <see cref="DrawablePool{T}"/>.
|
||||
/// </summary>
|
||||
public HitMarkerDrawable()
|
||||
{
|
||||
}
|
||||
|
||||
public HitMarkerDrawable(OsuAction? action)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
InternalChild = new HitMarker(action);
|
||||
}
|
||||
|
||||
protected override void OnApply(AimPointEntry entry)
|
||||
{
|
||||
Position = entry.Position;
|
||||
|
||||
using (BeginAbsoluteSequence(LifetimeStart))
|
||||
Show();
|
||||
|
||||
using (BeginAbsoluteSequence(LifetimeEnd - 200))
|
||||
this.FadeOut(200);
|
||||
}
|
||||
}
|
||||
|
||||
protected partial class HitMarkerPool : DrawablePool<HitMarkerDrawable>
|
||||
{
|
||||
private readonly OsuAction? action;
|
||||
|
||||
public HitMarkerPool(OsuAction? action, int initialSize)
|
||||
: base(initialSize)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
protected override HitMarkerDrawable CreateNewDrawable() => new HitMarkerDrawable(action);
|
||||
}
|
||||
|
||||
protected partial class AimPointEntry : LifetimeEntry
|
||||
{
|
||||
public Vector2 Position { get; }
|
||||
|
||||
public AimPointEntry(double time, Vector2 position)
|
||||
{
|
||||
LifetimeStart = time;
|
||||
LifetimeEnd = time + 1_000;
|
||||
Position = position;
|
||||
}
|
||||
}
|
||||
|
||||
protected partial class HitMarkerEntry : AimPointEntry
|
||||
{
|
||||
public bool IsLeftMarker { get; }
|
||||
|
||||
public HitMarkerEntry(double lifetimeStart, Vector2 position, bool isLeftMarker)
|
||||
: base(lifetimeStart, position)
|
||||
{
|
||||
IsLeftMarker = isLeftMarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user