blob: 87778e57480ca593e3d036d38d0a9aab5bece807 (
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
|
package dev.isxander.yacl3.dsl
import dev.isxander.yacl3.api.*
import net.minecraft.network.chat.Component
interface YACLDsl {
val namespaceKey: String
val categories: YACLDslReference
fun title(component: Component)
fun title(block: () -> Component)
fun category(id: String, block: CategoryDsl.() -> Unit): ConfigCategory
fun save(block: () -> Unit)
}
interface OptionAddableDsl {
fun <T : Any> option(id: String, block: OptionDsl<T>.() -> Unit): Option<T>
}
interface CategoryDsl : OptionAddableDsl {
val groups: CategoryDslReference
val options: GroupDslReference
fun group(id: String, block: GroupDsl.() -> Unit): OptionGroup
fun name(component: Component)
fun name(block: () -> Component)
fun tooltip(vararg component: Component)
fun tooltipBuilder(block: TooltipBuilderDsl.() -> Unit)
fun useDefaultTooltip(lines: Int = 1)
}
interface GroupDsl : OptionAddableDsl {
val options: GroupDslReference
fun name(component: Component)
fun name(block: () -> Component)
fun descriptionBuilder(block: OptionDescription.Builder.() -> Unit)
fun description(description: OptionDescription)
fun useDefaultDescription(lines: Int = 1)
}
interface OptionDsl<T> : Option.Builder<T> {
val option: FutureValue<Option<T>>
fun OptionDescription.Builder.addDefaultDescription(lines: Int? = null)
}
interface TooltipBuilderDsl {
fun text(component: Component)
fun text(block: () -> Component)
operator fun Component.unaryPlus()
class Delegate(private val tooltipFunction: (Component) -> Unit) : TooltipBuilderDsl {
override fun text(component: Component) {
tooltipFunction(component)
}
override fun text(block: () -> Component) {
text(block())
}
override fun Component.unaryPlus() {
text(this)
}
}
}
interface YACLDslReference : Reference<CategoryDslReference> {
fun get(): YetAnotherConfigLib?
val isBuilt: Boolean
fun registering(block: CategoryDsl.() -> Unit): RegisterableDelegateProvider<CategoryDsl, ConfigCategory>
}
interface CategoryDslReference : Reference<GroupDslReference> {
fun get(): ConfigCategory?
val root: GroupDslReference
val isBuilt: Boolean
fun registering(block: GroupDsl.() -> Unit): RegisterableDelegateProvider<GroupDsl, OptionGroup>
}
interface GroupDslReference {
fun get(): OptionGroup?
operator fun <T> get(id: String): FutureValue<Option<T>>
val isBuilt: Boolean
fun <T : Any> registering(block: OptionDsl<T>.() -> Unit): RegisterableDelegateProvider<OptionDsl<T>, Option<T>>
}
|