public SingerContextMenu(LyricManager manager, List <Lyric> lyrics, string name) : base(name) { Items = manager.Singers?.Select(singer => new OsuMenuItem(singer.Name, anySingerInLyric(singer) ? MenuItemType.Highlighted : MenuItemType.Standard, () => { // if only one lyric if (allSingerInLyric(singer)) { lyrics.ForEach(lyric => manager.RemoveSingerToLyric(singer, lyric)); } else { lyrics.ForEach(lyric => manager.AddSingerToLyric(singer, lyric)); } })).ToList(); bool anySingerInLyric(Singer singer) => lyrics.Any(lyric => manager.SingerInLyric(singer, lyric)); bool allSingerInLyric(Singer singer) => lyrics.All(lyric => manager.SingerInLyric(singer, lyric)); }
private void load(LyricManager lyricManager, SingerLyricEditor editor) { Item.SingersBindable.BindValueChanged(e => { // Check is lyric contains this singer, or default singer isSingerMatched = lyricManager.SingerInLyric(editor.Singer, Item); if (isSingerMatched) { Show(); } else { this.FadeTo(0.1f, 200); } }, true); }
private void load(LyricManager lyricManager) { if (HitObject is Lyric lyric) { lyric.SingersBindable.BindValueChanged(e => { // Check is lyric contains this singer, or default singer var isSingerMatch = lyricManager.SingerInLyric(singer, lyric); if (isSingerMatch) { Show(); } else { Hide(); } }, true); } }