Search in sources :

Example 6 with AdvancedSlot

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

the class GuiGateInterface method mouseReleased.

@Override
protected void mouseReleased(int mouseX, int mouseY, int eventType) {
    super.mouseReleased(mouseX, mouseY, eventType);
    if (index >= 0) {
        int i = index;
        index = -1;
        IStatement changeTo;
        Iterator<IStatement> it;
        if (trigger)
            it = container.getTriggerIterator(false);
        else
            it = container.getActionIterator(false);
        do {
            changeTo = it.next();
            i--;
        } while (i >= 0);
        AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
        if (slot == null)
            return;
        if (trigger && slot instanceof TriggerSlot) {
            TriggerSlot trig = (TriggerSlot) slot;
            container.setTrigger(trig.slot, changeTo.getUniqueTag(), true);
            for (StatementParameterSlot p : trig.parameters) {
                IStatementParameter parameter = null;
                if (p.slot < changeTo.minParameters()) {
                    parameter = changeTo.createParameter(p.slot);
                }
                container.setTriggerParameter(trig.slot, p.slot, parameter, true);
            }
        }
        if (!trigger && slot instanceof ActionSlot) {
            ActionSlot trig = (ActionSlot) slot;
            container.setAction(trig.slot, changeTo.getUniqueTag(), true);
            for (StatementParameterSlot p : trig.parameters) {
                IStatementParameter parameter = null;
                if (p.slot < changeTo.minParameters()) {
                    parameter = changeTo.createParameter(p.slot);
                }
                container.setActionParameter(trig.slot, p.slot, parameter, true);
            }
        }
    }
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) IStatementParameter(buildcraft.api.statements.IStatementParameter) IStatement(buildcraft.api.statements.IStatement) StatementParameterSlot(buildcraft.core.lib.gui.StatementParameterSlot)

Example 7 with AdvancedSlot

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

the class GuiGateInterface method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int type) throws IOException {
    if (gate == null) {
        return;
    }
    super.mouseClicked(x, y, type);
    AdvancedSlot slot = getSlotAtLocation(x, y);
    if (slot != null) {
        doSlotClick(slot, type);
        return;
    }
    int sX = 18;
    int sY = 6;
    Collection<IStatement> collect = container.getTriggerCollection(false);
    for (int i = 0; i < collect.size(); i++) {
        int pX = this.guiLeft - sX;
        int pY = this.guiTop + sY;
        if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
            trigger = true;
            index = i;
            return;
        }
        if (sX > 18 * 5) {
            sX = 18;
            sY += 18;
        } else
            sX += 18;
    }
    sX = 0;
    sY = 6;
    collect = container.getActionCollection(false);
    for (int i = 0; i < collect.size(); i++) {
        int pX = this.guiLeft + this.xSize() + sX;
        int pY = this.guiTop + sY;
        if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
            trigger = false;
            index = i;
            return;
        }
        if (sX > 18 * 4) {
            sX = 0;
            sY += 18;
        } else
            sX += 18;
    }
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) IStatement(buildcraft.api.statements.IStatement)

Example 8 with AdvancedSlot

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

the class GuiAssemblyTableOld method updateRecipes.

public void updateRecipes() {
    Set<String> addedRecipes = new HashSet<>();
    List<CraftingResult<ItemStack>> potentialRecipes = table.getPotentialOutputs();
    Iterator<CraftingResult<ItemStack>> cur = potentialRecipes.iterator();
    Collection<String> plannedIcons = table.plannedOutputIcons.keySet();
    Iterator<String> cur2 = plannedIcons.iterator();
    for (AdvancedSlot s : slots) {
        if (cur.hasNext()) {
            ((RecipeSlot) s).crafting = cur.next();
            ((RecipeSlot) s).craftable = true;
            addedRecipes.add(((RecipeSlot) s).crafting.recipe.getId());
        } else {
            String recipe = null;
            while (cur2.hasNext() && (recipe == null || addedRecipes.contains(recipe))) {
                recipe = cur2.next();
            }
            if (recipe != null && !addedRecipes.contains(recipe)) {
                ((RecipeSlot) s).crafting = table.plannedOutputIcons.get(recipe);
                ((RecipeSlot) s).craftable = false;
            } else {
                ((RecipeSlot) s).crafting = null;
            }
        }
    }
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot) CraftingResult(buildcraft.api.recipes.CraftingResult) HashSet(java.util.HashSet)

Example 9 with AdvancedSlot

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

the class GuiZonePlan method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    int blocksX = Math.round((mouseX - mapXMin) * blocksPerPixel);
    int blocksZ = Math.round((mouseY - mapYMin) * blocksPerPixel);
    int blockStartX = Math.round(cx - mapWidth * blocksPerPixel / 2);
    int blockStartZ = Math.round(cz - mapHeight * blocksPerPixel / 2);
    boolean clickOnMap = mouseX >= mapXMin && mouseX <= mapXMin + getContainer().mapTexture.width && mouseY >= mapYMin && mouseY <= mapYMin + getContainer().mapTexture.height;
    if (clickOnMap) {
        if (mouseButton == 1) {
            cx = blockStartX + blocksX;
            cz = blockStartZ + blocksZ;
            uploadMap();
            refreshSelectedArea();
            return;
        } else {
            inSelection = true;
            selX1 = mouseX;
            selY1 = mouseY;
            selX2 = 0;
            selY2 = 0;
            return;
        }
    }
    super.mouseClicked(mouseX, mouseY, mouseButton);
    textField.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
    AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
    if (slot instanceof AreaSlot) {
        colorSelected = (AreaSlot) slot;
        newSelection.setColor(0, 0, colorSelected.color.getDarkHex(), alpha);
        getContainer().loadArea(colorSelected.color.ordinal());
    }
}
Also used : AdvancedSlot(buildcraft.core.lib.gui.AdvancedSlot)

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