Search in sources :

Example 1 with GuiButtonCheckbox

use of blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox in project ImmersiveEngineering by BluSunrize.

the class GuiTurret method initGui.

@Override
public void initGui() {
    super.initGui();
    Keyboard.enableRepeatEvents(true);
    this.nameField = new GuiTextField(0, this.fontRendererObj, guiLeft + 11, guiTop + 88, 58, 12);
    this.nameField.setTextColor(-1);
    this.nameField.setDisabledTextColour(-1);
    this.nameField.setEnableBackgroundDrawing(false);
    this.nameField.setMaxStringLength(30);
    this.buttonList.clear();
    this.buttonList.add(new GuiReactiveList(this, 0, guiLeft + 10, guiTop + 10, 60, 72, tile.targetList.toArray(new String[tile.targetList.size()])).setPadding(0, 0, 2, 2).setFormatting(1, false));
    this.buttonList.add(new GuiButtonIE(1, guiLeft + 74, guiTop + 84, 24, 16, I18n.format(Lib.GUI_CONFIG + "turret.add"), "immersiveengineering:textures/gui/turret.png", 176, 65));
    this.buttonList.add(new GuiButtonCheckbox(2, guiLeft + 74, guiTop + 10, I18n.format(Lib.GUI_CONFIG + "turret.blacklist"), !tile.whitelist));
    this.buttonList.add(new GuiButtonCheckbox(3, guiLeft + 74, guiTop + 26, I18n.format(Lib.GUI_CONFIG + "turret.animals"), tile.attackAnimals));
    this.buttonList.add(new GuiButtonCheckbox(4, guiLeft + 74, guiTop + 42, I18n.format(Lib.GUI_CONFIG + "turret.players"), tile.attackPlayers));
    this.buttonList.add(new GuiButtonCheckbox(5, guiLeft + 74, guiTop + 58, I18n.format(Lib.GUI_CONFIG + "turret.neutrals"), tile.attackNeutrals));
    if (tile instanceof TileEntityTurretChem)
        this.buttonList.add(new GuiButtonState(6, guiLeft + 135, guiTop + 68, 14, 14, null, ((TileEntityTurretChem) tile).ignite, "immersiveengineering:textures/gui/turret.png", 176, 51, 0));
    else if (tile instanceof TileEntityTurretGun)
        this.buttonList.add(new GuiButtonState(6, guiLeft + 134, guiTop + 31, 16, 16, null, ((TileEntityTurretGun) tile).expelCasings, "immersiveengineering:textures/gui/turret.png", 176, 81, 0));
}
Also used : GuiReactiveList(blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList) GuiButtonIE(blusunrize.immersiveengineering.client.gui.elements.GuiButtonIE) TileEntityTurretGun(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun) GuiButtonState(blusunrize.immersiveengineering.client.gui.elements.GuiButtonState) GuiButtonCheckbox(blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox) GuiTextField(net.minecraft.client.gui.GuiTextField) TileEntityTurretChem(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem)

Example 2 with GuiButtonCheckbox

use of blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox in project ImmersiveEngineering by BluSunrize.

the class GuiModWorkbench method mouseReleased.

@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
    super.mouseReleased(mouseX, mouseY, state);
    Slot s = inventorySlots.getSlot(0);
    if (s != null && s.getHasStack() && s.getStack().getItem() instanceof IConfigurableTool) {
        ItemStack stack = s.getStack();
        IConfigurableTool tool = ((IConfigurableTool) stack.getItem());
        NBTTagCompound message = new NBTTagCompound();
        ToolConfigBoolean[] boolArray = tool.getBooleanOptions(stack);
        int iBool = 0;
        ToolConfigFloat[] floatArray = tool.getFloatOptions(stack);
        int iFloat = 0;
        for (GuiButton button : this.buttonList) {
            if (button instanceof GuiButtonCheckbox && boolArray != null)
                message.setBoolean("b_" + boolArray[iBool++].name, ((GuiButtonCheckbox) button).state);
            if (button instanceof GuiSliderIE && floatArray != null)
                message.setFloat("f_" + floatArray[iFloat++].name, (float) ((GuiSliderIE) button).sliderValue);
        }
        if (//Only send packets when values have changed
        lastMessage == null || !lastMessage.equals(message))
            ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(this.workbench, message));
        lastMessage = message;
    }
}
Also used : ToolConfigBoolean(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigBoolean) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GuiButton(net.minecraft.client.gui.GuiButton) GuiSliderIE(blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE) IESlot(blusunrize.immersiveengineering.common.gui.IESlot) Slot(net.minecraft.inventory.Slot) IConfigurableTool(blusunrize.immersiveengineering.api.tool.IConfigurableTool) ToolConfigFloat(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigFloat) GuiButtonCheckbox(blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox) ItemStack(net.minecraft.item.ItemStack) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 3 with GuiButtonCheckbox

use of blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox in project ImmersiveEngineering by BluSunrize.

the class GuiModWorkbench method initGui.

@Override
public void initGui() {
    this.buttonList.clear();
    super.initGui();
    Slot s = inventorySlots.getSlot(0);
    if (s != null && s.getHasStack() && s.getStack().getItem() instanceof IConfigurableTool) {
        ItemStack stack = s.getStack();
        IConfigurableTool tool = ((IConfigurableTool) stack.getItem());
        int buttonid = 0;
        ToolConfigBoolean[] boolArray = tool.getBooleanOptions(stack);
        if (boolArray != null)
            for (ToolConfigBoolean b : boolArray) this.buttonList.add(new GuiButtonCheckbox(buttonid++, guiLeft + b.x, guiTop + b.y, tool.fomatConfigName(stack, b), b.value));
        ToolConfigFloat[] floatArray = tool.getFloatOptions(stack);
        if (floatArray != null)
            for (ToolConfigFloat f : floatArray) this.buttonList.add(new GuiSliderIE(buttonid++, guiLeft + f.x, guiTop + f.y, 80, tool.fomatConfigName(stack, f), f.value));
    }
}
Also used : ToolConfigBoolean(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigBoolean) GuiSliderIE(blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE) IESlot(blusunrize.immersiveengineering.common.gui.IESlot) Slot(net.minecraft.inventory.Slot) IConfigurableTool(blusunrize.immersiveengineering.api.tool.IConfigurableTool) ToolConfigFloat(blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigFloat) GuiButtonCheckbox(blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GuiButtonCheckbox (blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox)3 IConfigurableTool (blusunrize.immersiveengineering.api.tool.IConfigurableTool)2 ToolConfigBoolean (blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigBoolean)2 ToolConfigFloat (blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig.ToolConfigFloat)2 GuiSliderIE (blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE)2 IESlot (blusunrize.immersiveengineering.common.gui.IESlot)2 Slot (net.minecraft.inventory.Slot)2 ItemStack (net.minecraft.item.ItemStack)2 GuiButtonIE (blusunrize.immersiveengineering.client.gui.elements.GuiButtonIE)1 GuiButtonState (blusunrize.immersiveengineering.client.gui.elements.GuiButtonState)1 GuiReactiveList (blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList)1 TileEntityTurretChem (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem)1 TileEntityTurretGun (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun)1 MessageTileSync (blusunrize.immersiveengineering.common.util.network.MessageTileSync)1 GuiButton (net.minecraft.client.gui.GuiButton)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1