Exemplo n.º 1
0
    protected RankList() {
      super(GuiSelectMinerRank.this.mc, 0, 0, 0, 0, 18);

      for (MinerRank rank : MinerRank.values()) {
        ranks.addIfAbsent(rank);
        contents.addIfAbsent(rank);
      }

      if (rankField != null) {
        String text = rankField.getText();

        if (!Strings.isNullOrEmpty(text)) {
          try {
            int i = Integer.parseInt(text);

            for (MinerRank rank : ranks) {
              if (i == rank.getRank()) {
                selected = rank;
                break;
              }
            }
          } catch (NumberFormatException e) {
            selected = null;
          }
        }
      }
    }
Exemplo n.º 2
0
    @Override
    public int compare(MinerRank o1, MinerRank o2) {
      int i = CaveUtils.compareWithNull(o1, o2);

      if (i == 0 && o1 != null && o2 != null) {
        i = Integer.compare(ranks.indexOf(o1), ranks.indexOf(o2));
      }

      return i;
    }
Exemplo n.º 3
0
 @Override
 public void scrollToSelected() {
   if (selected != null) {
     scrollToTop();
     scrollBy(contents.indexOf(selected) * getSlotHeight());
   }
 }
Exemplo n.º 4
0
    @Override
    protected void elementClicked(int index, boolean flag, int mouseX, int mouseY) {
      MinerRank entry = contents.get(index, null);

      if (entry != null) {
        selected = entry;
      }
    }
Exemplo n.º 5
0
    @Override
    protected void drawSlot(
        int index, int par2, int par3, int par4, Tessellator tessellator, int mouseX, int mouseY) {
      MinerRank entry = contents.get(index, null);

      if (entry == null) {
        return;
      }

      drawCenteredString(
          fontRendererObj, I18n.format(entry.getUnlocalizedName()), width / 2, par3 + 1, 0xFFFFFF);

      if (detailInfo.isChecked()) {
        CaveUtils.renderItemStack(
            mc,
            entry.getRenderItemStack(),
            width / 2 - 100,
            par3 - 1,
            true,
            true,
            Integer.toString(entry.getRank()));
      }
    }
Exemplo n.º 6
0
    @Override
    protected boolean isSelected(int index) {
      MinerRank entry = contents.get(index, null);

      return entry != null && selected != null && entry == selected;
    }
Exemplo n.º 7
0
 @Override
 protected int getSize() {
   return contents.size();
 }