From 7dc51e6f1f280276d782e3c644099758ff01bdb7 Mon Sep 17 00:00:00 2001 From: Gravy Boat Date: Thu, 23 Sep 2021 19:25:26 -0230 Subject: Initial Commit --- .../rewardclaim/ui/UISelectedReward.kt | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt (limited to 'src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt') diff --git a/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt b/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt new file mode 100644 index 0000000..47763dc --- /dev/null +++ b/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt @@ -0,0 +1,86 @@ +package tech.thatgravyboat.rewardclaim.ui + +import gg.essential.elementa.components.UIBlock +import gg.essential.elementa.components.UIImage +import gg.essential.elementa.components.UIText +import gg.essential.elementa.components.UIWrappedText +import gg.essential.elementa.constraints.XConstraint +import gg.essential.elementa.dsl.* +import gg.essential.elementa.effects.OutlineEffect +import gg.essential.elementa.utils.withAlpha +import gg.essential.universal.ChatColor +import gg.essential.vigilance.gui.VigilancePalette +import tech.thatgravyboat.rewardclaim.MappedImageCache +import tech.thatgravyboat.rewardclaim.RewardLanguage +import tech.thatgravyboat.rewardclaim.types.RewardData + +class UISelectedReward(middle : XConstraint) : UIBlock(VigilancePalette.getHighlight().withAlpha(204)) { + + private var image : UIImage? = null + + private val displayName = UIText("Select a Reward!").constrain { + x = 31.percent() + y = 10.3.percent() + } childOf this + + private val imageBackground = UIBlock(VigilancePalette.getBrightHighlight()).constrain { + x = 5.percent() + y = 10.3.percent() + width = 20.5.percent() + height = 42.6.percent() + } childOf this + + private val rarity = UIText().constrain { + x = 31.percent() + y = 10.3.percent() + 13.pixel() + } childOf this + + private val amount = UIText().constrain { + x = 31.percent() + y = 10.3.percent() + 25.pixel() + } childOf this + + private val desc = UIWrappedText().constrain { + x = 5.percent() + y = 52.9.percent() + 3.pixel() + width = 90.percent() + } childOf this + + init { + constrain { + width = 35.percent() + height = 30.percent() + x = middle - 17.5.percent() + y = 25.percent() + } + + UIBlock(VigilancePalette.getDivider()).constrain { + width = 64.5.percent() + height = 1.pixel() + x = 30.5.percent() + y = 10.3.percent() + 11.pixel() + } childOf this + } + + fun updateInfo(data: RewardData, language: RewardLanguage) { + displayName.setText(data.getDisplayName(language)) + enableEffect(OutlineEffect(data.rarity.color.color!!, 1F)) + rarity.setText("Rarity: ${data.rarity.color}${language.translate(data.rarity.translationKey)}") + + if (data.amount != null) amount.setText("Amount: ${ChatColor.GOLD}${data.amount}") + else if (data.boxes != null) amount.setText("Boxes: ${ChatColor.GOLD}${data.boxes}") + else amount.setText("") + desc.setText(data.getDescription(language)) + + data.image?.let { + it.url?.let { url -> + image?.let(imageBackground::removeChild) + image = UIImage.ofURL(url, MappedImageCache).constrain { + height = it.height.percent() + width = 100.percent() + } childOf imageBackground + } + } + + } +} \ No newline at end of file -- cgit