From a711cac81f846f4e0b1a4d274fe0aa5e132bd3e9 Mon Sep 17 00:00:00 2001 From: A6sT Date: Sun, 19 Jul 2026 19:26:29 +0200 Subject: [PATCH] Add bookmark color support --- Quaver.API/Maps/Structures/BookmarkInfo.cs | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Quaver.API/Maps/Structures/BookmarkInfo.cs b/Quaver.API/Maps/Structures/BookmarkInfo.cs index 6cf0bb97b..a14d93059 100644 --- a/Quaver.API/Maps/Structures/BookmarkInfo.cs +++ b/Quaver.API/Maps/Structures/BookmarkInfo.cs @@ -7,8 +7,10 @@ using System; using System.Collections.Generic; +using System.Drawing; using MoonSharp.Interpreter; using MoonSharp.Interpreter.Interop; +using Quaver.API.Helpers; namespace Quaver.API.Maps.Structures { @@ -16,6 +18,8 @@ namespace Quaver.API.Maps.Structures [Serializable] public class BookmarkInfo : IStartTime { + public const string DefaultColorRgb = "255,255,0"; + public int StartTime { get; @@ -30,6 +34,22 @@ public string Note set; } + public string ColorRgb + { + get; + [MoonSharpVisible(false)] + set; + } = DefaultColorRgb; + + [MoonSharpVisible(false)] + public Color GetColor() => + new Drain(ColorRgb, ',') is var (tr, (tg, (tb, _))) && + byte.TryParse(tr, out var r) && + byte.TryParse(tg, out var g) && + byte.TryParse(tb, out var b) + ? Color.FromArgb(r, g, b) + : Color.Yellow; + float IStartTime.StartTime { get => StartTime; @@ -45,10 +65,10 @@ public bool Equals(BookmarkInfo x, BookmarkInfo y) if (ReferenceEquals(y, null)) return false; if (x.GetType() != y.GetType()) return false; - return x.StartTime == y.StartTime && x.Note == y.Note; + return x.StartTime == y.StartTime && x.Note == y.Note && x.ColorRgb == y.ColorRgb; } - public int GetHashCode(BookmarkInfo obj) => HashCode.Combine(obj.StartTime, obj.Note); + public int GetHashCode(BookmarkInfo obj) => HashCode.Combine(obj.StartTime, obj.Note, obj.ColorRgb); } public static IEqualityComparer ByValueComparer { get; } = new TimeNoteEqualityComparer();