1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 23:47:21 +08:00

Only enable button if there are different filenames

This commit is contained in:
Salman Alshamrani 2024-11-24 01:11:28 -05:00
parent a872f74974
commit 95a6226413

View File

@ -40,7 +40,7 @@ namespace osu.Game.Screens.Edit.Setup
private Editor? editor { get; set; } private Editor? editor { get; set; }
private SetupScreenHeaderBackground headerBackground = null!; private SetupScreenHeaderBackground headerBackground = null!;
private RoundedButton updateAllDifficultiesButton = null!; private RoundedButton syncResourcesButton = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -63,11 +63,11 @@ namespace osu.Game.Screens.Edit.Setup
Caption = EditorSetupStrings.AudioTrack, Caption = EditorSetupStrings.AudioTrack,
PlaceholderText = EditorSetupStrings.ClickToSelectTrack, PlaceholderText = EditorSetupStrings.ClickToSelectTrack,
}, },
updateAllDifficultiesButton = new RoundedButton syncResourcesButton = new RoundedButton
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = EditorSetupStrings.ResourcesUpdateAllDifficulties, Text = EditorSetupStrings.ResourcesUpdateAllDifficulties,
Action = updateAllDifficulties, Action = syncResources,
Enabled = { Value = false }, Enabled = { Value = false },
} }
}; };
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Edit.Setup
beatmaps.AddFile(set, stream, newFilename); beatmaps.AddFile(set, stream, newFilename);
working.Value.Metadata.BackgroundFile = newBackgroundFile = newFilename; working.Value.Metadata.BackgroundFile = newBackgroundFile = newFilename;
updateAllDifficultiesButton.Enabled.Value = set.Beatmaps.Count > 1; syncResourcesButton.Enabled.Value = set.Beatmaps.Count > 1;
editorBeatmap.SaveState(); editorBeatmap.SaveState();
@ -155,7 +155,7 @@ namespace osu.Game.Screens.Edit.Setup
beatmaps.AddFile(set, stream, newFilename); beatmaps.AddFile(set, stream, newFilename);
working.Value.Metadata.AudioFile = newAudioFile = newFilename; working.Value.Metadata.AudioFile = newAudioFile = newFilename;
updateAllDifficultiesButton.Enabled.Value = set.Beatmaps.Count > 1; updateSyncResourcesButton();
editorBeatmap.SaveState(); editorBeatmap.SaveState();
music.ReloadCurrentTrack(); music.ReloadCurrentTrack();
@ -163,7 +163,16 @@ namespace osu.Game.Screens.Edit.Setup
return true; return true;
} }
private void updateAllDifficulties() private void updateSyncResourcesButton()
{
var set = working.Value.BeatmapSetInfo;
syncResourcesButton.Enabled.Value =
(newBackgroundFile != null && set.Beatmaps.DistinctBy(b => b.Metadata.BackgroundFile, StringComparer.OrdinalIgnoreCase).Count() > 1) ||
(newAudioFile != null && set.Beatmaps.DistinctBy(b => b.Metadata.AudioFile, StringComparer.OrdinalIgnoreCase).Count() > 1);
}
private void syncResources()
{ {
var beatmap = working.Value.BeatmapInfo; var beatmap = working.Value.BeatmapInfo;
var set = working.Value.BeatmapSetInfo; var set = working.Value.BeatmapSetInfo;
@ -192,7 +201,7 @@ namespace osu.Game.Screens.Edit.Setup
} }
editorBeatmap.SaveState(); editorBeatmap.SaveState();
updateAllDifficultiesButton.Enabled.Value = false; syncResourcesButton.Enabled.Value = false;
} }
private void backgroundChanged(ValueChangedEvent<FileInfo?> file) private void backgroundChanged(ValueChangedEvent<FileInfo?> file)