1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +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 partial class AnalysisFrameEntry : LifetimeEntry
{ {
public OsuAction? Action { get; } public OsuAction[] Action { get; }
public Vector2 Position { 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; LifetimeStart = time;
LifetimeEnd = time + 1_000; 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.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -12,7 +17,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
/// </summary> /// </summary>
public partial class ClickMarker : AnalysisMarker public partial class ClickMarker : AnalysisMarker
{ {
private Container clickDisplay = null!; private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -45,33 +51,27 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
Alpha = 0, Alpha = 0,
}, },
}, },
clickDisplay = new Container leftClickDisplay = new CircularProgress
{ {
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Both,
Colour = Colours.Yellow, Colour = Colours.Yellow,
Scale = new Vector2(0.95f), Size = new Vector2(0.95f),
Width = 0.5f, Anchor = Anchor.CentreLeft,
Masking = true, Origin = Anchor.CentreRight,
BorderThickness = 2, Rotation = 180,
BorderColour = Color4.White, Progress = 0.5f,
Child = new CircularContainer 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, 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(16); Size = new Vector2(16);
@ -81,8 +81,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{ {
base.OnApply(entry); base.OnApply(entry);
clickDisplay.Alpha = entry.Action != null ? 1 : 0; leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
clickDisplay.Rotation = entry.Action == OsuAction.LeftButton ? 0 : 180; 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.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{ {
@ -12,7 +15,8 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
/// </summary> /// </summary>
public partial class FrameMarker : AnalysisMarker public partial class FrameMarker : AnalysisMarker
{ {
private Container clickDisplay = null!; private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
private Circle mainCircle = null!; private Circle mainCircle = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -27,24 +31,26 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Colours.Pink2, Colour = Colours.Pink2,
}, },
clickDisplay = new Container leftClickDisplay = new CircularProgress
{ {
Colour = Colours.Yellow, Colour = Colours.Yellow,
Scale = new Vector2(0.8f), Size = new Vector2(0.8f),
Anchor = Anchor.Centre, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Rotation = 180,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Width = 0.5f, },
Masking = true, rightClickDisplay = new CircularProgress
Children = new Drawable[]
{
new Circle
{ {
Colour = Colours.Yellow,
Size = new Vector2(0.8f),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both, 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) protected override void OnApply(AnalysisFrameEntry entry)
{ {
base.OnApply(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; leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
clickDisplay.Rotation = entry.Action == OsuAction.LeftButton ? 0 : 180; 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 leftHeld = false;
bool rightHeld = false; bool rightHeld = false;
OsuAction? lastAction = null;
foreach (var frame in replay.Frames) foreach (var frame in replay.Frames)
{ {
var osuFrame = (OsuReplayFrame)frame; var osuFrame = (OsuReplayFrame)frame;
@ -76,7 +74,6 @@ namespace osu.Game.Rulesets.Osu.UI
else if (!leftHeld && leftButton) else if (!leftHeld && leftButton)
{ {
leftHeld = true; leftHeld = true;
lastAction = OsuAction.LeftButton;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, 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) else if (!rightHeld && rightButton)
{ {
rightHeld = true; rightHeld = true;
lastAction = OsuAction.RightButton;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.RightButton)); ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.RightButton));
} }
if (!leftButton && !rightButton) FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, osuFrame.Actions.ToArray()));
lastAction = null;
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, lastAction));
CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position)); CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position));
} }
} }