feat: added option and config for player fly speed

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2024-05-16 03:31:41 +02:00
parent 19f4b3649a
commit b4f46ee703
Signed by: moonleay
GPG key ID: 82667543CCD715FB
6 changed files with 39 additions and 8 deletions

View file

@ -25,4 +25,5 @@ import net.moonleay.gimbal.client.config.enums.ToastSettings
data class GimbalClientConfig( data class GimbalClientConfig(
val guiSettings: GimbalGuiSettings = GimbalGuiSettings(), val guiSettings: GimbalGuiSettings = GimbalGuiSettings(),
val toastSettings: ToastSettings = ToastSettings.ALL, val toastSettings: ToastSettings = ToastSettings.ALL,
val playerFlySpeed: Int = 0,
) )

View file

@ -45,7 +45,6 @@ object ClientEditor {
private val CURRENT_MODE_MODIFIER = mutableListOf<ModeModifier>() private val CURRENT_MODE_MODIFIER = mutableListOf<ModeModifier>()
private val TEMP_DISABLED_MODIFIERS = mutableListOf<ModeModifier>() private val TEMP_DISABLED_MODIFIERS = mutableListOf<ModeModifier>()
private val DISABLED_MODIFIERS_STORAGE = mutableListOf<ModeModifier>() private val DISABLED_MODIFIERS_STORAGE = mutableListOf<ModeModifier>()

View file

@ -86,7 +86,8 @@ class GimbalEditHudGui(private val parent: Screen, private val cfg: ClientConfig
verticalAnchor = anchor.second, verticalAnchor = anchor.second,
hudOptions = oldConf.guiSettings.hudOptions hudOptions = oldConf.guiSettings.hudOptions
), ),
toastSettings = oldConf.toastSettings toastSettings = oldConf.toastSettings,
playerFlySpeed = oldConf.playerFlySpeed
) )
cfg.updateConfig(newConf) cfg.updateConfig(newConf)

View file

@ -29,6 +29,8 @@ import net.moonleay.gimbal.client.config.GimbalClientConfig
import net.moonleay.gimbal.client.config.GimbalGuiSettings import net.moonleay.gimbal.client.config.GimbalGuiSettings
import net.moonleay.gimbal.client.config.enums.HudOptions import net.moonleay.gimbal.client.config.enums.HudOptions
import net.moonleay.gimbal.client.config.enums.ToastSettings import net.moonleay.gimbal.client.config.enums.ToastSettings
import net.moonleay.gimbal.client.screen.widgets.GimbalSliderWidget
import net.moonleay.gimbal.client.util.NumberUtil
import net.moonleay.gimbal.constants.TranslationKeys import net.moonleay.gimbal.constants.TranslationKeys
class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfigHolder) : class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfigHolder) :
@ -36,10 +38,12 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
private var hudOptions: HudOptions private var hudOptions: HudOptions
private var toastSettings: ToastSettings private var toastSettings: ToastSettings
private var playerFlySpeed: Int
init { init {
this.hudOptions = cfg.config.guiSettings.hudOptions this.hudOptions = cfg.config.guiSettings.hudOptions
this.toastSettings = cfg.config.toastSettings this.toastSettings = cfg.config.toastSettings
this.playerFlySpeed = cfg.config.playerFlySpeed
} }
override fun init() { override fun init() {
@ -65,7 +69,8 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
) )
val newConf = GimbalClientConfig( val newConf = GimbalClientConfig(
guiSettings = newGui, guiSettings = newGui,
toastSettings = cfg.config.toastSettings toastSettings = cfg.config.toastSettings,
playerFlySpeed = cfg.config.playerFlySpeed
) )
cfg.updateConfig(newConf) cfg.updateConfig(newConf)
}) })
@ -123,7 +128,8 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
offset = oldGuiConfig.offset, offset = oldGuiConfig.offset,
hudOptions = this.hudOptions hudOptions = this.hudOptions
), ),
toastSettings = oldConfig.toastSettings toastSettings = oldConfig.toastSettings,
playerFlySpeed = oldConfig.playerFlySpeed
) )
cfg.updateConfig(newConfig) cfg.updateConfig(newConfig)
} }
@ -166,14 +172,33 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
val oldConfig = cfg.config val oldConfig = cfg.config
val newConfig = GimbalClientConfig( val newConfig = GimbalClientConfig(
guiSettings = oldConfig.guiSettings, guiSettings = oldConfig.guiSettings,
toastSettings = this.toastSettings toastSettings = this.toastSettings,
playerFlySpeed = oldConfig.playerFlySpeed
) )
cfg.updateConfig(newConfig) cfg.updateConfig(newConfig)
} }
) )
this.addDrawableChild(GimbalSliderWidget(
this.width / 2 - 155,
this.height / 6 + 24 * 2,
150,
20,
Text.translatable(TranslationKeys.Gui.Config.PLAYER_FLY_SPEED),
NumberUtil.interpolate(this.playerFlySpeed.toDouble(), 50.0, 500.0, 0.0, 1.0),
50.0,
500.0,
) { value ->
this.playerFlySpeed = NumberUtil.interpolate(value, 0.0, 1.0, 50.0, 500.0).toInt()
val oldConfig = cfg.config
val newConfig = GimbalClientConfig(
guiSettings = oldConfig.guiSettings,
toastSettings = this.toastSettings,
playerFlySpeed = this.playerFlySpeed
)
cfg.updateConfig(newConfig)
})
// Done button // Done button
this.addDrawableChild(ButtonWidget( this.addDrawableChild(ButtonWidget(

View file

@ -31,6 +31,8 @@ object TranslationKeys {
const val GENERIC_ENABLED = "${BASE}enabled" const val GENERIC_ENABLED = "${BASE}enabled"
const val GENERIC_DISABLED = "${BASE}disabled" const val GENERIC_DISABLED = "${BASE}disabled"
const val PLAYER_FLY_SPEED = "${BASE}flySpeed"
object Hud { object Hud {
const val BASE = "${TranslationKeys.Gui.Config.BASE}hud." const val BASE = "${TranslationKeys.Gui.Config.BASE}hud."

View file

@ -50,10 +50,13 @@ class En_us_GimbalLanguageProvider(dataGenerator: FabricDataGenerator?) :
//Gimbal Toasts //Gimbal Toasts
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_TOASTS, "Show Toasts") translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_TOASTS, "Show Toasts")
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_ALL, "All") translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_ALL, "All")
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_TOGGLE, "Only toggle") translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_TOGGLE, "Only Toggle")
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_SYSTEM, "Only system") translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_SYSTEM, "Only System")
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_NONE, "None") translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_NONE, "None")
// Gimbal Generic Settings
translationBuilder.add(TranslationKeys.Gui.Config.PLAYER_FLY_SPEED, "Fly Speed")
// Gimbal Generic Gui // Gimbal Generic Gui
translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_ENABLED, "Enabled") translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_ENABLED, "Enabled")
translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_DISABLED, "Disabled") translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_DISABLED, "Disabled")