mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-14 01:14:11 +00:00
Restore Shift+click rename in Interface Terminal (#1237)
This commit is contained in:
1 parent
1880b8baa1
commit
251e8b144c
6 files changed
+73
-9
No files matched your search
@@ -46,5 +46,6 @@ public enum ActionItems {
|
||||
CONTROL_BUTTON_VALUES_ON,
|
||||
PINS,
|
||||
TOGGLE_SHOW_HIDDEN_INTERFACES_ON,
|
||||
TOGGLE_SHOW_HIDDEN_INTERFACES_OFF
|
||||
TOGGLE_SHOW_HIDDEN_INTERFACES_OFF,
|
||||
RENAME_INTERFACE
|
||||
}
|
||||
@@ -61,14 +61,17 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.api.util.NamedDimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
import appeng.client.gui.IInterfaceTerminalPostUpdate;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.render.highlighter.BlockPosHighlighter;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
@@ -82,6 +85,7 @@ import appeng.core.sync.packets.PacketInterfaceTerminalUpdate;
|
||||
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate.PacketEntry;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketRemoteRename;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketToggleInterfaceVisibility;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
@@ -107,7 +111,7 @@ import cpw.mods.fml.common.Loader;
|
||||
* @author firenoo
|
||||
*/
|
||||
public class GuiInterfaceTerminal extends AEBaseGui
|
||||
implements IDropToFillTextField, IGuiTooltipHandler, IInterfaceTerminalPostUpdate {
|
||||
implements IDropToFillTextField, IGuiTooltipHandler, IInterfaceTerminalPostUpdate, IGuiSub {
|
||||
|
||||
public static final int HEADER_HEIGHT = 52;
|
||||
public static final int INV_HEIGHT = 98;
|
||||
@@ -152,6 +156,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
protected static String searchFieldNamesText = "";
|
||||
|
||||
protected int offsetY;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
/*
|
||||
* Z-level Map (FLOATS) 0.0 - BACKGROUND 1.0 - ItemStacks 2.0 - Slot color overlays 20.0 - ItemStack overlays 21.0 -
|
||||
@@ -171,6 +176,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
|
||||
public GuiInterfaceTerminal(final Container cont) {
|
||||
super(cont);
|
||||
if (cont instanceof IContainerSubGui subGui) subGui.setGuiLink(this);
|
||||
|
||||
this.setScrollBar(new GuiScrollbar());
|
||||
this.xSize = 209;
|
||||
@@ -215,9 +221,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
|
||||
terminalStyleBox = new GuiImgButton(0, 0, Settings.TERMINAL_STYLE, null);
|
||||
|
||||
this.extraOptionsText = new ArrayList<>(3);
|
||||
this.extraOptionsText = new ArrayList<>(4);
|
||||
extraOptionsText.add(ButtonToolTips.HighlightInterface.getLocal());
|
||||
extraOptionsText.add(ButtonToolTips.HighlightInterfaceDesc.getLocal());
|
||||
extraOptionsText.add(ButtonToolTips.RenameInterface.getLocal());
|
||||
|
||||
NEI.searchField.putFormatter(this.searchFieldInputs);
|
||||
NEI.searchField.putFormatter(this.searchFieldOutputs);
|
||||
@@ -325,6 +332,20 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
buttonList.add(guiButtonUseSubstitute);
|
||||
|
||||
initCustomButtons(this.guiLeft - 18, offset);
|
||||
initPrimaryGuiButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPrimaryGuiButton() {
|
||||
if (inventorySlots instanceof IContainerSubGui subGui && subGui.getPrimaryGuiIcon() != null) {
|
||||
buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 22,
|
||||
this.guiTop,
|
||||
subGui.getPrimaryGuiIcon(),
|
||||
subGui.getPrimaryGuiIcon().getDisplayName(),
|
||||
itemRender));
|
||||
}
|
||||
}
|
||||
|
||||
protected void repositionSlots() {
|
||||
@@ -433,6 +454,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
return;
|
||||
}
|
||||
if (actionPerformedCustomButtons(btn)) return;
|
||||
if (btn == guiButtonAssemblersOnly) {
|
||||
onlyMolecularAssemblers = !onlyMolecularAssemblers;
|
||||
@@ -838,12 +863,15 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
}
|
||||
}
|
||||
tessellator.draw();
|
||||
/* Draw buttons — Alt switches highlight button to hide button */
|
||||
/* Draw buttons — Alt switches to hide button, Shift switches to rename button */
|
||||
if (viewY + entry.optionsButton.height > 0 && viewY < viewHeight) {
|
||||
final boolean altHeld = Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
|
||||
final GuiImgButton activeButton = altHeld ? entry.hideButton : entry.optionsButton;
|
||||
final boolean shiftHeld = isShiftKeyDown() && entry.isInPlayerDimension();
|
||||
final GuiImgButton activeButton = altHeld ? entry.hideButton
|
||||
: shiftHeld ? entry.renameButton : entry.optionsButton;
|
||||
entry.optionsButton.yPosition = viewY + 5;
|
||||
entry.hideButton.yPosition = altHeld ? viewY + 5 : -1;
|
||||
entry.renameButton.yPosition = shiftHeld && !altHeld ? viewY + 5 : -1;
|
||||
activeButton.drawButton(mc, relMouseX, relMouseY);
|
||||
if (activeButton.getMouseIn()
|
||||
&& relMouseY >= Math.max(titleBottom - viewY + activeButton.yPosition, activeButton.yPosition)) {
|
||||
@@ -851,6 +879,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
pendingHideButtonTooltip = buildInterfaceTerminalVisibilityTooltip(entry.hideButton);
|
||||
pendingHideButtonTooltipX = relMouseX + guiLeft + VIEW_LEFT;
|
||||
pendingHideButtonTooltipY = relMouseY + guiTop + HEADER_HEIGHT + 1;
|
||||
} else if (shiftHeld) {
|
||||
pendingHideButtonTooltip = Collections.singletonList(ButtonToolTips.RenameInterface.getLocal());
|
||||
pendingHideButtonTooltipX = relMouseX + guiLeft + VIEW_LEFT;
|
||||
pendingHideButtonTooltipY = relMouseY + guiTop + HEADER_HEIGHT + 1;
|
||||
} else {
|
||||
GL11.glTranslatef(0f, 0f, TOOLTIP_Z);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
@@ -862,6 +894,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
} else {
|
||||
entry.optionsButton.yPosition = -1;
|
||||
entry.hideButton.yPosition = -1;
|
||||
entry.renameButton.yPosition = -1;
|
||||
}
|
||||
/* PASS 2: Items */
|
||||
outerItems:
|
||||
@@ -1676,6 +1709,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
AppEngInternalInventory inv;
|
||||
GuiImgButton optionsButton;
|
||||
GuiImgButton hideButton;
|
||||
GuiImgButton renameButton;
|
||||
/** Nullable - icon that represents the interface */
|
||||
ItemStack selfRep;
|
||||
/** Nullable - icon that represents the interface's "target" */
|
||||
@@ -1715,6 +1749,8 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
this.optionsButton.setHalfSize(true);
|
||||
this.hideButton = new GuiImgButton(2, 0, Settings.INTERFACE_TERMINAL, YesNo.YES);
|
||||
this.hideButton.setHalfSize(true);
|
||||
this.renameButton = new GuiImgButton(2, 0, Settings.ACTIONS, ActionItems.RENAME_INTERFACE);
|
||||
this.renameButton.setHalfSize(true);
|
||||
this.guiHeight = 18 * rows + 1;
|
||||
this.brokenRecipes = new Boolean[rows * rowSize];
|
||||
this.useSubstitute = new Boolean[rows * rowSize];
|
||||
@@ -1731,6 +1767,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean isInPlayerDimension() {
|
||||
return mc != null && mc.thePlayer != null && mc.thePlayer.dimension == this.dim;
|
||||
}
|
||||
|
||||
InterfaceTerminalEntry setIcons(ItemStack selfRep, ItemStack dispRep) {
|
||||
// Kotlin would make this pretty easy :(
|
||||
this.selfRep = selfRep;
|
||||
@@ -1857,13 +1897,14 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
return true;
|
||||
}
|
||||
|
||||
optionsButton.func_146113_a(mc.getSoundHandler());
|
||||
|
||||
if (isShiftKeyDown()) {
|
||||
if (isShiftKeyDown() && isInPlayerDimension()) {
|
||||
renameButton.func_146113_a(mc.getSoundHandler());
|
||||
NetworkHandler.instance.sendToServer(new PacketRemoteRename(x, y, z, dim, side));
|
||||
return true;
|
||||
}
|
||||
|
||||
optionsButton.func_146113_a(mc.getSoundHandler());
|
||||
|
||||
// When using the highlight from the interface terminal, we want it to only
|
||||
// highlight the interface containing the patterns and not any output p2p interfaces
|
||||
BlockPosHighlighter.highlightNamedBlocks(
|
||||
|
||||
@@ -686,6 +686,7 @@ public class GuiImgButton extends GuiButton implements ITooltip {
|
||||
ActionItems.HIGHLIGHT_INTERFACE,
|
||||
ButtonToolTips.HighlightInterface,
|
||||
"");
|
||||
this.registerApp(70, Settings.ACTIONS, ActionItems.RENAME_INTERFACE, ButtonToolTips.RenameInterface, "");
|
||||
this.registerApp(
|
||||
5 * 16 + 10,
|
||||
Settings.INTERFACE_TERMINAL,
|
||||
|
||||
@@ -40,7 +40,9 @@ import appeng.api.parts.IInterfaceTerminal;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IInterfaceViewable;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
@@ -52,8 +54,13 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer implements IContainerSubGui {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IGuiSub guiLink;
|
||||
|
||||
private int nextId = 0;
|
||||
private boolean forceNextUpdate = false;
|
||||
@@ -482,4 +489,16 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return getPrimaryGui() != null ? getPrimaryGui().getIcon() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setGuiLink(final IGuiSub gs) {
|
||||
this.guiLink = gs;
|
||||
}
|
||||
}
|
||||
@@ -176,6 +176,7 @@ public enum ButtonToolTips implements Localization {
|
||||
ToggleShowOnlyInvalidInterfaceOffDesc,
|
||||
HighlightInterface,
|
||||
HighlightInterfaceDesc,
|
||||
RenameInterface,
|
||||
SearchFieldInputs,
|
||||
SearchFieldOutputs,
|
||||
SearchFieldNames,
|
||||
|
||||
@@ -635,6 +635,7 @@ gui.tooltips.appliedenergistics2.ToggleShowOnlyInvalidInterfaceOnDesc=Showing al
|
||||
gui.tooltips.appliedenergistics2.ToggleShowOnlyInvalidInterfaceOffDesc=Showing only interfaces with invalid patterns
|
||||
gui.tooltips.appliedenergistics2.HighlightInterface=Highlight interface
|
||||
gui.tooltips.appliedenergistics2.HighlightInterfaceDesc=§6ALT§8 - §7Toggle interface visibility
|
||||
gui.tooltips.appliedenergistics2.RenameInterface=§6SHIFT§8 - §7Rename interface
|
||||
gui.tooltips.appliedenergistics2.InterfaceTerminalVisibility=Interface Terminal Visibility
|
||||
gui.tooltips.appliedenergistics2.InterfaceTerminalVisibilityVisible=Visible - shown in interface terminal
|
||||
gui.tooltips.appliedenergistics2.InterfaceTerminalVisibilityHidden=Hidden - not shown in interface terminal
|
||||
|
||||
Reference in new issue
Block a user