public void ReloadConfig(string configPath) { var configFilePath = new FileInfo(configPath); if (configFilePath.Exists) { var configString = File.ReadAllText(configFilePath.FullName); var serializer = new XmlSerializer(typeof(Config)); using (var configIn = new MemoryStream(Encoding.Unicode.GetBytes(configString))) { var newConfig = serializer.Deserialize(configIn) as Config; ConfigKeyBind = newConfig.ConfigKeyBind; Enabled = newConfig.Enabled; EnabledKeyBind = newConfig.EnabledKeyBind; TimeOnScreen = newConfig.TimeOnScreen; CutoffSlightlyEarly = newConfig.CutoffSlightlyEarly; CutoffEarly = newConfig.CutoffEarly; CutoffVeryEarly = newConfig.CutoffVeryEarly; CutoffSlightlyLate = newConfig.CutoffSlightlyLate; CutoffLate = newConfig.CutoffLate; CutoffVeryLate = newConfig.CutoffVeryLate; ColorPerfect = newConfig.ColorPerfect; ColorSlightlyEarly = newConfig.ColorSlightlyEarly; ColorEarly = newConfig.ColorEarly; ColorVeryEarly = newConfig.ColorVeryEarly; ColorSlightlyLate = newConfig.ColorSlightlyLate; ColorLate = newConfig.ColorLate; ColorVeryLate = newConfig.ColorVeryLate; ColorMissed = newConfig.ColorMissed; AccuracyTime = newConfig.AccuracyTime; AccuracyMessage = newConfig.AccuracyMessage; AverageAccuracy = newConfig.AverageAccuracy; } } }
public Config() { Version = 2; TweakVersion = "0.0.0"; SilenceUpdates = false; ConfigX = 300.0f; ConfigY = 200.0f; ConfigKeyBind = new KeyBind { Key = KeyCode.F7, Ctrl = true, Alt = false, Shift = true }; Enabled = true; EnabledKeyBind = new KeyBind { Key = KeyCode.F7, Ctrl = false, Alt = false, Shift = false }; TimeOnScreen = 0.75f; CutoffSlightlyEarly = 0.01f; CutoffEarly = 0.02f; CutoffVeryEarly = 0.03f; CutoffSlightlyLate = 0.01f; CutoffLate = 0.02f; CutoffVeryLate = 0.03f; ColorPerfect = new ColorARGB(Color.white); ColorSlightlyEarly = new ColorARGB(Color.yellow); ColorEarly = new ColorARGB(new Color(1.0f, 0.5f, 0.0f)); ColorVeryEarly = new ColorARGB(Color.red); ColorSlightlyLate = new ColorARGB(new Color(0.25f, 0.9f, 1.0f)); ColorLate = new ColorARGB(new Color(0.0f, 0.5f, 1.0f)); ColorVeryLate = new ColorARGB(new Color(0.5f, 0.0f, 1.0f)); ColorMissed = new ColorARGB(Color.grey); AccuracyTime = new PositionableLabel { Visible = true, X = (int)(Screen.width * 0.8f), Y = (int)(Screen.height * (1270.0f / 1440.0f)), Size = Screen.height * 50 / 1440, Bold = true, Italic = false, Alignment = TextAnchor.MiddleCenter }; AccuracyMessage = new PositionableLabel { Visible = true, X = (int)(Screen.width * 0.8f), Y = (int)(Screen.height * (1330.0f / 1440.0f)), Size = Screen.height * 50 / 1440, Bold = true, Italic = false, Alignment = TextAnchor.MiddleCenter }; AverageAccuracy = new PositionableLabel { Visible = false, X = (int)(Screen.width * 0.8f), Y = (int)(Screen.height * (1390.0f / 1440.0f)), Size = Screen.height * 50 / 1440, Bold = true, Italic = false, Alignment = TextAnchor.MiddleCenter }; }
public Config(OldConfig oldConfig) { Version = 2; TweakVersion = "0.0.0"; SilenceUpdates = false; ConfigX = oldConfig.ConfigX; ConfigY = oldConfig.ConfigY; ConfigKeyBind = new KeyBind { Key = KeyCode.F7, Ctrl = true, Alt = false, Shift = true }; Enabled = oldConfig.Enabled; EnabledKeyBind = new KeyBind { Key = KeyCode.F7, Ctrl = false, Alt = false, Shift = false }; TimeOnScreen = oldConfig.TimeOnScreen; CutoffSlightlyEarly = oldConfig.CutoffSlightlyEarly; CutoffEarly = oldConfig.CutoffEarly; CutoffVeryEarly = oldConfig.CutoffVeryEarly; CutoffSlightlyLate = oldConfig.CutoffSlightlyLate; CutoffLate = oldConfig.CutoffLate; CutoffVeryLate = oldConfig.CutoffVeryLate; ColorPerfect = new ColorARGB(oldConfig.ColorPerfectARGB); ColorSlightlyEarly = new ColorARGB(oldConfig.ColorSlightlyEarlyARGB); ColorEarly = new ColorARGB(oldConfig.ColorEarlyARGB); ColorVeryEarly = new ColorARGB(oldConfig.ColorVeryEarlyARGB); ColorSlightlyLate = new ColorARGB(oldConfig.ColorSlightlyLateARGB); ColorLate = new ColorARGB(oldConfig.ColorLateARGB); ColorVeryLate = new ColorARGB(oldConfig.ColorVeryLateARGB); ColorMissed = new ColorARGB(oldConfig.ColorMissedARGB); AccuracyTime = new PositionableLabel { Visible = oldConfig.AccuracyTime, X = (int)oldConfig.AccuracyTimeX, Y = (int)oldConfig.AccuracyTimeY, Size = oldConfig.AccuracyTimeScale, Bold = oldConfig.AccuracyTimeBold, Italic = oldConfig.AccuracyTimeItalic, Alignment = TextAnchor.MiddleCenter }; AccuracyMessage = new PositionableLabel { Visible = oldConfig.AccuracyMessage, X = (int)oldConfig.AccuracyMessageX, Y = (int)oldConfig.AccuracyMessageY, Size = oldConfig.AccuracyMessageScale, Bold = oldConfig.AccuracyMessageBold, Italic = oldConfig.AccuracyMessageItalic, Alignment = TextAnchor.MiddleCenter }; AverageAccuracy = new PositionableLabel { Visible = oldConfig.AverageAccuracy, X = (int)oldConfig.AverageAccuracyX, Y = (int)oldConfig.AverageAccuracyY, Size = oldConfig.AverageAccuracyScale, Bold = oldConfig.AverageAccuracyBold, Italic = oldConfig.AverageAccuracyItalic, Alignment = TextAnchor.MiddleCenter }; }