diff --git a/OpenRA.Game/HotkeyDefinition.cs b/OpenRA.Game/HotkeyDefinition.cs index c228185f0b..ee43b4e79d 100644 --- a/OpenRA.Game/HotkeyDefinition.cs +++ b/OpenRA.Game/HotkeyDefinition.cs @@ -20,7 +20,7 @@ namespace OpenRA public readonly Hotkey Default = Hotkey.Invalid; public readonly string Description = ""; public readonly HashSet Types = new HashSet(); - public bool HasDuplicates = false; + public bool HasDuplicates { get; internal set; } public HotkeyDefinition(string name, MiniYaml node) { diff --git a/OpenRA.Game/HotkeyManager.cs b/OpenRA.Game/HotkeyManager.cs index 432b32b721..68d3fc0382 100644 --- a/OpenRA.Game/HotkeyManager.cs +++ b/OpenRA.Game/HotkeyManager.cs @@ -38,6 +38,9 @@ namespace OpenRA if (definitions.ContainsKey(kv.Key)) keys[kv.Key] = kv.Value; } + + foreach (var hd in definitions) + hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value.Name, this[hd.Value.Name].GetValue(), hd.Value) != null; } internal Func GetHotkeyReference(string name) @@ -65,6 +68,20 @@ namespace OpenRA settings[name] = value; else settings.Remove(name); + + var hadDuplicates = definition.HasDuplicates; + definition.HasDuplicates = GetFirstDuplicate(definition.Name, this[definition.Name].GetValue(), definition) != null; + + if (hadDuplicates || definition.HasDuplicates) + { + foreach (var hd in definitions) + { + if (hd.Value == definition) + continue; + + hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value.Name, this[hd.Value.Name].GetValue(), hd.Value) != null; + } + } } public HotkeyDefinition GetFirstDuplicate(string name, Hotkey value, HotkeyDefinition definition) diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 205ca1cdf5..9683816b04 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -490,9 +490,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (selectedHotkeyDefinition == null) selectedHotkeyDefinition = hd; - if (modData.Hotkeys.GetFirstDuplicate(hd.Name, modData.Hotkeys[hd.Name].GetValue(), hd) != null) - hd.HasDuplicates = true; - BindHotkeyPref(hd, template, hotkeyList); } } @@ -801,9 +798,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic WidgetUtils.TruncateButtonToTooltip(selectedHotkeyButton, hotkeyEntryWidget.Key.DisplayString()); modData.Hotkeys.Set(selectedHotkeyDefinition.Name, hotkeyEntryWidget.Key); Game.Settings.Save(); - - foreach (var hd in modData.Hotkeys.Definitions) - hd.HasDuplicates = modData.Hotkeys.GetFirstDuplicate(hd.Name, modData.Hotkeys[hd.Name].GetValue(), hd) != null; } void ResetHotkey()