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-18 08:23:37 +02:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
import java.io.IOException;
|
2014-06-28 22:18:36 +02:00
|
|
|
import java.text.NumberFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import com.google.common.base.Joiner;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-06-28 22:18:36 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
import appeng.api.AEApi;
|
2014-06-18 08:23:37 +02:00
|
|
|
import appeng.api.storage.ITerminalHost;
|
2014-06-28 22:18:36 +02:00
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IItemList;
|
2014-06-18 08:23:37 +02:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
2014-06-28 22:18:36 +02:00
|
|
|
import appeng.client.gui.widgets.GuiScrollbar;
|
2014-06-18 08:23:37 +02:00
|
|
|
import appeng.container.implementations.ContainerCraftConfirm;
|
2014-06-29 11:06:07 +02:00
|
|
|
import appeng.core.AELog;
|
2014-06-18 08:23:37 +02:00
|
|
|
import appeng.core.localization.GuiText;
|
2014-06-29 11:06:07 +02:00
|
|
|
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;
|
2014-06-28 22:18:36 +02:00
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
public class GuiCraftConfirm extends AEBaseGui
|
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final ContainerCraftConfirm ccc;
|
2014-07-11 06:46:51 +02:00
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final int rows = 5;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
|
|
|
final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
|
|
|
final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
GuiBridge OriginalGui;
|
|
|
|
|
|
|
|
boolean isAutoStart()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return ((ContainerCraftConfirm) this.inventorySlots).autoStart;
|
2014-06-29 11:06:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean isSimulation()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return ((ContainerCraftConfirm) this.inventorySlots).simulation;
|
2014-06-29 11:06:07 +02:00
|
|
|
}
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
|
|
|
super( new ContainerCraftConfirm( inventoryPlayer, te ) );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.xSize = 238;
|
|
|
|
this.ySize = 206;
|
|
|
|
this.myScrollBar = new GuiScrollbar();
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
|
2014-07-11 06:46:51 +02:00
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
if ( te instanceof WirelessTerminalGuiObject )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
2014-06-29 11:06:07 +02:00
|
|
|
|
|
|
|
if ( te instanceof PartTerminal )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.OriginalGui = GuiBridge.GUI_ME;
|
2014-06-29 11:06:07 +02:00
|
|
|
|
|
|
|
if ( te instanceof PartCraftingTerminal )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
2014-06-29 11:06:07 +02:00
|
|
|
|
|
|
|
if ( te instanceof PartPatternTerminal )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
GuiButton cancel;
|
|
|
|
GuiButton start;
|
2014-09-28 11:47:17 +02:00
|
|
|
GuiButton selectCPU;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal() );
|
|
|
|
this.start.enabled = false;
|
|
|
|
this.buttonList.add( this.start );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.selectCPU = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
|
2014-06-28 22:18:36 +02:00
|
|
|
+ GuiText.Automatic );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.selectCPU.enabled = false;
|
|
|
|
this.buttonList.add( this.selectCPU );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.OriginalGui != null )
|
|
|
|
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.buttonList.add( this.cancel );
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
|
|
|
|
2014-07-11 06:46:51 +02:00
|
|
|
private void updateCPUButtonText()
|
|
|
|
{
|
2014-09-10 18:01:43 +02:00
|
|
|
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
2014-07-16 05:26:12 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.ccc.myName.length() > 0 )
|
2014-07-16 05:26:12 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
String name = this.ccc.myName.substring( 0, Math.min( 20, this.ccc.myName.length() ) );
|
2014-07-16 05:26:12 +02:00
|
|
|
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
|
|
|
}
|
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.selectedCpu;
|
2014-07-16 05:26:12 +02:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.ccc.noCPU )
|
2014-07-11 06:46:51 +02:00
|
|
|
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.selectCPU.displayString = btnTextText;
|
2014-07-11 06:46:51 +02:00
|
|
|
}
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton btn)
|
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-07-11 06:46:51 +02:00
|
|
|
boolean backwards = Mouse.isButtonDown( 1 );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.selectCPU )
|
2014-07-11 06:46:51 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.cancel )
|
2014-06-29 11:06:07 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
|
2014-06-29 11:06:07 +02:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == this.start )
|
2014-06-29 11:06:07 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
|
|
|
}
|
|
|
|
catch (Throwable e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
private long getTotal(IAEItemStack is)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack a = this.storage.findPrecise( is );
|
|
|
|
IAEItemStack c = this.pending.findPrecise( is );
|
|
|
|
IAEItemStack m = this.missing.findPrecise( is );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
long total = 0;
|
|
|
|
|
|
|
|
if ( a != null )
|
|
|
|
total += a.getStackSize();
|
|
|
|
|
|
|
|
if ( c != null )
|
|
|
|
total += c.getStackSize();
|
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
if ( m != null )
|
|
|
|
total += m.getStackSize();
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void postUpdate(List<IAEItemStack> list, byte ref)
|
|
|
|
{
|
|
|
|
switch (ref)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (IAEItemStack l : list)
|
2014-12-29 15:13:47 +01:00
|
|
|
this.handleInput( this.storage, l );
|
2014-06-28 22:18:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
for (IAEItemStack l : list)
|
2014-12-29 15:13:47 +01:00
|
|
|
this.handleInput( this.pending, l );
|
2014-06-28 22:18:36 +02:00
|
|
|
break;
|
2014-06-29 11:06:07 +02:00
|
|
|
|
|
|
|
case 2:
|
|
|
|
for (IAEItemStack l : list)
|
2014-12-29 15:13:47 +01:00
|
|
|
this.handleInput( this.missing, l );
|
2014-06-29 11:06:07 +02:00
|
|
|
break;
|
2014-06-28 22:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (IAEItemStack l : list)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
long amt = this.getTotal( l );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
if ( amt <= 0 )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.deleteVisualStack( l );
|
2014-06-28 22:18:36 +02:00
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack is = this.findVisualStack( l );
|
2014-06-28 22:18:36 +02:00
|
|
|
is.setStackSize( amt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setScrollBar();
|
2014-06-28 22:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
|
|
|
|
{
|
|
|
|
IAEItemStack a = s.findPrecise( l );
|
|
|
|
|
|
|
|
if ( l.getStackSize() <= 0 )
|
|
|
|
{
|
|
|
|
if ( a != null )
|
|
|
|
a.reset();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( a == null )
|
|
|
|
{
|
|
|
|
s.add( l.copy() );
|
|
|
|
a = s.findPrecise( l );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( a != null )
|
|
|
|
a.setStackSize( l.getStackSize() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private IAEItemStack findVisualStack(IAEItemStack l)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
for (IAEItemStack o : this.visual)
|
2014-06-28 22:18:36 +02:00
|
|
|
{
|
|
|
|
if ( o.equals( l ) )
|
2014-09-29 09:26:35 +02:00
|
|
|
{
|
2014-06-28 22:18:36 +02:00
|
|
|
return o;
|
2014-09-29 09:26:35 +02:00
|
|
|
}
|
2014-06-28 22:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IAEItemStack stack = l.copy();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.visual.add( stack );
|
2014-06-28 22:18:36 +02:00
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void deleteVisualStack(IAEItemStack l)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Iterator<IAEItemStack> i = this.visual.iterator();
|
2014-06-28 22:18:36 +02:00
|
|
|
while (i.hasNext())
|
|
|
|
{
|
|
|
|
IAEItemStack o = i.next();
|
|
|
|
if ( o.equals( l ) )
|
|
|
|
{
|
|
|
|
i.remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setScrollBar()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
int size = this.visual.size();
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
|
|
|
|
this.myScrollBar.setRange( 0, (size + 2) / 3 - this.rows, 1 );
|
2014-06-28 22:18:36 +02:00
|
|
|
}
|
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
@Override
|
|
|
|
protected void keyTyped(char character, int key)
|
|
|
|
{
|
|
|
|
if ( !this.checkHotbarKeys( key ) )
|
|
|
|
{
|
|
|
|
if ( key == 28 )
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.actionPerformed( this.start );
|
2014-06-29 11:06:07 +02:00
|
|
|
}
|
|
|
|
super.keyTyped( character, key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
@Override
|
|
|
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setScrollBar();
|
|
|
|
this.bindTexture( "guis/craftingreport.png" );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
int tooltip = -1;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
2014-06-18 08:23:37 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateCPUButtonText();
|
2014-07-11 06:46:51 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.start.enabled = !(this.ccc.noCPU || this.isSimulation());
|
|
|
|
this.selectCPU.enabled = !this.isSimulation();
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
int gx = (this.width - this.xSize) / 2;
|
|
|
|
int gy = (this.height - this.ySize) / 2;
|
2014-09-28 11:47:17 +02:00
|
|
|
int offY = 23;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tooltip = -1;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
for (int z = 0; z <= 4 * 5; z++)
|
|
|
|
{
|
|
|
|
int minX = gx + 9 + x * 67;
|
2014-09-28 11:47:17 +02:00
|
|
|
int minY = gy + 22 + y * offY;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
if ( minX < mouse_x && minX + 67 > mouse_x )
|
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
if ( minY < mouse_y && minY + offY - 2 > mouse_y )
|
2014-06-28 22:18:36 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tooltip = z;
|
2014-06-28 22:18:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
x++;
|
|
|
|
|
|
|
|
if ( x > 2 )
|
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.drawScreen( mouse_x, mouse_y, btn );
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
long BytesUsed = this.ccc.bytesUsed;
|
2014-06-28 22:18:36 +02:00
|
|
|
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
|
2014-11-28 04:36:46 +01:00
|
|
|
String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
String dsp = null;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.isSimulation() )
|
2014-06-29 11:06:07 +02:00
|
|
|
dsp = GuiText.Simulation.getLocal();
|
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
dsp = this.ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + this.ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.cpuCoProcessors)
|
2014-06-29 11:06:07 +02:00
|
|
|
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
int offset = (219 - this.fontRendererObj.getStringWidth( dsp )) / 2;
|
|
|
|
this.fontRendererObj.drawString( dsp, offset, 165, 4210752 );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
int sectionLength = 67;
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2014-10-09 21:12:43 +02:00
|
|
|
int xo = 9;
|
|
|
|
int yo = 22;
|
2014-12-29 15:13:47 +01:00
|
|
|
int viewStart = this.myScrollBar.getCurrentScroll() * 3;
|
|
|
|
int viewEnd = viewStart + 3 * this.rows;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
String dspToolTip = "";
|
2014-09-28 22:20:14 +02:00
|
|
|
List<String> lineList = new LinkedList<String>();
|
2014-06-28 22:18:36 +02:00
|
|
|
int toolPosX = 0;
|
|
|
|
int toolPosY = 0;
|
|
|
|
|
|
|
|
int offY = 23;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++)
|
2014-06-28 22:18:36 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
2014-06-28 22:18:36 +02:00
|
|
|
if ( refStack != null )
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glScaled( 0.5, 0.5, 0.5 );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack stored = this.storage.findPrecise( refStack );
|
|
|
|
IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
|
|
|
IAEItemStack missingStack = this.missing.findPrecise( refStack );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
int lines = 0;
|
|
|
|
|
|
|
|
if ( stored != null && stored.getStackSize() > 0 )
|
|
|
|
lines++;
|
|
|
|
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
|
|
|
lines++;
|
2014-06-29 11:06:07 +02:00
|
|
|
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
|
|
|
lines++;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
int negY = ((lines - 1) * 5) / 2;
|
|
|
|
int downY = 0;
|
2014-08-01 03:22:24 +02:00
|
|
|
boolean red = false;
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
if ( stored != null && stored.getStackSize() > 0 )
|
|
|
|
{
|
|
|
|
String str = Long.toString( stored.getStackSize() );
|
|
|
|
if ( stored.getStackSize() >= 10000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
|
2014-06-28 22:18:36 +02:00
|
|
|
if ( stored.getStackSize() >= 10000000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
str = GuiText.FromStorage.getLocal() + ": " + str;
|
2014-12-29 15:13:47 +01:00
|
|
|
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
|
|
|
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
2014-09-28 20:56:16 +02:00
|
|
|
+ 6 - negY + downY) * 2, 4210752 );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tooltip == z - viewStart )
|
2014-06-28 22:18:36 +02:00
|
|
|
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
|
|
|
|
|
|
|
downY += 5;
|
|
|
|
}
|
|
|
|
|
2014-06-29 11:06:07 +02:00
|
|
|
if ( missingStack != null && missingStack.getStackSize() > 0 )
|
|
|
|
{
|
|
|
|
String str = Long.toString( missingStack.getStackSize() );
|
|
|
|
if ( missingStack.getStackSize() >= 10000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k';
|
2014-06-29 11:06:07 +02:00
|
|
|
if ( missingStack.getStackSize() >= 10000000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm';
|
2014-06-29 11:06:07 +02:00
|
|
|
|
|
|
|
str = GuiText.Missing.getLocal() + ": " + str;
|
2014-12-29 15:13:47 +01:00
|
|
|
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
|
|
|
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
2014-09-28 20:56:16 +02:00
|
|
|
+ 6 - negY + downY) * 2, 4210752 );
|
2014-06-29 11:06:07 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tooltip == z - viewStart )
|
2014-06-29 11:06:07 +02:00
|
|
|
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
|
|
|
|
|
2014-08-01 03:22:24 +02:00
|
|
|
red = true;
|
2014-06-29 11:06:07 +02:00
|
|
|
downY += 5;
|
|
|
|
}
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
|
|
|
{
|
|
|
|
String str = Long.toString( pendingStack.getStackSize() );
|
|
|
|
if ( pendingStack.getStackSize() >= 10000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
|
2014-06-28 22:18:36 +02:00
|
|
|
if ( pendingStack.getStackSize() >= 10000000 )
|
2014-11-28 04:36:46 +01:00
|
|
|
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
str = GuiText.ToCraft.getLocal() + ": " + str;
|
2014-12-29 15:13:47 +01:00
|
|
|
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
|
|
|
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
2014-09-28 20:56:16 +02:00
|
|
|
+ 6 - negY + downY) * 2, 4210752 );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tooltip == z - viewStart )
|
2014-06-28 22:18:36 +02:00
|
|
|
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
|
|
|
int posY = y * offY + yo;
|
|
|
|
|
|
|
|
ItemStack is = refStack.copy().getItemStack();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tooltip == z - viewStart )
|
2014-06-28 22:18:36 +02:00
|
|
|
{
|
|
|
|
dspToolTip = Platform.getItemDisplayName( is );
|
|
|
|
|
|
|
|
if ( lineList.size() > 0 )
|
2014-11-28 04:36:46 +01:00
|
|
|
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
|
|
|
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
|
|
|
toolPosY = y * offY + yo;
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.drawItem( posX, posY, is );
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-08-01 03:22:24 +02:00
|
|
|
if ( red )
|
|
|
|
{
|
|
|
|
int startX = x * (1 + sectionLength) + xo;
|
|
|
|
int startY = posY - 4;
|
|
|
|
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
|
|
|
|
}
|
|
|
|
|
2014-06-28 22:18:36 +02:00
|
|
|
x++;
|
|
|
|
|
|
|
|
if ( x > 2 )
|
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.tooltip >= 0 && dspToolTip.length() > 0 )
|
2014-06-28 22:18:36 +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-28 22:18:36 +02:00
|
|
|
GL11.glPopAttrib();
|
|
|
|
}
|
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|
2014-06-28 22:18:36 +02:00
|
|
|
|
2014-06-18 08:23:37 +02:00
|
|
|
}
|