aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-02 17:22:43 +0200
committernea <nea@nea.moe>2023-06-02 17:22:43 +0200
commitf249df8f67114b14e3d75a955ace1d28ba6cb937 (patch)
tree8dbc1c813b6bb2b9cc9674e5e9e85bb4088b08f1 /src/main/kotlin/moe/nea/firmament/gui
parentccf1d1d0e97983509b29c276caa058b8c8284a66 (diff)
downloadFirmament-f249df8f67114b14e3d75a955ace1d28ba6cb937.tar.gz
Firmament-f249df8f67114b14e3d75a955ace1d28ba6cb937.tar.bz2
Firmament-f249df8f67114b14e3d75a955ace1d28ba6cb937.zip
Refactor skill page
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt49
1 files changed, 22 insertions, 27 deletions
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 a485954..c750101 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
@@ -10,7 +10,6 @@ import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.text.Text
-import net.minecraft.util.Formatting
import moe.nea.firmament.apis.Skill
import moe.nea.firmament.gui.WBar
import moe.nea.firmament.repo.RepoManager
@@ -18,37 +17,33 @@ import moe.nea.firmament.util.FirmFormatters
import moe.nea.firmament.util.toShedaniel
object SkillPage : ProfilePage {
+
+ private fun skillBar(profileViewer: ProfileViewer, skill: Skill): WBar {
+ val leveling = RepoManager.neuRepo.constants.leveling
+ val exp = skill.accessor.get(profileViewer.member)
+ val maxLevel = skill.getMaximumLevel(leveling)
+ val level = skill.getLadder(leveling)
+ .runningFold(0.0) { a, b -> a + b }
+ .filter { it <= exp }.size
+ .coerceAtMost(maxLevel)
+ return object : WBar(
+ level.toDouble(), maxLevel.toDouble(),
+ skill.color.toShedaniel(), skill.color.toShedaniel().darker(2.0)
+ ) {
+ override fun addTooltip(tooltip: TooltipBuilder) {
+ tooltip.add(Text.literal("$level/$maxLevel"))
+ tooltip.add(Text.translatable("firmament.pv.skills.total", FirmFormatters.toString(exp, 1)))
+ }
+ }
+ }
+
override fun getElements(profileViewer: ProfileViewer): WWidget {
return WGridPanel().also {
it.insets = Insets.ROOT_PANEL
- it.add(
- WText(
- Text.literal(
- profileViewer.account.rankData?.let {
- ("§${it.color}[${it.tag}${profileViewer.account.rankPlusDyeColor.modern}" +
- "${it.plus ?: ""}§${it.color}] ${profileViewer.primaryName}")
- } ?: "${Formatting.GRAY}${profileViewer.primaryName}"
- )
- ), 0, 0, 6, 1
- )
+ it.add(WText(Text.literal(profileViewer.account.getDisplayName())), 0, 0, 6, 1)
for ((i, skill) in Skill.values().withIndex()) {
- val leveling = RepoManager.neuRepo.constants.leveling
- val exp = skill.accessor.get(profileViewer.member)
- 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, 4, 1)
- it.add(object : WBar(
- level.toDouble(), maxLevel.toDouble(),
- skill.color.toShedaniel(), skill.color.toShedaniel().darker(2.0)
- ) {
- override fun addTooltip(tooltip: TooltipBuilder) {
- tooltip.add(Text.literal("$level/$maxLevel"))
- tooltip.add(Text.translatable("firmament.pv.skills.total", FirmFormatters.toString(exp, 1)))
- }
- }, 4, i + 1, 4, 1)
+ it.add(skillBar(profileViewer, skill), 4, i + 1, 4, 1)
}
}
}