Exemplo n.º 1
0
        bool SetBinding(Enum key, UniversalInputType type)
        {
            //InputNode node = InputManager.GetNode(currentKey);
            InputNode node      = draftNodes[currentKey];
            string    keyString = type.ToString() + "." + key.ToString();

            // Check for conflicts with previous bindings.
            UniversalInputCombo ic = new UniversalInputCombo(keyString);

            for (int i = 0; i < currentKey; i++)
            {
                if (draftNodes[i].Conflict(ic))
                {
                    //SoundManager.PlaySound("hit2");
                    conflictTimer = 3;
                    return(false);
                }
            }

            // Write the new binding.
            node.SetCombo(keyString);
            InputManager.UpdateAliases();

            currentKey++;
            //SoundManager.PlaySound("tap2");
            conflictTimer = 0;
            return(true);
        }
Exemplo n.º 2
0
        public void FinalizeKeybinds()
        {
            if (!success)
            {
                return;
            }

            // Remove all conflicting old bindings.
            for (int i = 0; i < (int)GameCommand.MenuUp; i++)
            {
                InputNode           draftNode  = draftNodes[i];
                UniversalInputCombo draftCombo = draftNode.InternalInputCombos[0];
                for (int j = 0; j < (int)GameCommand.MenuUp; j++)
                {
                    InputNode node = InputManager.GetNode(j);
                    for (int k = 0; k < node.InternalInputCombos.Count; k++)
                    {
                        UniversalInputCombo combo = node.InternalInputCombos[k];
                        if (i == j && combo.GetInputType() == draftCombo.GetInputType())
                        {
                            node.InternalInputCombos.RemoveAt(k);
                            k--;
                            continue;
                        }
                        if (combo.ToString() == draftCombo.ToString())
                        {
                            node.InternalInputCombos.RemoveAt(k);
                            k--;
                            continue;
                        }
                    }
                }
            }

            // Add in new bindings.
            for (int i = 0; i < (int)GameCommand.MenuUp; i++)
            {
                InputManager.GetNode(i).AddCombo(draftNodes[i].InternalInputCombos[0].ToString());
            }

            InputManager.AskSetControls = false;
            InputManager.SaveConfig();
            InputManager.UpdateAliases();
        }