2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
/**
|
2015-02-03 12:04:13 +01:00
|
|
|
*
|
2014-08-05 05:33:26 +02:00
|
|
|
*/
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IDefinitions;
|
|
|
|
import appeng.api.definitions.IParts;
|
2014-08-05 05:33:26 +02:00
|
|
|
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;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
public class GuiCraftingStatus extends GuiCraftingCPU
|
|
|
|
{
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
final ContainerCraftingStatus status;
|
2014-09-28 11:47:17 +02:00
|
|
|
GuiButton selectCPU;
|
2014-08-05 05:33:26 +02:00
|
|
|
|
|
|
|
GuiTabButton originalGuiBtn;
|
2015-01-03 02:53:14 +01:00
|
|
|
GuiBridge originalGui;
|
2014-08-05 05:33:26 +02:00
|
|
|
ItemStack myIcon = null;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public GuiCraftingStatus( InventoryPlayer inventoryPlayer, ITerminalHost te )
|
|
|
|
{
|
2014-08-05 05:33:26 +02:00
|
|
|
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
this.status = (ContainerCraftingStatus) this.inventorySlots;
|
|
|
|
Object target = this.status.getTarget();
|
|
|
|
final IDefinitions definitions = AEApi.instance().definitions();
|
|
|
|
final IParts parts = definitions.parts();
|
2014-08-05 05:33:26 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( target instanceof WirelessTerminalGuiObject )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.myIcon = wirelessTerminalStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( target instanceof PartTerminal )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.myIcon = stack;
|
|
|
|
}
|
|
|
|
this.originalGui = GuiBridge.GUI_ME;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( target instanceof PartCraftingTerminal )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.myIcon = stack;
|
|
|
|
}
|
|
|
|
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( target instanceof PartPatternTerminal )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.myIcon = stack;
|
|
|
|
}
|
|
|
|
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
protected void actionPerformed( GuiButton btn )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
|
|
|
|
|
|
|
boolean backwards = Mouse.isButtonDown( 1 );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( btn == this.selectCPU )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( IOException e )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( btn == this.originalGuiBtn )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.selectCPU = new GuiButton( 0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
2014-09-28 11:47:17 +02:00
|
|
|
// selectCPU.enabled = false;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.selectCPU );
|
2014-08-05 05:33:26 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myIcon != null )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), itemRender ) );
|
|
|
|
this.originalGuiBtn.hideEdge = 13;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
@Override
|
|
|
|
public void drawScreen( int mouseX, int mouseY, float btn )
|
|
|
|
{
|
|
|
|
this.updateCPUButtonText();
|
|
|
|
super.drawScreen( mouseX, mouseY, btn );
|
|
|
|
}
|
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
private void updateCPUButtonText()
|
|
|
|
{
|
|
|
|
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.status.myName.length() > 0 )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
String name = this.status.myName.substring( 0, Math.min( 20, this.status.myName.length() ) );
|
2014-08-05 05:33:26 +02:00
|
|
|
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
|
|
|
}
|
|
|
|
else
|
2015-01-03 02:53:14 +01:00
|
|
|
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.status.noCPU )
|
2014-08-05 05:33:26 +02:00
|
|
|
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.selectCPU.displayString = btnTextText;
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
protected String getGuiDisplayName( String in )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return in; // the cup name is on the button
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
}
|