mirror of https://github.com/ppy/osu
Move the inherited `AllowTrackAdjustments` into `OsuScreen`
This commit is contained in:
parent
bd18c581c1
commit
b87af3dd68
|
@ -1075,6 +1075,11 @@ 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;
|
||||
|
||||
if (newOsuScreen.HideOverlaysOnEnter)
|
||||
CloseAllOverlays();
|
||||
else
|
||||
|
@ -1091,16 +1096,6 @@ private void screenPushed(IScreen lastScreen, IScreen newScreen)
|
|||
{
|
||||
ScreenChanged(lastScreen, newScreen);
|
||||
Logger.Log($"Screen changed → {newScreen}");
|
||||
|
||||
// set AllowTrackAdjustments if new screen defines it, inherit otherwise
|
||||
if (newScreen is IOsuScreen newOsuScreen && newOsuScreen.AllowTrackAdjustments.HasValue)
|
||||
allowTrackAdjustmentsDict[newScreen] = newOsuScreen.AllowTrackAdjustments.Value;
|
||||
else if (allowTrackAdjustmentsDict.ContainsKey(lastScreen))
|
||||
allowTrackAdjustmentsDict[newScreen] = allowTrackAdjustmentsDict[lastScreen];
|
||||
else
|
||||
allowTrackAdjustmentsDict[newScreen] = true;
|
||||
|
||||
MusicController.AllowTrackAdjustments = allowTrackAdjustmentsDict[newScreen];
|
||||
}
|
||||
|
||||
private void screenExited(IScreen lastScreen, IScreen newScreen)
|
||||
|
@ -1108,16 +1103,10 @@ private void screenExited(IScreen lastScreen, IScreen newScreen)
|
|||
ScreenChanged(lastScreen, newScreen);
|
||||
Logger.Log($"Screen changed ← {newScreen}");
|
||||
|
||||
allowTrackAdjustmentsDict.Remove(lastScreen);
|
||||
|
||||
if (newScreen == null)
|
||||
Exit();
|
||||
else
|
||||
MusicController.AllowTrackAdjustments = allowTrackAdjustmentsDict[newScreen];
|
||||
}
|
||||
|
||||
private readonly Dictionary<IScreen, bool> allowTrackAdjustmentsDict = new Dictionary<IScreen, bool>();
|
||||
|
||||
IBindable<bool> ILocalUserPlayInfo.IsPlaying => LocalUserPlaying;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public interface IOsuScreen : IScreen
|
|||
/// Whether mod track adjustments are allowed to be applied.
|
||||
/// Null means to inherit from the parent screen.
|
||||
/// </summary>
|
||||
bool? AllowTrackAdjustments { get; }
|
||||
bool? AllowTrackAdjustments { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.
|
||||
|
|
|
@ -81,7 +81,13 @@ public abstract class OsuScreen : Screen, IOsuScreen, IHasDescription
|
|||
|
||||
public virtual float BackgroundParallaxAmount => 1;
|
||||
|
||||
public virtual bool? AllowTrackAdjustments => null;
|
||||
private bool? allowTrackAdjustments = null;
|
||||
|
||||
public virtual bool? AllowTrackAdjustments
|
||||
{
|
||||
set => allowTrackAdjustments = value;
|
||||
get => allowTrackAdjustments;
|
||||
}
|
||||
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue