Example #1
0
        internal override void Load(InputMap savedMap)
        {
            if (savedMap is ButtonMap == false)
            {
                throw new Exception("ButtonMap attempting to load type other than ButtonMap");
            }

            ButtonMap savedButtonMap = savedMap as ButtonMap;

            foreach (ButtonBinding saved in savedButtonMap.ButtonBindings.Values)
            {
                if (this.ButtonBindings.ContainsKey(saved.Alias))
                {
                    ButtonBinding binding = ButtonBindings[saved.Alias];

                    if (binding.GetType().Equals(saved) == false)
                    {
                        throw new Exception("Error loading Button Bindings: Saved binding is not a same type as default binding");
                    }


                    if (binding is KeyBinding)
                    {
                        KeyBinding kb    = binding as KeyBinding;
                        KeyBinding other = saved as KeyBinding;
                        kb.Key       = other.Key;
                        kb.Modifiers = other.Modifiers;
                    }
                    else if (binding is GamePadButtonBinding)
                    {
                        GamePadButtonBinding gb    = binding as GamePadButtonBinding;
                        GamePadButtonBinding other = saved as GamePadButtonBinding;
                        gb.Button = other.Button;
                    }
                    else
                    {
                        throw new Exception("Unknown ButtonBinding type being loaded. Did you add a new type and forget to handle loading?");
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Adds controls (custom tab pages containing keybindingControls) for displaying each keybinding
        /// </summary>
        public void AddKeyBindingGuiControls()
        {
            for (int kmi = 0; kmi < keyMaps.inputMaps.Count; kmi++)
            {
                FlowLayoutTabPage fltp = new FlowLayoutTabPage();
                tcControlGroups.TabPages.Add(fltp);
                InputMap im = keyMaps.inputMaps.Values[kmi];
                if (im is ButtonMap == false)
                {
                    continue;
                }
                ButtonMap bm = im as ButtonMap;
                fltp.Text = bm.Alias;
                foreach (Input.KeyBinding kb in bm.ButtonBindings.Values)
                {
                    KeyBindingControl kbc = new KeyBindingControl(kb);

                    fltp.AddControl(kbc);
                }
            }
        }
Example #3
0
 public ButtonMap(ButtonMap other)
     : this(other.Alias)
 {
     ButtonBindings = new SortedList <string, ButtonBinding>(other.ButtonBindings);
 }