aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java
diff options
context:
space:
mode:
authorLulonaut <67191924+Lulonaut@users.noreply.github.com>2022-03-03 04:05:45 +0100
committerGitHub <noreply@github.com>2022-03-02 22:05:45 -0500
commitd44f33636eb301ff029bf41d7f1decb3340efb54 (patch)
treebbb78767f035222212b006207255a5dada9bdff8 /src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java
parentdb59eba3fd9121c7c0a88363994876c5b582c08c (diff)
downloadnotenoughupdates-d44f33636eb301ff029bf41d7f1decb3340efb54.tar.gz
notenoughupdates-d44f33636eb301ff029bf41d7f1decb3340efb54.tar.bz2
notenoughupdates-d44f33636eb301ff029bf41d7f1decb3340efb54.zip
NeuEventListener changes and dead code removal (#88)
* hide Hypixel reforge stats * unused import? * better comments * 2.1.md 🙂 * 2.1.md 🙂 * minor cleanup * api * remove collectionLog and morus and cape.png * remove FancyPortals and panorama dev cmd Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java
new file mode 100644
index 00000000..492c1dd7
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java
@@ -0,0 +1,112 @@
+package io.github.moulberry.notenoughupdates.util;
+
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.ContainerChest;
+
+import java.util.List;
+
+public class NotificationHandler {
+ public static List<String> notificationLines = null;
+ public static boolean showNotificationOverInv = false;
+ public static long notificationDisplayMillis = 0;
+
+ public static void displayNotification(List<String> lines, boolean showForever) {
+ displayNotification(lines, showForever, false);
+ }
+
+ public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) {
+ if (showForever) {
+ notificationDisplayMillis = -420;
+ } else {
+ notificationDisplayMillis = System.currentTimeMillis();
+ }
+ notificationLines = lines;
+ showNotificationOverInv = overInventory;
+ }
+
+ public static void renderNotification() {
+ long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
+ boolean display = timeRemaining > 0 || notificationDisplayMillis == -420;
+ if (display && notificationLines != null && notificationLines.size() > 0) {
+ int width = 0;
+ int height = notificationLines.size() * 10 + 10;
+
+ for (String line : notificationLines) {
+ int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8;
+ if (len > width) {
+ width = len;
+ }
+ }
+
+ ScaledResolution sr = Utils.pushGuiScale(2);
+
+ int midX = sr.getScaledWidth() / 2;
+ int topY = sr.getScaledHeight() * 3 / 4 - height / 2;
+ RenderUtils.drawFloatingRectDark(midX - width / 2, sr.getScaledHeight() * 3 / 4 - height / 2, width, height);
+ /*Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2,
+ midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C);
+ Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2,
+ midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);*/
+
+ int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close");
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "[X] Close",
+ midX + width / 2f - 3 - xLen,
+ topY + 3,
+ 0xFFFF5555,
+ false
+ );
+
+ if (notificationDisplayMillis > 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ (timeRemaining / 1000) + "s",
+ midX - width / 2f + 3,
+ topY + 3,
+ 0xFFaaaaaa,
+ false
+ );
+ }
+
+ Utils.drawStringCentered(
+ notificationLines.get(0),
+ Minecraft.getMinecraft().fontRendererObj,
+ midX,
+ topY + 4 + 5,
+ false,
+ -1
+ );
+ for (int i = 1; i < notificationLines.size(); i++) {
+ String line = notificationLines.get(i);
+ Utils.drawStringCentered(
+ line,
+ Minecraft.getMinecraft().fontRendererObj,
+ midX,
+ topY + 4 + 5 + 2 + i * 10,
+ false,
+ -1
+ );
+ }
+
+ Utils.pushGuiScale(-1);
+ }
+ }
+
+ public static boolean shouldRenderOverlay(Gui gui) {
+ boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe;
+ if (gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (containerName.trim().equals("Fast Travel")) {
+ validGui = false;
+ }
+ }
+ return validGui;
+ }
+}