From b774daef5bd961f955d365ce07bd5aa4acb161f4 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 12 Nov 2024 17:02:08 +0100 Subject: feat: MoulConfig config gui --- src/main/kotlin/util/MoulConfigUtils.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main/kotlin/util/MoulConfigUtils.kt') 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 GetSetter.xmap(crossinline fromT: (T) -> R, crossinline toT: (R) -> T): GetSetter { + val outer = this + return object : GetSetter { + override fun get(): R { + return fromT(outer.get()) + } + + override fun set(newValue: R) { + outer.set(toT(newValue)) + } + } + } + fun clickMCComponentInPlace( component: GuiComponent, x: Int, -- cgit