From a373c31ba136020d088c569c76008ecdc7744c3d Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Tue, 7 Sep 2021 21:19:58 +0200 Subject: ah search overlay tab completion --- .../notenoughupdates/overlays/AuctionSearchOverlay.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 816a6c63..2cfe176b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -334,6 +335,17 @@ public class AuctionSearchOverlay { } else if(Keyboard.getEventKey() == Keyboard.KEY_RETURN) { searchStringExtra = ""; close(); + } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB){ + searchString = autocompletedItems.iterator().next(); + JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(autocompletedItems.iterator().next()); + String displayname = repoObject.get("displayname").getAsString(); + if (displayname.contains("Enchanted Book")){ + String lore = repoObject.get("lore").getAsJsonArray().iterator().next().getAsString(); + String name = lore.substring(0, lore.lastIndexOf(" ")); + searchString = Utils.cleanColour(name); + } else { + searchString = Utils.cleanColour(displayname); + } } else if(Keyboard.getEventKeyState()) { textField.setFocus(true); textField.setText(searchString); -- cgit