Set duplicates flag for hotkeys in HotkeyManager
This commit is contained in:
committed by
abcdefg30
parent
38f5d2c100
commit
ad02adff3e
@@ -20,7 +20,7 @@ namespace OpenRA
|
|||||||
public readonly Hotkey Default = Hotkey.Invalid;
|
public readonly Hotkey Default = Hotkey.Invalid;
|
||||||
public readonly string Description = "";
|
public readonly string Description = "";
|
||||||
public readonly HashSet<string> Types = new HashSet<string>();
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
public bool HasDuplicates = false;
|
public bool HasDuplicates { get; internal set; }
|
||||||
|
|
||||||
public HotkeyDefinition(string name, MiniYaml node)
|
public HotkeyDefinition(string name, MiniYaml node)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace OpenRA
|
|||||||
if (definitions.ContainsKey(kv.Key))
|
if (definitions.ContainsKey(kv.Key))
|
||||||
keys[kv.Key] = kv.Value;
|
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<Hotkey> GetHotkeyReference(string name)
|
internal Func<Hotkey> GetHotkeyReference(string name)
|
||||||
@@ -65,6 +68,20 @@ namespace OpenRA
|
|||||||
settings[name] = value;
|
settings[name] = value;
|
||||||
else
|
else
|
||||||
settings.Remove(name);
|
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)
|
public HotkeyDefinition GetFirstDuplicate(string name, Hotkey value, HotkeyDefinition definition)
|
||||||
|
|||||||
@@ -490,9 +490,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (selectedHotkeyDefinition == null)
|
if (selectedHotkeyDefinition == null)
|
||||||
selectedHotkeyDefinition = hd;
|
selectedHotkeyDefinition = hd;
|
||||||
|
|
||||||
if (modData.Hotkeys.GetFirstDuplicate(hd.Name, modData.Hotkeys[hd.Name].GetValue(), hd) != null)
|
|
||||||
hd.HasDuplicates = true;
|
|
||||||
|
|
||||||
BindHotkeyPref(hd, template, hotkeyList);
|
BindHotkeyPref(hd, template, hotkeyList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -801,9 +798,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
WidgetUtils.TruncateButtonToTooltip(selectedHotkeyButton, hotkeyEntryWidget.Key.DisplayString());
|
WidgetUtils.TruncateButtonToTooltip(selectedHotkeyButton, hotkeyEntryWidget.Key.DisplayString());
|
||||||
modData.Hotkeys.Set(selectedHotkeyDefinition.Name, hotkeyEntryWidget.Key);
|
modData.Hotkeys.Set(selectedHotkeyDefinition.Name, hotkeyEntryWidget.Key);
|
||||||
Game.Settings.Save();
|
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()
|
void ResetHotkey()
|
||||||
|
|||||||
Reference in New Issue
Block a user