Make ProfilePage more generic

This commit is contained in:
nea
2023-06-02 00:27:53 +02:00
parent 7c60db4fbf
commit b61476608e
3 changed files with 20 additions and 12 deletions

View File

@@ -1,7 +1,11 @@
package moe.nea.firmament.gui.profileviewer package moe.nea.firmament.gui.profileviewer
import io.github.cottonmc.cotton.gui.widget.WWidget import io.github.cottonmc.cotton.gui.widget.WWidget
import io.github.cottonmc.cotton.gui.widget.icon.Icon
import net.minecraft.text.Text
interface ProfilePage { interface ProfilePage {
fun getElements(profileViewer: ProfileViewer): WWidget fun getElements(profileViewer: ProfileViewer): WWidget
val icon: Icon
val text: Text
} }

View File

@@ -1,18 +1,10 @@
package moe.nea.firmament.gui.profileviewer package moe.nea.firmament.gui.profileviewer
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription 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.WTabPanel
import io.github.cottonmc.cotton.gui.widget.data.Insets
import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon
import java.util.UUID 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.Member
import moe.nea.firmament.apis.Profile import moe.nea.firmament.apis.Profile
import moe.nea.firmament.gui.WBar
import moe.nea.firmament.util.toShedaniel
class ProfileViewer( class ProfileViewer(
val primaryPlayer: UUID, val primaryPlayer: UUID,
@@ -26,10 +18,13 @@ class ProfileViewer(
init { init {
val panel = WTabPanel().also { rootPanel = it } val panel = WTabPanel().also { rootPanel = it }
panel.backgroundPainter panel.backgroundPainter
panel.add(SkillPage.getElements(this)) { listOf<ProfilePage>(SkillPage)
it.icon(ItemIcon(Items.IRON_SWORD)) .forEach { page ->
it.title(Text.translatable("firmament.pv.skills")) panel.add(page.getElements(this)) {
} it.icon(page.icon)
it.tooltip(page.text)
}
}
} }
} }

View File

@@ -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.WText
import io.github.cottonmc.cotton.gui.widget.WWidget import io.github.cottonmc.cotton.gui.widget.WWidget
import io.github.cottonmc.cotton.gui.widget.data.Insets 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 net.minecraft.text.Text
import moe.nea.firmament.apis.Skill import moe.nea.firmament.apis.Skill
import moe.nea.firmament.gui.WBar 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")
} }