aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMadeleaan <70163122+Madeleaan@users.noreply.github.com>2023-10-19 23:46:26 +0200
committerGitHub <noreply@github.com>2023-10-19 23:46:26 +0200
commit83220de1c5867f003c915999775794bee3686b8e (patch)
tree3472074a3efd8a551d44ec845ed7586a9ec62af7 /src/main
parent54e236158db9b5947d125f83b29e53cf27f73a79 (diff)
downloadNotEnoughUpdates-83220de1c5867f003c915999775794bee3686b8e.tar.gz
NotEnoughUpdates-83220de1c5867f003c915999775794bee3686b8e.tar.bz2
NotEnoughUpdates-83220de1c5867f003c915999775794bee3686b8e.zip
Pv bestiary (#884)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt43
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.kt142
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_bestiary_tab.pngbin628 -> 1829 bytes
3 files changed, 164 insertions, 21 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt
index bcf86206..358d1c3a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryData.kt
@@ -23,6 +23,7 @@ import com.google.gson.JsonObject
import io.github.moulberry.notenoughupdates.util.Constants
import io.github.moulberry.notenoughupdates.util.ItemUtils
import io.github.moulberry.notenoughupdates.util.Utils
+import io.github.moulberry.notenoughupdates.util.roundToDecimals
import kotlin.math.min
object BestiaryData {
@@ -169,7 +170,7 @@ object BestiaryData {
)
}
}
- return Category(categoryId, categoryName, categoryIcon, emptyList(), subCategories)
+ return Category(categoryId, categoryName, categoryIcon, emptyList(), subCategories, calculateFamilyDataOfSubcategories(subCategories))
} else {
val categoryMobs = categoryData["mobs"].asJsonArray.map { it.asJsonObject }
@@ -199,7 +200,7 @@ object BestiaryData {
val levelData = calculateLevel(bracket, kills, cap)
computedMobs.add(Mob(mobName, mobIcon, kills, deaths, levelData))
}
- return Category(categoryId, categoryName, categoryIcon, computedMobs, emptyList())
+ return Category(categoryId, categoryName, categoryIcon, computedMobs, emptyList(), calculateFamilyData(computedMobs))
}
}
@@ -214,6 +215,9 @@ object BestiaryData {
val bracketData =
Constants.BESTIARY["brackets"].asJsonObject[bracket.toString()].asJsonArray.map { it.asDouble }
var maxLevel = false
+ var progress = 0.0
+ var effKills = 0.0
+ var effReq = 0.0
val effectiveKills = if (kills >= cap) {
maxLevel = true
@@ -222,14 +226,47 @@ object BestiaryData {
kills
}
+ val totalProgress = (effectiveKills/cap*100).roundToDecimals(1)
+
var level = 0
for (requiredKills in bracketData) {
if (effectiveKills >= requiredKills) {
level++
} else {
+ val prevTierKills = if (level != 0) bracketData[(level - 1).coerceAtLeast(0)].toInt() else 0
+ effKills = kills - prevTierKills
+ effReq = requiredKills - prevTierKills
+ progress = (effKills / effReq * 100).roundToDecimals(1)
break
}
}
- return MobLevelData(level, maxLevel)
+ return MobLevelData(level, maxLevel, progress, totalProgress, MobKillData(effKills, effReq, effectiveKills, cap))
+ }
+
+ private fun calculateFamilyData(mobs: List<Mob>): FamilyData {
+ var found = 0
+ var completed = 0
+
+ for (mob in mobs) {
+ if(mob.kills > 0) found++
+ if(mob.mobLevelData.maxLevel) completed++
+ }
+
+ return FamilyData(found, completed, mobs.size)
+ }
+
+ private fun calculateFamilyDataOfSubcategories(subCategories: List<Category>): FamilyData {
+ var found = 0
+ var completed = 0
+ var total = 0
+
+ for (category in subCategories) {
+ val data = category.familyData
+ found += data.found
+ completed += data.completed
+ total += data.total
+ }
+
+ return FamilyData(found, completed, total)
}
}
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 62847ea6..c25cbe34 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
@@ -48,13 +48,34 @@ data class Mob(
* A Bestiary category as defined in `constants/bestiary.json`
*/
data class Category(
- val id: String, val name: String, val icon: ItemStack, val mobs: List<Mob>, val subCategories: List<Category>
+ val id: String,
+ val name: String,
+ val icon: ItemStack,
+ val mobs: List<Mob>,
+ val subCategories: List<Category>,
+ val familyData: FamilyData
)
/**
* Level data for one specific mob
*/
-data class MobLevelData(val level: Int, val maxLevel: Boolean)
+data class MobLevelData(
+ val level: Int, val maxLevel: Boolean, val progress: Double, val totalProgress: Double, val mobKillData: MobKillData
+)
+
+/**
+ * Kills data for one specific mob
+ */
+data class MobKillData(
+ val tierKills: Double, val tierReq: Double, val cappedKills: Double, val cap: Double
+)
+
+/**
+ * Family data for one specific category
+ */
+data class FamilyData(
+ val found: Int, val completed: Int, val total: Int
+)
class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance) {
private var selectedCategory = "dynamic"
@@ -231,6 +252,64 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
selectedSubCategory = ""
}
+ // Render family information
+ var catData = selectedCategory.familyData
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED.toString() + "Families Found:",
+ (if (catData.found == catData.total) "§6" else "§7") + "${catData.found}/${catData.total}",
+ guiLeft + 280F,
+ guiTop + 70F,
+ 110
+ )
+ if (catData.found == catData.total) {
+ instance.renderGoldBar(guiLeft + 280F, guiTop + 80F, 112F)
+ } else {
+ instance.renderBar(guiLeft + 280F, guiTop + 80F, 112F, catData.found / catData.total.toFloat())
+ }
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED.toString() + "Families Completed:",
+ (if (catData.completed == catData.total) "§6" else "§7") + "${catData.completed}/${catData.total}",
+ guiLeft + 280F,
+ guiTop + 90F,
+ 110
+ )
+ if (catData.completed == catData.total) {
+ instance.renderGoldBar(guiLeft + 280F, guiTop + 100F, 112F)
+ } else {
+ instance.renderBar(guiLeft + 280F, guiTop + 100F, 112F, catData.completed / catData.total.toFloat())
+ }
+
+ // Render subcategory family information, if possible
+ if (selectedSubCategory != "") {
+ catData = selectedCategory.subCategories.find { it.id == selectedSubCategory }!!.familyData
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED.toString() + "Families Found:",
+ (if (catData.found == catData.total) "§6" else "§7") + "${catData.found}/${catData.total}",
+ guiLeft + 280F,
+ guiTop + 120F,
+ 110
+ )
+ if (catData.found == catData.total) {
+ instance.renderGoldBar(guiLeft + 280F, guiTop + 130F, 112F)
+ } else {
+ instance.renderBar(guiLeft + 280F, guiTop + 130F, 112F, catData.found / catData.total.toFloat())
+ }
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED.toString() + "Families Completed:",
+ (if (catData.completed == catData.total) "§6" else "§7") + "${catData.completed}/${catData.total}",
+ guiLeft + 280F,
+ guiTop + 140F,
+ 110
+ )
+ if (catData.completed == catData.total) {
+ instance.renderGoldBar(guiLeft + 280F, guiTop + 150F, 112F)
+ } else {
+ instance.renderBar(guiLeft + 280F, guiTop + 150F, 112F, catData.completed / catData.total.toFloat())
+ }
+ }
+
// Determine which mobs should be displayed
val mobs = if (selectedSubCategory != "") {
selectedCategory.subCategories.first { it.id == selectedSubCategory }.mobs
@@ -245,7 +324,6 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
val yIndex = i / mobListXCount
val x = 23 + mobListXPadding + (mobListXPadding + 20) * xIndex
val y = 30 + mobListYPadding + (mobListYPadding + 20) * yIndex
- val completedness = 0f
GlStateManager.disableLighting()
RenderHelper.enableGUIStandardItemLighting()
@@ -255,24 +333,11 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
guiLeft + x,
guiTop + y,
20f,
- 20 * (1 - completedness),
- 0f,
- 20 / 256f,
- 0f,
- 20 * (1 - completedness) / 256f,
- GL11.GL_NEAREST
- )
- //GlStateManager.color(1, 185 / 255f, 0, 1);
- Minecraft.getMinecraft().textureManager.bindTexture(GuiProfileViewer.pv_elements)
- Utils.drawTexturedRect(
- guiLeft + x,
- guiTop + y + 20 * (1 - completedness),
20f,
- 20 * completedness,
0f,
20 / 256f,
- 20 * (1 - completedness) / 256f,
- 20 / 256f,
+ 0f,
+ 20f / 256f,
GL11.GL_NEAREST
)
Utils.drawItemStack(stack, guiLeft + x.toInt() + 2, guiTop + y.toInt() + 2)
@@ -293,6 +358,47 @@ class BestiaryPage(instance: GuiProfileViewer?) : GuiProfileViewerPage(instance)
EnumChatFormatting.GRAY.toString() + "Deaths: " + EnumChatFormatting.GREEN +
StringUtils.formatNumber(deaths)
)
+ tooltipToDisplay.add("")
+
+ if (!mob.mobLevelData.maxLevel) {
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY.toString() + "Progress to Tier ${mob.mobLevelData.level + 1}: " +
+ EnumChatFormatting.AQUA + "${mob.mobLevelData.progress}%"
+ )
+
+ var bar = "§3§l§m"
+ for (j in 1..14) {
+ var col = ""
+ if (mob.mobLevelData.progress < j * (100 / 14)) col = "§f§l§m"
+ bar += "$col "
+ }
+ tooltipToDisplay.add(
+ "${bar}§r§b ${StringUtils.formatNumber(mob.mobLevelData.mobKillData.tierKills)}/${
+ StringUtils.formatNumber(
+ mob.mobLevelData.mobKillData.tierReq
+ )
+ }"
+ )
+ tooltipToDisplay.add("")
+ }
+
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY.toString() + "Overall Progress: " + EnumChatFormatting.AQUA + "${mob.mobLevelData.totalProgress}%" +
+ if (mob.mobLevelData.maxLevel) " §7(§c§lMAX!§r§7)" else ""
+ )
+ var bar = "§3§l§m"
+ for (j in 1..14) {
+ var col = ""
+ if (mob.mobLevelData.totalProgress < j * (100 / 14)) col = "§f§l§m"
+ bar += "$col "
+ }
+ tooltipToDisplay.add(
+ "${bar}§r§b ${StringUtils.formatNumber(mob.mobLevelData.mobKillData.cappedKills)}/${
+ StringUtils.formatNumber(
+ mob.mobLevelData.mobKillData.cap
+ )
+ }"
+ )
}
}
GlStateManager.color(1f, 1f, 1f, 1f)
diff --git a/src/main/resources/assets/notenoughupdates/pv_bestiary_tab.png b/src/main/resources/assets/notenoughupdates/pv_bestiary_tab.png
index 620c156b..a3ba742e 100644
--- a/src/main/resources/assets/notenoughupdates/pv_bestiary_tab.png
+++ b/src/main/resources/assets/notenoughupdates/pv_bestiary_tab.png
Binary files differ