From b61476608ec00642c5dc27cbfe02b4acf26c18d2 Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 2 Jun 2023 00:27:53 +0200 Subject: Make ProfilePage more generic --- .../nea/firmament/gui/profileviewer/ProfilePage.kt | 4 ++++ .../nea/firmament/gui/profileviewer/ProfileViewer.kt | 19 +++++++------------ .../moe/nea/firmament/gui/profileviewer/SkillPage.kt | 9 +++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfilePage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfilePage.kt index a491dd9..5f8d0a3 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfilePage.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfilePage.kt @@ -1,7 +1,11 @@ package moe.nea.firmament.gui.profileviewer import io.github.cottonmc.cotton.gui.widget.WWidget +import io.github.cottonmc.cotton.gui.widget.icon.Icon +import net.minecraft.text.Text interface ProfilePage { fun getElements(profileViewer: ProfileViewer): WWidget + val icon: Icon + val text: Text } diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt index 6285f6b..d3612e5 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt @@ -1,18 +1,10 @@ package moe.nea.firmament.gui.profileviewer import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription -import io.github.cottonmc.cotton.gui.widget.WGridPanel import io.github.cottonmc.cotton.gui.widget.WTabPanel -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 net.minecraft.util.DyeColor import moe.nea.firmament.apis.Member import moe.nea.firmament.apis.Profile -import moe.nea.firmament.gui.WBar -import moe.nea.firmament.util.toShedaniel class ProfileViewer( val primaryPlayer: UUID, @@ -26,10 +18,13 @@ class ProfileViewer( init { val panel = WTabPanel().also { rootPanel = it } panel.backgroundPainter - panel.add(SkillPage.getElements(this)) { - it.icon(ItemIcon(Items.IRON_SWORD)) - it.title(Text.translatable("firmament.pv.skills")) - } + listOf(SkillPage) + .forEach { page -> + panel.add(page.getElements(this)) { + it.icon(page.icon) + it.tooltip(page.text) + } + } } } 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 2e5b9d6..8f0693f 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt @@ -5,6 +5,10 @@ import io.github.cottonmc.cotton.gui.widget.WGridPanel import io.github.cottonmc.cotton.gui.widget.WText import io.github.cottonmc.cotton.gui.widget.WWidget 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.Text import moe.nea.firmament.apis.Skill import moe.nea.firmament.gui.WBar @@ -37,4 +41,9 @@ object SkillPage : ProfilePage { } } } + + override val icon: Icon + get() = ItemIcon(ItemStack(Items.IRON_SWORD)) + override val text: Text + get() = Text.translatable("firmament.pv.skills") } -- cgit