From 5f2cfe2d07e0ddfc4f600d6ea31bad11d896e72f Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Fri, 21 Oct 2022 08:18:32 +0000 Subject: misc pv changes (#314) --- .../profileviewer/GuiProfileViewer.java | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 501af179..c78a6167 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -29,6 +29,8 @@ import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage; import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage; +import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.DungeonsWeight; +import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight; import io.github.moulberry.notenoughupdates.util.AsyncDependencyLoader; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.PronounDB; @@ -58,6 +60,7 @@ import java.awt.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; @@ -76,6 +79,8 @@ public class GuiProfileViewer extends GuiScreen { public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.png"); public static final ResourceLocation pv_bingo = new ResourceLocation("notenoughupdates:pv_bingo.png"); + + public final static DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#"); public static final ResourceLocation pv_stranded = new ResourceLocation("notenoughupdates:pv_stranded.png"); public static final ResourceLocation pv_unknown = new ResourceLocation("notenoughupdates:pv_unknown.png"); public static final ResourceLocation resource_packs = @@ -1024,9 +1029,11 @@ public class GuiProfileViewer extends GuiScreen { if (mouseY > y - 4 && mouseY < y + 13) { String levelStr; String totalXpStr = null; - if (skillName.contains("Catacombs")) totalXpStr = - EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + - numberFormat.format(levelObj.totalXp); + if (skillName.contains("Catacombs")) { + totalXpStr = EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + + numberFormat.format(levelObj.totalXp) + EnumChatFormatting.DARK_GRAY + " (" + + DECIMAL_FORMAT.format(getPercentage(skillName.toLowerCase(), levelObj)) + "% to 50)"; + } if (levelObj.maxed) { levelStr = EnumChatFormatting.GOLD + "MAXED!"; } else { @@ -1238,6 +1245,25 @@ public class GuiProfileViewer extends GuiScreen { } } + public float getPercentage(String skillName, ProfileViewer.Level level) { + if (level.maxed) { + return 100; + } + if (skillName.contains("catacombs")) { + return (level.totalXp / DungeonsWeight.CATACOMBS_LEVEL_50_XP) * 100; + } else if (ExtraPage.slayers.containsKey(skillName)) { + return (level.totalXp / 1000000) * 100; + } else if (skillName.equalsIgnoreCase("social")) { + return (level.totalXp / 272800) * 100; + } else { + if (level.maxLevel == 60) { + return (level.totalXp / SkillsWeight.SKILLS_LEVEL_60) * 100; + } else { + return (level.totalXp / SkillsWeight.SKILLS_LEVEL_50) * 100; + } + } + } + /** * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] -- cgit