2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-01-23 17:28:12 +01:00
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
import org.lwjgl.input.Mouse;
|
2014-01-23 17:28:12 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.api.config.Settings;
|
2014-02-06 06:08:05 +01:00
|
|
|
import appeng.api.config.SortDir;
|
|
|
|
import appeng.api.config.SortOrder;
|
2014-01-23 20:02:48 +01:00
|
|
|
import appeng.api.implementations.guiobjects.INetworkTool;
|
2014-01-23 17:28:12 +01:00
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.client.gui.widgets.GuiImgButton;
|
2014-01-23 17:28:12 +01:00
|
|
|
import appeng.client.gui.widgets.GuiScrollbar;
|
2014-02-06 06:08:05 +01:00
|
|
|
import appeng.client.gui.widgets.ISortSource;
|
2014-01-23 17:28:12 +01:00
|
|
|
import appeng.client.me.ItemRepo;
|
|
|
|
import appeng.client.me.SlotME;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.container.implementations.ContainerNetworkStatus;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.core.AEConfig;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.localization.GuiText;
|
2014-01-23 17:28:12 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-06 06:08:05 +01:00
|
|
|
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
ItemRepo repo;
|
2014-03-06 06:45:14 +01:00
|
|
|
GuiImgButton units;
|
2014-01-23 17:28:12 +01:00
|
|
|
|
|
|
|
int rows = 4;
|
|
|
|
|
|
|
|
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
|
|
|
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
|
2014-03-06 06:45:14 +01:00
|
|
|
this.ySize = 153;
|
2014-01-23 17:28:12 +01:00
|
|
|
this.xSize = 195;
|
|
|
|
myScrollBar = new GuiScrollbar();
|
2014-02-06 06:08:05 +01:00
|
|
|
repo = new ItemRepo( myScrollBar, this );
|
2014-01-24 17:32:57 +01:00
|
|
|
repo.rowSize = 5;
|
2014-01-23 17:28:12 +01:00
|
|
|
}
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton btn)
|
|
|
|
{
|
|
|
|
super.actionPerformed( btn );
|
|
|
|
|
|
|
|
boolean backwards = Mouse.isButtonDown( 1 );
|
|
|
|
|
|
|
|
if ( btn == units )
|
|
|
|
{
|
|
|
|
AEConfig.instance.nextPowerUnit( backwards );
|
|
|
|
units.set( AEConfig.instance.selectedPowerUnit() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
|
|
|
|
|
|
|
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
|
|
|
buttonList.add( units );
|
|
|
|
}
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
public void postUpdate(List<IAEItemStack> list)
|
|
|
|
{
|
|
|
|
repo.clear();
|
|
|
|
|
|
|
|
for (IAEItemStack is : list)
|
|
|
|
repo.postUpdate( is );
|
|
|
|
|
|
|
|
repo.updateView();
|
|
|
|
setScrollBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setScrollBar()
|
|
|
|
{
|
2014-01-24 17:32:57 +01:00
|
|
|
int size = repo.size();
|
2014-01-23 17:28:12 +01:00
|
|
|
myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
|
2014-01-24 17:32:57 +01:00
|
|
|
myScrollBar.setRange( 0, (size + 4) / 5 - rows, 1 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
bindTexture( "guis/networkstatus.png" );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
|
|
|
}
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
int tooltip = -1;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
int gx = (width - xSize) / 2;
|
|
|
|
int gy = (height - ySize) / 2;
|
|
|
|
|
|
|
|
tooltip = -1;
|
|
|
|
|
|
|
|
for (int z = 0; z <= 4 * 5; z++)
|
|
|
|
{
|
|
|
|
int minX = gx + 14 + x * 31;
|
2014-01-24 17:32:57 +01:00
|
|
|
int minY = gy + 41 + y * 18;
|
2014-01-23 17:28:12 +01:00
|
|
|
|
|
|
|
if ( minX < mouse_x && minX + 28 > mouse_x )
|
|
|
|
{
|
|
|
|
if ( minY < mouse_y && minY + 20 > mouse_y )
|
|
|
|
{
|
|
|
|
tooltip = z;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
x++;
|
|
|
|
|
|
|
|
if ( x > 4 )
|
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.drawScreen( mouse_x, mouse_y, btn );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-01-23 17:28:12 +01:00
|
|
|
ContainerNetworkStatus ns = (ContainerNetworkStatus) inventorySlots;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
|
|
|
|
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
|
|
|
|
|
|
|
|
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
|
|
|
|
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
|
|
|
int sectionLength = 30;
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
int xo = 0 + 12;
|
|
|
|
int yo = 0 + 42;
|
2014-01-24 17:32:57 +01:00
|
|
|
int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
|
2014-01-23 17:28:12 +01:00
|
|
|
int viewEnd = viewStart + 5 * 4;
|
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
String ToolTip = "";
|
|
|
|
int toolPosX = 0;
|
|
|
|
int toolPosY = 0;
|
2014-01-23 17:28:12 +01:00
|
|
|
|
|
|
|
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
|
|
|
|
{
|
|
|
|
IAEItemStack refStack = repo.getRefrenceItem( z );
|
2014-01-24 17:32:57 +01:00
|
|
|
if ( refStack != null )
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glScaled( 0.5, 0.5, 0.5 );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
String str = Long.toString( refStack.getStackSize() );
|
|
|
|
if ( refStack.getStackSize() >= 10000 )
|
|
|
|
str = Long.toString( refStack.getStackSize() / 1000 ) + StatCollector.translateToLocal( "AppEng.Sizes.1000" );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
int w = fontRendererObj.getStringWidth( str );
|
|
|
|
fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2),
|
2014-01-24 17:32:57 +01:00
|
|
|
4210752 );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
int posX = x * sectionLength + xo + sectionLength - 18;
|
|
|
|
int posY = y * 18 + yo;
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
if ( tooltip == z - viewStart )
|
|
|
|
{
|
|
|
|
ToolTip = Platform.getItemDisplayName( repo.getItem( z ) );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
|
2014-02-16 08:33:49 +01:00
|
|
|
if ( refStack.getCountRequestable() > 0 )
|
2014-03-06 06:45:14 +01:00
|
|
|
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( refStack.getCountRequestable(), true ));
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
|
|
|
toolPosY = y * 18 + yo;
|
|
|
|
}
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
drawItem( posX, posY, repo.getItem( z ) );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
x++;
|
2014-01-23 17:28:12 +01:00
|
|
|
|
2014-01-24 17:32:57 +01:00
|
|
|
if ( x > 4 )
|
|
|
|
{
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
2014-01-23 17:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-01-24 17:32:57 +01:00
|
|
|
|
|
|
|
if ( tooltip >= 0 && ToolTip.length() > 0 )
|
|
|
|
{
|
|
|
|
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
|
|
|
drawTooltip( toolPosX, toolPosY + 10, 0, ToolTip );
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
}
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// @Override - NEI
|
|
|
|
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
|
|
|
{
|
|
|
|
if ( stack != null )
|
|
|
|
{
|
|
|
|
Slot s = getSlot( mousex, mousey );
|
|
|
|
if ( s instanceof SlotME )
|
|
|
|
{
|
|
|
|
IAEItemStack myStack = null;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
SlotME theSlotField = (SlotME) s;
|
|
|
|
myStack = theSlotField.getAEStack();
|
|
|
|
}
|
|
|
|
catch (Throwable _)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( myStack != null )
|
|
|
|
{
|
|
|
|
while (currenttip.size() > 1)
|
|
|
|
currenttip.remove( 1 );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return currenttip;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 17:28:12 +01:00
|
|
|
// Vanillia version...
|
|
|
|
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
|
|
|
{
|
|
|
|
Slot s = getSlot( x, y );
|
|
|
|
if ( s instanceof SlotME && stack != null )
|
|
|
|
{
|
|
|
|
IAEItemStack myStack = null;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
SlotME theSlotField = (SlotME) s;
|
|
|
|
myStack = theSlotField.getAEStack();
|
|
|
|
}
|
|
|
|
catch (Throwable _)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( myStack != null )
|
|
|
|
{
|
|
|
|
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
|
|
|
|
|
|
|
while (currenttip.size() > 1)
|
|
|
|
currenttip.remove( 1 );
|
|
|
|
|
|
|
|
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
|
2014-03-06 06:45:14 +01:00
|
|
|
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( myStack.getCountRequestable(), true ) );
|
2014-01-23 17:28:12 +01:00
|
|
|
|
|
|
|
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
|
|
|
}
|
|
|
|
}
|
2014-02-09 02:34:52 +01:00
|
|
|
// super.drawItemStackTooltip( stack, x, y );
|
2014-01-23 17:28:12 +01:00
|
|
|
}
|
2014-02-06 06:08:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Enum getSortBy()
|
|
|
|
{
|
|
|
|
return SortOrder.NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Enum getSortDir()
|
|
|
|
{
|
|
|
|
return SortDir.ASCENDING;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|