1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 20:03:21 +08:00

Make IOsuScreen.AllowTrackAdjustments nullable

Allows for inheriting value from the previous screen if undefined
This commit is contained in:
AbstractQbit 2021-09-14 17:37:57 +03:00
parent 52b1539dea
commit b9193aae6d
13 changed files with 42 additions and 12 deletions

View File

@ -1075,8 +1075,6 @@ namespace osu.Game
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
API.Activity.BindTo(newOsuScreen.Activity);
MusicController.AllowTrackAdjustments = newOsuScreen.AllowTrackAdjustments;
if (newOsuScreen.HideOverlaysOnEnter)
CloseAllOverlays();
else
@ -1093,6 +1091,24 @@ namespace osu.Game
{
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)
{
allowTrackAdjustmentsStack.Push(newOsuScreen.AllowTrackAdjustments.Value);
Logger.Log($"Screen's AllowTrackAdjustments explicit → {allowTrackAdjustmentsStack.First()}");
}
else if (allowTrackAdjustmentsStack.Any())
{
allowTrackAdjustmentsStack.Push(allowTrackAdjustmentsStack.First());
Logger.Log($"Screen's AllowTrackAdjustments inherit → {allowTrackAdjustmentsStack.First()}");
}
else
{
allowTrackAdjustmentsStack.Push(false);
}
MusicController.AllowTrackAdjustments = allowTrackAdjustmentsStack.First();
}
private void screenExited(IScreen lastScreen, IScreen newScreen)
@ -1102,8 +1118,17 @@ namespace osu.Game
if (newScreen == null)
Exit();
if (allowTrackAdjustmentsStack.Count > 1)
{
allowTrackAdjustmentsStack.Pop();
MusicController.AllowTrackAdjustments = allowTrackAdjustmentsStack.First();
Logger.Log($"Screen's AllowTrackAdjustments return ← {allowTrackAdjustmentsStack.First()}");
}
}
private Stack<bool> allowTrackAdjustmentsStack = new Stack<bool>();
IBindable<bool> ILocalUserPlayInfo.IsPlaying => LocalUserPlaying;
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private OsuDirectorySelector directorySelector;
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
/// <summary>
/// Text to display in the header to inform the user of what they are selecting.

View File

@ -56,7 +56,7 @@ namespace osu.Game.Screens.Edit
public override bool DisallowExternalBeatmapRulesetChanges => true;
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
protected bool HasUnsavedChanges => lastSavedHash != changeHandler.CurrentStateHash;

View File

@ -60,8 +60,9 @@ namespace osu.Game.Screens
/// <summary>
/// Whether mod track adjustments are allowed to be applied.
/// Null means to inherit from the parent screen.
/// </summary>
bool AllowTrackAdjustments { get; }
bool? AllowTrackAdjustments { get; }
/// <summary>
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Import
{
public override bool HideOverlaysOnEnter => true;
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
private OsuFileSelector fileSelector;
private Container contentContainer;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Screens.Menu
public override bool AllowExternalScreenChange => true;
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
private Screen songSelect;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
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

@ -24,7 +24,7 @@ namespace osu.Game.Screens.OnlinePlay
[Cached]
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;

View File

@ -11,6 +11,8 @@ namespace osu.Game.Screens.OnlinePlay
{
public override bool DisallowExternalBeatmapRulesetChanges => false;
public override bool? AllowTrackAdjustments => true;
public virtual string ShortTitle => Title;
[Resolved(CanBeNull = true)]

View File

@ -81,7 +81,7 @@ namespace osu.Game.Screens
public virtual float BackgroundParallaxAmount => 1;
public virtual bool AllowTrackAdjustments => true;
public virtual bool? AllowTrackAdjustments => null;
public Bindable<WorkingBeatmap> Beatmap { get; private set; }

View File

@ -56,7 +56,7 @@ namespace osu.Game.Screens.Play
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

@ -10,6 +10,8 @@ namespace osu.Game.Screens.Play
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
public override bool? AllowTrackAdjustments => true;
public void ApplyToBackground(Action<BackgroundScreenBeatmap> action) => base.ApplyToBackground(b => action.Invoke((BackgroundScreenBeatmap)b));
}
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens
public override bool CursorVisible => false;
public override bool AllowTrackAdjustments => false;
public override bool? AllowTrackAdjustments => false;
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
}