Search in sources :

Example 11 with SlotWidget

use of gregtech.api.gui.widgets.SlotWidget in project GregTech by GregTechCE.

the class SimpleGeneratorMetaTileEntity method createGuiTemplate.

protected ModularUI.Builder createGuiTemplate(EntityPlayer player) {
    Builder builder = ModularUI.defaultBuilder();
    builder.image(7, 16, 81, 55, GuiTextures.DISPLAY);
    TankWidget tankWidget = new TankWidget(importFluids.getTankAt(0), 69, 52, 18, 18).setHideTooltip(true).setAlwaysShowFull(true);
    builder.widget(tankWidget);
    builder.label(11, 20, "gregtech.gui.fluid_amount", 0xFFFFFF);
    builder.dynamicLabel(11, 30, tankWidget::getFormattedFluidAmount, 0xFFFFFF);
    builder.dynamicLabel(11, 40, tankWidget::getFluidLocalizedName, 0xFFFFFF);
    return builder.label(6, 6, getMetaFullName()).widget(new FluidContainerSlotWidget(containerInventory, 0, 90, 17, true).setBackgroundTexture(GuiTextures.SLOT, GuiTextures.IN_SLOT_OVERLAY)).widget(new ImageWidget(91, 36, 14, 15, GuiTextures.TANK_ICON)).widget(new SlotWidget(containerInventory, 1, 90, 54, true, false).setBackgroundTexture(GuiTextures.SLOT, GuiTextures.OUT_SLOT_OVERLAY)).bindPlayerInventory(player.inventory);
}
Also used : TankWidget(gregtech.api.gui.widgets.TankWidget) SlotWidget(gregtech.api.gui.widgets.SlotWidget) FluidContainerSlotWidget(gregtech.api.gui.widgets.FluidContainerSlotWidget) Builder(gregtech.api.gui.ModularUI.Builder) FluidContainerSlotWidget(gregtech.api.gui.widgets.FluidContainerSlotWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget)

Example 12 with SlotWidget

use of gregtech.api.gui.widgets.SlotWidget in project GregTech by GregTechCE.

the class FluidFilterContainer method initUI.

public void initUI(int y, Consumer<Widget> widgetGroup) {
    widgetGroup.accept(new LabelWidget(10, y, "cover.pump.fluid_filter.title"));
    widgetGroup.accept(new SlotWidget(filterInventory, 0, 10, y + 15).setBackgroundTexture(GuiTextures.SLOT, GuiTextures.FILTER_SLOT_OVERLAY));
    this.filterWrapper.initUI(y + 15, widgetGroup);
}
Also used : SlotWidget(gregtech.api.gui.widgets.SlotWidget) LabelWidget(gregtech.api.gui.widgets.LabelWidget)

Example 13 with SlotWidget

use of gregtech.api.gui.widgets.SlotWidget in project GregTech by GregTechCE.

the class RecipeMapCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, GTRecipeWrapper recipeWrapper, IIngredients ingredients) {
    IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();
    IGuiFluidStackGroup fluidStackGroup = recipeLayout.getFluidStacks();
    for (Widget uiWidget : modularUI.guiWidgets.values()) {
        if (uiWidget instanceof SlotWidget) {
            SlotWidget slotWidget = (SlotWidget) uiWidget;
            if (!(slotWidget.getHandle() instanceof SlotItemHandler)) {
                continue;
            }
            SlotItemHandler handle = (SlotItemHandler) slotWidget.getHandle();
            if (handle.getItemHandler() == importItems) {
                // this is input item stack slot widget, so add it to item group
                itemStackGroup.init(handle.getSlotIndex(), true, slotWidget.getPosition().x, slotWidget.getPosition().y);
            } else if (handle.getItemHandler() == exportItems) {
                // this is output item stack slot widget, so add it to item group
                itemStackGroup.init(importItems.getSlots() + handle.getSlotIndex(), false, slotWidget.getPosition().x, slotWidget.getPosition().y);
            }
        } else if (uiWidget instanceof TankWidget) {
            TankWidget tankWidget = (TankWidget) uiWidget;
            if (importFluids.getFluidTanks().contains(tankWidget.fluidTank)) {
                int importIndex = importFluids.getFluidTanks().indexOf(tankWidget.fluidTank);
                List<List<FluidStack>> inputsList = ingredients.getInputs(FluidStack.class);
                int fluidAmount = 0;
                if (inputsList.size() > importIndex && !inputsList.get(importIndex).isEmpty())
                    fluidAmount = inputsList.get(importIndex).get(0).amount;
                // this is input tank widget, so add it to fluid group
                fluidStackGroup.init(importIndex, true, tankWidget.getPosition().x + tankWidget.fluidRenderOffset, tankWidget.getPosition().y + tankWidget.fluidRenderOffset, tankWidget.getSize().width - (2 * tankWidget.fluidRenderOffset), tankWidget.getSize().height - (2 * tankWidget.fluidRenderOffset), fluidAmount, false, null);
            } else if (exportFluids.getFluidTanks().contains(tankWidget.fluidTank)) {
                int exportIndex = exportFluids.getFluidTanks().indexOf(tankWidget.fluidTank);
                List<List<FluidStack>> inputsList = ingredients.getOutputs(FluidStack.class);
                int fluidAmount = 0;
                if (inputsList.size() > exportIndex && !inputsList.get(exportIndex).isEmpty())
                    fluidAmount = inputsList.get(exportIndex).get(0).amount;
                // this is output tank widget, so add it to fluid group
                fluidStackGroup.init(importFluids.getFluidTanks().size() + exportIndex, false, tankWidget.getPosition().x + tankWidget.fluidRenderOffset, tankWidget.getPosition().y + tankWidget.fluidRenderOffset, tankWidget.getSize().width - (2 * tankWidget.fluidRenderOffset), tankWidget.getSize().height - (2 * tankWidget.fluidRenderOffset), fluidAmount, false, null);
            }
        }
    }
    itemStackGroup.addTooltipCallback(recipeWrapper::addTooltip);
    fluidStackGroup.addTooltipCallback(recipeWrapper::addTooltip);
    itemStackGroup.set(ingredients);
    fluidStackGroup.set(ingredients);
}
Also used : TankWidget(gregtech.api.gui.widgets.TankWidget) SlotWidget(gregtech.api.gui.widgets.SlotWidget) FluidStack(net.minecraftforge.fluids.FluidStack) IGuiFluidStackGroup(mezz.jei.api.gui.IGuiFluidStackGroup) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) Widget(gregtech.api.gui.Widget) TankWidget(gregtech.api.gui.widgets.TankWidget) SlotWidget(gregtech.api.gui.widgets.SlotWidget) FluidTankList(gregtech.api.capability.impl.FluidTankList) List(java.util.List) SlotItemHandler(net.minecraftforge.items.SlotItemHandler)

Aggregations

SlotWidget (gregtech.api.gui.widgets.SlotWidget)13 Builder (gregtech.api.gui.ModularUI.Builder)10 ImageWidget (gregtech.api.gui.widgets.ImageWidget)5 TankWidget (gregtech.api.gui.widgets.TankWidget)5 FluidContainerSlotWidget (gregtech.api.gui.widgets.FluidContainerSlotWidget)4 ModularUI (gregtech.api.gui.ModularUI)2 LabelWidget (gregtech.api.gui.widgets.LabelWidget)2 List (java.util.List)2 CCRenderState (codechicken.lib.render.CCRenderState)1 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 Matrix4 (codechicken.lib.vec.Matrix4)1 GTValues (gregtech.api.GTValues)1 FluidTankList (gregtech.api.capability.impl.FluidTankList)1 GuiTextures (gregtech.api.gui.GuiTextures)1 Widget (gregtech.api.gui.Widget)1 AdvancedTextWidget (gregtech.api.gui.widgets.AdvancedTextWidget)1 ClickButtonWidget (gregtech.api.gui.widgets.ClickButtonWidget)1 ProgressWidget (gregtech.api.gui.widgets.ProgressWidget)1 ServerWidgetGroup (gregtech.api.gui.widgets.ServerWidgetGroup)1 SimpleTextWidget (gregtech.api.gui.widgets.SimpleTextWidget)1