Added Crafting Status GUI to Terminals.
This commit is contained in:
@@ -26,7 +26,6 @@ import appeng.core.AELog;
|
|||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketValueConfig;
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.tile.crafting.TileCraftingTile;
|
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
@@ -42,13 +41,25 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|||||||
|
|
||||||
List<IAEItemStack> visual = new ArrayList();
|
List<IAEItemStack> visual = new ArrayList();
|
||||||
|
|
||||||
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, TileCraftingTile te) {
|
public void clearItems()
|
||||||
super( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
{
|
||||||
|
storage = AEApi.instance().storage().createItemList();
|
||||||
|
active = AEApi.instance().storage().createItemList();
|
||||||
|
pending = AEApi.instance().storage().createItemList();
|
||||||
|
visual = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected GuiCraftingCPU(ContainerCraftingCPU container) {
|
||||||
|
super( container );
|
||||||
this.ySize = 184;
|
this.ySize = 184;
|
||||||
this.xSize = 238;
|
this.xSize = 238;
|
||||||
myScrollBar = new GuiScrollbar();
|
myScrollBar = new GuiScrollbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
|
||||||
|
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||||
|
}
|
||||||
|
|
||||||
GuiButton cancel;
|
GuiButton cancel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,6 +216,8 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||||
{
|
{
|
||||||
|
cancel.enabled = !visual.isEmpty();
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
@@ -398,4 +411,5 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|||||||
{
|
{
|
||||||
return ViewItems.ALL;
|
return ViewItems.ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.storage.ITerminalHost;
|
||||||
|
import appeng.client.gui.widgets.GuiTabButton;
|
||||||
|
import appeng.container.implementations.ContainerCraftingStatus;
|
||||||
|
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.PacketSwitchGuis;
|
||||||
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
|
import appeng.helpers.WirelessTerminalGuiObject;
|
||||||
|
import appeng.parts.reporting.PartCraftingTerminal;
|
||||||
|
import appeng.parts.reporting.PartPatternTerminal;
|
||||||
|
import appeng.parts.reporting.PartTerminal;
|
||||||
|
|
||||||
|
public class GuiCraftingStatus extends GuiCraftingCPU
|
||||||
|
{
|
||||||
|
|
||||||
|
ContainerCraftingStatus ccc;
|
||||||
|
GuiButton selectcpu;
|
||||||
|
|
||||||
|
GuiTabButton originalGuiBtn;
|
||||||
|
GuiBridge OriginalGui;
|
||||||
|
ItemStack myIcon = null;
|
||||||
|
|
||||||
|
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||||
|
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
|
||||||
|
|
||||||
|
ccc = (ContainerCraftingStatus) inventorySlots;
|
||||||
|
Object target = ccc.getTarget();
|
||||||
|
|
||||||
|
if ( target instanceof WirelessTerminalGuiObject )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target instanceof PartTerminal )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_ME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target instanceof PartCraftingTerminal )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target instanceof PartPatternTerminal )
|
||||||
|
{
|
||||||
|
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||||
|
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton btn)
|
||||||
|
{
|
||||||
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|
||||||
|
if ( btn == selectcpu )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( btn == originalGuiBtn )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getGuiDisplayName(String in)
|
||||||
|
{
|
||||||
|
return in; // the cup name is on the button
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
selectcpu = new GuiButton( 0, this.guiLeft + 8, this.guiTop + ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
||||||
|
// selectcpu.enabled = false;
|
||||||
|
buttonList.add( selectcpu );
|
||||||
|
|
||||||
|
if ( myIcon != null )
|
||||||
|
{
|
||||||
|
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||||
|
originalGuiBtn.hideEdge = 13;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCPUButtonText()
|
||||||
|
{
|
||||||
|
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||||
|
|
||||||
|
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||||
|
{
|
||||||
|
if ( ccc.myName.length() > 0 )
|
||||||
|
{
|
||||||
|
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||||
|
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
btnTextText = GuiText.CPUs.getLocal() + ": #" + ccc.selectedCpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ccc.noCPU )
|
||||||
|
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||||
|
|
||||||
|
selectcpu.displayString = btnTextText;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||||
|
{
|
||||||
|
updateCPUButtonText();
|
||||||
|
super.drawScreen( mouse_x, mouse_y, btn );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import appeng.api.util.IConfigureableObject;
|
|||||||
import appeng.client.gui.AEBaseMEGui;
|
import appeng.client.gui.AEBaseMEGui;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
import appeng.client.gui.widgets.GuiScrollbar;
|
import appeng.client.gui.widgets.GuiScrollbar;
|
||||||
|
import appeng.client.gui.widgets.GuiTabButton;
|
||||||
import appeng.client.gui.widgets.ISortSource;
|
import appeng.client.gui.widgets.ISortSource;
|
||||||
import appeng.client.gui.widgets.MEGuiTextField;
|
import appeng.client.gui.widgets.MEGuiTextField;
|
||||||
import appeng.client.me.InternalSlotME;
|
import appeng.client.me.InternalSlotME;
|
||||||
@@ -35,7 +36,9 @@ import appeng.core.AEConfig;
|
|||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
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.PacketSwitchGuis;
|
||||||
import appeng.core.sync.packets.PacketValueConfig;
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.helpers.WirelessTerminalGuiObject;
|
import appeng.helpers.WirelessTerminalGuiObject;
|
||||||
import appeng.integration.IntegrationType;
|
import appeng.integration.IntegrationType;
|
||||||
@@ -47,6 +50,8 @@ import appeng.util.Platform;
|
|||||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GuiTabButton craftingStatusBtn;
|
||||||
|
|
||||||
MEGuiTextField searchField;
|
MEGuiTextField searchField;
|
||||||
private static String memoryText = "";
|
private static String memoryText = "";
|
||||||
|
|
||||||
@@ -227,6 +232,13 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
searchField.setTextColor( 0xFFFFFF );
|
searchField.setTextColor( 0xFFFFFF );
|
||||||
searchField.setVisible( true );
|
searchField.setVisible( true );
|
||||||
|
|
||||||
|
if ( viewCell || this instanceof GuiWirelessTerm )
|
||||||
|
{
|
||||||
|
buttonList.add( craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(),
|
||||||
|
itemRender ) );
|
||||||
|
craftingStatusBtn.hideEdge = 13;
|
||||||
|
}
|
||||||
|
|
||||||
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
||||||
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||||
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
|
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
|
||||||
@@ -273,6 +285,18 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton btn)
|
protected void actionPerformed(GuiButton btn)
|
||||||
{
|
{
|
||||||
|
if ( btn == craftingStatusBtn )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( btn instanceof GuiImgButton )
|
if ( btn instanceof GuiImgButton )
|
||||||
{
|
{
|
||||||
boolean backwards = Mouse.isButtonDown( 1 );
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ public class GuiPatternTerm extends GuiMEMonitorable
|
|||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 179, new ItemStack( Blocks.crafting_table ),
|
buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
|
||||||
GuiText.CraftingPattern.getLocal(), itemRender ) );
|
GuiText.CraftingPattern.getLocal(), itemRender ) );
|
||||||
buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 179, new ItemStack( Blocks.furnace ),
|
buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ),
|
||||||
GuiText.ProcessingPattern.getLocal(), itemRender ) );
|
GuiText.ProcessingPattern.getLocal(), itemRender ) );
|
||||||
|
|
||||||
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public class GuiTabButton extends GuiButton implements ITooltip
|
|||||||
RenderItem itemRenderer;
|
RenderItem itemRenderer;
|
||||||
|
|
||||||
int myIcon = -1;
|
int myIcon = -1;
|
||||||
|
public int hideEdge = 0;
|
||||||
|
|
||||||
ItemStack myItem;
|
ItemStack myItem;
|
||||||
|
|
||||||
String Msg;
|
String Msg;
|
||||||
@@ -66,16 +68,18 @@ public class GuiTabButton extends GuiButton implements ITooltip
|
|||||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||||
|
|
||||||
int uv_y = (int) Math.floor( 13 / 16 );
|
int uv_y = (int) Math.floor( 13 / 16 );
|
||||||
int uv_x = 13 - uv_y * 16;
|
int uv_x = (hideEdge > 0 ? 11 : 13) - uv_y * 16;
|
||||||
|
|
||||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 22, 22 );
|
int offsetX = hideEdge > 0 ? 1 : 0;
|
||||||
|
|
||||||
|
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 25, 22 );
|
||||||
|
|
||||||
if ( myIcon >= 0 )
|
if ( myIcon >= 0 )
|
||||||
{
|
{
|
||||||
uv_y = (int) Math.floor( myIcon / 16 );
|
uv_y = (int) Math.floor( myIcon / 16 );
|
||||||
uv_x = myIcon - uv_y * 16;
|
uv_x = myIcon - uv_y * 16;
|
||||||
|
|
||||||
this.drawTexturedModalRect( this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||||
@@ -89,7 +93,7 @@ public class GuiTabButton extends GuiButton implements ITooltip
|
|||||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
|
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
|
||||||
itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, par1Minecraft.renderEngine, myItem, this.xPosition + 3, this.yPosition + 3 );
|
itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, par1Minecraft.renderEngine, myItem, offsetX + this.xPosition + 3, this.yPosition + 3 );
|
||||||
GL11.glDisable( GL11.GL_LIGHTING );
|
GL11.glDisable( GL11.GL_LIGHTING );
|
||||||
|
|
||||||
itemRenderer.zLevel = 0.0F;
|
itemRenderer.zLevel = 0.0F;
|
||||||
|
|||||||
@@ -12,16 +12,18 @@ import appeng.api.networking.IGrid;
|
|||||||
import appeng.api.networking.IGridHost;
|
import appeng.api.networking.IGridHost;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.crafting.CraftingItemList;
|
import appeng.api.networking.crafting.CraftingItemList;
|
||||||
|
import appeng.api.networking.crafting.ICraftingCPU;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.storage.IBaseMonitor;
|
import appeng.api.networking.storage.IBaseMonitor;
|
||||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
|
import appeng.core.AELog;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||||
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.helpers.ICustomNameObject;
|
import appeng.helpers.ICustomNameObject;
|
||||||
import appeng.me.cluster.IAECluster;
|
|
||||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||||
import appeng.tile.crafting.TileCraftingTile;
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -31,13 +33,13 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
|
|
||||||
CraftingCPUCluster monitor = null;
|
CraftingCPUCluster monitor = null;
|
||||||
String cpuName = null;
|
String cpuName = null;
|
||||||
IGrid network;
|
protected IGrid network;
|
||||||
|
|
||||||
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||||
|
|
||||||
public ContainerCraftingCPU(InventoryPlayer ip, TileCraftingTile te) {
|
public ContainerCraftingCPU(InventoryPlayer ip, Object te) {
|
||||||
super( ip, null, null );
|
super( ip, te );
|
||||||
IGridHost host = te;// .getGridHost();
|
IGridHost host = (IGridHost) (te instanceof IGridHost ? te : null);
|
||||||
|
|
||||||
if ( host != null )
|
if ( host != null )
|
||||||
{
|
{
|
||||||
@@ -47,23 +49,52 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( te instanceof TileCraftingTile )
|
if ( te instanceof TileCraftingTile )
|
||||||
{
|
setCPU( (ICraftingCPU) ((TileCraftingTile) te).getCluster() );
|
||||||
IAECluster c = ((TileCraftingTile) te).getCluster();
|
|
||||||
if ( c instanceof CraftingCPUCluster )
|
|
||||||
{
|
|
||||||
cpuName = ((CraftingCPUCluster) c).getName();
|
|
||||||
|
|
||||||
monitor = (CraftingCPUCluster) c;
|
if ( network == null && Platform.isServer() )
|
||||||
if ( monitor != null )
|
isContainerValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCPU(ICraftingCPU c)
|
||||||
|
{
|
||||||
|
if ( c== monitor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( monitor != null )
|
||||||
|
monitor.removeListener( this );
|
||||||
|
|
||||||
|
for (Object g : this.crafters)
|
||||||
|
{
|
||||||
|
if ( g instanceof EntityPlayer )
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
monitor.getListOfItem( list, CraftingItemList.ALL );
|
NetworkHandler.instance.sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (EntityPlayerMP) g );
|
||||||
monitor.addListener( this, null );
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( network == null && Platform.isServer() )
|
if ( c instanceof CraftingCPUCluster )
|
||||||
isContainerValid = false;
|
{
|
||||||
|
cpuName = ((CraftingCPUCluster) c).getName();
|
||||||
|
|
||||||
|
monitor = (CraftingCPUCluster) c;
|
||||||
|
if ( monitor != null )
|
||||||
|
{
|
||||||
|
list.resetStatus();
|
||||||
|
monitor.getListOfItem( list, CraftingItemList.ALL );
|
||||||
|
monitor.addListener( this, null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
monitor = null;
|
||||||
|
cpuName = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelCrafting()
|
public void cancelCrafting()
|
||||||
@@ -106,7 +137,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
if ( Platform.isServer() && !list.isEmpty() )
|
if ( Platform.isServer() && monitor != null && !list.isEmpty() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package appeng.container.implementations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import appeng.api.networking.crafting.ICraftingCPU;
|
||||||
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
|
import appeng.api.storage.ITerminalHost;
|
||||||
|
import appeng.container.guisync.GuiSync;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||||
|
{
|
||||||
|
|
||||||
|
@GuiSync(5)
|
||||||
|
public int selectedCpu = -1;
|
||||||
|
|
||||||
|
@GuiSync(6)
|
||||||
|
public boolean noCPU = true;
|
||||||
|
|
||||||
|
@GuiSync(7)
|
||||||
|
public String myName = "";
|
||||||
|
|
||||||
|
public ArrayList<CraftingCPURecord> cpus = new ArrayList();
|
||||||
|
|
||||||
|
private void sendCPUs()
|
||||||
|
{
|
||||||
|
Collections.sort( cpus );
|
||||||
|
|
||||||
|
if ( selectedCpu >= cpus.size() )
|
||||||
|
{
|
||||||
|
selectedCpu = -1;
|
||||||
|
myName = "";
|
||||||
|
}
|
||||||
|
else if ( selectedCpu != -1 )
|
||||||
|
{
|
||||||
|
myName = cpus.get( selectedCpu ).myName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( selectedCpu == -1 && cpus.size() > 0 )
|
||||||
|
selectedCpu = 0;
|
||||||
|
|
||||||
|
if ( selectedCpu != -1 )
|
||||||
|
{
|
||||||
|
if ( cpus.get( selectedCpu ).cpu != monitor )
|
||||||
|
setCPU( cpus.get( selectedCpu ).cpu );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setCPU( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges()
|
||||||
|
{
|
||||||
|
ICraftingGrid cc = network.getCache( ICraftingGrid.class );
|
||||||
|
ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||||
|
|
||||||
|
int matches = 0;
|
||||||
|
boolean changed = false;
|
||||||
|
for (ICraftingCPU c : cpuSet)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
for (CraftingCPURecord ccr : cpus)
|
||||||
|
if ( ccr.cpu == c )
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
boolean matched = cpuMatches( c );
|
||||||
|
|
||||||
|
if ( matched )
|
||||||
|
matches++;
|
||||||
|
|
||||||
|
if ( !found != matched )
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( changed || cpus.size() != matches )
|
||||||
|
{
|
||||||
|
cpus.clear();
|
||||||
|
for (ICraftingCPU c : cpuSet)
|
||||||
|
{
|
||||||
|
if ( cpuMatches( c ) )
|
||||||
|
cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCPUs();
|
||||||
|
}
|
||||||
|
|
||||||
|
noCPU = cpus.size() == 0;
|
||||||
|
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean cpuMatches(ICraftingCPU c)
|
||||||
|
{
|
||||||
|
return c.isBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContainerCraftingStatus(InventoryPlayer ip, ITerminalHost te) {
|
||||||
|
super( ip, te );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cycleCpu(boolean next)
|
||||||
|
{
|
||||||
|
if ( next )
|
||||||
|
selectedCpu++;
|
||||||
|
else
|
||||||
|
selectedCpu--;
|
||||||
|
|
||||||
|
if ( selectedCpu < -1 )
|
||||||
|
selectedCpu = cpus.size() - 1;
|
||||||
|
else if ( selectedCpu >= cpus.size() )
|
||||||
|
selectedCpu = -1;
|
||||||
|
|
||||||
|
if ( selectedCpu == -1 && cpus.size() > 0 )
|
||||||
|
selectedCpu = 0;
|
||||||
|
|
||||||
|
if ( selectedCpu == -1 )
|
||||||
|
{
|
||||||
|
myName = "";
|
||||||
|
setCPU( null );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myName = cpus.get( selectedCpu ).myName;
|
||||||
|
setCPU( cpus.get( selectedCpu ).cpu );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -46,7 +46,9 @@ public enum GuiText
|
|||||||
|
|
||||||
InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern,
|
InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern,
|
||||||
|
|
||||||
InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint;
|
InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint,
|
||||||
|
|
||||||
|
NoCraftingJobs, CPUs;
|
||||||
|
|
||||||
String root;
|
String root;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import appeng.container.implementations.ContainerCondenser;
|
|||||||
import appeng.container.implementations.ContainerCraftAmount;
|
import appeng.container.implementations.ContainerCraftAmount;
|
||||||
import appeng.container.implementations.ContainerCraftConfirm;
|
import appeng.container.implementations.ContainerCraftConfirm;
|
||||||
import appeng.container.implementations.ContainerCraftingCPU;
|
import appeng.container.implementations.ContainerCraftingCPU;
|
||||||
|
import appeng.container.implementations.ContainerCraftingStatus;
|
||||||
import appeng.container.implementations.ContainerCraftingTerm;
|
import appeng.container.implementations.ContainerCraftingTerm;
|
||||||
import appeng.container.implementations.ContainerDrive;
|
import appeng.container.implementations.ContainerDrive;
|
||||||
import appeng.container.implementations.ContainerFormationPlane;
|
import appeng.container.implementations.ContainerFormationPlane;
|
||||||
@@ -161,7 +162,9 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
|
|
||||||
GUI_CRAFTING_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT),
|
GUI_CRAFTING_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT),
|
||||||
|
|
||||||
GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartMonitor.class, WORLD, SecurityPermissions.BUILD);
|
GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartMonitor.class, WORLD, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
|
GUI_CRAFTING_STATUS(ContainerCraftingStatus.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT);
|
||||||
|
|
||||||
private Class Tile;
|
private Class Tile;
|
||||||
private Class Gui;
|
private Class Gui;
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import appeng.api.config.FuzzyMode;
|
import appeng.api.config.FuzzyMode;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
import appeng.api.util.IConfigureableObject;
|
import appeng.api.util.IConfigureableObject;
|
||||||
|
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
import appeng.container.implementations.ContainerCellWorkbench;
|
import appeng.container.implementations.ContainerCellWorkbench;
|
||||||
import appeng.container.implementations.ContainerCraftConfirm;
|
import appeng.container.implementations.ContainerCraftConfirm;
|
||||||
import appeng.container.implementations.ContainerCraftingCPU;
|
import appeng.container.implementations.ContainerCraftingCPU;
|
||||||
|
import appeng.container.implementations.ContainerCraftingStatus;
|
||||||
import appeng.container.implementations.ContainerLevelEmitter;
|
import appeng.container.implementations.ContainerLevelEmitter;
|
||||||
import appeng.container.implementations.ContainerNetworkTool;
|
import appeng.container.implementations.ContainerNetworkTool;
|
||||||
import appeng.container.implementations.ContainerPatternTerm;
|
import appeng.container.implementations.ContainerPatternTerm;
|
||||||
@@ -56,6 +60,12 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
si.onWheel( is, Value.equals( "WheelUp" ) );
|
si.onWheel( is, Value.equals( "WheelUp" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus )
|
||||||
|
{
|
||||||
|
ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||||
|
qk.cycleCpu( Value.equals( "Next" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||||
{
|
{
|
||||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||||
@@ -198,6 +208,13 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
{
|
{
|
||||||
((AEBaseContainer) c).stringSync( Integer.parseInt( Name.substring( 8 ) ), Value );
|
((AEBaseContainer) c).stringSync( Integer.parseInt( Name.substring( 8 ) ), Value );
|
||||||
}
|
}
|
||||||
|
else if ( Name.equals( "CraftingStatus" ) && Value.equals( "Clear" ) )
|
||||||
|
{
|
||||||
|
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||||
|
if ( gs instanceof GuiCraftingCPU )
|
||||||
|
((GuiCraftingCPU) gs).clearItems();
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if ( c instanceof IConfigureableObject )
|
else if ( c instanceof IConfigureableObject )
|
||||||
{
|
{
|
||||||
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user