mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
Achievement Information in the booklet
This commit is contained in:
parent
b0d920a159
commit
89a2fa20d3
3 changed files with 44 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet;
|
||||
|
||||
import ellpeck.actuallyadditions.achievement.InitAchievements;
|
||||
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
|
||||
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
|
||||
import ellpeck.actuallyadditions.booklet.entry.BookletEntryAllSearch;
|
||||
|
@ -19,6 +20,8 @@ import ellpeck.actuallyadditions.util.*;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -76,6 +79,45 @@ public class BookletUtils{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an Achievement Info if the page has items that trigger achievements
|
||||
* @param pre If the hover info texts or the icon should be drawn
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY){
|
||||
if(booklet.currentPage == null){
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack[] stacks = booklet.currentPage.getItemStacksForPage();
|
||||
ArrayList list = null;
|
||||
|
||||
for(ItemStack stack : stacks){
|
||||
for(Achievement achievement : InitAchievements.achievementList){
|
||||
if(stack != null && achievement.theItemStack != null && achievement.theItemStack.isItemEqual(stack)){
|
||||
if(pre){
|
||||
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
if(mouseX >= booklet.guiLeft+booklet.xSize+1 && mouseX < booklet.guiLeft+booklet.xSize+1+22 && mouseY >= booklet.guiTop-18 && mouseY < booklet.guiTop-18+21){
|
||||
if(list == null){
|
||||
list = new ArrayList();
|
||||
list.add(EnumChatFormatting.GOLD+"Achievements related to this page:");
|
||||
}
|
||||
list.add("-"+StringUtil.localize(achievement.statId));
|
||||
list.add(EnumChatFormatting.GRAY+"("+achievement.getDescription()+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(list != null){
|
||||
booklet.drawHoveringText(list, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-renders the booklet page, including
|
||||
* -the number of a page and its content (text, crafting recipe etc.)
|
||||
|
|
|
@ -102,6 +102,7 @@ public class GuiBooklet extends GuiScreen{
|
|||
|
||||
//Pre-Renders the current page's content etc.
|
||||
BookletUtils.renderPre(this, x, y, this.ticksElapsed, this.mousePressed);
|
||||
BookletUtils.drawAchievementInfo(this, true, x, y);
|
||||
|
||||
//Does vanilla drawing stuff
|
||||
super.drawScreen(x, y, f);
|
||||
|
@ -115,6 +116,7 @@ public class GuiBooklet extends GuiScreen{
|
|||
//Draws hovering texts for buttons
|
||||
this.fontRendererObj.setUnicodeFlag(false);
|
||||
BookletUtils.doHoverTexts(this, x, y);
|
||||
BookletUtils.drawAchievementInfo(this, false, x, y);
|
||||
this.fontRendererObj.setUnicodeFlag(unicodeBefore);
|
||||
|
||||
//Resets mouse
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in a new issue