Added Sort By Inventory Tweaks.
NEI and Invtweaks options are now hidden without the supporting mod.
This commit is contained in:
parent
b219c950f4
commit
9f0f84a93f
|
@ -5,6 +5,9 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
@ -179,11 +182,13 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||
{
|
||||
if ( btn instanceof GuiImgButton )
|
||||
{
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if ( iBtn.getSetting() != Settings.ACTIONS )
|
||||
{
|
||||
Enum cv = iBtn.getCurrentValue();
|
||||
Enum next = Platform.nextEnum( cv );
|
||||
Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
|
||||
|
||||
if ( btn == searchBoxSettings )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
|
|
|
@ -141,6 +141,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( 66, Settings.SORT_BY, SortOrder.PRIORITY,
|
||||
// "AppEng.GuiITooltip.SortBy",
|
||||
// "AppEng.GuiITooltip.PriorityCellOrder" );
|
||||
|
|
|
@ -132,11 +132,12 @@ public class ItemRepo
|
|||
Enum SortDir = sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.Direction = (appeng.api.config.SortDir) SortDir;
|
||||
ItemSorters.init();
|
||||
|
||||
if ( SortBy == SortOrder.AMOUNT )
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortBySize );
|
||||
// else if ( SortBy == SortOrder.MOD )
|
||||
// Collections.sort( view, ItemSorters.ConfigBased_SortByMod );
|
||||
else if ( SortBy == SortOrder.INVTWEAKS )
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortByInvTweaks );
|
||||
else
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortByName );
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ public class AppEng
|
|||
// IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry
|
||||
// IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK
|
||||
IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila
|
||||
// IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI
|
||||
IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks", // INV
|
||||
IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI
|
||||
IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" // FMP
|
||||
} );
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public enum ButtonToolTips
|
|||
|
||||
Blocking, NonBlocking, Craft, DontCraft,
|
||||
|
||||
LevelType, LevelType_Energy, LevelType_Item;
|
||||
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks;
|
||||
|
||||
String root;
|
||||
|
||||
|
|
35
integration/modules/InvTweaks.java
Normal file
35
integration/modules/InvTweaks.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package appeng.integration.modules;
|
||||
|
||||
import invtweaks.api.InvTweaksAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
||||
public class InvTweaks extends BaseModule implements IInvTweaks
|
||||
{
|
||||
|
||||
public static InvTweaks instance;
|
||||
|
||||
@Instance("inventorytweaks")
|
||||
static InvTweaksAPI api;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
if ( api == null )
|
||||
throw new RuntimeException( "InvTweaks API Instance Failed." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareItems(ItemStack i, ItemStack j)
|
||||
{
|
||||
return api.compareItems( i, j );
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package appeng.integration.modules.dead;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class InvTweaks implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static InvTweaks instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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...
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue