diff options
author | nea <nea@nea.moe> | 2023-05-31 00:46:23 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-31 00:46:23 +0200 |
commit | a24a74fa2351d53693226ba0d0018fb9589cddc9 (patch) | |
tree | 4dc69bd90130f1755e75960251f5ca41701f84cf /src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt | |
parent | 88cb9468b4432f68d1197f512f68c951fdbdf3dd (diff) | |
download | Firmament-a24a74fa2351d53693226ba0d0018fb9589cddc9.tar.gz Firmament-a24a74fa2351d53693226ba0d0018fb9589cddc9.tar.bz2 Firmament-a24a74fa2351d53693226ba0d0018fb9589cddc9.zip |
[WIP] Add really shitty pv. This is mostly so I have something to be bothered to improve
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt new file mode 100644 index 0000000..e86ce8d --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt @@ -0,0 +1,49 @@ +package moe.nea.firmament.gui.profileviewer + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription +import io.github.cottonmc.cotton.gui.widget.TooltipBuilder +import io.github.cottonmc.cotton.gui.widget.WGridPanel +import io.github.cottonmc.cotton.gui.widget.WTabPanel +import io.github.cottonmc.cotton.gui.widget.WText +import io.github.cottonmc.cotton.gui.widget.data.Insets +import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon +import java.util.UUID +import net.minecraft.item.Items +import net.minecraft.text.Text +import moe.nea.firmament.apis.Profile +import moe.nea.firmament.apis.Skill +import moe.nea.firmament.repo.RepoManager + +class ProfileViewer( + val primaryPlayer: UUID, + val playerNames: Map<UUID, String>, + val profile: Profile, +) : LightweightGuiDescription() { + init { + val primaryMember = profile.members[primaryPlayer] ?: error("Primary player not in profile") + val panel = WTabPanel().also { rootPanel = it } + panel.backgroundPainter + panel.add(WGridPanel().also { + it.insets = Insets.ROOT_PANEL + it.add(WText(Text.literal(playerNames[primaryPlayer] ?: error("Primary player has no name"))), 0, 0, 6, 1) + for ((i, skill) in Skill.values().withIndex()) { + val leveling = RepoManager.neuRepo.constants.leveling + val exp = skill.accessor.get(primaryMember) + val maxLevel = skill.getMaximumLevel(leveling) + val level = skill.getLadder(leveling) + .runningFold(0.0) { a, b -> a + b } + .filter { it <= exp }.size + .coerceAtMost(maxLevel) + it.add(WText(Text.translatable("firmament.pv.skills.${skill.name.lowercase()}")), 0, i + 1, 5, 1) + it.add(object : WText(Text.literal("$level/$maxLevel")) { + override fun addTooltip(tooltip: TooltipBuilder) { + tooltip.add(Text.translatable("firmament.pv.skills.total", exp)) + } + }, 5, i + 1, 2, 1) + } + }) { + it.icon(ItemIcon(Items.IRON_SWORD)) + it.title(Text.translatable("firmament.pv.skills")) + } + } +} |