Skip to content

Commit

Permalink
Add: Difference of collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Mar 16, 2022
1 parent 0a79641 commit 3cc0e06
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 34 deletions.
2 changes: 1 addition & 1 deletion App/CollectionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void EditCollection(CollectionEditArgs e)
break;
}
}
else if (e.Action == CollectionEdit.Intersect)
else if (e.Action == CollectionEdit.Intersect || e.Action == CollectionEdit.Difference)
{
if (e.Collections.Count < 2)
return;
Expand Down
5 changes: 5 additions & 0 deletions App/Presenters/Controls/CollectionListingPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ private void _view_RightClick(object sender, Gui.Misc.StringEventArgs e)
return;
args = CollectionEditArgs.InverseCollections(selectedCollections, selectedCollections[0].Name);
break;
case "Difference":
if (selectedCollections == null)
return;
args = CollectionEditArgs.DifferenceCollections(selectedCollections, selectedCollections[0].Name);
break;
case "Create":
args = CollectionEditArgs.AddCollections(null);
break;
Expand Down
1 change: 1 addition & 0 deletions CollectionManagerDll/Enums/CollectionEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public enum CollectionEdit
Duplicate=8,
Intersect=9,
Inverse=10,
Difference=11,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public static CollectionEditArgs InverseCollections(Collections collections, str
};
}
#endregion
#region Difference Collections
public static CollectionEditArgs DifferenceCollections(Collections collections, string newName)
{
return new CollectionEditArgs(CollectionEdit.Difference)
{
Collections = collections,
NewName = newName
};
}
#endregion
#region Clear Collections
public static CollectionEditArgs ClearCollections()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ edit collection name
merge x collections
intersect x collections
inverse map sum of x collections
difference x collections
clear collections
add beatmaps to collection
remove beatmaps from collection
Expand Down Expand Up @@ -121,6 +122,25 @@ private void EditCollection(CollectionEditArgs args, bool suspendRefresh = false

EditCollection(CollectionEditArgs.AddCollections(new Collections() { targetCollection }), true);
}
else if (action == CollectionEdit.Difference)
{
var targetCollection = args.Collections.Last();
args.Collections.RemoveAt(args.Collections.Count - 1);
var mainCollection = args.Collections[0];
args.Collections.RemoveAt(0);
var beatmaps = mainCollection.AllBeatmaps();
foreach (var collection in args.Collections)
{
beatmaps = beatmaps.Except(collection.AllBeatmaps(), new CollectionBeatmapComparer()).Union(collection.AllBeatmaps().Except(beatmaps, new CollectionBeatmapComparer()));
}

foreach (var beatmap in beatmaps)
{
targetCollection.AddBeatmap(beatmap);
}

EditCollection(CollectionEditArgs.AddCollections(new Collections() { targetCollection }), true);
}
else if (action == CollectionEdit.Clear)
{
LoadedCollections.Clear();
Expand Down
78 changes: 45 additions & 33 deletions GuiComponents/Controls/CollectionListingView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ The following opinions are made available by right clicking in the left panel:

The new collection is named using the selected collection closest to the top of the listing, with `_0` appended to its name.

- Difference: Differentiates all selected collections by making a new collection with only maps that are present in only one selected collection.

The new collection is named using the selected collection closest to the top of the listing, with `_0` appended to its name.

- Inverse: Inverses all selected collections by making a new collection with only maps that are not present in any of the selected collections but are present in your osu! songs folder.

The new collection is named using the selected collection closest to the top of the listing, with `_0` appended to its name.
Expand Down

0 comments on commit 3cc0e06

Please sign in to comment.