private void load(KeyBindingStore store) { var enumType = Defaults?.FirstOrDefault()?.Action?.GetType(); if (enumType == null) { return; } // for now let's just assume a variant of zero. // this will need to be implemented in a better way in the future. int?variant = null; if (Ruleset != null) { variant = 0; } var bindings = store.Query(Ruleset?.ID, variant); foreach (Enum v in Enum.GetValues(enumType)) { // one row per valid action. Add(new KeyBindingRow(v, bindings.Where(b => b.Action.Equals((int)(object)v))) { AllowMainMouseButtons = Ruleset != null }); } }
protected override void ReloadMappings() { if (ruleset != null && !ruleset.ID.HasValue) { // if the provided ruleset is not stored to the database, we have no way to retrieve custom bindings. // fallback to defaults instead. KeyBindings = DefaultKeyBindings; } else { KeyBindings = store.Query(ruleset?.ID, variant).ToList(); } }
protected override void ReloadMappings() { var defaults = DefaultKeyBindings.ToList(); if (ruleset != null && !ruleset.ID.HasValue) { // if the provided ruleset is not stored to the database, we have no way to retrieve custom bindings. // fallback to defaults instead. KeyBindings = defaults; } else { KeyBindings = store.Query(ruleset?.ID, variant) // this ordering is important to ensure that we read entries from the database in the order // enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise // have been eaten by the music controller due to query order. .OrderBy(b => defaults.FindIndex(d => (int)d.Action == b.IntAction)).ToList(); } }
private void load(KeyBindingStore store) { var bindings = store.Query(Ruleset?.ID, variant); foreach (var defaultGroup in Defaults.GroupBy(d => d.Action)) { // one row per valid action. Add(new KeyBindingRow(defaultGroup.Key, bindings.Where(b => b.Action.Equals((int)defaultGroup.Key))) { AllowMainMouseButtons = Ruleset != null, Defaults = defaultGroup.Select(d => d.KeyCombination) }); } Add(new ResetButton { Action = () => Children.OfType <KeyBindingRow>().ForEach(k => k.RestoreDefaults()) }); }
protected override void ReloadMappings() => KeyBindings = store.Query(ruleset?.ID, variant).ToList();
protected override void ReloadMappings() { KeyBindings = store.Query(ruleset?.ID, variant); }