Added Feature: #0501 - Sorting by Mods

This commit is contained in:
AlgorithmX2 2014-08-05 23:30:59 -05:00
parent 12ec82d1b4
commit 8a194903d8
4 changed files with 29 additions and 2 deletions

View file

@ -148,6 +148,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );

View file

@ -275,7 +275,9 @@ public class ItemRepo
ItemSorters.Direction = (appeng.api.config.SortDir) SortDir;
ItemSorters.init();
if ( SortBy == SortOrder.AMOUNT )
if ( SortBy == SortOrder.MOD )
Collections.sort( view, ItemSorters.ConfigBased_SortByMod );
else if ( SortBy == SortOrder.AMOUNT )
Collections.sort( view, ItemSorters.ConfigBased_SortBySize );
else if ( SortBy == SortOrder.INVTWEAKS )
Collections.sort( view, ItemSorters.ConfigBased_SortByInvTweaks );

View file

@ -34,7 +34,7 @@ public enum ButtonToolTips
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small,
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither, Craft;
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither, Craft, Mod;
String root;

View file

@ -7,6 +7,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.core.AppEng;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IInvTweaks;
import appeng.util.item.AEItemStack;
public class ItemSorters
{
@ -63,6 +64,28 @@ public class ItemSorters
}
};
public static Comparator<IAEItemStack> ConfigBased_SortByMod = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
{
AEItemStack op1 = (AEItemStack) o1;
AEItemStack op2 = (AEItemStack) o2;
if ( Direction == SortDir.ASCENDING )
return secondarySort( op2.getModID().compareToIgnoreCase( op1.getModID() ), o1, o2 );
return secondarySort( op1.getModID().compareToIgnoreCase( op2.getModID() ), o2, o1 );
}
private int secondarySort(int compareToIgnoreCase, IAEItemStack o1, IAEItemStack o2)
{
if ( compareToIgnoreCase == 0 )
return Platform.getItemDisplayName( o2 ).compareToIgnoreCase( Platform.getItemDisplayName( o1 ) );
return compareToIgnoreCase;
}
};
public static Comparator<IAEItemStack> ConfigBased_SortBySize = new Comparator<IAEItemStack>() {
@Override
@ -73,6 +96,7 @@ public class ItemSorters
return compareLong( o1.getStackSize(), o2.getStackSize() );
}
};
public static Comparator<IAEItemStack> ConfigBased_SortByInvTweaks = new Comparator<IAEItemStack>() {
@Override