diff --git a/Thrive.csproj b/Thrive.csproj index 674ac09e65f..d074d1efe00 100644 --- a/Thrive.csproj +++ b/Thrive.csproj @@ -37,9 +37,9 @@ - - - + + + diff --git a/src/engine/Settings.cs b/src/engine/Settings.cs index eb3a0c8df8a..629f0739a64 100644 --- a/src/engine/Settings.cs +++ b/src/engine/Settings.cs @@ -193,7 +193,7 @@ private Settings() /// /// The current controls of the game. /// It stores the godot actions like g_move_left and - /// their associated ThriveInputEventWithModifiers + /// their associated ThriveInputEventWithModifiers /// public SettingValue CurrentControls { get; set; } = new SettingValue(InputGroupList.GetDefaultControls()); @@ -400,21 +400,7 @@ public void ApplySoundSettings() /// public void ApplyInputSettings() { - foreach (var action in CurrentControls.Value.Data) - { - // Clear all old input events - InputMap.ActionEraseEvents(action.Key); - - // Add the new input events - foreach (var inputEvent in action.Value) - { - // If the game is waiting for an input - if (inputEvent == null) - return; - - InputMap.ActionAddEvent(action.Key, inputEvent.ToGodotObject()); - } - } + CurrentControls.Value.ApplyToGodotInputMap(); } /// diff --git a/src/engine/input/key_mapping/InputActionItem.cs b/src/engine/input/key_mapping/InputActionItem.cs index 671bc918f4c..14bbd5a21f7 100644 --- a/src/engine/input/key_mapping/InputActionItem.cs +++ b/src/engine/input/key_mapping/InputActionItem.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; +using System.Linq; using Godot; /// -/// Defines one specific input. +/// Defines one input aspect like g_move_forward. /// Each InputActionItem has InputEventItems associated with it. /// public class InputActionItem : VBoxContainer @@ -18,15 +20,15 @@ public class InputActionItem : VBoxContainer [Export] public NodePath InputEventsContainerPath; - /// - /// The group in which this action is defined. - /// - internal InputGroupItem AssociatedGroup; - private Label inputActionHeader; private HBoxContainer inputEventsContainer; private Button addInputEvent; + /// + /// The group in which this action is defined. + /// + public InputGroupItem AssociatedGroup { get; set; } + /// /// The godot specific action name /// @@ -87,6 +89,18 @@ public override int GetHashCode() return InputName != null ? InputName.GetHashCode() : 0; } + internal static InputActionItem BuildGUI(InputGroupItem caller, NamedInputAction data, IEnumerable inputs) + { + var inputActionItem = (InputActionItem)InputGroupList.InputActionItemScene.Instance(); + + inputActionItem.InputName = data.InputName; + inputActionItem.DisplayName = data.Name; + inputActionItem.AssociatedGroup = caller; + inputActionItem.Inputs = new ObservableCollection(inputs.Select(d => InputEventItem.BuildGUI(inputActionItem, d))); + + return inputActionItem; + } + /// /// The small + button has been pressed /// diff --git a/src/engine/input/key_mapping/InputDataList.cs b/src/engine/input/key_mapping/InputDataList.cs index c26f7c61b42..453854f6179 100644 --- a/src/engine/input/key_mapping/InputDataList.cs +++ b/src/engine/input/key_mapping/InputDataList.cs @@ -1,32 +1,55 @@ using System; using System.Collections.Generic; +using Godot; /// -/// Stores an godot input action and its associated events +/// Stores godot input actions and their associated events /// public class InputDataList : ICloneable { - public InputDataList(Dictionary> data) + public InputDataList(Dictionary> data) { Data = data; } - public Dictionary> Data { get; } + public Dictionary> Data { get; } - public List this[string index] => Data[index]; + public List this[string index] => Data[index]; public object Clone() { - var result = new Dictionary>(); + var result = new Dictionary>(); foreach (var keyValuePair in Data) { - result[keyValuePair.Key] = new List(); + result[keyValuePair.Key] = new List(); foreach (var inputEventWithModifiers in keyValuePair.Value) { - result[keyValuePair.Key].Add((ThriveInputEventWithModifiers)inputEventWithModifiers.Clone()); + result[keyValuePair.Key].Add((SpecifiedInputKey)inputEventWithModifiers.Clone()); } } return new InputDataList(result); } + + /// + /// Applies the current controls to the InputMap. + /// + internal void ApplyToGodotInputMap() + { + foreach (var action in Data) + { + // Clear all old input events + InputMap.ActionEraseEvents(action.Key); + + // Add the new input events + foreach (var inputEvent in action.Value) + { + // If the game is waiting for an input + if (inputEvent == null) + return; + + InputMap.ActionAddEvent(action.Key, inputEvent.ToInputEvent()); + } + } + } } diff --git a/src/engine/input/key_mapping/InputEventItem.cs b/src/engine/input/key_mapping/InputEventItem.cs index 2b5e1c165bd..65a51fb73c3 100644 --- a/src/engine/input/key_mapping/InputEventItem.cs +++ b/src/engine/input/key_mapping/InputEventItem.cs @@ -21,10 +21,10 @@ public class InputEventItem : Node public bool WaitingForInput { get; private set; } /// - /// The currently assigned godot input event. + /// The currently assigned input event. /// null if this event was just created /// - public ThriveInputEventWithModifiers AssociatedEvent { get; set; } + public SpecifiedInputKey AssociatedEvent { get; set; } /// /// The action this event is associated with @@ -37,12 +37,12 @@ public class InputEventItem : Node internal bool JustAdded { get; set; } /// - /// Deleted this event from the associated action and updated the godot InputMap + /// Delete this event from the associated action and updated the godot InputMap /// public void Delete() { AssociatedAction.Inputs.Remove(this); - InputGroupList.Instance.ControlsChanged(); + InputGroupList.ControlsChanged(); } public override void _Ready() @@ -65,7 +65,7 @@ public override void _Ready() /// public override void _Input(InputEvent @event) { - if (InputGroupList.Instance.IsConflictDialogOpen()) + if (InputGroupList.IsConflictDialogOpen()) return; if (!WaitingForInput) @@ -99,7 +99,7 @@ public override void _Input(InputEvent @event) return; } - InputGroupList.Instance.WasListeningForInput = true; + InputGroupList.WasListeningForInput = true; WaitingForInput = false; UpdateButtonText(); return; @@ -112,16 +112,16 @@ public override void _Input(InputEvent @event) // The old godot input event. Null if this event is assigned a value the first time. var old = AssociatedEvent; - AssociatedEvent = new ThriveInputEventWithModifiers((InputEventWithModifiers)@event); + AssociatedEvent = new SpecifiedInputKey((InputEventWithModifiers)@event); // Get the conflicts with the new input. - var conflict = InputGroupList.Instance.Conflicts(this); + var conflict = InputGroupList.Conflicts(this); if (conflict != null) { AssociatedEvent = old; // If there are conflicts detected reset the changes and ask the user. - InputGroupList.Instance.ShowInputConflictDialog(this, conflict, (InputEventWithModifiers)@event); + InputGroupList.ShowInputConflictDialog(this, conflict, (InputEventWithModifiers)@event); return; } @@ -142,10 +142,10 @@ public override void _Input(InputEvent @event) WaitingForInput = false; JustAdded = false; - InputGroupList.Instance.WasListeningForInput = false; + InputGroupList.WasListeningForInput = false; // Update the godot InputMap - InputGroupList.Instance.ControlsChanged(); + InputGroupList.ControlsChanged(); // Update the button text UpdateButtonText(); @@ -164,6 +164,14 @@ public override int GetHashCode() return AssociatedEvent.GetHashCode(); } + internal static InputEventItem BuildGUI(InputActionItem caller, SpecifiedInputKey @event) + { + var res = (InputEventItem)InputGroupList.InputEventItemScene.Instance(); + res.AssociatedAction = caller; + res.AssociatedEvent = @event; + return res; + } + protected override void Dispose(bool disposing) { AssociatedAction = null; @@ -174,10 +182,10 @@ protected override void Dispose(bool disposing) private void OnButtonPressed(InputEvent @event) { - if (InputGroupList.Instance.IsConflictDialogOpen()) + if (InputGroupList.IsConflictDialogOpen()) return; - if (InputGroupList.Instance.ListeningForInput) + if (InputGroupList.ListeningForInput) return; if (!(@event is InputEventMouseButton inputButton)) diff --git a/src/engine/input/key_mapping/InputGroupItem.cs b/src/engine/input/key_mapping/InputGroupItem.cs index db863557544..54379647624 100644 --- a/src/engine/input/key_mapping/InputGroupItem.cs +++ b/src/engine/input/key_mapping/InputGroupItem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Godot; /// @@ -24,8 +25,6 @@ public class InputGroupItem : VBoxContainer /// public string GroupName { get; set; } - // ReSharper disable once CollectionNeverUpdated.Global (Reason: Loaded from json) - /// /// The associated actions the group contains /// @@ -51,6 +50,16 @@ public override void _Ready() } } + internal static InputGroupItem BuildGUI(InputGroupList caller, NamedInputGroup data, InputDataList inputData) + { + var result = (InputGroupItem)InputGroupList.InputGroupItemScene.Instance(); + + result.EnvironmentId = data.EnvironmentId.ToList(); + result.GroupName = data.GroupName; + result.Actions = data.Actions.Select(x => InputActionItem.BuildGUI(result, x, inputData[x.InputName])).ToList(); + return result; + } + protected override void Dispose(bool disposing) { inputGroupHeader?.Dispose(); diff --git a/src/engine/input/key_mapping/InputGroupList.cs b/src/engine/input/key_mapping/InputGroupList.cs index 8637396536d..d68a0869994 100644 --- a/src/engine/input/key_mapping/InputGroupList.cs +++ b/src/engine/input/key_mapping/InputGroupList.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using Godot; using Newtonsoft.Json; @@ -17,37 +18,29 @@ public class InputGroupList : VBoxContainer internal static PackedScene InputGroupItemScene; internal static PackedScene InputActionItemScene; - private static IEnumerable allGroupItems; + private static IEnumerable activeInputGroupList; private static InputDataList defaultControls = GetCurrentlyAppliedControls(); - private ConfirmationDialog conflictDialog; + private static bool wasListeningForInput; - private InputEventItem latestDialogCaller; - private InputEventItem latestDialogConflict; - private InputEventWithModifiers latestDialogNewEvent; + private static InputEventItem latestDialogCaller; + private static InputEventItem latestDialogConflict; + private static InputEventWithModifiers latestDialogNewEvent; - private bool wasListeningForInput; - - public InputGroupList() - { - Instance?.Dispose(); - Instance = this; - } + private static ConfirmationDialog conflictDialog; public delegate void ControlsChangedDelegate(InputDataList data); /// /// Fires whenever some inputs were redefined. /// - public event ControlsChangedDelegate OnControlsChanged; - - public static InputGroupList Instance { get; private set; } + public static event ControlsChangedDelegate OnControlsChanged; /// /// If I was listening for inputs. /// Used by the pause menu to not close whenever escape is pressed if the user was redefining keys /// - public bool WasListeningForInput + public static bool WasListeningForInput { get { @@ -61,9 +54,12 @@ public bool WasListeningForInput /// /// Is any Input currently waiting for input /// - public bool ListeningForInput => AllGroupItems.Any(x => x.Actions.Any(y => y.Inputs.Any(z => z.WaitingForInput))); + public static bool ListeningForInput => ActiveInputGroupList + .Any(x => x.Actions + .Any(y => y.Inputs + .Any(z => z.WaitingForInput))); - public IEnumerable AllGroupItems => allGroupItems; + public static IEnumerable ActiveInputGroupList => activeInputGroupList; /// /// Returns the default controls which never change, unless there is a new release. @@ -84,37 +80,16 @@ public static InputDataList GetCurrentlyAppliedControls() return new InputDataList(InputMap.GetActions().OfType() .ToDictionary(p => p, p => InputMap.GetActionList(p).OfType().Select( - x => new ThriveInputEventWithModifiers(x)).ToList())); - } - - /// - /// Loads the input_options and saves it to with the data in the AllGroupItems - /// - public void LoadFromData(InputDataList data) - { - // Load json - try - { - using var file = new File(); - file.Open(Constants.INPUT_OPTIONS, File.ModeFlags.Read); - var fileContent = file.GetAsText(); - var loadedJson = JsonConvert.DeserializeObject>(fileContent); - allGroupItems = loadedJson.Select(p => p.ToGodotObject(data)).ToList(); - file.Close(); - } - catch (Exception e) - { - GD.PrintErr($"Could not load the input settings: {e}"); - } + x => new SpecifiedInputKey(x)).ToList())); } /// /// Returns not only the applied controls, but the controls the user is currently editing before pressing save. /// /// The not applied controls. - public InputDataList GetCurrentlyPendingControls() + public static InputDataList GetCurrentlyPendingControls() { - var groups = AllGroupItems.ToList(); + var groups = ActiveInputGroupList.ToList(); if (!groups.Any()) return GetDefaultControls(); @@ -122,13 +97,25 @@ public InputDataList GetCurrentlyPendingControls() .ToDictionary(p => p.InputName, p => p.Inputs.Select(x => x.AssociatedEvent).ToList())); } - public override void _Ready() + /// + /// Get the input conflict if there are any + /// + /// The event with the new value + /// The collision if any + public static InputEventItem Conflicts(InputEventItem item) { - InputEventItemScene = GD.Load("res://src/engine/input/key_mapping/InputEventItem.tscn"); - InputGroupItemScene = GD.Load("res://src/engine/input/key_mapping/InputGroupItem.tscn"); - InputActionItemScene = GD.Load("res://src/engine/input/key_mapping/InputActionItem.tscn"); + // Get all environments the item is associated with. + var environments = item.AssociatedAction.AssociatedGroup.EnvironmentId; - conflictDialog = GetNode(ConflictDialogPath); + // Take all InputGroups. + // Take the ones with any interception of the environments. + // Take the input actions. + // Get the first action where the event collides or null if there aren't any. + return ActiveInputGroupList.Where(p => p.EnvironmentId.Any(x => environments.Contains(x))) + .SelectMany(p => p.Actions) + .Where(p => !Equals(item.AssociatedAction, p)) + .SelectMany(p => p.Inputs) + .FirstOrDefault(p => Equals(p, item)); } /// @@ -137,7 +124,7 @@ public override void _Ready() /// The event which wants to be redefined /// The event which produced the conflict /// The new event wanted to be set to the caller - public void ShowInputConflictDialog(InputEventItem caller, InputEventItem conflict, + public static void ShowInputConflictDialog(InputEventItem caller, InputEventItem conflict, InputEventWithModifiers newEvent) { latestDialogCaller = caller; @@ -149,73 +136,66 @@ public void ShowInputConflictDialog(InputEventItem caller, InputEventItem confli conflictDialog.PopupCenteredMinsize(); } - /// - /// Get the input conflict if there are any - /// - /// The event with the new value - /// The collision if any - public InputEventItem Conflicts(InputEventItem item) + public static void OnConflictConfirmed() { - // Get all environments the item is associated with. - var environments = item.AssociatedAction.AssociatedGroup.EnvironmentId; + latestDialogConflict.Delete(); + latestDialogCaller._Input(latestDialogNewEvent); + } - // Take all InputGroups. - // Take the ones with any interception of the environments. - // Take the input actions. - // Get the first action where the event collides or null if there aren't any. - return AllGroupItems.Where(p => p.EnvironmentId.Any(x => environments.Contains(x))) - .SelectMany(p => p.Actions) - .Where(p => !Equals(item.AssociatedAction, p)) - .SelectMany(p => p.Inputs) - .FirstOrDefault(p => Equals(p, item)); + public static bool IsConflictDialogOpen() + { + return conflictDialog.Visible; } /// - /// Loads the input_options.json file and sets up the tree. + /// Loads the input_options and saves it to with the data in the AllGroupItems /// - /// The input data the input tab should be loaded with - public void InitFromData(InputDataList data) + public void LoadFromData(InputDataList data) { - foreach (Node child in GetChildren()) + // Load json + try { - RemoveChild(child); + using var file = new File(); + file.Open(Constants.INPUT_OPTIONS, File.ModeFlags.Read); + var fileContent = file.GetAsText(); + var loadedJson = JsonConvert.DeserializeObject>(fileContent); + foreach (var inputGroupItem in activeInputGroupList ?? Array.Empty()) + inputGroupItem.Dispose(); - child.Free(); + activeInputGroupList = BuildGUI(loadedJson, data); + file.Close(); } - - LoadFromData(data); - - foreach (var inputGroup in AllGroupItems) + catch (Exception e) { - AddChild(inputGroup); + GD.PrintErr($"Could not load the input settings: {e}"); } } - public void OnConflictConfirmed() + public override void _Ready() { - latestDialogConflict.Delete(); - latestDialogCaller._Input(latestDialogNewEvent); + InputEventItemScene = GD.Load("res://src/engine/input/key_mapping/InputEventItem.tscn"); + InputGroupItemScene = GD.Load("res://src/engine/input/key_mapping/InputGroupItem.tscn"); + InputActionItemScene = GD.Load("res://src/engine/input/key_mapping/InputActionItem.tscn"); + + conflictDialog = GetNode(ConflictDialogPath); } - public bool IsConflictDialogOpen() + /// + /// Loads the input_options.json file and sets up the tree. + /// + /// The input data the input tab should be loaded with + public void InitFromData(InputDataList data) { - return conflictDialog.Visible; + LoadFromData(data); } - internal void ControlsChanged() + internal static void ControlsChanged() { OnControlsChanged?.Invoke(GetCurrentlyPendingControls()); } - protected override void Dispose(bool disposing) + private IEnumerable BuildGUI(IEnumerable loadedJson, InputDataList data) { - foreach (var inputGroupItem in AllGroupItems) - { - inputGroupItem.Dispose(); - } - - conflictDialog?.Dispose(); - - base.Dispose(disposing); + return loadedJson.Select(p => InputGroupItem.BuildGUI(this, p, data)).ToList(); } } diff --git a/src/engine/input/key_mapping/NamedInputAction.cs b/src/engine/input/key_mapping/NamedInputAction.cs new file mode 100644 index 00000000000..3640546f0a2 --- /dev/null +++ b/src/engine/input/key_mapping/NamedInputAction.cs @@ -0,0 +1,5 @@ +public class NamedInputAction +{ + public string InputName { get; set; } + public string Name { get; set; } +} diff --git a/src/engine/input/key_mapping/NamedInputGroup.cs b/src/engine/input/key_mapping/NamedInputGroup.cs new file mode 100644 index 00000000000..800ffd8d01f --- /dev/null +++ b/src/engine/input/key_mapping/NamedInputGroup.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +public class NamedInputGroup +{ + public string GroupName { get; set; } + public IReadOnlyList EnvironmentId { get; set; } + public IReadOnlyList Actions { get; set; } +} diff --git a/src/engine/input/key_mapping/ThriveInputEventWithModifiers.cs b/src/engine/input/key_mapping/SpecifiedInputKey.cs similarity index 84% rename from src/engine/input/key_mapping/ThriveInputEventWithModifiers.cs rename to src/engine/input/key_mapping/SpecifiedInputKey.cs index 9707e5a9207..48cdf52117b 100644 --- a/src/engine/input/key_mapping/ThriveInputEventWithModifiers.cs +++ b/src/engine/input/key_mapping/SpecifiedInputKey.cs @@ -1,13 +1,13 @@ using System; using Godot; -public class ThriveInputEventWithModifiers : ICloneable +public class SpecifiedInputKey : ICloneable { - public ThriveInputEventWithModifiers() + public SpecifiedInputKey() { } - public ThriveInputEventWithModifiers(InputEventWithModifiers @event) + public SpecifiedInputKey(InputEventWithModifiers @event) { Control = @event.Control; Alt = @event.Alt; @@ -40,9 +40,7 @@ public enum InputType /// /// Creates a string for the button to show. /// - /// - /// A human readable string. - /// + /// A human readable string. public override string ToString() { var text = string.Empty; @@ -78,28 +76,30 @@ public override string ToString() return text; } - public InputEventWithModifiers ToGodotObject() + public InputEventWithModifiers ToInputEvent() { - InputEventWithModifiers res = Type switch + InputEventWithModifiers result = Type switch { InputType.Key => new InputEventKey { Scancode = Code }, InputType.MouseButton => new InputEventMouseButton { ButtonIndex = (int)Code }, _ => throw new NotSupportedException("Unsupported InputType given"), }; - res.Alt = Alt; - res.Control = Control; - res.Shift = Shift; - return res; + + result.Alt = Alt; + result.Control = Control; + result.Shift = Shift; + return result; } public object Clone() { - return new ThriveInputEventWithModifiers + return new SpecifiedInputKey { Alt = Alt, Code = Code, Control = Control, Shift = Shift, + Type = Type, }; } @@ -109,7 +109,7 @@ public override bool Equals(object obj) return false; if (ReferenceEquals(this, obj)) return true; - if (!(obj is ThriveInputEventWithModifiers other)) + if (!(obj is SpecifiedInputKey other)) return false; return Control == other.Control && diff --git a/src/engine/input/key_mapping/serialisation/NamedInputAction.cs b/src/engine/input/key_mapping/serialisation/NamedInputAction.cs deleted file mode 100644 index 6070f353a90..00000000000 --- a/src/engine/input/key_mapping/serialisation/NamedInputAction.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -public class NamedInputAction -{ - public string InputName { get; set; } - public string Name { get; set; } - - public InputActionItem ToGodotObject(IEnumerable data, InputGroupItem caller) - { - var result = (InputActionItem)InputGroupList.InputActionItemScene.Instance(); - - result.InputName = InputName; - result.DisplayName = Name; - result.AssociatedGroup = caller; - result.Inputs = new ObservableCollection(data.Select(p => - { - var res = (InputEventItem)InputGroupList.InputEventItemScene.Instance(); - res.AssociatedAction = result; - res.AssociatedEvent = p; - return res; - })); - - return result; - } -} diff --git a/src/engine/input/key_mapping/serialisation/NamedInputGroup.cs b/src/engine/input/key_mapping/serialisation/NamedInputGroup.cs deleted file mode 100644 index 7d27298d9cf..00000000000 --- a/src/engine/input/key_mapping/serialisation/NamedInputGroup.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -public class NamedInputGroup -{ - public string GroupName { get; set; } - public IReadOnlyList EnvironmentId { get; set; } - public IReadOnlyList Actions { get; set; } - - public InputGroupItem ToGodotObject(InputDataList data) - { - var result = (InputGroupItem)InputGroupList.InputGroupItemScene.Instance(); - - result.EnvironmentId = EnvironmentId.ToList(); - result.GroupName = GroupName; - result.Actions = Actions.Select(p => p.ToGodotObject(data[p.InputName], result)).ToList(); - - return result; - } -} diff --git a/src/general/OptionsMenu.cs b/src/general/OptionsMenu.cs index 9f9b73cc4f5..8767cdf401e 100644 --- a/src/general/OptionsMenu.cs +++ b/src/general/OptionsMenu.cs @@ -312,7 +312,7 @@ public override void _Ready() // Inputs inputsTab = GetNode(InputsTabPath); inputGroupList = GetNode(InputGroupListPath); - inputGroupList.InitFromData(Settings.Instance.CurrentControls); + InitInputGroupList(); // Misc miscTab = GetNode(MiscTabPath); @@ -422,7 +422,7 @@ public void ApplySettingsToControls(Settings settings) runAutoEvoDuringGameplay.Pressed = settings.RunAutoEvoDuringGamePlay; // Input - inputGroupList.OnControlsChanged += OnControlsChanged; + InputGroupList.OnControlsChanged += OnControlsChanged; // Misc playIntro.Pressed = settings.PlayIntroVideo; @@ -1025,7 +1025,19 @@ private void OnTutorialsEnabledToggled(bool pressed) private void InitInputGroupList() { - InputGroupList.Instance.InitFromData(Settings.Instance.CurrentControls); + foreach (Node child in inputGroupList.GetChildren()) + { + inputGroupList.RemoveChild(child); + + child.Free(); + } + + inputGroupList.InitFromData(Settings.Instance.CurrentControls); + + foreach (var inputGroup in InputGroupList.ActiveInputGroupList) + { + inputGroupList.AddChild(inputGroup); + } } private void OnCustomUsernameEnabledToggled(bool pressed) diff --git a/src/general/PauseMenu.cs b/src/general/PauseMenu.cs index c8da4eff23a..26727a0c043 100644 --- a/src/general/PauseMenu.cs +++ b/src/general/PauseMenu.cs @@ -76,7 +76,7 @@ public override void _UnhandledInput(InputEvent @event) if (Visible) { // Do not close the window if the user is rebinding the input keys - if (InputGroupList.Instance.WasListeningForInput) + if (InputGroupList.WasListeningForInput) return; SetActiveMenu("primary"); diff --git a/src/gui_common/MainMenu.cs b/src/gui_common/MainMenu.cs index 1968e728d40..edc129334c4 100644 --- a/src/gui_common/MainMenu.cs +++ b/src/gui_common/MainMenu.cs @@ -129,7 +129,6 @@ private void RunMenuSetup() saves = GetNode("SaveManagerGUI"); gles2Popup = GetNode(GLES2PopupPath); - // Set initial menu // Set initial menu SwitchMenu();