Skip to content

Commit

Permalink
Merge pull request #29428 from peppy/update-editor-menu-items-difficu…
Browse files Browse the repository at this point in the history
…lty-change

Ensure the "Change Difficulty" menu uses up-to-date difficulty names
  • Loading branch information
smoogipoo authored Aug 15, 2024
2 parents 5710f0f + b5f6158 commit 52c1858
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,23 @@ private EditorMenuItem createDifficultySwitchMenu()
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 };
}

Expand Down

0 comments on commit 52c1858

Please sign in to comment.