示例#1
0
        /// <summary>
        /// Set a Rage.GameControl to control a menu only on a specific index.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="gtaControl"></param>
        /// <param name="controlIndex"></param>
        public void SetKey(Common.MenuControls control, GameControl gtaControl, int controlIndex)
        {
            if (_keyDictionary.ContainsKey(control))
                _keyDictionary[control].Item2.Add(new Tuple<GameControl, int>(gtaControl, controlIndex));
            else
            {
                _keyDictionary.Add(control,
                    new Tuple<List<Keys>, List<Tuple<GameControl, int>>>(new List<Keys>(), new List<Tuple<GameControl, int>>()));
                _keyDictionary[control].Item2.Add(new Tuple<GameControl, int>(gtaControl, controlIndex));
            }

        }
示例#2
0
 /// <summary>
 /// Remove all controls on a control.
 /// </summary>
 /// <param name="control"></param>
 public void ResetKey(Common.MenuControls control)
 {
     _keyDictionary[control].Item1.Clear();
     _keyDictionary[control].Item2.Clear();
 }
示例#3
0
 /// <summary>
 /// Set a key to control a menu. Can be multiple keys for each control.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="keyToSet"></param>
 public void SetKey(Common.MenuControls control, Keys keyToSet)
 {
     if (_keyDictionary.ContainsKey(control))
         _keyDictionary[control].Item1.Add(keyToSet);
     else
     {
         _keyDictionary.Add(control,
             new Tuple<List<Keys>, List<Tuple<GameControl, int>>>(new List<Keys>(), new List<Tuple<GameControl, int>>()));
         _keyDictionary[control].Item1.Add(keyToSet);
     }
 }
示例#4
0
 /// <summary>
 /// Set a Rage.GameControl to control a menu. Can be multiple controls. This applies it to all indexes.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="gtaControl"></param>
 public void SetKey(Common.MenuControls control, GameControl gtaControl)
 {
     SetKey(control, gtaControl, 0);
     SetKey(control, gtaControl, 1);
     SetKey(control, gtaControl, 2);
 }
示例#5
0
        /// <summary>
        /// Check whether a menucontrol has been released.
        /// </summary>
        /// <param name="control">Control to check for.</param>
        /// <param name="key">Key if you're using keys.</param>
        /// <returns></returns>
        public bool HasControlJustBeenReleaseed(Common.MenuControls control, Keys key = Keys.None)
        {
            List<Keys> tmpKeys = new List<Keys>(_keyDictionary[control].Item1);
            List<Tuple<GameControl, int>> tmpControls = new List<Tuple<GameControl, int>>(_keyDictionary[control].Item2);

            if (key != Keys.None)
            {
                if (tmpKeys.Any(Game.IsKeyDown))
                    return true;
            }
            if (tmpControls.Any(tuple => Game.IsControlJustReleased(tuple.Item2, tuple.Item1) || Common.IsDisabledControlJustReleased(tuple.Item2, tuple.Item1)))
                return true;
            return false;
        }
示例#6
0
 /// <summary>
 /// Check whether a menucontrol is being pressed.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool IsControlBeingPressed(Common.MenuControls control, Keys key = Keys.None)
 {
     List<Keys> tmpKeys = new List<Keys>(_keyDictionary[control].Item1);
     List<Tuple<GameControl, int>> tmpControls = new List<Tuple<GameControl, int>>(_keyDictionary[control].Item2);
     if (HasControlJustBeenReleaseed(control, key)) _controlCounter = 0;
     if (_controlCounter > 0)
     {
         _controlCounter++;
         if (_controlCounter > 30)
             _controlCounter = 0;
         return false;
     }
     if (key != Keys.None)
     {
         if (tmpKeys.Any(Game.IsKeyDown))
         {
             _controlCounter = 1;
             return true;
         }
     }
     if (tmpControls.Any(tuple => Game.IsControlPressed(tuple.Item2, tuple.Item1) || Common.IsDisabledControlPressed(tuple.Item2, tuple.Item1)))
     {
         _controlCounter = 1;
         return true;
     }
     return false;
 }
示例#7
0
        /// <summary>
        /// Check whether a menucontrol has been pressed.
        /// </summary>
        /// <param name="control">Control to check for.</param>
        /// <param name="key">Key if you're using keys.</param>
        /// <returns></returns>
        public bool HasControlJustBeenPressed(Common.MenuControls control, Keys key = Keys.None)
        {
            List<Keys> tmpKeys = new List<Keys>(_keyDictionary[control].Item1);
            List<Tuple<Control, int>> tmpControls = new List<Tuple<Control, int>>(_keyDictionary[control].Item2);

            if (key != Keys.None)
            {
                if (tmpKeys.Any(Game.IsKeyPressed))
                    return true;
            }
            if (tmpControls.Any(tuple => Game.IsControlJustPressed(tuple.Item2, tuple.Item1)))
                return true;
            return false;
        }
示例#8
0
 public void SetKey(Common.MenuControls menuControl, Keys control)
 {
     _menuList.ForEach(m => m.SetKey(menuControl, control));
 }
示例#9
0
 public void SetKey(Common.MenuControls menuControl, GameControl control, int controllerIndex)
 {
     _menuList.ForEach(m => m.SetKey(menuControl, control, controllerIndex));
 }
示例#10
0
 public void ResetKey(Common.MenuControls menuControl)
 {
     _menuList.ForEach(m => m.ResetKey(menuControl));
 }
示例#11
0
        /// <summary>
        /// Checks whether a menucontrol is being pressed and if selected item is UIListItem, uses UIListItem variables
        /// </summary>
        /// <param name="control"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool IsControlBeingPressed(Common.MenuControls control, Keys key = Keys.None)
        {
            if (control != Common.MenuControls.Left && control != Common.MenuControls.Right)
            {
                if (HasControlJustBeenReleaseed(control, key)) _holdTime = 0;
                if(Game.GameTime <= _holdTime)
                {
                    return false;
                }
                List<Keys> tmpKeys = new List<Keys>(_keyDictionary[control].Item1);
                List<Tuple<GameControl, int>> tmpControls = new List<Tuple<GameControl, int>>(_keyDictionary[control].Item2);
                if (key != Keys.None)
                {
                    if (tmpKeys.Any(Game.IsKeyDownRightNow))
                    {
                        _holdTime = Game.GameTime + HoldTimeBeforeScroll;
                        return true;
                    }
                }
                if (tmpControls.Any(tuple => Game.IsControlPressed(tuple.Item2, tuple.Item1) || Common.IsDisabledControlPressed(tuple.Item2, tuple.Item1)))
                {
                    _holdTime = Game.GameTime + HoldTimeBeforeScroll;
                    return true;
                }
                return false;
            }
            else if ((MenuItems[CurrentSelection] is UIMenuListItem) && MenuItems[CurrentSelection].Enabled)
            {

                UIMenuListItem it = (UIMenuListItem)MenuItems[CurrentSelection];
                if(it.ScrollingEnabled)
                {
                    if (HasControlJustBeenReleaseed(control, key)) { it._holdTime = 0; }
                    if(Game.GameTime <= it._holdTime)
                    {
                        return false;
                    }
                    List<Keys> tmpKeys = new List<Keys>(_keyDictionary[control].Item1);
                    List<Tuple<GameControl, int>> tmpControls = new List<Tuple<GameControl, int>>(_keyDictionary[control].Item2);
                    if (key != Keys.None)
                    {
                        if (tmpKeys.Any(Game.IsKeyDownRightNow))
                        {
                            it._holdTime = Game.GameTime + it.HoldTimeBeforeScroll;
                            return true;
                        }
                    }
                    if (tmpControls.Any(tuple => Game.IsControlPressed(tuple.Item2, tuple.Item1) || Common.IsDisabledControlPressed(tuple.Item2, tuple.Item1)))
                    {
                        it._holdTime = Game.GameTime + it.HoldTimeBeforeScroll;
                        return true;
                    }
                }
                else if(HasControlJustBeenPressed(control, key))
                {
                    return true;
                }

            }
            return false;
        }