コード例 #1
0
  public final String getText() {
    if (this.hasNoText) {
      return null;
    }

    String base =
        StringUtil.localize(
                "booklet."
                    + ModUtil.MOD_ID_LOWER
                    + ".chapter."
                    + this.chapter.getUnlocalizedName()
                    + ".text."
                    + this.id)
            .replaceAll("<imp>", EnumChatFormatting.DARK_GREEN + "")
            .replaceAll("<item>", EnumChatFormatting.BLUE + "")
            .replaceAll("<r>", EnumChatFormatting.BLACK + "")
            .replaceAll("<n>", "\n")
            .replaceAll("<i>", EnumChatFormatting.ITALIC + "")
            .replaceAll("<rs>", EnumChatFormatting.RESET + "");
    for (Object o : this.textReplacements.entrySet()) {
      Map.Entry e = (Map.Entry) o;
      base = base.replaceAll((String) e.getKey(), (String) e.getValue());
    }
    return base;
  }
コード例 #2
0
  /**
   * Draws the Title of the current chapter, current index entry or just "Actually Additions" if
   * neither is present
   */
  public static void drawTitle(GuiBooklet booklet) {
    // Upper title
    booklet.drawTexturedModalRect(
        booklet.guiLeft + booklet.xSize / 2 - 142 / 2, booklet.guiTop - 12, 0, 240, 142, 12);
    // Lower title
    booklet.drawTexturedModalRect(
        booklet.guiLeft + booklet.xSize / 2 - 142 / 2,
        booklet.guiTop + booklet.ySize,
        0,
        243,
        142,
        13);

    String strg =
        booklet.currentChapter == null
            ? (booklet.currentIndexEntry == null
                ? StringUtil.localize("itemGroup." + ModUtil.MOD_ID_LOWER)
                : booklet.currentIndexEntry.getLocalizedName())
            : booklet.currentChapter.getLocalizedName();
    booklet.drawCenteredString(
        booklet.getFontRenderer(),
        strg,
        booklet.guiLeft + booklet.xSize / 2,
        booklet.guiTop - 9,
        StringUtil.DECIMAL_COLOR_WHITE);
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @Override
  public void render(
      GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed) {
    ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
    if (input == null) {
      gui.mc.fontRenderer.drawSplitString(
          EnumChatFormatting.DARK_RED
              + StringUtil.localize("booklet." + ModUtil.MOD_ID_LOWER + ".recipeDisabled"),
          gui.guiLeft + 14,
          gui.guiTop + 15,
          115,
          0);
    } else {
      String strg = "Furnace Recipe";
      gui.mc.fontRenderer.drawString(
          strg,
          gui.guiLeft + gui.xSize / 2 - gui.mc.fontRenderer.getStringWidth(strg) / 2,
          gui.guiTop + 10,
          0);
    }

    String text = gui.currentPage.getText();
    if (text != null && !text.isEmpty()) {
      gui.mc.fontRenderer.drawSplitString(text, gui.guiLeft + 14, gui.guiTop + 100, 115, 0);
    }

    if (input != null) {
      for (int i = 0; i < 2; i++) {
        for (int x = 0; x < 2; x++) {
          ItemStack stack = x == 0 ? input : this.result;
          if (stack.getItemDamage() == Util.WILDCARD) {
            stack.setItemDamage(0);
          }
          boolean tooltip = i == 1;

          int xShow = gui.guiLeft + 37 + 1 + x * 42;
          int yShow = gui.guiTop + 20 + 21;
          if (!tooltip) {
            renderItem(gui, stack, xShow, yShow, 1.0F);
          } else {
            if (mouseX >= xShow
                && mouseX <= xShow + 16
                && mouseY >= yShow
                && mouseY <= yShow + 16) {
              this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, x == 0, mousePressed);
            }
          }
        }
      }
    }
  }
コード例 #4
0
  @SuppressWarnings("unchecked")
  @SideOnly(Side.CLIENT)
  protected void renderTooltipAndTransfer(
      GuiBooklet gui,
      ItemStack stack,
      int x,
      int y,
      boolean checkAndTransfer,
      boolean mousePressed) {
    boolean flagBefore = gui.mc.fontRenderer.getUnicodeFlag();
    gui.mc.fontRenderer.setUnicodeFlag(false);

    List list = stack.getTooltip(gui.mc.thePlayer, gui.mc.gameSettings.advancedItemTooltips);

    for (int k = 0; k < list.size(); ++k) {
      if (k == 0) {
        list.set(k, stack.getRarity().rarityColor + (String) list.get(k));
      } else {
        list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
      }
    }

    if (checkAndTransfer) {
      BookletPage page = BookletUtils.getFirstPageForStack(stack);
      if (page != null && page != this) {
        list.add(
            EnumChatFormatting.GOLD
                + StringUtil.localize("booklet." + ModUtil.MOD_ID_LOWER + ".clickToSeeRecipe"));

        if (mousePressed) {
          BookletUtils.openIndexEntry(
              gui,
              page.getChapter().entry,
              InitBooklet.entries.indexOf(page.getChapter().entry)
                      / GuiBooklet.CHAPTER_BUTTONS_AMOUNT
                  + 1,
              true);
          BookletUtils.openChapter(gui, page.getChapter(), page);
          Minecraft.getMinecraft()
              .getSoundHandler()
              .playSound(
                  PositionedSoundRecord.func_147674_a(
                      new ResourceLocation("gui.button.press"), 1.0F));
        }
      }
    }

    gui.drawHoveringText(list, x, y);

    gui.mc.fontRenderer.setUnicodeFlag(flagBefore);
  }
コード例 #5
0
  /**
   * 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
   */
  public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY) {
    if (booklet.currentChapter == null) {
      return;
    }

    ArrayList<String> infoList = null;
    for (BookletPage page : booklet.currentChapter.pages) {
      if (page != null && page.getItemStacksForPage() != null) {
        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() + ")");
                }
              }
            }
          }
        }
      }
    }

    if (infoList != null) {
      booklet.drawHoveringText(infoList, mouseX, mouseY);
    }
  }
コード例 #6
0
  /** Draws all of the hovering texts for the buttons that need explanation in the booklet */
  @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()) {
          ((BookmarkButton) button).drawHover(mouseX, mouseY);
        }
      }
    }
  }