1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:33:20 +08:00

Fix footer content not accessible by overlay when overriden by a subclass

This commit is contained in:
Salman Ahmed 2024-07-11 15:31:02 +03:00
parent 7a5624fd0e
commit d4a4a059d4
5 changed files with 26 additions and 20 deletions

View File

@ -45,7 +45,7 @@ namespace osu.Game.Overlays
private ScreenStack? stack; private ScreenStack? stack;
public ShearedButton? NextButton => currentFooterContent?.NextButton; public ShearedButton? NextButton => DisplayedFooterContent?.NextButton;
private readonly Bindable<bool> showFirstRunSetup = new Bindable<bool>(); private readonly Bindable<bool> showFirstRunSetup = new Bindable<bool>();
@ -148,17 +148,17 @@ namespace osu.Game.Overlays
[Resolved] [Resolved]
private ScreenFooter footer { get; set; } = null!; private ScreenFooter footer { get; set; } = null!;
private FirstRunSetupFooterContent? currentFooterContent; public new FirstRunSetupFooterContent? DisplayedFooterContent => base.DisplayedFooterContent as FirstRunSetupFooterContent;
public override VisibilityContainer CreateFooterContent() public override VisibilityContainer CreateFooterContent()
{ {
currentFooterContent = new FirstRunSetupFooterContent var footerContent = new FirstRunSetupFooterContent
{ {
ShowNextStep = showNextStep, ShowNextStep = showNextStep,
}; };
currentFooterContent.OnLoadComplete += _ => updateButtons(); footerContent.OnLoadComplete += _ => updateButtons();
return currentFooterContent; return footerContent;
} }
public override bool OnBackButton() public override bool OnBackButton()
@ -182,7 +182,7 @@ namespace osu.Game.Overlays
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Select: case GlobalAction.Select:
currentFooterContent?.NextButton.TriggerClick(); DisplayedFooterContent?.NextButton.TriggerClick();
return true; return true;
case GlobalAction.Back: case GlobalAction.Back:
@ -287,9 +287,9 @@ namespace osu.Game.Overlays
updateButtons(); updateButtons();
} }
private void updateButtons() => currentFooterContent?.UpdateButtons(currentStepIndex, steps); private void updateButtons() => DisplayedFooterContent?.UpdateButtons(currentStepIndex, steps);
private partial class FirstRunSetupFooterContent : VisibilityContainer public partial class FirstRunSetupFooterContent : VisibilityContainer
{ {
public ShearedButton NextButton { get; private set; } = null!; public ShearedButton NextButton { get; private set; } = null!;

View File

@ -254,9 +254,9 @@ namespace osu.Game.Overlays.Mods
}); });
} }
private ModSelectFooterContent? currentFooterContent; public new ModSelectFooterContent? DisplayedFooterContent => base.DisplayedFooterContent as ModSelectFooterContent;
public override VisibilityContainer CreateFooterContent() => currentFooterContent = new ModSelectFooterContent(this) public override VisibilityContainer CreateFooterContent() => new ModSelectFooterContent(this)
{ {
Beatmap = { BindTarget = Beatmap }, Beatmap = { BindTarget = Beatmap },
ActiveMods = { BindTarget = ActiveMods }, ActiveMods = { BindTarget = ActiveMods },
@ -270,7 +270,7 @@ namespace osu.Game.Overlays.Mods
base.Update(); base.Update();
SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? input_search_placeholder : tab_to_search_placeholder; SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? input_search_placeholder : tab_to_search_placeholder;
aboveColumnsContent.Padding = aboveColumnsContent.Padding with { Bottom = currentFooterContent?.DisplaysStackedVertically == true ? 75f : 15f }; aboveColumnsContent.Padding = aboveColumnsContent.Padding with { Bottom = DisplayedFooterContent?.DisplaysStackedVertically == true ? 75f : 15f };
} }
/// <summary> /// <summary>
@ -573,7 +573,7 @@ namespace osu.Game.Overlays.Mods
{ {
if (!SearchTextBox.HasFocus && !customisationPanel.Expanded.Value) if (!SearchTextBox.HasFocus && !customisationPanel.Expanded.Value)
{ {
currentFooterContent?.DeselectAllModsButton?.TriggerClick(); DisplayedFooterContent?.DeselectAllModsButton?.TriggerClick();
return true; return true;
} }

View File

@ -102,6 +102,8 @@ namespace osu.Game.Overlays.Mods
}; };
} }
public VisibilityContainer? DisplayedFooterContent { get; private set; }
/// <summary> /// <summary>
/// Creates content to be displayed on the game-wide footer. /// Creates content to be displayed on the game-wide footer.
/// </summary> /// </summary>
@ -137,7 +139,8 @@ namespace osu.Game.Overlays.Mods
if (footer != null) if (footer != null)
{ {
activeOverlayRegistration = footer.RegisterActiveOverlayContainer(this); activeOverlayRegistration = footer.RegisterActiveOverlayContainer(this, out var footerContent);
DisplayedFooterContent = footerContent;
if (footer.State.Value == Visibility.Hidden) if (footer.State.Value == Visibility.Hidden)
{ {
@ -160,6 +163,7 @@ namespace osu.Game.Overlays.Mods
{ {
activeOverlayRegistration?.Dispose(); activeOverlayRegistration?.Dispose();
activeOverlayRegistration = null; activeOverlayRegistration = null;
DisplayedFooterContent = null;
if (hideFooterOnPopOut) if (hideFooterOnPopOut)
{ {

View File

@ -190,7 +190,7 @@ namespace osu.Game.Screens.Footer
private readonly List<ScreenFooterButton> temporarilyHiddenButtons = new List<ScreenFooterButton>(); private readonly List<ScreenFooterButton> temporarilyHiddenButtons = new List<ScreenFooterButton>();
public IDisposable RegisterActiveOverlayContainer(ShearedOverlayContainer overlay) public IDisposable RegisterActiveOverlayContainer(ShearedOverlayContainer overlay, out VisibilityContainer? footerContent)
{ {
if (activeOverlay != null) if (activeOverlay != null)
{ {
@ -219,7 +219,9 @@ namespace osu.Game.Screens.Footer
updateColourScheme(overlay.ColourProvider.ColourScheme); updateColourScheme(overlay.ColourProvider.ColourScheme);
var content = overlay.CreateFooterContent() ?? Empty(); footerContent = overlay.CreateFooterContent();
var content = footerContent ?? Empty();
Add(contentContainer = new Container Add(contentContainer = new Container
{ {

View File

@ -23,9 +23,7 @@ namespace osu.Game.Screens.OnlinePlay
set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m); set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m);
} }
private FreeModSelectFooterContent? currentFooterContent; protected override SelectAllModsButton? SelectAllModsButton => DisplayedFooterContent?.SelectAllModsButton;
protected override SelectAllModsButton? SelectAllModsButton => currentFooterContent?.SelectAllModsButton;
public FreeModSelectOverlay() public FreeModSelectOverlay()
: base(OverlayColourScheme.Plum) : base(OverlayColourScheme.Plum)
@ -35,13 +33,15 @@ namespace osu.Game.Screens.OnlinePlay
protected override ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, true); protected override ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, true);
public override VisibilityContainer CreateFooterContent() => currentFooterContent = new FreeModSelectFooterContent(this) public new FreeModSelectFooterContent? DisplayedFooterContent => base.DisplayedFooterContent as FreeModSelectFooterContent;
public override VisibilityContainer CreateFooterContent() => new FreeModSelectFooterContent(this)
{ {
Beatmap = { BindTarget = Beatmap }, Beatmap = { BindTarget = Beatmap },
ActiveMods = { BindTarget = ActiveMods }, ActiveMods = { BindTarget = ActiveMods },
}; };
private partial class FreeModSelectFooterContent : ModSelectFooterContent public partial class FreeModSelectFooterContent : ModSelectFooterContent
{ {
private readonly FreeModSelectOverlay overlay; private readonly FreeModSelectOverlay overlay;