mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-26 14:24:23 +00:00
Disable hotbar keys handling in terminals (#331)
This commit is contained in:
1 parent
029b479297
commit
de2f625577
2 files changed
+69
-48
No files matched your search
@@ -7,12 +7,10 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import com.glodblock.github.client.gui.base.FCGuiMonitor;
|
import com.glodblock.github.client.gui.base.FCGuiMonitor;
|
||||||
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
|
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
|
||||||
import com.glodblock.github.util.ModAndClassUtil;
|
|
||||||
|
|
||||||
import appeng.api.storage.ITerminalHost;
|
import appeng.api.storage.ITerminalHost;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.client.me.ItemRepo;
|
import appeng.client.me.ItemRepo;
|
||||||
import appeng.core.AEConfig;
|
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
|
|
||||||
public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
|
public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
|
||||||
@@ -40,13 +38,6 @@ public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
|
|||||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
|
||||||
super.drawScreen(mouseX, mouseY, btn);
|
|
||||||
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
|
|
||||||
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
|
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
|
||||||
setSearchString(displayName, true);
|
setSearchString(displayName, true);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
import com.glodblock.github.FluidCraft;
|
import com.glodblock.github.FluidCraft;
|
||||||
import com.glodblock.github.client.gui.FCGuiTextField;
|
|
||||||
import com.glodblock.github.client.gui.GuiFluidMonitor;
|
import com.glodblock.github.client.gui.GuiFluidMonitor;
|
||||||
import com.glodblock.github.client.gui.GuiItemMonitor;
|
import com.glodblock.github.client.gui.GuiItemMonitor;
|
||||||
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
|
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
|
||||||
@@ -28,6 +27,7 @@ import com.glodblock.github.util.ModAndClassUtil;
|
|||||||
|
|
||||||
import appeng.api.config.CraftingStatus;
|
import appeng.api.config.CraftingStatus;
|
||||||
import appeng.api.config.PinsState;
|
import appeng.api.config.PinsState;
|
||||||
|
import appeng.api.config.SearchBoxFocusPriority;
|
||||||
import appeng.api.config.SearchBoxMode;
|
import appeng.api.config.SearchBoxMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.TerminalStyle;
|
import appeng.api.config.TerminalStyle;
|
||||||
@@ -45,6 +45,7 @@ import appeng.client.gui.widgets.GuiScrollbar;
|
|||||||
import appeng.client.gui.widgets.GuiTabButton;
|
import appeng.client.gui.widgets.GuiTabButton;
|
||||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||||
import appeng.client.gui.widgets.ISortSource;
|
import appeng.client.gui.widgets.ISortSource;
|
||||||
|
import appeng.client.gui.widgets.MEGuiTextField;
|
||||||
import appeng.client.me.InternalSlotME;
|
import appeng.client.me.InternalSlotME;
|
||||||
import appeng.client.me.ItemRepo;
|
import appeng.client.me.ItemRepo;
|
||||||
import appeng.client.me.PinSlotME;
|
import appeng.client.me.PinSlotME;
|
||||||
@@ -93,7 +94,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
public GuiTabButton craftingStatusBtn;
|
public GuiTabButton craftingStatusBtn;
|
||||||
protected IDisplayRepo repo;
|
protected IDisplayRepo repo;
|
||||||
protected GuiImgButton craftingStatusImgBtn;
|
protected GuiImgButton craftingStatusImgBtn;
|
||||||
protected FCGuiTextField searchField;
|
protected MEGuiTextField searchField;
|
||||||
protected int perRow = 9;
|
protected int perRow = 9;
|
||||||
protected int reservedSpace = 0;
|
protected int reservedSpace = 0;
|
||||||
protected boolean customSortOrder = true;
|
protected boolean customSortOrder = true;
|
||||||
@@ -113,6 +114,10 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
protected boolean hasShiftKeyDown = false;
|
protected boolean hasShiftKeyDown = false;
|
||||||
private PinsState pinsState;
|
private PinsState pinsState;
|
||||||
public final boolean hasPinHost;
|
public final boolean hasPinHost;
|
||||||
|
private boolean canBeAutoFocused;
|
||||||
|
private boolean isAutoFocused;
|
||||||
|
protected int currentMouseY;
|
||||||
|
protected int currentMouseX;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
|
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
|
||||||
@@ -337,18 +342,19 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||||
this.offsetY += 20;
|
this.offsetY += 20;
|
||||||
|
|
||||||
// Right now 80 > offsetX, but that can be changed later.
|
this.searchField = new MEGuiTextField(90, 12) {
|
||||||
// noinspection DataFlowIssue
|
|
||||||
this.searchField = new FCGuiTextField(
|
@Override
|
||||||
this.fontRendererObj,
|
public void onTextChange(final String oldText) {
|
||||||
this.guiLeft + Math.max(80, this.offsetX),
|
final String text = getText();
|
||||||
this.guiTop + 4,
|
repo.setSearchString(text);
|
||||||
90,
|
repo.updateView();
|
||||||
12);
|
setScrollBar();
|
||||||
this.searchField.setEnableBackgroundDrawing(false);
|
}
|
||||||
|
};
|
||||||
|
this.searchField.x = this.guiLeft + Math.max(80, this.offsetX);
|
||||||
|
this.searchField.y = this.guiTop + 4;
|
||||||
this.searchField.setMaxStringLength(25);
|
this.searchField.setMaxStringLength(25);
|
||||||
this.searchField.setTextColor(0xFFFFFF);
|
|
||||||
this.searchField.setVisible(true);
|
|
||||||
if (ModAndClassUtil.isSearchStringTooltip)
|
if (ModAndClassUtil.isSearchStringTooltip)
|
||||||
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
|
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
|
||||||
|
|
||||||
@@ -384,7 +390,9 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||||
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
|
this.canBeAutoFocused = SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting;
|
||||||
|
this.searchField.setFocused(this.canBeAutoFocused);
|
||||||
|
this.isAutoFocused = this.canBeAutoFocused;
|
||||||
|
|
||||||
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
|
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
|
||||||
setSearchString(memoryText, false);
|
setSearchString(memoryText, false);
|
||||||
@@ -420,6 +428,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
|
|
||||||
public void setSearchString(String memoryText, boolean updateView) {
|
public void setSearchString(String memoryText, boolean updateView) {
|
||||||
this.searchField.setText(memoryText);
|
this.searchField.setText(memoryText);
|
||||||
|
this.searchField.setCursorPositionEnd();
|
||||||
this.repo.setSearchString(memoryText);
|
this.repo.setSearchString(memoryText);
|
||||||
if (updateView) {
|
if (updateView) {
|
||||||
this.repo.updateView();
|
this.repo.updateView();
|
||||||
@@ -429,13 +438,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
this.searchField.mouseClicked(xCoord, yCoord, btn);
|
||||||
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
|
isAutoFocused = false;
|
||||||
this.searchField.mouseClicked(xCoord, yCoord, btn);
|
|
||||||
}
|
|
||||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
|
||||||
setSearchString("", true);
|
|
||||||
}
|
|
||||||
super.mouseClicked(xCoord, yCoord, btn);
|
super.mouseClicked(xCoord, yCoord, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,6 +722,9 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
if (this.searchField != null) {
|
if (this.searchField != null) {
|
||||||
this.searchField.drawTextBox();
|
this.searchField.drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.currentMouseX = mouseX;
|
||||||
|
this.currentMouseY = mouseY;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getBackground() {
|
protected String getBackground() {
|
||||||
@@ -740,18 +747,29 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(final char character, final int key) {
|
protected void keyTyped(final char character, final int key) {
|
||||||
if (!this.checkHotbarKeys(key)) {
|
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
boolean skipHotbarCheck = searchField.isFocused()
|
||||||
this.repo.setSearchString(this.searchField.getText());
|
&& (AEConfig.instance.searchBoxFocusPriority == SearchBoxFocusPriority.ALWAYS
|
||||||
this.repo.updateView();
|
|| (AEConfig.instance.searchBoxFocusPriority == SearchBoxFocusPriority.NO_AUTOSEARCH
|
||||||
this.setScrollBar();
|
&& !isAutoFocused));
|
||||||
} else {
|
|
||||||
super.keyTyped(character, key);
|
if (!skipHotbarCheck && checkHotbarKeys(key)) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean mouseInGui = this
|
||||||
|
.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY);
|
||||||
|
|
||||||
|
if (this.canBeAutoFocused && !searchField.isFocused() && mouseInGui) {
|
||||||
|
searchField.setFocused(true);
|
||||||
|
isAutoFocused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!searchField.textboxKeyTyped(character, key)) {
|
||||||
|
super.keyTyped(character, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,13 +851,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
this.standardSize = standardSize;
|
this.standardSize = standardSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
|
||||||
super.drawScreen(mouseX, mouseY, btn);
|
|
||||||
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
|
|
||||||
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOverSearchField(int x, int y) {
|
public boolean isOverSearchField(int x, int y) {
|
||||||
return searchField.isMouseIn(x, y);
|
return searchField.isMouseIn(x, y);
|
||||||
}
|
}
|
||||||
@@ -881,4 +892,23 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
|||||||
public void setPinsState(PinsState state) {
|
public void setPinsState(PinsState state) {
|
||||||
configSrc.putSetting(Settings.PINS_STATE, state);
|
configSrc.putSetting(Settings.PINS_STATE, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
protected boolean isPointInRegion(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY) {
|
||||||
|
pointX -= this.guiLeft;
|
||||||
|
pointY -= this.guiTop;
|
||||||
|
return pointX >= rectX - 1 && pointX < rectX + rectWidth + 1
|
||||||
|
&& pointY >= rectY - 1
|
||||||
|
&& pointY < rectY + rectHeight + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Moving items via hotbar keys in terminals isn't working anyway.
|
||||||
|
// Let's disable hotbar keys processing for terminal slots to allow proper input of numbers in the search field
|
||||||
|
@Override
|
||||||
|
protected boolean checkHotbarKeys(int keyCode) {
|
||||||
|
if (theSlot instanceof SlotME) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.checkHotbarKeys(keyCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user