示例#1
0
        public List <HotKeyManager.HotKeyActions> SetHotKeyCombo(
            HotKeyManager.HotKeyActions action,
            HotKeyManager.KeyCombo combo)
        {
            List <HotKeyManager.HotKeyActions> hotKeyActionsList = new List <HotKeyManager.HotKeyActions>();

            string[] strArray = combo.states.Split('|');
            foreach (HotKeyManager.HotKeyActions key in this.HotKeys.Keys)
            {
                if (key != action && this.HotKeys[key].key == combo.key && (this.HotKeys[key].alt == combo.alt && this.HotKeys[key].control == combo.control) && this.HotKeys[key].shift == combo.shift)
                {
                    string states  = this.HotKeys[key].states;
                    char[] chArray = new char[1] {
                        '|'
                    };
                    foreach (string str in states.Split(chArray))
                    {
                        if (((IEnumerable <string>)strArray).Contains <string>(str))
                        {
                            this.HotKeys[key].key = Keys.None;
                            hotKeyActionsList.Add(key);
                        }
                    }
                }
            }
            this.HotKeys[action] = combo;
            hotKeyActionsList.Add(action);
            return(hotKeyActionsList);
        }
示例#2
0
 public HotKeyManager.KeyCombo GetHotKeyCombo(HotKeyManager.HotKeyActions action)
 {
     if (this.HotKeys.ContainsKey(action))
     {
         return(this.HotKeys[action]);
     }
     return((HotKeyManager.KeyCombo)null);
 }
示例#3
0
 public bool OnVKReported(Keys key, bool shift, bool ctrl, bool alt)
 {
     this._app.HotKeyManager.SetVkReportMode(false);
     if (this._bindingaction != HotKeyManager.HotKeyActions.NoAction)
     {
         this._app.UI.SetVisible(this._app.UI.Path(this.ID, "dialogBinding"), false);
         HotKeyManager.KeyCombo hotKeyCombo = this._app.HotKeyManager.GetHotKeyCombo(this._bindingaction);
         hotKeyCombo.shift   = shift;
         hotKeyCombo.control = ctrl;
         hotKeyCombo.alt     = alt;
         hotKeyCombo.key     = key;
         this.UpdateHotkeyUI(this._app.HotKeyManager.SetHotKeyCombo(this._bindingaction, hotKeyCombo));
         this._bindingaction = HotKeyManager.HotKeyActions.NoAction;
     }
     return(true);
 }
示例#4
0
        public bool OnKeyBindPressed(HotKeyManager.HotKeyActions action, string gamestates)
        {
            if (gamestates.Contains(this.Name))
            {
                switch (action)
                {
                case HotKeyManager.HotKeyActions.State_Starmap:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <StarMapState>();
                    return(true);

                case HotKeyManager.HotKeyActions.State_BuildScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <BuildScreenState>((object)this._targetSystemID);
                    return(true);

                case HotKeyManager.HotKeyActions.State_DesignScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <DesignScreenState>((object)false, (object)this.Name);
                    return(true);

                case HotKeyManager.HotKeyActions.State_ResearchScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <ResearchScreenState>();
                    return(true);

                case HotKeyManager.HotKeyActions.State_ComparativeAnalysysScreen:
                    return(false);

                case HotKeyManager.HotKeyActions.State_EmpireSummaryScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <EmpireSummaryState>();
                    return(true);

                case HotKeyManager.HotKeyActions.State_SotspediaScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <SotspediaState>();
                    return(true);

                case HotKeyManager.HotKeyActions.State_DiplomacyScreen:
                    this.App.UI.LockUI();
                    this.App.SwitchGameState <DiplomacyScreenState>();
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
        {
            switch (messageId)
            {
            case InteropMessageID.IMID_SCRIPT_KEYCOMBO:
                if (!this._enabled)
                {
                    return(true);
                }
                HotKeyManager.HotKeyActions index = (HotKeyManager.HotKeyActions)message.ReadInteger();
                if (this.HotKeys.ContainsKey(index))
                {
                    foreach (IKeyBindListener listener in this._listeners)
                    {
                        if (listener.OnKeyBindPressed(index, this.HotKeys[index].states))
                        {
                            break;
                        }
                    }
                }
                return(true);

            case InteropMessageID.IMID_SCRIPT_VKREPORT:
                if (!this._enabled)
                {
                    return(true);
                }
                Keys key   = (Keys)message.ReadInteger();
                bool shift = message.ReadBool();
                bool ctrl  = message.ReadBool();
                bool alt   = message.ReadBool();
                foreach (IHotkeyVKListener vkListener in this._vkListeners)
                {
                    if (vkListener.OnVKReported(key, shift, ctrl, alt))
                    {
                        break;
                    }
                }
                return(true);

            default:
                return(false);
            }
        }
示例#6
0
        public bool LoadProfile(string profileName, bool absolutepath = false)
        {
            string str = !absolutepath ? HotKeyManager._profileRootDirectory + "\\" + profileName + ".keys" : profileName;

            if (profileName == "~Default")
            {
                str = this._assetdir + "\\" + profileName + ".keys";
            }
            if (!File.Exists(str))
            {
                return(false);
            }
            this.HotKeys.Clear();
            if (profileName == "~Default")
            {
                this.DefaultHotKeys.Clear();
            }
            this._profileName = profileName;
            XPathNavigator navigator = new XPathDocument(App.GetStreamForFile(str) != null ? App.GetStreamForFile(str) : (Stream) new FileStream(str, FileMode.Open)).CreateNavigator();

            navigator.MoveToFirstChild();
            do
            {
                if (navigator.HasChildren)
                {
                    navigator.MoveToFirstChild();
                    do
                    {
                        if (navigator.HasChildren)
                        {
                            HotKeyManager.KeyCombo      keyCombo = new HotKeyManager.KeyCombo();
                            HotKeyManager.HotKeyActions key      = HotKeyManager.HotKeyActions.NoAction;
                            navigator.MoveToFirstChild();
                            do
                            {
                                switch (navigator.Name)
                                {
                                case "event":
                                    if (Enum.IsDefined(typeof(HotKeyManager.HotKeyActions), (object)navigator.Value))
                                    {
                                        key = (HotKeyManager.HotKeyActions)Enum.Parse(typeof(HotKeyManager.HotKeyActions), navigator.Value, true);
                                        break;
                                    }
                                    break;

                                case "states":
                                    keyCombo.states = navigator.Value;
                                    break;

                                case "shift":
                                    keyCombo.shift = bool.Parse(navigator.Value);
                                    break;

                                case "ctrl":
                                    keyCombo.control = bool.Parse(navigator.Value);
                                    break;

                                case "alt":
                                    keyCombo.alt = bool.Parse(navigator.Value);
                                    break;

                                case "key":
                                    keyCombo.key = !Enum.IsDefined(typeof(Keys), (object)navigator.Value) ? Keys.None : (Keys)Enum.Parse(typeof(Keys), navigator.Value, true);
                                    break;
                                }
                            }while (navigator.MoveToNext());
                            if (key != HotKeyManager.HotKeyActions.NoAction && !this.HotKeys.ContainsKey(key))
                            {
                                this.HotKeys.Add(key, keyCombo);
                                if (profileName == "~Default")
                                {
                                    this.DefaultHotKeys.Add(key, keyCombo);
                                }
                            }
                            navigator.MoveToParent();
                        }
                    }while (navigator.MoveToNext());
                }
            }while (navigator.MoveToNext());
            this._loaded = true;
            foreach (HotKeyManager.HotKeyActions action in Enum.GetValues(typeof(HotKeyManager.HotKeyActions)))
            {
                if (!this.HotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action) && this.DefaultHotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action))
                {
                    this.SetHotKeyCombo(action, this.DefaultHotKeys[action]);
                }
            }
            this.SyncKeyProfile("");
            this.SaveProfile();
            return(true);
        }
示例#7
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked")
     {
         if (panelName == "hotKeyOptions_ok")
         {
             this._app.HotKeyManager.SaveProfile();
             this._app.HotKeyManager.SyncKeyProfile("");
             this._app.UI.CloseDialog((Dialog)this, true);
         }
         else if (panelName == "hotKeyOptions_default")
         {
             this._app.HotKeyManager.DeleteProfile();
             this._app.HotKeyManager.CreateProfile(this._app.UserProfile.ProfileName);
             this.PopulateHotKeyList();
         }
         else if (panelName.Contains("clearBinding"))
         {
             HotKeyManager.HotKeyActions action      = (HotKeyManager.HotKeyActions) int.Parse(panelName.Split('|')[1]);
             HotKeyManager.KeyCombo      hotKeyCombo = this._app.HotKeyManager.GetHotKeyCombo(action);
             hotKeyCombo.alt     = false;
             hotKeyCombo.control = false;
             hotKeyCombo.shift   = false;
             hotKeyCombo.key     = Keys.None;
             this.UpdateHotkeyUI(this._app.HotKeyManager.SetHotKeyCombo(action, hotKeyCombo));
         }
         else
         {
             if (!panelName.Contains("gameHotKey"))
             {
                 return;
             }
             HotKeyManager.HotKeyActions action = (HotKeyManager.HotKeyActions) int.Parse(panelName.Split('|')[1]);
             this._app.HotKeyManager.GetHotKeyCombo(action);
             this._app.UI.SetVisible(this._app.UI.Path(this.ID, "dialogBinding"), true);
             this._app.UI.SetText(this._app.UI.Path(this.ID, "dialogBinding", "bindtext"), "Press modifiers + key to bind for action - " + App.Localize("@UI_HOTKEY_" + action.ToString().ToUpper()));
             this._bindingaction = action;
             this._app.HotKeyManager.SetVkReportMode(true);
         }
     }
     else
     {
         if (msgType == "dialog_closed" || !(msgType == "checkbox_clicked"))
         {
             return;
         }
         if (panelName.StartsWith("alt_toggle"))
         {
             HotKeyManager.HotKeyActions action = (HotKeyManager.HotKeyActions) int.Parse(panelName.Split('|')[1]);
             bool flag = msgParams[0] == "1";
             HotKeyManager.KeyCombo hotKeyCombo = this._app.HotKeyManager.GetHotKeyCombo(action);
             if (action == HotKeyManager.HotKeyActions.NoAction)
             {
                 return;
             }
             hotKeyCombo.alt = flag;
             this.UpdateHotkeyUI(this._app.HotKeyManager.SetHotKeyCombo(action, hotKeyCombo));
         }
         else if (panelName.StartsWith("ctrl_toggle"))
         {
             HotKeyManager.HotKeyActions action = (HotKeyManager.HotKeyActions) int.Parse(panelName.Split('|')[1]);
             bool flag = msgParams[0] == "1";
             HotKeyManager.KeyCombo hotKeyCombo = this._app.HotKeyManager.GetHotKeyCombo(action);
             if (action == HotKeyManager.HotKeyActions.NoAction)
             {
                 return;
             }
             hotKeyCombo.control = flag;
             this.UpdateHotkeyUI(this._app.HotKeyManager.SetHotKeyCombo(action, hotKeyCombo));
         }
         else
         {
             if (!panelName.StartsWith("shift_toggle"))
             {
                 return;
             }
             HotKeyManager.HotKeyActions action = (HotKeyManager.HotKeyActions) int.Parse(panelName.Split('|')[1]);
             bool flag = msgParams[0] == "1";
             HotKeyManager.KeyCombo hotKeyCombo = this._app.HotKeyManager.GetHotKeyCombo(action);
             if (action == HotKeyManager.HotKeyActions.NoAction)
             {
                 return;
             }
             hotKeyCombo.shift = flag;
             this.UpdateHotkeyUI(this._app.HotKeyManager.SetHotKeyCombo(action, hotKeyCombo));
         }
     }
 }