Esempio n. 1
0
 /// <summary>
 /// Destroys the app.
 /// </summary>
 private void DestroyApp(GameScenes data)
 {
     if (data == GameScenes.MAINMENU)
     {
         GameEvents.onGameSceneLoadRequested.Remove(DestroyApp);
         ApplicationLauncher.Instance.RemoveModApplication(draftManagerButton);
         instance = null;
         Destroy(gameObject);
         Logger.DebugLog("DTV App Destroyed.");
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Called when the MonoBehavior is awakened.
        /// </summary>
        private void Awake()
        {
            // If there's already an instance, delete this instance.
            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            // Do not destroy this instance.
            DontDestroyOnLoad(gameObject);
            // Save this instance so others can detect it.
            instance = this;

            SoundManager.LoadSound("DraftTwitchViewers/Sounds/Start", "Start");
            SoundManager.LoadSound("DraftTwitchViewers/Sounds/Success", "Success");
            SoundManager.LoadSound("DraftTwitchViewers/Sounds/Failure", "Failure");
            startClip   = SoundManager.CreateSound("Start", false);
            successClip = SoundManager.CreateSound("Success", false);
            failureClip = SoundManager.CreateSound("Failure", false);

            // Load global settings.
            ConfigNode globalSettings = ConfigNode.Load(settingsLocation + "GlobalSettings.cfg");

            // If the file exists,
            if (globalSettings != null)
            {
                #region Draft Settings Load
                // Get the DRAFT node.
                ConfigNode draftSettings = globalSettings.GetNode("DRAFT");

                // If the DRAFT node exists,
                if (draftSettings != null)
                {
                    // Get the global settings.
                    if (draftSettings.HasValue("addToCraft"))
                    {
                        try { addToCraft = bool.Parse(draftSettings.GetValue("addToCraft")); } catch { }
                    }
                }
                // If the DRAFT node doesn't exist,
                else
                {
                    // Log a warning that is wasn't found.
                    Logger.DebugWarning("GlobalSettings.cfg WAS found, but the DRAFT node was not. Using defaults.");
                }
                #endregion

                #region Message Settings Load
                // Get the MESSAGES node.
                ConfigNode messageSettings = globalSettings.GetNode("MESSAGES");

                // If the MESSAGES node exists,
                if (messageSettings != null)
                {
                    // Get the global settings.
                    if (messageSettings.HasValue("draftMessage"))
                    {
                        draftMessage = messageSettings.GetValue("draftMessage");
                    }
                    if (messageSettings.HasValue("drawMessage"))
                    {
                        drawMessage = messageSettings.GetValue("drawMessage");
                    }
                }
                // If the DRAFT node doesn't exist,
                else
                {
                    // Log a warning that is wasn't found.
                    Logger.DebugWarning("GlobalSettings.cfg WAS found, but the MESSAGES node was not. Using defaults.");
                }
                #endregion
            }
            // If the file doesn't exist,
            else
            {
                // Log a warning that it wasn't found.
                Logger.DebugWarning("GlobalSettings.cfg wasn't found. Using defaults.");
            }

            // Create the App Launcher button and add it.
            draftManagerButton = ApplicationLauncher.Instance.AddModApplication(
                DisplayApp,
                HideApp,
                HoverApp,
                UnhoverApp,
                DummyVoid,
                Disable,
                ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.FLIGHT,
                GameDatabase.Instance.GetTexture("DraftTwitchViewers/Textures/Toolbar", false));

            // This app should be mutually exclusive. (It should disappear when the player clicks on another app.
            ApplicationLauncher.Instance.EnableMutuallyExclusive(draftManagerButton);

            // Set up the window bounds.
            windowRect = new Rect(Screen.width - windowWidth, 40f, windowWidth, windowHeight);
            // Set up the alert bounds.
            alertRect = new Rect(Screen.width / 2 - windowWidth / 2, Screen.height / 2 - windowHeight / 4, windowWidth, 1f);

            // Set up app destroyer.
            GameEvents.onGameSceneLoadRequested.Add(DestroyApp);
            Logger.DebugLog("DTV App Created.");
        }