use of am2.guis.controls.GuiButtonCompendiumTab in project ArsMagica2 by Mithion.
the class GuiCompendiumIndex method initGui.
@Override
public void initGui() {
super.initGui();
int idCount = 0;
idCount = initTabs(idCount);
for (CompendiumEntryType category : categories) {
idCount = initButtonsForCategory(category.getCategoryName(), idCount, category.equals(activeCategory));
}
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
nextPage = new GuiButtonCompendiumNext(idCount++, l + 320, i1 + 13, true);
prevPage = new GuiButtonCompendiumNext(idCount++, l + 33, i1 + 13, false);
backToIndex = new GuiButtonCompendiumTab(idCount++, l - 10, i1 + 20, StatCollector.translateToLocal("am2.gui.back"), "back", null);
backToIndex.setActive(true);
backToIndex.visible = false;
updateButton = new GuiSpellImageButton(idCount++, l - 5, i1 + 10, ArcaneCompendium.instance.isModUpdateAvailable() ? AMGuiIcons.warning : AMGuiIcons.checkmark, 0, 0);
updateButton.setDimensions(10, 10);
updateButton.setPopupText(ArcaneCompendium.instance.isModUpdateAvailable() ? StatCollector.translateToLocal("am2.tooltip.updateAvailable") : StatCollector.translateToLocal("am2.tooltip.upToDate"));
this.buttonList.add(nextPage);
this.buttonList.add(prevPage);
this.buttonList.add(backToIndex);
if (AMCore.config.allowVersionChecks())
this.buttonList.add(updateButton);
switchCategoryAndPage();
if (this.currentParentEntry != null && this.currentParentEntry.hasSubItems()) {
for (Object btn : this.buttonList) {
if (btn instanceof GuiButtonCompendiumTab) {
((GuiButtonCompendiumTab) btn).visible = false;
}
}
backToIndex.visible = true;
}
if (page < getNumPages()) {
nextPage.visible = true;
} else {
nextPage.visible = false;
}
if (this.page > 0) {
prevPage.visible = true;
} else {
prevPage.visible = false;
}
}
use of am2.guis.controls.GuiButtonCompendiumTab 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;
}
}
}
use of am2.guis.controls.GuiButtonCompendiumTab in project ArsMagica2 by Mithion.
the class GuiArcaneCompendium method initGui.
@Override
public void initGui() {
super.initGui();
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
prevPage = new GuiButtonCompendiumNext(0, l + 35, i1 + ySize - 25, false);
nextPage = new GuiButtonCompendiumNext(1, l + 315, i1 + ySize - 25, true);
backToIndex = new GuiButtonCompendiumTab(2, l - 10, i1 + 20, StatCollector.translateToLocal("am2.gui.back"), "back", null);
backToIndex.setActive(true);
prevLayer = new GuiButtonCompendiumNext(3, l + 180, i1 + 19, false);
nextLayer = new GuiButtonCompendiumNext(4, l + 305, i1 + 19, true);
pauseCycling = new GuiButtonVariableDims(5, l + 285, i1 + 190, AMGuiHelper.instance.runCompendiumTicker ? StatCollector.translateToLocal("am2.gui.pause") : StatCollector.translateToLocal("am2.gui.cycle")).setDimensions(40, 20);
if (entryMultiblock != null) {
prevLayer.visible = true;
nextLayer.visible = true;
pauseCycling.visible = true;
maxLayers = entryMultiblock.getHeight();
} else {
prevLayer.visible = false;
nextLayer.visible = false;
pauseCycling.visible = false;
}
this.buttonList.add(nextPage);
this.buttonList.add(prevPage);
this.buttonList.add(prevLayer);
this.buttonList.add(nextLayer);
this.buttonList.add(backToIndex);
this.buttonList.add(pauseCycling);
}
use of am2.guis.controls.GuiButtonCompendiumTab in project ArsMagica2 by Mithion.
the class GuiCompendiumIndex method initTabs.
private int initTabs(int idCount) {
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
int tabX = l + 10;
int tabY = i1 + 40;
int tabWidth = 1;
int tabHeight = 16;
for (CompendiumEntryType category : this.categories) {
int unlockedSubItems = 0;
ArrayList<CompendiumEntry> itemsInCategory = ArcaneCompendium.instance.getEntriesForCategory(category.getCategoryName());
for (CompendiumEntry entry : itemsInCategory) if (!entry.isLocked())
unlockedSubItems++;
if (unlockedSubItems == 0)
continue;
GuiButtonCompendiumTab tab = new GuiButtonCompendiumTab(idCount++, tabX, tabY, category.getCategoryLabel(), category.getCategoryName(), category.getRepresentItem());
if (this.activeCategory.equals(category)) {
tab.setActive(true);
}
if (tabWidth < tab.getWidth())
tabWidth = tab.getWidth();
tabY += 18;
tabX--;
this.buttonList.add(tab);
}
for (Object button : this.buttonList) {
((GuiButtonCompendiumTab) button).setDimensions(tabWidth, tabHeight);
}
return idCount;
}
Aggregations