Ejemplo n.º 1
0
 public static void CheckBinds()
 {
     if (Console.keyDetection != "")
     {
         return;
     }
     foreach (var item in Console.binds)
     {
         Bind data = item.Value;
         if (Console.status > 0 && !data.action.Contains("console", true))
         {
             continue;
         }
         bool keyDown = Button.EventKeyUp(data.key);
         if (keyDown && data.repeat && data.nextRepeat > Time.Get())
         {
             Console.AddCommand(data.action);
             data.nextRepeat += Time.Get() + data.repeatDelay;
         }
         else if (data.toggle)
         {
             if (data.toggleActive)
             {
                 Console.AddCommand(data.action);
             }
             if (keyDown && data.released)
             {
                 data.toggleActive = !data.toggleActive;
             }
         }
         else if (keyDown && data.released)
         {
             Console.AddCommand(data.action);
         }
         if (Console.lastCommand.Matches(data.action, true))
         {
             Event.current.Use();
         }
         data.released = !keyDown;
     }
 }
Ejemplo n.º 2
0
        public static void SaveBinds()
        {
            string bindString = "";

            foreach (var item in Console.binds)
            {
                Bind data = item.Value;
                bindString += data.name + "-" + data.action;
                if (data.repeat)
                {
                    bindString += "-" + data.repeatDelay;
                }
                bindString += "|";
            }
            if (Console.Get().configFile == "")
            {
                bindString = bindString.Trim('|') + "|";
                PlayerPref.Set <string>("binds", bindString);
            }
            else
            {
                Console.configOutput.Add(bindString.Replace("-", " ").Replace("|", "\r\n"));
            }
        }