Search in sources :

Example 1 with CompendiumBreadcrumb

use of am2.guis.AMGuiHelper.CompendiumBreadcrumb in project ArsMagica2 by Mithion.

the class GuiCompendiumIndex method actionPerformed.

@Override
protected void actionPerformed(GuiButton buttonClicked) {
    if (buttonClicked.id == backToIndex.id) {
        CompendiumBreadcrumb crumb = AMGuiHelper.instance.popCompendiumBreadcrumb();
        Minecraft.getMinecraft().displayGuiScreen(new GuiCompendiumIndex(crumb));
        return;
    }
    if (buttonClicked instanceof GuiButtonCompendiumTab) {
        this.currentParentEntry = null;
        this.currentParentEntryName = null;
        this.activeCategory = ((GuiButtonCompendiumTab) buttonClicked).displayString;
        activeCategoryID = ((GuiButtonCompendiumTab) buttonClicked).categoryID;
        int visibleButtons = 0;
        for (Object button : this.buttonList) {
            if (button instanceof GuiButtonCompendiumTab) {
                ((GuiButtonCompendiumTab) button).setActive(false);
            } else if (button instanceof GuiButtonCompendiumLink) {
                if (((GuiButtonCompendiumLink) button).getCategory().equals(activeCategoryID) && ((GuiButtonCompendiumLink) button).getPageNum() == 0) {
                    ((GuiButtonCompendiumLink) button).visible = true;
                    visibleButtons++;
                } else {
                    ((GuiButtonCompendiumLink) button).visible = false;
                }
            }
        }
        if (visibleButtons == 0) {
            String zeroItemText = ArcaneCompendium.instance.getZeroItemText(activeCategoryID);
            lines = GuiArcaneCompendium.splitStringToLines(fontRendererObj, zeroItemText, lineWidth, maxLines);
        } else {
            lines = null;
        }
        ((GuiButtonCompendiumTab) buttonClicked).setActive(true);
        page = 0;
        prevPage.visible = false;
        if (getNumPages() > 0) {
            nextPage.visible = true;
        } else {
            nextPage.visible = false;
        }
    } else if (buttonClicked instanceof GuiButtonCompendiumLink) {
        this.currentParentEntry = null;
        if (((GuiButtonCompendiumLink) buttonClicked).hasSubItems()) {
            storeBreadcrumb();
            for (Object btn : this.buttonList) {
                if (btn instanceof GuiButtonCompendiumTab) {
                    ((GuiButtonCompendiumTab) btn).visible = false;
                }
            }
            backToIndex.visible = true;
            this.currentParentEntryName = ((GuiButtonCompendiumLink) buttonClicked).getEntryID();
            this.currentParentEntry = ArcaneCompendium.instance.getEntry(currentParentEntryName);
            this.activeCategoryID = this.activeCategoryID + ":" + this.currentParentEntryName;
            currentParentEntry.setIsNew(false);
            switchCategoryAndPage();
        } else {
            CompendiumEntry entry = ArcaneCompendium.instance.getEntry(((GuiButtonCompendiumLink) buttonClicked).getEntryID());
            if (entry != null) {
                storeBreadcrumb();
                GuiArcaneCompendium gui = entry.getCompendiumGui(((GuiButtonCompendiumLink) buttonClicked).getEntryID());
                if (gui != null) {
                    Minecraft.getMinecraft().displayGuiScreen(gui);
                }
            }
        }
    }
    if (getNumPages() > 0) {
        if (buttonClicked.id == nextPage.id && page < getNumPages()) {
            page++;
            switchCategoryAndPage();
            if (page == getNumPages()) {
                nextPage.visible = false;
            }
            prevPage.visible = true;
        } else if (buttonClicked.id == prevPage.id && page > 0) {
            page--;
            switchCategoryAndPage();
            if (page == 0) {
                prevPage.visible = false;
            }
            nextPage.visible = true;
        }
    }
}
Also used : CompendiumBreadcrumb(am2.guis.AMGuiHelper.CompendiumBreadcrumb) GuiButtonCompendiumLink(am2.guis.controls.GuiButtonCompendiumLink) GuiButtonCompendiumTab(am2.guis.controls.GuiButtonCompendiumTab)

Example 2 with CompendiumBreadcrumb

use of am2.guis.AMGuiHelper.CompendiumBreadcrumb in project ArsMagica2 by Mithion.

the class GuiArcaneCompendium method actionPerformed.

@Override
protected void actionPerformed(GuiButton par1GuiButton) {
    switch(par1GuiButton.id) {
        case //prev page
        0:
            if (page > 0)
                page--;
            break;
        case //next page
        1:
            if (page < numPages)
                page++;
            break;
        case 2:
            CompendiumBreadcrumb prevEntry = AMGuiHelper.instance.popCompendiumBreadcrumb();
            if (prevEntry != null) {
                if (prevEntry.entryType == prevEntry.TYPE_ENTRY)
                    Minecraft.getMinecraft().displayGuiScreen(new GuiArcaneCompendium(prevEntry));
                else
                    Minecraft.getMinecraft().displayGuiScreen(new GuiCompendiumIndex(prevEntry));
            } else {
                Minecraft.getMinecraft().displayGuiScreen(new GuiCompendiumIndex());
            }
            break;
        case 3:
            curLayer--;
            if (curLayer < -1) {
                curLayer = maxLayers;
            }
            break;
        case 4:
            curLayer++;
            if (curLayer > maxLayers) {
                curLayer = -1;
            }
            break;
        case 5:
            AMGuiHelper.instance.runCompendiumTicker = !AMGuiHelper.instance.runCompendiumTicker;
            pauseCycling.displayString = AMGuiHelper.instance.runCompendiumTicker ? StatCollector.translateToLocal("am2.gui.pause") : StatCollector.translateToLocal("am2.gui.cycle");
            break;
    }
}
Also used : CompendiumBreadcrumb(am2.guis.AMGuiHelper.CompendiumBreadcrumb)

Aggregations

CompendiumBreadcrumb (am2.guis.AMGuiHelper.CompendiumBreadcrumb)2 GuiButtonCompendiumLink (am2.guis.controls.GuiButtonCompendiumLink)1 GuiButtonCompendiumTab (am2.guis.controls.GuiButtonCompendiumTab)1