Ejemplo n.º 1
0
 /// <summary>
 /// Lets you know if the specified modifier is pressed
 /// </summary>
 /// <param name="modifier">You can either specify just one Modifier or combine multiple (with |)</param>
 /// <returns></returns>
 public static bool IsControlModifierPressed(ControlModifier modifier)
 {
     if (modifier == ControlModifier.Any)
     {
         return(true);
     }
     else
     {
         ControlModifier BitMask = 0;
         ModifierFlagToKeyCode.ToList().ForEach(w =>
         {
             if (Game.IsControlPressed(defaultControlGroup, (Control)w.Value))
             {
                 BitMask = BitMask | w.Key;
             }
         });
         if (BitMask == modifier)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Waits until a user releases a key or until the specified timeout time is reached
        /// </summary>
        /// <param name="control">The <see cref="Control"/> that is wanting to be waited for release</param>
        /// <param name="modifier">The <see cref="ControlModifier"/> of the current bind</param>
        /// <param name="timeout">How long the wait should be before until the loop is existed</param>
        /// <returns>Returns if the player held the control for longer than the specified time</returns>
        public static async Task <bool> WaitForKeyRelease(Control control, ControlModifier modifier = ControlModifier.None, int timeout = 1000)
        {
            var currentTicks = Game.GameTime + 1;

            await BaseScript.Delay(0);

            while (IsControlPressed(control, true, modifier) && Game.GameTime - currentTicks < timeout)
            {
                await BaseScript.Delay(0);
            }

            return(Game.GameTime - currentTicks >= timeout);
        }
 public ControlSetting(Control control, bool keyboardOnly = true, ControlModifier modifier = ControlModifier.None)
 {
     this.Control      = control;
     this.Modifier     = modifier;
     this.KeyboardOnly = keyboardOnly;
 }
Ejemplo n.º 4
0
 public static bool IsDisabledControlPressed(Control control, bool keyboardOnly = true, ControlModifier modifier = ControlModifier.None)
 {
     return(Game.IsDisabledControlPressed(0, control) && (!keyboardOnly || (keyboardOnly && !WasLastInputFromController())) && IsControlModifierPressed(modifier));
 }