Skip to content

Commit ea2d471

Browse files
authored
Merge pull request #223 from A6sT/bookmark-editor
Add bookmark color support
2 parents a727e2f + a711cac commit ea2d471

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

Quaver.API/Maps/Structures/BookmarkInfo.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77

88
using System;
99
using System.Collections.Generic;
10+
using System.Drawing;
1011
using MoonSharp.Interpreter;
1112
using MoonSharp.Interpreter.Interop;
13+
using Quaver.API.Helpers;
1214

1315
namespace Quaver.API.Maps.Structures
1416
{
1517
[MoonSharpUserData]
1618
[Serializable]
1719
public class BookmarkInfo : IStartTime
1820
{
21+
public const string DefaultColorRgb = "255,255,0";
22+
1923
public int StartTime
2024
{
2125
get;
@@ -30,6 +34,22 @@ public string Note
3034
set;
3135
}
3236

37+
public string ColorRgb
38+
{
39+
get;
40+
[MoonSharpVisible(false)]
41+
set;
42+
} = DefaultColorRgb;
43+
44+
[MoonSharpVisible(false)]
45+
public Color GetColor() =>
46+
new Drain<char>(ColorRgb, ',') is var (tr, (tg, (tb, _))) &&
47+
byte.TryParse(tr, out var r) &&
48+
byte.TryParse(tg, out var g) &&
49+
byte.TryParse(tb, out var b)
50+
? Color.FromArgb(r, g, b)
51+
: Color.Yellow;
52+
3353
float IStartTime.StartTime
3454
{
3555
get => StartTime;
@@ -45,10 +65,10 @@ public bool Equals(BookmarkInfo x, BookmarkInfo y)
4565
if (ReferenceEquals(y, null)) return false;
4666
if (x.GetType() != y.GetType()) return false;
4767

48-
return x.StartTime == y.StartTime && x.Note == y.Note;
68+
return x.StartTime == y.StartTime && x.Note == y.Note && x.ColorRgb == y.ColorRgb;
4969
}
5070

51-
public int GetHashCode(BookmarkInfo obj) => HashCode.Combine(obj.StartTime, obj.Note);
71+
public int GetHashCode(BookmarkInfo obj) => HashCode.Combine(obj.StartTime, obj.Note, obj.ColorRgb);
5272
}
5373

5474
public static IEqualityComparer<BookmarkInfo> ByValueComparer { get; } = new TimeNoteEqualityComparer();

0 commit comments

Comments
 (0)