コード例 #1
0
ファイル: BindManager.cs プロジェクト: oldrock674/wowmapper
        public static void ResetDefaults(int profile)
        {
            CurrentKeybinds.Clear();
            CurrentKeybinds.AddRange(Defaults.KeybindStyles.GetDefault(Properties.Settings.Default.ModifierStyle));

            Properties.Settings.Default.ModifierStyle = profile;
            SaveBindings();
            BindingsChanged?.Invoke(null, EventArgs.Empty);
        }
コード例 #2
0
ファイル: BindManager.cs プロジェクト: oldrock674/wowmapper
        public static void SetKey(GamepadButton button, Key key)
        {
            var binding = CurrentKeybinds.First(bind => bind.BindType == button);

            binding.Key = key;

            SaveBindings();
            BindingsChanged?.Invoke(null, EventArgs.Empty);

            Properties.Settings.Default.BindingsModified = DateTime.Now;
            BindWriter.WriteBinds();
        }
コード例 #3
0
        public DynamicBindingMapper(IConfiguration config)
        {
            var folder = config["BindingsFolder"];

            // Watch for any new binding files coming in or being changed
            _allBindingFileWatcher = new CustomFileWatcher(folder, "*.binds");

            // When they do, make sure we've read and parsed the file and add it to our list.
            // This lets us switch as soon as the value in StartPreset.start changes, without
            // having to scan all the files again to find the one with that name.
            _allBindingSubscription = _allBindingFileWatcher.CreatedFiles
                                      .Merge(_allBindingFileWatcher.ChangedFiles)
                                      .Subscribe(x =>
            {
                // Load the .binds file
                var updatedBinding = BindingMapper.FromFile(Path.Combine(folder, x));
                var presetName     = updatedBinding.GetPresetName();
                _allBindingsByPresetName[presetName] = updatedBinding;

                // If we've seen a change in the current selected preset, then refresh everyone
                if (string.Equals(presetName, _currentSelectedPresetName))
                {
                    BindingsChanged?.Invoke(this, EventArgs.Empty);
                }
            });

            // Now start raising file events
            _allBindingFileWatcher.Start();

            // Watch for a new preset being selected
            _selectedBindingFileWatcher = new CustomFileWatcher(folder, "StartPreset.start");

            // When it does, switch to that binding set, and notify clients
            _selectedBindingSubscription = _selectedBindingFileWatcher.CreatedFiles
                                           .Merge(_selectedBindingFileWatcher.ChangedFiles)
                                           // FileWatcher can still produce multiple notifications for the same thing. For that matter,
                                           // users may flick through a few selection before setting. Throttle the updates.
                                           .Throttle(TimeSpan.FromSeconds(3))
                                           .Subscribe(x =>
            {
                Log.Info("Checking for new binding preset");
                _currentSelectedPresetName = ReadStartPreset(Path.Combine(folder, x));
                Log.Info($"Selecting binding preset {_currentSelectedPresetName}");
                // Refresh everyone's list of available bindings
                BindingsChanged?.Invoke(this, EventArgs.Empty);
            });

            // Now start raising file events
            _selectedBindingFileWatcher.Start();
        }
コード例 #4
0
 public void Clear(int index)
 {
     _bindings[index] = null;
     BindingsChanged?.Invoke();
 }
コード例 #5
0
 public void Set(ICharacter character, IAbility ability, int index)
 {
     _bindings[index] = character.Abilities.ToList().IndexOf(ability);
     BindingsChanged?.Invoke();
 }