From d28cd798e9e8808d451cf8ddfb8b657230251400 Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Thu, 13 Oct 2022 15:19:25 -0300 Subject: [PATCH] rework gui highlighting for terminals --- ...uiFluidInterfaceConfigurationTerminal.java | 20 ++++++++++++------- .../GuiInterfaceConfigurationTerminal.java | 12 +++++++++-- .../implementations/GuiInterfaceTerminal.java | 15 +++++++++++--- .../client/gui/widgets/GuiFluidTank.java | 15 ++++++++++++++ 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/main/java/appeng/client/gui/implementations/GuiFluidInterfaceConfigurationTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiFluidInterfaceConfigurationTerminal.java index d671e071e..788c02099 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiFluidInterfaceConfigurationTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiFluidInterfaceConfigurationTerminal.java @@ -19,10 +19,8 @@ package appeng.client.gui.implementations; -import appeng.api.AEApi; import appeng.api.config.ActionItems; import appeng.api.config.Settings; -import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiCustomSlot; @@ -89,6 +87,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements private final ArrayList names = new ArrayList<>(); private final ArrayList lines = new ArrayList<>(); private final Set matchedStacks = new HashSet<>(); + private final Set matchedInterfaces = new HashSet(); private final Map> cachedSearches = new WeakHashMap<>(); @@ -157,12 +156,14 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) { for (int z = 0; z < 5; z++) { - GuiFluidTank tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16); + GuiFluidTank tankSlot; + if (!matchedInterfaces.contains(inv) && !this.matchedStacks.contains(inv.getInventory().getFluidInSlot(z + (row * 5)))) { + tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16, true); + } else { + tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16); + } this.guiSlots.add(tankSlot); guiFluidTankClientDCInternalFluidInvMap.put(tankSlot, inv); - if (this.matchedStacks.contains(inv.getInventory().getFluidInSlot(z + (row * 5)))) { - drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00); - } } linesDraw++; offset += 18; @@ -321,6 +322,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements this.byName.clear(); this.buttonList.clear(); this.matchedStacks.clear(); + this.matchedInterfaces.clear(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); @@ -352,8 +354,12 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements slot++; } } + if (searchFieldInputs.isEmpty() || entry.getName().toLowerCase().contains(searchFieldInputs)) { + this.matchedInterfaces.add(entry); + found = true; + } // if found, filter skipped or machine name matching the search term, add it - if (found || entry.getName().toLowerCase().contains(searchFieldInputs)) { + if (found) { this.byName.put(entry.getName(), entry); cachedSearch.add(entry); } else { diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java index fb21dfa79..79e6a95bb 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceConfigurationTerminal.java @@ -78,6 +78,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI private final ArrayList names = new ArrayList<>(); private final ArrayList lines = new ArrayList<>(); private final Set matchedStacks = new HashSet<>(); + private final Set matchedInterfaces = new HashSet<>(); private final Map> cachedSearches = new WeakHashMap<>(); @@ -148,7 +149,9 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI for (int z = 0; z < 9; z++) { this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset)); if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) { - drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00); + drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x8A00FF00); + } else if (!matchedInterfaces.contains(inv)) { + drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x6A000000); } } linesDraw++; @@ -325,6 +328,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI this.byName.clear(); this.buttonList.clear(); this.matchedStacks.clear(); + this.matchedInterfaces.clear(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); @@ -356,7 +360,11 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI } } // if found, filter skipped or machine name matching the search term, add it - if (found || entry.getName().toLowerCase().contains(searchFieldInputs)) { + if (searchFieldInputs.isEmpty() || entry.getName().toLowerCase().contains(searchFieldInputs)) { + this.matchedInterfaces.add(entry); + found = true; + } + if (found) { this.byName.put(entry.getName(), entry); cachedSearch.add(entry); } else { diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java index 1ce42d2da..20f596a9f 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java @@ -69,7 +69,7 @@ public class GuiInterfaceTerminal extends AEBaseGui { private final ArrayList names = new ArrayList<>(); private final ArrayList lines = new ArrayList<>(); private final Set matchedStacks = new HashSet<>(); - + private final Set matchedInterfaces = new HashSet<>(); private final Map> cachedSearches = new WeakHashMap<>(); private boolean refreshList = false; @@ -155,7 +155,9 @@ public class GuiInterfaceTerminal extends AEBaseGui { for (int z = 0; z < 9; z++) { this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset)); if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) { - drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00); + drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x8A00FF00); + } else if (!matchedInterfaces.contains(inv)) { + drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x6A000000); } } linesDraw++; @@ -344,6 +346,7 @@ public class GuiInterfaceTerminal extends AEBaseGui { this.byName.clear(); this.buttonList.clear(); this.matchedStacks.clear(); + this.matchedInterfaces.clear(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase(); @@ -393,7 +396,13 @@ public class GuiInterfaceTerminal extends AEBaseGui { } } // if found, filter skipped or machine name matching the search term, add it - if (found || (entry.getName().toLowerCase().contains(searchFieldInputs) && entry.getName().toLowerCase().contains(searchFieldOutputs))) { + if ((searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty()) || + !searchFieldInputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldInputs) || + (!searchFieldOutputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldOutputs))) { + this.matchedInterfaces.add(entry); + found = true; + } + if (found) { if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) { this.byName.put(entry.getName(), entry); cachedSearch.add(entry); diff --git a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java index 8e4832c10..31c271255 100644 --- a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java @@ -41,6 +41,7 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip { private final int slot; private final int width; private final int height; + private boolean darkened = false; public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h) { super(id, x, y); @@ -50,6 +51,15 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip { this.height = h; } + public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h, boolean darkened) { + super(id, x, y); + this.tank = tank; + this.slot = slot; + this.width = w; + this.height = h; + this.darkened = darkened; + } + @Override public void drawContent(Minecraft mc, int mouseX, int mouseY, float partialTicks) { final IAEFluidStack fs = this.getFluidStack(); @@ -66,6 +76,11 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip { float red = (fluid.getFluid().getColor() >> 16 & 255) / 255.0F; float green = (fluid.getFluid().getColor() >> 8 & 255) / 255.0F; float blue = (fluid.getFluid().getColor() & 255) / 255.0F; + if (darkened) { + red = red * 0.4F; + green = green * 0.4F; + blue = blue * 0.4F; + } GlStateManager.color(red, green, blue); TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill().toString());