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:
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user