mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 19:27:31 +08:00
Extract method for difficulty switch menu creation
This commit is contained in:
parent
3a5099cf06
commit
e2fcdc394b
@ -806,6 +806,15 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
fileMenuItems.Add(new EditorMenuItemSpacer());
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
||||||
|
|
||||||
|
fileMenuItems.Add(createDifficultySwitchMenu());
|
||||||
|
|
||||||
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
||||||
|
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
|
||||||
|
return fileMenuItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EditorMenuItem createDifficultySwitchMenu()
|
||||||
|
{
|
||||||
var beatmapSet = playableBeatmap.BeatmapInfo.BeatmapSet;
|
var beatmapSet = playableBeatmap.BeatmapInfo.BeatmapSet;
|
||||||
|
|
||||||
Debug.Assert(beatmapSet != null);
|
Debug.Assert(beatmapSet != null);
|
||||||
@ -818,20 +827,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
difficultyItems.Add(new EditorMenuItemSpacer());
|
difficultyItems.Add(new EditorMenuItemSpacer());
|
||||||
|
|
||||||
foreach (var beatmap in rulesetBeatmaps.OrderBy(b => b.StarRating))
|
foreach (var beatmap in rulesetBeatmaps.OrderBy(b => b.StarRating))
|
||||||
difficultyItems.Add(createDifficultyMenuItem(beatmap));
|
{
|
||||||
|
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmap);
|
||||||
|
difficultyItems.Add(new DifficultyMenuItem(beatmap, isCurrentDifficulty, SwitchToDifficulty));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileMenuItems.Add(new EditorMenuItem("Change difficulty") { Items = difficultyItems });
|
return new EditorMenuItem("Change difficulty") { Items = difficultyItems };
|
||||||
|
|
||||||
fileMenuItems.Add(new EditorMenuItemSpacer());
|
|
||||||
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
|
|
||||||
return fileMenuItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DifficultyMenuItem createDifficultyMenuItem(BeatmapInfo beatmapInfo)
|
|
||||||
{
|
|
||||||
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmapInfo);
|
|
||||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, GetState(nextBeatmap));
|
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, GetState(nextBeatmap));
|
||||||
|
Loading…
Reference in New Issue
Block a user