mirror of
https://codeberg.org/moonleay/Gimbal.git
synced 2024-11-25 22:22:10 +00:00
feat: add ESC resets mode setting
This commit is contained in:
parent
d59cf8f9f0
commit
dc732cc39f
7 changed files with 35 additions and 3 deletions
|
@ -27,5 +27,6 @@ data class GimbalClientConfig(
|
||||||
val guiSettings: GimbalGuiSettings = GimbalGuiSettings(),
|
val guiSettings: GimbalGuiSettings = GimbalGuiSettings(),
|
||||||
val toastSettings: ToastSettings = ToastSettings.ALL,
|
val toastSettings: ToastSettings = ToastSettings.ALL,
|
||||||
val playerFlySpeed: Int = 100,
|
val playerFlySpeed: Int = 100,
|
||||||
|
val shouldEscResetMode: Boolean = true,
|
||||||
val defaultMode: Mode = Mode.NORMAL
|
val defaultMode: Mode = Mode.NORMAL
|
||||||
)
|
)
|
||||||
|
|
|
@ -55,7 +55,9 @@ object ClientEditor {
|
||||||
this.CURRENT_MODE = config.defaultMode
|
this.CURRENT_MODE = config.defaultMode
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.setMode(config.defaultMode)
|
if (!config.shouldEscResetMode) return
|
||||||
|
this.CURRENT_MODE = config.defaultMode
|
||||||
|
onUpdated()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConnectedToNewWorld() {
|
fun onConnectedToNewWorld() {
|
||||||
|
|
|
@ -88,6 +88,7 @@ class GimbalEditHudGui(private val parent: Screen, private val cfg: ClientConfig
|
||||||
),
|
),
|
||||||
toastSettings = oldConf.toastSettings,
|
toastSettings = oldConf.toastSettings,
|
||||||
playerFlySpeed = oldConf.playerFlySpeed,
|
playerFlySpeed = oldConf.playerFlySpeed,
|
||||||
|
shouldEscResetMode = oldConf.shouldEscResetMode,
|
||||||
defaultMode = oldConf.defaultMode
|
defaultMode = oldConf.defaultMode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
guiSettings = newGui,
|
guiSettings = newGui,
|
||||||
toastSettings = cfg.config.toastSettings,
|
toastSettings = cfg.config.toastSettings,
|
||||||
playerFlySpeed = cfg.config.playerFlySpeed,
|
playerFlySpeed = cfg.config.playerFlySpeed,
|
||||||
|
shouldEscResetMode = cfg.config.shouldEscResetMode,
|
||||||
defaultMode = cfg.config.defaultMode
|
defaultMode = cfg.config.defaultMode
|
||||||
)
|
)
|
||||||
cfg.updateConfig(newConf)
|
cfg.updateConfig(newConf)
|
||||||
|
@ -134,6 +135,7 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
),
|
),
|
||||||
toastSettings = oldConfig.toastSettings,
|
toastSettings = oldConfig.toastSettings,
|
||||||
playerFlySpeed = oldConfig.playerFlySpeed,
|
playerFlySpeed = oldConfig.playerFlySpeed,
|
||||||
|
shouldEscResetMode = oldConfig.shouldEscResetMode,
|
||||||
defaultMode = oldConfig.defaultMode
|
defaultMode = oldConfig.defaultMode
|
||||||
)
|
)
|
||||||
cfg.updateConfig(newConfig)
|
cfg.updateConfig(newConfig)
|
||||||
|
@ -179,6 +181,7 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
guiSettings = oldConfig.guiSettings,
|
guiSettings = oldConfig.guiSettings,
|
||||||
toastSettings = this.toastSettings,
|
toastSettings = this.toastSettings,
|
||||||
playerFlySpeed = oldConfig.playerFlySpeed,
|
playerFlySpeed = oldConfig.playerFlySpeed,
|
||||||
|
shouldEscResetMode = oldConfig.shouldEscResetMode,
|
||||||
defaultMode = oldConfig.defaultMode
|
defaultMode = oldConfig.defaultMode
|
||||||
)
|
)
|
||||||
cfg.updateConfig(newConfig)
|
cfg.updateConfig(newConfig)
|
||||||
|
@ -206,11 +209,33 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
guiSettings = oldConfig.guiSettings,
|
guiSettings = oldConfig.guiSettings,
|
||||||
toastSettings = this.toastSettings,
|
toastSettings = this.toastSettings,
|
||||||
playerFlySpeed = this.playerFlySpeed,
|
playerFlySpeed = this.playerFlySpeed,
|
||||||
|
shouldEscResetMode = oldConfig.shouldEscResetMode,
|
||||||
defaultMode = oldConfig.defaultMode
|
defaultMode = oldConfig.defaultMode
|
||||||
)
|
)
|
||||||
cfg.updateConfig(newConfig)
|
cfg.updateConfig(newConfig)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.addDrawableChild(CyclingButtonWidget.onOffBuilder()
|
||||||
|
.initially(cfg.config.shouldEscResetMode)
|
||||||
|
.build(
|
||||||
|
this.width / 2 - 155,
|
||||||
|
this.height / 6 + 24 * 3,
|
||||||
|
150,
|
||||||
|
20,
|
||||||
|
Text.translatable(TranslationKeys.Gui.Config.SHOULD_ESC_RESET_MODE)
|
||||||
|
) { _: CyclingButtonWidget<Boolean?>?, isEnabled: Boolean? ->
|
||||||
|
val newConf = GimbalClientConfig(
|
||||||
|
guiSettings = cfg.config.guiSettings,
|
||||||
|
toastSettings = cfg.config.toastSettings,
|
||||||
|
playerFlySpeed = cfg.config.playerFlySpeed,
|
||||||
|
shouldEscResetMode = isEnabled?: true,
|
||||||
|
defaultMode = cfg.config.defaultMode
|
||||||
|
)
|
||||||
|
cfg.updateConfig(newConf)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addDrawableChild<CyclingButtonWidget<Mode>>(
|
this.addDrawableChild<CyclingButtonWidget<Mode>>(
|
||||||
CyclingButtonWidget.builder<Mode> { value: Mode? ->
|
CyclingButtonWidget.builder<Mode> { value: Mode? ->
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -222,7 +247,7 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
.initially(this.defaultMode)
|
.initially(this.defaultMode)
|
||||||
.build(
|
.build(
|
||||||
this.width / 2 - 155 + 160,
|
this.width / 2 - 155 + 160,
|
||||||
this.height / 6 + 24 * 2,
|
this.height / 6 + 24 * 3,
|
||||||
150,
|
150,
|
||||||
20,
|
20,
|
||||||
Text.translatable(TranslationKeys.Gui.Config.DEFAULT_MODE)
|
Text.translatable(TranslationKeys.Gui.Config.DEFAULT_MODE)
|
||||||
|
@ -240,6 +265,7 @@ class GimbalSettingsGui(private val parent: Screen, private val cfg: ClientConfi
|
||||||
guiSettings = oldConfig.guiSettings,
|
guiSettings = oldConfig.guiSettings,
|
||||||
toastSettings = oldConfig.toastSettings,
|
toastSettings = oldConfig.toastSettings,
|
||||||
playerFlySpeed = oldConfig.playerFlySpeed,
|
playerFlySpeed = oldConfig.playerFlySpeed,
|
||||||
|
shouldEscResetMode = oldConfig.shouldEscResetMode,
|
||||||
defaultMode = this.defaultMode
|
defaultMode = this.defaultMode
|
||||||
)
|
)
|
||||||
cfg.updateConfig(newConfig)
|
cfg.updateConfig(newConfig)
|
||||||
|
|
|
@ -32,6 +32,7 @@ object TranslationKeys {
|
||||||
const val GENERIC_DISABLED = "${BASE}disabled"
|
const val GENERIC_DISABLED = "${BASE}disabled"
|
||||||
|
|
||||||
const val PLAYER_FLY_SPEED = "${BASE}flySpeed"
|
const val PLAYER_FLY_SPEED = "${BASE}flySpeed"
|
||||||
|
const val SHOULD_ESC_RESET_MODE = "${BASE}shouldESCResetMode"
|
||||||
const val DEFAULT_MODE = "${BASE}defaultMode"
|
const val DEFAULT_MODE = "${BASE}defaultMode"
|
||||||
|
|
||||||
object Hud {
|
object Hud {
|
||||||
|
|
|
@ -56,6 +56,7 @@ class EnUsLanguageProvider(dataGenerator: FabricDataGenerator?) :
|
||||||
|
|
||||||
// Gimbal Generic Settings
|
// Gimbal Generic Settings
|
||||||
translationBuilder.add(TranslationKeys.Gui.Config.PLAYER_FLY_SPEED, "Fly Speed")
|
translationBuilder.add(TranslationKeys.Gui.Config.PLAYER_FLY_SPEED, "Fly Speed")
|
||||||
|
translationBuilder.add(TranslationKeys.Gui.Config.SHOULD_ESC_RESET_MODE, "ESC Resets Mode")
|
||||||
translationBuilder.add(TranslationKeys.Gui.Config.DEFAULT_MODE, "Default Mode")
|
translationBuilder.add(TranslationKeys.Gui.Config.DEFAULT_MODE, "Default Mode")
|
||||||
|
|
||||||
// Gimbal Generic Gui
|
// Gimbal Generic Gui
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class NormalModeMixin {
|
||||||
|
|
||||||
@Inject(method = "openPauseMenu", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "openPauseMenu", at = @At("HEAD"), cancellable = true)
|
||||||
private void setDefaultMode(boolean pause, CallbackInfo ci) {
|
private void setDefaultMode(boolean pause, CallbackInfo ci) {
|
||||||
if (ClientEditor.INSTANCE.isInNonDefaultMode() && ClientEditor.INSTANCE.isAllowed()) {
|
if (ClientMain.CONFIG.getConfig().getShouldEscResetMode() && ClientEditor.INSTANCE.isInNonDefaultMode() && ClientEditor.INSTANCE.isAllowed()) {
|
||||||
assert this.player != null;
|
assert this.player != null;
|
||||||
if (this.player.isCreative()) {
|
if (this.player.isCreative()) {
|
||||||
// Set the editor mode to normal
|
// Set the editor mode to normal
|
||||||
|
|
Loading…
Reference in a new issue