Exemplo n.º 1
0
        public void Update(MyDebugSystem system, MyGuiInput input)
        {
            input.GetPressedKeys(m_pressedKeys);
            short modifier = 0;

            if (input.IsAnyAltKeyPressed())
            {
                modifier |= (short)MyShortcut.ModifierValue.Alt;
            }
            if (input.IsAnyShiftKeyPressed())
            {
                modifier |= (short)MyShortcut.ModifierValue.Shift;
            }
            if (input.IsAnyCtrlKeyPressed())
            {
                modifier |= (short)MyShortcut.ModifierValue.Control;
            }

            foreach (Keys k in m_pressedKeys)
            {
                var key = (Keys)k;
                if (key == Keys.LeftAlt || key == Keys.RightAlt || key == Keys.LeftShift || key == Keys.RightShift || key == Keys.LeftControl || key == Keys.RightControl)
                {
                    continue;
                }

                if (input.IsNewKeyPress(key))
                {
                    OnKeyPressed(system, key, modifier);
                }
            }
        }
Exemplo n.º 2
0
        public void RegisterShortcut(MyDebugSystem system, string category, string name, MyShortcut shortcut, DebugItemHandler action)
        {
            MyDebugConsoleItem item = new MyDebugConsoleItem
            {
                System   = system,
                Category = category,
                Name     = name,
                Shortcut = shortcut,
                Action   = action
            };

            //if (m_shortcutMap.ContainsKey(shortcut))
            //  return false;
            if (shortcut != null)
            {
                m_shortcutMap.Add(shortcut, item);
            }

            List <MyDebugConsoleItem> items;

            m_categoriesMap.TryGetValue(category.ToString(), out items);
            if (items == null)
            {
                items = new List <MyDebugConsoleItem>();
                m_categoriesMap.Add(category.ToString(), items);
            }

            items.Add(item);
        }
Exemplo n.º 3
0
        /// <summary>
        /// OnKeyDown
        /// </summary>
        /// <param name="key"></param>
        private void OnKeyPressed(MyDebugSystem system, Keys key, short modifier)
        {
            MyShortcut shortcut = new MyShortcut(key, modifier);

            if (m_shortcutMap.ContainsKey(shortcut))
            {
                MyDebugConsoleItem debugItem = m_shortcutMap[shortcut];
                if ((debugItem.System == system) || (debugItem.System == MyDebugSystem.Any))
                {
                    debugItem.Action(debugItem);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// OnKeyDown
        /// </summary>
        /// <param name="key"></param>
        private void OnKeyPressed(MyDebugSystem system, Keys key, short modifier)
        {
            MyShortcut shortcut = new MyShortcut(key, modifier);

            if (m_shortcutMap.ContainsKey(shortcut))
            {
                MyDebugConsoleItem debugItem = m_shortcutMap[shortcut];
                if ((debugItem.System == system) || (debugItem.System == MyDebugSystem.Any))
                {
                    debugItem.Action(debugItem);
                }
            }
        }
Exemplo n.º 5
0
        public void Update(MyDebugSystem system, MyGuiInput input)
        {
            input.GetPressedKeys(m_pressedKeys);
            short modifier = 0;
            if (input.IsAnyAltKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Alt;
            if (input.IsAnyShiftKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Shift;
            if (input.IsAnyCtrlKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Control;

            foreach(Keys k in m_pressedKeys)
            {
                var key = (Keys)k;
                if (key == Keys.LeftAlt || key == Keys.RightAlt || key == Keys.LeftShift || key == Keys.RightShift || key == Keys.LeftControl || key == Keys.RightControl)
                    continue;

                if (input.IsNewKeyPress(key))
                    OnKeyPressed(system, key, modifier);
            }
        }
Exemplo n.º 6
0
        public void RegisterShortcut(MyDebugSystem system, string category, string name, MyShortcut shortcut, DebugItemHandler action)
        {
            MyDebugConsoleItem item = new MyDebugConsoleItem
            {
                System = system,
                Category = category,
                Name = name,
                Shortcut = shortcut,
                Action = action
            };

            //if (m_shortcutMap.ContainsKey(shortcut))
              //  return false;
            if (shortcut != null)
            {
                m_shortcutMap.Add(shortcut, item);
            }

            List<MyDebugConsoleItem> items;
            m_categoriesMap.TryGetValue(category.ToString(), out items);
            if (items == null)
            {
                items = new List<MyDebugConsoleItem>();
                m_categoriesMap.Add(category.ToString(), items);
            }

            items.Add(item);
        }