Move all the "inherit previous `AllowTrackAdjustments`" logic into `OsuScreen`

This commit is contained in:
AbstractQbit 2021-09-15 21:25:39 +03:00
parent 931e873a7e
commit 318f0941ca
8 changed files with 13 additions and 11 deletions

View File

@ -1075,10 +1075,7 @@ protected virtual void ScreenChanged(IScreen current, IScreen newScreen)
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
API.Activity.BindTo(newOsuScreen.Activity);
if (newOsuScreen.AllowTrackAdjustments.HasValue)
MusicController.AllowTrackAdjustments = newOsuScreen.AllowTrackAdjustments.Value;
else
newOsuScreen.AllowTrackAdjustments = MusicController.AllowTrackAdjustments;
MusicController.AllowTrackAdjustments = newOsuScreen.AllowTrackAdjustments;
if (newOsuScreen.HideOverlaysOnEnter)
CloseAllOverlays();

View File

@ -56,7 +56,7 @@ public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalActi
public override bool DisallowExternalBeatmapRulesetChanges => true;
public override bool? AllowTrackAdjustments => false;
public override bool AllowTrackAdjustments => false;
protected bool HasUnsavedChanges => lastSavedHash != changeHandler.CurrentStateHash;

View File

@ -62,7 +62,7 @@ public interface IOsuScreen : IScreen
/// Whether mod track adjustments are allowed to be applied.
/// A <see langword="null"/> value means that the parent screen's value of this setting will be used.
/// </summary>
bool? AllowTrackAdjustments { get; set; }
bool AllowTrackAdjustments { get; }
/// <summary>
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.

View File

@ -26,7 +26,7 @@ public class MultiSpectatorScreen : SpectatorScreen
public override bool DisallowExternalBeatmapRulesetChanges => true;
// We are managing our own adjustments. For now, this happens inside the Player instances themselves.
public override bool? AllowTrackAdjustments => false;
public override bool AllowTrackAdjustments => false;
/// <summary>
/// Whether all spectating players have finished loading.

View File

@ -11,7 +11,7 @@ public abstract class OnlinePlaySubScreen : OsuScreen, IOnlinePlaySubScreen
{
public override bool DisallowExternalBeatmapRulesetChanges => false;
public override bool? AllowTrackAdjustments => true;
public override bool AllowTrackAdjustments => true;
public virtual string ShortTitle => Title;

View File

@ -81,7 +81,12 @@ public abstract class OsuScreen : Screen, IOsuScreen, IHasDescription
public virtual float BackgroundParallaxAmount => 1;
public virtual bool? AllowTrackAdjustments { get; set; }
[Resolved]
private MusicController musicController { get; set; }
private bool? allowTrackAdjustments;
public virtual bool AllowTrackAdjustments => allowTrackAdjustments ??= (musicController?.AllowTrackAdjustments ?? false);
public Bindable<WorkingBeatmap> Beatmap { get; private set; }

View File

@ -56,7 +56,7 @@ public abstract class Player : ScreenWithBeatmapBackground, ISamplePlaybackDisab
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
// We are managing our own adjustments (see OnEntering/OnExiting).
public override bool? AllowTrackAdjustments => false;
public override bool AllowTrackAdjustments => false;
private readonly IBindable<bool> gameActive = new Bindable<bool>(true);

View File

@ -53,7 +53,7 @@ public abstract class SongSelect : ScreenWithBeatmapBackground, IKeyBindingHandl
protected virtual bool DisplayStableImportPrompt => stableImportManager?.SupportsImportFromStable == true;
public override bool? AllowTrackAdjustments => true;
public override bool AllowTrackAdjustments => true;
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.