blob: a5ad0f08dda2b1ad80feaadfbb92c9a428cd9006 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
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.constraints.CenterConstraint
import gg.essential.elementa.constraints.XConstraint
import gg.essential.elementa.constraints.YConstraint
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.ExternalConfiguration
import tech.thatgravyboat.rewardclaim.MappedImageCache
import tech.thatgravyboat.rewardclaim.types.RewardData
import tech.thatgravyboat.rewardclaim.types.RewardLanguage
class UIReward(xConstraint: XConstraint, yConstraint: YConstraint) :
UIBlock(VigilancePalette.getHighlight().withAlpha(204)) {
private val imageBackground: UIBlock
private val title: UIText
private val rarityDesc: UIText
private val amountDesc: UIText
init {
constrain {
width = 35.percent()
height = 16.percent()
x = xConstraint
y = yConstraint
}
imageBackground = UIBlock(VigilancePalette.getBrightHighlight()).constrain {
width = 20.57.percent()
height = 80.percent()
x = 2.545.percent()
y = 10.percent()
} childOf this
UIBlock(VigilancePalette.getDivider()).constrain {
width = 1.pixel()
height = 95.percent()
x = 25.66.percent()
y = 2.5.percent()
} childOf this
val rightSideStart = (25.66.percent() + 2.pixel()) + 1.28.percent()
UIBlock(VigilancePalette.getDivider()).constrain {
width = 71.78.percent() - 1.pixel()
height = 1.pixel()
x = rightSideStart
y = 26.percent()
} childOf this
title = UIText("Unknown Reward").constrain {
x = rightSideStart
y = 26.percent() - (getHeight() + 1).pixel()
} childOf this
rarityDesc = UIText("Rarity: Unknown").constrain {
x = rightSideStart
y = 26.percent() + 3.pixel()
} childOf this
amountDesc = UIText("Amount: ${ChatColor.GOLD}0").constrain {
x = rightSideStart
y = 26.percent() + (5 + rarityDesc.getHeight()).pixel()
} childOf this
amountDesc.hide(true)
}
fun setSelected(selected: Boolean) {
if (selected) {
enableEffect(OutlineEffect(VigilancePalette.getAccent(), 1F))
} else {
removeEffect<OutlineEffect>()
}
}
fun setData(data: RewardData, language: RewardLanguage) {
title.setText(data.getDisplayName(language))
rarityDesc.setText("Rarity: ${data.rarity.color}${language.translate(data.rarity.translationKey)}")
data.amount?.let {
amountDesc.setText("Amount: ${ChatColor.GOLD}$it")
amountDesc.unhide(true)
}
data.intlist?.let {
amountDesc.setText("Boxes: ${ChatColor.GOLD}${it.size}")
amountDesc.unhide(true)
}
data.image?.let {
it.url?.let { url ->
val imageType = ExternalConfiguration.getImageType(it.imageType)
UIImage.ofURL(url, MappedImageCache).constrain {
width = imageType.width.percent()
height = imageType.height.percent()
if (imageType.center) {
x = CenterConstraint()
y = CenterConstraint()
}
} childOf imageBackground
}
}
}
}
|