Search in sources :

Example 1 with GuiItemButton

use of net.geforcemods.securitycraft.gui.components.GuiItemButton in project SecurityCraft by Geforce132.

the class GuiCustomizeBlock method initGui.

@Override
public void initGui() {
    super.initGui();
    for (int i = 0; i < tileEntity.getNumberOfCustomizableOptions(); i++) {
        descriptionButtons[i] = new GuiItemButton(i, guiLeft + 130, (guiTop + 10) + (i * 25), 20, 20, "", itemRender, new ItemStack(tileEntity.acceptedModules()[i].getItem()));
        this.buttonList.add(descriptionButtons[i]);
        this.hoverCheckers[i] = new HoverChecker(descriptionButtons[i], 20);
    }
    if (tileEntity.customOptions() != null) {
        for (int i = 0; i < tileEntity.customOptions().length; i++) {
            optionButtons[i] = new GuiButton(i, guiLeft + 178, (guiTop + 10) + (i * 25), 120, 20, getOptionButtonTitle(tileEntity.customOptions()[i]));
            optionButtons[i].packedFGColour = tileEntity.customOptions()[i].toString().matches(tileEntity.customOptions()[i].getDefaultValue().toString()) ? 16777120 : 14737632;
            this.buttonList.add(optionButtons[i]);
            this.hoverCheckers[i + tileEntity.getNumberOfCustomizableOptions()] = new HoverChecker(optionButtons[i], 20);
        }
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) ItemStack(net.minecraft.item.ItemStack) GuiItemButton(net.geforcemods.securitycraft.gui.components.GuiItemButton) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker)

Example 2 with GuiItemButton

use of net.geforcemods.securitycraft.gui.components.GuiItemButton in project SecurityCraft by Geforce132.

the class GuiCustomizeBlock method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    if (!(guibutton instanceof GuiItemButton)) {
        Option<?> tempOption = tileEntity.customOptions()[guibutton.id];
        tempOption.toggle();
        guibutton.packedFGColour = tempOption.toString().matches(tempOption.getDefaultValue().toString()) ? 16777120 : 14737632;
        guibutton.displayString = getOptionButtonTitle(tempOption);
        mod_SecurityCraft.network.sendToServer(new PacketSToggleOption(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), guibutton.id));
    }
}
Also used : PacketSToggleOption(net.geforcemods.securitycraft.network.packets.PacketSToggleOption) GuiItemButton(net.geforcemods.securitycraft.gui.components.GuiItemButton)

Aggregations

GuiItemButton (net.geforcemods.securitycraft.gui.components.GuiItemButton)2 PacketSToggleOption (net.geforcemods.securitycraft.network.packets.PacketSToggleOption)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ItemStack (net.minecraft.item.ItemStack)1 HoverChecker (net.minecraftforge.fml.client.config.HoverChecker)1