예제 #1
0
        private void AEnabled_CheckedChanged(object sender, EventArgs e)
        {
            if (!updatingUI)
            {
                SingleDisabledKey data = new SingleDisabledKey
                {
                    KD_Player = (Player)this.KeyControlTarget.SelectedIndex,
                    KD_Key = Key.A,
                    Enabled = AEnabled.Checked
                };

                if (!data.Enabled)
                {
                    bool temp = updatingUI;
                    updatingUI = true;
                    AllControlsEnabled.Checked = false;
                    updatingUI = temp;
                }

                Messenger<SingleDisabledKey>.Broadcast("SingleKeyControlEnabled", data);
            }
        }
예제 #2
0
        /// <summary>
        /// If a key is disabled it is added to the Dictionary.
        /// If a key is enabled it is removed from the Dictionary.
        /// There is a Dictionary for All and one for each Player.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="key"></param>
        /// <param name="enabled"></param>
        private void ToggleKeyControl(SingleDisabledKey data)
        {
            if (data.KD_Player == Player.All)
            {
                // If the Key is for all players we have to update all dictionaries.
                for (int i = 0; i < Enum.GetNames(typeof(Player)).Length; i++)
                {
                    #region toggle
                    if (data.Enabled)
                    {
                        if (DisabledControls[i].ContainsKey((int)data.KD_Key))
                            DisabledControls[i].Remove((int)data.KD_Key);
                    }
                    else
                    {
                        if (!DisabledControls[i].ContainsKey((int)data.KD_Key))
                            DisabledControls[i].Add((int)data.KD_Key, data.KD_Key);
                    }
                    #endregion
                }
            }
            else
            {
                // If the Key is only for one player we dont have to worry about looping.
                #region toggle
                if (data.Enabled)
                {
                    //Messenger<string>.Broadcast("SomethingMagical", "ToggleKeyControl: Enable key");
                    if (DisabledControls[(int)data.KD_Player].ContainsKey((int)data.KD_Key))
                        DisabledControls[(int)data.KD_Player].Remove((int)data.KD_Key);
                }
                else
                {
                    //Messenger<string>.Broadcast("SomethingMagical", "ToggleKeyControl: Disable Key");
                    if (!DisabledControls[(int)data.KD_Player].ContainsKey((int)data.KD_Key))
                        DisabledControls[(int)data.KD_Player].Add((int)data.KD_Key, data.KD_Key);
                }
                #endregion

            }
        }