Example #1
0
File: KeyMap.cs Project: hww/VARP2
        /// <summary>
        /// Set key value pair. Replace existing.
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="value"></param>
        public override void SetLocal(int evt, object value)
        {
            if (!Event.IsValid(evt))
            {
                throw new ArgumentOutOfRangeException("evt");
            }

            // do not support keys with modificators
            if (evt >= KeyModifyers.Alt)
            {
                throw new ArgumentOutOfRangeException("evt");
            }

            // limit by some "rational" number ;)
            if (evt >= MaxSize)
            {
                throw new ArgumentOutOfRangeException("evt");
            }

            if (evt >= items.Count)
            {
                // extend size of the items list
                var large = new List <KeyMapItem>(evt + 10);
                var i     = 0;
                foreach (var item in items)
                {
                    large[i++] = item;
                }
                items = large;
            }

            items[evt] = new KeyMapItem(evt, value);
        }
Example #2
0
        /// <summary>
        /// Evaluate the keybinding.
        /// </summary>
        /// <param name="item"></param>
        private void Eval(KeyMapItem item)
        {
            var value = item.value;

            if (value is KeyMap)
            {
                var o = value as KeyMap;
                // KeyMap without title is just keyMap
                if (o.Title == null)
                {
                    return;
                }
                // KeyMap with title behave as menu
                UiManager.I.CreateMenu(o, Vector3.zero, 200f);
            }
            else if (value is NativeFunction)
            {
                // native function
                var o       = value as NativeFunction;
                var returns = o.Call();
                inputBuffer.Clear();
            }
            else if (value is string)
            {
                // string expression
                var o = value as string;
                NativeFunctionRepl.Instance.Evaluate(o);
            }
            else if (value is MenuLineBaseComplex)
            {
            }
            else if (value is MenuLineBaseSimple)
            {
            }
        }
Example #3
0
File: KeyMap.cs Project: hww/VARP2
        /// <summary>
        /// Set key value pair. Replace existing
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="value"></param>
        public virtual void SetLocal(int evt, object value)
        {
            if (!Event.IsValid(evt))
            {
                throw new ArgumentOutOfRangeException("evt");
            }
            var binding = new KeyMapItem(evt, value);
            var index   = GetIndexOf(evt);

            if (index >= 0)
            {
                items[index] = binding;
            }
            else
            {
                items.Add(binding);
            }

            if (evt == Event.DefaultPseudoCode)
            {
                defaultBinding = binding;
            }
        }