aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui
diff options
context:
space:
mode:
authorohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
committerohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
commiteeb5c45d71997cb259fc35330490a19db7865603 (patch)
tree65771b27ed837896fa3140dec1af78306accebcd /src/main/java/io/github/moulberry/notenoughupdates/miscgui
parent4d9e538ced80728bca74491698347333f515bfcc (diff)
parent1b172089ce502803f7644611afd618ce00dcb860 (diff)
downloadnotenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.gz
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.bz2
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.zip
Merge branch 'Moulberry:master' into master
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java31
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java92
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java10
4 files changed, 137 insertions, 14 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
index 73ab69c9..df13b42a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
@@ -1,9 +1,13 @@
package io.github.moulberry.notenoughupdates.miscgui;
import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -29,16 +33,14 @@ public class GuiEnchantColour extends GuiScreen {
private final int xSize = 217;
private int ySize = 0;
- private List<String> getEnchantColours() {
- return NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
- }
-
public static final Splitter splitter = Splitter.on(":").limit(5);
private HashMap<Integer, String> comparators = new HashMap<>();
private HashMap<Integer, String> modifiers = new HashMap<>();
private List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
+ private List<String> enchantNamesPretty = null;
+
private LerpingInteger scroll = new LerpingInteger(0, 100);
public static int BOLD_MODIFIER = 0b1;
@@ -47,6 +49,27 @@ public class GuiEnchantColour extends GuiScreen {
public static int UNDERLINE_MODIFIER = 0b1000;
public static int STRIKETHROUGH_MODIFIER = 0b10000;
+ private List<String> getEnchantNamesPretty() {
+ if(enchantNamesPretty == null) {
+ JsonObject enchantsJson = Constants.ENCHANTS;
+ if(!enchantsJson.has("enchants_pretty")) {
+ return Lists.newArrayList("ERROR");
+ } else {
+ JsonArray pretty = enchantsJson.getAsJsonArray("enchants_pretty");
+
+ enchantNamesPretty = new ArrayList<>();
+ for(int i=0; i<pretty.size(); i++) {
+ enchantNamesPretty.add(pretty.get(i).getAsString());
+ }
+ }
+ }
+ return enchantNamesPretty;
+ }
+
+ private List<String> getEnchantColours() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
+ }
+
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
index 166e6ba2..21d1018d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
@@ -1,18 +1,23 @@
package io.github.moulberry.notenoughupdates.miscgui;
+import com.google.common.collect.Lists;
import io.github.moulberry.notenoughupdates.core.*;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
+import io.github.moulberry.notenoughupdates.util.GuiTextures;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -21,6 +26,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.*;
import java.net.URL;
+import java.util.List;
public class GuiItemCustomize extends GuiScreen {
@@ -28,7 +34,7 @@ public class GuiItemCustomize extends GuiScreen {
private final ItemStack stack;
private final String itemUUID;
- private final GuiElementTextField textFieldRename = new GuiElementTextField("", 178, 20, GuiElementTextField.COLOUR);
+ private final GuiElementTextField textFieldRename = new GuiElementTextField("", 158, 20, GuiElementTextField.COLOUR);
private final GuiElementBoolean enchantGlintButton;
private int renderHeight = 0;
@@ -108,6 +114,25 @@ public class GuiItemCustomize extends GuiScreen {
if(!this.textFieldRename.getText().isEmpty()) {
data.customName = this.textFieldRename.getText();
+
+ NBTTagCompound stackTagCompound = stack.getTagCompound();
+ if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) {
+ NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display");
+
+ if (nbttagcompound.hasKey("Name", 8)) {
+ String name = nbttagcompound.getString("Name");
+ char[] chars = name.toCharArray();
+
+ int i;
+ for(i=0; i<chars.length; i+=2) {
+ if(chars[i] != '\u00a7'){
+ break;
+ }
+ }
+
+ data.customNamePrefix = name.substring(0, i);
+ }
+ }
}
ItemCustomizeManager.putItemData(itemUUID, data);
@@ -129,13 +154,15 @@ public class GuiItemCustomize extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
+ List<String> tooltipToDisplay = null;
+
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int xCenter = scaledResolution.getScaledWidth()/2;
int yTopStart = (scaledResolution.getScaledHeight()-renderHeight)/2;
int yTop = yTopStart;
- RenderUtils.drawFloatingRectDark(xCenter-100, yTop-9, 200, renderHeight);
+ RenderUtils.drawFloatingRectDark(xCenter-100, yTop-9, 200, renderHeight+11);
RenderUtils.drawFloatingRectDark(xCenter-90, yTop-5, 180, 14);
Utils.renderShadowedString("\u00a75\u00a7lNEU Item Customizer", xCenter, yTop-1, 180);
@@ -143,14 +170,61 @@ public class GuiItemCustomize extends GuiScreen {
yTop += 14;
if(!textFieldRename.getFocus() && textFieldRename.getText().isEmpty()) {
- textFieldRename.setOptions(0);
+ textFieldRename.setOptions(GuiElementTextField.SCISSOR_TEXT);
textFieldRename.setPrependText("\u00a77Enter Custom Name...");
} else {
- textFieldRename.setOptions(GuiElementTextField.COLOUR);
+ textFieldRename.setOptions(GuiElementTextField.COLOUR | GuiElementTextField.SCISSOR_TEXT);
textFieldRename.setPrependText("");
}
- textFieldRename.render(xCenter-textFieldRename.getWidth()/2, yTop);
+ if(!textFieldRename.getFocus()) {
+ textFieldRename.setSize(158, 20);
+ } else {
+ int textSize = fontRendererObj.getStringWidth(textFieldRename.getTextDisplay())+10;
+ textFieldRename.setSize(Math.max(textSize, 158), 20);
+ }
+
+ textFieldRename.render(xCenter-textFieldRename.getWidth()/2-10, yTop);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help);
+ GlStateManager.color(1, 1, 1, 1);
+ int helpX = xCenter+textFieldRename.getWidth()/2-10;
+ Utils.drawTexturedRect(helpX, yTop, 20, 20, GL11.GL_LINEAR);
+
+ if(mouseX >= helpX && mouseX <= helpX+20 && mouseY >= yTop && mouseY <= yTop+20) {
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.AQUA+"Set a custom name for the item",
+ EnumChatFormatting.GREEN+"",
+ EnumChatFormatting.GREEN+"Type \"&&\" to use colour codes",
+ EnumChatFormatting.GREEN+"Type \"**\" for \u272A",
+ EnumChatFormatting.GREEN+"",
+ EnumChatFormatting.GREEN+"Available colour codes:",
+ Utils.chromaString("\u00B6z = Chroma"),
+ EnumChatFormatting.DARK_BLUE+"\u00B61 = Dark Blue",
+ EnumChatFormatting.DARK_GREEN+"\u00B62 = Dark Green",
+ EnumChatFormatting.DARK_AQUA+"\u00B63 = Dark Aqua",
+ EnumChatFormatting.DARK_RED+"\u00B64 = Dark Red",
+ EnumChatFormatting.DARK_PURPLE+"\u00B65 = Dark Purple",
+ EnumChatFormatting.GOLD+"\u00B66 = Gold",
+ EnumChatFormatting.GRAY+"\u00B67 = Gray",
+ EnumChatFormatting.DARK_GRAY+"\u00B68 = Dark Gray",
+ EnumChatFormatting.BLUE+"\u00B69 = Blue",
+ EnumChatFormatting.GREEN+"\u00B6a = Green",
+ EnumChatFormatting.AQUA+"\u00B6b = Aqua",
+ EnumChatFormatting.RED+"\u00B6c = Red",
+ EnumChatFormatting.LIGHT_PURPLE+"\u00B6d = Purple",
+ EnumChatFormatting.YELLOW+"\u00B6e = Yellow",
+ EnumChatFormatting.WHITE+"\u00B6f = White",
+ "",
+ EnumChatFormatting.GREEN+"Available formatting codes:",
+ EnumChatFormatting.GRAY+"\u00B6k = "+EnumChatFormatting.OBFUSCATED+"Obfuscated",
+ EnumChatFormatting.GRAY+"\u00B6l = "+EnumChatFormatting.BOLD+"Bold",
+ EnumChatFormatting.GRAY+"\u00B6m = "+EnumChatFormatting.STRIKETHROUGH+"Strikethrough",
+ EnumChatFormatting.GRAY+"\u00B6n = "+EnumChatFormatting.UNDERLINE+"Underline",
+ EnumChatFormatting.GRAY+"\u00B6o = "+EnumChatFormatting.ITALIC+"Italic"
+ );
+ }
+
yTop += 25;
RenderUtils.drawFloatingRectDark(xCenter-90, yTop, 180, 110);
@@ -246,6 +320,10 @@ public class GuiItemCustomize extends GuiScreen {
editor.render();
}
+ if(tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fontRendererObj);
+ }
+
super.drawScreen(mouseX, mouseY, partialTicks);
}
@@ -268,6 +346,8 @@ public class GuiItemCustomize extends GuiScreen {
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ Keyboard.enableRepeatEvents(true);
+
if(textFieldRename.getFocus()) {
if(keyCode == Keyboard.KEY_ESCAPE) {
textFieldRename.setFocus(false);
@@ -313,7 +393,7 @@ public class GuiItemCustomize extends GuiScreen {
int xCenter = scaledResolution.getScaledWidth()/2;
int yTop = (scaledResolution.getScaledHeight()-renderHeight)/2;
- if(mouseX >= xCenter-textFieldRename.getWidth()/2 && mouseX <= xCenter+textFieldRename.getWidth()/2 &&
+ if(mouseX >= xCenter-textFieldRename.getWidth()/2-10 && mouseX <= xCenter+textFieldRename.getWidth()/2-10 &&
mouseY >= yTop+14 && mouseY <= yTop+14+textFieldRename.getHeight()) {
textFieldRename.mouseClicked(mouseX, mouseY, mouseButton);
} else {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
index 010dc3e2..32a7c76a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
@@ -39,7 +39,6 @@ public class InventoryStorageSelector {
return false;
}
if(Minecraft.getMinecraft().currentScreen != null) {
- isOverridingSlot = false;
return false;
}
if(Minecraft.getMinecraft().thePlayer == null) {
@@ -58,6 +57,9 @@ public class InventoryStorageSelector {
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
+ if(Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
selectedIndex--;
@@ -107,12 +109,18 @@ public class InventoryStorageSelector {
if(Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
isOverridingSlot = false;
}
+ if(Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
- if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) {
+ Minecraft.getMinecraft().thePlayer.inventory.currentItem = 0;
+ isOverridingSlot = true;
+ } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
selectedIndex--;
int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
@@ -156,6 +164,9 @@ public class InventoryStorageSelector {
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return resultantSlot;
}
+ if(Minecraft.getMinecraft().currentScreen != null) {
+ return resultantSlot;
+ }
int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
if(isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
@@ -219,6 +230,9 @@ public class InventoryStorageSelector {
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
+ if(Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
if(selectedIndex > max) selectedIndex = max;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
index f22ed9ae..a59131ea 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -1008,7 +1008,13 @@ public class StorageOverlay extends GuiElement {
@Override
public boolean keyboardInput() {
if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
+ clearSearch();
+ return false;
+ }
+ if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
+ return false;
+ }
+ if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
return false;
}
@@ -1021,6 +1027,6 @@ public class StorageOverlay extends GuiElement {
}
}
- return false;
+ return true;
}
}