ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TexturedButton.java

65 lines
2.3 KiB
Java
Raw Normal View History

2015-12-04 18:14:03 +01:00
/*
2016-05-16 22:52:27 +02:00
* This file ("TexturedButton.java") is part of the Actually Additions mod for Minecraft.
2015-12-04 18:14:03 +01:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-12-04 18:14:03 +01:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-12-04 18:14:03 +01:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.booklet.button;
2015-12-04 18:14:03 +01:00
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
2015-12-04 18:14:03 +01:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
2015-12-04 18:14:03 +01:00
2016-05-19 20:05:12 +02:00
import javax.annotation.Nonnull;
2015-12-04 18:14:03 +01:00
import java.util.ArrayList;
import java.util.List;
public class TexturedButton extends GuiButton{
public int texturePosX;
public int texturePosY;
2016-05-19 20:05:12 +02:00
public final List textList = new ArrayList();
2015-12-04 18:14:03 +01:00
2015-12-19 10:30:39 +01:00
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
this(id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
}
2015-12-04 18:14:03 +01:00
@SuppressWarnings("unchecked")
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){
super(id, x, y, width, height, "");
this.texturePosX = texturePosX;
this.texturePosY = texturePosY;
this.textList.addAll(hoverTextList);
}
public void setTexturePos(int x, int y){
this.texturePosX = x;
this.texturePosY = y;
}
@Override
2016-05-19 20:05:12 +02:00
public void drawButton(@Nonnull Minecraft minecraft, int x, int y){
2015-12-04 18:14:03 +01:00
if(this.visible){
minecraft.getTextureManager().bindTexture(GuiBooklet.resLoc);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
int k = this.getHoverState(this.hovered);
2015-12-04 18:14:03 +01:00
if(k == 0){
k = 1;
}
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
2015-12-04 18:14:03 +01:00
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.texturePosX, this.texturePosY-this.height+k*this.height, this.width, this.height);
this.mouseDragged(minecraft, x, y);
}
}
}