aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt
index 896a8fb5..2691f23c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt
@@ -58,11 +58,11 @@ data class MobLevelData(val level: Int, val maxLevel: Boolean)
class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) {
private var selectedCategory = "dynamic"
- private var lastSelectedCategory = ""
private var selectedSubCategory = ""
private var tooltipToDisplay: MutableList<String> = mutableListOf()
private var bestiaryLevel = 0.0
private var computedCategories: MutableList<Category> = mutableListOf()
+ private var lastProfileName = ""
private val bestiaryTexture = ResourceLocation("notenoughupdates:pv_bestiary_tab.png")
private val mobListXCount = 9
@@ -74,8 +74,9 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
val guiLeft = GuiProfileViewer.getGuiLeft()
val guiTop = GuiProfileViewer.getGuiTop()
- val selectedProfile = selectedProfile ?: return
+ val selectedProfile = GuiProfileViewer.getSelectedProfile() ?: return
val profileInfo = selectedProfile.profileJson
+ val profileName = GuiProfileViewer.getProfileName()
if (!hasMigrated(profileInfo) || Constants.BESTIARY == null) {
Utils.drawStringCentered(
@@ -85,13 +86,28 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
true,
0
)
+ lastProfileName = profileName
return
}
- // Do the initial parsing only once
- if (computedCategories.isEmpty()) {
+ // Do the initial parsing only once or on profile switch
+ if (computedCategories.isEmpty() || lastProfileName != profileName) {
computedCategories = parseBestiaryData(profileInfo)
bestiaryLevel = calculateTotalBestiaryTiers(computedCategories).toDouble()
}
+
+ if (computedCategories.isEmpty() || Constants.BESTIARY == null) {
+ Utils.drawStringCentered(
+ "${EnumChatFormatting.RED}No valid bestiary data!",
+ guiLeft + 431 / 2f,
+ (guiTop + 101).toFloat(),
+ true,
+ 0
+ )
+ lastProfileName = profileName
+ return
+ }
+ lastProfileName = profileName
+
val bestiarySize = computedCategories.size
val bestiaryXSize = (350f / (bestiarySize - 1 + 0.0000001f)).toInt()