diff options
author | nea <nea@nea.moe> | 2023-06-02 00:27:53 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-06-02 00:27:53 +0200 |
commit | b61476608ec00642c5dc27cbfe02b4acf26c18d2 (patch) | |
tree | 6fda28508b784bf7214cc2982e4b19b7b9d57d5e /src | |
parent | 7c60db4fbf6b67dc5144436d2387331219128d3c (diff) | |
download | Firmament-b61476608ec00642c5dc27cbfe02b4acf26c18d2.tar.gz Firmament-b61476608ec00642c5dc27cbfe02b4acf26c18d2.tar.bz2 Firmament-b61476608ec00642c5dc27cbfe02b4acf26c18d2.zip |
Make ProfilePage more generic
Diffstat (limited to 'src')
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<ProfilePage>(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") } |