diff options
| author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
|---|---|---|
| committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
| commit | 07403ec86c53f67b94d988b4c01a0afc2fdb2810 (patch) | |
| tree | fba4b3c37b02c42267e03a07453d3941c98fd66d /src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java | |
| parent | fc4143dd3c892b11ae5f427fcecc22044ff98460 (diff) | |
| parent | ec0660e41145d3d9ed479b3e697afddf8ddc8c4c (diff) | |
| download | notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.gz notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.bz2 notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.zip | |
Merge branch 'beta'
uh yeah its pretty necessary guys
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java | 566 |
1 files changed, 395 insertions, 171 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 23def271..73381955 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -3,15 +3,14 @@ package io.github.moulberry.notenoughupdates; import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.infopanes.*; import io.github.moulberry.notenoughupdates.itemeditor.NEUItemEditor; import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; +import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned; import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating; -import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupHorz; -import io.github.moulberry.notenoughupdates.util.LerpingFloat; -import io.github.moulberry.notenoughupdates.util.LerpingInteger; -import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.GuiContainer; @@ -57,6 +56,8 @@ import static io.github.moulberry.notenoughupdates.GuiTextures.*; public class NEUOverlay extends Gui { + private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation("notenoughupdates:supersecretassets/bald.png"); + private NEUManager manager; private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$"; @@ -95,8 +96,14 @@ public class NEUOverlay extends Gui { private TreeSet<JsonObject> searchedItems = null; private JsonObject[] searchedItemsArr = null; + private HashMap<String, Set<String>> searchedItemsSubgroup = new HashMap<>(); + + private long selectedItemMillis = 0; + private int selectedItemGroupX = -1; + private int selectedItemGroupY = -1; + private List<JsonObject> selectedItemGroup = null; + private boolean itemPaneOpen = false; - private boolean hoveringItemPaneToggle = false; private int page = 0; @@ -128,8 +135,6 @@ public class NEUOverlay extends Gui { private static final int SORT_MODE_ARMOR = 4; private static final int SORT_MODE_ACCESSORY = 5; - private ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - private boolean disabled = false; private int lastScreenWidth; @@ -272,20 +277,17 @@ public class NEUOverlay extends Gui { @Override public void render(float x, float y) { int paddingUnscaled = getPaddingUnscaled(); + int searchYSize = getSearchBarYSize(); - Minecraft.getMinecraft().getTextureManager().bindTexture(settings); - drawRect((int)x, (int)y, - (int)x + getWidth(), (int)y + getHeight(), - Color.WHITE.getRGB()); - - - drawRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - (int)x + getWidth() - paddingUnscaled, (int)y + getHeight() - paddingUnscaled, - Color.GRAY.getRGB()); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(x, y, + searchYSize + paddingUnscaled*2, searchYSize + paddingUnscaled*2, GL11.GL_NEAREST); + Minecraft.getMinecraft().getTextureManager().bindTexture(settings); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - getSearchBarYSize(), getSearchBarYSize()); + searchYSize, searchYSize); GlStateManager.bindTexture(0); } }; @@ -310,8 +312,9 @@ public class NEUOverlay extends Gui { @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { if(Mouse.getEventButtonState()) { - displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help", - "https://moulberry.github.io/files/neu_help.html")); + //displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help", + // "https://moulberry.github.io/files/neu_help.html")); + Minecraft.getMinecraft().displayGuiScreen(new HelpGUI()); Utils.playPressSound(); } } @@ -323,16 +326,14 @@ public class NEUOverlay extends Gui { @Override public void render(float x, float y) { int paddingUnscaled = getPaddingUnscaled(); + int searchYSize = getSearchBarYSize(); - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - drawRect((int)x, (int)y, - (int)x + getWidth(), (int)y + getHeight(), - Color.WHITE.getRGB()); - - drawRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - (int)x + getWidth() - paddingUnscaled, (int)y + getHeight() - paddingUnscaled, - Color.GRAY.getRGB()); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(x, y, + searchYSize + paddingUnscaled*2, searchYSize + paddingUnscaled*2, GL11.GL_NEAREST); + Minecraft.getMinecraft().getTextureManager().bindTexture(help); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, getSearchBarYSize(), getSearchBarYSize()); @@ -401,7 +402,6 @@ public class NEUOverlay extends Gui { NBTTagList textures = new NBTTagList(); NBTTagCompound textures_0 = new NBTTagCompound(); - String uuid = UUID.nameUUIDFromBytes(display.getBytes()).toString(); skullOwner.setString("Id", uuid); skullOwner.setString("Name", uuid); @@ -424,16 +424,13 @@ public class NEUOverlay extends Gui { } } if(render != null) { - Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); GlStateManager.color(1, 1, 1, 1); Utils.drawTexturedRect(x, y, - bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_LINEAR); - GlStateManager.color(fg.getRed() / 255f,fg.getGreen() / 255f, - fg.getBlue() / 255f, fg.getAlpha() / 255f); - Utils.drawTexturedRect(x+paddingUnscaled, y+paddingUnscaled, bigItemSize, bigItemSize, GL11.GL_LINEAR); + bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_NEAREST); - int mouseX = Mouse.getX() * scaledresolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; - int mouseY = scaledresolution.getScaledHeight() - Mouse.getY() * scaledresolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1; + int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth; + int mouseY = Utils.peekGuiScale().getScaledHeight() - Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1; if(mouseX > x && mouseX < x+bigItemSize) { if(mouseY > y && mouseY < y+bigItemSize) { @@ -454,21 +451,21 @@ public class NEUOverlay extends Gui { }; } - private MBGuiGroupHorz createQuickCommandGroup() { + private MBGuiGroupAligned createQuickCommandGroup() { List<MBGuiElement> children = new ArrayList<>(); for(String quickCommand : manager.config.quickCommands.value) { children.add(createQuickCommand(quickCommand)); } - return new MBGuiGroupHorz(children) { + return new MBGuiGroupAligned(children, false) { public int getPadding() { return getPaddingUnscaled()*4; } }; } - private MBGuiGroupHorz createSearchBarGroup() { + private MBGuiGroupAligned createSearchBarGroup() { List<MBGuiElement> children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this)); - return new MBGuiGroupHorz(children) { + return new MBGuiGroupAligned(children, false) { public int getPadding() { return getPaddingUnscaled()*4; } @@ -490,7 +487,7 @@ public class NEUOverlay extends Gui { map.put(createSearchBarGroup(), searchBarAnchor); map.put(createQuickCommandGroup(), quickCommandAnchor); - return new MBGuiGroupFloating(scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), map); + return new MBGuiGroupFloating(Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), map); } public void resetAnchors(boolean onlyIfNull) { @@ -541,6 +538,7 @@ public class NEUOverlay extends Gui { itemPaneOffsetFactor.setValue(1); itemPaneTabOffset.setValue(20); } + if(activeInfoPane != null) activeInfoPane.reset(); } /** @@ -570,6 +568,22 @@ public class NEUOverlay extends Gui { } } + public void mouseInputInv() { + if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { + if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100) { + Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); + if(slot != null) { + ItemStack hover = slot.getStack(); + if(hover != null) { + textField.setText("id:"+manager.getInternalNameForItem(hover)); + itemPaneOpen = true; + updateSearch(); + } + } + } + } + } + /** * Handles the mouse input, cancelling the forge event if a NEU gui element is clicked. */ @@ -578,11 +592,12 @@ public class NEUOverlay extends Gui { return false; } - int width = scaledresolution.getScaledWidth(); - int height = scaledresolution.getScaledHeight(); + Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue()); - int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); - int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; //if(lastMouseX != mouseX || lastMouseY != mouseY) { // millisLastMouseMove = System.currentTimeMillis(); @@ -602,9 +617,36 @@ public class NEUOverlay extends Gui { guiGroup.mouseClick(0, 0, mouseX, mouseY); + if(selectedItemGroup != null) { + int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size()); + if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) { + for(int i=0; i<selectedItemGroup.size(); i++) { + if(mouseX >= selectedX-1+18*i && mouseX <= selectedX+17+18*i) { + JsonObject item = selectedItemGroup.get(i); + if (item != null) { + if(Mouse.getEventButton() == 0) { + manager.showRecipe(item); + } else if(Mouse.getEventButton() == 1) { + showInfo(item); + } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100) { + textField.setText("id:"+item.get("internalname").getAsString()); + updateSearch(); + searchMode = true; + } + } + Utils.pushGuiScale(-1); + return true; + } + } + } + } + //Item selection (right) gui if(mouseX > width*getItemPaneOffsetFactor()) { - if(!Mouse.getEventButtonState()) return true; //End early if the mouse isn't pressed, but still cancel event. + if(!Mouse.getEventButtonState()) { + Utils.pushGuiScale(-1); + return true; //End early if the mouse isn't pressed, but still cancel event. + } AtomicBoolean clickedItem = new AtomicBoolean(false); iterateItemSlots(new ItemSlotConsumer() { @@ -619,7 +661,7 @@ public class NEUOverlay extends Gui { manager.showRecipe(item); } else if(Mouse.getEventButton() == 1) { showInfo(item); - } else if(Mouse.getEventButton() == 2) { + } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100) { textField.setText("id:"+item.get("internalname").getAsString()); updateSearch(); searchMode = true; @@ -637,7 +679,7 @@ public class NEUOverlay extends Gui { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int maxPages = getMaxPages(); - String name = scaledresolution.getScaleFactor()<4?"Page: ":""; + String name = Utils.peekGuiScale().getScaleFactor()<4?"Page: ":""; float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+name + maxPages + "/" + maxPages); float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f; int buttonXSize = (int)Math.min(maxButtonXSize, getSearchBarYSize()*480/160f); @@ -692,47 +734,60 @@ public class NEUOverlay extends Gui { } } } + Utils.pushGuiScale(-1); return true; } - if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { - if(Mouse.getEventButton() == 2) { - Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen); - if(slot != null) { - ItemStack hover = slot.getStack(); - if(hover != null) { - textField.setText("id:"+manager.getInternalNameForItem(hover)); - updateSearch(); - searchMode = true; + //Clicking on "close info pane" button + if(activeInfoPane instanceof SettingsInfoPane) { + Utils.pushGuiScale(2); + + int widthN = Utils.peekGuiScale().getScaledWidth(); + int heightN = Utils.peekGuiScale().getScaledHeight(); + int mouseXN = Mouse.getX() * widthN / Minecraft.getMinecraft().displayWidth; + int mouseYN = heightN - Mouse.getY() * heightN / Minecraft.getMinecraft().displayHeight - 1; + + if(mouseXN > widthN*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseXN < widthN*getInfoPaneOffsetFactor()-getBoxPadding()+8) { + if(mouseYN > getBoxPadding()-8 && mouseYN < getBoxPadding()+8) { + if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up + displayInformationPane(null); + + Utils.pushGuiScale(-1); + Utils.pushGuiScale(-1); return true; } } } - } - //Clicking on "close info pane" button - if(mouseX > width*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseX < width*getInfoPaneOffsetFactor()-getBoxPadding()+8) { - if(mouseY > getBoxPadding()-8 && mouseY < getBoxPadding()+8) { - if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up - displayInformationPane(null); - return true; + Utils.pushGuiScale(-1); + } else { + if(mouseX > width*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseX < width*getInfoPaneOffsetFactor()-getBoxPadding()+8) { + if(mouseY > getBoxPadding()-8 && mouseY < getBoxPadding()+8) { + if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up + displayInformationPane(null); + Utils.pushGuiScale(-1); + return true; + } } } } + if(activeInfoPane != null) { if(mouseX < width*getInfoPaneOffsetFactor()) { activeInfoPane.mouseInput(width, height, mouseX, mouseY, mouseDown); + Utils.pushGuiScale(-1); return true; } else if(Mouse.getEventButton() <= 1 && Mouse.getEventButtonState()) { //Left or right click activeInfoPane.mouseInputOutside(); } } + Utils.pushGuiScale(-1); return false; } public int getPaddingUnscaled() { - int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor(); + int paddingUnscaled = searchBarPadding/Utils.peekGuiScale().getScaleFactor(); if(paddingUnscaled < 1) paddingUnscaled = 1; return paddingUnscaled; @@ -742,7 +797,7 @@ public class NEUOverlay extends Gui { * Returns searchBarXSize, scaled by 0.8 if gui scale == AUTO. */ public int getSearchBarXSize() { - if(scaledresolution.getScaleFactor()==4) return (int)(searchBarXSize*0.8); + if(Utils.peekGuiScale().getScaleFactor()==4) return (int)(searchBarXSize*0.8); return (int)(searchBarXSize); } @@ -767,8 +822,8 @@ public class NEUOverlay extends Gui { * Finds the index of the character inside the search bar that was clicked, used to set the caret. */ public int getClickedIndex(int mouseX, int mouseY) { - int width = scaledresolution.getScaledWidth(); - int height = scaledresolution.getScaledHeight(); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); int xComp = mouseX - (width/2 - getSearchBarXSize()/2 + 5); @@ -852,21 +907,38 @@ public class NEUOverlay extends Gui { itemstack.set(hover); } } else if(!hoverInv) { - int height = scaledresolution.getScaledHeight(); + Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue()); - int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); - int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - iterateItemSlots(new ItemSlotConsumer() { - public void consume(int x, int y, int id) { - if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) { - if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) { - JsonObject json = getSearchedItemPage(id); - if (json != null) internalname.set(json.get("internalname").getAsString()); + if (selectedItemGroup != null) { + int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size()); + + if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) { + for (int i = 0; i < selectedItemGroup.size(); i++) { + if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) { + internalname.set(selectedItemGroup.get(i).get("internalname").getAsString()); } } } - }); + } else { + iterateItemSlots(new ItemSlotConsumer() { + public void consume(int x, int y, int id) { + if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) { + if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) { + JsonObject json = getSearchedItemPage(id); + if (json != null) internalname.set(json.get("internalname").getAsString()); + } + } + } + }); + } + + + Utils.pushGuiScale(-1); } if(internalname.get() != null) { if(itemstack.get() != null) { @@ -988,8 +1060,8 @@ public class NEUOverlay extends Gui { float cost1 = manager.auctionManager.getLowestBin(o1.get("internalname").getAsString()); float cost2 = manager.auctionManager.getLowestBin(o2.get("internalname").getAsString()); - if(cost1 == -1) cost1 = manager.getCraftCost(o1.get("internalname").getAsString()).craftCost; - if(cost2 == -1) cost2 = manager.getCraftCost(o2.get("internalname").getAsString()).craftCost; + if(cost1 == -1) cost1 = manager.auctionManager.getCraftCost(o1.get("internalname").getAsString()).craftCost; + if(cost2 == -1) cost2 = manager.auctionManager.getCraftCost(o2.get("internalname").getAsString()).craftCost; if(cost1 < cost2) return mult; if(cost1 > cost2) return -mult; @@ -1049,12 +1121,16 @@ public class NEUOverlay extends Gui { * Checks whether an item matches the current sort mode. */ public boolean checkMatchesSort(String internalname, JsonObject item) { + if(!manager.config.showVanillaItems.value && item.has("vanilla") && item.get("vanilla").getAsBoolean()) { + return false; + } + if(getSortMode() == SORT_MODE_ALL) { return !internalname.matches(mobRegex); } else if(getSortMode() == SORT_MODE_MOB) { return internalname.matches(mobRegex); } else if(getSortMode() == SORT_MODE_PET) { - return internalname.matches(petRegex); + return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("["); } else if(getSortMode() == SORT_MODE_TOOL) { return checkItemType(item.get("lore").getAsJsonArray(), "SWORD", "BOW", "AXE", "PICKAXE", "FISHING ROD", "WAND", "SHOVEL", "HOE") >= 0; @@ -1074,13 +1150,30 @@ public class NEUOverlay extends Gui { public void updateSearch() { if(searchedItems==null) searchedItems = new TreeSet<>(getItemComparator()); searchedItems.clear(); + searchedItemsSubgroup.clear(); searchedItemsArr = null; redrawItems = true; Set<String> itemsMatch = manager.search(textField.getText(), true); for(String itemname : itemsMatch) { JsonObject item = manager.getItemInformation().get(itemname); if(checkMatchesSort(itemname, item)) { - searchedItems.add(item); + if(item.has("parent") && item.get("parent").isJsonPrimitive()) { + searchedItemsSubgroup + .computeIfAbsent(item.get("parent").getAsString(), k->new HashSet<>()) + .add(item.get("internalname").getAsString()); + } else { + searchedItems.add(item); + } + } + } + out: + for(Map.Entry<String, Set<String>> entry : searchedItemsSubgroup.entrySet()) { + if(searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) { + continue; + } + for(String itemname : entry.getValue()) { + JsonObject item = manager.getItemInformation().get(itemname); + if(item != null) searchedItems.add(item); } } switch(textField.getText().toLowerCase().trim()) { @@ -1097,6 +1190,15 @@ public class NEUOverlay extends Gui { case "ducttapedigger": searchedItems.add(CustomItems.DUCTTAPE); break; + case "thirtyvirus": + searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT")); + break; + case "leocthl": + searchedItems.add(CustomItems.LEOCTHL); + break; + case "spinaxx": + searchedItems.add(CustomItems.SPINAXX); + break; } } @@ -1137,13 +1239,13 @@ public class NEUOverlay extends Gui { } public int getItemBoxXPadding() { - int width = scaledresolution.getScaledWidth(); + int width = Utils.peekGuiScale().getScaledWidth(); return (((int)(width/3*getWidthMult())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2; } public int getBoxPadding() { double panePadding = Math.max(0, Math.min(20, manager.config.panePadding.value)); - return (int)(panePadding*2/scaledresolution.getScaleFactor()+5); + return (int)(panePadding*2/Utils.peekGuiScale().getScaleFactor()+5); } private abstract class ItemSlotConsumer { @@ -1151,7 +1253,7 @@ public class NEUOverlay extends Gui { } public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer) { - int width = scaledresolution.getScaledWidth(); + int width = Utils.peekGuiScale().getScaledWidth(); int itemBoxXPadding = getItemBoxXPadding(); iterateItemSlots(itemSlotConsumer, (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding); } @@ -1162,8 +1264,8 @@ public class NEUOverlay extends Gui { * code duplication issues. */ public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int xStart) { - int width = scaledresolution.getScaledWidth(); - int height = scaledresolution.getScaledHeight(); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); int paneWidth = (int)(width/3*getWidthMult()); int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2; @@ -1184,7 +1286,7 @@ public class NEUOverlay extends Gui { public float getWidthMult() { float scaleFMult = 1; - if(scaledresolution.getScaleFactor()==4) scaleFMult *= 0.9f; + if(Utils.peekGuiScale().getScaleFactor()==4) scaleFMult *= 0.9f; if(manager.auctionManager.customAH.isRenderOverAuctionView()) scaleFMult *= 0.8f; return (float)Math.max(0.5, Math.min(1.5, manager.config.paneWidthMult.value.floatValue()))*scaleFMult; } @@ -1193,7 +1295,7 @@ public class NEUOverlay extends Gui { * Calculates the number of horizontal item slots. */ public int getSlotsXSize() { - int width = scaledresolution.getScaledWidth(); + int width = Utils.peekGuiScale().getScaledWidth(); int paneWidth = (int)(width/3*getWidthMult()); int itemBoxXPadding = (((int)(width-width*getItemPaneOffsetFactor())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2; @@ -1207,7 +1309,7 @@ public class NEUOverlay extends Gui { * Calculates the number of vertical item slots. */ public int getSlotsYSize() { - int height = scaledresolution.getScaledHeight(); + int height = Utils.peekGuiScale().getScaledHeight(); int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2; int yStart = getBoxPadding()+getSearchBarYSize()+itemBoxYPadding; @@ -1222,7 +1324,7 @@ public class NEUOverlay extends Gui { } public int getSearchBarYSize() { - return Math.max(searchBarYSize/scaledresolution.getScaleFactor(), ITEM_SIZE); + return Math.max(searchBarYSize/Utils.peekGuiScale().getScaleFactor(), ITEM_SIZE); } /** @@ -1245,10 +1347,11 @@ public class NEUOverlay extends Gui { int rightPressed = 0; if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) { - int height = scaledresolution.getScaledHeight(); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); - int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); - int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; if(mouseY >= top && mouseY <= top+ySize) { int leftPrev = leftSide-1; @@ -1388,7 +1491,12 @@ public class NEUOverlay extends Gui { * Renders black squares over the inventory to indicate items that do not match a specific search. (When searchMode * is enabled) */ - public void renderOverlay(int mouseX, int mouseY) { + public void renderOverlay() { + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + if(searchMode && textField.getText().length() > 0) { if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { GuiContainer inv = (GuiContainer) Minecraft.getMinecraft().currentScreen; @@ -1480,16 +1588,16 @@ public class NEUOverlay extends Gui { if(blurShaderHorz == null) { try { - blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); + blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), + "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); } catch(Exception e) { } } if(blurShaderVert == null) { try { - blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - blurOutputHorz, blurOutputVert); + blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), + "blur", blurOutputHorz, blurOutputVert); blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); } catch(Exception e) { } @@ -1517,7 +1625,6 @@ public class NEUOverlay extends Gui { public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) { if(manager.config.bgBlurFactor.value <= 0 || !OpenGlHelper.isFramebufferEnabled()) return; - int f = scaledresolution.getScaleFactor(); float uMin = x/(float)width; float uMax = (x+blurWidth)/(float)width; float vMin = y/(float)height; @@ -1532,11 +1639,11 @@ public class NEUOverlay extends Gui { } public void updateGuiGroupSize() { - ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledresolution.getScaledWidth(); - int height = scaledresolution.getScaledHeight(); + Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue()); + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); - if(lastScreenWidth != width || lastScreenHeight != height || scaledresolution.getScaleFactor() != lastScale) { + if(lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) { guiGroup.width = width; guiGroup.height = height; @@ -1545,28 +1652,48 @@ public class NEUOverlay extends Gui { lastScreenWidth = width; lastScreenHeight = height; - lastScale = scaledresolution.getScaleFactor(); + lastScale = Utils.peekGuiScale().getScaleFactor(); } + + Utils.pushGuiScale(-1); } int guiScaleLast = 0; + private boolean showVanillaLast = false; /** * Renders the search bar, quick commands, item selection (right) and item info (left) gui elements. */ - public void render(int mouseX, int mouseY, boolean hoverInv) { + public void render(boolean hoverInv) { if(disabled) { return; } FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledresolution.getScaledWidth(); - int height = scaledresolution.getScaledHeight(); + + Utils.resetGuiScale(); + Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue()); + + int width = Utils.peekGuiScale().getScaledWidth(); + int height = Utils.peekGuiScale().getScaledHeight(); + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + if(showVanillaLast != manager.config.showVanillaItems.value) { + showVanillaLast = manager.config.showVanillaItems.value; + updateSearch(); + } + + if(textField.getText().toLowerCase().contains("bald")) { + Minecraft.getMinecraft().getTextureManager().bindTexture(SUPERGEHEIMNISVERMOGEN); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect((width-64)/2f, (height-64)/2f-114, 64, 64, GL11.GL_LINEAR); + GlStateManager.bindTexture(0); + } updateGuiGroupSize(); - if(guiScaleLast != scaledresolution.getScaleFactor()) { - guiScaleLast = scaledresolution.getScaleFactor(); + if(guiScaleLast != Utils.peekGuiScale().getScaleFactor()) { + guiScaleLast = Utils.peekGuiScale().getScaleFactor(); redrawItems = true; } @@ -1580,15 +1707,13 @@ public class NEUOverlay extends Gui { yaw++; yaw %= 360; - manager.updatePrices(); - - int opacity = Math.min(255, Math.max(0, manager.config.bgOpacity.value.intValue())); - bg = new Color((bg.getRGB() & 0x00ffffff) | opacity << 24, true); + bg = new Color(SpecialColour.specialToChromaRGB(manager.config.paneBackgroundColour.value), true); + fg = new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value)); + Color fgCustomOpacity = new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true); - opacity = Math.min(255, Math.max(0, manager.config.fgOpacity.value.intValue())); - Color fgCustomOpacity = new Color((fg.getRGB() & 0x00ffffff) | opacity << 24, true); - Color fgFavourite = new Color(limCol(fg.getRed()+20), limCol(fg.getGreen()+10), limCol(fg.getBlue()-10), opacity); - Color fgFavourite2 = new Color(limCol(fg.getRed()+100), limCol(fg.getGreen()+50), limCol(fg.getBlue()-50), opacity); + Color fgFavourite2 = new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true); + Color fgFavourite = new Color((int)(fgFavourite2.getRed()*0.8f), (int)(fgFavourite2.getGreen()*0.8f), + (int)(fgFavourite2.getBlue()*0.8f), fgFavourite2.getAlpha()); if(itemPaneOpen) { if(itemPaneTabOffset.getValue() == 0) { @@ -1633,21 +1758,16 @@ public class NEUOverlay extends Gui { int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding(); //Tab - Minecraft.getMinecraft().getTextureManager().bindTexture(itemPaneTabArrow); - GlStateManager.color(1f, 1f, 1f, 0.3f); - Utils.drawTexturedRect(width-itemPaneTabOffset.getValue(), height/2 - 50, 20, 100); - GlStateManager.bindTexture(0); + if(!manager.config.disableItemTabOpen.value) { + Minecraft.getMinecraft().getTextureManager().bindTexture(itemPaneTabArrow); + GlStateManager.color(1f, 1f, 1f, 0.3f); + Utils.drawTexturedRect(width-itemPaneTabOffset.getValue()*64/20f, height/2f - 32, 64, 64); + GlStateManager.bindTexture(0); - if(mouseX > width-itemPaneTabOffset.getValue() && mouseY > height/2 - 50 - && mouseY < height/2 + 50) { - if(!hoveringItemPaneToggle) { - if(!manager.config.disableItemTabOpen.value) { - itemPaneOpen = !itemPaneOpen; - |
