Search in sources :

Example 1 with GuiArcaneCompendium

use of am2.guis.GuiArcaneCompendium 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 GuiArcaneCompendium

use of am2.guis.GuiArcaneCompendium in project ArsMagica2 by Mithion.

the class CompendiumEntryBoss method getCompendiumGui.

@Override
@SideOnly(Side.CLIENT)
protected GuiArcaneCompendium getCompendiumGui(String searchID, int meta) {
    String modEntityID = "arsmagica2." + searchID;
    Class entityClass = (Class) EntityList.stringToClassMapping.get(modEntityID);
    if (entityClass != null) {
        try {
            Constructor ctor = entityClass.getConstructor(World.class);
            return new GuiArcaneCompendium((Entity) ctor.newInstance(Minecraft.getMinecraft().theWorld));
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    return new GuiArcaneCompendium(searchID);
}
Also used : GuiArcaneCompendium(am2.guis.GuiArcaneCompendium) Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with GuiArcaneCompendium

use of am2.guis.GuiArcaneCompendium in project ArsMagica2 by Mithion.

the class CompendiumEntryMob method getCompendiumGui.

@Override
@SideOnly(Side.CLIENT)
protected GuiArcaneCompendium getCompendiumGui(String searchID, int meta) {
    String modEntityID = searchID.indexOf(".") == -1 ? "arsmagica2." + searchID : searchID;
    Class entityClass = (Class) EntityList.stringToClassMapping.get(modEntityID);
    if (entityClass != null) {
        try {
            Constructor ctor = entityClass.getConstructor(World.class);
            return new GuiArcaneCompendium((Entity) ctor.newInstance(Minecraft.getMinecraft().theWorld));
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    return new GuiArcaneCompendium(searchID);
}
Also used : GuiArcaneCompendium(am2.guis.GuiArcaneCompendium) Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 4 with GuiArcaneCompendium

use of am2.guis.GuiArcaneCompendium in project ArsMagica2 by Mithion.

the class CompendiumEntryRitual method getCompendiumGui.

@Override
@SideOnly(Side.CLIENT)
protected GuiArcaneCompendium getCompendiumGui(String searchID, int meta) {
    if (this.ritualShape != null) {
        try {
            Field f = RitualShapeHelper.class.getField(ritualShape);
            MultiblockStructureDefinition def = (MultiblockStructureDefinition) f.get(RitualShapeHelper.instance);
            ISkillTreeEntry entry = SkillManager.instance.getSkill(ritualController);
            if (entry instanceof IRitualInteraction) {
                IRitualInteraction controller = (IRitualInteraction) entry;
                return new GuiArcaneCompendium(searchID, def, controller);
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return new GuiArcaneCompendium(searchID);
}
Also used : Field(java.lang.reflect.Field) GuiArcaneCompendium(am2.guis.GuiArcaneCompendium) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) IRitualInteraction(am2.api.spell.component.interfaces.IRitualInteraction) MultiblockStructureDefinition(am2.api.blocks.MultiblockStructureDefinition) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 5 with GuiArcaneCompendium

use of am2.guis.GuiArcaneCompendium 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

GuiArcaneCompendium (am2.guis.GuiArcaneCompendium)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 CompendiumBreadcrumb (am2.guis.AMGuiHelper.CompendiumBreadcrumb)2 Constructor (java.lang.reflect.Constructor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MultiblockStructureDefinition (am2.api.blocks.MultiblockStructureDefinition)1 IRitualInteraction (am2.api.spell.component.interfaces.IRitualInteraction)1 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1 GuiButtonCompendiumLink (am2.guis.controls.GuiButtonCompendiumLink)1 GuiButtonCompendiumTab (am2.guis.controls.GuiButtonCompendiumTab)1 Field (java.lang.reflect.Field)1