2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerInputter;
|
2016-08-09 20:56:09 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-03-19 21:27:56 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2015-06-28 03:12:32 +02:00
|
|
|
import net.minecraft.client.gui.GuiTextField;
|
2016-01-08 15:21:05 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-03-19 21:27:56 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-06-12 19:12:06 +02:00
|
|
|
|
2015-03-19 21:27:56 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public class GuiInputter extends GuiWtfMojang {
|
|
|
|
|
|
|
|
public static final int OFFSET_ADVANCED = 12 + 36;
|
|
|
|
public static final String[] SIDES = new String[] { StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.disabled"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.up"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.down"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.north"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.east"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.south"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.west") };
|
2016-11-19 23:12:22 +01:00
|
|
|
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_inputter");
|
|
|
|
private static final ResourceLocation RES_LOC_ADVANCED = AssetUtil.getGuiLocation("gui_inputter_advanced");
|
2016-05-19 20:05:12 +02:00
|
|
|
public final TileEntityInputter tileInputter;
|
2016-06-01 00:39:35 +02:00
|
|
|
private final boolean isAdvanced;
|
2015-06-28 03:12:32 +02:00
|
|
|
private GuiTextField fieldPutStart;
|
|
|
|
private GuiTextField fieldPutEnd;
|
|
|
|
private GuiTextField fieldPullStart;
|
|
|
|
private GuiTextField fieldPullEnd;
|
2015-04-04 05:20:19 +02:00
|
|
|
|
2016-07-23 19:20:53 +02:00
|
|
|
private FilterSettingsGui leftFilter;
|
|
|
|
private FilterSettingsGui rightFilter;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced) {
|
2015-04-04 05:20:19 +02:00
|
|
|
super(new ContainerInputter(inventory, tile, isAdvanced));
|
2019-05-02 09:10:29 +02:00
|
|
|
this.tileInputter = (TileEntityInputter) tile;
|
2015-03-19 21:27:56 +01:00
|
|
|
this.xSize = 176;
|
2019-05-02 09:10:29 +02:00
|
|
|
this.ySize = 97 + 86 + (isAdvanced ? OFFSET_ADVANCED : 0);
|
2015-04-04 05:20:19 +02:00
|
|
|
this.isAdvanced = isAdvanced;
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void initGui() {
|
2015-03-19 21:27:56 +01:00
|
|
|
super.initGui();
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.isAdvanced) {
|
|
|
|
this.leftFilter = new FilterSettingsGui(this.tileInputter.leftFilter, this.guiLeft + 3, this.guiTop + 6, this.buttonList);
|
|
|
|
this.rightFilter = new FilterSettingsGui(this.tileInputter.rightFilter, this.guiLeft + 157, this.guiTop + 6, this.buttonList);
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fieldPullStart = new GuiTextField(3000, this.fontRenderer, this.guiLeft + 6, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
2016-06-10 13:57:52 +02:00
|
|
|
this.fieldPullStart.setMaxStringLength(5);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.fieldPullStart.setEnableBackgroundDrawing(false);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fieldPullEnd = new GuiTextField(3001, this.fontRenderer, this.guiLeft + 50, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
2016-06-10 13:57:52 +02:00
|
|
|
this.fieldPullEnd.setMaxStringLength(5);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.fieldPullEnd.setEnableBackgroundDrawing(false);
|
2015-06-12 19:12:06 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fieldPutStart = new GuiTextField(3002, this.fontRenderer, this.guiLeft + 91, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
2016-06-10 13:57:52 +02:00
|
|
|
this.fieldPutStart.setMaxStringLength(5);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.fieldPutStart.setEnableBackgroundDrawing(false);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fieldPutEnd = new GuiTextField(3004, this.fontRenderer, this.guiLeft + 135, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
2016-06-10 13:57:52 +02:00
|
|
|
this.fieldPutEnd.setMaxStringLength(5);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.fieldPutEnd.setEnableBackgroundDrawing(false);
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
SmallerButton buttonSidePutP = new SmallerButton(0, this.guiLeft + 155, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), ">");
|
|
|
|
SmallerButton buttonSidePutM = new SmallerButton(1, this.guiLeft + 90, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), "<");
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
SmallerButton buttonSidePullP = new SmallerButton(2, this.guiLeft + 70, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), ">");
|
|
|
|
SmallerButton buttonSidePullM = new SmallerButton(3, this.guiLeft + 5, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), "<");
|
2015-03-19 21:27:56 +01:00
|
|
|
|
|
|
|
this.buttonList.add(buttonSidePutP);
|
|
|
|
this.buttonList.add(buttonSidePullP);
|
|
|
|
this.buttonList.add(buttonSidePutM);
|
|
|
|
this.buttonList.add(buttonSidePullM);
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.buttonList.add(new TinyButton(TileEntityInputter.OKAY_BUTTON_ID, this.guiLeft + 84, this.guiTop + 91 + (this.isAdvanced ? OFFSET_ADVANCED : 0)));
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawScreen(int x, int y, float f) {
|
2015-10-03 10:19:40 +02:00
|
|
|
super.drawScreen(x, y, f);
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
int newTopOffset = this.guiTop + (this.isAdvanced ? OFFSET_ADVANCED : 0);
|
2015-10-03 10:19:40 +02:00
|
|
|
//Info Mode on!
|
2019-05-02 09:10:29 +02:00
|
|
|
if (x >= this.guiLeft + 4 && y >= newTopOffset + 65 && x <= this.guiLeft + 4 + 38 && y <= newTopOffset + 65 + 12) {
|
|
|
|
this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.1").replace("<p>", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.pull")), 200), x, y);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (x >= this.guiLeft + 89 && y >= newTopOffset + 65 && x <= this.guiLeft + 89 + 38 && y <= newTopOffset + 65 + 12) {
|
|
|
|
this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.1").replace("<p>", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.put")), 200), x, y);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (x >= this.guiLeft + 48 && y >= newTopOffset + 65 && x <= this.guiLeft + 48 + 38 && y <= newTopOffset + 65 + 12) {
|
|
|
|
this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.2").replace("<p>", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.pull")), 200), x, y);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (x >= this.guiLeft + 133 && y >= newTopOffset + 65 && x <= this.guiLeft + 133 + 38 && y <= newTopOffset + 65 + 12) {
|
|
|
|
this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.2").replace("<p>", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.put")), 200), x, y);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
2016-07-23 19:20:53 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.isAdvanced) {
|
2016-07-23 19:20:53 +02:00
|
|
|
this.leftFilter.drawHover(x, y);
|
|
|
|
this.rightFilter.drawHover(x, y);
|
|
|
|
}
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawGuiContainerForegroundLayer(int x, int y) {
|
2017-06-29 18:30:02 +02:00
|
|
|
AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileInputter);
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2015-03-29 15:29:05 +02:00
|
|
|
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop + 97 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 0, 0, 176, 86);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2016-06-10 13:57:52 +02:00
|
|
|
this.mc.getTextureManager().bindTexture(this.isAdvanced ? RES_LOC_ADVANCED : RES_LOC);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 97 + (this.isAdvanced ? OFFSET_ADVANCED : 0));
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fontRenderer.drawString(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.inbound"), this.guiLeft + 23 + 3, this.guiTop + 32 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
|
|
|
|
this.fontRenderer.drawString(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.outbound"), this.guiLeft + 104 + 3, this.guiTop + 32 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPull + 1], this.guiLeft + 24 + 1, this.guiTop + 45 + 3 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
|
|
|
|
this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPut + 1], this.guiLeft + 109 + 1, this.guiTop + 45 + 3 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutStart), this.guiLeft + 92, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE);
|
|
|
|
this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutEnd), this.guiLeft + 136, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE);
|
|
|
|
this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullStart), this.guiLeft + 7, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE);
|
|
|
|
this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullEnd), this.guiLeft + 51, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2015-06-28 03:12:32 +02:00
|
|
|
this.fieldPutStart.drawTextBox();
|
|
|
|
this.fieldPutEnd.drawTextBox();
|
|
|
|
this.fieldPullStart.drawTextBox();
|
|
|
|
this.fieldPullEnd.drawTextBox();
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.fieldPutStart.mouseClicked(par1, par2, par3);
|
|
|
|
this.fieldPutEnd.mouseClicked(par1, par2, par3);
|
|
|
|
this.fieldPullStart.mouseClicked(par1, par2, par3);
|
|
|
|
this.fieldPullEnd.mouseClicked(par1, par2, par3);
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
super.mouseClicked(par1, par2, par3);
|
|
|
|
}
|
2015-06-12 19:12:06 +02:00
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void keyTyped(char theChar, int key) throws IOException {
|
|
|
|
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
|
|
|
|
if (this.fieldPutStart.isFocused()) {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.setVariable(this.fieldPutStart, 0);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.fieldPutEnd.isFocused()) {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.setVariable(this.fieldPutEnd, 1);
|
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.fieldPullStart.isFocused()) {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.setVariable(this.fieldPullStart, 2);
|
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.fieldPullEnd.isFocused()) {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.setVariable(this.fieldPullEnd, 3);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (Character.isDigit(theChar) || key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE || key == Keyboard.KEY_LEFT || key == Keyboard.KEY_RIGHT) {
|
2015-10-03 10:19:40 +02:00
|
|
|
this.fieldPutStart.textboxKeyTyped(theChar, key);
|
|
|
|
this.fieldPutEnd.textboxKeyTyped(theChar, key);
|
|
|
|
this.fieldPullStart.textboxKeyTyped(theChar, key);
|
|
|
|
this.fieldPullEnd.textboxKeyTyped(theChar, key);
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2015-10-03 10:19:40 +02:00
|
|
|
super.keyTyped(theChar, key);
|
2015-07-09 16:59:43 +02:00
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void updateScreen() {
|
2015-10-03 10:19:40 +02:00
|
|
|
super.updateScreen();
|
|
|
|
|
|
|
|
this.fieldPutStart.updateCursorCounter();
|
|
|
|
this.fieldPutEnd.updateCursorCounter();
|
|
|
|
this.fieldPullStart.updateCursorCounter();
|
|
|
|
this.fieldPullEnd.updateCursorCounter();
|
2016-07-23 19:20:53 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.isAdvanced) {
|
2016-07-23 19:20:53 +02:00
|
|
|
this.leftFilter.update();
|
|
|
|
this.rightFilter.update();
|
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public void setVariable(GuiTextField field, int sendInt) {
|
|
|
|
if (!field.getText().isEmpty()) {
|
2016-05-02 17:46:53 +02:00
|
|
|
this.sendPacket(this.parse(field.getText()), sendInt);
|
2015-10-03 10:19:40 +02:00
|
|
|
field.setText("");
|
2015-07-09 16:59:43 +02:00
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private void sendPacket(int text, int textID) {
|
2016-12-29 21:29:00 +01:00
|
|
|
PacketHandlerHelper.sendNumberPacket(this.tileInputter, text, textID);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private int parse(String theInt) {
|
|
|
|
try {
|
2015-10-03 10:19:40 +02:00
|
|
|
return Integer.parseInt(theInt);
|
2019-05-02 09:10:29 +02:00
|
|
|
} catch (Exception e) {
|
2015-10-03 10:19:40 +02:00
|
|
|
return -1;
|
2015-07-09 16:59:43 +02:00
|
|
|
}
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void actionPerformed(GuiButton button) {
|
|
|
|
if (button.id == TileEntityInputter.OKAY_BUTTON_ID) {
|
2015-06-28 03:12:32 +02:00
|
|
|
this.setVariable(this.fieldPutStart, 0);
|
|
|
|
this.setVariable(this.fieldPutEnd, 1);
|
|
|
|
this.setVariable(this.fieldPullStart, 2);
|
|
|
|
this.setVariable(this.fieldPullEnd, 3);
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2016-08-09 20:56:09 +02:00
|
|
|
PacketHandlerHelper.sendButtonPacket(this.tileInputter, button.id);
|
2015-10-02 16:48:01 +02:00
|
|
|
}
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 15:22:30 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public static class SmallerButton extends GuiButton {
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2016-11-19 23:12:22 +01:00
|
|
|
public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter");
|
2016-11-17 14:56:26 +01:00
|
|
|
private final boolean smaller;
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public SmallerButton(int id, int x, int y, String display) {
|
2016-11-17 14:56:26 +01:00
|
|
|
this(id, x, y, display, false);
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public SmallerButton(int id, int x, int y, String display, boolean smaller) {
|
2016-11-17 14:56:26 +01:00
|
|
|
super(id, x, y, 16, smaller ? 12 : 16, display);
|
|
|
|
this.smaller = smaller;
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawButton(Minecraft mc, int x, int y, float f) {
|
|
|
|
if (this.visible) {
|
2016-05-02 17:46:53 +02:00
|
|
|
mc.getTextureManager().bindTexture(this.resLoc);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
2016-01-08 08:10:55 +01:00
|
|
|
int k = this.getHoverState(this.hovered);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.enableBlend();
|
|
|
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
|
|
|
GlStateManager.blendFunc(770, 771);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.drawTexturedModalRect(this.x, this.y, this.smaller ? 200 : 176, k * this.height, this.width, this.height);
|
2015-03-19 21:27:56 +01:00
|
|
|
this.mouseDragged(mc, x, y);
|
|
|
|
|
|
|
|
int color = 14737632;
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.packedFGColour != 0) {
|
2016-05-02 17:46:53 +02:00
|
|
|
color = this.packedFGColour;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (!this.enabled) {
|
2015-10-02 16:48:01 +02:00
|
|
|
color = 10526880;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (this.hovered) {
|
2015-10-03 10:16:18 +02:00
|
|
|
color = 16777120;
|
|
|
|
}
|
2015-03-19 21:27:56 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, color);
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-01 15:22:30 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public static class TinyButton extends GuiButton {
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2016-11-19 23:12:22 +01:00
|
|
|
public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter");
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public TinyButton(int id, int x, int y) {
|
2015-06-28 03:12:32 +02:00
|
|
|
super(id, x, y, 8, 8, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawButton(Minecraft mc, int x, int y, float f) {
|
|
|
|
if (this.visible) {
|
2016-05-02 17:46:53 +02:00
|
|
|
mc.getTextureManager().bindTexture(this.resLoc);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
2016-01-08 08:10:55 +01:00
|
|
|
int k = this.getHoverState(this.hovered);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.enableBlend();
|
|
|
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
|
|
|
GlStateManager.blendFunc(770, 771);
|
2019-05-02 09:10:29 +02:00
|
|
|
this.drawTexturedModalRect(this.x, this.y, 192, k * 8, 8, 8);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.mouseDragged(mc, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 21:27:56 +01:00
|
|
|
}
|