[#modding] Method to get key assigned from command only return the first value found.```cs...

Issue #5022 resolved
Freehold Games Bot Account created an issue

Marked for crossposting by: helado, who knits the icy cream

Message (jump):

<ZoraZ> Method to get key assigned from command only return the first value found.
cs // XRL.UI.LegacyKeyMapping.cs public static int GetKeyFromCommand(string Cmd) { foreach (KeyValuePair<string, Dictionary<string, int>> keyValuePair in LegacyKeyMapping.CurrentMap.PrimaryMapCommandToKeyLayer) { int result; if (keyValuePair.Value.TryGetValue(Cmd, out result)) { return result; } } foreach (KeyValuePair<string, Dictionary<string, int>> keyValuePair2 in LegacyKeyMapping.CurrentMap.SecondaryMapCommandToKeyLayer) { int result2; if (keyValuePair2.Value.TryGetValue(Cmd, out result2)) { return result2; } } return 0; }
So when I try to check keys press, it only works for the user-assigned primary key, the secondary one get ignored completely. As far as I dig the files there's no way around this so I have to write a util method myself, something like:
cs public static (int, int) GetAllKeysFromCommand(string Cmd) { int primary = 0; int secondary = 0; foreach (KeyValuePair<string, Dictionary<string, int>> keyValuePair in LegacyKeyMapping.CurrentMap.PrimaryMapCommandToKeyLayer) { if (keyValuePair.Value.TryGetValue(Cmd, out primary)) { break; } } foreach (KeyValuePair<string, Dictionary<string, int>> keyValuePair2 in LegacyKeyMapping.CurrentMap.SecondaryMapCommandToKeyLayer) { if (keyValuePair2.Value.TryGetValue(Cmd, out secondary)) { break; } } return (primary, secondary); }

Comments (6)

  1. Log in to comment