blob: 47763dc9bba3f2ed10aeb1a64e95ec7e4fcf9afd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
}
}
}
}
|