ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/booklet/button/TrialsButton.java

41 lines
1.4 KiB
Java
Raw Normal View History

package de.ellpeck.actuallyadditions.common.booklet.button;
2017-02-18 00:54:58 +01:00
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.common.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.common.util.StringUtil;
2017-02-18 00:54:58 +01:00
import net.minecraft.client.Minecraft;
2019-05-02 09:10:29 +02:00
public class TrialsButton extends TexturedButton {
2017-02-18 00:54:58 +01:00
private final boolean isTrials;
2019-05-02 09:10:29 +02:00
public TrialsButton(GuiBooklet gui) {
super(GuiBooklet.RES_LOC_GADGETS, -152000, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16);
2017-02-18 00:54:58 +01:00
this.isTrials = gui.areTrialsOpened();
this.enabled = !this.isTrials;
}
@Override
2019-05-02 09:10:29 +02:00
public void drawButton(Minecraft minecraft, int x, int y, float f) {
super.drawButton(minecraft, x, y, f);
2017-02-18 00:54:58 +01:00
2019-05-02 09:10:29 +02:00
if (this.visible) {
if (this.hovered || this.isTrials) {
this.drawCenteredString(minecraft.fontRenderer, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialsButton.name"), this.x + (this.width - 8) / 2, this.y + (this.height - 8) / 2, 14737632);
2017-02-18 00:54:58 +01:00
}
}
}
@Override
2019-05-02 09:10:29 +02:00
protected int getHoverState(boolean mouseOver) {
if (mouseOver || this.isTrials) {
2017-02-18 00:54:58 +01:00
return 2;
2019-05-02 09:10:29 +02:00
} else if (!this.enabled) {
2017-02-18 00:54:58 +01:00
return 0;
2019-05-02 09:10:29 +02:00
} else {
2017-02-18 00:54:58 +01:00
return 1;
}
}
}