Search in sources :

Example 1 with ContainerKeystone

use of am2.items.ContainerKeystone in project ArsMagica2 by Mithion.

the class GuiKeystone method initGui.

@Override
public void initGui() {
    super.initGui();
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    combinationName = new GuiTextField(fontRendererObj, 44, 86, 88, 16);
    int sliderMax = Math.max(0, ItemsCommonProxy.keystone.numCombinations(((ContainerKeystone) this.inventorySlots).getKeystoneStack()) - 9);
    scrollBar = new GuiSlideControl(4, l + xSize + 58, i1 + 14, 159, "", 0, 0, Math.max(sliderMax, 1));
    scrollBar.setVertical();
    scrollBar.setButtonOnly();
    scrollBar.setOverrideTexture(background);
    scrollBar.setButtonProperties(184, 193, 190, 193, 6, 15);
    scrollBar.setScale(1.0f);
    scrollBar.setNoDynamicDisplay(true);
    if (sliderMax == 0)
        scrollBar.enabled = false;
    prevCombination = new GuiStatedImageButton(3, l + 8, i1 + 86, background, 208, 192);
    nextCombination = new GuiStatedImageButton(2, l + 152, i1 + 86, background, 208, 208);
    addCombination = new GuiStatedImageButton(0, l + 26, i1 + 86, background, 208, 224);
    forgetCombination = new GuiStatedImageButton(1, l + 134, i1 + 86, background, 208, 240);
    prevCombination.addStateCoords(GuiStatedImageButton.States.MOUSEOVER, 224, 192);
    nextCombination.addStateCoords(GuiStatedImageButton.States.MOUSEOVER, 224, 208);
    addCombination.addStateCoords(GuiStatedImageButton.States.MOUSEOVER, 224, 224);
    forgetCombination.addStateCoords(GuiStatedImageButton.States.MOUSEOVER, 224, 240);
    prevCombination.addStateCoords(GuiStatedImageButton.States.CLICK, 240, 192);
    nextCombination.addStateCoords(GuiStatedImageButton.States.CLICK, 240, 208);
    addCombination.addStateCoords(GuiStatedImageButton.States.CLICK, 240, 224);
    forgetCombination.addStateCoords(GuiStatedImageButton.States.CLICK, 240, 240);
    prevCombination.setDimensions(16, 16);
    nextCombination.setDimensions(16, 16);
    addCombination.setDimensions(16, 16);
    forgetCombination.setDimensions(16, 16);
    this.buttonList.add(addCombination);
    this.buttonList.add(forgetCombination);
    this.buttonList.add(nextCombination);
    this.buttonList.add(prevCombination);
    this.buttonList.add(scrollBar);
}
Also used : GuiStatedImageButton(am2.guis.controls.GuiStatedImageButton) GuiTextField(net.minecraft.client.gui.GuiTextField) GuiSlideControl(am2.guis.controls.GuiSlideControl)

Example 2 with ContainerKeystone

use of am2.items.ContainerKeystone in project ArsMagica2 by Mithion.

the class GuiKeystone method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    mc.renderEngine.bindTexture(new ResourceLocation("textures/atlas/items.png"));
    int numCombos = Math.min(ItemsCommonProxy.keystone.numCombinations(((ContainerKeystone) this.inventorySlots).getKeystoneStack()), comboScrollOffset + 9);
    int cx = xSize;
    int cy = 13;
    Tessellator t = Tessellator.instance;
    KeystoneCombination matchedCombo = ((ContainerKeystone) this.inventorySlots).getCurrentMatchedCombination();
    for (int i = comboScrollOffset; i < numCombos; ++i) {
        KeystoneCombination combo = ItemsCommonProxy.keystone.getCombinationAt(((ContainerKeystone) this.inventorySlots).getKeystoneStack(), i);
        if (matchedCombo != null && combo.equals(matchedCombo)) {
            currentCombination = i;
            for (int n = 0; n < combo.metas.length; ++n) {
                if (combo.metas[n] > -1) {
                    IIcon icon = AMGuiIcons.selectedRunes;
                    AMGuiHelper.DrawIconAtXY(icon, cx, cy, this.zLevel, 16, 16, true);
                }
                cx += 18;
            }
            mc.renderEngine.bindTexture(new ResourceLocation("textures/atlas/items.png"));
            cx = xSize;
        }
        for (int n = 0; n < combo.metas.length; ++n) {
            if (combo.metas[n] > -1) {
                IIcon icon = ItemsCommonProxy.rune.getIconFromDamage(combo.metas[n]);
                AMGuiHelper.DrawIconAtXY(icon, cx, cy, this.zLevel, 16, 16, true);
            }
            cx += 18;
        }
        cy += 18;
        cx = xSize;
    }
    mc.renderEngine.bindTexture(extras);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
    //special slot(s)
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
    int index = ((ContainerKeystone) this.inventorySlots).specialSlotIndex - 32;
    int x = 8 + 18 * index;
    int y = (((ContainerKeystone) this.inventorySlots).runebagSlot > -1) ? 216 : 179;
    drawTexturedModalRect(x, y, 0, 20, 16, 16);
    if (((ContainerKeystone) this.inventorySlots).runebagSlot > -1) {
        index = ((ContainerKeystone) this.inventorySlots).runebagSlot;
        x = 8 + 18 * (index % 9);
        y = index < 9 ? 216 : 140 + 18 * (int) Math.floor(index / 9f);
        drawTexturedModalRect(x, y, 0, 20, 16, 16);
    }
    GL11.glDisable(GL11.GL_BLEND);
    combinationName.drawTextBox();
    if (AMGuiHelper.instance.getSlowTicker() < displayTime) {
        fontRendererObj.drawSplitString(displayMessage, -90, 0, 90, displayColor);
    } else {
        displayTime = 0;
    }
    if (matchedCombo != null) {
        combinationName.setText(matchedCombo.name);
    }
    if (hoveredCombo > -1) {
        KeystoneCombination combo = ItemsCommonProxy.keystone.getCombinationAt(((ContainerKeystone) this.inventorySlots).getKeystoneStack(), hoveredCombo);
        ArrayList<String> lines = new ArrayList<String>();
        lines.add(combo.name);
        lines.add("\2477\247o" + StatCollector.translateToLocal("am2.gui.keystoneComboClick"));
        lines.add("\2477\247o" + StatCollector.translateToLocal("am2.gui.keystoneComboClick2") + "\247r");
        AMGuiHelper.drawHoveringText(lines, par1 - 25, par2 + 18, Minecraft.getMinecraft().fontRenderer, this.xSize, this.ySize);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) KeystoneCombination(am2.items.ItemKeystone.KeystoneCombination) IIcon(net.minecraft.util.IIcon) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ContainerKeystone(am2.items.ContainerKeystone)

Example 3 with ContainerKeystone

use of am2.items.ContainerKeystone in project ArsMagica2 by Mithion.

the class ServerGuiManager method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te == null && ID != ArsMagicaGuiIdList.GUI_SPELL_BOOK && ID != ArsMagicaGuiIdList.GUI_KEYSTONE && ID != ArsMagicaGuiIdList.GUI_ESSENCE_BAG && ID != ArsMagicaGuiIdList.GUI_RUNE_BAG && ID != ArsMagicaGuiIdList.GUI_RIFT && ID != ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION) {
        return null;
    }
    switch(ID) {
        case ArsMagicaGuiIdList.GUI_ESSENCE_REFINER:
            if (!(te instanceof TileEntityEssenceRefiner)) {
                return null;
            }
            return new ContainerEssenceRefiner(player.inventory, (TileEntityEssenceRefiner) te);
        case ArsMagicaGuiIdList.GUI_SPELL_BOOK:
            ItemStack bookStack = player.getCurrentEquippedItem();
            if (bookStack.getItem() == null || !(bookStack.getItem() instanceof ItemSpellBook)) {
                return null;
            }
            ItemSpellBook item = (ItemSpellBook) bookStack.getItem();
            return new ContainerSpellBook(player.inventory, player.getCurrentEquippedItem(), item.ConvertToInventory(bookStack));
        case ArsMagicaGuiIdList.GUI_CALEFACTOR:
            if (!(te instanceof TileEntityCalefactor)) {
                return null;
            }
            return new ContainerCalefactor(player, (TileEntityCalefactor) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE_LOCKABLE:
            if (!(te instanceof IKeystoneLockable)) {
                return null;
            }
            return new ContainerKeystoneLockable(player.inventory, (IKeystoneLockable) te);
        case ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER:
            if (!(te instanceof TileEntityAstralBarrier)) {
                return null;
            }
            return new ContainerAstralBarrier(player.inventory, (TileEntityAstralBarrier) te);
        case ArsMagicaGuiIdList.GUI_SEER_STONE:
            if (!(te instanceof TileEntitySeerStone)) {
                return null;
            }
            return new ContainerSeerStone(player.inventory, (TileEntitySeerStone) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE_CHEST:
            if (!(te instanceof TileEntityKeystoneChest)) {
                return null;
            }
            return new ContainerKeystoneChest(player.inventory, (TileEntityKeystoneChest) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE:
            ItemStack keystoneStack = player.getCurrentEquippedItem();
            if (keystoneStack.getItem() == null || !(keystoneStack.getItem() instanceof ItemKeystone)) {
                return null;
            }
            ItemKeystone keystone = (ItemKeystone) keystoneStack.getItem();
            int runeBagSlot = InventoryUtilities.getInventorySlotIndexFor(player.inventory, ItemsCommonProxy.runeBag);
            ItemStack runeBag = null;
            if (runeBagSlot > -1)
                runeBag = player.inventory.getStackInSlot(runeBagSlot);
            return new ContainerKeystone(player.inventory, player.getCurrentEquippedItem(), runeBag, keystone.ConvertToInventory(keystoneStack), runeBag == null ? null : ItemsCommonProxy.runeBag.ConvertToInventory(runeBag), runeBagSlot);
        case ArsMagicaGuiIdList.GUI_ESSENCE_BAG:
            ItemStack bagStack = player.getCurrentEquippedItem();
            if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemEssenceBag)) {
                return null;
            }
            ItemEssenceBag bag = (ItemEssenceBag) bagStack.getItem();
            return new ContainerEssenceBag(player.inventory, player.getCurrentEquippedItem(), bag.ConvertToInventory(bagStack));
        case ArsMagicaGuiIdList.GUI_RUNE_BAG:
            bagStack = player.getCurrentEquippedItem();
            if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemRuneBag)) {
                return null;
            }
            ItemRuneBag runebag = (ItemRuneBag) bagStack.getItem();
            return new ContainerRuneBag(player.inventory, player.getCurrentEquippedItem(), runebag.ConvertToInventory(bagStack));
        case ArsMagicaGuiIdList.GUI_ARCANE_RECONSTRUCTOR:
            if (!(te instanceof TileEntityArcaneReconstructor)) {
                return null;
            }
            return new ContainerArcaneReconstructor(player.inventory, (TileEntityArcaneReconstructor) te);
        case ArsMagicaGuiIdList.GUI_INSCRIPTION_TABLE:
            if (!(te instanceof TileEntityInscriptionTable)) {
                return null;
            }
            return new ContainerInscriptionTable((TileEntityInscriptionTable) te, player.inventory);
        case ArsMagicaGuiIdList.GUI_SUMMONER:
            if (!(te instanceof TileEntitySummoner)) {
                return null;
            }
            return new ContainerSummoner(player.inventory, (TileEntitySummoner) te);
        case ArsMagicaGuiIdList.GUI_MAGICIANS_WORKBENCH:
            if (!(te instanceof TileEntityMagiciansWorkbench)) {
                return null;
            }
            return new ContainerMagiciansWorkbench(player.inventory, (TileEntityMagiciansWorkbench) te);
        case ArsMagicaGuiIdList.GUI_RIFT:
            return new ContainerRiftStorage(player.inventory, RiftStorage.For(player));
        case ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION:
            return new ContainerSpellCustomization(player);
        case ArsMagicaGuiIdList.GUI_CRYSTAL_MARKER:
            if (!(te instanceof TileEntityCrystalMarker)) {
                return null;
            }
            return new ContainerCrystalMarker(player, (TileEntityCrystalMarker) te);
        case ArsMagicaGuiIdList.GUI_OBELISK:
            if (!(te instanceof TileEntityObelisk)) {
                return null;
            }
            return new ContainerObelisk((TileEntityObelisk) te, player);
        case ArsMagicaGuiIdList.GUI_FLICKER_HABITAT:
            if (!(te instanceof TileEntityFlickerHabitat)) {
                return null;
            }
            return new ContainerFlickerHabitat(player, (TileEntityFlickerHabitat) te);
        case ArsMagicaGuiIdList.GUI_ARMOR_INFUSION:
            if (!(te instanceof TileEntityArmorImbuer)) {
                return null;
            }
            return new ContainerArmorInfuser(player, (TileEntityArmorImbuer) te);
        case ArsMagicaGuiIdList.GUI_ARCANE_DECONSTRUCTOR:
            if (!(te instanceof TileEntityArcaneDeconstructor)) {
                return null;
            }
            return new ContainerArcaneDeconstructor(player.inventory, (TileEntityArcaneDeconstructor) te);
        case ArsMagicaGuiIdList.GUI_INERT_SPAWNER:
            if (!(te instanceof TileEntityInertSpawner)) {
                return null;
            }
            return new ContainerInertSpawner(player, (TileEntityInertSpawner) te);
        case ArsMagicaGuiIdList.GUI_SPELL_SEALED_DOOR:
            if (!(te instanceof TileEntitySpellSealedDoor)) {
                return null;
            }
            return new ContainerSpellSealedDoor(player.inventory, (TileEntitySpellSealedDoor) te);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IKeystoneLockable(am2.api.blocks.IKeystoneLockable) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ContainerKeystone

use of am2.items.ContainerKeystone in project ArsMagica2 by Mithion.

the class GuiKeystone method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == scrollBar) {
        comboScrollOffset = Math.round(scrollBar.getShiftedValue());
        return;
    }
    if (button == addCombination) {
        if (combinationName.getText() == null || combinationName.getText().trim().equals("")) {
            displayMessage = StatCollector.translateToLocal("am2.gui.nameRequired");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0xff0000;
        } else {
            displayMessage = StatCollector.translateToLocal("am2.gui.comboStored");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0x00ff00;
            int[] metas = new int[InventoryKeyStone.inventorySize];
            for (int i = 0; i < InventoryKeyStone.inventorySize; ++i) {
                ItemStack stack = this.keystoneInventory.getStackInSlot(i);
                metas[i] = stack != null ? stack.getItemDamage() : -1;
            }
            AMDataWriter writer = new AMDataWriter();
            writer.add(true);
            writer.add(combinationName.getText());
            for (int i = 0; i < metas.length; ++i) writer.add(metas[i]);
            AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SAVE_KEYSTONE_COMBO, writer.generate());
            ItemsCommonProxy.keystone.addCombination(((ContainerKeystone) this.inventorySlots).getKeystoneStack(), combinationName.getText(), metas);
            recalculateSlider();
        }
    } else if (button == forgetCombination) {
        KeystoneCombination matchedCombo = ((ContainerKeystone) this.inventorySlots).getCurrentMatchedCombination();
        if (matchedCombo == null) {
            displayMessage = StatCollector.translateToLocal("am2.gui.comboNotSaved");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0xff0000;
        } else {
            displayMessage = StatCollector.translateToLocal("am2.gui.comboRemoved");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0x00ff00;
            combinationName.setText("");
            AMDataWriter writer = new AMDataWriter();
            writer.add(false);
            writer.add(matchedCombo.name);
            for (int i = 0; i < matchedCombo.metas.length; ++i) writer.add(matchedCombo.metas[i]);
            AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SAVE_KEYSTONE_COMBO, writer.generate());
            ItemsCommonProxy.keystone.removeCombination(((ContainerKeystone) this.inventorySlots).getKeystoneStack(), matchedCombo.name);
            recalculateSlider();
        }
    } else {
        int numCombinatons = ItemsCommonProxy.keystone.numCombinations(((ContainerKeystone) this.inventorySlots).getKeystoneStack());
        int originalCombo = currentCombination;
        boolean changed = false;
        boolean skipped = false;
        if (numCombinatons == 0)
            return;
        if (numCombinatons == 1) {
            currentCombination = 0;
            if (((ContainerKeystone) this.inventorySlots).setInventoryToCombination(currentCombination))
                changed = true;
        } else {
            if (button == nextCombination) {
                currentCombination++;
                if (currentCombination >= numCombinatons)
                    currentCombination = 0;
                while (currentCombination != originalCombo) {
                    if (!((ContainerKeystone) this.inventorySlots).setInventoryToCombination(currentCombination)) {
                        currentCombination++;
                        if (currentCombination >= numCombinatons)
                            currentCombination = 0;
                        skipped = true;
                    } else {
                        changed = true;
                        break;
                    }
                }
            } else if (button == prevCombination) {
                currentCombination--;
                if (currentCombination < 0)
                    currentCombination = numCombinatons - 1;
                while (currentCombination != originalCombo) {
                    if (!((ContainerKeystone) this.inventorySlots).setInventoryToCombination(currentCombination)) {
                        currentCombination--;
                        if (currentCombination < 0)
                            currentCombination = numCombinatons - 1;
                        skipped = true;
                    } else {
                        changed = true;
                        break;
                    }
                }
            }
        }
        if (!changed) {
            displayMessage = StatCollector.translateToLocal("am2.gui.comboMissingRunes");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0xff0000;
        } else if (skipped) {
            displayMessage = StatCollector.translateToLocal("am2.gui.oneOrMoreSkipped");
            displayTime = AMGuiHelper.instance.getSlowTicker() + 3;
            displayColor = 0xff0000;
        }
    }
}
Also used : KeystoneCombination(am2.items.ItemKeystone.KeystoneCombination) ItemStack(net.minecraft.item.ItemStack) AMDataWriter(am2.network.AMDataWriter) ContainerKeystone(am2.items.ContainerKeystone)

Aggregations

ContainerKeystone (am2.items.ContainerKeystone)2 KeystoneCombination (am2.items.ItemKeystone.KeystoneCombination)2 ItemStack (net.minecraft.item.ItemStack)2 IKeystoneLockable (am2.api.blocks.IKeystoneLockable)1 GuiSlideControl (am2.guis.controls.GuiSlideControl)1 GuiStatedImageButton (am2.guis.controls.GuiStatedImageButton)1 AMDataWriter (am2.network.AMDataWriter)1 ArrayList (java.util.ArrayList)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IIcon (net.minecraft.util.IIcon)1 ResourceLocation (net.minecraft.util.ResourceLocation)1