Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lemonade.mod.gui.type;
- import org.lwjgl.opengl.GL11;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.gui.GuiScreenBook;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.resources.I18n;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import net.lemonade.mod.Reference;
- public class GuiItemE extends GuiScreen {
- private final int bookImageHeight = 192;
- private final int bookImageWidth = 245;
- private int currPage = 0;
- private static final ResourceLocation bookGuiTextures = new ResourceLocation(Reference.MOD_ID + ":textures/gui/book.png");
- private static final int bookTotalPages = 4;
- private static ResourceLocation[] bookPageTextures = new ResourceLocation[bookTotalPages];
- private static String[] stringPageText = new String[bookTotalPages];
- private NextPageButton buttonNextPage;
- private BackPageButton buttonPreviousPage;
- public GuiItemE() {
- bookPageTextures[0] = new ResourceLocation(Reference.MOD_ID + ":textures/gui/ItemBook/Home.png");
- bookPageTextures[1] = new ResourceLocation(Reference.MOD_ID + ":textures/gui/ItemBook/Page1.png");
- bookPageTextures[2] = new ResourceLocation(Reference.MOD_ID + ":textures/gui/ItemBook/Page2.png");
- bookPageTextures[3] = new ResourceLocation(Reference.MOD_ID + ":textures/gui/ItemBook/Page3.png");
- }
- @Override
- public void initGui() {
- buttonList.clear();
- int offsetFromScreenLeft = (width - bookImageWidth) / 2;
- buttonList.add(buttonNextPage = new NextPageButton(1, offsetFromScreenLeft + 201, 225, true));
- buttonList.add(buttonPreviousPage = new BackPageButton(2, offsetFromScreenLeft + 24, 225, false));
- }
- @Override
- public void updateScreen() {
- buttonNextPage.visible = (currPage < bookTotalPages - 1);
- buttonPreviousPage.visible = currPage > 0;
- }
- @Override
- public void drawScreen(int parWidth, int parHeight, float p_73863_3_) {
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- if (currPage == 0) {
- mc.getTextureManager().bindTexture(bookPageTextures[0]);
- }else if (currPage == 1) {
- mc.getTextureManager().bindTexture(bookPageTextures[1]);
- }else if (currPage == 2) {
- mc.getTextureManager().bindTexture(bookPageTextures[2]);
- }else if (currPage == 3) {
- mc.getTextureManager().bindTexture(bookPageTextures[3]);
- }
- int offsetFromScreenLeft = (int) ((width - bookImageWidth) / 2.0F);
- drawTexturedModalRect(offsetFromScreenLeft, -1, 0, 0, 254, 257);
- int widthOfString;
- String stringPageIndicator = I18n.format("book.pageIndicator", new Object[] { Integer.valueOf(currPage + 1), bookTotalPages });
- widthOfString = fontRendererObj.getStringWidth(stringPageIndicator);
- fontRendererObj.drawString(stringPageIndicator, offsetFromScreenLeft - widthOfString + bookImageWidth - 3, 11, 0);
- super.drawScreen(parWidth, parHeight, p_73863_3_);
- }
- @Override
- protected void mouseClickMove(int parMouseX, int parMouseY, int parLastButtonClicked, long parTimeSinceMouseClick) {
- }
- @Override
- protected void actionPerformed(GuiButton parButton) {
- if (parButton == buttonNextPage) {
- if (currPage < bookTotalPages - 1) {
- ++currPage;
- }
- } else if (parButton == buttonPreviousPage) {
- if (currPage > 0) {
- --currPage;
- }
- }
- }
- @Override
- public void onGuiClosed() {
- }
- @Override
- public boolean doesGuiPauseGame() {
- return false;
- }
- @SideOnly(Side.CLIENT)
- static class NextPageButton extends GuiButton
- {
- private final boolean field_146151_o;
- public NextPageButton(int p_i46316_1_, int p_i46316_2_, int p_i46316_3_, boolean p_i46316_4_)
- {
- super(p_i46316_1_, p_i46316_2_, p_i46316_3_, 23, 13, "");
- this.field_146151_o = p_i46316_4_;
- }
- public void drawButton(Minecraft mc, int mouseX, int mouseY)
- {
- if (this.visible)
- {
- boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- mc.getTextureManager().bindTexture(bookGuiTextures);
- int k = 0;
- int l = 192;
- if (flag)
- {
- k += 23;
- }
- if (!this.field_146151_o)
- {
- l += 13;
- }
- this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
- }
- }
- }
- @SideOnly(Side.CLIENT)
- static class BackPageButton extends GuiButton
- {
- private final boolean field_146151_o;
- public BackPageButton(int p_i46316_1_, int p_i46316_2_, int p_i46316_3_, boolean p_i46316_4_)
- {
- super(p_i46316_1_, p_i46316_2_, p_i46316_3_, 23, 13, "");
- this.field_146151_o = p_i46316_4_;
- }
- public void drawButton(Minecraft mc, int mouseX, int mouseY)
- {
- if (this.visible)
- {
- boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- mc.getTextureManager().bindTexture(bookGuiTextures);
- int k = 0;
- int l = 192;
- if (flag)
- {
- k += 23;
- }
- if (!this.field_146151_o)
- {
- l += 13;
- }
- this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment