Added "Last modified" sorting option
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
### 1.5.24
|
### 1.5.24
|
||||||
- The Grid now displays last modified information (player name and date) and size on tooltips of stacks (raoulvdberge)
|
- The Grid now displays last modified information (player name and date) and size on tooltips of stacks (raoulvdberge)
|
||||||
|
- Added "Last modified" sorting option in the Grid (raoulvdberge)
|
||||||
- Removed craft-only mode for the Exporter (raoulvdberge)
|
- Removed craft-only mode for the Exporter (raoulvdberge)
|
||||||
- Fixed Exporter with Stack Upgrade not working correctly in Regulator Mode (raoulvdberge)
|
- Fixed Exporter with Stack Upgrade not working correctly in Regulator Mode (raoulvdberge)
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public interface IGrid {
|
|||||||
int SORTING_TYPE_NAME = 1;
|
int SORTING_TYPE_NAME = 1;
|
||||||
int SORTING_TYPE_ID = 2;
|
int SORTING_TYPE_ID = 2;
|
||||||
int SORTING_TYPE_INVENTORYTWEAKS = 3;
|
int SORTING_TYPE_INVENTORYTWEAKS = 3;
|
||||||
|
int SORTING_TYPE_LAST_MODIFIED = 4;
|
||||||
|
|
||||||
int SEARCH_BOX_MODE_NORMAL = 0;
|
int SEARCH_BOX_MODE_NORMAL = 0;
|
||||||
int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1;
|
int SEARCH_BOX_MODE_NORMAL_AUTOSELECTED = 1;
|
||||||
@@ -232,7 +233,11 @@ public interface IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean isValidSortingType(int type) {
|
static boolean isValidSortingType(int type) {
|
||||||
return type == SORTING_TYPE_QUANTITY || type == SORTING_TYPE_NAME || type == SORTING_TYPE_ID || type == SORTING_TYPE_INVENTORYTWEAKS;
|
return type == SORTING_TYPE_QUANTITY ||
|
||||||
|
type == SORTING_TYPE_NAME ||
|
||||||
|
type == SORTING_TYPE_ID ||
|
||||||
|
type == SORTING_TYPE_INVENTORYTWEAKS ||
|
||||||
|
type == SORTING_TYPE_LAST_MODIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isValidSortingDirection(int direction) {
|
static boolean isValidSortingDirection(int direction) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class GridSortingID extends GridSorting {
|
|||||||
public int compare(IGridStack left, IGridStack right) {
|
public int compare(IGridStack left, IGridStack right) {
|
||||||
int x = left.getHash();
|
int x = left.getHash();
|
||||||
int y = right.getHash();
|
int y = right.getHash();
|
||||||
|
|
||||||
if (left.getIngredient() instanceof ItemStack && right.getIngredient() instanceof ItemStack) {
|
if (left.getIngredient() instanceof ItemStack && right.getIngredient() instanceof ItemStack) {
|
||||||
x = Item.getIdFromItem(((ItemStack) left.getIngredient()).getItem());
|
x = Item.getIdFromItem(((ItemStack) left.getIngredient()).getItem());
|
||||||
y = Item.getIdFromItem(((ItemStack) right.getIngredient()).getItem());
|
y = Item.getIdFromItem(((ItemStack) right.getIngredient()).getItem());
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui.grid.sorting;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||||
|
|
||||||
|
public class GridSortingLastModified extends GridSorting {
|
||||||
|
@Override
|
||||||
|
public int compare(IGridStack left, IGridStack right) {
|
||||||
|
long lt = left.getTrackerEntry() != null ? left.getTrackerEntry().getTime() : 0;
|
||||||
|
long rt = right.getTrackerEntry() != null ? right.getTrackerEntry().getTime() : 0;
|
||||||
|
|
||||||
|
if (lt != rt) {
|
||||||
|
// For "last modified" the comparison is reversed
|
||||||
|
if (sortingDirection == IGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
|
return Long.compare(rt, lt);
|
||||||
|
} else if (sortingDirection == IGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
|
return Long.compare(lt, rt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ public class Sorter implements Runnable {
|
|||||||
private static final GridSorting SORTING_NAME = new GridSortingName();
|
private static final GridSorting SORTING_NAME = new GridSortingName();
|
||||||
private static final GridSorting SORTING_ID = new GridSortingID();
|
private static final GridSorting SORTING_ID = new GridSortingID();
|
||||||
private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
|
private static final GridSorting SORTING_INVENTORYTWEAKS = new GridSortingInventoryTweaks();
|
||||||
|
private static final GridSorting SORTING_LAST_MODIFIED = new GridSortingLastModified();
|
||||||
|
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private boolean started;
|
private boolean started;
|
||||||
@@ -59,6 +60,7 @@ public class Sorter implements Runnable {
|
|||||||
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
||||||
SORTING_ID.setSortingDirection(grid.getSortingDirection());
|
SORTING_ID.setSortingDirection(grid.getSortingDirection());
|
||||||
SORTING_INVENTORYTWEAKS.setSortingDirection(grid.getSortingDirection());
|
SORTING_INVENTORYTWEAKS.setSortingDirection(grid.getSortingDirection());
|
||||||
|
SORTING_LAST_MODIFIED.setSortingDirection(grid.getSortingDirection());
|
||||||
|
|
||||||
stacks.sort(SORTING_NAME);
|
stacks.sort(SORTING_NAME);
|
||||||
|
|
||||||
@@ -68,6 +70,8 @@ public class Sorter implements Runnable {
|
|||||||
stacks.sort(SORTING_ID);
|
stacks.sort(SORTING_ID);
|
||||||
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_INVENTORYTWEAKS) {
|
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_INVENTORYTWEAKS) {
|
||||||
stacks.sort(SORTING_INVENTORYTWEAKS);
|
stacks.sort(SORTING_INVENTORYTWEAKS);
|
||||||
|
} else if (grid.getSortingType() == IGrid.SORTING_TYPE_LAST_MODIFIED) {
|
||||||
|
stacks.sort(SORTING_LAST_MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ public class SideButtonGridSortingType extends SideButton {
|
|||||||
type = IGrid.SORTING_TYPE_NAME;
|
type = IGrid.SORTING_TYPE_NAME;
|
||||||
} else if (type == IGrid.SORTING_TYPE_NAME) {
|
} else if (type == IGrid.SORTING_TYPE_NAME) {
|
||||||
if (grid.getType() == GridType.FLUID) {
|
if (grid.getType() == GridType.FLUID) {
|
||||||
type = IGrid.SORTING_TYPE_QUANTITY;
|
type = IGrid.SORTING_TYPE_LAST_MODIFIED;
|
||||||
} else {
|
} else {
|
||||||
type = IGrid.SORTING_TYPE_ID;
|
type = IGrid.SORTING_TYPE_ID;
|
||||||
}
|
}
|
||||||
} else if (type == IGrid.SORTING_TYPE_ID) {
|
} else if (type == IGrid.SORTING_TYPE_ID) {
|
||||||
|
type = IGrid.SORTING_TYPE_LAST_MODIFIED;
|
||||||
|
} else if (type == NetworkNodeGrid.SORTING_TYPE_LAST_MODIFIED) {
|
||||||
if (grid.getType() == GridType.FLUID || !Loader.isModLoaded(GridSortingInventoryTweaks.MOD_ID)) {
|
if (grid.getType() == GridType.FLUID || !Loader.isModLoaded(GridSortingInventoryTweaks.MOD_ID)) {
|
||||||
type = IGrid.SORTING_TYPE_QUANTITY;
|
type = IGrid.SORTING_TYPE_QUANTITY;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ sidebutton.refinedstorage:grid.sorting.type.0=Quantity
|
|||||||
sidebutton.refinedstorage:grid.sorting.type.1=Name
|
sidebutton.refinedstorage:grid.sorting.type.1=Name
|
||||||
sidebutton.refinedstorage:grid.sorting.type.2=ID
|
sidebutton.refinedstorage:grid.sorting.type.2=ID
|
||||||
sidebutton.refinedstorage:grid.sorting.type.3=InventoryTweaks
|
sidebutton.refinedstorage:grid.sorting.type.3=InventoryTweaks
|
||||||
|
sidebutton.refinedstorage:grid.sorting.type.4=Last modified
|
||||||
sidebutton.refinedstorage:grid.search_box_mode=Search box mode
|
sidebutton.refinedstorage:grid.search_box_mode=Search box mode
|
||||||
sidebutton.refinedstorage:grid.search_box_mode.0=Normal
|
sidebutton.refinedstorage:grid.search_box_mode.0=Normal
|
||||||
sidebutton.refinedstorage:grid.search_box_mode.1=Normal (autoselected)
|
sidebutton.refinedstorage:grid.search_box_mode.1=Normal (autoselected)
|
||||||
|
|||||||
Reference in New Issue
Block a user