Added Interface Priority.
This commit is contained in:
@@ -10,16 +10,20 @@ import org.lwjgl.input.Mouse;
|
|||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.YesNo;
|
import appeng.api.config.YesNo;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
|
import appeng.client.gui.widgets.GuiTabButton;
|
||||||
import appeng.container.implementations.ContainerInterface;
|
import appeng.container.implementations.ContainerInterface;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketConfigButton;
|
import appeng.core.sync.packets.PacketConfigButton;
|
||||||
|
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
|
|
||||||
public class GuiInterface extends GuiUpgradeable
|
public class GuiInterface extends GuiUpgradeable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GuiTabButton priority;
|
||||||
GuiImgButton BlockMode;
|
GuiImgButton BlockMode;
|
||||||
|
|
||||||
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||||
@@ -34,6 +38,18 @@ public class GuiInterface extends GuiUpgradeable
|
|||||||
|
|
||||||
boolean backwards = Mouse.isButtonDown( 1 );
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|
||||||
|
if ( btn == priority )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( btn == BlockMode )
|
if ( btn == BlockMode )
|
||||||
@@ -49,6 +65,9 @@ public class GuiInterface extends GuiUpgradeable
|
|||||||
@Override
|
@Override
|
||||||
protected void addButtons()
|
protected void addButtons()
|
||||||
{
|
{
|
||||||
|
priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
|
||||||
|
buttonList.add( priority );
|
||||||
|
|
||||||
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
|
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
|
||||||
buttonList.add( BlockMode );
|
buttonList.add( BlockMode );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ import appeng.core.sync.packets.PacketSwitchGuis;
|
|||||||
import appeng.core.sync.packets.PacketValueConfig;
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.helpers.IPriorityHost;
|
import appeng.helpers.IPriorityHost;
|
||||||
import appeng.parts.automation.PartFormationPlane;
|
import appeng.parts.automation.PartFormationPlane;
|
||||||
|
import appeng.parts.misc.PartInterface;
|
||||||
import appeng.parts.misc.PartStorageBus;
|
import appeng.parts.misc.PartStorageBus;
|
||||||
|
import appeng.tile.misc.TileInterface;
|
||||||
import appeng.tile.storage.TileChest;
|
import appeng.tile.storage.TileChest;
|
||||||
import appeng.tile.storage.TileDrive;
|
import appeng.tile.storage.TileDrive;
|
||||||
|
|
||||||
@@ -80,6 +82,18 @@ public class GuiPriority extends AEBaseGui
|
|||||||
OriginalGui = GuiBridge.GUI_CHEST;
|
OriginalGui = GuiBridge.GUI_CHEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( target instanceof TileInterface )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().blocks().blockInterface.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target instanceof PartInterface )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().parts().partInterface.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
if ( OriginalGui != null )
|
if ( OriginalGui != null )
|
||||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ import appeng.util.item.AEItemStack;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
||||||
IConfigureableObject, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
IConfigureableObject, IConfigManagerHost, ICraftingProvider, IUpgradeableHost, IPriorityHost
|
||||||
{
|
{
|
||||||
|
|
||||||
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||||
@@ -88,6 +88,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
IInterfaceHost iHost;
|
IInterfaceHost iHost;
|
||||||
BaseActionSource mySrc;
|
BaseActionSource mySrc;
|
||||||
ConfigManager cm = new ConfigManager( this );
|
ConfigManager cm = new ConfigManager( this );
|
||||||
|
int priority;
|
||||||
|
|
||||||
List<ICraftingPatternDetails> craftingList = null;
|
List<ICraftingPatternDetails> craftingList = null;
|
||||||
List<ItemStack> waitingToSend = null;
|
List<ItemStack> waitingToSend = null;
|
||||||
@@ -113,9 +114,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
|
|
||||||
assert (accountedFor.length == patterns.getSizeInventory());
|
assert (accountedFor.length == patterns.getSizeInventory());
|
||||||
|
|
||||||
if (! gridProxy.isReady() )
|
if ( !gridProxy.isReady() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( craftingList != null )
|
if ( craftingList != null )
|
||||||
{
|
{
|
||||||
Iterator<ICraftingPatternDetails> i = craftingList.iterator();
|
Iterator<ICraftingPatternDetails> i = craftingList.iterator();
|
||||||
@@ -159,7 +160,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
if ( is == null )
|
if ( is == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( is.getItem() instanceof ICraftingPatternItem )
|
if ( is.getItem() instanceof ICraftingPatternItem )
|
||||||
{
|
{
|
||||||
ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
|
ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
|
||||||
ICraftingPatternDetails details = cpi.getPatternForItem( is, iHost.getTileEntity().getWorldObj() );
|
ICraftingPatternDetails details = cpi.getPatternForItem( is, iHost.getTileEntity().getWorldObj() );
|
||||||
@@ -257,6 +258,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
storage.writeToNBT( data, "storage" );
|
storage.writeToNBT( data, "storage" );
|
||||||
upgrades.writeToNBT( data, "upgrades" );
|
upgrades.writeToNBT( data, "upgrades" );
|
||||||
craftingTracker.writeToNBT( data );
|
craftingTracker.writeToNBT( data );
|
||||||
|
data.setInteger( "priority", priority );
|
||||||
|
|
||||||
NBTTagList waitingToSend = new NBTTagList();
|
NBTTagList waitingToSend = new NBTTagList();
|
||||||
if ( this.waitingToSend != null )
|
if ( this.waitingToSend != null )
|
||||||
@@ -293,6 +295,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
config.readFromNBT( data, "config" );
|
config.readFromNBT( data, "config" );
|
||||||
patterns.readFromNBT( data, "patterns" );
|
patterns.readFromNBT( data, "patterns" );
|
||||||
storage.readFromNBT( data, "storage" );
|
storage.readFromNBT( data, "storage" );
|
||||||
|
priority = data.getInteger( "priority" );
|
||||||
readConfig();
|
readConfig();
|
||||||
updateCraftingList();
|
updateCraftingList();
|
||||||
}
|
}
|
||||||
@@ -882,7 +885,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
if ( gridProxy.isActive() && craftingList != null )
|
if ( gridProxy.isActive() && craftingList != null )
|
||||||
{
|
{
|
||||||
for (ICraftingPatternDetails details : craftingList)
|
for (ICraftingPatternDetails details : craftingList)
|
||||||
|
{
|
||||||
|
details.setPriority( this.priority );
|
||||||
craftingTracker.addCraftingOption( this, details );
|
craftingTracker.addCraftingOption( this, details );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,4 +1064,26 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
{
|
{
|
||||||
updateCraftingList();
|
updateCraftingList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority()
|
||||||
|
{
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriority(int newValue)
|
||||||
|
{
|
||||||
|
priority = newValue;
|
||||||
|
markDirty();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, gridProxy.getNode() ) );
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,4 +331,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||||||
{
|
{
|
||||||
return aepattern.equals( ((PatternHelper) obj).aepattern );
|
return aepattern.equals( ((PatternHelper) obj).aepattern );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriority(int priority)
|
||||||
|
{
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-1
@@ -55,6 +55,7 @@ import appeng.util.ItemSorters;
|
|||||||
import com.google.common.collect.ImmutableCollection;
|
import com.google.common.collect.ImmutableCollection;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
|
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
|
||||||
{
|
{
|
||||||
@@ -251,7 +252,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
// make them immutable
|
// make them immutable
|
||||||
for (Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet())
|
for (Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet())
|
||||||
{
|
{
|
||||||
craftableItems.put( e.getKey(), ImmutableSet.copyOf( e.getValue() ) );
|
craftableItems.put( e.getKey(), ImmutableSortedSet.copyOf( e.getValue() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import appeng.client.texture.CableBusTextures;
|
|||||||
import appeng.core.sync.GuiBridge;
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.helpers.DualityInterface;
|
import appeng.helpers.DualityInterface;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
|
import appeng.helpers.IPriorityHost;
|
||||||
import appeng.parts.PartBasicState;
|
import appeng.parts.PartBasicState;
|
||||||
import appeng.tile.inventory.IAEAppEngInventory;
|
import appeng.tile.inventory.IAEAppEngInventory;
|
||||||
import appeng.tile.inventory.InvOperation;
|
import appeng.tile.inventory.InvOperation;
|
||||||
@@ -52,7 +53,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class PartInterface extends PartBasicState implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
|
public class PartInterface extends PartBasicState implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
|
||||||
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable
|
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||||
{
|
{
|
||||||
|
|
||||||
DualityInterface duality = new DualityInterface( proxy, this );
|
DualityInterface duality = new DualityInterface( proxy, this );
|
||||||
@@ -60,13 +61,14 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||||||
public PartInterface(ItemStack is) {
|
public PartInterface(ItemStack is) {
|
||||||
super( PartInterface.class, is );
|
super( PartInterface.class, is );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToWorld()
|
public void addToWorld()
|
||||||
{
|
{
|
||||||
super.addToWorld();
|
super.addToWorld();
|
||||||
duality.initalize();
|
duality.initalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void stateChange(MENetworkChannelsChanged c)
|
public void stateChange(MENetworkChannelsChanged c)
|
||||||
{
|
{
|
||||||
@@ -390,4 +392,16 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||||||
duality.jobStateChange( link );
|
duality.jobStateChange( link );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority()
|
||||||
|
{
|
||||||
|
return duality.getPriority();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriority(int newValue)
|
||||||
|
{
|
||||||
|
duality.setPriority( newValue );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import appeng.api.util.IConfigManager;
|
|||||||
import appeng.api.util.IConfigureableObject;
|
import appeng.api.util.IConfigureableObject;
|
||||||
import appeng.helpers.DualityInterface;
|
import appeng.helpers.DualityInterface;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
|
import appeng.helpers.IPriorityHost;
|
||||||
import appeng.tile.events.AETileEventHandler;
|
import appeng.tile.events.AETileEventHandler;
|
||||||
import appeng.tile.events.TileEventType;
|
import appeng.tile.events.TileEventType;
|
||||||
import appeng.tile.grid.AENetworkInvTile;
|
import appeng.tile.grid.AENetworkInvTile;
|
||||||
@@ -45,13 +46,12 @@ import appeng.util.inv.IInventoryDestination;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ISegmentedInventory, ITileStorageMonitorable, IStorageMonitorable,
|
public class TileInterface extends AENetworkInvTile implements IGridTickable, ISegmentedInventory, ITileStorageMonitorable, IStorageMonitorable,
|
||||||
IInventoryDestination, IInterfaceHost, IConfigureableObject
|
IInventoryDestination, IInterfaceHost, IConfigureableObject, IPriorityHost
|
||||||
{
|
{
|
||||||
|
|
||||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||||
DualityInterface duality = new DualityInterface( gridProxy, this );
|
DualityInterface duality = new DualityInterface( gridProxy, this );
|
||||||
|
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void stateChange(MENetworkChannelsChanged c)
|
public void stateChange(MENetworkChannelsChanged c)
|
||||||
{
|
{
|
||||||
@@ -285,4 +285,16 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||||||
{
|
{
|
||||||
duality.jobStateChange( link );
|
duality.jobStateChange( link );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority()
|
||||||
|
{
|
||||||
|
return duality.getPriority();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriority(int newValue)
|
||||||
|
{
|
||||||
|
duality.setPriority( newValue );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user