diff options
author | Gravy Boat <thatgravyboat@gmail.com> | 2021-09-23 19:25:26 -0230 |
---|---|---|
committer | Gravy Boat <thatgravyboat@gmail.com> | 2021-09-23 19:25:26 -0230 |
commit | 7dc51e6f1f280276d782e3c644099758ff01bdb7 (patch) | |
tree | 89bbbbcc22b100c20e752a750ccef0547c466229 /src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt | |
parent | f71b3ccee2ec9949de7e572375a45dbf1c3fadb8 (diff) | |
download | RewardClaim-7dc51e6f1f280276d782e3c644099758ff01bdb7.tar.gz RewardClaim-7dc51e6f1f280276d782e3c644099758ff01bdb7.tar.bz2 RewardClaim-7dc51e6f1f280276d782e3c644099758ff01bdb7.zip |
Initial Commit
Diffstat (limited to 'src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt')
-rw-r--r-- | src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/UISelectedReward.kt | 86 |
1 files changed, 86 insertions, 0 deletions
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 |