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
|
package tech.thatgravyboat.rewardclaim.ui
import gg.essential.elementa.UIComponent
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.CenterConstraint
import gg.essential.elementa.dsl.*
import gg.essential.elementa.events.UIClickEvent
import gg.essential.elementa.utils.withAlpha
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.VigilancePalette.getBackground
class UIPopup private constructor(title: String, text: String) : UIBlock(getBackground().withAlpha(200)) {
private val box: UIBlock
constructor(
title: String,
text: String,
image: UIImage? = null,
event: (UIComponent.(event: UIClickEvent) -> Unit),
buttonText: String
) : this(title, text) {
val btnText = UIText(buttonText, false)
val width = btnText.getTextWidth() + 18 + if (image != null) 18 else 0
UIButton(image, width, CenterConstraint(), btnText, Alignment.MIDDLE).onMouseClick(event) childOf box
}
constructor(
title: String,
text: String,
image1: UIImage? = null,
event1: (UIComponent.(event: UIClickEvent) -> Unit),
buttonText: String,
image2: UIImage? = null,
event2: (UIComponent.(event: UIClickEvent) -> Unit),
buttonText2: String
) : this(title, text) {
val btn1Text = UIText(buttonText, false)
val btn1Width = btn1Text.getTextWidth() + 18 + if (image1 != null) 18 else 0
val btn2Text = UIText(buttonText2, false)
val btn2Width = btn2Text.getTextWidth() + 18 + if (image2 != null) 18 else 0
val width = btn1Width.coerceAtLeast(btn2Width)
UIButton(
image1,
width,
CenterConstraint() - 5.percent(),
btn1Text,
Alignment.RIGHT
).onMouseClick(event1) childOf box
UIButton(
image2,
width,
CenterConstraint() + 5.percent(),
btn2Text,
Alignment.LEFT
).onMouseClick(event2) childOf box
}
init {
constrain {
width = 100.percent()
height = 100.percent()
}
box = UIBlock(VigilancePalette.getHighlight()).constrain {
width = 50.percent()
height = 45.percent()
x = CenterConstraint()
y = CenterConstraint()
} childOf this
UIText(title).constrain {
y = 5.percent()
x = CenterConstraint()
} childOf box
UIWrappedText(text, true, centered = true, trimText = true).constrain {
width = 90.percent()
height = 80.percent()
x = 5.percent()
y = 5.percent() + 11.pixel()
} childOf box
}
}
|