1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Merge pull request #29428 from peppy/update-editor-menu-items-difficulty-change

Ensure the "Change Difficulty" menu uses up-to-date difficulty names
This commit is contained in:
Dan Balasescu 2024-08-16 00:44:59 +09:00 committed by GitHub
commit 52c1858bbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1286,10 +1286,23 @@ namespace osu.Game.Screens.Edit
foreach (var beatmap in rulesetBeatmaps)
{
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmap);
difficultyItems.Add(new DifficultyMenuItem(beatmap, isCurrentDifficulty, SwitchToDifficulty));
var difficultyMenuItem = new DifficultyMenuItem(beatmap, isCurrentDifficulty, SwitchToDifficulty);
difficultyItems.Add(difficultyMenuItem);
}
}
// Ensure difficulty names are updated when modified in the editor.
// Maybe we could trigger less often but this seems to work well enough.
editorBeatmap.SaveStateTriggered += () =>
{
foreach (var beatmapInfo in Beatmap.Value.BeatmapSetInfo.Beatmaps)
{
var menuItem = difficultyItems.OfType<DifficultyMenuItem>().FirstOrDefault(i => i.BeatmapInfo.Equals(beatmapInfo));
if (menuItem != null)
menuItem.Text.Value = string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? "(unnamed)" : beatmapInfo.DifficultyName;
}
};
return new EditorMenuItem(EditorStrings.ChangeDifficulty) { Items = difficultyItems };
}