aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-12 17:02:08 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-12 17:02:08 +0100
commitb774daef5bd961f955d365ce07bd5aa4acb161f4 (patch)
tree8e5f8f92593f8c594cc25592901342cc8923cee9 /src/main/kotlin/util
parent9763a4caa44fb6629aae92f3ad696487d962b0d9 (diff)
downloadFirmament-b774daef5bd961f955d365ce07bd5aa4acb161f4.tar.gz
Firmament-b774daef5bd961f955d365ce07bd5aa4acb161f4.tar.bz2
Firmament-b774daef5bd961f955d365ce07bd5aa4acb161f4.zip
feat: MoulConfig config gui
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/MoulConfigUtils.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/util/MoulConfigUtils.kt b/src/main/kotlin/util/MoulConfigUtils.kt
index 54528dd..2e52092 100644
--- a/src/main/kotlin/util/MoulConfigUtils.kt
+++ b/src/main/kotlin/util/MoulConfigUtils.kt
@@ -234,6 +234,19 @@ object MoulConfigUtils {
// TODO: move this utility into moulconfig (also rework guicontext into an interface so i can make this mesh better into vanilla)
fun GuiContext.adopt(element: GuiComponent) = element.foldRecursive(Unit, { comp, unit -> comp.context = this })
+ inline fun <T, R> GetSetter<T>.xmap(crossinline fromT: (T) -> R, crossinline toT: (R) -> T): GetSetter<R> {
+ val outer = this
+ return object : GetSetter<R> {
+ override fun get(): R {
+ return fromT(outer.get())
+ }
+
+ override fun set(newValue: R) {
+ outer.set(toT(newValue))
+ }
+ }
+ }
+
fun clickMCComponentInPlace(
component: GuiComponent,
x: Int,