aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
diff options
context:
space:
mode:
authorMoulberry <jjenour@student.unimelb.edu.au>2022-03-03 11:03:58 +0800
committerGitHub <noreply@github.com>2022-03-03 11:03:58 +0800
commit7c6d37b2eb758a13b342b906f0aef88b940bc52a (patch)
tree9602a014425b859e3aba98f31f93d6de04521356 /src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
parentdb59eba3fd9121c7c0a88363994876c5b582c08c (diff)
downloadnotenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.tar.gz
notenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.tar.bz2
notenoughupdates-7c6d37b2eb758a13b342b906f0aef88b940bc52a.zip
Merge pull request #248 from NotEnoughUpdates/master
NEU 2.1 🙂
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java5095
1 files changed, 2816 insertions, 2279 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 080353a7..d1bfed14 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -8,18 +8,30 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
-import io.github.moulberry.notenoughupdates.infopanes.*;
+import io.github.moulberry.notenoughupdates.infopanes.DevInfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.InfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.TextInfoPane;
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.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
+import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
-import io.github.moulberry.notenoughupdates.util.*;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.LerpingFloat;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.entity.RenderManager;
@@ -31,6 +43,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -42,17 +56,16 @@ import net.minecraft.util.Matrix4f;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.ClientCommandHandler;
-import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
-import java.awt.*;
+import java.awt.Color;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -61,2276 +74,2800 @@ import java.util.concurrent.atomic.AtomicReference;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class NEUOverlay extends Gui {
-
- private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation("notenoughupdates:supersecretassets/bald.png");
- private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png");
- private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png");
-
- private NEUManager manager;
-
- private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
- private String petRegex = ".*?;[0-5]$";
-
- private ResourceLocation[] sortIcons = new ResourceLocation[] {
- sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
- };
- private ResourceLocation[] sortIconsActive = new ResourceLocation[] {
- sort_all_active, sort_mob_active, sort_pet_active, sort_tool_active, sort_armor_active, sort_accessory_active
- };
-
- private ResourceLocation[] orderIcons = new ResourceLocation[] {
- order_alphabetical, order_rarity, order_value
- };
- private ResourceLocation[] orderIconsActive = new ResourceLocation[] {
- order_alphabetical_active, order_rarity_active, order_value_active
- };
-
- //Various constants used for GUI structure
- private final int searchBarYOffset = 10;
- private final int searchBarPadding = 2;
-
- private float oldWidthMult = 0;
-
- public static final int ITEM_PADDING = 4;
- public static final int ITEM_SIZE = 16;
-
- private Color bg = new Color(90, 90, 140, 50);
- private Color fg = new Color(100,100,100, 255);
-
- private InfoPane activeInfoPane = null;
-
- private TreeSet<JsonObject> searchedItems = null;
- private final List<JsonObject> searchedItemsArr = new ArrayList<>();
-
- private HashMap<String, List<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 int page = 0;
-
- private LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
- private LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
- private LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0);
-
- public boolean searchMode = false;
- private long millisLastLeftClick = 0;
- private long millisLastMouseMove = 0;
- private int lastMouseX = 0;
- private int lastMouseY = 0;
-
- public static final int overlayColourDark = new Color(0, 0, 0, 120).getRGB();
- public static final int overlayColourLight = new Color(255, 255, 255, 120).getRGB();
-
- boolean mouseDown = false;
-
- private boolean redrawItems = false;
-
- private boolean searchBarHasFocus = false;
- private GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
-
- private static final int COMPARE_MODE_ALPHABETICAL = 0;
- private static final int COMPARE_MODE_RARITY = 1;
- private static final int COMPARE_MODE_VALUE = 2;
-
- private static final int SORT_MODE_ALL = 0;
- private static final int SORT_MODE_MOB = 1;
- private static final int SORT_MODE_PET = 2;
- private static final int SORT_MODE_TOOL = 3;
- private static final int SORT_MODE_ARMOR = 4;
- private static final int SORT_MODE_ACCESSORY = 5;
-
- private boolean disabled = false;
-
- private int lastScreenWidth;
- private int lastScreenHeight;
- private int lastScale;
-
- private List<String> textToDisplay = null;
-
- public MBGuiGroupFloating guiGroup = null;
-
- public NEUOverlay(NEUManager manager) {
- this.manager = manager;
- textField.setFocused(true);
- textField.setCanLoseFocus(false);
-
- guiGroup = createGuiGroup();
- }
-
- private MBGuiElement createSearchBar() {
- return new MBGuiElement() {
- public int getWidth() {
- int paddingUnscaled = getPaddingUnscaled();
-
- return getSearchBarXSize() + 2*paddingUnscaled;
- }
-
- public int getHeight() {
- int paddingUnscaled = getPaddingUnscaled();
-
- return getSearchBarYSize() + 2*paddingUnscaled;
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- return;
- }
- if(Mouse.getEventButtonState()) {
- setSearchBarFocus(true);
- if(Mouse.getEventButton() == 1) { //Right mouse button down
- textField.setText("");
- updateSearch();
- } else {
- if(System.currentTimeMillis() - millisLastLeftClick < 300) {
- searchMode = !searchMode;
- if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
- NEUEventListener.displayNotification(Lists.newArrayList(
- "\u00a7eSearch Highlight",
- "\u00a77In this mode NEU will gray out non matching items in",
- "\u00a77your inventory or chests.",
- "\u00a77This allows you easily find items as the item will stand out.",
- "\u00a77To toggle this please double click on the search bar in your inventory.",
- "\u00a77",
- "\u00a77Press X on your keyboard to close this notifcation"), true, true);
- NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = false;
-
- }
- }
- textField.setCursorPosition(getClickedIndex(mouseX, mouseY));
- millisLastLeftClick = System.currentTimeMillis();
- }
- }
- }
-
- @Override
- public void mouseClickOutside() {
- setSearchBarFocus(false);
- }
-
- @Override
- public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- return;
- }
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int paddingUnscaled = getPaddingUnscaled();
-
- GlStateManager.color(1, 1, 1, 1);
- if(searchMode) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR_GOLD);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR);
- }
-
- int w = getWidth();
- int h = getHeight();
-
- for(int yIndex=0; yIndex<=2; yIndex++) {
- for(int xIndex=0; xIndex<=2; xIndex++) {
- float uMin = 0;
- float uMax = 4/20f;
- int partX = (int)x;
- int partW = 4;
- if(xIndex == 1) {
- partX += 4;
- uMin = 4/20f;
- uMax = 16/20f;
- partW = w-8;
- } else if(xIndex == 2) {
- partX += w-4;
- uMin = 16/20f;
- uMax = 20/20f;
- }
-
- float vMin = 0;
- float vMax = 4/20f;
- int partY = (int)y;
- int partH = 4;
- if(yIndex == 1) {
- partY += 4;
- vMin = 4/20f;
- vMax = 16/20f;
- partH = h-8;
- } else if(yIndex == 2) {
- partY += h-4;
- vMin = 16/20f;
- vMax = 20/20f;
- }
-
- Utils.drawTexturedRect(partX, partY, partW, partH, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
- }
- }
-
- //Search bar text
- fr.drawString(textField.getText(), (int)x + 5,
- (int) y-4 + getHeight()/2, Color.WHITE.getRGB());
-
- //Determines position of cursor. Cursor blinks on and off every 500ms.
- if(searchBarHasFocus && System.currentTimeMillis()%1000>500) {
- String textBeforeCursor = textField.getText().substring(0, textField.getCursorPosition());
- int textBeforeCursorWidth = fr.getStringWidth(textBeforeCursor);
- drawRect((int)x + 5 + textBeforeCursorWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeCursorWidth+1,
- (int)y-4+9 + getHeight()/2, Color.WHITE.getRGB());
- }
-
- String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
- int selectionWidth = fr.getStringWidth(selectedText);
-
- int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd());
- String textBeforeSelection = textField.getText().substring(0, leftIndex);
- int textBeforeSelectionWidth = fr.getStringWidth(textBeforeSelection);
-
- drawRect((int)x + 5 + textBeforeSelectionWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeSelectionWidth + selectionWidth,
- (int)y-4+9 + getHeight()/2, Color.LIGHT_GRAY.getRGB());
-
- fr.drawString(selectedText,
- (int)x + 5 + textBeforeSelectionWidth,
- (int)y-4 + getHeight()/2, Color.BLACK.getRGB());
- }
-
- }
-
- @Override
- public void recalculate() {
- }
- };
- }
-
- private MBGuiElement createSettingsButton(NEUOverlay overlay) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
- return;
- }
- if(Mouse.getEventButtonState()) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- int paddingUnscaled = getPaddingUnscaled();
- int searchYSize = getSearchBarYSize();
-
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
- return;
- }
- 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,
- searchYSize, searchYSize);
-
- GlStateManager.bindTexture(0);
- }
- };
- }
-
- private MBGuiElement createHelpButton(NEUOverlay overlay) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton){
- return;
- }
- if(Mouse.getEventButtonState()) {
- //displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
- // "https://moulberry.github.io/files/neu_help.html"));
- //Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neuhelp");
- Utils.playPressSound();
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- int paddingUnscaled = getPaddingUnscaled();
- int searchYSize = getSearchBarYSize();
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
- return;
- }
-
- 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());
- GlStateManager.bindTexture(0);
-
- }
- };
- }
-
- private MBGuiElement createQuickCommand(String quickCommandStr) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
-
- if((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
- (NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && !Mouse.getEventButtonState() && Mouse.getEventButton() != -1)) {
- if(quickCommandStr.contains(":")) {
- String command = quickCommandStr.split(":")[0].trim();
- if(command.startsWith("/")) {
- NotEnoughUpdates.INSTANCE.sendChatMessage(command);
- } else {
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/"+command);
- }
- Utils.playPressSound();
- }
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
-
- int paddingUnscaled = getPaddingUnscaled();
- int bigItemSize = getSearchBarYSize();
-
- String[] quickCommandStrSplit = quickCommandStr.split(":");
- if(quickCommandStrSplit.length!=3) {
- return;
- }
- String display = quickCommandStrSplit[2];
- ItemStack render = null;
- float extraScale = 1;
- if(display.length() > 20) { //Custom head
- render = new ItemStack(Items.skull, 1, 3);
- NBTTagCompound nbt = new NBTTagCompound();
- NBTTagCompound skullOwner = new NBTTagCompound();
- NBTTagCompound properties = new NBTTagCompound();
- NBTTagList textures = new NBTTagList();
- NBTTagCompound textures_0 = new NBTTagCompound();
-
- String uuid = UUID.nameUUIDFromBytes(display.getBytes()).toString();
- skullOwner.setString("Id", uuid);
- skullOwner.setString("Name", uuid);
-
- textures_0.setString("Value", display);
- textures.appendTag(textures_0);
-
- properties.setTag("textures", textures);
- skullOwner.setTag("Properties", properties);
- nbt.setTag("SkullOwner", skullOwner);
- render.setTagCompound(nbt);
-
- extraScale = 1.3f;
- } else if(manager.getItemInformation().containsKey(display)) {
- render = manager.jsonToStack(manager.getItemInformation().get(display), true, true);
- } else {
- Item item = Item.itemRegistry.getObject(new ResourceLocation(display.toLowerCase()));
- if(item != null) {
- render = new ItemStack(item);
- }
- }
- if(render != null) {
- NBTTagCompound tag = render.getTagCompound() != null ? render.getTagCompound() : new NBTTagCompound();
- tag.setString("qc_id", quickCommandStrSplit[0].toLowerCase().trim());
- render.setTagCompound(tag);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x, y,
- bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_NEAREST);
-
- 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) {
- textToDisplay = new ArrayList<>();
- textToDisplay.add(EnumChatFormatting.GRAY+quickCommandStrSplit[1]);
- }
- }
-
- GlStateManager.enableDepth();
- float itemScale = bigItemSize/(float)ITEM_SIZE*extraScale;
- GlStateManager.pushMatrix();
- GlStateManager.scale(itemScale, itemScale, 1);
- GlStateManager.translate((x-(extraScale-1)*bigItemSize/2+paddingUnscaled) /itemScale,
- (y-(extraScale-1)*bigItemSize/2+paddingUnscaled)/itemScale, 0f);
- Utils.drawItemStack(render, 0, 0);
- GlStateManager.popMatrix();
- }
- }
- };
- }
-
- private MBGuiGroupAligned createQuickCommandGroup() {
- List<MBGuiElement> children = new ArrayList<>();
- for(String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
- children.add(createQuickCommand(quickCommand));
- }
- return new MBGuiGroupAligned(children, false) {
- public int getPadding() {
- return getPaddingUnscaled()*4;
- }
- };
- }
-
- private MBGuiGroupAligned createSearchBarGroup() {
- List<MBGuiElement> children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this));
- return new MBGuiGroupAligned(children, false) {
- public int getPadding() {
- return getPaddingUnscaled()*4;
- }
- };
- }
-
- private MBGuiGroupFloating createGuiGroup() {
- LinkedHashMap<MBGuiElement, MBAnchorPoint> map = new LinkedHashMap<>();
-
- MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
- MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
-
- searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
-
- map.put(createSearchBarGroup(), searchBarAnchor);
- map.put(createQuickCommandGroup(), quickCommandAnchor);
-
- return new MBGuiGroupFloating(Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), map);
- }
-
- public void resetAnchors(boolean onlyIfNull) {
- MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
- MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
-
- if(onlyIfNull) {
- searchBarAnchor = searchBarAnchor != null ? null :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? null :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
- } else {
- searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
- }
-
-
- int index = 0;
- Set<MBGuiElement> set = new LinkedHashSet<>(guiGroup.getChildrenMap().keySet());
- for(MBGuiElement element : set) {
- switch(index) {
- case 0:
- if(searchBarAnchor == null) continue;
- guiGroup.getChildrenMap().get(element).anchorPoint = searchBarAnchor.anchorPoint;
- guiGroup.getChildrenMap().get(element).offset = searchBarAnchor.offset;
- break;
- case 1:
- if(quickCommandAnchor == null) continue;
- guiGroup.getChildrenMap().get(element).anchorPoint = quickCommandAnchor.anchorPoint;
- guiGroup.getChildrenMap().get(element).offset = quickCommandAnchor.offset;
- break;
- }
- index++;
- }
- }
-
- /**
- * Disables searchBarFocus and resets the item pane position. Called whenever NEUOverlay is opened.
- */
- public void reset() {
- searchBarHasFocus = false;
- if(!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
- itemPaneOpen = false;
- itemPaneOffsetFactor.setValue(1);
- itemPaneTabOffset.setValue(20);
- }
- if(activeInfoPane != null) activeInfoPane.reset();
- guiGroup.recalculate();
- }
-
- /**
- * Calls #displayInformationPane with a HTMLInfoPane created from item.info and item.infoType.
- */
- public void showInfo(JsonObject item) {
- if(item.has("info") && item.has("infoType")) {
- JsonArray lore = item.get("info").getAsJsonArray();
- String[] loreA = new String[lore.size()];
- for (int i = 0; i < lore.size(); i++) loreA[i] = lore.get(i).getAsString();
- String loreS = StringUtils.join(loreA, "\n");
-
- String internalname = item.get("internalname").getAsString();
- String name = item.get("displayname").getAsString();
- switch(item.get("infoType").getAsString()) {
- case "WIKI_URL":
- displayInformationPane(HTMLInfoPane.createFromWikiUrl(this, manager, name, loreS));
- return;
- case "WIKI":
- displayInformationPane(HTMLInfoPane.createFromWiki(this, manager, name, internalname, loreS));
- return;
- case "HTML":
- displayInformationPane(new HTMLInfoPane(this, manager, name, internalname, loreS));
- return;
- }
- displayInformationPane(new TextInfoPane(this, manager, name, loreS));
- }
- }
-
- public void mouseInputInv() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
- if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- 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.
- */
- public boolean mouseInput() {
- if(disabled) {
- return false;
- }
-
- Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
-
- 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();
- //}
-
- lastMouseX = mouseX;
- lastMouseY = mouseY;
-
- if(Mouse.getEventButtonState()) {
- mouseDown = true;
- } else if(Mouse.getEventButton() != -1) {
- mouseDown = false;
- }
-
- //Unfocuses the search bar by default. Search bar is focused if the click is on the bar itself.
- if(Mouse.getEventButtonState()) setSearchBarFocus(false);
-
- 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 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- 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()) {
- 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() {
- 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) {
- clickedItem.set(true);
-
- JsonObject item = getSearchedItemPage(id);
- 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 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+item.get("internalname").getAsString());
- updateSearch();
- searchMode = true;
- }
- }
- }
- }
- }
- });
- if(!clickedItem.get()) {
- int paneWidth = (int)(width/3*getWidthMult());
- int leftSide = (int)(width*getItemPaneOffsetFactor());
- int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding();
- leftSide = leftSide+getBoxPadding()+getItemBoxXPadding();
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int maxPages = getMaxPages();
- 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);
- int ySize = (int)(buttonXSize/480f*160);
- int yOffset = (int)((getSearchBarYSize()-ySize)/2f);
- int top = getBoxPadding()+yOffset;
-
- if(mouseY >= top && mouseY <= top+ySize) {
- int leftPrev = leftSide-1;
- if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button
- setPage(page-1);
- Utils.playPressSound();
- }
- int leftNext = rightSide+1-buttonXSize;
- if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button
- setPage(page+1);
- Utils.playPressSound();
- }
- }
-
- float sortIconsMinX = (sortIcons.length+orderIcons.length)*(ITEM_SIZE+ITEM_PADDING)+ITEM_SIZE;
- float availableX = rightSide-leftSide;
- float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
-
- int scaledITEM_SIZE = (int)(ITEM_SIZE*sortOrderScaleFactor);
- int scaledItemPaddedSize = (int)((ITEM_SIZE+ITEM_PADDING)*sortOrderScaleFactor);
- int iconTop = height-getBoxPadding()-(ITEM_SIZE+scaledITEM_SIZE)/2-1;
-
- if(mouseY >= iconTop && mouseY <= iconTop+scaledITEM_SIZE) {
- for(int i=0; i<orderIcons.length; i++) {
- int orderIconX = leftSide+i*scaledItemPaddedSize;
- if(mouseX >= orderIconX && mouseX <= orderIconX+scaledITEM_SIZE) {
- if(Mouse.getEventButton() == 0) {
- NotEnoughUpdates.INSTANCE.config.hidden.compareMode = i;
- updateSearch();
- Utils.playPressSound();
- } else if(Mouse.getEventButton() == 1) {
- NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.set(i,
- !NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.get(i));
- updateSearch();
- Utils.playPressSound();
- }
- }