|
@@ -2,94 +2,91 @@ package com.blamejared.controlling.client.gui;
|
|
|
|
|
|
import com.blamejared.controlling.Controlling;
|
|
import com.blamejared.controlling.Controlling;
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
-import com.mojang.blaze3d.platform.GlStateManager;
|
|
|
|
-import net.minecraft.client.AbstractOption;
|
|
|
|
-import net.minecraft.client.GameSettings;
|
|
|
|
-import net.minecraft.client.Minecraft;
|
|
|
|
|
|
+import net.minecraft.client.*;
|
|
import net.minecraft.client.gui.IGuiEventListener;
|
|
import net.minecraft.client.gui.IGuiEventListener;
|
|
-import net.minecraft.client.gui.screen.ControlsScreen;
|
|
|
|
-import net.minecraft.client.gui.screen.MouseSettingsScreen;
|
|
|
|
-import net.minecraft.client.gui.screen.Screen;
|
|
|
|
|
|
+import net.minecraft.client.gui.screen.*;
|
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
|
import net.minecraft.client.gui.widget.button.Button;
|
|
import net.minecraft.client.gui.widget.button.Button;
|
|
import net.minecraft.client.gui.widget.list.KeyBindingList;
|
|
import net.minecraft.client.gui.widget.list.KeyBindingList;
|
|
import net.minecraft.client.settings.KeyBinding;
|
|
import net.minecraft.client.settings.KeyBinding;
|
|
import net.minecraft.client.util.InputMappings;
|
|
import net.minecraft.client.util.InputMappings;
|
|
import net.minecraft.util.Util;
|
|
import net.minecraft.util.Util;
|
|
-import net.minecraft.util.text.ITextComponent;
|
|
|
|
-import net.minecraft.util.text.StringTextComponent;
|
|
|
|
-import net.minecraft.util.text.TranslationTextComponent;
|
|
|
|
-import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
-import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
|
|
+import net.minecraft.util.text.*;
|
|
|
|
+import net.minecraftforge.api.distmarker.*;
|
|
import org.lwjgl.glfw.GLFW;
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
-import java.util.Random;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.function.Predicate;
|
|
import java.util.function.Predicate;
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
@OnlyIn(Dist.CLIENT)
|
|
public class GuiNewControls extends ControlsScreen {
|
|
public class GuiNewControls extends ControlsScreen {
|
|
-
|
|
|
|
|
|
+
|
|
private Button buttonReset;
|
|
private Button buttonReset;
|
|
private final Screen parentScreen;
|
|
private final Screen parentScreen;
|
|
private final GameSettings options;
|
|
private final GameSettings options;
|
|
-
|
|
|
|
|
|
+
|
|
private String lastSearch;
|
|
private String lastSearch;
|
|
private TextFieldWidget search;
|
|
private TextFieldWidget search;
|
|
-
|
|
|
|
|
|
+
|
|
private DisplayMode displayMode;
|
|
private DisplayMode displayMode;
|
|
private SearchType searchType;
|
|
private SearchType searchType;
|
|
private SortOrder sortOrder;
|
|
private SortOrder sortOrder;
|
|
-
|
|
|
|
|
|
+
|
|
private Button buttonNone;
|
|
private Button buttonNone;
|
|
private Button buttonConflicting;
|
|
private Button buttonConflicting;
|
|
private GuiCheckBox buttonKey;
|
|
private GuiCheckBox buttonKey;
|
|
private GuiCheckBox buttonCat;
|
|
private GuiCheckBox buttonCat;
|
|
|
|
+ private Button buttonFree;
|
|
private Button patreonButton;
|
|
private Button patreonButton;
|
|
private boolean confirmingReset = false;
|
|
private boolean confirmingReset = false;
|
|
-
|
|
|
|
|
|
+ private boolean showFree = false;
|
|
private String name;
|
|
private String name;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private KeyBindingList customKeyList;
|
|
|
|
+ private GuiFreeKeysList freeKeyList;
|
|
|
|
+
|
|
public GuiNewControls(Screen screen, GameSettings settings) {
|
|
public GuiNewControls(Screen screen, GameSettings settings) {
|
|
|
|
+
|
|
super(screen, settings);
|
|
super(screen, settings);
|
|
this.parentScreen = screen;
|
|
this.parentScreen = screen;
|
|
this.options = settings;
|
|
this.options = settings;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
|
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
|
* window resizes, the buttonList is cleared beforehand.
|
|
* window resizes, the buttonList is cleared beforehand.
|
|
*/
|
|
*/
|
|
protected void init() {
|
|
protected void init() {
|
|
-
|
|
|
|
|
|
+
|
|
this.addButton(new Button(this.width / 2 - 155, 18, 150, 20, new TranslationTextComponent("options.mouse_settings"), (p_213126_1_) -> {
|
|
this.addButton(new Button(this.width / 2 - 155, 18, 150, 20, new TranslationTextComponent("options.mouse_settings"), (p_213126_1_) -> {
|
|
this.minecraft.displayGuiScreen(new MouseSettingsScreen(this, options));
|
|
this.minecraft.displayGuiScreen(new MouseSettingsScreen(this, options));
|
|
}));
|
|
}));
|
|
this.addButton(AbstractOption.AUTO_JUMP.createWidget(this.minecraft.gameSettings, this.width / 2 - 155 + 160, 18, 150));
|
|
this.addButton(AbstractOption.AUTO_JUMP.createWidget(this.minecraft.gameSettings, this.width / 2 - 155 + 160, 18, 150));
|
|
-
|
|
|
|
- this.keyBindingList = new GuiNewKeyBindingList(this, this.minecraft);
|
|
|
|
|
|
+ customKeyList = new GuiNewKeyBindingList(this, this.minecraft);
|
|
|
|
+ freeKeyList = new GuiFreeKeysList(this, this.minecraft);
|
|
|
|
+ this.keyBindingList = customKeyList;
|
|
this.children.add(this.keyBindingList);
|
|
this.children.add(this.keyBindingList);
|
|
this.setListener(this.keyBindingList);
|
|
this.setListener(this.keyBindingList);
|
|
- this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29, 150, 20, new TranslationTextComponent("gui.done"), (p_213126_1_) -> GuiNewControls.this.minecraft.displayGuiScreen(GuiNewControls.this.parentScreen)));
|
|
|
|
-
|
|
|
|
- this.buttonReset = this.addButton(new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslationTextComponent("controls.resetAll"), (p_213126_1_) -> {
|
|
|
|
-
|
|
|
|
- if (!confirmingReset) {
|
|
|
|
|
|
+ this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29, 150, 20, new TranslationTextComponent("gui.done"), (p_213126_1_) -> GuiNewControls.this.minecraft
|
|
|
|
+ .displayGuiScreen(GuiNewControls.this.parentScreen)));
|
|
|
|
+
|
|
|
|
+ this.buttonReset = this.addButton(new Button(this.width / 2 - 155, this.height - 29, 74, 20, new TranslationTextComponent("controls.resetAll"), (p_213126_1_) -> {
|
|
|
|
+
|
|
|
|
+ if(!confirmingReset) {
|
|
confirmingReset = true;
|
|
confirmingReset = true;
|
|
p_213126_1_.setMessage(new TranslationTextComponent("options.confirmReset"));
|
|
p_213126_1_.setMessage(new TranslationTextComponent("options.confirmReset"));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
confirmingReset = false;
|
|
confirmingReset = false;
|
|
p_213126_1_.setMessage(new TranslationTextComponent("controls.resetAll"));
|
|
p_213126_1_.setMessage(new TranslationTextComponent("controls.resetAll"));
|
|
- for (KeyBinding keybinding : GuiNewControls.this.minecraft.gameSettings.keyBindings) {
|
|
|
|
|
|
+ for(KeyBinding keybinding : GuiNewControls.this.minecraft.gameSettings.keyBindings) {
|
|
keybinding.setToDefault();
|
|
keybinding.setToDefault();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
}));
|
|
}));
|
|
this.buttonNone = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showNone"), (p_213126_1_) -> {
|
|
this.buttonNone = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showNone"), (p_213126_1_) -> {
|
|
- if (displayMode == DisplayMode.NONE) {
|
|
|
|
|
|
+ if(displayMode == DisplayMode.NONE) {
|
|
buttonNone.setMessage(new TranslationTextComponent("options.showNone"));
|
|
buttonNone.setMessage(new TranslationTextComponent("options.showNone"));
|
|
displayMode = DisplayMode.ALL;
|
|
displayMode = DisplayMode.ALL;
|
|
} else {
|
|
} else {
|
|
@@ -100,7 +97,7 @@ public class GuiNewControls extends ControlsScreen {
|
|
filterKeys();
|
|
filterKeys();
|
|
}));
|
|
}));
|
|
this.buttonConflicting = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showConflicts"), (p_213126_1_) -> {
|
|
this.buttonConflicting = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showConflicts"), (p_213126_1_) -> {
|
|
- if (displayMode == DisplayMode.CONFLICTING) {
|
|
|
|
|
|
+ if(displayMode == DisplayMode.CONFLICTING) {
|
|
buttonConflicting.setMessage(new TranslationTextComponent("options.showConflicts"));
|
|
buttonConflicting.setMessage(new TranslationTextComponent("options.showConflicts"));
|
|
displayMode = DisplayMode.ALL;
|
|
displayMode = DisplayMode.ALL;
|
|
} else {
|
|
} else {
|
|
@@ -111,38 +108,46 @@ public class GuiNewControls extends ControlsScreen {
|
|
filterKeys();
|
|
filterKeys();
|
|
}));
|
|
}));
|
|
search = new TextFieldWidget(font, this.width / 2 - 154, this.height - 29 - 23, 148, 18, new StringTextComponent(""));
|
|
search = new TextFieldWidget(font, this.width / 2 - 154, this.height - 29 - 23, 148, 18, new StringTextComponent(""));
|
|
- this.buttonKey = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 37, new TranslationTextComponent("options.key").getString(), false) {
|
|
|
|
|
|
+ this.buttonKey = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 37, new TranslationTextComponent("options.key")
|
|
|
|
+ .getString(), false) {
|
|
@Override
|
|
@Override
|
|
public void onPress() {
|
|
public void onPress() {
|
|
|
|
+
|
|
super.onPress();
|
|
super.onPress();
|
|
buttonCat.setIsChecked(false);
|
|
buttonCat.setIsChecked(false);
|
|
searchType = this.isChecked() ? SearchType.KEY : SearchType.NAME;
|
|
searchType = this.isChecked() ? SearchType.KEY : SearchType.NAME;
|
|
filterKeys();
|
|
filterKeys();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- this.buttonCat = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 50, new TranslationTextComponent("options.category").getString(), false) {
|
|
|
|
-
|
|
|
|
|
|
+ this.buttonCat = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 50, new TranslationTextComponent("options.category")
|
|
|
|
+ .getString(), false) {
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onPress() {
|
|
public void onPress() {
|
|
|
|
+
|
|
super.onPress();
|
|
super.onPress();
|
|
buttonKey.setIsChecked(false);
|
|
buttonKey.setIsChecked(false);
|
|
searchType = this.isChecked() ? SearchType.CATEGORY : SearchType.NAME;
|
|
searchType = this.isChecked() ? SearchType.CATEGORY : SearchType.NAME;
|
|
filterKeys();
|
|
filterKeys();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- name = Controlling.PATRON_LIST.stream().skip(Controlling.PATRON_LIST.isEmpty() ? 0 : new Random().nextInt(Controlling.PATRON_LIST.size())).findFirst().orElse("");
|
|
|
|
- patreonButton = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24 - 24, 150 / 2, 20, new StringTextComponent("Patreon"), p_onPress_1_ -> {
|
|
|
|
- Util.getOSType().openURI("https://patreon.com/jaredlll08?s=controllingmod");
|
|
|
|
- }) {
|
|
|
|
|
|
+ name = Controlling.PATRON_LIST.stream()
|
|
|
|
+ .skip(Controlling.PATRON_LIST.isEmpty() ? 0 : new Random().nextInt(Controlling.PATRON_LIST.size()))
|
|
|
|
+ .findFirst()
|
|
|
|
+ .orElse("");
|
|
|
|
+ patreonButton = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24 - 24, 150 / 2, 20, new StringTextComponent("Patreon"), p_onPress_1_ -> Util
|
|
|
|
+ .getOSType()
|
|
|
|
+ .openURI("https://patreon.com/jaredlll08?s=controllingmod")) {
|
|
private boolean wasHovered;
|
|
private boolean wasHovered;
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
|
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
|
- if (this.visible) {
|
|
|
|
|
|
+
|
|
|
|
+ if(this.visible) {
|
|
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
|
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
|
- if (this.wasHovered != this.isHovered()) {
|
|
|
|
- if (this.isHovered()) {
|
|
|
|
- if (this.isFocused()) {
|
|
|
|
|
|
+ if(this.wasHovered != this.isHovered()) {
|
|
|
|
+ if(this.isHovered()) {
|
|
|
|
+ if(this.isFocused()) {
|
|
this.nextNarration = Util.milliTime() + 200L;
|
|
this.nextNarration = Util.milliTime() + 200L;
|
|
} else {
|
|
} else {
|
|
this.nextNarration = Util.milliTime() + 750L;
|
|
this.nextNarration = Util.milliTime() + 750L;
|
|
@@ -151,229 +156,295 @@ public class GuiNewControls extends ControlsScreen {
|
|
this.nextNarration = Long.MAX_VALUE;
|
|
this.nextNarration = Long.MAX_VALUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (this.visible) {
|
|
|
|
|
|
+
|
|
|
|
+ if(this.visible) {
|
|
this.renderButton(stack, mouseX, mouseY, partialTicks);
|
|
this.renderButton(stack, mouseX, mouseY, partialTicks);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
this.narrate();
|
|
this.narrate();
|
|
this.wasHovered = this.isHovered();
|
|
this.wasHovered = this.isHovered();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
sortOrder = SortOrder.NONE;
|
|
sortOrder = SortOrder.NONE;
|
|
- Button buttonSort = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, new TranslationTextComponent("options.sort").appendString(": " + sortOrder.getName()), (p_213126_1_) -> {
|
|
|
|
|
|
+ Button buttonSort = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, new TranslationTextComponent("options.sort")
|
|
|
|
+ .appendString(": " + sortOrder.getName()), (p_213126_1_) -> {
|
|
sortOrder = sortOrder.cycle();
|
|
sortOrder = sortOrder.cycle();
|
|
p_213126_1_.setMessage(new TranslationTextComponent("options.sort").appendString(": " + sortOrder.getName()));
|
|
p_213126_1_.setMessage(new TranslationTextComponent("options.sort").appendString(": " + sortOrder.getName()));
|
|
filterKeys();
|
|
filterKeys();
|
|
}));
|
|
}));
|
|
|
|
+
|
|
|
|
+ this.buttonFree = this.addButton(new Button(this.width / 2 - 155 + 76, this.height - 29, 74, 20, new TranslationTextComponent("options.toggleFree"), (p_213126_1_) -> {
|
|
|
|
+ this.children.remove(this.keyBindingList);
|
|
|
|
+ if(showFree) {
|
|
|
|
+ buttonSort.active = true;
|
|
|
|
+ buttonCat.active = true;
|
|
|
|
+ buttonKey.active = true;
|
|
|
|
+ buttonNone.active = true;
|
|
|
|
+ buttonConflicting.active = true;
|
|
|
|
+ buttonReset.active = true;
|
|
|
|
+ keyBindingList = customKeyList;
|
|
|
|
+ } else {
|
|
|
|
+ freeKeyList.recalculate();
|
|
|
|
+ buttonSort.active = false;
|
|
|
|
+ buttonCat.active = false;
|
|
|
|
+ buttonKey.active = false;
|
|
|
|
+ buttonNone.active = false;
|
|
|
|
+ buttonConflicting.active = false;
|
|
|
|
+ buttonReset.active = false;
|
|
|
|
+ keyBindingList = freeKeyList;
|
|
|
|
+ }
|
|
|
|
+ this.children.add(this.keyBindingList);
|
|
|
|
+ this.setListener(this.keyBindingList);
|
|
|
|
+ showFree = !showFree;
|
|
|
|
+ }));
|
|
|
|
+
|
|
lastSearch = "";
|
|
lastSearch = "";
|
|
displayMode = DisplayMode.ALL;
|
|
displayMode = DisplayMode.ALL;
|
|
searchType = SearchType.NAME;
|
|
searchType = SearchType.NAME;
|
|
-
|
|
|
|
|
|
+ // InputMappings.Input.REGISTRY.values().stream().forEach(input -> {
|
|
|
|
+ // System.out.println(input.func_237520_d_().getString() + " : " + input.getKeyCode());
|
|
|
|
+ // });
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean charTyped(char var1, int var2) {
|
|
public boolean charTyped(char var1, int var2) {
|
|
|
|
+
|
|
return search.charTyped(var1, var2);
|
|
return search.charTyped(var1, var2);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void tick() {
|
|
public void tick() {
|
|
|
|
+
|
|
this.search.tick();
|
|
this.search.tick();
|
|
- if (!lastSearch.equals(search.getText())) {
|
|
|
|
|
|
+ if(!lastSearch.equals(search.getText())) {
|
|
filterKeys();
|
|
filterKeys();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void filterKeys() {
|
|
public void filterKeys() {
|
|
-
|
|
|
|
|
|
+
|
|
lastSearch = search.getText();
|
|
lastSearch = search.getText();
|
|
keyBindingList.getEventListeners().clear();
|
|
keyBindingList.getEventListeners().clear();
|
|
- if (lastSearch.isEmpty() && displayMode == DisplayMode.ALL && sortOrder == SortOrder.NONE) {
|
|
|
|
- keyBindingList.getEventListeners().addAll(((GuiNewKeyBindingList) keyBindingList).getAllEntries());
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.keyBindingList.setScrollAmount(0);
|
|
|
|
- Predicate<GuiNewKeyBindingList.KeyEntry> filters = displayMode.getPredicate();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- switch (searchType) {
|
|
|
|
- case NAME:
|
|
|
|
- filters = filters.and(keyEntry -> keyEntry.getKeyDesc().toLowerCase().contains(lastSearch.toLowerCase()));
|
|
|
|
- break;
|
|
|
|
- case CATEGORY:
|
|
|
|
- filters = filters.and(keyEntry -> new TranslationTextComponent(keyEntry.getKeybinding().getKeyCategory()).getString().toLowerCase().contains(lastSearch.toLowerCase()));
|
|
|
|
- break;
|
|
|
|
- case KEY:
|
|
|
|
- filters = filters.and(keyEntry -> keyEntry.getKeybinding().func_238171_j_().getString().toLowerCase().contains(lastSearch.toLowerCase()));
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (GuiNewKeyBindingList.Entry entry : ((GuiNewKeyBindingList) keyBindingList).getAllEntries()) {
|
|
|
|
- if (searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
|
|
|
|
- if (entry instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
- GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
|
|
|
|
- if (filters.test(keyEntry)) {
|
|
|
|
|
|
+ if(keyBindingList instanceof GuiNewKeyBindingList) {
|
|
|
|
+
|
|
|
|
+ if(lastSearch.isEmpty() && displayMode == DisplayMode.ALL && sortOrder == SortOrder.NONE) {
|
|
|
|
+ keyBindingList.getEventListeners().addAll(((GuiCustomList) keyBindingList).getAllEntries());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.keyBindingList.setScrollAmount(0);
|
|
|
|
+ Predicate<GuiNewKeyBindingList.KeyEntry> filters = displayMode.getPredicate();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ switch(searchType) {
|
|
|
|
+ case NAME:
|
|
|
|
+ filters = filters.and(keyEntry -> keyEntry.getKeyDesc()
|
|
|
|
+ .toLowerCase()
|
|
|
|
+ .contains(lastSearch.toLowerCase()));
|
|
|
|
+ break;
|
|
|
|
+ case CATEGORY:
|
|
|
|
+ filters = filters.and(keyEntry -> new TranslationTextComponent(keyEntry.getKeybinding()
|
|
|
|
+ .getKeyCategory()).getString().toLowerCase().contains(lastSearch.toLowerCase()));
|
|
|
|
+ break;
|
|
|
|
+ case KEY:
|
|
|
|
+ filters = filters.and(keyEntry -> keyEntry.getKeybinding()
|
|
|
|
+ .func_238171_j_()
|
|
|
|
+ .getString()
|
|
|
|
+ .toLowerCase()
|
|
|
|
+ .contains(lastSearch.toLowerCase()));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(GuiNewKeyBindingList.Entry entry : ((GuiCustomList) keyBindingList).getAllEntries()) {
|
|
|
|
+ if(searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
|
|
|
|
+ if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
+ GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
|
|
|
|
+ if(filters.test(keyEntry)) {
|
|
|
|
+ keyBindingList.getEventListeners().add(entry);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
keyBindingList.getEventListeners().add(entry);
|
|
keyBindingList.getEventListeners().add(entry);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- keyBindingList.getEventListeners().add(entry);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (entry instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
- GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
|
|
|
|
- if (filters.test(keyEntry)) {
|
|
|
|
- keyBindingList.getEventListeners().add(entry);
|
|
|
|
|
|
+ if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
+ GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
|
|
|
|
+ if(filters.test(keyEntry)) {
|
|
|
|
+ keyBindingList.getEventListeners().add(entry);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
- }
|
|
|
|
- if (searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
|
|
|
|
- Set<GuiNewKeyBindingList.CategoryEntry> categories = new LinkedHashSet<>();
|
|
|
|
-
|
|
|
|
- for (KeyBindingList.Entry entry : keyBindingList.getEventListeners()) {
|
|
|
|
- if (entry instanceof GuiNewKeyBindingList.CategoryEntry) {
|
|
|
|
- GuiNewKeyBindingList.CategoryEntry centry = (GuiNewKeyBindingList.CategoryEntry) entry;
|
|
|
|
- categories.add(centry);
|
|
|
|
- for (KeyBindingList.Entry child : keyBindingList.getEventListeners()) {
|
|
|
|
- if (child instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
- GuiNewKeyBindingList.KeyEntry childEntry = (GuiNewKeyBindingList.KeyEntry) child;
|
|
|
|
- if (childEntry.getKeybinding().getKeyCategory().equals(centry.getName())) {
|
|
|
|
- categories.remove(centry);
|
|
|
|
|
|
+ if(searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
|
|
|
|
+ Set<GuiNewKeyBindingList.CategoryEntry> categories = new LinkedHashSet<>();
|
|
|
|
+
|
|
|
|
+ for(KeyBindingList.Entry entry : keyBindingList.getEventListeners()) {
|
|
|
|
+ if(entry instanceof GuiNewKeyBindingList.CategoryEntry) {
|
|
|
|
+ GuiNewKeyBindingList.CategoryEntry centry = (GuiNewKeyBindingList.CategoryEntry) entry;
|
|
|
|
+ categories.add(centry);
|
|
|
|
+ for(KeyBindingList.Entry child : keyBindingList.getEventListeners()) {
|
|
|
|
+ if(child instanceof GuiNewKeyBindingList.KeyEntry) {
|
|
|
|
+ GuiNewKeyBindingList.KeyEntry childEntry = (GuiNewKeyBindingList.KeyEntry) child;
|
|
|
|
+ if(childEntry.getKeybinding().getKeyCategory().equals(centry.getName())) {
|
|
|
|
+ categories.remove(centry);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ keyBindingList.getEventListeners().removeAll(categories);
|
|
|
|
+ }
|
|
|
|
+ sortOrder.sort(keyBindingList.getEventListeners());
|
|
|
|
+
|
|
|
|
+ } else if(keyBindingList instanceof GuiFreeKeysList) {
|
|
|
|
+ if(lastSearch.isEmpty()) {
|
|
|
|
+ keyBindingList.getEventListeners().addAll(((GuiCustomList) keyBindingList).getAllEntries());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.keyBindingList.setScrollAmount(0);
|
|
|
|
+
|
|
|
|
+ for(GuiFreeKeysList.Entry entry : ((GuiCustomList) keyBindingList).getAllEntries()) {
|
|
|
|
+ if(entry instanceof GuiFreeKeysList.InputEntry) {
|
|
|
|
+ GuiFreeKeysList.InputEntry inputEntry = (GuiFreeKeysList.InputEntry) entry;
|
|
|
|
+ if(inputEntry.getInput().toString().toLowerCase().contains(lastSearch.toLowerCase())) {
|
|
|
|
+ keyBindingList.getEventListeners().add(entry);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ keyBindingList.getEventListeners().add(entry);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- keyBindingList.getEventListeners().removeAll(categories);
|
|
|
|
}
|
|
}
|
|
- sortOrder.sort(keyBindingList.getEventListeners());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Draws the screen and all the components in it.
|
|
* Draws the screen and all the components in it.
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
|
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
|
|
|
+
|
|
this.renderBackground(stack);
|
|
this.renderBackground(stack);
|
|
this.keyBindingList.render(stack, mouseX, mouseY, partialTicks);
|
|
this.keyBindingList.render(stack, mouseX, mouseY, partialTicks);
|
|
drawCenteredString(stack, this.font, this.title.getString(), this.width / 2, 8, 16777215);
|
|
drawCenteredString(stack, this.font, this.title.getString(), this.width / 2, 8, 16777215);
|
|
boolean flag = false;
|
|
boolean flag = false;
|
|
-
|
|
|
|
- for (KeyBinding keybinding : this.options.keyBindings) {
|
|
|
|
- if (!keybinding.isDefault()) {
|
|
|
|
- flag = true;
|
|
|
|
- break;
|
|
|
|
|
|
+
|
|
|
|
+ if(!showFree) {
|
|
|
|
+ for(KeyBinding keybinding : this.options.keyBindings) {
|
|
|
|
+ if(!keybinding.isDefault()) {
|
|
|
|
+ flag = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
search.render(stack, mouseX, mouseY, partialTicks);
|
|
search.render(stack, mouseX, mouseY, partialTicks);
|
|
this.buttonReset.active = flag;
|
|
this.buttonReset.active = flag;
|
|
- if (!flag) {
|
|
|
|
|
|
+ if(!flag) {
|
|
confirmingReset = false;
|
|
confirmingReset = false;
|
|
buttonReset.setMessage(new TranslationTextComponent("controls.resetAll"));
|
|
buttonReset.setMessage(new TranslationTextComponent("controls.resetAll"));
|
|
}
|
|
}
|
|
- for (int i = 0; i < this.buttons.size(); ++i) {
|
|
|
|
|
|
+ for(int i = 0; i < this.buttons.size(); ++i) {
|
|
this.buttons.get(i).render(stack, mouseX, mouseY, partialTicks);
|
|
this.buttons.get(i).render(stack, mouseX, mouseY, partialTicks);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
ITextComponent text = new TranslationTextComponent("options.search");
|
|
ITextComponent text = new TranslationTextComponent("options.search");
|
|
font.func_238407_a_(stack, text.func_241878_f(), this.width / 2f - (155 / 2f) - (font.getStringWidth(text.getString())) - 5, this.height - 29 - 42, 16777215);
|
|
font.func_238407_a_(stack, text.func_241878_f(), this.width / 2f - (155 / 2f) - (font.getStringWidth(text.getString())) - 5, this.height - 29 - 42, 16777215);
|
|
-
|
|
|
|
- if (patreonButton.isHovered()) {
|
|
|
|
|
|
+
|
|
|
|
+ if(patreonButton.isHovered()) {
|
|
String str = "Join " + name + " and other patrons!";
|
|
String str = "Join " + name + " and other patrons!";
|
|
renderTooltip(stack, new StringTextComponent(str), mouseX, mouseY);
|
|
renderTooltip(stack, new StringTextComponent(str), mouseX, mouseY);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean mouseClicked(double mx, double my, int mb) {
|
|
public boolean mouseClicked(double mx, double my, int mb) {
|
|
|
|
+
|
|
boolean valid;
|
|
boolean valid;
|
|
- if (this.buttonId != null) {
|
|
|
|
|
|
+ if(this.buttonId != null) {
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.Type.MOUSE.getOrMakeInput(mb));
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.Type.MOUSE.getOrMakeInput(mb));
|
|
this.buttonId = null;
|
|
this.buttonId = null;
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
valid = true;
|
|
valid = true;
|
|
search.setFocused2(false);
|
|
search.setFocused2(false);
|
|
- } else if (mb == 0 && this.keyBindingList.mouseClicked(mx, my, mb)) {
|
|
|
|
|
|
+ } else if(mb == 0 && this.keyBindingList.mouseClicked(mx, my, mb)) {
|
|
this.setDragging(true);
|
|
this.setDragging(true);
|
|
this.setListener(this.keyBindingList);
|
|
this.setListener(this.keyBindingList);
|
|
valid = true;
|
|
valid = true;
|
|
search.setFocused2(false);
|
|
search.setFocused2(false);
|
|
} else {
|
|
} else {
|
|
valid = search.mouseClicked(mx, my, mb);
|
|
valid = search.mouseClicked(mx, my, mb);
|
|
- if (!valid && search.isFocused() && mb == 1) {
|
|
|
|
|
|
+ if(!valid && search.isFocused() && mb == 1) {
|
|
search.setText("");
|
|
search.setText("");
|
|
valid = true;
|
|
valid = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (!valid) {
|
|
|
|
-
|
|
|
|
- for (IGuiEventListener iguieventlistener : this.getEventListeners()) {
|
|
|
|
- if (iguieventlistener.mouseClicked(mx, my, mb)) {
|
|
|
|
|
|
+
|
|
|
|
+ if(!valid) {
|
|
|
|
+
|
|
|
|
+ for(IGuiEventListener iguieventlistener : this.getEventListeners()) {
|
|
|
|
+ if(iguieventlistener.mouseClicked(mx, my, mb)) {
|
|
this.setListener(iguieventlistener);
|
|
this.setListener(iguieventlistener);
|
|
- if (mb == 0) {
|
|
|
|
|
|
+ if(mb == 0) {
|
|
this.setDragging(true);
|
|
this.setDragging(true);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
valid = true;
|
|
valid = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
return valid;
|
|
return valid;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean mouseReleased(double mx, double my, int mb) {
|
|
public boolean mouseReleased(double mx, double my, int mb) {
|
|
- if (mb == 0 && this.keyBindingList.mouseReleased(mx, my, mb)) {
|
|
|
|
|
|
+
|
|
|
|
+ if(mb == 0 && this.keyBindingList.mouseReleased(mx, my, mb)) {
|
|
this.setDragging(false);
|
|
this.setDragging(false);
|
|
return true;
|
|
return true;
|
|
- } else if (search.isFocused()) {
|
|
|
|
|
|
+ } else if(search.isFocused()) {
|
|
return search.mouseReleased(mx, my, mb);
|
|
return search.mouseReleased(mx, my, mb);
|
|
} else {
|
|
} else {
|
|
this.setDragging(false);
|
|
this.setDragging(false);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean keyPressed(int keyCode, int scanCode, int modifier) {
|
|
public boolean keyPressed(int keyCode, int scanCode, int modifier) {
|
|
- if (!search.isFocused() && this.buttonId == null) {
|
|
|
|
- if (hasControlDown()) {
|
|
|
|
- if (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_F)) {
|
|
|
|
|
|
+
|
|
|
|
+ if(!search.isFocused() && this.buttonId == null) {
|
|
|
|
+ if(hasControlDown()) {
|
|
|
|
+ if(InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_F)) {
|
|
search.setFocused2(true);
|
|
search.setFocused2(true);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (search.keyPressed(keyCode, scanCode, modifier)) {
|
|
|
|
|
|
+ if(search.keyPressed(keyCode, scanCode, modifier)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- if (search.isFocused()) {
|
|
|
|
- if (keyCode == 256) {
|
|
|
|
|
|
+ if(search.isFocused()) {
|
|
|
|
+ if(keyCode == 256) {
|
|
search.setFocused2(false);
|
|
search.setFocused2(false);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (this.buttonId != null) {
|
|
|
|
- if (keyCode == 256) {
|
|
|
|
|
|
+ if(this.buttonId != null) {
|
|
|
|
+ if(keyCode == 256) {
|
|
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.INPUT_INVALID);
|
|
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.INPUT_INVALID);
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.INPUT_INVALID);
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.INPUT_INVALID);
|
|
} else {
|
|
} else {
|
|
- this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.getInputByCode(keyCode, scanCode));
|
|
|
|
|
|
+ this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings
|
|
|
|
+ .getInputByCode(keyCode, scanCode));
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.getInputByCode(keyCode, scanCode));
|
|
this.options.setKeyBindingCode(this.buttonId, InputMappings.getInputByCode(keyCode, scanCode));
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.buttonId.getKey()))
|
|
|
|
|
|
+
|
|
|
|
+ if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.buttonId.getKey())) {
|
|
this.buttonId = null;
|
|
this.buttonId = null;
|
|
|
|
+ }
|
|
this.time = Util.milliTime();
|
|
this.time = Util.milliTime();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
KeyBinding.resetKeyBindingArrayAndHash();
|
|
return true;
|
|
return true;
|
|
@@ -381,6 +452,6 @@ public class GuiNewControls extends ControlsScreen {
|
|
return super.keyPressed(keyCode, scanCode, modifier);
|
|
return super.keyPressed(keyCode, scanCode, modifier);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|