Search in sources :

Example 1 with ImageCycleButtonWidget

use of gregtech.api.gui.widgets.ImageCycleButtonWidget in project GregTech by GregTechCEu.

the class MultiblockWithDisplayBase method createUITemplate.

protected ModularUI.Builder createUITemplate(EntityPlayer entityPlayer) {
    ModularUI.Builder builder = ModularUI.extendedBuilder();
    builder.image(7, 4, 162, 121, GuiTextures.DISPLAY);
    builder.label(11, 9, getMetaFullName(), 0xFFFFFF);
    builder.widget(new AdvancedTextWidget(11, 19, this::addDisplayText, 0xFFFFFF).setMaxWidthLimit(156).setClickHandler(this::handleDisplayClick));
    if (shouldShowVoidingModeButton()) {
        builder.widget(new ImageCycleButtonWidget(149, 121 - 17, 18, 18, GuiTextures.BUTTON_VOID_MULTIBLOCK, 4, this::getVoidingMode, this::setVoidingMode).setTooltipHoverString(this::getVoidingModeTooltip));
    }
    builder.bindPlayerInventory(entityPlayer.inventory, 134);
    return builder;
}
Also used : ModularUI(gregtech.api.gui.ModularUI) ImageCycleButtonWidget(gregtech.api.gui.widgets.ImageCycleButtonWidget) AdvancedTextWidget(gregtech.api.gui.widgets.AdvancedTextWidget)

Example 2 with ImageCycleButtonWidget

use of gregtech.api.gui.widgets.ImageCycleButtonWidget in project GregTech by GregTechCEu.

the class ClipboardBehavior method createMTEUI.

public ModularUI createMTEUI(PlayerInventoryHolder holder, EntityPlayer entityPlayer) {
    // So that people don't click on any text fields
    initNBT(holder.getCurrentItem());
    ModularUI.Builder builder = ModularUI.builder(GuiTextures.CLIPBOARD_PAPER_BACKGROUND, 170, 238);
    builder.image(18, 8, 130, 14, GuiTextures.CLIPBOARD_TEXT_BOX);
    builder.widget(new SimpleTextWidget(20, 10, "", TEXT_COLOR, () -> getTitle(holder), true).setCenter(false));
    for (int i = 0; i < 8; i++) {
        int finalI = i;
        builder.widget(new ImageCycleButtonWidget(6, 37 + 20 * i, 15, 15, GuiTextures.CLIPBOARD_BUTTON, 4, () -> getButtonState(holder, finalI), (x) -> setButton(holder, finalI, x)));
        builder.image(22, 38 + 20 * i, 140, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
        builder.widget(new SimpleTextWidget(24, 40 + 20 * i, "", TEXT_COLOR, () -> getString(holder, finalI), true).setCenter(false));
    }
    builder.widget(new ClickButtonWidget(30, 200, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? -10 : -1)).setButtonTexture(GuiTextures.BUTTON_LEFT).setShouldClientCallback(true));
    builder.widget(new ClickButtonWidget(124, 200, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? 10 : 1)).setButtonTexture(GuiTextures.BUTTON_RIGHT).setShouldClientCallback(true));
    builder.widget(new SimpleTextWidget(85, 208, "", TEXT_COLOR, () -> (getPageNum(holder) + 1) + " / " + MAX_PAGES, true));
    builder.shouldColor(false);
    return builder.build(holder, entityPlayer);
}
Also used : SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget) MetaItems(gregtech.common.items.MetaItems) MACHINE(gregtech.common.blocks.MetaBlocks.MACHINE) EnumHand(net.minecraft.util.EnumHand) ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) IItemBehaviour(gregtech.api.items.metaitem.stats.IItemBehaviour) Block(net.minecraft.block.Block) TextFieldWidget2(gregtech.api.gui.widgets.TextFieldWidget2) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemUIFactory(gregtech.api.items.gui.ItemUIFactory) World(net.minecraft.world.World) EnumFacing(net.minecraft.util.EnumFacing) ImageCycleButtonWidget(gregtech.api.gui.widgets.ImageCycleButtonWidget) BlockPos(net.minecraft.util.math.BlockPos) MetaTileEntityClipboard(gregtech.common.metatileentities.MetaTileEntityClipboard) GuiTextures(gregtech.api.gui.GuiTextures) ActionResult(net.minecraft.util.ActionResult) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EnumActionResult(net.minecraft.util.EnumActionResult) RayTracer(codechicken.lib.raytracer.RayTracer) ModularUI(gregtech.api.gui.ModularUI) PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) CLIPBOARD_TILE(gregtech.common.metatileentities.MetaTileEntities.CLIPBOARD_TILE) ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) ModularUI(gregtech.api.gui.ModularUI) ImageCycleButtonWidget(gregtech.api.gui.widgets.ImageCycleButtonWidget) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Example 3 with ImageCycleButtonWidget

use of gregtech.api.gui.widgets.ImageCycleButtonWidget in project GregTech by GregTechCEu.

the class ClipboardBehavior method createUI.

@Override
public ModularUI createUI(PlayerInventoryHolder holder, EntityPlayer entityPlayer) {
    ModularUI.Builder builder = ModularUI.builder(GuiTextures.CLIPBOARD_BACKGROUND, 186, 263);
    initNBT(holder.getCurrentItem());
    List<TextFieldWidget2> textFields = new ArrayList<>();
    builder.image(28, 28, 130, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
    textFields.add(new TextFieldWidget2(30, 30, 126, 9, () -> getTitle(holder), val -> setTitle(holder, val)).setMaxLength(25).setCentered(true).setTextColor(TEXT_COLOR));
    for (int i = 0; i < 8; i++) {
        int finalI = i;
        builder.widget(new ImageCycleButtonWidget(14, 55 + 22 * i, 15, 15, GuiTextures.CLIPBOARD_BUTTON, 4, () -> getButtonState(holder, finalI), (x) -> setButton(holder, finalI, x)));
        builder.image(32, 58 + 22 * i, 140, 12, GuiTextures.CLIPBOARD_TEXT_BOX);
        textFields.add(new TextFieldWidget2(34, 60 + 22 * i, 136, 9, () -> getString(holder, finalI), val -> setString(holder, finalI, val)).setMaxLength(23).setTextColor(TEXT_COLOR));
    }
    for (TextFieldWidget2 textField : textFields) {
        builder.widget(textField.setOnFocus(textField2 -> textFields.forEach(textField3 -> {
            if (textField3 != textField2) {
                textField3.unFocus();
            }
        })));
    }
    builder.widget(new ClickButtonWidget(38, 231, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? -10 : -1)).setButtonTexture(GuiTextures.BUTTON_LEFT).setShouldClientCallback(true));
    builder.widget(new ClickButtonWidget(132, 231, 16, 16, "", (x) -> incrPageNum(holder, x.isShiftClick ? 10 : 1)).setButtonTexture(GuiTextures.BUTTON_RIGHT).setShouldClientCallback(true));
    builder.widget(new SimpleTextWidget(93, 240, "", TEXT_COLOR, () -> (getPageNum(holder) + 1) + " / " + MAX_PAGES, true));
    builder.shouldColor(false);
    return builder.build(holder, entityPlayer);
}
Also used : SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget) MetaItems(gregtech.common.items.MetaItems) MACHINE(gregtech.common.blocks.MetaBlocks.MACHINE) EnumHand(net.minecraft.util.EnumHand) ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) IItemBehaviour(gregtech.api.items.metaitem.stats.IItemBehaviour) Block(net.minecraft.block.Block) TextFieldWidget2(gregtech.api.gui.widgets.TextFieldWidget2) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemUIFactory(gregtech.api.items.gui.ItemUIFactory) World(net.minecraft.world.World) EnumFacing(net.minecraft.util.EnumFacing) ImageCycleButtonWidget(gregtech.api.gui.widgets.ImageCycleButtonWidget) BlockPos(net.minecraft.util.math.BlockPos) MetaTileEntityClipboard(gregtech.common.metatileentities.MetaTileEntityClipboard) GuiTextures(gregtech.api.gui.GuiTextures) ActionResult(net.minecraft.util.ActionResult) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EnumActionResult(net.minecraft.util.EnumActionResult) RayTracer(codechicken.lib.raytracer.RayTracer) ModularUI(gregtech.api.gui.ModularUI) PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) CLIPBOARD_TILE(gregtech.common.metatileentities.MetaTileEntities.CLIPBOARD_TILE) ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) ModularUI(gregtech.api.gui.ModularUI) ArrayList(java.util.ArrayList) ImageCycleButtonWidget(gregtech.api.gui.widgets.ImageCycleButtonWidget) TextFieldWidget2(gregtech.api.gui.widgets.TextFieldWidget2) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Aggregations

ModularUI (gregtech.api.gui.ModularUI)3 ImageCycleButtonWidget (gregtech.api.gui.widgets.ImageCycleButtonWidget)3 RayTracer (codechicken.lib.raytracer.RayTracer)2 GuiTextures (gregtech.api.gui.GuiTextures)2 ClickButtonWidget (gregtech.api.gui.widgets.ClickButtonWidget)2 SimpleTextWidget (gregtech.api.gui.widgets.SimpleTextWidget)2 TextFieldWidget2 (gregtech.api.gui.widgets.TextFieldWidget2)2 ItemUIFactory (gregtech.api.items.gui.ItemUIFactory)2 PlayerInventoryHolder (gregtech.api.items.gui.PlayerInventoryHolder)2 IItemBehaviour (gregtech.api.items.metaitem.stats.IItemBehaviour)2 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)2 MACHINE (gregtech.common.blocks.MetaBlocks.MACHINE)2 MetaItems (gregtech.common.items.MetaItems)2 CLIPBOARD_TILE (gregtech.common.metatileentities.MetaTileEntities.CLIPBOARD_TILE)2 MetaTileEntityClipboard (gregtech.common.metatileentities.MetaTileEntityClipboard)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2