Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting all the notes in a bookmark/timing change #59

Merged
merged 6 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 0 additions & 17 deletions Classes/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,23 +306,6 @@ public static Window GetFirstWindow<T>() where T : Window {
}
return null;
}
public static bool InsertSortedUnique(List<Note> notes, Note note) {
// check which index to insert the new note at (keep everything in sorted order)
var i = 0;
foreach (var thisNote in notes) {
int comp = thisNote.CompareTo(note);
if (comp == 0) {
return false;
}
if (comp > 0) {
notes.Insert(i, note);
return true;
}
i++;
}
notes.Add(note);
return true;
}
// TODO figure out a better way than this
public static string UidGenerator(Note n) {
return $"Note({Math.Round(n.beat, 4)},{n.col})";
Expand Down
15 changes: 14 additions & 1 deletion Classes/Integrations/DiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void SetPresence(string songName, int numNotes) {
return;
}
var rp = new RichPresence() {
Details = songName == null ? "No song open" : $"Mapping: {songName}",
Details = GetPresenceDetails(songName),
State = songName == null ? "" : $"{numNotes} notes placed",
Assets = new Assets() {
LargeImageKey = Edda.Const.DiscordRPC.IconKey
Expand All @@ -31,6 +31,19 @@ public void SetPresence(string songName, int numNotes) {

client.SetPresence(rp);
}

private string GetPresenceDetails(string songName)
{
switch (songName)
{
case null: return "No song open";
case "": return "Mapping: *Untitled*";
Brollyy marked this conversation as resolved.
Show resolved Hide resolved
default:
return $"Mapping: {songName}";

}
}

public void Enable() {
enabled = true;
InitClient();
Expand Down
3 changes: 1 addition & 2 deletions Classes/MapEditor/BPMChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public int CompareTo(object obj) {
if (!(obj is BPMChange n)) {
throw new Exception();
}
BPMChange m = this;
return m.globalBeat.CompareTo(n.globalBeat);
return this.globalBeat.CompareTo(n.globalBeat);
}
}
29 changes: 24 additions & 5 deletions Classes/MapEditor/Bookmark.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Edda {
public class Bookmark {
public class Bookmark : IComparable, IEquatable<Bookmark>
{

public double beat { get; set; }
public string name { get; set; }
public Bookmark(double beat, string name) {
this.beat = beat;
this.name = name;
}

public int CompareTo(object obj)
{
if (!(obj is Bookmark b))
{
throw new Exception();
}
if (this.Equals(b))
{
return 0;
}
if (Helper.DoubleApproxGreater(this.beat, b.beat))
{
return 1;
}
return -1;
}

public bool Equals(Bookmark b)
{
return Helper.DoubleApproxEqual(b.beat, this.beat);
}
}
}
2 changes: 1 addition & 1 deletion Classes/MapEditor/EditManager/EditList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public EditList(List<Edit<T>> items) {
public EditList() {
this.items = new List<Edit<T>>();
}
public EditList(bool isAdding, List<T> items) {
public EditList(bool isAdding, IEnumerable<T> items) {
this.items = new List<Edit<T>>();
foreach (T item in items) {
this.items.Add(new Edit<T>(isAdding, item));
Expand Down
Loading