Search in sources :

Example 1 with AdvancedSlot

use of buildcraft.core.lib.gui.AdvancedSlot in project BuildCraft by BuildCraft.

the class GuiBuilder method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    // We cannot do super here due to some crazy shenanigans with a dynamically
    // resized GUI.
    GlStateManager.color(1f, 1f, 1f, 1f);
    boolean isBlueprint = builder.getStackInSlot(0) != null;
    mc.renderEngine.bindTexture(REGULAR_TEXTURE);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, ySize);
    mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
    if (isBlueprint) {
        drawTexturedModalRect(guiLeft + 169, guiTop, 169, 0, 256 - 169, ySize);
    }
    List<RequirementItemStack> needs = builder.getNeededItems();
    if (needs != null) {
        if (needs.size() > slots.size()) {
            getContainerBuilder().scrollbarWidget.hidden = false;
            getContainerBuilder().scrollbarWidget.setLength((needs.size() - slots.size() + 3) / 4);
        } else {
            getContainerBuilder().scrollbarWidget.hidden = true;
        }
        int offset = getContainerBuilder().scrollbarWidget.getPosition() * 4;
        for (int s = 0; s < slots.size(); s++) {
            int ts = offset + s;
            if (ts >= needs.size()) {
                ((SlotBuilderRequirement) slots.get(s)).stack = null;
            } else {
                ((SlotBuilderRequirement) slots.get(s)).stack = needs.get(ts);
            }
        }
        for (GuiButton b : (List<GuiButton>) buttonList) {
            b.visible = true;
        }
    } else {
        getContainerBuilder().scrollbarWidget.hidden = true;
        for (AdvancedSlot slot : slots) {
            ((SlotBuilderRequirement) slot).stack = null;
        }
        for (GuiButton b : (List<GuiButton>) buttonList) {
            b.visible = false;
        }
    }
    if (builder.getControlMode() == Mode.Off) {
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        int extraX = guiLeft + OPTION_EXTRA_X_POS.getAsInt();
        int extraY = guiTop + OPTION_EXTRA_Y_POS.getAsInt();
        drawTexturedModalRect(extraX, extraY, CoreIconProvider.TURNED_OFF.getSprite(), 16, 16);
    }
    drawWidgets(x, y);
    if (isBlueprint) {
        drawBackgroundSlots(x, y);
        for (int i = 0; i < builder.fluidTanks.length; i++) {
            Tank tank = builder.fluidTanks[i];
            if (tank.getFluid() != null && tank.getFluid().amount > 0) {
                drawFluid(tank.getFluid(), guiLeft + 179 + 18 * i, guiTop + 145, 16, 47, tank.getCapacity());
            }
        }
        mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
        for (int i = 0; i < builder.fluidTanks.length; i++) {
            Tank tank = builder.fluidTanks[i];
            if (tank.getFluid() != null && tank.getFluid().amount > 0) {
                drawTexturedModalRect(guiLeft + 179 + 18 * i, guiTop + 145, 0, 54, 16, 47);
            }
        }
    }
    GlStateManager.color(1f, 1f, 1f, 1f);
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) RequirementItemStack(buildcraft.core.blueprints.RequirementItemStack) ArrayList(java.util.ArrayList) List(java.util.List) Tank(buildcraft.lib.fluids.Tank)

Example 2 with AdvancedSlot

use of buildcraft.core.lib.gui.AdvancedSlot in project BuildCraft by BuildCraft.

the class GuiGateInterface method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    container.synchronize();
    if (gate == null) {
        return;
    }
    ResourceLocation texture = container.getGateGuiFile();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(texture);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    for (AdvancedSlot slot : slots) {
        if (slot instanceof TriggerSlot) {
            boolean halfWidth = container.actionsState[((TriggerSlot) slot).slot] == ActionActiveState.Partial;
            if (container.actionsState[((TriggerSlot) slot).slot] != ActionActiveState.Deactivated) {
                mc.renderEngine.bindTexture(texture);
                drawTexturedModalRect(guiLeft + slot.x + 17 + 18 * gate.material.numTriggerParameters, guiTop + slot.y + 6, 176, 18, halfWidth ? 9 : 18, 4);
            }
        } else if (slot instanceof StatementParameterSlot) {
            StatementParameterSlot paramSlot = (StatementParameterSlot) slot;
            StatementSlot statement = paramSlot.statementSlot;
            mc.renderEngine.bindTexture(texture);
            if (statement.isDefined()) {
                if (!paramSlot.isAllowed()) {
                    drawTexturedModalRect(guiLeft + slot.x - 1, guiTop + slot.y - 1, 176, 0, 18, 18);
                } else if (paramSlot.isRequired() && paramSlot.getParameter() == null) {
                    drawTexturedModalRect(guiLeft + slot.x - 1, guiTop + slot.y - 1, 176, 22, 18, 18);
                }
            } else {
                drawTexturedModalRect(guiLeft + slot.x - 1, guiTop + slot.y - 1, 176, 0, 18, 18);
            }
        }
    }
    drawBackgroundSlots(x, y);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    // Make sure that render states are reset, an ItemStack can derp them up.
    GL11.glDisable(GL11.GL_LIGHTING);
    GlStateManager.disableLighting();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GlStateManager.enableAlpha();
    GL11.glEnable(GL11.GL_BLEND);
    GlStateManager.enableBlend();
    tooltip = null;
    int sX = 18;
    int sY = OPTION_TRIGGERS_Y.getAsInt();
    int width = OPTION_TRIGGERS_WIDE.getAsInt() * 18;
    triggerRows = 1;
    for (IStatement statement : container.getTriggerCollection(false)) {
        int pX = this.guiLeft - sX;
        int pY = this.guiTop + sY;
        if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
            String desc = statement.getDescription();
            tooltip = I18n.format(desc);
        }
        drawStatement(pX, pY, statement);
        if (sX >= width) {
            sX = 18;
            sY += 18;
            triggerRows++;
        } else {
            sX += 18;
            lastTriggerRowSize = sX;
        }
    }
    width = OPTION_ACTIONS_WIDE.getAsInt() * 18;
    sX = 0;
    sY = OPTION_ACTIONS_Y.getAsInt();
    actionRows = 1;
    for (IStatement statement : container.getActionCollection(false)) {
        int pX = this.guiLeft + this.xSize() + sX;
        int pY = this.guiTop + sY;
        drawStatement(pX, pY, statement);
        if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
            String desc = statement.getDescription();
            tooltip = I18n.format(desc);
        }
        if (sX >= width - 18) {
            sX = 0;
            sY += 18;
            actionRows++;
        } else {
            sX += 18;
            lastActionRowSize = sX;
        }
    }
    if (index != -1) {
        Collection<IStatement> collect;
        if (trigger)
            collect = container.getTriggerCollection(false);
        else
            collect = container.getActionCollection(false);
        IStatement state = null;
        int i = index;
        Iterator<IStatement> it = collect.iterator();
        while (i >= 0) {
            state = it.next();
            i--;
        }
        AdvancedSlot hoverSlot = getSlotAtLocation(x, y);
        boolean isValid = (trigger && hoverSlot instanceof TriggerSlot) || (!trigger && hoverSlot instanceof ActionSlot);
        if (!isValid) {
            GlStateManager.color(0.95f, 0.6f, 0.6f);
        }
        drawStatement(x - 8, y - 8, state);
        GlStateManager.color(1.0f, 1.0f, 1.0f);
    }
    GlStateManager.enableLighting();
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
}
Also used : StatementSlot(buildcraft.core.lib.gui.StatementSlot) AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) ResourceLocation(net.minecraft.util.ResourceLocation) IStatement(buildcraft.api.statements.IStatement) StatementParameterSlot(buildcraft.core.lib.gui.StatementParameterSlot)

Example 3 with AdvancedSlot

use of buildcraft.core.lib.gui.AdvancedSlot in project BuildCraft by BuildCraft.

the class GuiAssemblyTableOld method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    updateRecipes();
    for (AdvancedSlot slot2 : slots) {
        RecipeSlot slot = (RecipeSlot) slot2;
        if (slot.crafting != null) {
            if (!slot.craftable) {
                drawTexturedModalRect(guiLeft + slot.x, guiTop + slot.y, 215, 1, 16, 16);
            } else if (table.isAssembling(slot.crafting.recipe)) {
                drawTexturedModalRect(guiLeft + slot.x, guiTop + slot.y, 196, 1, 16, 16);
            } else if (table.isPlanned(slot.crafting.recipe)) {
                drawTexturedModalRect(guiLeft + slot.x, guiTop + slot.y, 177, 1, 16, 16);
            }
        }
    }
    int h = table.getProgressScaled(70);
    drawTexturedModalRect(guiLeft + 86, guiTop + 36 + 70 - h, 176, 18, 4, h);
    drawBackgroundSlots(x, y);
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot)

Example 4 with AdvancedSlot

use of buildcraft.core.lib.gui.AdvancedSlot in project BuildCraft by BuildCraft.

the class GuiProgrammingTable method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    updateRecipes();
    int i = 0;
    for (AdvancedSlot slot2 : slots) {
        RecipeSlot slot = (RecipeSlot) slot2;
        if (slot.slot != null) {
            if (table.optionId == i) {
                drawTexturedModalRect(guiLeft + slot.x, guiTop + slot.y, 196, 1, 16, 16);
            }
        }
        i++;
    }
    int h = table.getProgressScaled(70);
    drawTexturedModalRect(guiLeft + 164, guiTop + 36 + 70 - h, 176, 18, 4, h);
    drawBackgroundSlots(x, y);
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot)

Example 5 with AdvancedSlot

use of buildcraft.core.lib.gui.AdvancedSlot in project BuildCraft by BuildCraft.

the class GuiFiller method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int k) throws IOException {
    super.mouseClicked(x, y, k);
    AdvancedSlot slot = getSlotAtLocation(x, y);
    if (slot != null && !filler.isPatternLocked()) {
        int i = ((FillerParameterSlot) slot).slot;
        if (i < filler.patternParameters.length) {
            if (filler.patternParameters[i] != null) {
                filler.patternParameters[i].onClick(filler, filler.currentPattern, mc.thePlayer.inventory.getItemStack(), new StatementMouseClick(k, isShiftKeyDown()));
            } else {
                filler.patternParameters[i] = filler.currentPattern.createParameter(i);
            }
            filler.rpcSetParameter(i, filler.patternParameters[i]);
        }
    }
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) StatementMouseClick(buildcraft.api.statements.StatementMouseClick)

Aggregations

AdvancedSlot (buildcraft.core.lib.gui.AdvancedSlot)9 IStatement (buildcraft.api.statements.IStatement)3 StatementParameterSlot (buildcraft.core.lib.gui.StatementParameterSlot)2 CraftingResult (buildcraft.api.recipes.CraftingResult)1 IStatementParameter (buildcraft.api.statements.IStatementParameter)1 StatementMouseClick (buildcraft.api.statements.StatementMouseClick)1 RequirementItemStack (buildcraft.core.blueprints.RequirementItemStack)1 StatementSlot (buildcraft.core.lib.gui.StatementSlot)1 Tank (buildcraft.lib.fluids.Tank)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ResourceLocation (net.minecraft.util.ResourceLocation)1