GuiNewControls.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. package us.getfluxed.controlsearch.client.gui;
  2. import net.minecraft.client.Minecraft;
  3. import net.minecraft.client.gui.*;
  4. import net.minecraft.client.resources.I18n;
  5. import net.minecraft.client.settings.*;
  6. import net.minecraftforge.client.settings.KeyModifier;
  7. import net.minecraftforge.fml.client.config.GuiCheckBox;
  8. import org.lwjgl.input.*;
  9. import javax.swing.*;
  10. import java.io.IOException;
  11. import java.util.*;
  12. public class GuiNewControls extends GuiControls {
  13. private static final GameSettings.Options[] OPTIONS_ARR = new GameSettings.Options[]{GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.AUTO_JUMP};
  14. /**
  15. * A reference to the screen object that created this. Used for navigating between screens.
  16. */
  17. private final GuiScreen parentScreen;
  18. /**
  19. * Reference to the GameSettings object.
  20. */
  21. private final GameSettings options;
  22. /**
  23. * The ID of the button that has been pressed.
  24. */
  25. private GuiButton buttonReset;
  26. private GuiTextField search;
  27. private String lastFilterText = "";
  28. private boolean conflicts = false;
  29. private boolean none = false;
  30. private EnumSortingType sortingType = EnumSortingType.DEFAULT;
  31. public int availableTime;
  32. public GuiButton buttonConflict;
  33. public GuiButton buttonNone;
  34. public GuiButton buttonSorting;
  35. public GuiCheckBox boxSearchCategory;
  36. public GuiCheckBox boxSearchKey;
  37. public GuiNewControls(GuiScreen screen, GameSettings settings) {
  38. super(screen, settings);
  39. this.parentScreen = screen;
  40. this.options = settings;
  41. }
  42. /**
  43. * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
  44. * window resizes, the buttonList is cleared beforehand.
  45. */
  46. public void initGui() {
  47. this.conflicts = false;
  48. this.none = false;
  49. this.sortingType = EnumSortingType.DEFAULT;
  50. this.keyBindingList = new GuiNewKeyBindingList(this, this.mc);
  51. this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("gui.done")));
  52. this.buttonReset = this.addButton(new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 155, 20, I18n.format("controls.resetAll")));
  53. this.screenTitle = I18n.format("controls.title");
  54. int i = 0;
  55. for(GameSettings.Options gamesettings$options : OPTIONS_ARR) {
  56. if(gamesettings$options.getEnumFloat()) {
  57. this.buttonList.add(new GuiOptionSlider(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options));
  58. } else {
  59. this.buttonList.add(new GuiOptionButton(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options, this.options.getKeyBinding(gamesettings$options)));
  60. }
  61. ++i;
  62. }
  63. search = new GuiTextField(0, mc.fontRendererObj, this.width / 2 - 154, this.height - 29 - 23, 148, 18);
  64. search.setCanLoseFocus(true);
  65. buttonConflict = new GuiButton(2906, this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, I18n.format("options.showConflicts"));
  66. buttonNone = new GuiButton(2907, this.width / 2 - 155 + 160 + 80, this.height - 29 - 24, 150 / 2, 20, I18n.format("options.showNone"));
  67. buttonSorting = new GuiButton(2908, this.width / 2 - 155 + 160 + 80, this.height - 29 - 24 - 24, 150 / 2, 20, I18n.format("options.sort") + ": " + sortingType.getName());
  68. boxSearchCategory = new GuiCheckBox(2909, this.width / 2 - (155 / 2) + 20, this.height - 29 - 37, I18n.format("options.category"), false);
  69. boxSearchKey = new GuiCheckBox(2910, this.width / 2 - (155 / 2) + 20, this.height - 29 - 50, I18n.format("options.key"), false);
  70. this.buttonList.add(buttonConflict);
  71. this.buttonList.add(buttonNone);
  72. this.buttonList.add(buttonSorting);
  73. this.buttonList.add(boxSearchCategory);
  74. this.buttonList.add(boxSearchKey);
  75. }
  76. @Override
  77. public void updateScreen() {
  78. search.updateCursorCounter();
  79. if(!search.getText().equals(lastFilterText)) {
  80. reloadKeys(0);
  81. }
  82. }
  83. public LinkedList<GuiListExtended.IGuiListEntry> getConflictingEntries() {
  84. LinkedList<GuiListExtended.IGuiListEntry> conflicts = new LinkedList<>();
  85. for(GuiListExtended.IGuiListEntry entry : ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll()) {
  86. if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
  87. GuiNewKeyBindingList.KeyEntry ent = (GuiNewKeyBindingList.KeyEntry) entry;
  88. if(ent.getKeybinding().getKeyCode() == 0) {
  89. continue;
  90. }
  91. for(GuiListExtended.IGuiListEntry entry1 : ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll()) {
  92. if(!entry.equals(entry1))
  93. if(entry1 instanceof GuiNewKeyBindingList.KeyEntry) {
  94. GuiNewKeyBindingList.KeyEntry ent1 = (GuiNewKeyBindingList.KeyEntry) entry1;
  95. if(ent1.getKeybinding().getKeyCode() == 0) {
  96. continue;
  97. }
  98. if(ent.getKeybinding().conflicts(ent1.getKeybinding())) {
  99. if(!conflicts.contains(ent))
  100. conflicts.add(ent);
  101. if(!conflicts.contains(ent1))
  102. conflicts.add(ent1);
  103. }
  104. }
  105. }
  106. }
  107. }
  108. return conflicts;
  109. }
  110. public LinkedList<GuiListExtended.IGuiListEntry> getNoneEntries() {
  111. LinkedList<GuiListExtended.IGuiListEntry> none = new LinkedList<>();
  112. for(GuiListExtended.IGuiListEntry entry : ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll()) {
  113. if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
  114. GuiNewKeyBindingList.KeyEntry ent = (GuiNewKeyBindingList.KeyEntry) entry;
  115. if(ent.getKeybinding().getKeyCode() == 0) {
  116. none.add(ent);
  117. }
  118. }
  119. }
  120. return none;
  121. }
  122. public void sort(LinkedList<GuiListExtended.IGuiListEntry> list, EnumSortingType type) {
  123. if(sortingType != EnumSortingType.DEFAULT)
  124. list.sort((o1, o2) -> {
  125. if(o1 instanceof GuiNewKeyBindingList.KeyEntry && o2 instanceof GuiNewKeyBindingList.KeyEntry) {
  126. GuiNewKeyBindingList.KeyEntry ent1 = (GuiNewKeyBindingList.KeyEntry) o1;
  127. GuiNewKeyBindingList.KeyEntry ent2 = (GuiNewKeyBindingList.KeyEntry) o2;
  128. if(type == EnumSortingType.AZ) {
  129. return translate(ent1.getKeybinding().getKeyDescription()).compareTo(I18n.format(ent2.getKeybinding().getKeyDescription()));
  130. } else if(type == EnumSortingType.ZA) {
  131. return translate(ent2.getKeybinding().getKeyDescription()).compareTo(I18n.format(ent1.getKeybinding().getKeyDescription()));
  132. }
  133. }
  134. if(o1.equals(o2)) {
  135. return 0;
  136. }
  137. return o1.toString().compareTo(o2.toString());
  138. });
  139. }
  140. public LinkedList<GuiListExtended.IGuiListEntry> sortKeys(LinkedList<GuiListExtended.IGuiListEntry> list, EnumSortingType type) {
  141. if(type == EnumSortingType.DEFAULT) {
  142. return list;
  143. }
  144. LinkedList<GuiListExtended.IGuiListEntry> sorted = new LinkedList<>();
  145. sorted.addAll(list);
  146. sort(list, type);
  147. return sorted;
  148. }
  149. private void reloadKeys(int type) {
  150. if(type == 0) {
  151. LinkedList<GuiListExtended.IGuiListEntry> newList = new LinkedList<>();
  152. LinkedList<GuiListExtended.IGuiListEntry> list = ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll();
  153. if(conflicts || none) {
  154. if(!search.getText().isEmpty()) {
  155. if(conflicts)
  156. list = getConflictingEntries();
  157. else if(none) {
  158. list = getNoneEntries();
  159. }
  160. } else
  161. list = ((GuiNewKeyBindingList) keyBindingList).getListEntries();
  162. }
  163. for(GuiListExtended.IGuiListEntry entry : list) {
  164. if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
  165. GuiNewKeyBindingList.KeyEntry ent = (GuiNewKeyBindingList.KeyEntry) entry;
  166. if(boxSearchCategory.isChecked()) {
  167. if(translate(ent.getKeybinding().getKeyCategory()).toLowerCase().contains(search.getText().toLowerCase())) {
  168. newList.add(entry);
  169. }
  170. } else if(boxSearchKey.isChecked()) {
  171. if(translate(ent.getKeybinding().getDisplayName()).toLowerCase().contains(search.getText().toLowerCase())) {
  172. newList.add(entry);
  173. }
  174. } else {
  175. if(translate(ent.getKeybinding().getKeyDescription()).toLowerCase().contains(search.getText().toLowerCase())) {
  176. newList.add(entry);
  177. }
  178. }
  179. }
  180. }
  181. ((GuiNewKeyBindingList) keyBindingList).setListEntries(sortKeys(newList, sortingType));
  182. lastFilterText = search.getText();
  183. if(lastFilterText.isEmpty()) {
  184. if(!conflicts && !none)
  185. ((GuiNewKeyBindingList) keyBindingList).setListEntries(((GuiNewKeyBindingList) keyBindingList).getListEntriesAll());
  186. else
  187. reloadKeys(conflicts ? 1 : 2);
  188. reloadKeys(3);
  189. }
  190. } else if(type == 1) {
  191. ((GuiNewKeyBindingList) keyBindingList).setListEntries(getConflictingEntries());
  192. if(!this.conflicts) {
  193. ((GuiNewKeyBindingList) keyBindingList).setListEntries(((GuiNewKeyBindingList) keyBindingList).getListEntriesAll());
  194. }
  195. if(!search.getText().isEmpty())
  196. reloadKeys(0);
  197. } else if(type == 2) {
  198. ((GuiNewKeyBindingList) keyBindingList).setListEntries(getNoneEntries());
  199. if(!this.none) {
  200. ((GuiNewKeyBindingList) keyBindingList).setListEntries(((GuiNewKeyBindingList) keyBindingList).getListEntriesAll());
  201. }
  202. if(!search.getText().isEmpty())
  203. reloadKeys(0);
  204. } else if(type == 3) {
  205. LinkedList<GuiListExtended.IGuiListEntry> list = ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll();
  206. if(sortingType == EnumSortingType.DEFAULT && (conflicts || none)) {
  207. reloadKeys(conflicts ? 1 : 2);
  208. }
  209. if(conflicts || none) {
  210. list = ((GuiNewKeyBindingList) keyBindingList).getListEntries();
  211. }
  212. LinkedList<GuiListExtended.IGuiListEntry> sorted = new LinkedList<>();
  213. for(GuiListExtended.IGuiListEntry entry : list) {
  214. if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
  215. sorted.add(entry);
  216. }
  217. }
  218. sort(list, sortingType);
  219. ((GuiNewKeyBindingList) keyBindingList).setListEntries(sorted);
  220. if(sortingType == EnumSortingType.DEFAULT && !conflicts && !none) {
  221. ((GuiNewKeyBindingList) keyBindingList).setListEntries(((GuiNewKeyBindingList) keyBindingList).getListEntriesAll());
  222. }
  223. if(!search.getText().isEmpty())
  224. reloadKeys(0);
  225. }
  226. }
  227. public String translate(String text) {
  228. return I18n.format(text);
  229. }
  230. /**
  231. * Handles mouse input.
  232. */
  233. public void handleMouseInput() throws IOException {
  234. superSuperHandleMouseInput();
  235. this.keyBindingList.handleMouseInput();
  236. }
  237. /**
  238. * Handles mouse input.
  239. */
  240. public void superSuperHandleMouseInput() throws IOException {
  241. int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
  242. int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
  243. int k = Mouse.getEventButton();
  244. if(Mouse.getEventButtonState()) {
  245. if(this.mc.gameSettings.touchscreen && this.touchValue++ > 0) {
  246. return;
  247. }
  248. this.eventButton = k;
  249. this.lastMouseEvent = Minecraft.getSystemTime();
  250. this.mouseClicked(i, j, this.eventButton);
  251. } else if(k != -1) {
  252. if(this.mc.gameSettings.touchscreen && --this.touchValue > 0) {
  253. return;
  254. }
  255. this.eventButton = -1;
  256. this.mouseReleased(i, j, k);
  257. } else if(this.eventButton != -1 && this.lastMouseEvent > 0L) {
  258. long l = Minecraft.getSystemTime() - this.lastMouseEvent;
  259. this.mouseClickMove(i, j, this.eventButton, l);
  260. }
  261. }
  262. /**
  263. * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
  264. */
  265. protected void actionPerformed(GuiButton button) throws IOException {
  266. if(button.id == 200) {
  267. this.mc.displayGuiScreen(this.parentScreen);
  268. } else if(button.id == 201) {
  269. for(KeyBinding keybinding : this.mc.gameSettings.keyBindings) {
  270. keybinding.setToDefault();
  271. }
  272. KeyBinding.resetKeyBindingArrayAndHash();
  273. availableTime = 0;
  274. } else if(button.id < 100 && button instanceof GuiOptionButton) {
  275. this.options.setOptionValue(((GuiOptionButton) button).returnEnumOptions(), 1);
  276. button.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
  277. } else if(button.id == 2906) {
  278. availableTime = 0;
  279. none = false;
  280. buttonNone.displayString = none ? I18n.format("options.showAll") : I18n.format("options.showNone");
  281. if(!conflicts) {
  282. conflicts = true;
  283. buttonConflict.displayString = I18n.format("options.showAll");
  284. reloadKeys(1);
  285. } else {
  286. conflicts = false;
  287. buttonConflict.displayString = I18n.format("options.showConflicts");
  288. reloadKeys(1);
  289. }
  290. } else if(button.id == 2907) {
  291. availableTime = 0;
  292. conflicts = false;
  293. buttonConflict.displayString = conflicts ? I18n.format("options.showAll") : I18n.format("options.showConflicts");
  294. if(!none) {
  295. none = true;
  296. buttonNone.displayString = I18n.format("options.showAll");
  297. reloadKeys(2);
  298. } else {
  299. none = false;
  300. buttonNone.displayString = I18n.format("options.showNone");
  301. reloadKeys(2);
  302. }
  303. } else if(button.id == 2908) {
  304. availableTime = 0;
  305. sortingType = sortingType.cycle();
  306. buttonSorting.displayString = I18n.format("options.sort") + ": " + sortingType.getName();
  307. reloadKeys(3);
  308. } else if(button.id == 2909) {
  309. availableTime = 0;
  310. boxSearchKey.setIsChecked(false);
  311. reloadKeys(0);
  312. } else if(button.id == 2910) {
  313. availableTime = 0;
  314. boxSearchCategory.setIsChecked(false);
  315. reloadKeys(0);
  316. }
  317. }
  318. /**
  319. * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
  320. */
  321. protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
  322. if(this.buttonId != null) {
  323. this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), -100 + mouseButton);
  324. this.options.setOptionKeyBinding(this.buttonId, -100 + mouseButton);
  325. this.buttonId = null;
  326. KeyBinding.resetKeyBindingArrayAndHash();
  327. } else if(mouseButton != 0 || !this.keyBindingList.mouseClicked(mouseX, mouseY, mouseButton)) {
  328. superSuperMouseClicked(mouseX, mouseY, mouseButton);
  329. }
  330. search.mouseClicked(mouseX, mouseY, mouseButton);
  331. if(mouseButton == 1 && mouseX >= search.xPosition && mouseX < search.xPosition + search.width && mouseY >= search.yPosition && mouseY < search.yPosition + search.height) {
  332. search.setText("");
  333. }
  334. }
  335. /**
  336. * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
  337. */
  338. protected void superSuperMouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
  339. if(mouseButton == 0) {
  340. for(int i = 0; i < this.buttonList.size(); ++i) {
  341. GuiButton guibutton = this.buttonList.get(i);
  342. if(guibutton.mousePressed(this.mc, mouseX, mouseY)) {
  343. net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event = new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.buttonList);
  344. if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
  345. break;
  346. guibutton = event.getButton();
  347. this.selectedButton = guibutton;
  348. guibutton.playPressSound(this.mc.getSoundHandler());
  349. this.actionPerformed(guibutton);
  350. if(this.equals(this.mc.currentScreen))
  351. net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.buttonList));
  352. }
  353. }
  354. }
  355. }
  356. /**
  357. * Called when a mouse button is released.
  358. */
  359. protected void mouseReleased(int mouseX, int mouseY, int state) {
  360. if(state != 0 || !this.keyBindingList.mouseReleased(mouseX, mouseY, state)) {
  361. superSuperMouseReleased(mouseX, mouseY, state);
  362. }
  363. }
  364. protected void superSuperMouseReleased(int mouseX, int mouseY, int state) {
  365. if(this.selectedButton != null && state == 0) {
  366. this.selectedButton.mouseReleased(mouseX, mouseY);
  367. this.selectedButton = null;
  368. }
  369. }
  370. /**
  371. * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
  372. * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
  373. */
  374. protected void keyTyped(char typedChar, int keyCode) throws IOException {
  375. if(this.buttonId != null) {
  376. if(keyCode == 1) {
  377. this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, 0);
  378. this.options.setOptionKeyBinding(this.buttonId, 0);
  379. } else if(keyCode != 0) {
  380. this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), keyCode);
  381. this.options.setOptionKeyBinding(this.buttonId, keyCode);
  382. } else if(typedChar > 0) {
  383. this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), typedChar + 256);
  384. this.options.setOptionKeyBinding(this.buttonId, typedChar + 256);
  385. }
  386. if(!KeyModifier.isKeyCodeModifier(keyCode)) {
  387. this.buttonId = null;
  388. }
  389. this.time = Minecraft.getSystemTime();
  390. KeyBinding.resetKeyBindingArrayAndHash();
  391. } else {
  392. if(search.isFocused())
  393. search.textboxKeyTyped(typedChar, keyCode);
  394. else if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
  395. if(availableTime > 0 && availableTime < 40) {
  396. availableTime = 0;
  397. } else {
  398. availableTime = 40;
  399. }
  400. } else {
  401. superSuperKeyTyped(typedChar, keyCode);
  402. }
  403. }
  404. }
  405. protected void superSuperKeyTyped(char typedChar, int keyCode) throws IOException {
  406. if(keyCode == 1) {
  407. this.mc.displayGuiScreen((GuiScreen) null);
  408. if(this.mc.currentScreen == null) {
  409. this.mc.setIngameFocus();
  410. }
  411. }
  412. }
  413. /**
  414. * Draws the screen and all the components in it.
  415. */
  416. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  417. this.drawDefaultBackground();
  418. this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks);
  419. this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 8, 16777215);
  420. this.drawCenteredString(this.fontRendererObj, I18n.format("options.search"), this.width / 2 - (155 / 2), this.height - 29 - 39, 16777215);
  421. boolean flag = false;
  422. for(KeyBinding keybinding : this.options.keyBindings) {
  423. if(!keybinding.isSetToDefaultValue()) {
  424. flag = true;
  425. break;
  426. }
  427. }
  428. this.buttonReset.enabled = flag;
  429. superSuperDrawScreen(mouseX, mouseY, partialTicks);
  430. search.drawTextBox();
  431. if(availableTime > 0) {
  432. drawRect(keyBindingList.left, keyBindingList.top, keyBindingList.right, keyBindingList.bottom + 18, 0xFF000000);
  433. LinkedList<Integer> keyCodes = new LinkedList<>();
  434. for(int i = 2; i < 219; i++) {
  435. keyCodes.add(i);
  436. }
  437. keyCodes.add(-98);
  438. keyCodes.add(-99);
  439. keyCodes.add(-100);
  440. List<Integer> removed = new ArrayList<>();
  441. ((GuiNewKeyBindingList) keyBindingList).getListEntriesAll().forEach(i -> {
  442. if(i instanceof GuiNewKeyBindingList.KeyEntry) {
  443. removed.add(((GuiNewKeyBindingList.KeyEntry) i).getKeybinding().getKeyCode());
  444. }
  445. });
  446. int[] rem = new int[]{0xDB, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x29, 0x79, 0x57, 0x7B, 0x7D, 0x8D, 0x90, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x9C, 0xA7, 0xB3, 0xC5, 0x91, 0xC4, 0xDA};
  447. for(int i : rem) {
  448. removed.add(i);
  449. }
  450. keyCodes.forEach(i -> {
  451. if(i >= 0)
  452. if(Keyboard.getKeyName(i) == null || Keyboard.getKeyName(i).isEmpty()) {
  453. removed.add(i);
  454. }
  455. });
  456. keyCodes.removeAll(removed);
  457. Collections.sort(keyCodes);
  458. final int[] x = {0};
  459. final int[] y = {0};
  460. final int[] count = {0};
  461. fontRendererObj.drawString(I18n.format("options.availableKeys") + ":", width / 2, keyBindingList.top + 2, 0xFFFFFF);
  462. List<String> codes = new ArrayList<>();
  463. keyCodes.forEach(key -> {
  464. if(key >= 0) {
  465. codes.add(Keyboard.getKeyName(key));
  466. fontRendererObj.drawString(Keyboard.getKeyName(key), keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0xFF55FF);
  467. } else {
  468. codes.add(Mouse.getButtonName(key + 100));
  469. switch(key + 100) {
  470. case 0:
  471. fontRendererObj.drawString("Button 1", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
  472. break;
  473. case 1:
  474. fontRendererObj.drawString("Button 2", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
  475. break;
  476. case 2:
  477. fontRendererObj.drawString("Button 3", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
  478. break;
  479. }
  480. }
  481. count[0]++;
  482. if(count[0] > keyBindingList.height / 30) {
  483. count[0] = 0;
  484. x[0]++;
  485. y[0] = 0;
  486. }
  487. });
  488. availableTime--;
  489. }
  490. }
  491. public void superSuperDrawScreen(int mouseX, int mouseY, float partialTicks) {
  492. for(GuiButton aButtonList : this.buttonList) {
  493. aButtonList.func_191745_a(this.mc, mouseX, mouseY, partialTicks);
  494. }
  495. for(GuiLabel aLabelList : this.labelList) {
  496. aLabelList.drawLabel(this.mc, mouseX, mouseY);
  497. }
  498. }
  499. }