|
@@ -4,18 +4,19 @@ import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.*;
|
|
import net.minecraft.client.gui.*;
|
|
import net.minecraft.client.resources.I18n;
|
|
import net.minecraft.client.resources.I18n;
|
|
import net.minecraft.client.settings.*;
|
|
import net.minecraft.client.settings.*;
|
|
|
|
+import net.minecraftforge.client.settings.KeyModifier;
|
|
|
|
+import org.lwjgl.input.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.LinkedList;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
-public class GuiNewControls extends GuiScreen {
|
|
|
|
|
|
+public class GuiNewControls extends GuiControls {
|
|
|
|
|
|
private static final GameSettings.Options[] OPTIONS_ARR = new GameSettings.Options[]{GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.AUTO_JUMP};
|
|
private static final GameSettings.Options[] OPTIONS_ARR = new GameSettings.Options[]{GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.AUTO_JUMP};
|
|
/**
|
|
/**
|
|
* A reference to the screen object that created this. Used for navigating between screens.
|
|
* A reference to the screen object that created this. Used for navigating between screens.
|
|
*/
|
|
*/
|
|
private final GuiScreen parentScreen;
|
|
private final GuiScreen parentScreen;
|
|
- protected String screenTitle = "Controls";
|
|
|
|
/**
|
|
/**
|
|
* Reference to the GameSettings object.
|
|
* Reference to the GameSettings object.
|
|
*/
|
|
*/
|
|
@@ -23,8 +24,6 @@ public class GuiNewControls extends GuiScreen {
|
|
/**
|
|
/**
|
|
* The ID of the button that has been pressed.
|
|
* The ID of the button that has been pressed.
|
|
*/
|
|
*/
|
|
- public KeyBinding buttonId;
|
|
|
|
- public long time;
|
|
|
|
public GuiNewKeyBindingList keyBindingList;
|
|
public GuiNewKeyBindingList keyBindingList;
|
|
private GuiButton buttonReset;
|
|
private GuiButton buttonReset;
|
|
|
|
|
|
@@ -33,7 +32,12 @@ public class GuiNewControls extends GuiScreen {
|
|
|
|
|
|
private boolean conflicts = false;
|
|
private boolean conflicts = false;
|
|
|
|
|
|
|
|
+ public int availableTime;
|
|
|
|
+
|
|
|
|
+ public GuiButton conflictsButton;
|
|
|
|
+
|
|
public GuiNewControls(GuiScreen screen, GameSettings settings) {
|
|
public GuiNewControls(GuiScreen screen, GameSettings settings) {
|
|
|
|
+ super(screen, settings);
|
|
this.parentScreen = screen;
|
|
this.parentScreen = screen;
|
|
this.options = settings;
|
|
this.options = settings;
|
|
}
|
|
}
|
|
@@ -44,9 +48,9 @@ public class GuiNewControls extends GuiScreen {
|
|
*/
|
|
*/
|
|
public void initGui() {
|
|
public void initGui() {
|
|
this.keyBindingList = new GuiNewKeyBindingList(this, this.mc);
|
|
this.keyBindingList = new GuiNewKeyBindingList(this, this.mc);
|
|
- this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("gui.done", new Object[0])));
|
|
|
|
- this.buttonReset = this.func_189646_b(new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("controls.resetAll", new Object[0])));
|
|
|
|
- this.screenTitle = I18n.format("controls.title", new Object[0]);
|
|
|
|
|
|
+ this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("gui.done")));
|
|
|
|
+ this.buttonReset = this.func_189646_b(new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("controls.resetAll")));
|
|
|
|
+ this.screenTitle = I18n.format("controls.title");
|
|
int i = 0;
|
|
int i = 0;
|
|
|
|
|
|
for(GameSettings.Options gamesettings$options : OPTIONS_ARR) {
|
|
for(GameSettings.Options gamesettings$options : OPTIONS_ARR) {
|
|
@@ -60,15 +64,14 @@ public class GuiNewControls extends GuiScreen {
|
|
}
|
|
}
|
|
|
|
|
|
search = new GuiTextField(0, mc.fontRendererObj, this.width / 2 - 155, this.height - 29 - 28, 150, 18);
|
|
search = new GuiTextField(0, mc.fontRendererObj, this.width / 2 - 155, this.height - 29 - 28, 150, 18);
|
|
- search.setFocused(true);
|
|
|
|
search.setCanLoseFocus(true);
|
|
search.setCanLoseFocus(true);
|
|
- this.buttonList.add(new GuiButton(2906, this.width / 2 - 155 + 160, this.height - 29 - 29, 150, 20, I18n.format("options.showConflicts")));
|
|
|
|
|
|
+ conflictsButton = new GuiButton(2906, this.width / 2 - 155 + 160, this.height - 29 - 29, 150, 20, I18n.format("options.showConflicts"));
|
|
|
|
+ this.buttonList.add(conflictsButton);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updateScreen() {
|
|
public void updateScreen() {
|
|
- super.updateScreen();
|
|
|
|
search.updateCursorCounter();
|
|
search.updateCursorCounter();
|
|
if(!search.getText().equals(lastFilterText)) {
|
|
if(!search.getText().equals(lastFilterText)) {
|
|
reloadKeys(0);
|
|
reloadKeys(0);
|
|
@@ -122,10 +125,39 @@ public class GuiNewControls extends GuiScreen {
|
|
* Handles mouse input.
|
|
* Handles mouse input.
|
|
*/
|
|
*/
|
|
public void handleMouseInput() throws IOException {
|
|
public void handleMouseInput() throws IOException {
|
|
- super.handleMouseInput();
|
|
|
|
|
|
+ superSuperHandleMouseInput();
|
|
this.keyBindingList.handleMouseInput();
|
|
this.keyBindingList.handleMouseInput();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Handles mouse input.
|
|
|
|
+ */
|
|
|
|
+ public void superSuperHandleMouseInput() throws IOException {
|
|
|
|
+ int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
|
|
|
+ int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
|
|
|
+ int k = Mouse.getEventButton();
|
|
|
|
+
|
|
|
|
+ if(Mouse.getEventButtonState()) {
|
|
|
|
+ if(this.mc.gameSettings.touchscreen && this.touchValue++ > 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.eventButton = k;
|
|
|
|
+ this.lastMouseEvent = Minecraft.getSystemTime();
|
|
|
|
+ this.mouseClicked(i, j, this.eventButton);
|
|
|
|
+ } else if(k != -1) {
|
|
|
|
+ if(this.mc.gameSettings.touchscreen && --this.touchValue > 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.eventButton = -1;
|
|
|
|
+ this.mouseReleased(i, j, k);
|
|
|
|
+ } else if(this.eventButton != -1 && this.lastMouseEvent > 0L) {
|
|
|
|
+ long l = Minecraft.getSystemTime() - this.lastMouseEvent;
|
|
|
|
+ this.mouseClickMove(i, j, this.eventButton, l);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
|
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
|
*/
|
|
*/
|
|
@@ -136,17 +168,20 @@ public class GuiNewControls extends GuiScreen {
|
|
for(KeyBinding keybinding : this.mc.gameSettings.keyBindings) {
|
|
for(KeyBinding keybinding : this.mc.gameSettings.keyBindings) {
|
|
keybinding.setToDefault();
|
|
keybinding.setToDefault();
|
|
}
|
|
}
|
|
-
|
|
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
|
|
+ availableTime = 0;
|
|
} else if(button.id < 100 && button instanceof GuiOptionButton) {
|
|
} else if(button.id < 100 && button instanceof GuiOptionButton) {
|
|
this.options.setOptionValue(((GuiOptionButton) button).returnEnumOptions(), 1);
|
|
this.options.setOptionValue(((GuiOptionButton) button).returnEnumOptions(), 1);
|
|
button.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
|
|
button.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
|
|
} else if(button.id == 2906) {
|
|
} else if(button.id == 2906) {
|
|
|
|
+ availableTime = 0;
|
|
if(!conflicts) {
|
|
if(!conflicts) {
|
|
conflicts = true;
|
|
conflicts = true;
|
|
|
|
+ conflictsButton.displayString = "Show All";
|
|
reloadKeys(1);
|
|
reloadKeys(1);
|
|
} else {
|
|
} else {
|
|
conflicts = false;
|
|
conflicts = false;
|
|
|
|
+ conflictsButton.displayString = "Show Conflicts";
|
|
reloadKeys(1);
|
|
reloadKeys(1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -164,7 +199,7 @@ public class GuiNewControls extends GuiScreen {
|
|
this.buttonId = null;
|
|
this.buttonId = null;
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
} else if(mouseButton != 0 || !this.keyBindingList.mouseClicked(mouseX, mouseY, mouseButton)) {
|
|
} else if(mouseButton != 0 || !this.keyBindingList.mouseClicked(mouseX, mouseY, mouseButton)) {
|
|
- super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
|
|
|
|
+ superSuperMouseClicked(mouseX, mouseY, mouseButton);
|
|
}
|
|
}
|
|
search.mouseClicked(mouseX, mouseY, mouseButton);
|
|
search.mouseClicked(mouseX, mouseY, mouseButton);
|
|
if(mouseButton == 1 && mouseX >= search.xPosition && mouseX < search.xPosition + search.width && mouseY >= search.yPosition && mouseY < search.yPosition + search.height) {
|
|
if(mouseButton == 1 && mouseX >= search.xPosition && mouseX < search.xPosition + search.width && mouseY >= search.yPosition && mouseY < search.yPosition + search.height) {
|
|
@@ -172,12 +207,42 @@ public class GuiNewControls extends GuiScreen {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
|
|
|
+ */
|
|
|
|
+ protected void superSuperMouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
|
|
+ if(mouseButton == 0) {
|
|
|
|
+ for(int i = 0; i < this.buttonList.size(); ++i) {
|
|
|
|
+ GuiButton guibutton = this.buttonList.get(i);
|
|
|
|
+
|
|
|
|
+ if(guibutton.mousePressed(this.mc, mouseX, mouseY)) {
|
|
|
|
+ net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event = new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.buttonList);
|
|
|
|
+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
|
|
|
|
+ break;
|
|
|
|
+ guibutton = event.getButton();
|
|
|
|
+ this.selectedButton = guibutton;
|
|
|
|
+ guibutton.playPressSound(this.mc.getSoundHandler());
|
|
|
|
+ this.actionPerformed(guibutton);
|
|
|
|
+ if(this.equals(this.mc.currentScreen))
|
|
|
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.buttonList));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Called when a mouse button is released.
|
|
* Called when a mouse button is released.
|
|
*/
|
|
*/
|
|
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
|
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
|
if(state != 0 || !this.keyBindingList.mouseReleased(mouseX, mouseY, state)) {
|
|
if(state != 0 || !this.keyBindingList.mouseReleased(mouseX, mouseY, state)) {
|
|
- super.mouseReleased(mouseX, mouseY, state);
|
|
|
|
|
|
+ superSuperMouseReleased(mouseX, mouseY, state);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void superSuperMouseReleased(int mouseX, int mouseY, int state) {
|
|
|
|
+ if(this.selectedButton != null && state == 0) {
|
|
|
|
+ this.selectedButton.mouseReleased(mouseX, mouseY);
|
|
|
|
+ this.selectedButton = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -197,16 +262,29 @@ public class GuiNewControls extends GuiScreen {
|
|
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), typedChar + 256);
|
|
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), typedChar + 256);
|
|
this.options.setOptionKeyBinding(this.buttonId, typedChar + 256);
|
|
this.options.setOptionKeyBinding(this.buttonId, typedChar + 256);
|
|
}
|
|
}
|
|
- //This is the modifier section, to the game, it appears that shift is down when it is not, this is the fix.
|
|
|
|
-// if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(keyCode))
|
|
|
|
|
|
+ if(!KeyModifier.isKeyCodeModifier(keyCode)) {
|
|
this.buttonId = null;
|
|
this.buttonId = null;
|
|
|
|
+ }
|
|
this.time = Minecraft.getSystemTime();
|
|
this.time = Minecraft.getSystemTime();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
} else {
|
|
} else {
|
|
if(search.isFocused())
|
|
if(search.isFocused())
|
|
search.textboxKeyTyped(typedChar, keyCode);
|
|
search.textboxKeyTyped(typedChar, keyCode);
|
|
- else
|
|
|
|
- super.keyTyped(typedChar, keyCode);
|
|
|
|
|
|
+ else if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL))
|
|
|
|
+ availableTime = 40;
|
|
|
|
+ else {
|
|
|
|
+ superSuperKeyTyped(typedChar, keyCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void superSuperKeyTyped(char typedChar, int keyCode) throws IOException {
|
|
|
|
+ if(keyCode == 1) {
|
|
|
|
+ this.mc.displayGuiScreen((GuiScreen) null);
|
|
|
|
+
|
|
|
|
+ if(this.mc.currentScreen == null) {
|
|
|
|
+ this.mc.setIngameFocus();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -228,7 +306,81 @@ public class GuiNewControls extends GuiScreen {
|
|
}
|
|
}
|
|
|
|
|
|
this.buttonReset.enabled = flag;
|
|
this.buttonReset.enabled = flag;
|
|
- super.drawScreen(mouseX, mouseY, partialTicks);
|
|
|
|
|
|
+ superSuperDrawScreen(mouseX, mouseY, partialTicks);
|
|
search.drawTextBox();
|
|
search.drawTextBox();
|
|
|
|
+
|
|
|
|
+ if(availableTime > 0) {
|
|
|
|
+ drawRect(keyBindingList.left, keyBindingList.top, keyBindingList.right, keyBindingList.bottom + 18, 0xFF000000);
|
|
|
|
+ LinkedList<Integer> keyCodes = new LinkedList<>();
|
|
|
|
+ for(int i = 2; i < 219; i++) {
|
|
|
|
+ keyCodes.add(i);
|
|
|
|
+ }
|
|
|
|
+ keyCodes.add(-98);
|
|
|
|
+ keyCodes.add(-99);
|
|
|
|
+ keyCodes.add(-100);
|
|
|
|
+
|
|
|
|
+ List<Integer> removed = new ArrayList<>();
|
|
|
|
+ keyBindingList.getListEntriesAll().forEach(i -> {
|
|
|
|
+ if(i instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
+ removed.add(((GuiNewKeyBindingList.KeyEntry) i).getKeybinding().getKeyCode());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ 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};
|
|
|
|
+ for(int i : rem) {
|
|
|
|
+ removed.add(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ keyCodes.forEach(i -> {
|
|
|
|
+ if(i >= 0)
|
|
|
|
+ if(Keyboard.getKeyName(i) == null || Keyboard.getKeyName(i).isEmpty()) {
|
|
|
|
+ removed.add(i);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ keyCodes.removeAll(removed);
|
|
|
|
+ Collections.sort(keyCodes);
|
|
|
|
+ final int[] x = {0};
|
|
|
|
+ final int[] y = {0};
|
|
|
|
+ final int[] count = {0};
|
|
|
|
+ fontRendererObj.drawString("Available Keys:", width / 2, keyBindingList.top + 2, 0xFFFFFF);
|
|
|
|
+ List<String> codes = new ArrayList<>();
|
|
|
|
+ keyCodes.forEach(key -> {
|
|
|
|
+ if(key >= 0) {
|
|
|
|
+ codes.add(Keyboard.getKeyName(key));
|
|
|
|
+ fontRendererObj.drawString(Keyboard.getKeyName(key), keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0xFF55FF);
|
|
|
|
+ } else {
|
|
|
|
+ codes.add(Mouse.getButtonName(key + 100));
|
|
|
|
+ switch(key + 100) {
|
|
|
|
+ case 0:
|
|
|
|
+ fontRendererObj.drawString("Button 1", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ fontRendererObj.drawString("Button 2", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ fontRendererObj.drawString("Button 3", keyBindingList.left + (x[0] * 65), keyBindingList.top + 12 + (y[0]++ * fontRendererObj.FONT_HEIGHT), 0x55FF55);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ count[0]++;
|
|
|
|
+ if(count[0] > keyBindingList.height / 30) {
|
|
|
|
+ count[0] = 0;
|
|
|
|
+ x[0]++;
|
|
|
|
+ y[0] = 0;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ availableTime--;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void superSuperDrawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
|
|
+ for(GuiButton aButtonList : this.buttonList) {
|
|
|
|
+ aButtonList.drawButton(this.mc, mouseX, mouseY);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(GuiLabel aLabelList : this.labelList) {
|
|
|
|
+ aLabelList.drawLabel(this.mc, mouseX, mouseY);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|