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

53 lines
1.8 KiB
Java
Raw Normal View History

2017-02-18 00:54:58 +01:00
/*
* This file ("TrialsButton.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.button;
2018-05-10 11:38:58 +02:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
2017-02-18 00:54:58 +01:00
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button.IPressable;
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;
2021-04-19 21:20:23 +02:00
public TrialsButton(GuiBooklet gui, IPressable action) {
super(GuiBooklet.RES_LOC_GADGETS, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16, action);
2017-02-18 00:54:58 +01:00
this.isTrials = gui.areTrialsOpened();
2021-02-27 22:59:18 +01:00
this.active = !this.isTrials;
2017-02-18 00:54:58 +01:00
}
@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) {
2021-02-27 22:59:18 +01:00
if (this.isHovered || this.isTrials) {
this.drawCenteredString(minecraft.font, 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;
2021-02-27 22:59:18 +01:00
} else if (!this.active) {
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;
}
}
}