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

disable certain options when no beatmap is selected

This commit is contained in:
nanashi-1 2022-11-15 20:55:55 +08:00
parent 7b9ed6a4b2
commit e8d170e772
2 changed files with 30 additions and 4 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select.Options;
using osu.Game.Users;
using osu.Game.Utils;
using osuTK.Input;
@ -33,10 +34,12 @@ namespace osu.Game.Screens.Select
private PlayBeatmapDetailArea playBeatmapDetailArea = null!;
protected BeatmapOptionsButton? editOptionButton;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit());
editOptionButton = BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit());
}
protected void PresentScore(ScoreInfo score) =>
@ -142,5 +145,12 @@ namespace osu.Game.Screens.Select
playerLoader = null;
}
}
protected override void OnBeatmapOptionsButtonDisabledChanged(bool disabled)
{
base.OnBeatmapOptionsButtonDisabledChanged(disabled);
if (editOptionButton != null) editOptionButton.Disabled = disabled;
}
}
}

View File

@ -116,6 +116,10 @@ namespace osu.Game.Screens.Select
private double audioFeedbackLastPlaybackTime;
protected BeatmapOptionsButton deleteOptionButton;
protected BeatmapOptionsButton clearOptionButton;
[CanBeNull]
private IDisposable modSelectOverlayRegistration;
@ -285,9 +289,9 @@ namespace osu.Game.Screens.Select
Footer.AddButton(button, overlay);
BeatmapOptions.AddButton(@"Manage", @"collections", FontAwesome.Solid.Book, colours.Green, () => manageCollectionsDialog?.Show());
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo));
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo));
deleteOptionButton = BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo));
clearOptionButton = BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo));
}
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
@ -412,7 +416,13 @@ namespace osu.Game.Screens.Select
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap> e = null)
{
var beatmap = e?.NewValue ?? Beatmap.Value;
if (beatmap is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
if (beatmap is DummyWorkingBeatmap || !this.IsCurrentScreen())
{
OnBeatmapOptionsButtonDisabledChanged(true);
return;
}
OnBeatmapOptionsButtonDisabledChanged(false);
Logger.Log($"Song select working beatmap updated to {beatmap}");
@ -647,6 +657,12 @@ namespace osu.Game.Screens.Select
return false;
}
protected virtual void OnBeatmapOptionsButtonDisabledChanged(bool disabled)
{
deleteOptionButton.Disabled = disabled;
clearOptionButton.Disabled = disabled;
}
private void playExitingTransition()
{
ModSelect.Hide();