fix: unsubscribe VisibilityChanged in _ExitTree, use IsActionReleased for ui_cancel, expose ApplyGamepadDeadzone public

This commit is contained in:
2026-03-19 03:51:01 +01:00
parent 38c86f1a67
commit 829d081eab
5 changed files with 6 additions and 8 deletions

View File

@@ -149,7 +149,7 @@ public partial class SettingsManager : Node
}
}
private void ApplyGamepadDeadzone()
public void ApplyGamepadDeadzone()
{
foreach (var action in DeadzoneActions)
{

View File

@@ -73,11 +73,7 @@ public partial class GameplaySettings : Control
private void OnDeadzoneChanged(double value)
{
SettingsManager.Instance.GamepadDeadzone = (float)value;
foreach (var action in new[] { "left", "right", "up", "down" })
{
if (InputMap.HasAction(action))
InputMap.ActionSetDeadzone(action, (float)value);
}
SettingsManager.Instance.ApplyGamepadDeadzone();
DeadzoneValueLabel.Text = $"{value:F2}";
SaveSettings();
}

View File

@@ -48,6 +48,7 @@ public partial class MainMenu : Control
{
if (InputDeviceManager.Instance != null)
InputDeviceManager.Instance.DeviceChanged -= OnDeviceChanged;
VisibilityChanged -= OnVisibilityChanged;
}
private void OnVisibilityChanged()

View File

@@ -57,7 +57,7 @@ public partial class Marketplace : Control
public override void _Input(InputEvent @event)
{
if (@event.IsActionPressed("ui_cancel") && IsVisible())
if (@event.IsActionReleased("ui_cancel") && IsVisible())
{
Hide();
foreach (var c in ComponentsToDisable) c.ProcessMode = ProcessModeEnum.Inherit;

View File

@@ -43,6 +43,7 @@ public partial class SettingsMenu : Control
{
if (InputDeviceManager.Instance != null)
InputDeviceManager.Instance.DeviceChanged -= OnDeviceChanged;
VisibilityChanged -= OnVisibilityChanged;
}
private void OnVisibilityChanged()
@@ -62,7 +63,7 @@ public partial class SettingsMenu : Control
public override void _UnhandledInput(InputEvent @event)
{
if (!@event.IsActionPressed("ui_cancel")) return;
if (!@event.IsActionReleased("ui_cancel")) return;
if (UIManager.IsScreenOnTop(SettingsMenuControl)) UIManager.PopScreen();
}