Search in sources :

Example 1 with IFontRenderer

use of buildcraft.lib.client.guide.font.IFontRenderer in project BuildCraft by BuildCraft.

the class GuidePageContents method drawCenteredText.

private void drawCenteredText(String text, int x, int y, int width) {
    IFontRenderer f = getFontRenderer();
    int fWidth = f.getStringWidth(text);
    f.drawString(text, (x + (width - fWidth) / 2), y, 0);
}
Also used : IFontRenderer(buildcraft.lib.client.guide.font.IFontRenderer)

Example 2 with IFontRenderer

use of buildcraft.lib.client.guide.font.IFontRenderer in project BuildCraft by BuildCraft.

the class GuideChapter method draw.

public EnumGuiSide draw(int index, float partialTicks) {
    IFontRenderer font = gui.getCurrentFont();
    String text = chapter.text;
    float hoverWidth = getHoverWidth(partialTicks);
    float width = font.getStringWidth(text) + hoverWidth;
    int colour = COLOURS[index % COLOURS.length];
    int y = gui.minY + 20 * (index + 1);
    if (lastDrawn == EnumGuiSide.LEFT) {
        float x = gui.minX - width - 4 + 11;
        RenderUtil.setGLColorFromInt(colour);
        GuiGuide.CHAPTER_MARKER_LEFT.drawAt(x - 5, y - 4);
        float oX = x - 5 + GuiGuide.CHAPTER_MARKER_LEFT.width;
        GuiGuide.CHAPTER_MARKER_SPACE.drawScaledInside(oX, y - 4, width + 4, 16);
        RenderUtil.setGLColorFromInt(-1);
        font.drawString(text, (int) x, y, 0);
    } else if (lastDrawn == EnumGuiSide.RIGHT) {
        int x = gui.minX + GuiGuide.PAGE_LEFT.width + GuiGuide.PAGE_RIGHT.width - 11;
        RenderUtil.setGLColorFromInt(colour);
        GuiGuide.CHAPTER_MARKER_SPACE.drawScaledInside(x, y - 4, width + 4, 16);
        GuiGuide.CHAPTER_MARKER_RIGHT.drawAt(x + width + 4, y - 4);
        RenderUtil.setGLColorFromInt(-1);
        font.drawString(text, (int) (x + 4 + hoverWidth), y, 0);
    }
    return lastDrawn;
}
Also used : IFontRenderer(buildcraft.lib.client.guide.font.IFontRenderer)

Example 3 with IFontRenderer

use of buildcraft.lib.client.guide.font.IFontRenderer in project BuildCraft by BuildCraft.

the class GuidePageContents method drawScaledCenteredText.

private void drawScaledCenteredText(float scale, String text, int x, int y, int width) {
    IFontRenderer f = getFontRenderer();
    int fWidth = (int) (f.getStringWidth(text) * scale);
    if (scale != 1) {
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, 1);
    }
    f.drawString(text, (int) ((x + (width - fWidth) / 2) / scale), (int) (y / scale), 0);
    if (scale != 1) {
        GlStateManager.popMatrix();
    }
}
Also used : IFontRenderer(buildcraft.lib.client.guide.font.IFontRenderer)

Example 4 with IFontRenderer

use of buildcraft.lib.client.guide.font.IFontRenderer 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 5 with IFontRenderer

use of buildcraft.lib.client.guide.font.IFontRenderer in project BuildCraft by BuildCraft.

the class GuidePageContents method handleMouseClick.

@Override
public void handleMouseClick(int x, int y, int width, int height, int mouseX, int mouseY, int mouseButton, int index, boolean isEditing) {
    super.handleMouseClick(x, y, width, height, mouseX, mouseY, mouseButton, index, isEditing);
    if (index % 2 == 0) {
        int oX = x + ORDER_OFFSET_X;
        int oY = y + ORDER_OFFSET_Y;
        for (int i = 0; i < GuiGuide.ORDERS.length; i++) {
            GuiRectangle rect = new GuiRectangle(oX, oY, 14, 14);
            if (rect.contains(gui.mouse)) {
                gui.sortingOrderIndex = i;
                loadMainGui();
                gui.refreshChapters();
                contents.setFontRenderer(getFontRenderer());
                return;
            }
            oY += 14;
        }
        if (!searchText.mouseClicked(mouseX, mouseY, mouseButton) && !searchText.isFocused() && new GuiRectangle(x - 2, y - 34, 40, 34).contains(mouseX, mouseY)) {
            searchText.setFocused(true);
        }
        if (mouseButton == 1 && mouseX >= searchText.x && mouseX < searchText.x + searchText.width && mouseY >= searchText.y && mouseY < searchText.y + searchText.height) {
            searchText.setText("");
        }
    }
    if (mouseButton == 0) {
        if (index == 0) {
            IFontRenderer f = getFontRenderer();
            String text = XmlPageLoader.SHOW_LORE ? "Show Lore [x]" : "Show Lore [ ]";
            int fWidth = f.getStringWidth(text);
            GuiRectangle rect;
            rect = new GuiRectangle(x + (width - fWidth) / 2, y + height / 2 + 12, fWidth, f.getFontHeight(text));
            if (rect.contains(mouseX, mouseY)) {
                XmlPageLoader.SHOW_LORE = !XmlPageLoader.SHOW_LORE;
            }
            text = XmlPageLoader.SHOW_HINTS ? "Show Hints [x]" : "Show Hints [ ]";
            fWidth = f.getStringWidth(text);
            rect = new GuiRectangle(x + (width - fWidth) / 2, y + height / 2 + 26, fWidth, f.getFontHeight(text));
            if (rect.contains(mouseX, mouseY)) {
                XmlPageLoader.SHOW_HINTS = !XmlPageLoader.SHOW_HINTS;
            }
        }
    }
    if (new GuiRectangle(x, y, width, height).contains(mouseX, mouseY)) {
        PagePosition pos = new PagePosition(2, 0);
        search: 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, -1);
            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, -1);
                for (PageLink page : header.visiblePages) {
                    pos = page.text.renderIntoArea(x, y, width, height, pos, -1);
                    if (pos.page == index && page.text.wasHovered()) {
                        page.onClicked();
                        break search;
                    }
                }
            }
        }
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) 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)

Aggregations

IFontRenderer (buildcraft.lib.client.guide.font.IFontRenderer)6 Title (buildcraft.lib.client.guide.parts.contents.ContentsList.Title)2 SubHeader (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader)2 PageLink (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader.PageLink)2 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)2 GuiIcon (buildcraft.lib.gui.GuiIcon)1