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
* @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){
if(booklet.currentChapter == 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:");
ArrayList<String> infoList = null;
for(BookletPage page : booklet.currentChapter.pages){
for(ItemStack stack : page.getItemStacksForPage()){
for(Achievement achievement : InitAchievements.achievementList){
if(stack != null && achievement.theItemStack != null && achievement.theItemStack.isItemEqual(stack)){
if(pre){
booklet.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
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(infoList == null){
infoList = new ArrayList<String>();
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){
booklet.drawHoveringText(list, mouseX, mouseY);
if(infoList != null){
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);
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.mc.getTextureManager().bindTexture(resLoc);
//Draws the search bar
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);
}
//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
this.fontRendererObj.setUnicodeFlag(false);
BookletUtils.drawTitle(this);
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
super.drawScreen(x, y, f);
this.searchField.drawTextBox();