aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-31 19:38:38 +0200
committernea <nea@nea.moe>2023-08-31 21:22:26 +0200
commitcb032e7c221e40736ab26b193eea4e32d06113d9 (patch)
treee49047b3b78fb9887d72cbe9458af44ecbc179d4 /src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt
parentb7b01f1c6fbf889ae9bfcdb5b34c5ccfa48d5ba0 (diff)
downloadfirmament-cb032e7c221e40736ab26b193eea4e32d06113d9.tar.gz
firmament-cb032e7c221e40736ab26b193eea4e32d06113d9.tar.bz2
firmament-cb032e7c221e40736ab26b193eea4e32d06113d9.zip
Add price tooltips
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/config/ManagedConfig.kt25
1 files changed, 16 insertions, 9 deletions
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<SavedKeyBinding> = keyBindingWithDefaultModifiers(propertyName) { SavedKeyBinding(default()) }
+ ): ManagedOption<SavedKeyBinding> = keyBindingWithOutDefaultModifiers(propertyName) { SavedKeyBinding(default()) }
- protected fun keyBindingWithDefaultModifiers(
+ protected fun keyBindingWithOutDefaultModifiers(
propertyName: String,
default: () -> SavedKeyBinding,
): ManagedOption<SavedKeyBinding> {
return option(propertyName, default, KeyBindingHandler("firmament.config.${name}.${propertyName}", this))
}
+ protected fun keyBindingWithDefaultUnbound(
+ propertyName: String,
+ ): ManagedOption<SavedKeyBinding> {
+ return keyBindingWithOutDefaultModifiers(propertyName) { SavedKeyBinding(GLFW.GLFW_KEY_UNKNOWN) }
+ }
+
protected fun integer(
propertyName: String,
min: Int,