Search in sources :

Example 1 with GuideChapter

use of buildcraft.lib.client.guide.parts.GuideChapter in project BuildCraft by BuildCraft.

the class GuiGuide method updateScreen.

@Override
public void updateScreen() {
    super.updateScreen();
    if (isOpen) {
        // Calculate pen hover position
        float hoverDiff = (PEN_HIDDEN_HEIGHT_MAX - PEN_HIDDEN_HEIGHT_MIN) / PEN_HOVER_TIME;
        hoverStageLast = hoverStageNext;
        if (hoverStageNext > PEN_HIDDEN_HEIGHT_MAX) {
            hoverStageNext -= hoverDiff * 5;
        } else if (isOverHover) {
            hoverStageNext += hoverDiff;
            if (hoverStageNext > PEN_HIDDEN_HEIGHT_MAX) {
                hoverStageNext = PEN_HIDDEN_HEIGHT_MAX;
            }
        } else {
            if (hoverStageNext > PEN_HIDDEN_HEIGHT_MIN) {
                hoverStageNext -= hoverDiff;
            }
            if (hoverStageNext < PEN_HIDDEN_HEIGHT_MIN) {
                hoverStageNext = PEN_HIDDEN_HEIGHT_MIN;
            }
        }
        currentPage.updateScreen();
        for (GuideChapter chapter : chapters) {
            chapter.updateScreen();
        }
    } else if (isOpening) {
        openingAngleLast = openingAngleNext;
        openingAngleNext += 180 / BOOK_OPEN_TIME;
    }
    if (currentPage != null) {
        setupFontRenderer();
        currentPage.tick();
    }
}
Also used : GuideChapter(buildcraft.lib.client.guide.parts.GuideChapter)

Example 2 with GuideChapter

use of buildcraft.lib.client.guide.parts.GuideChapter in project BuildCraft by BuildCraft.

the class GuiGuide method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    mouse.setMousePosition(mouseX, mouseY);
    // Primary mouse button
    if (mouseButton == 0) {
        if (isOpen) {
            int page0xMin = this.minX + (int) PAGE_LEFT_TEXT.x;
            int page0xMax = page0xMin + (int) PAGE_LEFT_TEXT.width;
            int page1xMin = this.minX + PAGE_LEFT.width + (int) PAGE_RIGHT_TEXT.x;
            int page1xMax = page1xMin + (int) PAGE_RIGHT_TEXT.width;
            int pageYMin = this.minY + (int) PAGE_RIGHT_TEXT.y;
            int pageYMax = pageYMin + (int) PAGE_RIGHT_TEXT.height;
            GuidePageBase current = currentPage;
            current.setFontRenderer(currentFont);
            for (GuideChapter chapter : chapters) {
                if (chapter.handleClick()) {
                    return;
                }
            }
            current.handleMouseClick(page0xMin, pageYMin, page0xMax - page0xMin, pageYMax - pageYMin, mouseX, mouseY, mouseButton, currentPage.getPage(), isEditing);
            current.handleMouseClick(page1xMin, pageYMin, page1xMax - page1xMin, pageYMax - pageYMin, mouseX, mouseY, mouseButton, currentPage.getPage() + 1, isEditing);
            if ((!pages.isEmpty()) && BACK_POSITION.offset(minX, minY).contains(mouse)) {
                closePage();
            }
            if (isOverHover) {
                isEditing = !isEditing;
                if (!isEditing) {
                    hoverStageNext = PEN_UP.height;
                }
            }
        } else {
            if (mouseX >= minX && mouseY >= minY && mouseX <= minX + BOOK_COVER.width && mouseY <= minY + BOOK_COVER.height) {
                if (isOpening) {
                    // So you can double-click to open it instantly
                    isOpen = true;
                }
                isOpening = true;
            }
        }
    }
}
Also used : GuideChapter(buildcraft.lib.client.guide.parts.GuideChapter) GuidePageBase(buildcraft.lib.client.guide.parts.GuidePageBase)

Example 3 with GuideChapter

use of buildcraft.lib.client.guide.parts.GuideChapter 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)

Aggregations

GuideChapter (buildcraft.lib.client.guide.parts.GuideChapter)3 GuidePageBase (buildcraft.lib.client.guide.parts.GuidePageBase)1 GuiIcon (buildcraft.lib.gui.GuiIcon)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1