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-06-26 03:49:37 +02:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-06-28 07:20:12 +02:00
|
|
|
import java.io.IOException;
|
2014-06-27 04:47:26 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
2014-06-28 07:20:12 +02:00
|
|
|
import java.util.LinkedList;
|
2014-06-26 03:49:37 +02:00
|
|
|
import java.util.List;
|
2015-05-19 16:07:02 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
import com.google.common.base.Joiner;
|
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
import org.apache.commons.lang3.time.DurationFormatUtils;
|
2014-11-28 04:36:46 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-06-26 03:49:37 +02:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
2014-06-27 04:47:26 +02:00
|
|
|
import appeng.api.AEApi;
|
2014-06-26 03:49:37 +02:00
|
|
|
import appeng.api.config.SortDir;
|
|
|
|
import appeng.api.config.SortOrder;
|
|
|
|
import appeng.api.config.ViewItems;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2014-06-27 04:47:26 +02:00
|
|
|
import appeng.api.storage.data.IItemList;
|
2015-01-31 16:02:11 +01:00
|
|
|
import appeng.api.util.AEColor;
|
2014-06-26 03:49:37 +02:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
|
|
|
import appeng.client.gui.widgets.GuiScrollbar;
|
|
|
|
import appeng.client.gui.widgets.ISortSource;
|
|
|
|
import appeng.container.implementations.ContainerCraftingCPU;
|
2015-02-27 13:33:53 +01:00
|
|
|
import appeng.core.AEConfig;
|
2014-06-28 07:20:12 +02:00
|
|
|
import appeng.core.AELog;
|
2014-06-26 03:49:37 +02:00
|
|
|
import appeng.core.localization.GuiText;
|
2014-06-28 07:20:12 +02:00
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
|
|
|
import appeng.core.sync.packets.PacketValueConfig;
|
2014-06-26 03:49:37 +02:00
|
|
|
import appeng.util.Platform;
|
2015-05-19 16:07:02 +02:00
|
|
|
import appeng.util.ReadableNumberConverter;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-06-26 03:49:37 +02:00
|
|
|
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
private final static int GUI_HEIGHT = 184;
|
|
|
|
private final static int GUI_WIDTH = 238;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
private final static int DISPLAYED_ROWS = 6;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
private final static int TEXT_COLOR = 0x404040;
|
|
|
|
private final static int BACKGROUND_ALPHA = 0x5A000000;
|
2014-06-27 04:47:26 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
private final static int SECTION_LENGTH = 67;
|
|
|
|
|
|
|
|
private final static int SCROLLBAR_TOP = 19;
|
|
|
|
private final static int SCROLLBAR_LEFT = 218;
|
|
|
|
private final static int SCROLLBAR_HEIGHT = 137;
|
|
|
|
|
|
|
|
private final static int CANCEL_LEFT_OFFSET = 163;
|
|
|
|
private final static int CANCEL_TOP_OFFSET = 25;
|
|
|
|
private final static int CANCEL_HEIGHT = 20;
|
|
|
|
private final static int CANCEL_WIDTH = 50;
|
|
|
|
|
|
|
|
private final static int ETA_TOP_OFFSET = 165;
|
|
|
|
private final static int ETA_LEFT_OFFSET = 8;
|
|
|
|
|
|
|
|
private final static int ITEMSTACK_LEFT_OFFSET = 9;
|
|
|
|
private final static int ITEMSTACK_TOP_OFFSET = 22;
|
|
|
|
|
|
|
|
private final ContainerCraftingCPU craftingCpu;
|
|
|
|
|
|
|
|
private IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
|
|
|
private IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
|
|
|
|
private IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
|
|
|
|
|
|
|
private List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
|
|
|
private GuiButton cancel;
|
|
|
|
private int tooltip = -1;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public GuiCraftingCPU( InventoryPlayer inventoryPlayer, Object te )
|
2014-08-05 05:33:26 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
protected GuiCraftingCPU( ContainerCraftingCPU container )
|
|
|
|
{
|
2014-08-05 05:33:26 +02:00
|
|
|
super( container );
|
2015-05-19 16:07:02 +02:00
|
|
|
this.craftingCpu = container;
|
|
|
|
this.ySize = GUI_HEIGHT;
|
|
|
|
this.xSize = GUI_WIDTH;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myScrollBar = new GuiScrollbar();
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public void clearItems()
|
|
|
|
{
|
|
|
|
this.storage = AEApi.instance().storage().createItemList();
|
|
|
|
this.active = AEApi.instance().storage().createItemList();
|
|
|
|
this.pending = AEApi.instance().storage().createItemList();
|
|
|
|
this.visual = new ArrayList<IAEItemStack>();
|
2014-08-05 05:33:26 +02:00
|
|
|
}
|
|
|
|
|
2014-06-26 03:49:37 +02:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
protected void actionPerformed( GuiButton btn )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.cancel == btn )
|
2014-06-28 07:20:12 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( IOException e )
|
2014-06-28 07:20:12 +02:00
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
}
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setScrollBar();
|
2015-05-19 16:07:02 +02:00
|
|
|
this.cancel = new GuiButton( 0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal() );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.cancel );
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setScrollBar()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
int size = this.visual.size();
|
2014-06-27 04:47:26 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
this.myScrollBar.setTop( SCROLLBAR_TOP ).setLeft( SCROLLBAR_LEFT ).setHeight( SCROLLBAR_HEIGHT );
|
|
|
|
this.myScrollBar.setRange( 0, ( size + 2 ) / 3 - DISPLAYED_ROWS, 1 );
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-05-08 23:25:19 +02:00
|
|
|
public void drawScreen( int mouseX, int mouseY, float btn )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cancel.enabled = !this.visual.isEmpty();
|
2014-08-05 05:33:26 +02:00
|
|
|
|
2014-06-26 03:49:37 +02:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
final int gx = ( this.width - this.xSize ) / 2;
|
|
|
|
final int gy = ( this.height - this.ySize ) / 2;
|
|
|
|
final int offY = 23;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tooltip = -1;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = 0; z <= 4 * 5; z++ )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
int minX = gx + 9 + x * 67;
|
2014-09-28 11:47:17 +02:00
|
|
|
int minY = gy + 22 + y * offY;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
if( minX < mouseX && minX + 67 > mouseX )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2015-05-08 23:25:19 +02:00
|
|
|
if( minY < mouseY && minY + offY - 2 > mouseY )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tooltip = z;
|
2014-06-26 03:49:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x++;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( x > 2 )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
super.drawScreen( mouseX, mouseY, btn );
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
|
|
|
|
|
|
|
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, TEXT_COLOR );
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
if( this.craftingCpu.eta > 0 )
|
|
|
|
{
|
|
|
|
final String etaText = this.getGuiDisplayName( GuiText.ETA.getLocal() );
|
|
|
|
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.craftingCpu.eta, TimeUnit.NANOSECONDS );
|
|
|
|
final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, this.getGuiDisplayName( GuiText.ETAFormat.getLocal() ) );
|
|
|
|
this.fontRendererObj.drawString( String.format( etaText, etaTimeText ), ETA_LEFT_OFFSET, ETA_TOP_OFFSET, TEXT_COLOR );
|
|
|
|
}
|
2014-06-26 03:49:37 +02:00
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2015-05-19 16:07:02 +02:00
|
|
|
final int viewStart = this.myScrollBar.getCurrentScroll() * 3;
|
|
|
|
final int viewEnd = viewStart + 3 * 6;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2014-06-28 07:20:12 +02:00
|
|
|
String dspToolTip = "";
|
2014-09-28 22:20:14 +02:00
|
|
|
List<String> lineList = new LinkedList<String>();
|
2014-06-26 03:49:37 +02:00
|
|
|
int toolPosX = 0;
|
|
|
|
int toolPosY = 0;
|
|
|
|
|
2014-06-28 07:20:12 +02:00
|
|
|
int offY = 23;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( refStack != null )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glScaled( 0.5, 0.5, 0.5 );
|
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
|
|
|
final IAEItemStack activeStack = this.active.findPrecise( refStack );
|
|
|
|
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
|
|
|
int lines = 0;
|
2015-03-26 12:13:34 +01:00
|
|
|
boolean active = false;
|
|
|
|
boolean scheduled = false;
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( stored != null && stored.getStackSize() > 0 )
|
2015-01-31 16:02:11 +01:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lines++;
|
2015-01-31 16:02:11 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( activeStack != null && activeStack.getStackSize() > 0 )
|
2015-01-31 16:02:11 +01:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lines++;
|
2015-01-31 16:02:11 +01:00
|
|
|
active = true;
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
2015-01-31 16:02:11 +01:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lines++;
|
2015-01-31 16:02:11 +01:00
|
|
|
scheduled = true;
|
|
|
|
}
|
2015-02-27 13:33:53 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
|
2015-01-31 16:02:11 +01:00
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
int bgColor = ( active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant ) | BACKGROUND_ALPHA;
|
|
|
|
int startX = ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET ) * 2;
|
|
|
|
int startY = ( ( y * offY + ITEMSTACK_TOP_OFFSET ) - 3 ) * 2;
|
|
|
|
drawRect( startX, startY, startX + ( SECTION_LENGTH * 2 ), startY + ( offY * 2 ) - 2, bgColor );
|
2015-01-31 16:02:11 +01:00
|
|
|
}
|
2015-02-27 13:33:53 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
int negY = ( ( lines - 1 ) * 5 ) / 2;
|
2014-06-28 07:20:12 +02:00
|
|
|
int downY = 0;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( stored != null && stored.getStackSize() > 0 )
|
2014-06-28 07:20:12 +02:00
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
final String str = GuiText.Stored.getLocal() + ": " + converter.toWideReadableForm( stored.getStackSize() );
|
2014-12-29 15:13:47 +01:00
|
|
|
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
2015-05-19 16:07:02 +02:00
|
|
|
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.tooltip == z - viewStart )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-06-28 07:20:12 +02:00
|
|
|
|
|
|
|
downY += 5;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( activeStack != null && activeStack.getStackSize() > 0 )
|
2014-06-28 07:20:12 +02:00
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
final String str = GuiText.Crafting.getLocal() + ": " + converter.toWideReadableForm( activeStack.getStackSize() );
|
|
|
|
final int w = 4 + this.fontRendererObj.getStringWidth( str );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.tooltip == z - viewStart )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-06-28 07:20:12 +02:00
|
|
|
|
|
|
|
downY += 5;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
2014-06-28 07:20:12 +02:00
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
final String str = GuiText.Scheduled.getLocal() + ": " + converter.toWideReadableForm( pendingStack.getStackSize() );
|
|
|
|
final int w = 4 + this.fontRendererObj.getStringWidth( str );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
2014-06-28 07:20:12 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.tooltip == z - viewStart )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-06-28 07:20:12 +02:00
|
|
|
}
|
2014-06-26 03:49:37 +02:00
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
2015-05-19 16:07:02 +02:00
|
|
|
int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
|
|
|
int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2014-06-27 04:47:26 +02:00
|
|
|
ItemStack is = refStack.copy().getItemStack();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.tooltip == z - viewStart )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
2014-06-28 07:20:12 +02:00
|
|
|
dspToolTip = Platform.getItemDisplayName( is );
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( lineList.size() > 0 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
toolPosX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
|
|
|
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.drawItem( posX, posY, is );
|
2014-06-26 03:49:37 +02:00
|
|
|
|
|
|
|
x++;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( x > 2 )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
|
2014-06-26 03:49:37 +02:00
|
|
|
{
|
|
|
|
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
2014-06-26 03:49:37 +02:00
|
|
|
GL11.glPopAttrib();
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
|
|
|
|
{
|
|
|
|
this.bindTexture( "guis/craftingcpu.png" );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void postUpdate( List<IAEItemStack> list, byte ref )
|
|
|
|
{
|
|
|
|
switch( ref )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for( IAEItemStack l : list )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.handleInput( this.storage, l );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
for( IAEItemStack l : list )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.handleInput( this.active, l );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
for( IAEItemStack l : list )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.handleInput( this.pending, l );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( IAEItemStack l : list )
|
|
|
|
{
|
|
|
|
long amt = this.getTotal( l );
|
|
|
|
|
|
|
|
if( amt <= 0 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.deleteVisualStack( l );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
IAEItemStack is = this.findVisualStack( l );
|
|
|
|
is.setStackSize( amt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setScrollBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleInput( IItemList<IAEItemStack> s, IAEItemStack l )
|
|
|
|
{
|
|
|
|
IAEItemStack a = s.findPrecise( l );
|
|
|
|
|
|
|
|
if( l.getStackSize() <= 0 )
|
|
|
|
{
|
|
|
|
if( a != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
a.reset();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( a == null )
|
|
|
|
{
|
|
|
|
s.add( l.copy() );
|
|
|
|
a = s.findPrecise( l );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( a != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
a.setStackSize( l.getStackSize() );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private long getTotal( IAEItemStack is )
|
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
final IAEItemStack a = this.storage.findPrecise( is );
|
|
|
|
final IAEItemStack b = this.active.findPrecise( is );
|
|
|
|
final IAEItemStack c = this.pending.findPrecise( is );
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
long total = 0;
|
|
|
|
|
|
|
|
if( a != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
total += a.getStackSize();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
if( b != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
total += b.getStackSize();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
if( c != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
total += c.getStackSize();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void deleteVisualStack( IAEItemStack l )
|
|
|
|
{
|
2015-05-19 16:07:02 +02:00
|
|
|
final Iterator<IAEItemStack> i = this.visual.iterator();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
while( i.hasNext() )
|
|
|
|
{
|
|
|
|
IAEItemStack o = i.next();
|
|
|
|
if( o.equals( l ) )
|
|
|
|
{
|
|
|
|
i.remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-26 03:49:37 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
private IAEItemStack findVisualStack( IAEItemStack l )
|
|
|
|
{
|
|
|
|
for( IAEItemStack o : this.visual )
|
|
|
|
{
|
|
|
|
if( o.equals( l ) )
|
|
|
|
{
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 16:07:02 +02:00
|
|
|
final IAEItemStack stack = l.copy();
|
2015-04-03 08:54:31 +02:00
|
|
|
this.visual.add( stack );
|
2015-05-19 16:07:02 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
return stack;
|
2014-06-26 03:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Enum getSortBy()
|
|
|
|
{
|
|
|
|
return SortOrder.NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Enum getSortDir()
|
|
|
|
{
|
|
|
|
return SortDir.ASCENDING;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Enum getSortDisplay()
|
|
|
|
{
|
|
|
|
return ViewItems.ALL;
|
|
|
|
}
|
|
|
|
}
|