示例#1
0
文件: HotKeys.cs 项目: jaedan/OrionUO
        public static void OnMouse(int button, int wheel)
        {
            if (World.Player == null || !m_Enabled)
            {
                return;
            }

            ModKeys cur = ModKeys.None;
            int     key = 0;

            switch (button)
            {
            case 0:
                if (wheel == 1)
                {
                    // Wheel down
                    key = -2;
                }
                else
                {
                    // Wheel up
                    key = -1;
                }
                break;

            case 1:
                key = -3;
                break;

            case 2:
                key = -4;
                break;

            case 3:
                key = -5;
                break;
            }

            if (KeyDown(Keys.ControlKey))
            {
                cur |= ModKeys.Control;
            }
            if (KeyDown(Keys.Menu))
            {
                cur |= ModKeys.Alt;
            }
            if (KeyDown(Keys.ShiftKey))
            {
                cur |= ModKeys.Shift;
            }

            KeyData hk = Get(key, cur);

            if (hk != null)
            {
                hk.Callback();
            }
        }
示例#2
0
        public static bool OnKeyDown(int key)
        {
            if (World.Player == null)
            {
                return(true);
            }

            ModKeys cur = ModKeys.None;

            if (KeyDown(Keys.ControlKey))
            {
                cur |= ModKeys.Control;
            }
            if (KeyDown(Keys.Menu))
            {
                cur |= ModKeys.Alt;
            }
            if (KeyDown(Keys.ShiftKey))
            {
                cur |= ModKeys.Shift;
            }

            if (m_HK_En != null && m_HK_En.Key > 0 && m_HK_En.Mod == cur && (m_HK_En.Key == key || KeyDown((Keys)m_HK_En.Key)))
            {
                m_HK_En.Callback();
                return(m_HK_En.SendToUO);
            }

            if (m_Enabled)
            {
                for (int i = 0; i < m_List.Count; i++)
                {
                    KeyData hk = (KeyData)m_List[i];
                    if (hk.Mod == cur && hk.Key > 0)
                    {
                        if (hk.Key == key || KeyDown((Keys)hk.Key))
                        {
                            if (Macros.MacroManager.AcceptActions)
                            {
                                Macros.MacroManager.Action(new Macros.HotKeyAction(hk));
                            }
                            hk.Callback();
                            return(hk.SendToUO);
                        }
                    }
                }
            }

            return(true);
        }
示例#3
0
        public static bool OnKeyDown(int key, ModKeys mod)
        {
            if (World.Player == null)
            {
                return(true);
            }
            ModKeys cur = mod;

            if (KeyDown(Keys.ControlKey))
            {
                cur |= ModKeys.Control;
            }
            if (KeyDown(Keys.Menu))
            {
                cur |= ModKeys.Alt;
            }
            if (KeyDown(Keys.ShiftKey))
            {
                cur |= ModKeys.Shift;
            }

            if (m_HK_En != null && m_HK_En.Key > 0 && m_HK_En.Mod == cur &&
                (m_HK_En.Key == key || KeyDown((Keys)m_HK_En.Key)))
            {
                m_HK_En.Callback();
                return(m_HK_En.SendToUO);
            }

            if (_hotKeyEnableToggle != null && _hotKeyEnableToggle.Key > 0 && _hotKeyEnableToggle.Mod == cur &&
                (_hotKeyEnableToggle.Key == key || KeyDown((Keys)_hotKeyEnableToggle.Key)))
            {
                _hotKeyEnableToggle.Callback();
                return(_hotKeyEnableToggle.SendToUO);
            }

            if (_hotKeyDisableToggle != null && _hotKeyDisableToggle.Key > 0 && _hotKeyDisableToggle.Mod == cur &&
                (_hotKeyDisableToggle.Key == key || KeyDown((Keys)_hotKeyDisableToggle.Key)))
            {
                _hotKeyDisableToggle.Callback();
                return(_hotKeyDisableToggle.SendToUO);
            }

            if (m_Enabled)
            {
                for (int i = 0; i < m_List.Count; i++)
                {
                    KeyData hk = (KeyData)m_List[i];
                    if (hk.Mod == cur && hk.Key > 0)
                    {
                        if (hk.Key == key)
                        {
                            if (Macros.MacroManager.AcceptActions)
                            {
                                Macros.MacroManager.Action(new Macros.HotKeyAction(hk));
                            }

                            ScriptManager.AddToScript($"hotkey '{hk.DispName}'");

                            hk.Callback();
                            return(hk.SendToUO);
                        }
                    }
                }

                // if pressed key didn't match a hotkey, check for any key currently down
                for (int i = 0; i < m_List.Count; i++)
                {
                    KeyData hk = (KeyData)m_List[i];
                    if (hk.Mod == cur && hk.Key > 0)
                    {
                        if (KeyDown((Keys)hk.Key))
                        {
                            if (Macros.MacroManager.AcceptActions)
                            {
                                Macros.MacroManager.Action(new Macros.HotKeyAction(hk));
                            }

                            ScriptManager.AddToScript($"hotkey '{hk.DispName}'");

                            hk.Callback();
                            return(hk.SendToUO);
                        }
                    }
                }
            }

            return(true);
        }