예제 #1
0
        public static bool SetEnableBind(List <AxBind> AxisBinds, string name, bool enable)
        {
            AxBind kBind = AxisBinds.Find(kb => kb.name == name);

            if (kBind != null)
            {
                kBind.disable = !enable; return(true);
            }
            return(false);
        }
예제 #2
0
        public bool AddAxisBind(AxBind axisBind)
        {
            int index = (!string.IsNullOrEmpty(axisBind.name)) ? KeyBinds.FindIndex(kb => kb.name == axisBind.name) : -1;

            if (index < 0)
            {
                AxisBinds.Add(axisBind);
                if (updateText)
                {
                    UpdateCurrentKeyBindText();
                }
                return(true);
            }
            return(false);
        }
예제 #3
0
        public bool RemoveAxisBind(AxBind axBind)
        {
            int index = AxisBinds.IndexOf(axBind);

            if (index < 0)
            {
                return(false);
            }
            axBind.DoAxis(0);
            AxisBinds.RemoveAt(index);
            if (updateText)
            {
                UpdateCurrentKeyBindText();
            }
            return(true);
        }
예제 #4
0
        public static bool HasAxisBind(AxBind axBind)
        {
            int index = axBind != null?Instance.AxisBinds.IndexOf(axBind) : -1;

            return(index >= 0);
        }
예제 #5
0
 public static bool AddListener(AxBind axBind)
 {
     return(Instance.AddAxisBind(axBind));
 }
예제 #6
0
 public static bool RemoveListener(AxBind axBind)
 {
     return(Instance.RemoveAxisBind(axBind));
 }
예제 #7
0
        public string CalcualteCurrentKeyBindText()
        {
            EnsureInitializedKeyBinding();
            StringBuilder sb = new StringBuilder();

            for (int s = 0; s < keyBindGroups.Length; ++s)
            {
                KBindGroup ks = keyBindGroups[s];
                if (ks.allKeyBindings.Count == 0)
                {
                    continue;
                }
                sb.Append("[" + ks.name + "]\n");
                for (int i = 0; i < ks.allKeyBindings.Count; ++i)
                {
                    KBind kb            = ks.allKeyBindings[i];
                    bool  needsPriority = true;
                    bool  hasKeys       = true;
                    if (kb.keyCombinations.Length != 0 && (kb.keyCombinations.Length != 1 || kb.keyCombinations[0].key != KCode.None))
                    {
                        KCombo theseKeys = kb.keyCombinations[0];
                        bool   hasPrev   = i > 0;
                        bool   hasNext   = i < ks.allKeyBindings.Count - 1;
                        KBind  prev      = (hasPrev) ? ks.allKeyBindings[i - 1] : null;
                        KBind  next      = (hasNext) ? ks.allKeyBindings[i + 1] : null;
                        KCombo prevKeys  = hasPrev && prev.keyCombinations.Length > 0 ? prev.keyCombinations[0] : null;
                        KCombo nextKeys  = hasNext && next.keyCombinations.Length > 0 ? next.keyCombinations[0] : null;
                        needsPriority = (prevKeys != null && prevKeys.CompareTo(theseKeys) == 0 ||
                                         nextKeys != null && nextKeys.CompareTo(theseKeys) == 0);
                    }
                    else
                    {
                        hasKeys = false;
                    }
                    if (hasKeys)
                    {
                        sb.Append(kb.ShortDescribe(" | "));
                    }
                    else
                    {
                        sb.Append("(no keys)");
                    }
                    sb.Append(" :");
                    if (needsPriority)
                    {
                        sb.Append(kb.priority.ToString());
                    }
                    sb.Append(": ");
                    sb.Append(kb.name);
                    sb.Append("\n");
                }
            }
            if (AxisBinds.Count > 0)
            {
                sb.Append("[Axis]\n");
                for (int i = 0; i < AxisBinds.Count; ++i)
                {
                    AxBind ab = AxisBinds[i];
                    sb.Append(ab.ShortDescribe(" | "));
                    sb.Append(" :: ");
                    sb.Append(ab.name);
                    sb.Append("\n");
                }
            }
            return(sb.ToString());
        }