Applied-Energistics-2-tiler.../src/main/java/appeng/client/gui/AEBaseMEGui.java

147 lines
4.7 KiB
Java
Raw Normal View History

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-09-24 02:26:27 +02:00
package appeng.client.gui;
2014-09-24 02:26:27 +02:00
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
2015-12-24 02:07:03 +01:00
2014-09-24 02:26:27 +02:00
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
2014-09-24 02:26:27 +02:00
2014-09-24 02:26:27 +02:00
public abstract class AEBaseMEGui extends AEBaseGui
{
2015-09-30 14:24:40 +02:00
public AEBaseMEGui( final Container container )
{
2014-09-24 02:26:27 +02:00
super( container );
}
2015-09-30 14:24:40 +02:00
public List<String> handleItemTooltip( final ItemStack stack, final int mouseX, final int mouseY, final List<String> currentToolTip )
2014-09-24 02:26:27 +02:00
{
if( stack != null )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final Slot s = this.getSlot( mouseX, mouseY );
if( s instanceof SlotME )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
2014-09-24 02:26:27 +02:00
IAEItemStack myStack = null;
try
{
2015-09-30 14:24:40 +02:00
final SlotME theSlotField = (SlotME) s;
2014-09-24 02:26:27 +02:00
myStack = theSlotField.getAEStack();
}
2015-09-30 14:24:40 +02:00
catch( final Throwable ignore )
2014-09-24 02:26:27 +02:00
{
}
if( myStack != null )
2014-09-24 02:26:27 +02:00
{
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
{
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
}
2014-09-24 02:26:27 +02:00
if( myStack.getCountRequestable() > 0 )
{
final String local = ButtonToolTips.ItemsRequestable.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
}
2014-09-24 02:26:27 +02:00
}
else if( stack.stackSize > BigNumber || ( stack.stackSize > 1 && stack.isItemDamaged() ) )
2014-09-24 02:26:27 +02:00
{
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
2014-09-24 02:26:27 +02:00
}
}
}
return currentToolTip;
2014-09-24 02:26:27 +02:00
}
// Vanilla version...
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
@Override
2015-09-30 14:24:40 +02:00
protected void renderToolTip( final ItemStack stack, final int x, final int y )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final Slot s = this.getSlot( x, y );
if( s instanceof SlotME && stack != null )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
2014-09-24 02:26:27 +02:00
IAEItemStack myStack = null;
try
{
2015-09-30 14:24:40 +02:00
final SlotME theSlotField = (SlotME) s;
2014-09-24 02:26:27 +02:00
myStack = theSlotField.getAEStack();
}
2015-09-30 14:24:40 +02:00
catch( final Throwable ignore )
2014-09-24 02:26:27 +02:00
{
}
if( myStack != null )
2014-09-24 02:26:27 +02:00
{
@SuppressWarnings( "unchecked" )
2015-09-30 14:24:40 +02:00
final List<String> currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
2014-09-24 02:26:27 +02:00
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
2015-04-29 02:30:53 +02:00
{
currentToolTip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
if( myStack.getCountRequestable() > 0 )
2015-04-29 02:30:53 +02:00
{
currentToolTip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
this.drawTooltip( x, y, currentToolTip );
2014-09-24 02:26:27 +02:00
}
else if( stack.stackSize > BigNumber )
2014-09-24 02:26:27 +02:00
{
List<String> var4 = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
2014-09-24 02:26:27 +02:00
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
this.drawTooltip( x, y, var4 );
2014-09-24 02:26:27 +02:00
return;
}
}
super.renderToolTip( stack, x, y );
// super.drawItemStackTooltip( stack, x, y );
}
}