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; } } } }
@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; }
@Override public void scrollToSelected() { if (selected != null) { scrollToTop(); scrollBy(contents.indexOf(selected) * getSlotHeight()); } }
@Override protected void elementClicked(int index, boolean flag, int mouseX, int mouseY) { MinerRank entry = contents.get(index, null); if (entry != null) { selected = entry; } }
@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())); } }
@Override protected boolean isSelected(int index) { MinerRank entry = contents.get(index, null); return entry != null && selected != null && entry == selected; }
@Override protected int getSize() { return contents.size(); }