From cb032e7c221e40736ab26b193eea4e32d06113d9 Mon Sep 17 00:00:00 2001 From: nea Date: Thu, 31 Aug 2023 19:38:38 +0200 Subject: Add price tooltips --- .../moe/nea/firmament/gui/config/ManagedConfig.kt | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/main/kotlin/moe/nea/firmament/gui') diff --git a/src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt b/src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt index 8743293..8e05632 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt @@ -14,22 +14,23 @@ import io.github.cottonmc.cotton.gui.widget.WLabel 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.VerticalAlignment +import moe.nea.jarvis.api.Point +import org.lwjgl.glfw.GLFW import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonObject +import kotlin.io.path.createDirectories +import kotlin.io.path.readText +import kotlin.io.path.writeText +import kotlin.time.Duration +import net.minecraft.client.gui.screen.Screen +import net.minecraft.text.Text import moe.nea.firmament.Firmament import moe.nea.firmament.gui.WTightScrollPanel import moe.nea.firmament.keybindings.SavedKeyBinding import moe.nea.firmament.util.MC import moe.nea.firmament.util.ScreenUtil.setScreenLater -import moe.nea.jarvis.api.Point -import net.minecraft.client.gui.screen.Screen -import net.minecraft.text.Text -import kotlin.io.path.createDirectories -import kotlin.io.path.readText -import kotlin.io.path.writeText -import kotlin.time.Duration abstract class ManagedConfig(override val name: String) : ManagedConfigElement() { @@ -110,15 +111,21 @@ abstract class ManagedConfig(override val name: String) : ManagedConfigElement() protected fun keyBinding( propertyName: String, default: () -> Int, - ): ManagedOption = keyBindingWithDefaultModifiers(propertyName) { SavedKeyBinding(default()) } + ): ManagedOption = keyBindingWithOutDefaultModifiers(propertyName) { SavedKeyBinding(default()) } - protected fun keyBindingWithDefaultModifiers( + protected fun keyBindingWithOutDefaultModifiers( propertyName: String, default: () -> SavedKeyBinding, ): ManagedOption { return option(propertyName, default, KeyBindingHandler("firmament.config.${name}.${propertyName}", this)) } + protected fun keyBindingWithDefaultUnbound( + propertyName: String, + ): ManagedOption { + return keyBindingWithOutDefaultModifiers(propertyName) { SavedKeyBinding(GLFW.GLFW_KEY_UNKNOWN) } + } + protected fun integer( propertyName: String, min: Int, -- cgit