From 821a85ab17bcdb5a760c758292b02aace51a5e33 Mon Sep 17 00:00:00 2001 From: Gary Kertopermono Date: Sun, 5 Apr 2020 18:03:27 +0200 Subject: [PATCH] Made it easier to check for golden and rap notes --- VocaluxeLib/Menu/SingNotes/CNoteBars.cs | 11 ++++++----- VocaluxeLib/Songs/CBaseNote.cs | 14 ++++++++++++++ VocaluxeLib/Songs/CSongNote.cs | 9 +++++++++ VocaluxeLib/Songs/CSungNote.cs | 6 ++++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/VocaluxeLib/Menu/SingNotes/CNoteBars.cs b/VocaluxeLib/Menu/SingNotes/CNoteBars.cs index 023cab92..d8ee4c06 100644 --- a/VocaluxeLib/Menu/SingNotes/CNoteBars.cs +++ b/VocaluxeLib/Menu/SingNotes/CNoteBars.cs @@ -84,8 +84,8 @@ namespace VocaluxeLib.Menu.SingNotes _Flares.Clear(); _PerfectNoteEffect.Clear(); - foreach (CSongNote note in _Lines[_CurrentLine].Notes.Where(note => (note.Type == ENoteType.Golden || note.Type == ENoteType.RapGolden))) - _AddGoldenNote(_GetNoteRect(note, note.Type == ENoteType.Rap || note.Type == ENoteType.RapGolden)); + foreach (CSongNote note in _Lines[_CurrentLine].Notes.Where(note => (note.IsGoldenNote))) + _AddGoldenNote(_GetNoteRect(note)); } public void Draw() @@ -107,7 +107,7 @@ namespace VocaluxeLib.Menu.SingNotes { if (note.Type != ENoteType.Freestyle) { - SRectF rect = _GetNoteRect(note, note.Type == ENoteType.Rap || note.Type == ENoteType.RapGolden); + SRectF rect = _GetNoteRect(note); _DrawNoteBG(rect, color); _DrawNoteBase(rect, new SColorF(_NoteBaseColor, _NoteBaseColor.A * Alpha), 1f); @@ -130,7 +130,7 @@ namespace VocaluxeLib.Menu.SingNotes _DrawNoteFill(rect, color, factor); - if (note.EndBeat >= CBase.Game.GetRecordedBeat() && note.Hit && (note.HitNote.Type == ENoteType.Golden || note.HitNote.Type == ENoteType.RapGolden)) + if (note.EndBeat >= CBase.Game.GetRecordedBeat() && note.Hit && note.IsGoldenNote) { SRectF re = rect; re.W = (CBase.Game.GetMidRecordedBeat() - note.StartBeat) / beats * Rect.W; @@ -171,10 +171,11 @@ namespace VocaluxeLib.Menu.SingNotes perfnote.Draw(); } - private SRectF _GetNoteRect(CBaseNote note, bool isRapNote = false) + private SRectF _GetNoteRect(CBaseNote note) { CSongLine line = _Lines[_CurrentLine]; float beats = line.LastNoteBeat - line.FirstNoteBeat + 1; + bool isRapNote = note.IsRapNote; float width = note.Duration * Rect.W / beats; float y = Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - line.BaseLine) / 2f) * _NoteLineHeight - _AddNoteHeight / 2; diff --git a/VocaluxeLib/Songs/CBaseNote.cs b/VocaluxeLib/Songs/CBaseNote.cs index 271283c3..d28750c2 100644 --- a/VocaluxeLib/Songs/CBaseNote.cs +++ b/VocaluxeLib/Songs/CBaseNote.cs @@ -82,6 +82,20 @@ namespace VocaluxeLib.Songs } public abstract int PointsForBeat { get; } + + public bool IsRapNote + { + get { return IsNoteType(ENoteType.Rap, ENoteType.RapGolden); } + } + + public bool IsGoldenNote + { + get { return IsNoteType(ENoteType.Golden, ENoteType.RapGolden); } + } #endregion Properties + + #region Methods + public abstract bool IsNoteType(params ENoteType[] noteTypes); + #endregion Methods } } \ No newline at end of file diff --git a/VocaluxeLib/Songs/CSongNote.cs b/VocaluxeLib/Songs/CSongNote.cs index f0ce3d73..1a96b8e7 100644 --- a/VocaluxeLib/Songs/CSongNote.cs +++ b/VocaluxeLib/Songs/CSongNote.cs @@ -15,6 +15,8 @@ // along with Vocaluxe. If not, see . #endregion +using System.Linq; + namespace VocaluxeLib.Songs { /// @@ -37,6 +39,13 @@ namespace VocaluxeLib.Songs } #endregion Constructors + #region Methods + public override bool IsNoteType(params ENoteType[] noteTypes) + { + return noteTypes.Contains(Type); + } + #endregion Method + #region Properties public ENoteType Type { get; set; } diff --git a/VocaluxeLib/Songs/CSungNote.cs b/VocaluxeLib/Songs/CSungNote.cs index 3fd3b9a1..d010722c 100644 --- a/VocaluxeLib/Songs/CSungNote.cs +++ b/VocaluxeLib/Songs/CSungNote.cs @@ -15,6 +15,8 @@ // along with Vocaluxe. If not, see . #endregion +using System.Linq; + namespace VocaluxeLib.Songs { /// @@ -74,6 +76,10 @@ namespace VocaluxeLib.Songs Perfect = result; } + public override bool IsNoteType(params ENoteType[] noteTypes) + { + return HitNote != null && noteTypes.Contains(HitNote.Type); + } #endregion Methods public override int PointsForBeat