Added Interface Priority.
This commit is contained in:
parent
502235dd42
commit
8ae01a4e38
7 changed files with 103 additions and 9 deletions
|
@ -10,16 +10,20 @@ import org.lwjgl.input.Mouse;
|
|||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
GuiImgButton BlockMode;
|
||||
|
||||
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||
|
@ -34,6 +38,18 @@ public class GuiInterface extends GuiUpgradeable
|
|||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == BlockMode )
|
||||
|
@ -49,6 +65,9 @@ public class GuiInterface extends GuiUpgradeable
|
|||
@Override
|
||||
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 );
|
||||
buttonList.add( BlockMode );
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ import appeng.core.sync.packets.PacketSwitchGuis;
|
|||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
|
@ -80,6 +82,18 @@ public class GuiPriority extends AEBaseGui
|
|||
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 )
|
||||
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;
|
||||
|
||||
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 };
|
||||
|
@ -88,6 +88,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
IInterfaceHost iHost;
|
||||
BaseActionSource mySrc;
|
||||
ConfigManager cm = new ConfigManager( this );
|
||||
int priority;
|
||||
|
||||
List<ICraftingPatternDetails> craftingList = null;
|
||||
List<ItemStack> waitingToSend = null;
|
||||
|
@ -113,7 +114,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
|
||||
assert (accountedFor.length == patterns.getSizeInventory());
|
||||
|
||||
if (! gridProxy.isReady() )
|
||||
if ( !gridProxy.isReady() )
|
||||
return;
|
||||
|
||||
if ( craftingList != null )
|
||||
|
@ -159,7 +160,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
if ( is == null )
|
||||
return;
|
||||
|
||||
if ( is.getItem() instanceof ICraftingPatternItem )
|
||||
if ( is.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
|
||||
ICraftingPatternDetails details = cpi.getPatternForItem( is, iHost.getTileEntity().getWorldObj() );
|
||||
|
@ -257,6 +258,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
storage.writeToNBT( data, "storage" );
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
craftingTracker.writeToNBT( data );
|
||||
data.setInteger( "priority", priority );
|
||||
|
||||
NBTTagList waitingToSend = new NBTTagList();
|
||||
if ( this.waitingToSend != null )
|
||||
|
@ -293,6 +295,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
config.readFromNBT( data, "config" );
|
||||
patterns.readFromNBT( data, "patterns" );
|
||||
storage.readFromNBT( data, "storage" );
|
||||
priority = data.getInteger( "priority" );
|
||||
readConfig();
|
||||
updateCraftingList();
|
||||
}
|
||||
|
@ -882,7 +885,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
if ( gridProxy.isActive() && craftingList != null )
|
||||
{
|
||||
for (ICraftingPatternDetails details : craftingList)
|
||||
{
|
||||
details.setPriority( this.priority );
|
||||
craftingTracker.addCraftingOption( this, details );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1058,4 +1064,26 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int priority)
|
||||
{
|
||||
this.priority = priority;
|
||||
}
|
||||
}
|
||||
|
|
3
me/cache/CraftingGridCache.java
vendored
3
me/cache/CraftingGridCache.java
vendored
|
@ -55,6 +55,7 @@ import appeng.util.ItemSorters;
|
|||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
||||
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
|
||||
{
|
||||
|
@ -251,7 +252,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||
// make them immutable
|
||||
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.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
@ -52,7 +53,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartInterface extends PartBasicState implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
|
||||
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable
|
||||
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||
{
|
||||
|
||||
DualityInterface duality = new DualityInterface( proxy, this );
|
||||
|
@ -60,6 +61,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||
public PartInterface(ItemStack is) {
|
||||
super( PartInterface.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
|
@ -390,4 +392,16 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||
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.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
|
@ -45,13 +46,12 @@ import appeng.util.inv.IInventoryDestination;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ISegmentedInventory, ITileStorageMonitorable, IStorageMonitorable,
|
||||
IInventoryDestination, IInterfaceHost, IConfigureableObject
|
||||
IInventoryDestination, IInterfaceHost, IConfigureableObject, IPriorityHost
|
||||
{
|
||||
|
||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||
DualityInterface duality = new DualityInterface( gridProxy, this );
|
||||
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkChannelsChanged c)
|
||||
{
|
||||
|
@ -285,4 +285,16 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||
{
|
||||
duality.jobStateChange( link );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return duality.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
{
|
||||
duality.setPriority( newValue );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue