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

Fix settings not working if ReplayPlayer is not available

This commit is contained in:
Dean Herbert 2024-09-04 19:09:23 +09:00
parent cc3d220f6f
commit 9b81deb3ac
No known key found for this signature in database
2 changed files with 17 additions and 17 deletions

View File

@ -103,6 +103,8 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
} }
public new ReplayAnalysisSettings Settings => base.Settings;
public bool HitMarkersVisible => HitMarkers.Alpha > 0 && HitMarkers.Entries.Any(); public bool HitMarkersVisible => HitMarkers.Alpha > 0 && HitMarkers.Entries.Any();
public bool AimMarkersVisible => AimMarkers.Alpha > 0 && AimMarkers.Entries.Any(); public bool AimMarkersVisible => AimMarkers.Alpha > 0 && AimMarkers.Entries.Any();
public bool AimLinesVisible => AimLines.Alpha > 0 && AimLines.Vertices.Count > 1; public bool AimLinesVisible => AimLines.Alpha > 0 && AimLines.Vertices.Count > 1;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.UI
protected readonly AimMarkersContainer AimMarkers; protected readonly AimMarkersContainer AimMarkers;
protected readonly AimLinesContainer AimLines; protected readonly AimLinesContainer AimLines;
public ReplayAnalysisSettings Settings = null!; protected ReplayAnalysisSettings Settings = null!;
private readonly Replay replay; private readonly Replay replay;
private readonly DrawableRuleset drawableRuleset; private readonly DrawableRuleset drawableRuleset;
@ -45,32 +45,30 @@ namespace osu.Game.Rulesets.Osu.UI
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ReplayPlayer replayPlayer) private void load(ReplayPlayer? replayPlayer)
{ {
replayPlayer.AddSettings(Settings = new ReplayAnalysisSettings()); Settings = new ReplayAnalysisSettings();
LoadReplay(); if (replayPlayer != null)
replayPlayer.AddSettings(Settings);
else
// only in test
AddInternal(Settings);
loadReplay();
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Settings.HitMarkersEnabled.BindValueChanged(e => toggleHitMarkers(e.NewValue), true); Settings.HitMarkersEnabled.BindValueChanged(enabled => HitMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
Settings.AimMarkersEnabled.BindValueChanged(e => toggleAimMarkers(e.NewValue), true); Settings.AimMarkersEnabled.BindValueChanged(enabled => AimMarkers.FadeTo(enabled.NewValue ? 1 : 0), true);
Settings.AimLinesEnabled.BindValueChanged(e => toggleAimLines(e.NewValue), true); Settings.AimLinesEnabled.BindValueChanged(enabled => AimLines.FadeTo(enabled.NewValue ? 1 : 0), true);
Settings.CursorHideEnabled.BindValueChanged(e => toggleCursorHidden(e.NewValue), true); Settings.CursorHideEnabled.BindValueChanged(enabled => drawableRuleset.Playfield.Cursor.FadeTo(enabled.NewValue ? 0 : 1), true);
} }
private void toggleHitMarkers(bool value) => HitMarkers.FadeTo(value ? 1 : 0); private void loadReplay()
private void toggleAimMarkers(bool value) => AimMarkers.FadeTo(value ? 1 : 0);
private void toggleAimLines(bool value) => AimLines.FadeTo(value ? 1 : 0);
private void toggleCursorHidden(bool value) => drawableRuleset.Playfield.Cursor.FadeTo(value ? 0 : 1);
protected void LoadReplay()
{ {
bool leftHeld = false; bool leftHeld = false;
bool rightHeld = false; bool rightHeld = false;