Example #1
0
        private static void CheckForClosedProcessLogic(string[] activeProcesses)
        {
            // If the previously focussed linked process was closed
            if (!linkedProcessClosed && !activeProcesses.Contains(previousLinkedProcess) && Settings.processControllers.ContainsKey(previousLinkedProcess))
            {
                // If we should disable LockSetGame
                if (!String.IsNullOrWhiteSpace(Settings.processControllers[previousLinkedProcess].lockSetGame))
                {
                    StateTracking.LockGame(Settings.processControllers[previousLinkedProcess].lockSetGame, false);
                }

                // If we should AutoSetGameOnClose
                if (!String.IsNullOrWhiteSpace(Settings.processControllers[previousLinkedProcess].autoSetGameOnClose))
                {
                    StateTracking.SetGame(Settings.processControllers[previousLinkedProcess].autoSetGameOnClose);
                }

                linkedProcessClosed = true;

                // If we have closed the linked process and have NOT switched to another, set currentLinkedProcess to none
                if (previousLinkedProcess == currentLinkedProcess)
                {
                    currentLinkedProcess = "";
                }
            }

            // Update linkedProcessClosed if we have switched to a new linked process
            if (previousLinkedProcess != currentLinkedProcess)
            {
                linkedProcessClosed = false;
            }
        }
Example #2
0
        // Checks periodically if the currently focussed window is a different linked process to the previously focussed + linked process
        // The aim is to only switch lighting effects when we refocus to another linked process, otherwise we let the last linked process keep its profile running
        private static void UpdateProcessLinkedProfiles()
        {
            string currentFocus = GetFocussedProcess();

            // If we have switched focus to another process
            // Note:    If a controller is manually launched (e.g. the documentation Javascript), refocussing to a linked process WILL NOT trigger AutoSetGame.
            //          This is by design to allow switching between unlinked processes without interupting lighting. We could trigger AutoSetGame whenever we
            //          refocus, however this unfortunently causes an undesirable flickering effect. Therefore use unlinked/manual controllers at your own risk.
            if (currentFocus != currentLinkedProcess)
            {
                // Is the new process another linked process
                if (Settings.processControllers.ContainsKey(currentFocus))
                {
                    Console.WriteLine(pre + "Switched focus to linked process: {0}", currentFocus);

                    if (!String.IsNullOrWhiteSpace(currentLinkedProcess) && activeControllers.ContainsKey(currentLinkedProcess) && Settings.processControllers[currentLinkedProcess].closeOnProfileSwitch)
                    {
                        KillController(currentLinkedProcess);
                    }

                    StartController(currentFocus);

                    // If we should AutoSetGame, do it now
                    if (!String.IsNullOrWhiteSpace(Settings.processControllers[currentFocus].autoSetGame))
                    {
                        StateTracking.SetGame(Settings.processControllers[currentFocus].autoSetGame);
                    }

                    // If we should enable LockSetGame
                    if (!String.IsNullOrWhiteSpace(Settings.processControllers[currentFocus].lockSetGame))
                    {
                        StateTracking.LockGame(Settings.processControllers[currentFocus].lockSetGame, true);
                    }

                    currentLinkedProcess = currentFocus;
                }
                // Switched to an unlinked process
                else
                {
                    // Nothing to do here... wait... Default controllers are AIDS!!
                }
            }
        }
        static string HandleICue(Dictionary <string, string> paramaters)
        {
            switch (paramaters["func"].ToLower())
            {
            case "getgame":
                if (StateTracking.Games.Keys.Count > 0 && !String.IsNullOrWhiteSpace(StateTracking.CurrentGame))
                {
                    string gameName = (paramaters.ContainsKey("game")) ? paramaters["game"] : StateTracking.CurrentGame;
                    if (StateTracking.Games.ContainsKey(gameName))
                    {
                        return(JsonConvert.SerializeObject(StateTracking.Games[gameName], Formatting.Indented));
                    }
                }
                break;

            case "getallgames":
                if (StateTracking.Games.Keys.Count > 0)
                {
                    return(JsonConvert.SerializeObject(StateTracking.Games, Formatting.Indented));
                }
                break;

            case "setgame":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.SetGame(paramaters["game"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "reset":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.ResetGame(paramaters["game"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "lock":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.LockGame(paramaters["game"], true))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "unlock":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.LockGame(paramaters["game"], false))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "setstate":
                if (paramaters.ContainsKey("game") && paramaters.ContainsKey("state"))
                {
                    if (StateTracking.SetState(paramaters["game"], paramaters["state"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "clearstate":
                if (paramaters.ContainsKey("game") && paramaters.ContainsKey("state"))
                {
                    if (StateTracking.ClearState(paramaters["game"], paramaters["state"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "clearallstates":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.ClearAllStates(paramaters["game"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "setevent":
                if (paramaters.ContainsKey("game") && paramaters.ContainsKey("event"))
                {
                    if (StateTracking.SetEvent(paramaters["game"], paramaters["event"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            case "clearallevents":
                if (paramaters.ContainsKey("game"))
                {
                    if (StateTracking.ClearAllEvents(paramaters["game"]))
                    {
                        return(StateTracking.ErrorToString(0));
                    }
                    else
                    {
                        return(StateTracking.GetLastErrorString());
                    }
                }
                break;

            default:
                // No function provided
                Console.WriteLine(pre + "Error - No valid function provided, requested funtion ({0})", paramaters["func"].ToLower());
                return(StateTracking.ErrorToString(5));
            }

            return("");
        }