From 4a9e1c462e4bc757c00813bab1944d42fc479d0e Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Thu, 22 Dec 2022 07:22:06 +1100 Subject: Added essence shop tooltip to pv (#488) --- .../notenoughupdates/profileviewer/ExtraPage.java | 25 ++++++++++++++++++++-- .../moulberry/notenoughupdates/util/Constants.java | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java index 21ccc683..5f477196 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java @@ -39,6 +39,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -108,7 +109,9 @@ public class ExtraPage extends GuiProfileViewerPage { float xStart, float yStartTop, float xOffset, - float yOffset + float yOffset, + float mouseX, + float mouseY ) { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); @@ -143,6 +146,24 @@ public class ExtraPage extends GuiProfileViewerPage { guiTop + yStartTop + (yOffset - 1) * i, 76 ); + if (Constants.ESSENCESHOPS == null) return; + JsonObject essenceShops = Constants.ESSENCESHOPS; + if (mouseX >= guiLeft + xStart + xOffset && mouseX <= guiLeft + xStart + xOffset + 76 && + mouseY >= guiTop + yStartTop + (yOffset - 1) * i && + mouseY <= guiTop + yStartTop + (yOffset - 1) * i + 10) { + getInstance().tooltipToDisplay = new ArrayList<>(); + if (essenceShops.get(essenceName) == null) continue; + + for (Map.Entry entry : essenceShops.get(essenceName).getAsJsonObject().entrySet()) { + int perkTier = + (profileInfo.has("perks") && profileInfo.get("perks").getAsJsonObject().has(entry.getKey()) ? profileInfo.get("perks").getAsJsonObject().get(entry.getKey()).getAsInt() : 0); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.GOLD + entry.getValue().getAsJsonObject().get("name").getAsString() + ": " + EnumChatFormatting.AQUA + + perkTier + "/" + entry.getValue().getAsJsonObject().get("costs").getAsJsonArray().size() + ); + } + + } } } @@ -414,7 +435,7 @@ public class ExtraPage extends GuiProfileViewerPage { 76 ); - drawEssence(profileInfo, xStart, yStartTop, xOffset, yOffset); + drawEssence(profileInfo, xStart, yStartTop, xOffset, yOffset, mouseX, mouseY); if (topKills == null) { topKills = new TreeMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java index e7674aa9..0105ba1f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -77,6 +77,7 @@ public class Constants { public static JsonObject WEIGHT; public static JsonObject RNGSCORE; public static JsonObject ABIPHONE; + public static JsonObject ESSENCESHOPS; private static final ReentrantLock lock = new ReentrantLock(); @@ -100,6 +101,7 @@ public class Constants { WEIGHT = Utils.getConstant("weight", gson); RNGSCORE = Utils.getConstant("rngscore", gson); ABIPHONE = Utils.getConstant("abiphone", gson); + ESSENCESHOPS = Utils.getConstant("essenceshops", gson); parseEssenceCosts(); } catch (Exception ex) { -- cgit