Skip to content

Commit

Permalink
fixed dye sorting (again)
Browse files Browse the repository at this point in the history
Fixes #568 - Crash Upon Dye Selection
  • Loading branch information
Yuki-Codes committed Oct 5, 2021
1 parent 13542bf commit 99b2a37
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Anamnesis/Character/Views/DyeSelector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,21 @@ private bool OnFilter(object obj, string[]? search = null)

private int OnSort(object a, object b)
{
if (a is IDye dyeA && b is IDye dyeB)
{
if (a == DyeUtility.NoneDye)
return -1;
if (a == b)
return 0;

if (b == DyeUtility.NoneDye)
return 1;
if (a == DyeUtility.NoneDye && b != DyeUtility.NoneDye)
return -1;

if (dyeA.IsFavorite)
if (a != DyeUtility.NoneDye && b == DyeUtility.NoneDye)
return 1;

if (a is IDye dyeA && b is IDye dyeB)
{
if (dyeA.IsFavorite && !dyeB.IsFavorite)
return -1;

if (dyeB.IsFavorite)
if (!dyeA.IsFavorite && dyeB.IsFavorite)
return 1;

return -dyeB.Key.CompareTo(dyeA.Key);
Expand Down

0 comments on commit 99b2a37

Please sign in to comment.