public static bool ClearState(string gameName, string stateName)
        {
            if (!ValidateGame(gameName))
            {
                return(false);
            }

            // If the key exists and is false, it has been (or will be) validated, so no need to validate it now
            if (Games[gameName].currentStates.ContainsKey(stateName) && !Games[gameName].currentStates[stateName])
            {
                return(true);
            }

            Console.WriteLine(pre + "Clear State ({0}): {1}", gameName, stateName);

            if (CurrentGame == gameName)
            {
                // If current game, then validate with iCUE
                bool success = PipeServer.BoolFunction(string.Format("clearstate|{0}", stateName));
                if (success)
                {
                    Games[gameName].SetState(stateName, false);
                }
                return(success);
            }
            else
            {
                // Set it now, validate on change games
                Games[gameName].SetState(stateName, false);
                return(true);
            }
        }
        public static bool ClearAllStates(string gameName)
        {
            if (!ValidateGame(gameName))
            {
                return(false);
            }

            Console.WriteLine(pre + "Clearing All States ({0})", gameName);

            if (CurrentGame == gameName)
            {
                bool success = PipeServer.BoolFunction("clearallstates");
                if (success)
                {
                    List <string> keys = Games[gameName].currentStates.Keys.ToList();
                    foreach (string key in keys)
                    {
                        Games[gameName].SetState(key, false);
                    }
                }
                return(success);
            }
            else
            {
                List <string> keys = Games[gameName].currentStates.Keys.ToList();
                foreach (string key in keys)
                {
                    Games[gameName].SetState(key, false);
                }
                return(true);
            }
        }
        public static bool SetEvent(string gameName, string eventName)
        {
            if (!ValidateGame(gameName))
            {
                return(false);
            }

            Console.WriteLine(pre + "Triggered Event ({0}): {1}", gameName, eventName);

            // Only set event if current game
            if (CurrentGame == gameName)
            {
                bool success = PipeServer.BoolFunction(string.Format("setevent|{0}", eventName));
                if (success)
                {
                    Games[gameName].TriggerEvent(eventName);
                }
                return(success);
            }
            else
            {
                Games[gameName].TriggerEvent(eventName);
                return(true);
            }
        }
        public static bool ClearAllEvents(string gameName)
        {
            if (!ValidateGame(gameName))
            {
                return(false);
            }

            if (CurrentGame == gameName)
            {
                Console.WriteLine(pre + "Clearing All Events ({0})", gameName);
                return(PipeServer.BoolFunction("clearallevents"));
            }

            return(true);
        }
Esempio n. 5
0
        // Runs when the application terminates, used to close all the controllers and current CgSDK Handler
        private static bool OnAppExit(CtrlType sig)
        {
            Linker.KillAllControllers();
            PipeServer.CleanUpClients();
            isRunning = false;

            bool handled = true;

            switch (sig)
            {
            case CtrlType.CTRL_C_EVENT:
            case CtrlType.CTRL_LOGOFF_EVENT:
            case CtrlType.CTRL_SHUTDOWN_EVENT:
            case CtrlType.CTRL_CLOSE_EVENT:
                handled = true;
                break;

            default:
                return(handled);
            }

            return(handled);
        }
 public static int GetLastError()
 {
     return(PipeServer.IntFunction("getlasterror"));
 }
        public static bool SetGame(string gameName)
        {
            if (Locked && CurrentGame != gameName)
            {
                return(false);
            }

            if (gameName.ToUpper() == "ICUE")
            {
                // Use gameName = "iCUE" to not use the SDK -> Freeing up the iCUE Software to work as normal
                Console.WriteLine(pre + "Set Game to: iCUE - Releasing software");
                PipeServer.ResetClient();

                if (!Games.ContainsKey("iCUE"))
                {
                    Games["iCUE"] = new GameState("iCUE");
                }

                CurrentGame = "iCUE";
                return(true);
            }
            else if (!ValidateGame(gameName))
            {
                return(false);
            }
            else
            {
                PipeServer.ResetClient();
                SetupCgSDK();
            }

            bool success = PipeServer.BoolFunction(string.Format("setgame|{0}", gameName));

            CurrentGame = (success) ? gameName : CurrentGame;
            if (success)
            {
                if (!Games.ContainsKey(gameName))
                {
                    // Add game and validate it
                    Games[gameName] = new GameState(gameName);
                }
                else
                {
                    // Set game and validate all states
                    List <string> invalidStates = new List <string>();
                    foreach (KeyValuePair <string, bool> state in Games[gameName].currentStates)
                    {
                        bool valid = false;

                        // If state is true and validated with iCUE, keep it
                        if (state.Value == true && PipeServer.BoolFunction(string.Format("setstate|{0}", state.Key)))
                        {
                            valid = true;
                        }

                        if (!valid)
                        {
                            // Delete invalid states
                            invalidStates.Add(state.Key);
                        }
                    }

                    foreach (string stateName in invalidStates)
                    {
                        Games[gameName].currentStates.Remove(stateName);
                    }
                }
                Console.WriteLine(pre + "Set Game to: " + gameName);
            }
            else
            {
                PrintIfLastError(string.Format("Failed to set game to \"{0}\", error: {{0}}", gameName));
            }
            return(success);
        }
 public static bool ReleaseControl()
 {
     return(PipeServer.BoolFunction("releasecontrol"));
 }
 public static bool RequestControl()
 {
     return(PipeServer.BoolFunction("requestcontrol"));
 }
 public static void PerformProtocolHandshake()
 {
     PipeServer.BoolFunction("performprotocolhandshake");
 }