Search in sources :

Example 1 with GuiButtonManualNavigation

use of blusunrize.lib.manual.gui.GuiButtonManualNavigation in project ImmersiveEngineering by BluSunrize.

the class ManualPageMultiblock method initPage.

@Override
public void initPage(GuiManual gui, int x, int y, List<GuiButton> pageButtons) {
    int yOff = 0;
    if (multiblock.getStructureManual() != null) {
        this.renderInfo = new MultiblockRenderInfo(multiblock);
        this.blockAccess = new MultiblockBlockAccess(renderInfo);
        transX = x + 60 + renderInfo.structureWidth / 2;
        transY = y + 35 + (float) Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight + renderInfo.structureWidth * renderInfo.structureWidth + renderInfo.structureLength * renderInfo.structureLength) / 2;
        rotX = 25;
        rotY = -45;
        scale = multiblock.getManualScale();
        boolean canRenderFormed = multiblock.canRenderFormedStructure();
        yOff = (int) (transY + scale * Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight + renderInfo.structureWidth * renderInfo.structureWidth + renderInfo.structureLength * renderInfo.structureLength) / 2);
        pageButtons.add(new GuiButtonManualNavigation(gui, 100, x + 4, (int) transY - (canRenderFormed ? 11 : 5), 10, 10, 4));
        if (canRenderFormed)
            pageButtons.add(new GuiButtonManualNavigation(gui, 103, x + 4, (int) transY + 1, 10, 10, 6));
        if (this.renderInfo.structureHeight > 1) {
            pageButtons.add(new GuiButtonManualNavigation(gui, 101, x + 4, (int) transY - (canRenderFormed ? 14 : 8) - 16, 10, 16, 3));
            pageButtons.add(new GuiButtonManualNavigation(gui, 102, x + 4, (int) transY + (canRenderFormed ? 14 : 8), 10, 16, 2));
        }
    }
    IngredientStack[] totalMaterials = this.multiblock.getTotalMaterials();
    if (totalMaterials != null) {
        componentTooltip = new ArrayList();
        componentTooltip.add(I18n.format("desc.immersiveengineering.info.reqMaterial"));
        int maxOff = 1;
        boolean hasAnyItems = false;
        boolean[] hasItems = new boolean[totalMaterials.length];
        for (int ss = 0; ss < totalMaterials.length; ss++) if (totalMaterials[ss] != null) {
            IngredientStack req = totalMaterials[ss];
            int reqSize = req.inputSize;
            for (int slot = 0; slot < ManualUtils.mc().thePlayer.inventory.getSizeInventory(); slot++) {
                ItemStack inSlot = ManualUtils.mc().thePlayer.inventory.getStackInSlot(slot);
                if (inSlot != null && req.matchesItemStackIgnoringSize(inSlot))
                    if ((reqSize -= inSlot.stackSize) <= 0)
                        break;
            }
            if (reqSize <= 0) {
                hasItems[ss] = true;
                if (!hasAnyItems)
                    hasAnyItems = true;
            }
            maxOff = Math.max(maxOff, ("" + req.inputSize).length());
        }
        for (int ss = 0; ss < totalMaterials.length; ss++) if (totalMaterials[ss] != null) {
            IngredientStack req = totalMaterials[ss];
            int indent = maxOff - ("" + req.inputSize).length();
            String sIndent = "";
            if (indent > 0)
                for (int ii = 0; ii < indent; ii++) sIndent += "0";
            String s = hasItems[ss] ? (TextFormatting.GREEN + TextFormatting.BOLD.toString() + "✓" + TextFormatting.RESET + " ") : hasAnyItems ? ("   ") : "";
            s += TextFormatting.GRAY + sIndent + req.inputSize + "x " + TextFormatting.RESET;
            ItemStack example = req.getExampleStack();
            if (example != null)
                s += example.getRarity().rarityColor + example.getDisplayName();
            else
                s += "???";
            componentTooltip.add(s);
        }
    }
    super.initPage(gui, x, yOff, pageButtons);
}
Also used : GuiButtonManualNavigation(blusunrize.lib.manual.gui.GuiButtonManualNavigation) ArrayList(java.util.ArrayList) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) ItemStack(net.minecraft.item.ItemStack)

Example 2 with GuiButtonManualNavigation

use of blusunrize.lib.manual.gui.GuiButtonManualNavigation in project ImmersiveEngineering by BluSunrize.

the class ManualPageShader method initPage.

@Override
public void initPage(GuiManual gui, int x, int y, List<GuiButton> pageButtons) {
    EntityPlayer player = ManualUtils.mc().thePlayer;
    String username = player.getName();
    unlocked = ShaderRegistry.receivedShaders.get(username).contains(shader.getName());
    shaderItem = new ItemStack(ShaderRegistry.itemShader);
    shaderItem.setTagCompound(new NBTTagCompound());
    shaderItem.getTagCompound().setString("shader_name", shader.getName());
    replicationCost = shader.replicationCost;
    if (unlocked) {
        ArrayList<ItemStack> list = new ArrayList<ItemStack>();
        for (ItemStack is : ShaderRegistry.itemExamples) if (is != null && is.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
            ItemStack s = is.copy();
            ShaderWrapper wrapper = s.getCapability(CapabilityShader.SHADER_CAPABILITY, null);
            if (wrapper != null) {
                wrapper.setShaderItem(shaderItem);
                list.add(s);
            }
        }
        exampleItems = list.toArray(new ItemStack[list.size()]);
        example = 0;
        if (exampleItems.length > 1) {
            pageButtons.add(new GuiButtonManualNavigation(gui, 100, x + 50, y, 10, 16, 0));
            pageButtons.add(new GuiButtonManualNavigation(gui, 101, x + 100, y, 10, 16, 1));
        }
    } else
        exampleItems = null;
    this.text = "§lRarity: §r" + " " + shader.rarity.rarityName;
    if (unlocked) {
        String set = shader.info_set == null || shader.info_set.isEmpty() ? null : ManualUtils.attemptStringTranslation(Lib.DESC_INFO + "shader.set.%s", shader.info_set);
        String reference = shader.info_reference == null || shader.info_reference.isEmpty() ? null : ManualUtils.attemptStringTranslation(Lib.DESC_INFO + "shader.reference.%s", shader.info_reference);
        String details = shader.info_details == null || shader.info_details.isEmpty() ? null : ManualUtils.attemptStringTranslation(Lib.DESC_INFO + "shader.details.%s", shader.info_details);
        if (set != null)
            this.text += "<br><br>" + I18n.format("desc.immersiveengineering.info.shader.set") + " " + set;
        if (reference != null)
            this.text += "<br><br>" + I18n.format("desc.immersiveengineering.info.shader.reference") + "<br>" + reference;
        if (details != null)
            this.text += "<br><br>" + I18n.format("desc.immersiveengineering.info.shader.details") + "<br>" + details;
        String cost = Integer.toString(replicationCost.inputSize);
        if (!ApiUtils.hasPlayerIngredient(gui.mc.thePlayer, replicationCost) && !gui.mc.thePlayer.capabilities.isCreativeMode)
            cost = TextFormatting.RED + cost;
        pageButtons.add(new GuiButtonManual(gui, 102, x + 50, y + 138, 70, 12, TextFormatting.BOLD + I18n.format("ie.manual.entry.shaderList.order") + " " + cost + "x   ").setTextColour(gui.getManual().getTextColour(), gui.getManual().getHighlightColour()));
    } else {
        this.text += "<br><br>" + I18n.format("ie.manual.entry.shaderList.noInfo");
        if (player.capabilities.isCreativeMode)
            pageButtons.add(new GuiButtonManual(gui, 103, x + 10, y + 80, 100, 16, I18n.format("ie.manual.entry.shaderList.unlock")).setTextColour(gui.getManual().getTextColour(), gui.getManual().getHighlightColour()));
    }
    super.initPage(gui, x, y, pageButtons);
}
Also used : GuiButtonManual(blusunrize.lib.manual.gui.GuiButtonManual) GuiButtonManualNavigation(blusunrize.lib.manual.gui.GuiButtonManualNavigation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ArrayList(java.util.ArrayList) ShaderWrapper(blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GuiButtonManualNavigation (blusunrize.lib.manual.gui.GuiButtonManualNavigation)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 IngredientStack (blusunrize.immersiveengineering.api.crafting.IngredientStack)1 ShaderWrapper (blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper)1 GuiButtonManual (blusunrize.lib.manual.gui.GuiButtonManual)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1