Remove Exts.Enum<T>

This functionality is now built in. We can rely on the built in functions rather than a custom class.
This commit is contained in:
RoosterDragon
2025-11-20 20:09:13 +00:00
committed by Gustas Kažukauskas
parent 00cd438190
commit e652f95be9
6 changed files with 20 additions and 46 deletions

View File

@@ -27,25 +27,21 @@ namespace OpenRA
public static bool TryParse(string s, out Hotkey result)
{
result = Invalid;
if (string.IsNullOrWhiteSpace(s))
if (s == null)
return false;
var parts = s.Split(' ');
Span<Range> ranges = stackalloc Range[2];
var span = s.AsSpan();
var count = span.Split(ranges, ' ');
if (count == 0)
return false;
if (!Enum<Keycode>.TryParse(parts[0], true, out var key))
{
if (!int.TryParse(parts[0], out var c))
return false;
key = (Keycode)c;
}
if (!Enum.TryParse(span[ranges[0]], true, out Keycode key))
return false;
var mods = Modifiers.None;
if (parts.Length >= 2)
{
var modString = s[s.IndexOf(' ')..];
if (!Enum<Modifiers>.TryParse(modString, true, out mods))
return false;
}
if (count == 2 && !Enum.TryParse(span[ranges[1]], true, out mods))
return false;
result = new Hotkey(key, mods);
return true;