diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt index 9f4ca05..bcc1ce1 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt @@ -9,6 +9,7 @@ import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabeticall import fr.username404.snowygui.gui.feature.Category import fr.username404.snowygui.gui.feature.Colors import fr.username404.snowygui.gui.feature.Macro +import fr.username404.snowygui.gui.feature.Keystrokes import fr.username404.snowygui.gui.feature.riskyCheats import fr.username404.snowygui.gui.feature.Zoom import net.minecraft.client.gui.screens.Screen @@ -60,6 +61,11 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) { startBooleanToggle(TranslatableComponent("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer { Zoom.smoothCameraOnZoom = it Zoom.execAction() + }.build(), + startEnumSelector(TranslatableComponent("$confPrefix.behavior.keystrokes.position"), Keystrokes.Position::class.java, Keystrokes.Position.values().find { + it.value == Keystrokes.currentPosition + }).setSaveConsumer { + Keystrokes.currentPosition = it.value }.build() ) ) diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt index 18b34d3..49b9286 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt @@ -107,7 +107,7 @@ object Configuration { ModifiableValues.entries.fold(this) { previous, entry -> previous.withValue(entry.key, entry.value.let { ConfigValueFactory.fromAnyRef( - if (it !is Lazy<*>) ConfigValueFactory.fromAnyRef(it) else it.value + if (it !is Lazy<*>) it else it.value ) }) } @@ -141,7 +141,9 @@ object Configuration { when { Number::class.isSuperclassOf(T::class) -> when (T::class) { Double::class -> 2.0 - Int::class, UInt::class, Short::class, UShort::class -> 2 + Int::class, UInt::class, + Short::class, UShort::class, + Long::class, ULong::class -> 2 Float::class -> 2F else -> throw e } as T diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Keystrokes.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Keystrokes.kt index 349f255..c44a55d 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Keystrokes.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Keystrokes.kt @@ -1,6 +1,7 @@ package fr.username404.snowygui.gui.feature import com.mojang.blaze3d.vertex.PoseStack +import fr.username404.snowygui.config.Configuration import fr.username404.snowygui.gui.ColoredElement import fr.username404.snowygui.gui.Renderable import fr.username404.snowygui.utils.FontUtil @@ -9,7 +10,14 @@ import net.minecraft.client.Minecraft @ButtonInfo(Category.HUD) object Keystrokes: ButtonImplWithHud() { + var currentPosition: Double by Configuration; internal set + @Suppress("UNUSED") + enum class Position(internal val value: Double) { + LEFT(180.0), + RIGHT(-120.0) + } private val hud = object : ColoredElement(x = 135.0, y = 20.0, height = 36, width = 36, color = Colors.BLACK(), opacity = 0.5F) { + override var x: Double get() = (Minecraft.getInstance().window.guiScaledWidth / 2.0) - currentPosition; set(value) = Unit override var y: Double get() = Minecraft.getInstance().window.guiScaledHeight.toDouble() - yOrigin set(value) = Unit @@ -59,4 +67,9 @@ object Keystrokes: ButtonImplWithHud() { override val hudRenderLambda = Renderable { hud.display(it) } + init { + if (!Position.values().map { it.value }.contains(currentPosition)) { + currentPosition = Position.LEFT.value + } + } } \ No newline at end of file