Search in sources :

Example 6 with GuiIcon

use of buildcraft.lib.gui.GuiIcon in project BuildCraft by BuildCraft.

the class GuidePageContents method renderPage.

@Override
protected void renderPage(int x, int y, int width, int height, int index) {
    IFontRenderer f = getFontRenderer();
    if (index == 0) {
        String text = "BuildCraft";
        float scale = 3;
        int fWidth = (int) (f.getStringWidth(text) * scale);
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, 1);
        f.drawString(text, (int) ((x + (width - fWidth) / 2) / scale), (int) ((y + height / 2 - 62) / scale), 0);
        GlStateManager.popMatrix();
        text = "v" + BCLib.VERSION;
        fWidth = f.getStringWidth(text);
        f.drawString(text, x + (width - fWidth) / 2, y + height / 2 - 36, 0);
        scale = 1.5f;
        text = LocaleUtil.localize("options.title");
        fWidth = (int) (f.getStringWidth(text) * scale);
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, 1);
        f.drawString(text, (int) ((x + (width - fWidth) / 2) / scale), (int) ((y + height / 2 - 4) / scale), 0);
        GlStateManager.popMatrix();
        text = XmlPageLoader.SHOW_LORE ? "Show Lore [x]" : "Show Lore [ ]";
        fWidth = f.getStringWidth(text);
        f.drawString(text, x + (width - fWidth) / 2, y + height / 2 + 12, 0);
        text = XmlPageLoader.SHOW_HINTS ? "Show Hints [x]" : "Show Hints [ ]";
        fWidth = f.getStringWidth(text);
        f.drawString(text, x + (width - fWidth) / 2, y + height / 2 + 26, 0);
    } else if (index == 1) {
        int _height = GuideManager.loadedMods.size() + 1;
        if (GuideManager.loadedOther.size() > 0) {
            _height++;
            _height += GuideManager.loadedOther.size();
        }
        int perLineHeight = f.getFontHeight("Ly") + 3;
        _height *= perLineHeight;
        int _y = y + (height - _height) / 2;
        drawCenteredText(TextFormatting.BOLD + "Loaded Mods:", x, _y, width);
        _y += perLineHeight;
        for (String text : GuideManager.loadedMods) {
            drawCenteredText(text, x, _y, width);
            _y += perLineHeight;
        }
        if (GuideManager.loadedOther.size() > 0) {
            drawCenteredText(TextFormatting.BOLD + "Loaded Resource Packs:", x, _y, width);
            _y += perLineHeight;
            for (String text : GuideManager.loadedOther) {
                drawCenteredText(text, x, _y, width);
                _y += perLineHeight;
            }
        }
    } else if (index % 2 == 0) {
        searchText.x = x + 23;
        searchText.y = y - 23;
        if (!searchText.isFocused() && searchText.getText().isEmpty()) {
            GuiGuide.SEARCH_TAB_CLOSED.drawAt(x + 8, y - 20);
            GuiGuide.SEARCH_ICON.drawAt(x + 8, y - 19);
        } else {
            GuiGuide.SEARCH_TAB_OPEN.drawAt(x - 2, y - 29);
            GuiGuide.SEARCH_ICON.drawAt(x + 8, y - 25);
        }
        searchText.drawTextBox();
    }
    RenderUtil.setGLColorFromInt(-1);
    PagePosition pos = new PagePosition(2, 0);
    for (Title title : contents.visibleTitles) {
        SubHeader firstHeader = title.visibleHeaders[0];
        PageLink firstPage = firstHeader.visiblePages[0];
        pos = pos.guaranteeSpace(32 + gui.getCurrentFont().getFontHeight(firstPage.text.text.text), height);
        pos = title.chapter.renderIntoArea(x, y, width, height, pos, index);
        for (SubHeader header : title.visibleHeaders) {
            firstPage = header.visiblePages[0];
            pos = pos.guaranteeSpace(gui.getCurrentFont().getFontHeight(firstPage.text.text.text), height);
            pos = header.text.renderIntoArea(x, y, width, height, pos, index);
            for (PageLink page : header.visiblePages) {
                pos = page.renderIntoArea(x, y, width, height, pos, index);
            }
        }
    }
    if (numPages == -1) {
        numPages = pos.page + 1;
    }
    super.renderPage(x, y, width, height, index);
    if (index % 2 == 0) {
        int oX = x + ORDER_OFFSET_X;
        int oY = y + ORDER_OFFSET_Y;
        int i = 0;
        for (GuiIcon icon : GuiGuide.ORDERS) {
            if (gui.sortingOrderIndex == i) {
                icon = icon.offset(0, 14);
            }
            icon.drawAt(oX, oY);
            oY += 14;
            i++;
        }
    }
}
Also used : SubHeader(buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader) PageLink(buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader.PageLink) Title(buildcraft.lib.client.guide.parts.contents.ContentsList.Title) IFontRenderer(buildcraft.lib.client.guide.font.IFontRenderer) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 7 with GuiIcon

use of buildcraft.lib.gui.GuiIcon in project BuildCraft by BuildCraft.

the class GuiGuide method drawOpen.

private void drawOpen(float partialTicks) {
    // Draw the pages
    mc.renderEngine.bindTexture(LEFT_PAGE);
    PAGE_LEFT.drawAt(minX, minY);
    mc.renderEngine.bindTexture(RIGHT_PAGE);
    PAGE_RIGHT.drawAt(minX + PAGE_LEFT.width, minY);
    isOverHover = PEN_HIDDEN_AREA.offset(minX, minY).contains(mouse);
    // Now draw the actual contents of the book
    String title = currentPage.getTitle();
    if (title != null) {
        int x = /* this.minX + */
        (width - currentFont.getStringWidth(title)) / 2;
        currentFont.drawString(title, x, minY + 12, 0);
    }
    tooltipStack = null;
    tooltip.clear();
    setupFontRenderer();
    for (GuideChapter chapter : chapters) {
        chapter.reset();
    }
    currentPage.renderFirstPage(minX + (int) PAGE_LEFT_TEXT.x, minY + (int) PAGE_LEFT_TEXT.y, (int) PAGE_LEFT_TEXT.width, (int) PAGE_LEFT_TEXT.height);
    currentPage.renderSecondPage(minX + PAGE_LEFT.width + (int) PAGE_RIGHT_TEXT.x, minY + (int) PAGE_RIGHT_TEXT.y, (int) PAGE_RIGHT_TEXT.width, (int) PAGE_RIGHT_TEXT.height);
    int chapterIndex = 0;
    for (GuideChapter chapter : chapters) {
        chapter.draw(chapterIndex, partialTicks);
        chapterIndex++;
    }
    // Draw the back button if there are any pages on the stack
    if (!pages.isEmpty()) {
        GuiIcon icon = BACK;
        IGuiArea position = BACK_POSITION.offset(minX, minY);
        if (position.contains(mouse)) {
            icon = BACK_HOVERED;
        }
        icon.drawAt(position);
    }
    // Reset the colour for the pen
    GlStateManager.color(1, 1, 1);
    // Draw the pen
    if (isEditing) {
        mc.renderEngine.bindTexture(ICONS_2);
        if (isOverHover) {
            PEN_UP.drawAt(mouse.getX() - PEN_UP.width / 2, mouse.getY() - PEN_UP.height);
        } else {
            PEN_ANGLED.drawAt(mouse.getX() - 2, mouse.getY() - PEN_ANGLED.height - 2);
        }
    } else {
        int h = (int) (hoverStageLast * (1 - partialTicks) + hoverStageNext * partialTicks);
        // Draw pen
        mc.renderEngine.bindTexture(ICONS_2);
        drawTexturedModalRect(minX + PAGE_LEFT.width - PEN_HIDDEN_WIDTH / 2, minY - h, PEN_HIDDEN_X, PEN_HIDDEN_Y, PEN_HIDDEN_WIDTH, h);
        if (tooltipStack != null) {
            renderToolTip(tooltipStack, (int) mouse.getX(), (int) mouse.getY());
        } else if (!tooltip.isEmpty()) {
            drawHoveringText(tooltip, (int) mouse.getX(), (int) mouse.getY());
        }
    }
}
Also used : GuideChapter(buildcraft.lib.client.guide.parts.GuideChapter) IGuiArea(buildcraft.lib.gui.pos.IGuiArea) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 8 with GuiIcon

use of buildcraft.lib.gui.GuiIcon in project BuildCraft by BuildCraft.

the class GuidePageBase method handleMouseClick.

public void handleMouseClick(int x, int y, int width, int height, int mouseX, int mouseY, int mouseButton, int index, boolean isEditing) {
    // Even => first page, test page back button and first page text clicks
    if (index % 2 == 0) {
        if (index != 0) {
            GuiIcon icon = GuiGuide.TURN_BACK;
            GuiRectangle turnBox = new GuiRectangle(x, y + height, icon.width, icon.height);
            if (turnBox.contains(gui.mouse)) {
                lastPage();
            }
        }
    } else {
        // Odd => second page, test forward page button
        if (index + 1 < numPages) {
            GuiIcon icon = GuiGuide.TURN_FORWARDS;
            GuiRectangle turnBox = new GuiRectangle(x + width - icon.width, y + height, icon.width, icon.height);
            if (turnBox.contains(gui.mouse)) {
                nextPage();
            }
        }
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) GuiIcon(buildcraft.lib.gui.GuiIcon)

Aggregations

GuiIcon (buildcraft.lib.gui.GuiIcon)8 EnumPipePart (buildcraft.api.core.EnumPipePart)2 ISprite (buildcraft.api.core.render.ISprite)2 IStatementParameter (buildcraft.api.statements.IStatementParameter)2 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)2 StatementWrapper (buildcraft.lib.statement.StatementWrapper)2 IFontRenderer (buildcraft.lib.client.guide.font.IFontRenderer)1 GuideChapter (buildcraft.lib.client.guide.parts.GuideChapter)1 Title (buildcraft.lib.client.guide.parts.contents.ContentsList.Title)1 SubHeader (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader)1 PageLink (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader.PageLink)1 IGuiElement (buildcraft.lib.gui.IGuiElement)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1 IReference (buildcraft.lib.misc.data.IReference)1 ItemStack (net.minecraft.item.ItemStack)1