1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 12:22:56 +08:00

Switch to using CircularProgress for more consistent sizing

Also show both mouse buttons at once on frame markers.
This commit is contained in:
Dean Herbert 2024-09-05 15:12:02 +09:00
parent 4f719b9fec
commit 7390d89c75
No known key found for this signature in database
4 changed files with 58 additions and 59 deletions

View File

@ -8,11 +8,11 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class AnalysisFrameEntry : LifetimeEntry
{
public OsuAction? Action { get; }
public OsuAction[] Action { get; }
public Vector2 Position { get; }
public AnalysisFrameEntry(double time, Vector2 position, OsuAction? action = null)
public AnalysisFrameEntry(double time, Vector2 position, params OsuAction[] action)
{
LifetimeStart = time;
LifetimeEnd = time + 1_000;

View File

@ -1,7 +1,12 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
@ -12,7 +17,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
/// </summary>
public partial class ClickMarker : AnalysisMarker
{
private Container clickDisplay = null!;
private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
[BackgroundDependencyLoader]
private void load()
@ -45,33 +51,27 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
Alpha = 0,
},
},
clickDisplay = new Container
leftClickDisplay = new CircularProgress
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Both,
Colour = Colours.Yellow,
Scale = new Vector2(0.95f),
Width = 0.5f,
Masking = true,
BorderThickness = 2,
BorderColour = Color4.White,
Child = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Width = 2,
Masking = true,
BorderThickness = 2,
BorderColour = Color4.White,
Child = new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0,
},
}
}
Size = new Vector2(0.95f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Rotation = 180,
Progress = 0.5f,
InnerRadius = 0.18f,
RelativeSizeAxes = Axes.Both,
},
rightClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.95f),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Progress = 0.5f,
InnerRadius = 0.18f,
RelativeSizeAxes = Axes.Both,
},
};
Size = new Vector2(16);
@ -81,8 +81,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
base.OnApply(entry);
clickDisplay.Alpha = entry.Action != null ? 1 : 0;
clickDisplay.Rotation = entry.Action == OsuAction.LeftButton ? 0 : 180;
leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
rightClickDisplay.Alpha = entry.Action.Contains(OsuAction.RightButton) ? 1 : 0;
}
}
}

View File

@ -1,9 +1,12 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
@ -12,7 +15,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
/// </summary>
public partial class FrameMarker : AnalysisMarker
{
private Container clickDisplay = null!;
private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
private Circle mainCircle = null!;
[BackgroundDependencyLoader]
@ -27,24 +31,26 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
RelativeSizeAxes = Axes.Both,
Colour = Colours.Pink2,
},
clickDisplay = new Container
leftClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Scale = new Vector2(0.8f),
Anchor = Anchor.Centre,
Size = new Vector2(0.8f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Rotation = 180,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both,
},
rightClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.8f),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Masking = true,
Children = new Drawable[]
{
new Circle
{
RelativeSizeAxes = Axes.Both,
Width = 2,
Colour = Color4.White,
},
},
},
};
}
@ -52,12 +58,12 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
protected override void OnApply(AnalysisFrameEntry entry)
{
base.OnApply(entry);
Size = new Vector2(entry.Action != null ? 4 : 2.5f);
Size = new Vector2(entry.Action.Any() ? 4 : 2.5f);
mainCircle.Colour = entry.Action != null ? Colours.Gray4 : Colours.Pink2;
mainCircle.Colour = entry.Action.Any() ? Colours.Gray4 : Colours.Pink2;
clickDisplay.Alpha = entry.Action != null ? 1 : 0;
clickDisplay.Rotation = entry.Action == OsuAction.LeftButton ? 0 : 180;
leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
rightClickDisplay.Alpha = entry.Action.Contains(OsuAction.RightButton) ? 1 : 0;
}
}
}

View File

@ -62,8 +62,6 @@ namespace osu.Game.Rulesets.Osu.UI
bool leftHeld = false;
bool rightHeld = false;
OsuAction? lastAction = null;
foreach (var frame in replay.Frames)
{
var osuFrame = (OsuReplayFrame)frame;
@ -76,7 +74,6 @@ namespace osu.Game.Rulesets.Osu.UI
else if (!leftHeld && leftButton)
{
leftHeld = true;
lastAction = OsuAction.LeftButton;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.LeftButton));
}
@ -85,14 +82,10 @@ namespace osu.Game.Rulesets.Osu.UI
else if (!rightHeld && rightButton)
{
rightHeld = true;
lastAction = OsuAction.RightButton;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.RightButton));
}
if (!leftButton && !rightButton)
lastAction = null;
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, lastAction));
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, osuFrame.Actions.ToArray()));
CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position));
}
}