mirror of
https://codeberg.org/moonleay/Gimbal.git
synced 2024-11-25 22:22:10 +00:00
feat: added option and config for player fly speed
Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
19f4b3649a
commit
b4f46ee703
6 changed files with 39 additions and 8 deletions
|
@ -25,4 +25,5 @@ import net.moonleay.gimbal.client.config.enums.ToastSettings
|
|||
data class GimbalClientConfig(
|
||||
val guiSettings: GimbalGuiSettings = GimbalGuiSettings(),
|
||||
val toastSettings: ToastSettings = ToastSettings.ALL,
|
||||
val playerFlySpeed: Int = 0,
|
||||
)
|
||||
|
|
|
@ -45,7 +45,6 @@ object ClientEditor {
|
|||
|
||||
private val CURRENT_MODE_MODIFIER = mutableListOf<ModeModifier>()
|
||||
private val TEMP_DISABLED_MODIFIERS = mutableListOf<ModeModifier>()
|
||||
|
||||
private val DISABLED_MODIFIERS_STORAGE = mutableListOf<ModeModifier>()
|
||||
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ class GimbalEditHudGui(private val parent: Screen, private val cfg: ClientConfig
|
|||
verticalAnchor = anchor.second,
|
||||
hudOptions = oldConf.guiSettings.hudOptions
|
||||
),
|
||||
toastSettings = oldConf.toastSettings
|
||||
toastSettings = oldConf.toastSettings,
|
||||
playerFlySpeed = oldConf.playerFlySpeed
|
||||
)
|
||||
|
||||
cfg.updateConfig(newConf)
|
||||
|
|
|
@ -29,6 +29,8 @@ import net.moonleay.gimbal.client.config.GimbalClientConfig
|
|||
import net.moonleay.gimbal.client.config.GimbalGuiSettings
|
||||
import net.moonleay.gimbal.client.config.enums.HudOptions
|
||||
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
|
||||
|
||||
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 toastSettings: ToastSettings
|
||||
private var playerFlySpeed: Int
|
||||
|
||||
init {
|
||||
this.hudOptions = cfg.config.guiSettings.hudOptions
|
||||
this.toastSettings = cfg.config.toastSettings
|
||||
this.playerFlySpeed = cfg.config.playerFlySpeed
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
@ -65,7 +69,8 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
|||
)
|
||||
val newConf = GimbalClientConfig(
|
||||
guiSettings = newGui,
|
||||
toastSettings = cfg.config.toastSettings
|
||||
toastSettings = cfg.config.toastSettings,
|
||||
playerFlySpeed = cfg.config.playerFlySpeed
|
||||
)
|
||||
cfg.updateConfig(newConf)
|
||||
})
|
||||
|
@ -123,7 +128,8 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
|||
offset = oldGuiConfig.offset,
|
||||
hudOptions = this.hudOptions
|
||||
),
|
||||
toastSettings = oldConfig.toastSettings
|
||||
toastSettings = oldConfig.toastSettings,
|
||||
playerFlySpeed = oldConfig.playerFlySpeed
|
||||
)
|
||||
cfg.updateConfig(newConfig)
|
||||
}
|
||||
|
@ -166,14 +172,33 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
|||
val oldConfig = cfg.config
|
||||
val newConfig = GimbalClientConfig(
|
||||
guiSettings = oldConfig.guiSettings,
|
||||
toastSettings = this.toastSettings
|
||||
toastSettings = this.toastSettings,
|
||||
playerFlySpeed = oldConfig.playerFlySpeed
|
||||
)
|
||||
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
|
||||
this.addDrawableChild(ButtonWidget(
|
||||
|
|
|
@ -31,6 +31,8 @@ object TranslationKeys {
|
|||
const val GENERIC_ENABLED = "${BASE}enabled"
|
||||
const val GENERIC_DISABLED = "${BASE}disabled"
|
||||
|
||||
const val PLAYER_FLY_SPEED = "${BASE}flySpeed"
|
||||
|
||||
object Hud {
|
||||
const val BASE = "${TranslationKeys.Gui.Config.BASE}hud."
|
||||
|
||||
|
|
|
@ -50,10 +50,13 @@ class En_us_GimbalLanguageProvider(dataGenerator: FabricDataGenerator?) :
|
|||
//Gimbal 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_TOGGLE, "Only toggle")
|
||||
translationBuilder.add(TranslationKeys.Gui.Config.Toasts.SHOW_SYSTEM, "Only system")
|
||||
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_NONE, "None")
|
||||
|
||||
// Gimbal Generic Settings
|
||||
translationBuilder.add(TranslationKeys.Gui.Config.PLAYER_FLY_SPEED, "Fly Speed")
|
||||
|
||||
// Gimbal Generic Gui
|
||||
translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_ENABLED, "Enabled")
|
||||
translationBuilder.add(TranslationKeys.Gui.Config.GENERIC_DISABLED, "Disabled")
|
||||
|
|
Loading…
Reference in a new issue