1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Add setting to adjust replay analysis display length

This commit is contained in:
Dean Herbert 2024-09-05 15:53:53 +09:00
parent 0f01a855af
commit a1cf67be62
No known key found for this signature in database
4 changed files with 64 additions and 22 deletions

View File

@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
SetDefault(OsuRulesetSetting.ReplayFrameMarkersEnabled, false);
SetDefault(OsuRulesetSetting.ReplayCursorPathEnabled, false);
SetDefault(OsuRulesetSetting.ReplayCursorHideEnabled, false);
SetDefault(OsuRulesetSetting.ReplayAnalysisDisplayLength, 750);
}
}
@ -43,5 +44,6 @@ namespace osu.Game.Rulesets.Osu.Configuration
ReplayFrameMarkersEnabled,
ReplayCursorPathEnabled,
ReplayCursorHideEnabled,
ReplayAnalysisDisplayLength,
}
}

View File

@ -12,10 +12,10 @@ namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
public Vector2 Position { get; }
public AnalysisFrameEntry(double time, Vector2 position, params OsuAction[] action)
public AnalysisFrameEntry(double time, double displayLength, Vector2 position, params OsuAction[] action)
{
LifetimeStart = time;
LifetimeEnd = time + 1_000;
LifetimeEnd = time + displayLength;
Position = position;
Action = action;
}

View File

@ -17,10 +17,11 @@ namespace osu.Game.Rulesets.Osu.UI
private BindableBool showClickMarkers { get; } = new BindableBool();
private BindableBool showFrameMarkers { get; } = new BindableBool();
private BindableBool showCursorPath { get; } = new BindableBool();
private BindableInt displayLength { get; } = new BindableInt();
protected readonly ClickMarkerContainer ClickMarkers;
protected readonly FrameMarkerContainer FrameMarkers;
protected readonly CursorPathContainer CursorPath;
protected ClickMarkerContainer ClickMarkers = null!;
protected FrameMarkerContainer FrameMarkers = null!;
protected CursorPathContainer CursorPath = null!;
private readonly Replay replay;
@ -29,36 +30,65 @@ namespace osu.Game.Rulesets.Osu.UI
RelativeSizeAxes = Axes.Both;
this.replay = replay;
InternalChildren = new Drawable[]
{
CursorPath = new CursorPathContainer(),
ClickMarkers = new ClickMarkerContainer(),
FrameMarkers = new FrameMarkerContainer(),
};
}
private bool requireDisplay => showClickMarkers.Value || showFrameMarkers.Value || showCursorPath.Value;
[BackgroundDependencyLoader]
private void load(OsuRulesetConfigManager config)
{
loadReplay();
config.BindWith(OsuRulesetSetting.ReplayClickMarkersEnabled, showClickMarkers);
config.BindWith(OsuRulesetSetting.ReplayFrameMarkersEnabled, showFrameMarkers);
config.BindWith(OsuRulesetSetting.ReplayCursorPathEnabled, showCursorPath);
config.BindWith(OsuRulesetSetting.ReplayAnalysisDisplayLength, displayLength);
}
protected override void LoadComplete()
{
base.LoadComplete();
showClickMarkers.BindValueChanged(enabled => ClickMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
showFrameMarkers.BindValueChanged(enabled => FrameMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
showCursorPath.BindValueChanged(enabled => CursorPath.FadeTo(enabled.NewValue ? 1 : 0), true);
showClickMarkers.BindValueChanged(enabled =>
{
initialise();
ClickMarkers.FadeTo(enabled.NewValue ? 1 : 0);
}, true);
showFrameMarkers.BindValueChanged(enabled =>
{
initialise();
FrameMarkers.FadeTo(enabled.NewValue ? 1 : 0);
}, true);
showCursorPath.BindValueChanged(enabled =>
{
initialise();
CursorPath.FadeTo(enabled.NewValue ? 1 : 0);
}, true);
displayLength.BindValueChanged(_ =>
{
isLoaded = false;
initialise();
}, true);
}
private void loadReplay()
private bool isLoaded;
private void initialise()
{
if (!requireDisplay)
return;
if (isLoaded)
return;
isLoaded = true;
// It's faster to reinitialise the whole drawable stack than use `Clear` on `PooledDrawableWithLifetimeContainer`
InternalChildren = new Drawable[]
{
CursorPath = new CursorPathContainer(),
ClickMarkers = new ClickMarkerContainer(),
FrameMarkers = new FrameMarkerContainer(),
};
bool leftHeld = false;
bool rightHeld = false;
@ -74,7 +104,7 @@ namespace osu.Game.Rulesets.Osu.UI
else if (!leftHeld && leftButton)
{
leftHeld = true;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.LeftButton));
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, OsuAction.LeftButton));
}
if (rightHeld && !rightButton)
@ -82,11 +112,11 @@ namespace osu.Game.Rulesets.Osu.UI
else if (!rightHeld && rightButton)
{
rightHeld = true;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, OsuAction.RightButton));
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, OsuAction.RightButton));
}
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position, osuFrame.Actions.ToArray()));
CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, osuFrame.Position));
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, osuFrame.Actions.ToArray()));
CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position));
}
}
}

View File

@ -25,6 +25,15 @@ namespace osu.Game.Rulesets.Osu.UI
[SettingSource("Hide gameplay cursor", SettingControlType = typeof(PlayerCheckbox))]
public BindableBool HideSkinCursor { get; } = new BindableBool();
[SettingSource("Display length", SettingControlType = typeof(PlayerSliderBar<int>))]
public BindableInt DisplayLength { get; } = new BindableInt
{
MinValue = 100,
Default = 800,
MaxValue = 2000,
Precision = 100,
};
public ReplayAnalysisSettings(OsuRulesetConfigManager config)
: base("Analysis Settings")
{
@ -40,6 +49,7 @@ namespace osu.Game.Rulesets.Osu.UI
config.BindWith(OsuRulesetSetting.ReplayFrameMarkersEnabled, ShowAimMarkers);
config.BindWith(OsuRulesetSetting.ReplayCursorPathEnabled, ShowCursorPath);
config.BindWith(OsuRulesetSetting.ReplayCursorHideEnabled, HideSkinCursor);
config.BindWith(OsuRulesetSetting.ReplayAnalysisDisplayLength, DisplayLength);
}
}
}