Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Quaver.API/Maps/Structures/BookmarkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@

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
{
[MoonSharpUserData]
[Serializable]
public class BookmarkInfo : IStartTime
{
public const string DefaultColorRgb = "255,255,0";

public int StartTime
{
get;
Expand All @@ -30,6 +34,22 @@ public string Note
set;
}

public string ColorRgb
{
get;
[MoonSharpVisible(false)]
set;
} = DefaultColorRgb;

[MoonSharpVisible(false)]
public Color GetColor() =>
new Drain<char>(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;
Expand All @@ -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<BookmarkInfo> ByValueComparer { get; } = new TimeNoteEqualityComparer();
Expand Down
Loading