Ejemplo n.º 1
0
        /**
         * <summary>Gets the options values associated with a specific profile.</summary>
         * <param name = "profileID">A unique identifier for the profile to save to</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         * <param name = "doSave">If True, and if the profile had no OptionsData to read, then new values will be saved to it</param>
         * <returns>An instance of OptionsData containing the profile's options</returns>
         */
        public static OptionsData LoadPrefsFromID(int profileID, bool showLog = false, bool doSave = true)
        {
            if (DoesProfileIDExist(profileID))
            {
                string optionsSerialized = OptionsFileHandler.LoadOptions(profileID, showLog);
                if (!string.IsNullOrEmpty(optionsSerialized))
                {
                    return(Serializer.DeserializeOptionsData(optionsSerialized));
                }
            }

            // No data exists, so create new
            if (KickStarter.settingsManager == null)
            {
                return(null);
            }

            OptionsData _optionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, profileID);

            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs();
            }

            return(_optionsData);
        }
Ejemplo n.º 2
0
 /**
  * <summary>Gets the ID number of the active profile.</summary>
  * <returns>The active profile's unique identifier</returns>
  */
 public static int GetActiveProfileID()
 {
     if (KickStarter.settingsManager != null && KickStarter.settingsManager.useProfiles)
     {
         return(OptionsFileHandler.GetActiveProfile());
     }
     return(0);
 }
Ejemplo n.º 3
0
        /**
         * <summary>Checks if a specific profile ID exists.</summary>
         * <param name = "profileID">The profile ID to check for</param>
         * <returns>True if the given profile ID exists</returns>
         */
        public static bool DoesProfileIDExist(int profileID)
        {
            if (KickStarter.settingsManager != null && !KickStarter.settingsManager.useProfiles)
            {
                profileID = 0;
            }

            return(OptionsFileHandler.DoesProfileExist(profileID));
        }
Ejemplo n.º 4
0
        /**
         * <summary>Saves specific options to a specific profile.</summary>
         * <param name = "ID">A unique identifier for the profile to save to</param>
         * <param name = "_optionsData">An instance of OptionsData containing the options to save</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         */
        public static void SavePrefsToID(int ID, OptionsData _optionsData = null, bool showLog = false)
        {
            if (_optionsData == null)
            {
                _optionsData = Options.optionsData;
            }
            string optionsSerialized = Serializer.SerializeObject <OptionsData> (_optionsData, true);

            if (optionsSerialized != "")
            {
                OptionsFileHandler.SaveOptions(ID, optionsSerialized, showLog);
            }
        }
Ejemplo n.º 5
0
        /**
         * <summary>Saves specific options to a specific profile.</summary>
         * <param name = "ID">A unique identifier for the profile to save to</param>
         * <param name = "_optionsData">An instance of OptionsData containing the options to save</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         */
        public static void SavePrefsToID(int ID, OptionsData _optionsData = null, bool showLog = false)
        {
            if (_optionsData == null)
            {
                _optionsData = Options.optionsData;
            }
            string optionsSerialized = Serializer.SerializeObject <OptionsData> (_optionsData, true, SaveSystem.OptionsFileFormatHandler);

            if (!string.IsNullOrEmpty(optionsSerialized))
            {
                OptionsFileHandler.SaveOptions(ID, optionsSerialized, showLog);
            }
        }
Ejemplo n.º 6
0
        /**
         * <summary>Gets the options values associated with a specific profile.</summary>
         * <param name = "profileID">A unique identifier for the profile to save to</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         * <param name = "doSave">If True, and if the profile had no OptionsData to read, then new values will be saved to it</param>
         * <returns>An instance of OptionsData containing the profile's options</returns>
         */
        public static OptionsData LoadPrefsFromID(int profileID, bool showLog = false, bool doSave = true)
        {
            if (DoesProfileIDExist(profileID))
            {
                string optionsSerialized = OptionsFileHandler.LoadOptions(profileID, showLog);
                if (!string.IsNullOrEmpty(optionsSerialized))
                {
                    try
                    {
                        return(Serializer.DeserializeOptionsData(optionsSerialized));
                    }
                    catch (System.Exception e)
                    {
                        ACDebug.LogWarning("Error retrieving OptionsData for profile #" + profileID + " - rebuilding..\nException: " + e);

                        OptionsData fallbackOptionsData = new OptionsData(profileID);
                        if (KickStarter.settingsManager != null)
                        {
                            fallbackOptionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage,
                                                                  KickStarter.settingsManager.defaultVoiceLanguage,
                                                                  KickStarter.settingsManager.defaultShowSubtitles,
                                                                  KickStarter.settingsManager.defaultSfxVolume,
                                                                  KickStarter.settingsManager.defaultMusicVolume,
                                                                  KickStarter.settingsManager.defaultSpeechVolume,
                                                                  profileID);
                        }
                        SavePrefsToID(profileID, fallbackOptionsData);
                        return(fallbackOptionsData);
                    }
                }
            }

            // No data exists, so create new
            if (KickStarter.settingsManager == null)
            {
                return(null);
            }

            OptionsData _optionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultVoiceLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, profileID);

            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs();
            }

            return(_optionsData);
        }
Ejemplo n.º 7
0
        /**
         * <summary>Deletes the PlayerPrefs key associated with a specfic profile</summary>
         * <param name = "profileID">The unique identifier of the profile to delete</param>
         */
        public static void DeleteProfilePrefs(int profileID)
        {
            bool isDeletingCurrentProfile = (profileID == GetActiveProfileID());

            OptionsFileHandler.DeleteOptions(profileID);

            if (isDeletingCurrentProfile)
            {
                for (int i = 0; i < maxProfiles; i++)
                {
                    if (DoesProfileIDExist(i))
                    {
                        SwitchProfileID(i);
                        return;
                    }
                }

                // No other profile found, create new
                SwitchProfileID(0);
            }
        }
Ejemplo n.º 8
0
 /**
  * <summary>Sets the ID number of the active profile.</summary>
  * <param name = "profileID">A unique identifier for the profile</param>
  */
 public static void SetActiveProfileID(int profileID)
 {
     OptionsFileHandler.SetActiveProfile(profileID);
 }