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-01-27 05:00:36 +01:00
|
|
|
package appeng.client.gui.widgets;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2017-04-12 16:10:13 +02:00
|
|
|
import appeng.client.texture.ExtraBlockTextures;
|
2014-01-27 05:00:36 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-04-12 16:10:13 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import org.lwjgl.opengl.GL12;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
public class GuiTabButton extends GuiButton implements ITooltip
|
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
private final RenderItem itemRenderer;
|
|
|
|
private final String message;
|
2015-10-08 15:42:42 +02:00
|
|
|
private int hideEdge = 0;
|
2014-11-28 04:36:46 +01:00
|
|
|
private int myIcon = -1;
|
|
|
|
private ItemStack myItem;
|
2014-08-05 05:33:26 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public GuiTabButton( final int x, final int y, final int ico, final String message, final RenderItem ir )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
super( 0, 0, 16, "" );
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
this.xPosition = x;
|
|
|
|
this.yPosition = y;
|
|
|
|
this.width = 22;
|
|
|
|
this.height = 22;
|
|
|
|
this.myIcon = ico;
|
|
|
|
this.message = message;
|
2014-01-27 05:00:36 +01:00
|
|
|
this.itemRenderer = ir;
|
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
/**
|
|
|
|
* Using itemstack as an icon
|
|
|
|
*
|
2017-04-12 16:10:13 +02:00
|
|
|
* @param x x pos of button
|
|
|
|
* @param y y pos of button
|
|
|
|
* @param ico used icon
|
2014-11-28 04:36:46 +01:00
|
|
|
* @param message mouse over message
|
2017-04-12 16:10:13 +02:00
|
|
|
* @param ir renderer
|
2014-11-28 04:36:46 +01:00
|
|
|
*/
|
2015-09-25 23:10:56 +02:00
|
|
|
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final RenderItem ir )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
super( 0, 0, 16, "" );
|
|
|
|
this.xPosition = x;
|
|
|
|
this.yPosition = y;
|
|
|
|
this.width = 22;
|
|
|
|
this.height = 22;
|
|
|
|
this.myItem = ico;
|
|
|
|
this.message = message;
|
|
|
|
this.itemRenderer = ir;
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void drawButton( final Minecraft minecraft, final int x, final int y )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.visible )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
2014-11-28 04:36:46 +01:00
|
|
|
minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
|
|
|
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
2014-08-05 05:33:26 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myIcon >= 0 )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final int uv_y = (int) Math.floor( this.myIcon / 16 );
|
2014-11-28 04:36:46 +01:00
|
|
|
uv_x = this.myIcon - uv_y * 16;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2014-08-05 05:33:26 +02:00
|
|
|
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
this.mouseDragged( minecraft, x, y );
|
2014-01-27 05:00:36 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myItem != null )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
this.zLevel = 100.0F;
|
2014-11-28 04:36:46 +01:00
|
|
|
this.itemRenderer.zLevel = 100.0F;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
|
|
|
GL11.glEnable( GL11.GL_LIGHTING );
|
|
|
|
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
|
|
|
RenderHelper.enableGUIStandardItemLighting();
|
2015-09-25 23:10:56 +02:00
|
|
|
final FontRenderer fontrenderer = minecraft.fontRenderer;
|
2014-11-28 04:36:46 +01:00
|
|
|
this.itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, minecraft.renderEngine, this.myItem, offsetX + this.xPosition + 3, this.yPosition + 3 );
|
2014-01-27 05:00:36 +01:00
|
|
|
GL11.glDisable( GL11.GL_LIGHTING );
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
this.itemRenderer.zLevel = 0.0F;
|
2014-01-27 05:00:36 +01:00
|
|
|
this.zLevel = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-28 04:36:46 +01:00
|
|
|
public String getMessage()
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return this.message;
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int xPos()
|
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return this.xPosition;
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int yPos()
|
|
|
|
{
|
2014-11-28 04:36:46 +01:00
|
|
|
return this.yPosition;
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getWidth()
|
|
|
|
{
|
|
|
|
return 22;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getHeight()
|
|
|
|
{
|
|
|
|
return 22;
|
|
|
|
}
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
@Override
|
|
|
|
public boolean isVisible()
|
|
|
|
{
|
|
|
|
return this.visible;
|
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
|
|
|
|
public int getHideEdge()
|
|
|
|
{
|
|
|
|
return this.hideEdge;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHideEdge( final int hideEdge )
|
|
|
|
{
|
|
|
|
this.hideEdge = hideEdge;
|
|
|
|
}
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|