Added Sort By Inventory Tweaks.
NEI and Invtweaks options are now hidden without the supporting mod.
This commit is contained in:
@@ -4,11 +4,25 @@ import java.util.Comparator;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
|
||||
public class ItemSorters
|
||||
{
|
||||
|
||||
public static SortDir Direction = SortDir.ASCENDING;
|
||||
private static IInvTweaks api;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
if ( api != null )
|
||||
return;
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( "InvTweaks" ) )
|
||||
api = (IInvTweaks) AppEng.instance.getIntegration( "InvTweaks" );
|
||||
else
|
||||
api = null;
|
||||
}
|
||||
|
||||
public static int compareInt(int a, int b)
|
||||
{
|
||||
@@ -58,5 +72,20 @@ public class ItemSorters
|
||||
return compareLong( o1.getStackSize(), o2.getStackSize() );
|
||||
}
|
||||
};
|
||||
public static Comparator<IAEItemStack> ConfigBased_SortByInvTweaks = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(IAEItemStack o1, IAEItemStack o2)
|
||||
{
|
||||
if ( api == null )
|
||||
return ConfigBased_SortByName.compare( o1, o2 );
|
||||
|
||||
int cmp = api.compareItems( o1.getItemStack(), o2.getItemStack() );
|
||||
|
||||
if ( Direction == SortDir.ASCENDING )
|
||||
return cmp;
|
||||
return -cmp;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+17
-1
@@ -52,7 +52,9 @@ import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
@@ -178,11 +180,25 @@ public class Platform
|
||||
else
|
||||
ce = nextEnum( ce );
|
||||
}
|
||||
while (!ValidOptions.contains( ce ));
|
||||
while (!ValidOptions.contains( ce ) || isNotValidSetting( ce ));
|
||||
|
||||
return ce;
|
||||
}
|
||||
|
||||
private static boolean isNotValidSetting(Enum e)
|
||||
{
|
||||
if ( e == SortOrder.INVTWEAKS && !AppEng.instance.isIntegrationEnabled( "InvTweaks" ) )
|
||||
return true;
|
||||
|
||||
if ( e == SearchBoxMode.NEI_AUTOSEARCH && !AppEng.instance.isIntegrationEnabled( "NEI" ) )
|
||||
return true;
|
||||
|
||||
if ( e == SearchBoxMode.NEI_MANUAL_SEARCH && !AppEng.instance.isIntegrationEnabled( "NEI" ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple way to cycle an enum...
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user