Large chunk on the pattern terminal.

This commit is contained in:
AlgorithmX2 2014-04-09 23:51:08 -05:00
parent 01c76a6870
commit d84be03027
11 changed files with 206 additions and 45 deletions

View file

@ -483,8 +483,12 @@ public abstract class AEBaseGui extends GuiContainer
if ( o instanceof OptionalSlotFake ) if ( o instanceof OptionalSlotFake )
{ {
OptionalSlotFake fs = (OptionalSlotFake) o; OptionalSlotFake fs = (OptionalSlotFake) o;
if ( fs.renderDisabled() )
{
if ( fs.isEnabled() ) if ( fs.isEnabled() )
{
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 ); this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
}
else else
{ {
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
@ -497,6 +501,7 @@ public abstract class AEBaseGui extends GuiContainer
} }
} }
} }
}
@Override @Override
final protected void drawGuiContainerForegroundLayer(int x, int y) final protected void drawGuiContainerForegroundLayer(int x, int y)

View file

@ -1,27 +1,42 @@
package appeng.client.gui.implementations; package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import appeng.api.config.ActionItems; import appeng.api.config.ActionItems;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
public class GuiPatternTerm extends GuiMEMonitorable public class GuiPatternTerm extends GuiMEMonitorable
{ {
GuiImgButton exttractPatternBtn; ContainerPatternTerm container;
GuiTabButton tabCraftButton;
GuiTabButton tabProcessButton;
GuiImgButton substitutionsBtn; GuiImgButton substitutionsBtn;
GuiImgButton encodeBtn;
@Override @Override
public void initGui() public void initGui()
{ {
super.initGui(); super.initGui();
buttonList.add( exttractPatternBtn = new GuiImgButton( this.guiLeft + 6, this.guiTop + this.ySize - 161, Settings.ACTIONS, ActionItems.PULL ) ); buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 179, new ItemStack( Blocks.crafting_table ),
buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 118, this.guiTop + this.ySize - 161, Settings.ACTIONS, ActionItems.CLOSE ) ); GuiText.CraftingPattern.getLocal(), itemRender ) );
exttractPatternBtn.halfSize = true; buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 179, new ItemStack( Blocks.furnace ),
GuiText.ProcessingPattern.getLocal(), itemRender ) );
buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
buttonList.add( encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 144, Settings.ACTIONS, ActionItems.ENCODE ) );
substitutionsBtn.halfSize = true;
} }
@Override @Override
@ -29,9 +44,22 @@ public class GuiPatternTerm extends GuiMEMonitorable
{ {
super.actionPerformed( btn ); super.actionPerformed( btn );
if ( exttractPatternBtn == btn ) try
{ {
if ( tabCraftButton == btn || tabProcessButton == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", tabProcessButton == btn ? "0" : "1" ) );
}
if ( encodeBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} }
if ( substitutionsBtn == btn ) if ( substitutionsBtn == btn )
@ -42,17 +70,31 @@ public class GuiPatternTerm extends GuiMEMonitorable
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) { public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) ); super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
container = (ContainerPatternTerm) this.inventorySlots;
reservedSpace = 85; reservedSpace = 85;
} }
protected String getBackground() protected String getBackground()
{ {
if ( container.craftingMode )
return "guis/pattern.png"; return "guis/pattern.png";
return "guis/pattern2.png";
} }
@Override @Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{ {
if ( !container.craftingMode )
{
tabCraftButton.visible = true;
tabProcessButton.visible = false;
}
else
{
tabCraftButton.visible = false;
tabProcessButton.visible = true;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY ); super.drawFG( offsetX, offsetY, mouseX, mouseY );
fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, ySize - 96 + 2 - reservedSpace, 4210752 ); fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, ySize - 96 + 2 - reservedSpace, 4210752 );
} }

View file

@ -156,7 +156,8 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint ); registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings ); registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
registerApp( 7, Settings.ACTIONS, ActionItems.PULL, ButtonToolTips.Pull, ButtonToolTips.PullDescription ); registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
registerApp( 4 + 3 * 16, Settings.ACTIONS, ActionItems.SUBSTITUTION, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDesc );
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems ); registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable ); registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );

View file

@ -1,9 +1,12 @@
package appeng.container.implementations; package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake; import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotPatternTerm; import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
@ -13,37 +16,97 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost
{ {
AppEngInternalInventory craftSlotInv = new AppEngInternalInventory( this, 1 ); AppEngInternalInventory craftSlotInv = new AppEngInternalInventory( this, 1 );
SlotFake craftingSlots[] = new SlotFake[9]; SlotFake craftingSlots[] = new SlotFake[9];
SlotFake outputSlots[] = new SlotFake[3]; OptionalSlotFake outputSlots[] = new OptionalSlotFake[3];
SlotPatternTerm craftSlot;
SlotRestrictedInput patternSlot;
PartPatternTerminal ct; SlotPatternTerm craftSlot;
SlotRestrictedInput patternSlotIN;
SlotRestrictedInput patternSlotOUT;
public PartPatternTerminal ct;
public boolean craftingMode = true;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) { public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) {
super( ip, montiorable, false ); super( ip, montiorable, false );
ct = (PartPatternTerminal) montiorable; ct = (PartPatternTerminal) montiorable;
IInventory patternInv = ct.getInventoryByName( "pattern" ); IInventory patternInv = ct.getInventoryByName( "pattern" );
IInventory output = ct.getInventoryByName( "output" );
IInventory crafting = ct.getInventoryByName( "crafting" ); IInventory crafting = ct.getInventoryByName( "crafting" );
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++) for (int x = 0; x < 3; x++)
addSlotToContainer( craftingSlots[x + y * 3] = new SlotFake( crafting, x + y * 3, 54 + x * 18, -76 + y * 18 ) ); addSlotToContainer( craftingSlots[x + y * 3] = new SlotFake( crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
addSlotToContainer( craftSlot = new SlotPatternTerm( craftSlotInv, this, 0, 110, -76 + 18, 2 ) );
craftSlot.renderDisabled = false;
craftSlot.IIcon = -1;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
addSlotToContainer( outputSlots[y] = new SlotFake( crafting, 9 + y, 146, -76 + y * 18 ) ); {
addSlotToContainer( outputSlots[y] = new OptionalSlotFake( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
outputSlots[y].renderDisabled = false;
outputSlots[y].IIcon = -1;
}
addSlotToContainer( patternSlotIN = new SlotRestrictedInput( PlaceableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9 ) );
addSlotToContainer( patternSlotOUT = new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34 ) );
addSlotToContainer( patternSlot = new SlotRestrictedInput( PlaceableItemType.PATTERN, patternInv, 0, 17, -72 - 9 ) ); patternSlotOUT.setStackLimit( 1 );
addSlotToContainer( craftSlot = new SlotPatternTerm( craftSlotInv, 0, 17, -72 + 34 ) );
patternSlot.setStackLimit( 1 );
bindPlayerInventory( ip, 0, 0 ); bindPlayerInventory( ip, 0, 0 );
updateOrderOfOutputSlots();
}
private void updateOrderOfOutputSlots()
{
if ( !craftingMode )
{
craftSlot.xDisplayPosition = 0;
for (int y = 0; y < 3; y++)
outputSlots[y].xDisplayPosition = outputSlots[y].defX;
}
else
{
craftSlot.xDisplayPosition = craftSlot.defX;
for (int y = 0; y < 3; y++)
outputSlots[y].xDisplayPosition = 0;
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if ( craftingMode != ct.craftingMode )
{
craftingMode = ct.craftingMode;
updateOrderOfOutputSlots();
for (Object c : this.crafters)
{
if ( c instanceof ICrafting )
((ICrafting) c).sendProgressBarUpdate( this, 97, craftingMode ? 1 : 0 );
}
}
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 97 )
{
craftingMode = value == 1;
updateOrderOfOutputSlots();
}
} }
@Override @Override
@ -57,4 +120,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{ {
} }
public void encode()
{
}
@Override
public boolean isSlotEnabled(int idx)
{
if ( idx == 1 )
return craftingMode == false;
if ( idx == 2 )
return craftingMode == true;
return false;
}
} }

View file

@ -10,6 +10,8 @@ public class OptionalSlotFake extends SlotFake
final int groupNum; final int groupNum;
IOptionalSlotHost host; IOptionalSlotHost host;
public boolean renderDisabled = true;
public int srcX; public int srcX;
public int srcY; public int srcY;
@ -43,4 +45,9 @@ public class OptionalSlotFake extends SlotFake
return host.isSlotEnabled( groupNum ); return host.isSlotEnabled( groupNum );
} }
public boolean renderDisabled()
{
return renderDisabled;
}
} }

View file

@ -4,22 +4,23 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotPatternTerm extends AppEngSlot public class SlotPatternTerm extends OptionalSlotFake
{ {
public SlotPatternTerm(IInventory inv, int idx, int x, int y) { public SlotPatternTerm(IInventory inv, IOptionalSlotHost h, int idx, int x, int y, int grpnum) {
super( inv, idx, x, y ); super( inv, h, idx, x, y, 0, 0, grpnum );
} }
@Override @Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer) public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{ {
return false; return super.canTakeStack( par1EntityPlayer );
} }
@Override @Override
public void onPickupFromSlot(EntityPlayer p, ItemStack is) public void onPickupFromSlot(EntityPlayer p, ItemStack is)
{ {
super.onPickupFromSlot( p, is );
} }
} }

View file

@ -130,9 +130,14 @@ public class SlotRestrictedInput extends AppEngSlot
case VALID_ENCODED_PATTERN_W_OUPUT: case VALID_ENCODED_PATTERN_W_OUPUT:
case ENCODED_PATTERN_W_OUTPUT: case ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN: { case ENCODED_PATTERN: {
ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) i.getItem()).getPatternForItem( i ) : null; if ( i.getItem() instanceof ICraftingPatternItem )
return pattern != null; return true;
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem)
// i.getItem()).getPatternForItem( i ) : null;
return false;// pattern != null;
} }
case BLANK_PATTERN:
return AEApi.instance().materials().materialBlankPattern.sameAs( i );
case PATTERN: case PATTERN:
if ( i.getItem() instanceof ICraftingPatternItem ) if ( i.getItem() instanceof ICraftingPatternItem )

View file

@ -34,7 +34,7 @@ public enum ButtonToolTips
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small, LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small,
Pull, PullDescription, Substitutions, SubstitutionsOn, SubstitutionsOff; Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc;
String root; String root;

View file

@ -26,7 +26,9 @@ public enum GuiText
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize, METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize,
StoredPower, MaxPower, RequiredPower, Efficiency, CopyMode, CopyModeDesc, PatternTerminal; StoredPower, MaxPower, RequiredPower, Efficiency, CopyMode, CopyModeDesc, PatternTerminal,
CraftingPattern, ProcessingPattern;
String root; String root;

View file

@ -17,6 +17,7 @@ import appeng.api.util.IConfigureableObject;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerCellWorkbench;
import appeng.container.implementations.ContainerLevelEmitter; import appeng.container.implementations.ContainerLevelEmitter;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.implementations.ContainerPriority; import appeng.container.implementations.ContainerPriority;
import appeng.container.implementations.ContainerQuartzKnife; import appeng.container.implementations.ContainerQuartzKnife;
import appeng.container.implementations.ContainerSecurity; import appeng.container.implementations.ContainerSecurity;
@ -66,6 +67,18 @@ public class PacketValueConfig extends AppEngPacket
lvc.setLevel( Long.parseLong( Value ), player ); lvc.setLevel( Long.parseLong( Value ), player );
return; return;
} }
else if ( Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
{
ContainerPatternTerm cpt = (ContainerPatternTerm) c;
if ( Name.equals( "PatternTerminal.CraftMode" ) )
{
cpt.ct.craftingMode = Value.equals( "1" );
}
else if ( Name.equals( "PatternTerminal.Encode" ) )
{
cpt.encode();
}
}
else if ( Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench ) else if ( Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
{ {
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c; ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;

View file

@ -14,43 +14,45 @@ import appeng.tile.inventory.InvOperation;
public class PartPatternTerminal extends PartTerminal implements IAEAppEngInventory public class PartPatternTerminal extends PartTerminal implements IAEAppEngInventory
{ {
AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 + 3 ); AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
AppEngInternalInventory pattern = new AppEngInternalInventory( this, 1 ); AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
public boolean craftingMode = true;
@Override @Override
public void writeToNBT(NBTTagCompound data) public void writeToNBT(NBTTagCompound data)
{ {
super.writeToNBT( data ); super.writeToNBT( data );
data.setBoolean( "craftingMode", craftingMode );
pattern.writeToNBT( data, "pattern" ); pattern.writeToNBT( data, "pattern" );
craftingGrid.writeToNBT( data, "craftingGrid" ); output.writeToNBT( data, "outputList" );
crafting.writeToNBT( data, "craftingGrid" );
} }
@Override @Override
public void readFromNBT(NBTTagCompound data) public void readFromNBT(NBTTagCompound data)
{ {
super.readFromNBT( data ); super.readFromNBT( data );
craftingMode = data.getBoolean( "craftingMode" );
pattern.readFromNBT( data, "pattern" ); pattern.readFromNBT( data, "pattern" );
craftingGrid.readFromNBT( data, "craftingGrid" ); output.readFromNBT( data, "outputList" );
crafting.readFromNBT( data, "craftingGrid" );
} }
@Override @Override
public void getDrops(List<ItemStack> drops, boolean wrenched) public void getDrops(List<ItemStack> drops, boolean wrenched)
{ {
for (ItemStack is : craftingGrid)
if ( is != null )
drops.add( is );
for (ItemStack is : pattern) for (ItemStack is : pattern)
if ( is != null ) if ( is != null )
drops.add( is ); drops.add( is );
} }
public PartPatternTerminal(ItemStack is) { public PartPatternTerminal(ItemStack is) {
super( PartPatternTerminal.class, is, true ); super( PartPatternTerminal.class, is );
frontBright = CableBusTextures.PartPatternTerm_Bright; frontBright = CableBusTextures.PartPatternTerm_Bright;
frontColored = CableBusTextures.PartPatternTerm_Colored; frontColored = CableBusTextures.PartPatternTerm_Colored;
frontDark = CableBusTextures.PartPatternTerm_Dark; frontDark = CableBusTextures.PartPatternTerm_Dark;
// frontSolid = CableBusTextures.PartPatternTerm_Solid;
} }
public GuiBridge getGui() public GuiBridge getGui()
@ -62,9 +64,14 @@ public class PartPatternTerminal extends PartTerminal implements IAEAppEngInvent
public IInventory getInventoryByName(String name) public IInventory getInventoryByName(String name)
{ {
if ( name.equals( "crafting" ) ) if ( name.equals( "crafting" ) )
return craftingGrid; return crafting;
if ( name.equals( "output" ) )
return output;
if ( name.equals( "pattern" ) ) if ( name.equals( "pattern" ) )
return pattern; return pattern;
return super.getInventoryByName( name ); return super.getInventoryByName( name );
} }