make it so that name sorting is applied always

this is so that position of items isn't determined by their place in the list by default..
This commit is contained in:
Raoul Van den Berge
2016-02-04 00:00:11 +01:00
parent 17d99aa8ad
commit 8e56e4b19e
2 changed files with 19 additions and 21 deletions

View File

@@ -249,6 +249,24 @@ public class GuiGrid extends GuiBase
}
}
items.sort(new Comparator<StorageItem>()
{
@Override
public int compare(StorageItem o1, StorageItem o2)
{
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING)
{
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
}
else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING)
{
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
}
return 0;
}
});
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY)
{
items.sort(new Comparator<StorageItem>()
@@ -269,26 +287,6 @@ public class GuiGrid extends GuiBase
}
});
}
else if (grid.getSortingType() == TileGrid.SORTING_TYPE_NAME)
{
items.sort(new Comparator<StorageItem>()
{
@Override
public int compare(StorageItem o1, StorageItem o2)
{
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING)
{
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
}
else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING)
{
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
}
return 0;
}
});
}
return items;
}

View File

@@ -31,7 +31,7 @@ public class SideButtonGridSortingType extends SideButton
public void draw(GuiBase gui, int x, int y)
{
gui.bindTexture("icons.png");
gui.drawTexture(x, y + 2 - 1, grid.getSortingType() * 16, 32, 16, 16);
gui.drawTexture(x - 1, y + 2 - 1, grid.getSortingType() * 16, 32, 16, 16);
}
@Override