diff options
author | Lulonaut <67191924+Lulonaut@users.noreply.github.com> | 2022-06-12 05:48:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 03:48:25 +0000 |
commit | c8500921b28240f6fdae902a5efe8d81ca916d9f (patch) | |
tree | abd270aa9045ca2261291e6aaca11853fce0fc79 | |
parent | b3a62c57c3bb5f2e2bb033bb08e085a30be8e570 (diff) | |
download | NotEnoughUpdates-c8500921b28240f6fdae902a5efe8d81ca916d9f.tar.gz NotEnoughUpdates-c8500921b28240f6fdae902a5efe8d81ca916d9f.tar.bz2 NotEnoughUpdates-c8500921b28240f6fdae902a5efe8d81ca916d9f.zip |
Only level 100 option in ah search overlay (#160)
-rw-r--r-- | .idea/copyright/NotEnoughUpdates.xml | 2 | ||||
-rw-r--r-- | Update Notes/2.1.md | 1 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java | 61 |
3 files changed, 40 insertions, 24 deletions
diff --git a/.idea/copyright/NotEnoughUpdates.xml b/.idea/copyright/NotEnoughUpdates.xml index ea087768..8dd67ac4 100644 --- a/.idea/copyright/NotEnoughUpdates.xml +++ b/.idea/copyright/NotEnoughUpdates.xml @@ -1,7 +1,7 @@ <component name="CopyrightManager"> <copyright> <option name="allowReplaceRegexp" value="Copyright" /> - <option name="notice" value="Copyright (C) 2022 NotEnoughUpdates contributors This file is part of NotEnoughUpdates. NotEnoughUpdates is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. NotEnoughUpdates is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>." /> + <option name="notice" value="Copyright (C) 2022 NotEnoughUpdates contributors This file is part of NotEnoughUpdates. NotEnoughUpdates is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. NotEnoughUpdates is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>." /> <option name="myName" value="NotEnoughUpdates" /> </copyright> </component>
\ No newline at end of file diff --git a/Update Notes/2.1.md b/Update Notes/2.1.md index fe32ed69..933b907a 100644 --- a/Update Notes/2.1.md +++ b/Update Notes/2.1.md @@ -95,6 +95,7 @@ - Added support for attributes in neuec - Added Heavy Pearls to todo overlay - cobble8 - Added Booster Cookie Warning - 2stinkysocks +- Added an option to only search for Level 100 pets in the auction house search overlay - Lulonaut ### **Bug Fixes:** 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 a493d201..aee47db2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -59,8 +59,7 @@ public class AuctionSearchOverlay { private static final ResourceLocation SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED = new ResourceLocation( "notenoughupdates:auc_search/ah_search_overlay_tab_completed.png"); private static final ResourceLocation STAR = new ResourceLocation("notenoughupdates:auc_search/star.png"); - private static final ResourceLocation MASTER_STAR = - new ResourceLocation("notenoughupdates:auc_search/master_star.png"); + private static final ResourceLocation MASTER_STAR = new ResourceLocation("notenoughupdates:auc_search/master_star.png"); private static final ResourceLocation STAR_BOARD = new ResourceLocation("notenoughupdates:auc_search/star_board.png"); private static final GuiElementTextField textField = new GuiElementTextField("", 200, 20, 0); @@ -73,6 +72,7 @@ public class AuctionSearchOverlay { private static int selectedStars = 0; private static boolean atLeast = true; + private static boolean onlyLevel100 = false; private static final int AUTOCOMPLETE_HEIGHT = 118; @@ -156,15 +156,22 @@ public class AuctionSearchOverlay { Utils.drawTexturedRect(width / 2 + 108 + 10 * i, topY + 29, 9, 10, GL11.GL_NEAREST); } - if (selectedStars < 6) Gui.drawRect(width / 2 + 106, topY + 42, width / 2 + 115, topY + 51, 0xffffffff); - if (selectedStars < 6) Gui.drawRect(width / 2 + 107, topY + 43, width / 2 + 114, topY + 50, 0xff000000); - if (atLeast && selectedStars < 6) Gui.drawRect(width / 2 + 108, topY + 44, width / 2 + 113, topY + 49, 0xffffffff); - if (selectedStars < 6) Minecraft.getMinecraft().fontRendererObj.drawString( - "At Least?", - width / 2 + 117, - topY + 43, - 0xffffff - ); + if (selectedStars < 6) { + Gui.drawRect(width / 2 + 106, topY + 42, width / 2 + 115, topY + 51, 0xffffffff); + Gui.drawRect(width / 2 + 107, topY + 43, width / 2 + 114, topY + 50, 0xff000000); + Minecraft.getMinecraft().fontRendererObj.drawString("At Least?", width / 2 + 117, topY + 43, 0xffffff); + + if (atLeast) { + Gui.drawRect(width / 2 + 108, topY + 44, width / 2 + 113, topY + 49, 0xffffffff); + } + } + + Gui.drawRect(width / 2 + 106, topY + 53, width / 2 + 115, topY + 62, 0xffffffff); + Gui.drawRect(width / 2 + 107, topY + 54, width / 2 + 114, topY + 61, 0xff000000); + if (onlyLevel100) { + Gui.drawRect(width / 2 + 108, topY + 55, width / 2 + 113, topY + 60, 0xffffffff); + } + Minecraft.getMinecraft().fontRendererObj.drawString("Level 100 pets only?", width / 2 + 117, topY + 54, 0xffffff); Minecraft.getMinecraft().fontRendererObj.drawString("Enter Query:", width / 2 - 100, topY - 10, 0xdddddd, true); @@ -293,17 +300,13 @@ public class AuctionSearchOverlay { } String searchString = autocompletedItems.toArray()[i].toString(); JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(searchString); - String displayname = repoObject.get("displayname").getAsString(); - if (displayname.contains("Enchanted Book")) { - String lore = repoObject.get("lore").getAsJsonArray().get(0).getAsString(); - String name = lore.substring(0, lore.lastIndexOf(" ")); - return Utils.cleanColour(name); - } else { - return Utils.cleanColour(displayname); + if (repoObject != null) { + ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(repoObject); + return Utils.cleanColour(stack.getDisplayName().replaceAll("\\[.+]", "")); } - } else { - return null; + } + return null; } public static void close() { @@ -321,10 +324,16 @@ public class AuctionSearchOverlay { TileEntitySign tes = ((AccessorGuiEditSign) Minecraft.getMinecraft().currentScreen).getTileSign(); - String search = searchString.trim(); - if (searchStringExtra != null && !searchStringExtra.isEmpty()) { - search += " " + searchStringExtra.trim(); + StringBuilder stringBuilder = new StringBuilder(searchString.trim()); + if (!searchStringExtra.isEmpty()) { + stringBuilder.append(searchStringExtra.trim()); } + if (onlyLevel100) { + stringBuilder.insert(0, "[Lvl 100] "); + } + + String search = stringBuilder.toString(); + if (search.length() <= 15) { tes.signText[0] = new ChatComponentText(search.substring(0, Math.min(search.length(), 15))); } else { @@ -565,6 +574,12 @@ public class AuctionSearchOverlay { return; } + if (Mouse.getEventButtonState() && mouseX >= width / 2 + 106 && mouseX <= width / 2 + 116 && + mouseY >= topY + 53 && mouseY <= topY + 62) { + onlyLevel100 = !onlyLevel100; + return; + } + if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && searchFieldClicked) { textField.mouseClickMove(mouseX - 2, topY + 10, 0, 0); } |