Search in sources :

Example 1 with CategoryWrapper

use of amerifrance.guideapi.wrapper.CategoryWrapper in project Guide-API by TeamAmeriFrance.

the class GuiHome method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) {
    Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    Minecraft.getMinecraft().getTextureManager().bindTexture(outlineTexture);
    drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor());
    drawCenteredString(fontRenderer, book.getLocalizedWelcomeMessage().replace("\\n", "\n").replace("&", "ยง"), guiLeft + xSize / 2 + 1, guiTop + 15, 0);
    categoryPage = MathHelper.clamp(categoryPage, 0, categoryWrapperMap.size() - 1);
    for (CategoryWrapper wrapper : this.categoryWrapperMap.get(categoryPage)) if (wrapper.canPlayerSee())
        wrapper.draw(mouseX, mouseY, this);
    for (CategoryWrapper wrapper : this.categoryWrapperMap.get(categoryPage)) if (wrapper.canPlayerSee())
        wrapper.drawExtras(mouseX, mouseY, this);
    drawCenteredString(fontRenderer, String.format("%d/%d", categoryPage + 1, categoryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0);
    drawCenteredStringWithShadow(fontRenderer, book.getLocalizedBookTitle(), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB());
    buttonPrev.visible = categoryPage != 0;
    buttonNext.visible = categoryPage != categoryWrapperMap.asMap().size() - 1 && !categoryWrapperMap.asMap().isEmpty();
    for (GuiButton button : this.buttonList) button.drawButton(this.mc, mouseX, mouseY);
}
Also used : CategoryWrapper(amerifrance.guideapi.wrapper.CategoryWrapper) GuiButton(net.minecraft.client.gui.GuiButton)

Example 2 with CategoryWrapper

use of amerifrance.guideapi.wrapper.CategoryWrapper in project Guide-API by TeamAmeriFrance.

the class GuiHome method initGui.

@Override
public void initGui() {
    this.buttonList.clear();
    this.categoryWrapperMap.clear();
    guiLeft = (this.width - this.xSize) / 2;
    guiTop = (this.height - this.ySize) / 2;
    addButton(buttonNext = new ButtonNext(0, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this));
    addButton(buttonPrev = new ButtonPrev(1, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this));
    addButton(buttonSearch = new ButtonSearch(2, guiLeft + xSize / 6, guiTop, this));
    int cX = guiLeft + 45;
    int cY = guiTop + 40;
    int drawLoc = 0;
    int i = 0;
    int pageNumber = 0;
    for (CategoryAbstract category : book.getCategoryList()) {
        category.onInit(book, this, player, bookStack);
        switch(drawLoc) {
            case 0:
                {
                    categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack));
                    cX += 27;
                    drawLoc = 1;
                    break;
                }
            case 1:
                {
                    categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack));
                    cX += 27;
                    drawLoc = 2;
                    break;
                }
            case 2:
                {
                    categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack));
                    cX += 27;
                    drawLoc = 3;
                    break;
                }
            case 3:
                {
                    categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack));
                    drawLoc = 0;
                    cX = guiLeft + 45;
                    cY += 30;
                    break;
                }
        }
        i++;
        if (i >= 16) {
            i = 0;
            cX = guiLeft + 45;
            cY = guiTop + 40;
            pageNumber++;
        }
    }
}
Also used : ButtonSearch(amerifrance.guideapi.button.ButtonSearch) CategoryWrapper(amerifrance.guideapi.wrapper.CategoryWrapper) CategoryAbstract(amerifrance.guideapi.api.impl.abstraction.CategoryAbstract) ButtonPrev(amerifrance.guideapi.button.ButtonPrev) ButtonNext(amerifrance.guideapi.button.ButtonNext)

Aggregations

CategoryWrapper (amerifrance.guideapi.wrapper.CategoryWrapper)2 CategoryAbstract (amerifrance.guideapi.api.impl.abstraction.CategoryAbstract)1 ButtonNext (amerifrance.guideapi.button.ButtonNext)1 ButtonPrev (amerifrance.guideapi.button.ButtonPrev)1 ButtonSearch (amerifrance.guideapi.button.ButtonSearch)1 GuiButton (net.minecraft.client.gui.GuiButton)1