aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-31 21:27:07 +0200
committernea <nea@nea.moe>2023-07-31 21:27:07 +0200
commitc3e1bab941f47dfd5ef5c55805015ee5d47da802 (patch)
treeb4db354834ad01260b2c544ae6bfe7e73de00a07 /src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt
parentd8ee0c458a31352eefdb2100a53c3af268b2bb53 (diff)
downloadfirmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.tar.gz
firmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.tar.bz2
firmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.zip
Improve config gui handling
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt b/src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt
index bf25691..e5d2621 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/config/DurationHandler.kt
@@ -1,5 +1,6 @@
package moe.nea.firmament.gui.config
+import io.github.cottonmc.cotton.gui.widget.WBox
import io.github.cottonmc.cotton.gui.widget.WLabel
import io.github.cottonmc.cotton.gui.widget.WSlider
import io.github.cottonmc.cotton.gui.widget.data.Axis
@@ -27,20 +28,11 @@ class DurationHandler(val config: ManagedConfig, val min: Duration, val max: Dur
}
override fun emitGuiElements(opt: ManagedConfig.Option<Duration>, guiAppender: GuiAppender) {
- val lw = guiAppender.width / 2
- guiAppender.set(
- 0, 0, lw, 1,
- WLabel(opt.labelText).setVerticalAlignment(VerticalAlignment.CENTER)
- )
val label =
WLabel(Text.literal(FirmFormatters.formatTimespan(opt.value))).setVerticalAlignment(VerticalAlignment.CENTER)
- guiAppender.set(lw, 0, 2, 1, label)
- guiAppender.set(
- lw + 2,
- 0,
- lw - 2,
- 1,
- WSlider(min.inWholeMilliseconds.toInt(), max.inWholeMilliseconds.toInt(), Axis.HORIZONTAL).apply {
+ guiAppender.appendLabeledRow(opt.labelText, WBox(Axis.HORIZONTAL).also {
+ it.add(label, 40, 18)
+ it.add(WSlider(min.inWholeMilliseconds.toInt(), max.inWholeMilliseconds.toInt(), Axis.HORIZONTAL).apply {
valueChangeListener = IntConsumer {
opt.value = it.milliseconds
label.text = Text.literal(FirmFormatters.formatTimespan(opt.value))
@@ -50,8 +42,8 @@ class DurationHandler(val config: ManagedConfig, val min: Duration, val max: Dur
value = opt.value.inWholeMilliseconds.toInt()
label.text = Text.literal(FirmFormatters.formatTimespan(opt.value))
}
- })
- guiAppender.skipRows(1)
+ }, 130, 18)
+ })
}
}