Made Achievement Info work for entire chapters

This commit is contained in:
Ellpeck 2015-11-14 01:18:37 +01:00
parent 89a2fa20d3
commit abf4202da8
2 changed files with 28 additions and 26 deletions

View file

@ -83,38 +83,38 @@ public class BookletUtils{
* Draws an Achievement Info if the page has items that trigger achievements * 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 * @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){ public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY){
if(booklet.currentPage == null){ if(booklet.currentChapter == null){
return; return;
} }
ItemStack[] stacks = booklet.currentPage.getItemStacksForPage(); ArrayList<String> infoList = null;
ArrayList list = null; for(BookletPage page : booklet.currentChapter.pages){
for(ItemStack stack : page.getItemStacksForPage()){
for(ItemStack stack : stacks){
for(Achievement achievement : InitAchievements.achievementList){ for(Achievement achievement : InitAchievements.achievementList){
if(stack != null && achievement.theItemStack != null && achievement.theItemStack.isItemEqual(stack)){ if(stack != null && achievement.theItemStack != null && achievement.theItemStack.isItemEqual(stack)){
if(pre){ if(pre){
booklet.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21); booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21);
return; return;
} }
else{ 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(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){ if(infoList == null){
list = new ArrayList(); infoList = new ArrayList<String>();
list.add(EnumChatFormatting.GOLD+"Achievements related to this page:"); infoList.add(EnumChatFormatting.GOLD+"Achievements related to this chapter:");
}
infoList.add("-"+StringUtil.localize(achievement.statId));
infoList.add(EnumChatFormatting.GRAY+"("+achievement.getDescription()+")");
} }
list.add("-"+StringUtil.localize(achievement.statId));
list.add(EnumChatFormatting.GRAY+"("+achievement.getDescription()+")");
} }
} }
} }
} }
} }
if(list != null){ if(infoList != null){
booklet.drawHoveringText(list, mouseX, mouseY); booklet.drawHoveringText(infoList, mouseX, mouseY);
} }
} }

View file

@ -88,22 +88,24 @@ public class GuiBooklet extends GuiScreen{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(ClientProxy.jingleAllTheWay ? resLocChristmas : (ClientProxy.pumpkinBlurPumpkinBlur ? resLocHalloween : (ClientProxy.bulletForMyValentine ? resLocValentine : resLoc))); this.mc.getTextureManager().bindTexture(ClientProxy.jingleAllTheWay ? resLocChristmas : (ClientProxy.pumpkinBlurPumpkinBlur ? resLocHalloween : (ClientProxy.bulletForMyValentine ? resLocValentine : resLoc)));
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
this.mc.getTextureManager().bindTexture(resLoc);
//Draws the search bar //Draws the search bar
if(this.currentIndexEntry instanceof BookletEntryAllSearch && this.currentChapter == null){ if(this.currentIndexEntry instanceof BookletEntryAllSearch && this.currentChapter == null){
this.mc.getTextureManager().bindTexture(resLoc);
this.drawTexturedModalRect(this.guiLeft+146, this.guiTop+160, 146, 80, 70, 14); this.drawTexturedModalRect(this.guiLeft+146, this.guiTop+160, 146, 80, 70, 14);
} }
//Draws Achievement Info
BookletUtils.drawAchievementInfo(this, true, x, y);
//Pre-Renders the current page's content etc.
BookletUtils.renderPre(this, x, y, this.ticksElapsed, this.mousePressed);
//Draws the title //Draws the title
this.fontRendererObj.setUnicodeFlag(false); this.fontRendererObj.setUnicodeFlag(false);
BookletUtils.drawTitle(this); BookletUtils.drawTitle(this);
this.fontRendererObj.setUnicodeFlag(true); this.fontRendererObj.setUnicodeFlag(true);
//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 //Does vanilla drawing stuff
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
this.searchField.drawTextBox(); this.searchField.drawTextBox();