Made Booklet Buttons be checked better

This commit is contained in:
Ellpeck 2015-12-04 18:14:03 +01:00
parent 3d7e2c91a6
commit f808bcf43f
9 changed files with 309 additions and 232 deletions

View file

@ -11,26 +11,22 @@
package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.achievement.InitAchievements;
import ellpeck.actuallyadditions.booklet.button.BookmarkButton;
import ellpeck.actuallyadditions.booklet.button.IndexButton;
import ellpeck.actuallyadditions.booklet.button.TexturedButton;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
import ellpeck.actuallyadditions.booklet.entry.BookletEntryAllSearch;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.update.UpdateChecker;
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;
import java.awt.*;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
public class BookletUtils{
@ -152,44 +148,15 @@ public class BookletUtils{
*/
@SuppressWarnings("unchecked")
public static void doHoverTexts(GuiBooklet booklet, int mouseX, int mouseY){
//Achievements Hover Text
if(booklet.buttonAchievements.func_146115_a()){
booklet.drawHoveringText(Collections.singletonList(EnumChatFormatting.GOLD+"Show Achievements"), mouseX, mouseY);
}
//Config Hover Text
else if(booklet.buttonConfig.func_146115_a()){
ArrayList list = new ArrayList();
list.add(EnumChatFormatting.GOLD+"Show Configuration GUI");
list.addAll(booklet.getFontRenderer().listFormattedStringToWidth("It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!", GuiBooklet.TOOLTIP_SPLIT_LENGTH));
booklet.drawHoveringText(list, mouseX, mouseY);
}
//Twitter Hover Text
else if(booklet.buttonTwitter.func_146115_a()){
booklet.drawHoveringText(Collections.singletonList(EnumChatFormatting.GOLD+"Open @ActAddMod on Twitter in Browser"), mouseX, mouseY);
}
//Forum Hover Text
else if(booklet.buttonForum.func_146115_a()){
booklet.drawHoveringText(Collections.singletonList(EnumChatFormatting.GOLD+"Open Minecraft Forum Post in Browser"), mouseX, mouseY);
}
//Update Checker Hover Text
else if(booklet.buttonUpdate.func_146115_a()){
ArrayList list = new ArrayList();
if(UpdateChecker.checkFailed){
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed")).getFormattedText());
}
else if(UpdateChecker.needsUpdateNotify){
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.generic")).getFormattedText());
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersion)).getFormattedText());
list.add(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.buttonOptions"));
}
booklet.drawHoveringText(list, mouseX, mouseY);
}
else{
for(GuiButton button : booklet.bookmarkButtons){
if(button instanceof BookmarkButton && button.func_146115_a()){
//Update all of the buttons' hovering texts
for(Object button : booklet.getButtonList()){
if(button instanceof GuiButton && ((GuiButton)button).visible && ((GuiButton)button).func_146115_a()){
if(button instanceof BookmarkButton){
((BookmarkButton)button).drawHover(mouseX, mouseY);
}
else if(button instanceof TexturedButton){
booklet.drawHoveringText(((TexturedButton)button).textList, mouseX, mouseY);
}
}
}
}
@ -407,163 +374,4 @@ public class BookletUtils{
}
return possiblePages;
}
public static class IndexButton extends GuiButton{
public BookletChapter chap;
private GuiBooklet gui;
public IndexButton(int id, int x, int y, int width, int height, String text, GuiBooklet gui){
super(id, x, y, width, height, text);
this.gui = gui;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY){
if(this.visible){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition+this.width && mouseY < this.yPosition+this.height;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.mouseDragged(minecraft, mouseX, mouseY);
int textOffsetX = 0;
if(this.chap != null){
if(this.chap.displayStack != null){
GL11.glPushMatrix();
BookletPage.renderItem(this.gui, this.chap.displayStack, this.xPosition-4, this.yPosition, 0.725F);
GL11.glPopMatrix();
textOffsetX = 10;
}
}
if(this.field_146123_n){
GL11.glPushMatrix();
AssetUtil.drawHorizontalGradientRect(this.xPosition+textOffsetX-1, this.yPosition+this.height-1, this.xPosition+this.gui.getFontRenderer().getStringWidth(this.displayString)+textOffsetX+1, this.yPosition+this.height, 0x80 << 24 | 22271, 22271);
GL11.glPopMatrix();
}
this.gui.getFontRenderer().drawString(this.displayString, this.xPosition+textOffsetX, this.yPosition+(this.height-8)/2, 0);
}
}
}
public static class TexturedButton extends GuiButton{
public int texturePosX;
public int texturePosY;
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
super(id, x, y, width, height, "");
this.texturePosX = texturePosX;
this.texturePosY = texturePosY;
}
public void setTexturePos(int x, int y){
this.texturePosX = x;
this.texturePosY = y;
}
@Override
public void drawButton(Minecraft minecraft, int x, int y){
if(this.visible){
minecraft.getTextureManager().bindTexture(GuiBooklet.resLoc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
int k = this.getHoverState(this.field_146123_n);
if(k == 0){
k = 1;
}
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.texturePosX, this.texturePosY-this.height+k*this.height, this.width, this.height);
this.mouseDragged(minecraft, x, y);
}
}
}
public static class BookmarkButton extends GuiButton{
public BookletChapter assignedChapter;
public BookletPage assignedPage;
public BookletEntry assignedEntry;
public int assignedPageInIndex;
private GuiBooklet booklet;
public BookmarkButton(int id, int x, int y, GuiBooklet booklet){
super(id, x, y, 16, 16, "");
this.booklet = booklet;
}
public void onPressed(){
if(this.assignedEntry != null){
if(KeyUtil.isShiftPressed()){
this.assignedEntry = null;
this.assignedChapter = null;
this.assignedPage = null;
this.assignedPageInIndex = 1;
}
else{
openIndexEntry(this.booklet, this.assignedEntry, this.assignedPageInIndex, true);
openChapter(this.booklet, this.assignedChapter, this.assignedPage);
}
}
else{
if(this.booklet.currentIndexEntry != null){
this.assignedEntry = this.booklet.currentIndexEntry;
this.assignedChapter = this.booklet.currentChapter;
this.assignedPage = this.booklet.currentPage;
this.assignedPageInIndex = this.booklet.pageOpenInIndex;
}
}
} @Override
public void drawButton(Minecraft minecraft, int x, int y){
if(this.visible){
minecraft.getTextureManager().bindTexture(GuiBooklet.resLoc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
int k = this.getHoverState(this.field_146123_n);
if(k == 0){
k = 1;
}
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int renderHeight = 25;
this.drawTexturedModalRect(this.xPosition, this.yPosition, 146+(this.assignedEntry == null ? 0 : 16), 194-renderHeight+k*renderHeight, this.width, renderHeight);
this.mouseDragged(minecraft, x, y);
if(this.assignedEntry != null){
GL11.glPushMatrix();
BookletPage.renderItem(booklet, this.assignedChapter != null && this.assignedChapter.displayStack != null ? this.assignedChapter.displayStack : new ItemStack(InitItems.itemBooklet), this.xPosition+2, this.yPosition+1, 0.725F);
GL11.glPopMatrix();
}
}
}
@SuppressWarnings("unchecked")
public void drawHover(int mouseX, int mouseY){
ArrayList list = new ArrayList();
if(this.assignedEntry != null){
if(this.assignedChapter != null){
list.add(EnumChatFormatting.GOLD+this.assignedChapter.getLocalizedName()+", Page "+this.assignedPage.getID());
}
else{
list.add(EnumChatFormatting.GOLD+this.assignedEntry.getLocalizedName()+", Page "+this.assignedPageInIndex);
}
list.add("Click to open");
list.add(EnumChatFormatting.ITALIC+"Shift-Click to remove");
}
else{
list.add(EnumChatFormatting.GOLD+"None");
list.add("Click to save current page");
}
this.booklet.drawHoveringText(list, mouseX, mouseY);
}
}
}

View file

@ -12,6 +12,9 @@ package ellpeck.actuallyadditions.booklet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.button.BookmarkButton;
import ellpeck.actuallyadditions.booklet.button.IndexButton;
import ellpeck.actuallyadditions.booklet.button.TexturedButton;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
import ellpeck.actuallyadditions.booklet.entry.BookletEntryAllSearch;
@ -20,7 +23,9 @@ import ellpeck.actuallyadditions.config.GuiConfiguration;
import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.update.UpdateChecker;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.KeyUtil;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.playerdata.PersistentClientData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
@ -28,10 +33,14 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@SideOnly(Side.CLIENT)
@ -43,7 +52,6 @@ public class GuiBooklet extends GuiScreen{
public static final ResourceLocation resLocValentine = AssetUtil.getBookletGuiLocation("guiBookletValentinesDay");
public static final int CHAPTER_BUTTONS_AMOUNT = 13;
public static final int TOOLTIP_SPLIT_LENGTH = 200;
public int xSize;
public int ySize;
@ -95,6 +103,10 @@ public class GuiBooklet extends GuiScreen{
return this.fontRendererObj;
}
public List getButtonList(){
return this.buttonList;
}
@Override
public void drawScreen(int x, int y, float f){
//Fixes Unicode flag
@ -214,61 +226,82 @@ public class GuiBooklet extends GuiScreen{
}
//Handles gonig from page to chapter or from chapter to index
else if(button == this.buttonPreviousScreen){
if(this.currentChapter != null){
BookletUtils.openIndexEntry(this, this.currentIndexEntry, this.pageOpenInIndex, true);
if(KeyUtil.isShiftPressed()){
if(this.currentChapter != null){
BookletUtils.openIndexEntry(this, this.currentIndexEntry, this.pageOpenInIndex, true);
}
else{
BookletUtils.openIndexEntry(this, null, 1, true);
}
}
else{
BookletUtils.openIndexEntry(this, null, 1, true);
//TODO History
}
}
//Handles Bookmark button
else if(button instanceof BookletUtils.BookmarkButton){
((BookletUtils.BookmarkButton)button).onPressed();
else if(button instanceof BookmarkButton){
((BookmarkButton)button).onPressed();
}
else{
BookletUtils.handleChapterButtonClick(this, button);
}
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "MismatchedQueryAndUpdateOfCollection"})
@Override
public void initGui(){
this.guiLeft = (this.width-this.xSize)/2;
this.guiTop = (this.height-this.ySize)/2;
this.buttonForward = new BookletUtils.TexturedButton(0, this.guiLeft+this.xSize-26, this.guiTop+this.ySize+1, 164, 0, 18, 10);
this.buttonForward = new TexturedButton(0, this.guiLeft+this.xSize-26, this.guiTop+this.ySize+1, 164, 0, 18, 10, Collections.singletonList(EnumChatFormatting.GOLD+"Next Page"));
this.buttonList.add(this.buttonForward);
this.buttonBackward = new BookletUtils.TexturedButton(1, this.guiLeft+8, this.guiTop+this.ySize+1, 146, 0, 18, 10);
this.buttonBackward = new TexturedButton(1, this.guiLeft+8, this.guiTop+this.ySize+1, 146, 0, 18, 10, Collections.singletonList(EnumChatFormatting.GOLD+"Previous Page"));
this.buttonList.add(this.buttonBackward);
this.buttonPreviousScreen = new BookletUtils.TexturedButton(2, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+1, 182, 0, 15, 10);
List prevScreenHover = new ArrayList<>();
prevScreenHover.add(EnumChatFormatting.GOLD+"Back");
prevScreenHover.add("Click for last item in history");
prevScreenHover.add(EnumChatFormatting.ITALIC+"Shift-Click for Chapter");
this.buttonPreviousScreen = new TexturedButton(2, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+1, 182, 0, 15, 10, prevScreenHover);
this.buttonList.add(this.buttonPreviousScreen);
this.buttonUpdate = new BookletUtils.TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11);
ArrayList updateHover = new ArrayList();
if(UpdateChecker.checkFailed){
updateHover.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed")).getFormattedText());
}
else if(UpdateChecker.needsUpdateNotify){
updateHover.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.generic")).getFormattedText());
updateHover.add(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersion)).getFormattedText());
updateHover.add(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.buttonOptions"));
}
this.buttonUpdate = new TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11, updateHover);
this.buttonUpdate.visible = UpdateChecker.needsUpdateNotify;
this.buttonList.add(this.buttonUpdate);
this.buttonTwitter = new BookletUtils.TexturedButton(5, this.guiLeft, this.guiTop, 213, 0, 8, 8);
this.buttonTwitter = new TexturedButton(5, this.guiLeft, this.guiTop, 213, 0, 8, 8, Collections.singletonList(EnumChatFormatting.GOLD+"Open @ActAddMod on Twitter in Browser"));
this.buttonList.add(this.buttonTwitter);
this.buttonForum = new BookletUtils.TexturedButton(6, this.guiLeft, this.guiTop+10, 221, 0, 8, 8);
this.buttonForum = new TexturedButton(6, this.guiLeft, this.guiTop+10, 221, 0, 8, 8, Collections.singletonList(EnumChatFormatting.GOLD+"Open Minecraft Forum Post in Browser"));
this.buttonList.add(this.buttonForum);
this.buttonAchievements = new BookletUtils.TexturedButton(7, this.guiLeft+138, this.guiTop, 205, 0, 8, 8);
this.buttonAchievements = new TexturedButton(7, this.guiLeft+138, this.guiTop, 205, 0, 8, 8, Collections.singletonList(EnumChatFormatting.GOLD+"Show Achievements"));
this.buttonList.add(this.buttonAchievements);
this.buttonConfig = new BookletUtils.TexturedButton(8, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8);
ArrayList configHover = new ArrayList();
configHover.add(EnumChatFormatting.GOLD+"Show Configuration GUI");
configHover.addAll(this.fontRendererObj.listFormattedStringToWidth("It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!", 200));
this.buttonConfig = new TexturedButton(8, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8, configHover);
this.buttonList.add(this.buttonConfig);
for(int i = 0; i < this.chapterButtons.length; i++){
this.chapterButtons[i] = new BookletUtils.IndexButton(9+i, guiLeft+15, guiTop+10+(i*12), 115, 10, "", this);
this.chapterButtons[i] = new IndexButton(9+i, guiLeft+15, guiTop+10+(i*12), 115, 10, "", this);
this.buttonList.add(this.chapterButtons[i]);
}
for(int i = 0; i < this.bookmarkButtons.length; i++){
int x = this.guiLeft+xSize/2-(this.bookmarkButtons.length/2*16)+(i*16);
this.bookmarkButtons[i] = new BookletUtils.BookmarkButton(this.chapterButtons[this.chapterButtons.length-1].id+1+i, x, this.guiTop+this.ySize+13, this);
this.bookmarkButtons[i] = new BookmarkButton(this.chapterButtons[this.chapterButtons.length-1].id+1+i, x, this.guiTop+this.ySize+13, this);
this.buttonList.add(this.bookmarkButtons[i]);
}
@ -305,7 +338,7 @@ public class GuiBooklet extends GuiScreen{
this.buttonUpdate.visible = buttonThere;
if(buttonThere){
if(this.ticksElapsed%8 == 0){
BookletUtils.TexturedButton button = (BookletUtils.TexturedButton)this.buttonUpdate;
TexturedButton button = (TexturedButton)this.buttonUpdate;
button.setTexturePos(245, button.texturePosY == 0 ? 22 : 0);
}
}

View file

@ -0,0 +1,111 @@
/*
* This file ("BookmarkButton.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet.button;
import ellpeck.actuallyadditions.booklet.BookletUtils;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.util.KeyUtil;
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.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
public class BookmarkButton extends GuiButton{
public BookletChapter assignedChapter;
public BookletPage assignedPage;
public BookletEntry assignedEntry;
public int assignedPageInIndex;
private GuiBooklet booklet;
public BookmarkButton(int id, int x, int y, GuiBooklet booklet){
super(id, x, y, 16, 16, "");
this.booklet = booklet;
}
public void onPressed(){
if(this.assignedEntry != null){
if(KeyUtil.isShiftPressed()){
this.assignedEntry = null;
this.assignedChapter = null;
this.assignedPage = null;
this.assignedPageInIndex = 1;
}
else{
BookletUtils.openIndexEntry(this.booklet, this.assignedEntry, this.assignedPageInIndex, true);
BookletUtils.openChapter(this.booklet, this.assignedChapter, this.assignedPage);
}
}
else{
if(this.booklet.currentIndexEntry != null){
this.assignedEntry = this.booklet.currentIndexEntry;
this.assignedChapter = this.booklet.currentChapter;
this.assignedPage = this.booklet.currentPage;
this.assignedPageInIndex = this.booklet.pageOpenInIndex;
}
}
}
@Override
public void drawButton(Minecraft minecraft, int x, int y){
if(this.visible){
minecraft.getTextureManager().bindTexture(GuiBooklet.resLoc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
int k = this.getHoverState(this.field_146123_n);
if(k == 0){
k = 1;
}
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int renderHeight = 25;
this.drawTexturedModalRect(this.xPosition, this.yPosition, 146+(this.assignedEntry == null ? 0 : 16), 194-renderHeight+k*renderHeight, this.width, renderHeight);
this.mouseDragged(minecraft, x, y);
if(this.assignedEntry != null){
GL11.glPushMatrix();
BookletPage.renderItem(booklet, this.assignedChapter != null && this.assignedChapter.displayStack != null ? this.assignedChapter.displayStack : new ItemStack(InitItems.itemBooklet), this.xPosition+2, this.yPosition+1, 0.725F);
GL11.glPopMatrix();
}
}
}
@SuppressWarnings("unchecked")
public void drawHover(int mouseX, int mouseY){
ArrayList list = new ArrayList();
if(this.assignedEntry != null){
if(this.assignedChapter != null){
list.add(EnumChatFormatting.GOLD+this.assignedChapter.getLocalizedName()+", Page "+this.assignedPage.getID());
}
else{
list.add(EnumChatFormatting.GOLD+this.assignedEntry.getLocalizedName()+", Page "+this.assignedPageInIndex);
}
list.add("Click to open");
list.add(EnumChatFormatting.ITALIC+"Shift-Click to remove");
}
else{
list.add(EnumChatFormatting.GOLD+"None");
list.add("Click to save current page");
}
this.booklet.drawHoveringText(list, mouseX, mouseY);
}
}

View file

@ -0,0 +1,61 @@
/*
* This file ("IndexButton.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet.button;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.util.AssetUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
public class IndexButton extends GuiButton{
public BookletChapter chap;
private GuiBooklet gui;
public IndexButton(int id, int x, int y, int width, int height, String text, GuiBooklet gui){
super(id, x, y, width, height, text);
this.gui = gui;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY){
if(this.visible){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition+this.width && mouseY < this.yPosition+this.height;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.mouseDragged(minecraft, mouseX, mouseY);
int textOffsetX = 0;
if(this.chap != null){
if(this.chap.displayStack != null){
GL11.glPushMatrix();
BookletPage.renderItem(this.gui, this.chap.displayStack, this.xPosition-4, this.yPosition, 0.725F);
GL11.glPopMatrix();
textOffsetX = 10;
}
}
if(this.field_146123_n){
GL11.glPushMatrix();
AssetUtil.drawHorizontalGradientRect(this.xPosition+textOffsetX-1, this.yPosition+this.height-1, this.xPosition+this.gui.getFontRenderer().getStringWidth(this.displayString)+textOffsetX+1, this.yPosition+this.height, 0x80 << 24 | 22271, 22271);
GL11.glPopMatrix();
}
this.gui.getFontRenderer().drawString(this.displayString, this.xPosition+textOffsetX, this.yPosition+(this.height-8)/2, 0);
}
}
}

View file

@ -0,0 +1,64 @@
/*
* This file ("TexturedButton.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet.button;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
public class TexturedButton extends GuiButton{
public int texturePosX;
public int texturePosY;
public List textList = new ArrayList();
@SuppressWarnings("unchecked")
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){
super(id, x, y, width, height, "");
this.texturePosX = texturePosX;
this.texturePosY = texturePosY;
this.textList.addAll(hoverTextList);
}
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
this(id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
}
public void setTexturePos(int x, int y){
this.texturePosX = x;
this.texturePosY = y;
}
@Override
public void drawButton(Minecraft minecraft, int x, int y){
if(this.visible){
minecraft.getTextureManager().bindTexture(GuiBooklet.resLoc);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height;
int k = this.getHoverState(this.field_146123_n);
if(k == 0){
k = 1;
}
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.texturePosX, this.texturePosY-this.height+k*this.height, this.width, this.height);
this.mouseDragged(minecraft, x, y);
}
}
}

View file

@ -11,7 +11,6 @@
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.util.KeyUtil;
import ellpeck.actuallyadditions.util.ModUtil;
@ -67,7 +66,7 @@ public class TooltipEvent{
}
//Disabling Info
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".disablingInfo.desc"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".disablingInfo.desc"), 200));
}
else{
if(ConfigBoolValues.CTRL_INFO_FOR_EXTRA_INFO.isEnabled()){

View file

@ -12,7 +12,6 @@ package ellpeck.actuallyadditions.inventory.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.inventory.ContainerInputter;
import ellpeck.actuallyadditions.network.PacketHandler;
import ellpeck.actuallyadditions.network.gui.PacketGuiButton;
@ -125,7 +124,7 @@ public class GuiInputter extends GuiContainer{
this.whitelistPut.displayString = this.tileInputter.isPutWhitelist ? "O" : "X";
if(this.isAdvanced){
List infoList = this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.whitelistInfo"), GuiBooklet.TOOLTIP_SPLIT_LENGTH);
List infoList = this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.whitelistInfo"), 200);
String text1 = this.tileInputter.isPullWhitelist ? StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.whitelist") : StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.blacklist");
if(x >= guiLeft+3 && y >= guiTop+16 && x <= guiLeft+18 && y <= guiTop+31){
ArrayList list = new ArrayList();
@ -145,16 +144,16 @@ public class GuiInputter extends GuiContainer{
int newTopOffset = this.guiTop+(this.isAdvanced ? OFFSET_ADVANCED : 0);
//Info Mode on!
if(x >= guiLeft+11 && y >= newTopOffset+65 && x <= guiLeft+11+31 && y <= newTopOffset+65+12){
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.1").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.pull")), GuiBooklet.TOOLTIP_SPLIT_LENGTH), x, y);
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.1").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.pull")), 200), x, y);
}
if(x >= guiLeft+96 && y >= newTopOffset+65 && x <= guiLeft+96+31 && y <= newTopOffset+65+12){
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.1").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.put")), GuiBooklet.TOOLTIP_SPLIT_LENGTH), x, y);
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.1").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.put")), 200), x, y);
}
if(x >= guiLeft+48 && y >= newTopOffset+65 && x <= guiLeft+48+31 && y <= newTopOffset+65+12){
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.2").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.pull")), GuiBooklet.TOOLTIP_SPLIT_LENGTH), x, y);
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.2").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.pull")), 200), x, y);
}
if(x >= guiLeft+133 && y >= newTopOffset+65 && x <= guiLeft+133+31 && y <= newTopOffset+65+12){
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.2").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.put")), GuiBooklet.TOOLTIP_SPLIT_LENGTH), x, y);
this.func_146283_a(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".inputter.info.2").replace("<p>", StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".gui.put")), 200), x, y);
}
}

View file

@ -16,6 +16,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.booklet.BookletUtils;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.booklet.button.TexturedButton;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
@ -25,7 +26,7 @@ import net.minecraftforge.client.event.GuiScreenEvent;
public class NEIScreenEvents{
private static final int NEI_BUTTON_ID = 123782;
private BookletUtils.TexturedButton neiButton;
private TexturedButton neiButton;
@SuppressWarnings("unchecked")
@SubscribeEvent
@ -38,7 +39,7 @@ public class NEIScreenEvents{
int guiLeft = (event.gui.width-xSize)/2;
int guiTop = (event.gui.height-ySize)/2;
this.neiButton = new BookletUtils.TexturedButton(NEI_BUTTON_ID, guiLeft+xSize-24, guiTop+127, 146, 154, 20, 20){
this.neiButton = new TexturedButton(NEI_BUTTON_ID, guiLeft+xSize-24, guiTop+127, 146, 154, 20, 20){
@Override
public void drawButton(Minecraft minecraft, int x, int y){
super.drawButton(minecraft, x, y);

View file

@ -15,6 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.BookletUtils;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.booklet.button.BookmarkButton;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
@ -48,7 +49,7 @@ public class PersistentClientData{
//Save Bookmarks
NBTTagList list = new NBTTagList();
for(int i = 0; i < gui.bookmarkButtons.length; i++){
BookletUtils.BookmarkButton button = (BookletUtils.BookmarkButton)gui.bookmarkButtons[i];
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Entry", button.assignedEntry == null ? -1 : InitBooklet.entries.indexOf(button.assignedEntry));
@ -144,7 +145,7 @@ public class PersistentClientData{
NBTTagList list = worldCompound.getTagList("Bookmarks", 10);
if(list != null){
for(int i = 0; i < list.tagCount(); i++){
BookletUtils.BookmarkButton button = (BookletUtils.BookmarkButton)gui.bookmarkButtons[i];
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
NBTTagCompound compound = list.getCompoundTagAt(i);
int entry = compound.getInteger("Entry");