示例#1
0
        public static PluginUserSettings LoadUserSettingsFromFile()
        {
            PluginUserSettings userSettings = new PluginUserSettings();

            //default values
            userSettings.Textspeed    = 0.04f;
            userSettings.MessageDelay = 8;

            if (File.Exists(UserData.Path + "cameramessage/userSettings.txt"))
            {
                string   filetext             = File.ReadAllText(UserData.Path + "cameramessage/userSettings.txt");
                string[] settingsMessageArray = filetext.Split('\n');

                foreach (string userSetting in settingsMessageArray)
                {
                    if (userSetting.Contains(TEXTSPEED))
                    {
                        userSettings.Textspeed = float.Parse(userSetting.Substring(TEXTSPEED.Length));
                    }
                    else if (userSetting.Contains(MESSAGEDELAY))
                    {
                        userSettings.MessageDelay = int.Parse(userSetting.Substring(MESSAGEDELAY.Length));
                    }
                }
            }
            return(userSettings);
        }
示例#2
0
        public static void SaveSettingsToFile(PluginUserSettings pluginUserSettings)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(TEXTSPEED);
            sb.Append(pluginUserSettings.Textspeed);
            sb.Append(Environment.NewLine);
            sb.Append(MESSAGEDELAY);
            sb.Append(pluginUserSettings.MessageDelay);

            WriteSettingsToFile(sb.ToString());
        }
示例#3
0
        void IPlugin.OnLevelWasLoaded(int level)
        {
            //Console.WriteLine("on level was loaded");

            GameObject gameObject = GameObject.Find("CommonSpace");

            bool flag = false;

            CameraMessageBase[] componentsInChildren = gameObject.GetComponentsInChildren <CameraMessageBase>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                CameraMessageBase cameraMessageBase = componentsInChildren[i];
                flag = true;
                cameraMessageBase.InitializeCaches();
            }
            if (!flag)
            {
                CameraMessageBase cameraMessageBase = gameObject.AddComponent <CameraMessageBase>();

                if (CameraMessageBase.studioneocam == null)
                {
                    //getCameraV2();
                    //getCameraBase();
                    Helpers.GetCameraStudioNeo();
                }


                cameraMessageBase.InitializeCaches();

                PluginUserSettings userSettings = SaveFileManager.LoadUserSettingsFromFile();
                CameraMessageBase.textSpeed       = userSettings.Textspeed;
                CameraMessageBase.textSpeedString = CameraMessageBase.textSpeed.ToString().Substring(CameraMessageBase.textSpeed.ToString().Length - 1);
                CameraMessageBase.messageDelay    = userSettings.MessageDelay.ToString();

                //Console.WriteLine("loaded textSpeed: '" + userSettings.Textspeed + "'");
            }
        }