Fix the keystrokes positions completely, and add a setting to the cloth config screen to move them

This commit is contained in:
Username404 2021-07-18 17:14:49 +02:00
parent 95408f6546
commit 27bbaef032
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
3 changed files with 23 additions and 2 deletions

View File

@ -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()
)
)

View File

@ -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

View File

@ -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
}
}
}