1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 09:50:13 +08:00

Allow visibly disabling the "go to beatmap" button

Easiest way to make this work without rewriting the layout logic.

I think it makes sense to have the button still exist there but not be
usable on certain screens.
This commit is contained in:
Dean Herbert
2025-09-26 18:08:47 +09:00
Unverified
parent badeb24d56
commit da80b61f38
2 changed files with 40 additions and 14 deletions
@@ -16,10 +16,12 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
private readonly APIBeatmapSet beatmapSet;
private readonly bool allowNavigationToBeatmap;
public GoToBeatmapButton(APIBeatmapSet beatmapSet)
public GoToBeatmapButton(APIBeatmapSet beatmapSet, bool allowNavigationToBeatmap)
{
this.beatmapSet = beatmapSet;
this.allowNavigationToBeatmap = allowNavigationToBeatmap;
}
[BackgroundDependencyLoader(true)]
@@ -27,7 +29,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
Action = () => game?.PresentBeatmap(beatmapSet);
Icon.Icon = FontAwesome.Solid.AngleDoubleRight;
TooltipText = "Go to beatmap";
}
protected override void LoadComplete()
@@ -40,8 +41,31 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
private void updateState()
{
Enabled.Value = state.Value == DownloadState.LocallyAvailable;
this.FadeTo(Enabled.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
bool available = state.Value == DownloadState.LocallyAvailable;
Enabled.Value = allowNavigationToBeatmap && available;
float alpha;
if (available && allowNavigationToBeatmap)
{
TooltipText = "Go to beatmap";
Enabled.Value = true;
alpha = 1f;
}
else if (available)
{
TooltipText = string.Empty;
Enabled.Value = false;
alpha = 0.3f;
}
else
{
TooltipText = string.Empty;
Enabled.Value = false;
alpha = 0;
}
this.FadeTo(alpha, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
}
}
}
@@ -30,7 +30,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
set
{
buttonsExpandedWidth = value;
buttonArea.Width = value;
if (IsLoaded)
updateState();
}
@@ -67,7 +66,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public CollapsibleButtonContainer(APIBeatmapSet beatmapSet)
public CollapsibleButtonContainer(APIBeatmapSet beatmapSet, bool allowNavigationToBeatmap = true)
{
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
@@ -116,14 +115,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
},
new GoToBeatmapButton(beatmapSet)
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
State = { BindTarget = downloadTracker.State },
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
}
}
}
},
@@ -152,6 +143,15 @@ namespace osu.Game.Beatmaps.Drawables.Cards
}
}
};
buttons.Add(new GoToBeatmapButton(beatmapSet, allowNavigationToBeatmap)
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
State = { BindTarget = downloadTracker.State },
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
});
}
protected override void LoadComplete()
@@ -165,6 +165,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
private void updateState()
{
buttonArea.Width = buttonsExpandedWidth;
float buttonAreaWidth = ShowDetails.Value ? ButtonsExpandedWidth : ButtonsCollapsedWidth;
float mainAreaWidth = Width - buttonAreaWidth;