blob: 687959d4c2bbad21b3205f30ea794aa7bc205bfa (
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
|
package moe.nea.firmament.gui.config
import io.github.cottonmc.cotton.gui.client.BackgroundPainter
import io.github.cottonmc.cotton.gui.client.CottonClientScreen
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription
import io.github.cottonmc.cotton.gui.widget.WButton
import io.github.cottonmc.cotton.gui.widget.WGridPanel
import io.github.cottonmc.cotton.gui.widget.WLabel
import io.github.cottonmc.cotton.gui.widget.WListPanel
import io.github.cottonmc.cotton.gui.widget.data.Insets
import net.minecraft.text.Text
import moe.nea.firmament.features.FeatureManager
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.ScreenUtil.setScreenLater
object AllConfigsGui {
fun showAllGuis() {
val lwgd = LightweightGuiDescription()
var screen: CottonClientScreen? = null
lwgd.setRootPanel(WListPanel(
listOf(
RepoManager.Config
) + FeatureManager.allFeatures.mapNotNull { it.config }, ::WGridPanel
) { config, panel ->
panel.insets = Insets.ROOT_PANEL
panel.backgroundPainter = BackgroundPainter.VANILLA
panel.add(WLabel(Text.translatable("firmament.config.${config.name}")), 0, 0, 10, 1)
panel.add(WButton(Text.translatable("firmanent.config.edit")).also {
it.setOnClick {
config.showConfigEditor(screen)
}
}, 0, 1, 10, 1)
println("Panel size: ${panel.width} ${panel.height}")
}.also {
it.setListItemHeight(52)
it.setSize(10 * 18 + 14 + 16, 300)
})
screen = CottonClientScreen(lwgd)
setScreenLater(screen)
}
}
|