aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt26
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt13
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt100
3 files changed, 123 insertions, 16 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt
new file mode 100644
index 0000000..ff9e894
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt
@@ -0,0 +1,26 @@
+package moe.nea.firmament.gui
+
+import io.github.cottonmc.cotton.gui.client.BackgroundPainter
+import io.github.cottonmc.cotton.gui.widget.TooltipBuilder
+import io.github.cottonmc.cotton.gui.widget.WItem
+import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.item.TooltipContext
+import net.minecraft.item.ItemStack
+import net.minecraft.text.Text
+import moe.nea.firmament.util.MC
+
+class WTitledItem(val stack: ItemStack, val countString: Text = Text.empty()) : WItem(stack) {
+ override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) {
+ BackgroundPainter.SLOT.paintBackground(context, x, y, this)
+ super.paint(context, x, y, mouseX, mouseY)
+ context.matrices.push()
+ context.matrices.translate(0F, 0F, 200F)
+ context.drawText(MC.font, countString, x + 19 - 2 - MC.font.getWidth(countString), y + 6 + 3, 0xFFFFFF, true)
+ context.matrices.push()
+ }
+
+ override fun addTooltip(tooltip: TooltipBuilder) {
+ tooltip.add(*stack.getTooltip(null, TooltipContext.BASIC).toTypedArray())
+ }
+
+}
diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt
index 62889bd..20e11e7 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt
@@ -14,8 +14,10 @@ import net.minecraft.client.item.TooltipContext
import net.minecraft.item.Items
import net.minecraft.text.Text
import moe.nea.firmament.gui.WTightScrollPanel
+import moe.nea.firmament.gui.WTitledItem
import moe.nea.firmament.rei.PetData
import moe.nea.firmament.rei.SBItemStack
+import moe.nea.firmament.repo.RepoManager
object PetsPage : ProfilePage {
override fun getElements(profileViewer: ProfileViewer): WWidget {
@@ -26,16 +28,7 @@ object PetsPage : ProfilePage {
it.setGaps(8, 8)
for ((i, pet) in profileViewer.member.pets.withIndex()) {
val stack = SBItemStack(pet.itemId, PetData(pet.tier, pet.type.name, pet.exp)).asItemStack()
- it.add(object : WItem(stack) {
- override fun paint(context: DrawContext?, x: Int, y: Int, mouseX: Int, mouseY: Int) {
- BackgroundPainter.SLOT.paintBackground(context, x, y, this)
- super.paint(context, x, y, mouseX, mouseY)
- }
-
- override fun addTooltip(tooltip: TooltipBuilder) {
- tooltip.add(*stack.getTooltip(null, TooltipContext.BASIC).toTypedArray())
- }
- }, i % 5, i / 5, 1, 1)
+ it.add(WTitledItem(stack), i % 5, i / 5, 1, 1)
}
it.layout()
})), 0, 1, 8, 8)
diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
index c750101..2de217e 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
@@ -1,20 +1,39 @@
package moe.nea.firmament.gui.profileviewer
import io.github.cottonmc.cotton.gui.widget.TooltipBuilder
+import io.github.cottonmc.cotton.gui.widget.WBox
import io.github.cottonmc.cotton.gui.widget.WGridPanel
+import io.github.cottonmc.cotton.gui.widget.WPanel
+import io.github.cottonmc.cotton.gui.widget.WTabPanel
import io.github.cottonmc.cotton.gui.widget.WText
import io.github.cottonmc.cotton.gui.widget.WWidget
+import io.github.cottonmc.cotton.gui.widget.data.Axis
+import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment
import io.github.cottonmc.cotton.gui.widget.data.Insets
import io.github.cottonmc.cotton.gui.widget.icon.Icon
import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
+import net.minecraft.text.Style
import net.minecraft.text.Text
+import net.minecraft.util.Formatting
+import moe.nea.firmament.apis.CollectionInfo
+import moe.nea.firmament.apis.CollectionType
+import moe.nea.firmament.apis.Member
import moe.nea.firmament.apis.Skill
import moe.nea.firmament.gui.WBar
+import moe.nea.firmament.gui.WFixedPanel
+import moe.nea.firmament.gui.WTitledItem
+import moe.nea.firmament.hud.horizontal
+import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry
+import moe.nea.firmament.rei.SBItemEntryDefinition
+import moe.nea.firmament.repo.HypixelStaticData
+import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.FirmFormatters
+import moe.nea.firmament.util.modifyLore
import moe.nea.firmament.util.toShedaniel
+import moe.nea.firmament.util.toTextColor
object SkillPage : ProfilePage {
@@ -37,14 +56,83 @@ object SkillPage : ProfilePage {
}
}
+ private fun collectionItem(type: CollectionType, info: CollectionInfo, skill: Skill, member: Member): WWidget {
+ val collectionCount = member.collection[type] ?: 0
+ val unlockedTiers = info.tiers.count { it.amountRequired <= collectionCount }
+ return WTitledItem(
+ SBItemEntryDefinition.getEntry(type.skyblockId).asItemEntry().value.copy()
+ .also {
+ it.setCustomName(
+ Text.literal(info.name).fillStyle(
+ Style.EMPTY.withItalic(false).withBold(true)
+ .withColor(skill.color.toTextColor())
+ )
+ )
+ it.modifyLore { old ->
+ listOf(
+ Text.literal("${info.name} Collection: $collectionCount / ${info.tiers.last().amountRequired}"),
+ Text.literal("Tiers unlocked: $unlockedTiers")
+ ).map {
+ it.fillStyle(
+ Style.EMPTY.withItalic(false).withColor(Formatting.GRAY)
+ )
+ }
+ }
+ }, countString = Text.literal("$unlockedTiers").styled {
+ if (unlockedTiers == info.maxTiers)
+ it.withColor(Formatting.YELLOW)
+ else it
+ }
+ )
+ }
+
+ private fun collectionPanel(profileViewer: ProfileViewer): WTabPanel {
+ return WTabPanel().also {
+ val data = HypixelStaticData.collectionData
+ val panels = mutableListOf<WPanel>()
+ for ((skill, collections) in data.entries) {
+ val panel = WBox(Axis.HORIZONTAL).also {
+ it.horizontalAlignment = HorizontalAlignment.CENTER
+ it.add(WFixedPanel(WGridPanel().also {
+ it.insets = Insets.ROOT_PANEL
+ it.setGaps(2, 2)
+ var x = 0
+ var y = 0
+ for (item in collections.items) {
+ it.add(collectionItem(item.key, item.value, skill, profileViewer.member), x, y, 1, 1)
+ x++
+ if (x == 5) {
+ x = 0
+ y++
+ }
+ }
+ }))
+ }
+ panels.add(panel)
+ it.add(panel) {
+ it.tooltip(
+ Text.translatable("firmament.pv.skills.${skill.name.lowercase()}")
+ .styled { it.withColor(skill.color.toTextColor()) })
+ it.icon(ItemIcon(RepoManager.getNEUItem(skill.icon).asItemStack()))
+ }
+ }
+ it.layout()
+ val tabWidth = it.width
+ panels.forEach { it.setSize(tabWidth - Insets.ROOT_PANEL.horizontal, it.height) }
+ }
+ }
+
override fun getElements(profileViewer: ProfileViewer): WWidget {
- return WGridPanel().also {
+ return WBox(Axis.HORIZONTAL).also {
it.insets = Insets.ROOT_PANEL
- it.add(WText(Text.literal(profileViewer.account.getDisplayName())), 0, 0, 6, 1)
- for ((i, skill) in Skill.values().withIndex()) {
- it.add(WText(Text.translatable("firmament.pv.skills.${skill.name.lowercase()}")), 0, i + 1, 4, 1)
- it.add(skillBar(profileViewer, skill), 4, i + 1, 4, 1)
- }
+ it.add(WGridPanel().also {
+ it.add(WText(Text.literal(profileViewer.account.getDisplayName())), 0, 0, 8, 1)
+ for ((i, skill) in Skill.values().withIndex()) {
+ it.add(WText(Text.translatable("firmament.pv.skills.${skill.name.lowercase()}")), 0, i + 1, 4, 1)
+ it.add(skillBar(profileViewer, skill), 4, i + 1, 4, 1)
+ }
+ })
+ it.add(collectionPanel(profileViewer))
}
}