public static void ChangeSetting(string Key, string NewValue) { bool SettingChanged = false; string FileInput = File.ReadAllText(SaveLocation + DEFAULTFILE); foreach (string SettingLine in FileInput.Split(SETTINGPAIRSEPERATOR)) { string[] SettingParts = SettingLine.Split(SETTINGSEPERATOR); if (SettingParts[ZERO] == Key) { FileInput.Replace(SettingParts[ZERO] + SETTINGPAIRSEPERATOR + SettingParts[ONE], SettingParts[ZERO] + SETTINGPAIRSEPERATOR + NewValue); SettingChanged = true; } } if (SettingChanged) { File.WriteAllText(SaveLocation + DEFAULTFILE, FileInput); } else { throw new RtSettingNotFoundException(Key); } }
public static string ReadSetting(string Key) { string FileInput = File.ReadAllText(SaveLocation + DEFAULTFILE); foreach (string SettingLine in FileInput.Split(SETTINGSEPERATOR)) { string[] SettingParts = SettingLine.Split(SETTINGPAIRSEPERATOR); if (SettingParts[ZERO] == Key) { return(SettingParts[ONE]); } } throw new RtSettingNotFoundException(Key); }
private static bool CheckSettingFile(List <string> SettingContent) { bool IsOkay = false; bool BoolValue = false; string StrValue = ""; int IntValue = 0; foreach (string SettingLine in SettingContent) { #region TTSSettingCheck if (SettingLine.Contains("TTS_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Min_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Max_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Content_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Effect_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Filter : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("TTS_Content : ")) { IsOkay = true; } else if (SettingLine.Contains("TTS_Effect_List : ")) { IsOkay = true; } else if (SettingLine.Contains("TTS_Voice : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; if (StrValue == "TTS_Voice_Heami" || StrValue == "TTS_Voice_Google" || StrValue == "TTS_Voice_Randome") { IsOkay = true; } } else if (SettingLine.Contains("TTS_Effect : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("TTS_Min : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("TTS_Max : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } #endregion #region FloatDonationMessageSettingCheck if (SettingLine.Contains("FDM_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("FDM_Min_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("FDM_Max_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("FDM_Filter : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("FDM_Content : ")) { IsOkay = true; } else if (SettingLine.Contains("FDM_Intro : ")) { IsOkay = true; } else if (SettingLine.Contains("FDM_Effect : ")) { IsOkay = true; } else if (SettingLine.Contains("FDM_Outtro : ")) { IsOkay = true; } else if (SettingLine.Contains("FDM_Time : ")) { IsOkay = true; } else if (SettingLine.Contains("FDM_Min : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("FDM_Max : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } #endregion #region YoutubeSettingCheck if (SettingLine.Contains("Youtube_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("Youtube_Next_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("Youtube_Min_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("Youtube_Max_Enable : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("Youtube_Filter : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = bool.TryParse(StrValue, out BoolValue); } else if (SettingLine.Contains("Youtube_Min : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("Youtube_Max : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } #endregion #region BroadCastFrmCheck if (SettingLine.Contains("Youtube_X : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("Youtube_Y : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("Youtube_Width : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("Youtube_Height : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("FDM_X : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("FDM_Y : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("FDM_Width : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } else if (SettingLine.Contains("FDM_Height : ")) { StrValue = Regex.Split(SettingLine, " : ")[1]; IsOkay = int.TryParse(StrValue, out IntValue); } #endregion if (IsOkay == false) { return(false); } } return(true); }