@Override protected void actionPerformed(GuiButton button) { if (button.enabled) { switch (button.id) { case 0: if (rankList.selected != null) { MinerRank rank = rankList.selected; if (rankField != null) { rankField.setText(Integer.toString(rank.getRank())); } } mc.displayGuiScreen(parent); rankList.selected = null; rankList.scrollToTop(); break; case 1: CaveConfigGui.detailInfo = detailInfo.isChecked(); break; case 2: CaveConfigGui.instantFilter = instantFilter.isChecked(); break; } } }
@Override public void initGui() { if (rankList == null) { rankList = new RankList(); } rankList.func_148122_a(width, height, 32, height - 28); if (doneButton == null) { doneButton = new GuiButtonExt(0, 0, 0, 145, 20, I18n.format("gui.done")); } doneButton.xPosition = width / 2 + 10; doneButton.yPosition = height - doneButton.height - 4; if (detailInfo == null) { detailInfo = new GuiCheckBox(1, 0, 5, I18n.format(Caveworld.CONFIG_LANG + "detail"), true); } detailInfo.setIsChecked(CaveConfigGui.detailInfo); detailInfo.xPosition = width / 2 + 95; if (instantFilter == null) { instantFilter = new GuiCheckBox( 2, 0, detailInfo.yPosition + detailInfo.height + 2, I18n.format(Caveworld.CONFIG_LANG + "instant"), true); } instantFilter.setIsChecked(CaveConfigGui.instantFilter); instantFilter.xPosition = detailInfo.xPosition; buttonList.clear(); buttonList.add(doneButton); buttonList.add(detailInfo); buttonList.add(instantFilter); if (filterTextField == null) { filterTextField = new GuiTextField(fontRendererObj, 0, 0, 150, 16); filterTextField.setMaxStringLength(100); } filterTextField.xPosition = width / 2 - filterTextField.width - 5; filterTextField.yPosition = height - filterTextField.height - 6; detailHoverChecker = new HoverChecker(detailInfo, 800); instantHoverChecker = new HoverChecker(instantFilter, 800); }
@Override protected void keyTyped(char c, int code) { if (filterTextField.isFocused()) { if (code == Keyboard.KEY_ESCAPE) { filterTextField.setFocused(false); } String prev = filterTextField.getText(); filterTextField.textboxKeyTyped(c, code); String text = filterTextField.getText(); boolean changed = text != prev; if (Strings.isNullOrEmpty(text) && changed) { rankList.setFilter(null); } else if (instantFilter.isChecked() && changed || code == Keyboard.KEY_RETURN) { rankList.setFilter(text); } } else { if (code == Keyboard.KEY_ESCAPE) { mc.displayGuiScreen(parent); } else if (code == Keyboard.KEY_BACK) { rankList.selected = null; } else if (code == Keyboard.KEY_UP) { rankList.scrollUp(); } else if (code == Keyboard.KEY_DOWN) { rankList.scrollDown(); } else if (code == Keyboard.KEY_HOME) { rankList.scrollToTop(); } else if (code == Keyboard.KEY_END) { rankList.scrollToEnd(); } else if (code == Keyboard.KEY_SPACE) { rankList.scrollToSelected(); } else if (code == Keyboard.KEY_PRIOR) { rankList.scrollToPrev(); } else if (code == Keyboard.KEY_NEXT) { rankList.scrollToNext(); } else if (code == Keyboard.KEY_F || code == mc.gameSettings.keyBindChat.getKeyCode()) { filterTextField.setFocused(true); } } }