Bigger settings panel
This commit is contained in:
@@ -32,10 +32,12 @@ import io.github.cottonmc.cotton.gui.widget.WScrollPanel
|
|||||||
import io.github.cottonmc.cotton.gui.widget.data.Axis
|
import io.github.cottonmc.cotton.gui.widget.data.Axis
|
||||||
import io.github.cottonmc.cotton.gui.widget.data.Insets
|
import io.github.cottonmc.cotton.gui.widget.data.Insets
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
|
import kotlin.streams.asSequence
|
||||||
import net.minecraft.client.gui.screen.Screen
|
import net.minecraft.client.gui.screen.Screen
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import moe.nea.firmament.features.FeatureManager
|
import moe.nea.firmament.features.FeatureManager
|
||||||
import moe.nea.firmament.gui.WFixedPanel
|
import moe.nea.firmament.gui.WFixedPanel
|
||||||
|
import moe.nea.firmament.gui.WSplitPanel
|
||||||
import moe.nea.firmament.gui.WTightScrollPanel
|
import moe.nea.firmament.gui.WTightScrollPanel
|
||||||
import moe.nea.firmament.repo.RepoManager
|
import moe.nea.firmament.repo.RepoManager
|
||||||
import moe.nea.firmament.util.MC
|
import moe.nea.firmament.util.MC
|
||||||
@@ -51,26 +53,30 @@ object AllConfigsGui {
|
|||||||
) + FeatureManager.allFeatures.mapNotNull { it.config }
|
) + FeatureManager.allFeatures.mapNotNull { it.config }
|
||||||
val box = WBox(Axis.VERTICAL)
|
val box = WBox(Axis.VERTICAL)
|
||||||
configs.forEach { config ->
|
configs.forEach { config ->
|
||||||
val panel = WGridPanel()
|
val panel = WSplitPanel(
|
||||||
|
WLabel(Text.translatable("firmament.config.${config.name}")),
|
||||||
|
WButton(Text.translatable("firmanent.config.edit")).also {
|
||||||
|
it.setOnClick {
|
||||||
|
config.showConfigEditor(screen)
|
||||||
|
}
|
||||||
|
it.setSize(40, 18)
|
||||||
|
}
|
||||||
|
)
|
||||||
panel.insets = Insets.ROOT_PANEL
|
panel.insets = Insets.ROOT_PANEL
|
||||||
panel.backgroundPainter = BackgroundPainter.VANILLA
|
panel.backgroundPainter = BackgroundPainter.VANILLA
|
||||||
panel.add(WLabel(Text.translatable("firmament.config.${config.name}")), 0, 0, 10, 1)
|
box.add((panel))
|
||||||
panel.add(WButton(Text.translatable("firmanent.config.edit")).also {
|
|
||||||
it.setOnClick {
|
|
||||||
config.showConfigEditor(screen)
|
|
||||||
}
|
|
||||||
}, 0, 1, 10, 1)
|
|
||||||
box.add(WFixedPanel(panel))
|
|
||||||
}
|
}
|
||||||
|
box.streamChildren().asSequence()
|
||||||
|
.forEach { it.setSize(380, 0) }
|
||||||
lwgd.setRootPanel(WBox(
|
lwgd.setRootPanel(WBox(
|
||||||
Axis.VERTICAL
|
Axis.VERTICAL
|
||||||
).also {
|
).also {
|
||||||
it.insets = Insets.ROOT_PANEL
|
it.insets = Insets.ROOT_PANEL
|
||||||
box.layout()
|
box.layout()
|
||||||
it.add(WFixedPanel((WTightScrollPanel((box)).also {
|
it.add(WFixedPanel((WScrollPanel((box)).also {
|
||||||
it.setSize(0, MC.window.scaledHeight / 2)
|
it.setSize(400, 300)
|
||||||
})))
|
})))
|
||||||
it.setSize(0, MC.window.scaledHeight / 2)
|
it.setSize(400, 300)
|
||||||
})
|
})
|
||||||
|
|
||||||
screen = object : CottonClientScreen(lwgd) {
|
screen = object : CottonClientScreen(lwgd) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import moe.nea.firmament.gui.WFixedPanel
|
|||||||
import moe.nea.firmament.gui.WSplitPanel
|
import moe.nea.firmament.gui.WSplitPanel
|
||||||
|
|
||||||
class GuiAppender(val width: Int, val screenAccessor: () -> Screen) {
|
class GuiAppender(val width: Int, val screenAccessor: () -> Screen) {
|
||||||
internal val panel = WBox(Axis.VERTICAL).also {
|
val panel = WBox(Axis.VERTICAL).also {
|
||||||
it.setSize(width, 200)
|
it.setSize(width, 200)
|
||||||
}
|
}
|
||||||
internal val reloadables = mutableListOf<(() -> Unit)>()
|
internal val reloadables = mutableListOf<(() -> Unit)>()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription
|
|||||||
import io.github.cottonmc.cotton.gui.widget.WBox
|
import io.github.cottonmc.cotton.gui.widget.WBox
|
||||||
import io.github.cottonmc.cotton.gui.widget.WButton
|
import io.github.cottonmc.cotton.gui.widget.WButton
|
||||||
import io.github.cottonmc.cotton.gui.widget.WLabel
|
import io.github.cottonmc.cotton.gui.widget.WLabel
|
||||||
|
import io.github.cottonmc.cotton.gui.widget.WScrollPanel
|
||||||
import io.github.cottonmc.cotton.gui.widget.data.Axis
|
import io.github.cottonmc.cotton.gui.widget.data.Axis
|
||||||
import io.github.cottonmc.cotton.gui.widget.data.Insets
|
import io.github.cottonmc.cotton.gui.widget.data.Insets
|
||||||
import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment
|
import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment
|
||||||
@@ -40,6 +41,7 @@ import kotlin.time.Duration
|
|||||||
import net.minecraft.client.gui.screen.Screen
|
import net.minecraft.client.gui.screen.Screen
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import moe.nea.firmament.Firmament
|
import moe.nea.firmament.Firmament
|
||||||
|
import moe.nea.firmament.gui.WTightScrollPanel
|
||||||
import moe.nea.firmament.util.MC
|
import moe.nea.firmament.util.MC
|
||||||
import moe.nea.firmament.util.ScreenUtil.setScreenLater
|
import moe.nea.firmament.util.ScreenUtil.setScreenLater
|
||||||
|
|
||||||
@@ -195,7 +197,7 @@ abstract class ManagedConfig(val name: String) {
|
|||||||
fun getConfigEditor(parent: Screen? = null): CottonClientScreen {
|
fun getConfigEditor(parent: Screen? = null): CottonClientScreen {
|
||||||
val lwgd = LightweightGuiDescription()
|
val lwgd = LightweightGuiDescription()
|
||||||
var screen: Screen? = null
|
var screen: Screen? = null
|
||||||
val guiapp = GuiAppender(400, { requireNotNull(screen) { "Screen Accessor called too early" } })
|
val guiapp = GuiAppender(400) { requireNotNull(screen) { "Screen Accessor called too early" } }
|
||||||
latestGuiAppender = guiapp
|
latestGuiAppender = guiapp
|
||||||
guiapp.panel.insets = Insets.ROOT_PANEL
|
guiapp.panel.insets = Insets.ROOT_PANEL
|
||||||
guiapp.appendFullRow(WBox(Axis.HORIZONTAL).also {
|
guiapp.appendFullRow(WBox(Axis.HORIZONTAL).also {
|
||||||
@@ -210,7 +212,9 @@ abstract class ManagedConfig(val name: String) {
|
|||||||
})
|
})
|
||||||
sortedOptions.forEach { it.appendToGui(guiapp) }
|
sortedOptions.forEach { it.appendToGui(guiapp) }
|
||||||
guiapp.reloadables.forEach { it() }
|
guiapp.reloadables.forEach { it() }
|
||||||
lwgd.setRootPanel(guiapp.panel)
|
lwgd.setRootPanel(WTightScrollPanel(guiapp.panel).also {
|
||||||
|
it.setSize(400, 300)
|
||||||
|
})
|
||||||
screen =
|
screen =
|
||||||
object : CottonClientScreen(lwgd) {
|
object : CottonClientScreen(lwgd) {
|
||||||
override fun init() {
|
override fun init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user