diff options
author | Lulonaut <lulonaut@lulonaut.tech> | 2023-09-27 13:20:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 21:20:32 +1000 |
commit | 92f71a39fcf82fe9231d3bafbc550c76a63109a7 (patch) | |
tree | 85d800feef7e33332a794a451152aff1adb7401a /src/main/java/io | |
parent | c41f5adb3977d8d60944c548fa2b456587256f5f (diff) | |
download | NotEnoughUpdates-92f71a39fcf82fe9231d3bafbc550c76a63109a7.tar.gz NotEnoughUpdates-92f71a39fcf82fe9231d3bafbc550c76a63109a7.tar.bz2 NotEnoughUpdates-92f71a39fcf82fe9231d3bafbc550c76a63109a7.zip |
Fix museum overlay crash and bestiary page not refreshing on profile switch (#822)
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt | 24 |
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() |