Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. public class GuiDossier extends GuiScreen {
  2.  
  3. private ItemStack dossierItem;
  4. private int guiWidth = 128;
  5. private int guiHeight = 180;
  6. private int currentPage;
  7. private int maxPages;
  8. private BookDocument dossier;
  9.  
  10. private PageButton nButton, prevButton;
  11. private SmallFontRenderer fonts = DClient.fonts;
  12. private static ResourceLocation bookRight;
  13. private static ResourceLocation bookLeft;
  14. private BookData bData;
  15.  
  16. private Page pageLeft;
  17. private Page pageRight;
  18.  
  19. public GuiDossier(ItemStack stack, BookData data) {
  20. LogHelper.info("GuiDossier constructor is called!");
  21. this.mc = Minecraft.getMinecraft();
  22. this.dossierItem = stack;
  23. currentPage = 0;
  24. LogHelper.info(data == null ? "Data in GuiDossier is null!"
  25. : "Data is not null in GuiDossier");
  26. dossier = data.getBookDocument();
  27. if (data.font != null)
  28. this.fonts = data.font;
  29. bookLeft = data.leftImage;
  30. bookRight = data.rightImage;
  31. this.bData = data;
  32. }
  33.  
  34. @SuppressWarnings("unchecked")
  35. public void initGui() {
  36. LogHelper.info("initGui() is called!");
  37. maxPages = dossier.getEntries().length;
  38. updateText();
  39. int xPos = (this.width - guiWidth) / 2;
  40. this.buttonList.add(this.prevButton = new PageButton(1, xPos - 45, 185,
  41. false));
  42. this.buttonList.add(this.nButton = new PageButton(2, xPos + guiWidth
  43. + 26, 185, true));
  44. }
  45.  
  46. protected void actionPerformed(GuiButton button) {
  47. LogHelper.info("actionPerformed() is called!");
  48. if (button.enabled) {
  49. if (button.id == 1)
  50. currentPage += 2;
  51. if (button.id == 2)
  52. currentPage -= 2;
  53. updateText();
  54. }
  55. }
  56.  
  57. public void updateText() {
  58. LogHelper.info("updateText is called!");
  59. if (maxPages % 2 == 1) {
  60. if (currentPage > maxPages)
  61. currentPage = maxPages;
  62. else {
  63. if (currentPage >= maxPages)
  64. currentPage = maxPages - 2;
  65. }
  66. if (currentPage % 2 == 1)
  67. currentPage--;
  68. if (currentPage < 0)
  69. currentPage = 0;
  70.  
  71. Page[] pages = dossier.getEntries();
  72. LogHelper.info(pages == null ? "Pages are null!"
  73. : "Pages are not null.");
  74. Page page = pages[currentPage];
  75. LogHelper
  76. .info(page == null ? "Page is null!" : "Page is not null.");
  77. if (page != null)
  78. pageLeft = page;
  79. else
  80. pageLeft = null;
  81.  
  82. page = pages[currentPage + 1];
  83. if (page != null)
  84. pageRight = page;
  85. else
  86. pageRight = null;
  87. }
  88. }
  89.  
  90. @Override
  91. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  92. LogHelper.info("drawScren() in GuiDossier is called!");
  93. int x = (this.width / 2);
  94. int y = (height - this.guiHeight) / 2;
  95.  
  96. GL11.glColor4f(1F, 1F, 1F, 1F);
  97. this.mc.getTextureManager().bindTexture(bookRight);
  98. this.drawTexturedModalRect(x, y, 0, 0, this.guiWidth, this.guiHeight);
  99.  
  100. GL11.glColor4f(1F, 1F, 1F, 1F);
  101. this.mc.getTextureManager().bindTexture(bookLeft);
  102. x -= this.guiWidth;
  103. this.drawTexturedModalRect(x, y, 256 - this.guiWidth, 0, this.guiWidth,
  104. this.guiHeight);
  105.  
  106. super.drawScreen(mouseX, mouseY, partialTicks);
  107.  
  108. if (pageLeft != null && pageRight != null) {
  109. LogHelper.info("Trying to draw the left page!");
  110. pageLeft.draw(x + 16, y + 12, mouseX, mouseY, fonts,
  111. bData.canTranslate, this);
  112.  
  113. LogHelper.info("Trying to draw the right page!");
  114. pageRight.draw(x + 220, y + 12, mouseX, mouseY, fonts,
  115. bData.canTranslate, this);
  116. }
  117.  
  118. nButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
  119. prevButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
  120. }
  121.  
  122. public Minecraft getMC() {
  123. return mc;
  124. }
  125.  
  126. public boolean doesGuiPauseGame() {
  127. return false;
  128. }
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement