aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/gui/ChatShortcutViewGui.kt
blob: a4a9f70507b4150f0ff914cf93715f0b819193b7 (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
package cc.woverflow.chatting.gui

import cc.woverflow.chatting.chat.ChatShortcuts
import cc.woverflow.chatting.gui.components.TextBlock
import gg.essential.api.EssentialAPI
import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.components.UIBlock
import gg.essential.elementa.constraints.CenterConstraint
import gg.essential.elementa.constraints.RelativeWindowConstraint
import gg.essential.elementa.constraints.SiblingConstraint
import gg.essential.elementa.dsl.*
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.ButtonComponent

class ChatShortcutViewGui : WindowScreen(version = ElementaVersion.V1) {
    override fun initScreen(width: Int, height: Int) {
        super.initScreen(width, height)
        for ((index, shortcut) in ChatShortcuts.shortcuts.withIndex()) {
            val block = UIBlock(VigilancePalette.getBackground()).constrain {
                x = 3.percent()
                y = (index * 12).percent()
                this.width = 94.percent()
                this.height = 25.pixels()
            } childOf this.window
            TextBlock(shortcut.first).constrain {
                x = RelativeWindowConstraint(0.05F)
                y = CenterConstraint()
            } childOf block
            TextBlock(shortcut.second).constrain {
                x = SiblingConstraint(10F)
                y = CenterConstraint()
            } childOf block
            ButtonComponent("Edit") {
                println("${shortcut.first} ${shortcut.second}")
                EssentialAPI.getGuiUtil().openScreen(ChatShortcutEditGui(shortcut.first, shortcut.second, true))
            } constrain {
                x = SiblingConstraint(20F)
                y = CenterConstraint()
            } childOf block
            ButtonComponent("Delete") {
                println("${shortcut.first} ${shortcut.second}")
                ChatShortcuts.removeShortcut(shortcut.first)
                EssentialAPI.getGuiUtil().openScreen(ChatShortcutViewGui())
            } constrain {
                x = SiblingConstraint(5F)
                y = CenterConstraint()
            } childOf block
        }
        ButtonComponent("New") {
            EssentialAPI.getGuiUtil().openScreen(ChatShortcutEditGui("", "", false))
        } constrain {
            x = CenterConstraint()
            y = 80.percent()
        } childOf window
    }
}