|
@@ -11,82 +11,87 @@ import org.apache.commons.lang3.ArrayUtils;
|
|
|
import java.util.*;
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
-public class GuiNewKeyBindingList extends GuiListExtended {
|
|
|
-
|
|
|
- private final GuiNewControls controlsScreen;
|
|
|
- private final Minecraft mc;
|
|
|
- private LinkedList<IGuiListEntry> listEntries;
|
|
|
- private LinkedList<IGuiListEntry> listEntriesAll;
|
|
|
-
|
|
|
- private int maxListLabelWidth;
|
|
|
-
|
|
|
- public GuiNewKeyBindingList(GuiNewControls controls, Minecraft mcIn) {
|
|
|
- super(mcIn, controls.width + 45, controls.height + 80, 63, controls.height - 80, 20);
|
|
|
- this.controlsScreen = controls;
|
|
|
- this.mc = mcIn;
|
|
|
- KeyBinding[] akeybinding = ArrayUtils.clone(mcIn.gameSettings.keyBindings);
|
|
|
- listEntries = new LinkedList<>();
|
|
|
- listEntriesAll = new LinkedList<>();
|
|
|
-
|
|
|
- // this.listEntries = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()];
|
|
|
- Arrays.sort(akeybinding);
|
|
|
- int i = 0;
|
|
|
- String s = null;
|
|
|
-
|
|
|
- for(KeyBinding keybinding : akeybinding) {
|
|
|
- String s1 = keybinding.getKeyCategory();
|
|
|
-
|
|
|
- if(!s1.equals(s)) {
|
|
|
- s = s1;
|
|
|
- this.listEntries.add(new GuiNewKeyBindingList.CategoryEntry(s1));
|
|
|
- this.listEntriesAll.add(new GuiNewKeyBindingList.CategoryEntry(s1));
|
|
|
-
|
|
|
- // this.listEntries[i++] = new GuiNewKeyBindingList.CategoryEntry(s1);
|
|
|
- }
|
|
|
-
|
|
|
- int j = mcIn.fontRendererObj.getStringWidth(I18n.format(keybinding.getKeyDescription(), new Object[0]));
|
|
|
-
|
|
|
- if(j > this.maxListLabelWidth) {
|
|
|
- this.maxListLabelWidth = j;
|
|
|
- }
|
|
|
-
|
|
|
- this.listEntries.add(new GuiNewKeyBindingList.KeyEntry(keybinding));
|
|
|
- this.listEntriesAll.add(new GuiNewKeyBindingList.KeyEntry(keybinding));
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- protected int getSize() {
|
|
|
- return this.listEntries.size();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Gets the IGuiListEntry object for the given index
|
|
|
- */
|
|
|
- public GuiListExtended.IGuiListEntry getListEntry(int index) {
|
|
|
- return this.listEntries.get(index);
|
|
|
- }
|
|
|
-
|
|
|
- protected int getScrollBarX() {
|
|
|
- return super.getScrollBarX() + 35;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Gets the width of the list
|
|
|
- */
|
|
|
- public int getListWidth() {
|
|
|
- return super.getListWidth() + 32;
|
|
|
- }
|
|
|
-
|
|
|
- @SideOnly(Side.CLIENT)
|
|
|
- public class CategoryEntry implements GuiListExtended.IGuiListEntry {
|
|
|
-
|
|
|
- private final String labelText;
|
|
|
- private final int labelWidth;
|
|
|
-
|
|
|
- public CategoryEntry(String name) {
|
|
|
- this.labelText = I18n.format(name);
|
|
|
- this.labelWidth = GuiNewKeyBindingList.this.mc.fontRendererObj.getStringWidth(this.labelText);
|
|
|
+public class GuiNewKeyBindingList extends GuiKeyBindingList {
|
|
|
+
|
|
|
+ private final GuiNewControls controlsScreen;
|
|
|
+ private final Minecraft mc;
|
|
|
+ private LinkedList<IGuiListEntry> listEntries;
|
|
|
+ private LinkedList<IGuiListEntry> listEntriesAll;
|
|
|
+
|
|
|
+ private int maxListLabelWidth;
|
|
|
+
|
|
|
+ public GuiNewKeyBindingList(GuiNewControls controls, Minecraft mcIn) {
|
|
|
+ super(controls, mcIn);
|
|
|
+ this.controlsScreen = controls;
|
|
|
+ this.mc = mcIn;
|
|
|
+ this.width = controls.width + 45;
|
|
|
+ this.height = controls.height + 80;
|
|
|
+ this.top = 63;
|
|
|
+ this.bottom = controls.height - 80;
|
|
|
+ KeyBinding[] akeybinding = ArrayUtils.clone(mcIn.gameSettings.keyBindings);
|
|
|
+ listEntries = new LinkedList<>();
|
|
|
+ listEntriesAll = new LinkedList<>();
|
|
|
+
|
|
|
+ // this.listEntries = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()];
|
|
|
+ Arrays.sort(akeybinding);
|
|
|
+ int i = 0;
|
|
|
+ String s = null;
|
|
|
+
|
|
|
+ for(KeyBinding keybinding : akeybinding) {
|
|
|
+ String s1 = keybinding.getKeyCategory();
|
|
|
+
|
|
|
+ if(!s1.equals(s)) {
|
|
|
+ s = s1;
|
|
|
+ if(!s1.endsWith(".hidden")) {
|
|
|
+ this.listEntries.add(new GuiNewKeyBindingList.CategoryEntry(s1));
|
|
|
+ this.listEntriesAll.add(new GuiNewKeyBindingList.CategoryEntry(s1));
|
|
|
+ }
|
|
|
+ // this.listEntries[i++] = new GuiNewKeyBindingList.CategoryEntry(s1);
|
|
|
+ }
|
|
|
+
|
|
|
+ int j = mcIn.fontRendererObj.getStringWidth(I18n.format(keybinding.getKeyDescription(), new Object[0]));
|
|
|
+
|
|
|
+ if(j > this.maxListLabelWidth) {
|
|
|
+ this.maxListLabelWidth = j;
|
|
|
+ }
|
|
|
+ if(!s1.endsWith(".hidden")) {
|
|
|
+ this.listEntries.add(new GuiNewKeyBindingList.KeyEntry(keybinding));
|
|
|
+ this.listEntriesAll.add(new GuiNewKeyBindingList.KeyEntry(keybinding));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected int getSize() {
|
|
|
+ return this.listEntries.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the IGuiListEntry object for the given index
|
|
|
+ */
|
|
|
+ public GuiListExtended.IGuiListEntry getListEntry(int index) {
|
|
|
+ return this.listEntries.get(index);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected int getScrollBarX() {
|
|
|
+ return super.getScrollBarX() + 35;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the width of the list
|
|
|
+ */
|
|
|
+ public int getListWidth() {
|
|
|
+ return super.getListWidth() + 32;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SideOnly(Side.CLIENT)
|
|
|
+ public class CategoryEntry implements GuiListExtended.IGuiListEntry {
|
|
|
+
|
|
|
+ private final String labelText;
|
|
|
+ private final int labelWidth;
|
|
|
+
|
|
|
+ public CategoryEntry(String name) {
|
|
|
+ this.labelText = I18n.format(name);
|
|
|
+ this.labelWidth = GuiNewKeyBindingList.this.mc.fontRendererObj.getStringWidth(this.labelText);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -102,38 +107,38 @@ public class GuiNewKeyBindingList extends GuiListExtended {
|
|
|
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
|
|
|
* clicked and the list should not be dragged.
|
|
|
*/
|
|
|
- public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
|
|
|
- */
|
|
|
- public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @SideOnly(Side.CLIENT)
|
|
|
- public class KeyEntry implements GuiListExtended.IGuiListEntry {
|
|
|
-
|
|
|
- /**
|
|
|
- * The keybinding specified for this KeyEntry
|
|
|
- */
|
|
|
- private final KeyBinding keybinding;
|
|
|
- /**
|
|
|
- * The localized key description for this KeyEntry
|
|
|
- */
|
|
|
- private final String keyDesc;
|
|
|
- private final GuiButton btnChangeKeyBinding;
|
|
|
- private final GuiButton btnReset;
|
|
|
-
|
|
|
- private KeyEntry(KeyBinding name) {
|
|
|
- this.keybinding = name;
|
|
|
- this.keyDesc = I18n.format(name.getKeyDescription(), new Object[0]);
|
|
|
- this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 95, 20, I18n.format(name.getKeyDescription(), new Object[0]));
|
|
|
- this.btnReset = new GuiButton(0, 0, 0, 50, 20, I18n.format("controls.reset", new Object[0]));
|
|
|
- }
|
|
|
+ public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
|
|
|
+ */
|
|
|
+ public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @SideOnly(Side.CLIENT)
|
|
|
+ public class KeyEntry implements GuiListExtended.IGuiListEntry {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The keybinding specified for this KeyEntry
|
|
|
+ */
|
|
|
+ private final KeyBinding keybinding;
|
|
|
+ /**
|
|
|
+ * The localized key description for this KeyEntry
|
|
|
+ */
|
|
|
+ private final String keyDesc;
|
|
|
+ private final GuiButton btnChangeKeyBinding;
|
|
|
+ private final GuiButton btnReset;
|
|
|
+
|
|
|
+ private KeyEntry(KeyBinding name) {
|
|
|
+ this.keybinding = name;
|
|
|
+ this.keyDesc = I18n.format(name.getKeyDescription(), new Object[0]);
|
|
|
+ this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 95, 20, I18n.format(name.getKeyDescription(), new Object[0]));
|
|
|
+ this.btnReset = new GuiButton(0, 0, 0, 50, 20, I18n.format("controls.reset", new Object[0]));
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void func_192633_a(int p_192633_1_, int p_192633_2_, int p_192633_3_, float p_192633_4_) {
|
|
@@ -143,6 +148,7 @@ public class GuiNewKeyBindingList extends GuiListExtended {
|
|
|
public void func_192634_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float p_192634_9_) {
|
|
|
boolean flag = GuiNewKeyBindingList.this.controlsScreen.buttonId == this.keybinding;
|
|
|
GuiNewKeyBindingList.this.mc.fontRendererObj.drawString(this.keyDesc, x + 90 - GuiNewKeyBindingList.this.maxListLabelWidth, y + slotHeight / 2 - GuiNewKeyBindingList.this.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215);
|
|
|
+ GuiNewKeyBindingList.this.mc.fontRendererObj.drawString(String.format("(%s)", I18n.format(keybinding.getKeyCategory())), x - 45 - GuiNewKeyBindingList.this.maxListLabelWidth, y + slotHeight / 2 - GuiNewKeyBindingList.this.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215);
|
|
|
this.btnReset.xPosition = x + 210;
|
|
|
this.btnReset.yPosition = y;
|
|
|
this.btnReset.enabled = !this.keybinding.isSetToDefaultValue();
|
|
@@ -150,6 +156,11 @@ public class GuiNewKeyBindingList extends GuiListExtended {
|
|
|
this.btnChangeKeyBinding.xPosition = x + 105;
|
|
|
this.btnChangeKeyBinding.yPosition = y;
|
|
|
this.btnChangeKeyBinding.displayString = this.keybinding.getDisplayName();
|
|
|
+ if(keybinding.isSetToDefaultValue()) {
|
|
|
+ btnReset.visible = false;
|
|
|
+ } else {
|
|
|
+ btnReset.visible = true;
|
|
|
+ }
|
|
|
boolean flag1 = false;
|
|
|
boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G
|
|
|
|
|
@@ -173,44 +184,44 @@ public class GuiNewKeyBindingList extends GuiListExtended {
|
|
|
|
|
|
/**
|
|
|
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
|
|
|
- * clicked and the list should not be dragged.
|
|
|
- */
|
|
|
- public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
|
- if(this.btnChangeKeyBinding.mousePressed(GuiNewKeyBindingList.this.mc, mouseX, mouseY)) {
|
|
|
- GuiNewKeyBindingList.this.controlsScreen.buttonId = this.keybinding;
|
|
|
- return true;
|
|
|
- } else if(this.btnReset.mousePressed(GuiNewKeyBindingList.this.mc, mouseX, mouseY)) {
|
|
|
- this.keybinding.setToDefault();
|
|
|
- GuiNewKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault());
|
|
|
- KeyBinding.resetKeyBindingArrayAndHash();
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
|
|
|
- */
|
|
|
- public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
|
|
|
- this.btnChangeKeyBinding.mouseReleased(x, y);
|
|
|
- this.btnReset.mouseReleased(x, y);
|
|
|
- }
|
|
|
-
|
|
|
- public KeyBinding getKeybinding() {
|
|
|
- return keybinding;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public LinkedList<IGuiListEntry> getListEntries() {
|
|
|
- return listEntries;
|
|
|
- }
|
|
|
-
|
|
|
- public LinkedList<IGuiListEntry> getListEntriesAll() {
|
|
|
- return listEntriesAll;
|
|
|
- }
|
|
|
-
|
|
|
- public void setListEntries(LinkedList<IGuiListEntry> listEntries) {
|
|
|
- this.listEntries = listEntries;
|
|
|
- }
|
|
|
+ * clicked and the list should not be dragged.
|
|
|
+ */
|
|
|
+ public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
|
+ if(this.btnChangeKeyBinding.mousePressed(GuiNewKeyBindingList.this.mc, mouseX, mouseY)) {
|
|
|
+ GuiNewKeyBindingList.this.controlsScreen.buttonId = this.keybinding;
|
|
|
+ return true;
|
|
|
+ } else if(this.btnReset.mousePressed(GuiNewKeyBindingList.this.mc, mouseX, mouseY)) {
|
|
|
+ this.keybinding.setToDefault();
|
|
|
+ GuiNewKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault());
|
|
|
+ KeyBinding.resetKeyBindingArrayAndHash();
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
|
|
|
+ */
|
|
|
+ public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
|
|
|
+ this.btnChangeKeyBinding.mouseReleased(x, y);
|
|
|
+ this.btnReset.mouseReleased(x, y);
|
|
|
+ }
|
|
|
+
|
|
|
+ public KeyBinding getKeybinding() {
|
|
|
+ return keybinding;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public LinkedList<IGuiListEntry> getListEntries() {
|
|
|
+ return listEntries;
|
|
|
+ }
|
|
|
+
|
|
|
+ public LinkedList<IGuiListEntry> getListEntriesAll() {
|
|
|
+ return listEntriesAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setListEntries(LinkedList<IGuiListEntry> listEntries) {
|
|
|
+ this.listEntries = listEntries;
|
|
|
+ }
|
|
|
}
|