summaryrefslogtreecommitdiff
path: root/src/SMAPI/Utilities/KeybindList.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Utilities/KeybindList.cs')
-rw-r--r--src/SMAPI/Utilities/KeybindList.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/SMAPI/Utilities/KeybindList.cs b/src/SMAPI/Utilities/KeybindList.cs
index 7b2c396b..18eeb9fd 100644
--- a/src/SMAPI/Utilities/KeybindList.cs
+++ b/src/SMAPI/Utilities/KeybindList.cs
@@ -1,7 +1,6 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using StardewModdingAPI.Toolkit.Serialization;
@@ -42,7 +41,7 @@ namespace StardewModdingAPI.Utilities
/// <exception cref="FormatException">The <paramref name="input"/> format is invalid.</exception>
public static KeybindList Parse(string input)
{
- return KeybindList.TryParse(input, out KeybindList parsed, out string[] errors)
+ return KeybindList.TryParse(input, out KeybindList? parsed, out string[] errors)
? parsed
: throw new SParseException($"Can't parse {nameof(Keybind)} from invalid value '{input}'.\n{string.Join("\n", errors)}");
}
@@ -51,7 +50,7 @@ namespace StardewModdingAPI.Utilities
/// <param name="input">The keybind string. See remarks on <see cref="ToString"/> for format details.</param>
/// <param name="parsed">The parsed keybind list, if valid.</param>
/// <param name="errors">The errors that occurred while parsing the input, if any.</param>
- public static bool TryParse(string input, out KeybindList parsed, out string[] errors)
+ public static bool TryParse(string input, [NotNullWhen(true)] out KeybindList? parsed, out string[] errors)
{
// empty input
if (string.IsNullOrWhiteSpace(input))
@@ -69,7 +68,7 @@ namespace StardewModdingAPI.Utilities
if (string.IsNullOrWhiteSpace(rawSet))
continue;
- if (!Keybind.TryParse(rawSet, out Keybind keybind, out string[] curErrors))
+ if (!Keybind.TryParse(rawSet, out Keybind? keybind, out string[] curErrors))
rawErrors.AddRange(curErrors);
else
keybinds.Add(keybind);
@@ -151,7 +150,7 @@ namespace StardewModdingAPI.Utilities
}
/// <summary>Get the keybind which is currently down, if any. If there are multiple keybinds down, the first one is returned.</summary>
- public Keybind GetKeybindCurrentlyDown()
+ public Keybind? GetKeybindCurrentlyDown()
{
return this.Keybinds.FirstOrDefault(p => p.GetState().IsDown());
}