public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(pathLauncherFolder); if (File.Exists(pathLauncherINI)) { if (panelFileVersion != FuncParser.stringRead(pathLauncherINI, "General", "Version_CP")) { FuncParser.iniWrite(pathLauncherINI, "General", "Version_CP", panelFileVersion); } int wLeft = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowLeft"); int wTop = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowTop"); if (wLeft < 0 || wTop < 0) { StartPosition = FormStartPosition.CenterScreen; } else { if (wLeft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { wLeft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } if (wTop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { wTop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } StartPosition = FormStartPosition.Manual; Location = new Point(wLeft, wTop); } settingsPreset = FuncParser.intRead(pathLauncherINI, "General", "SettingsPreset"); if (settingsPreset < 0 || settingsPreset > 3) { settingsPreset = 2; } numberStyle = FuncParser.intRead(pathLauncherINI, "General", "NumberStyle"); if (numberStyle < 1 || numberStyle > 2) { numberStyle = 1; } if (FuncParser.stringRead(pathLauncherINI, "General", "Language").ToUpper() == "EN") { langTranslate = "EN"; setLangTranslateEN(); } else { setLangTranslateRU(); } predictFPS = FuncParser.intRead(pathLauncherINI, "Game", "PredictFPS"); if (predictFPS < 30 || predictFPS > 240) { predictFPS = 60; } if (!FuncParser.keyExists(pathLauncherINI, "Game", "ZFighting")) { FuncParser.iniWrite(pathLauncherINI, "Game", "ZFighting", "0"); } int nearDistance = FuncParser.intRead(pathLauncherINI, "Game", "NearDistance"); if (nearDistance < 15 || nearDistance > 25) { FuncParser.iniWrite(pathLauncherINI, "Game", "NearDistance", "18"); } customFont = FuncParser.stringRead(pathLauncherINI, "Font", "CP_Font"); if (customFont != null) { var ifc = new InstalledFontCollection(); for (int i = ifc.Families.Length - 1; i >= 0; i--) { if (ifc.Families[i].Name == customFont) { FuncMisc.supportStrikeOut(customFont); FuncMisc.setFormFont(this); break; } else if (i == 0) { customFont = null; } } ifc = null; } } else { setLangTranslateRU(); StartPosition = FormStartPosition.CenterScreen; OnProcessExit(this, new EventArgs()); } if (!File.Exists(pathSkyrimPrefsINI) || !File.Exists(pathSkyrimINI)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); refreshStyle(); }
public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(pathLauncherFolder); if (!Directory.Exists(pathDataFolder)) { MessageBox.Show(@"Панель Управления должна располагаться по адресу: Директория Игры\Любая Папка\" + Environment.NewLine + Environment.NewLine + @"The Control Panel should be located at: Game Directory\Any Folder\"); Environment.Exit(0); } string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 0) { foreach (string line in arguments) { if (line.StartsWith("-s=", StringComparison.OrdinalIgnoreCase)) { argsStartsWith = line.Remove(0, 3); } else if (line.StartsWith("-w=", StringComparison.OrdinalIgnoreCase)) { argsWaitBefore = FuncParser.stringToInt(line.Remove(0, 3)); } } arguments = null; } if (File.Exists(pathLauncherINI)) { FuncParser.iniWrite(pathLauncherINI, "General", "Version_CP", panelFileVersion); int wLeft = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowLeft"); int wTop = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowTop"); if (wLeft < 0 || wTop < 0) { StartPosition = FormStartPosition.CenterScreen; } else { if (wLeft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { wLeft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } if (wTop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { wTop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } StartPosition = FormStartPosition.Manual; Location = new Point(wLeft, wTop); } settingsPreset = FuncParser.intRead(pathLauncherINI, "General", "SettingsPreset"); if (settingsPreset < 0 || settingsPreset > 3) { settingsPreset = 2; } numberStyle = FuncParser.intRead(pathLauncherINI, "General", "NumberStyle"); if (numberStyle < 1 || numberStyle > 2) { numberStyle = 1; } if (string.Equals(FuncParser.stringRead(pathLauncherINI, "General", "Language"), "EN", StringComparison.OrdinalIgnoreCase)) { langTranslate = "EN"; setLangTranslateEN(); } else { setLangTranslateRU(); } maxFPS = FuncParser.intRead(pathLauncherINI, "Game", "MaxFPS"); if (maxFPS < 30 || maxFPS > 240) { maxFPS = 60; } if (!FuncParser.keyExists(pathLauncherINI, "Game", "ZFighting")) { FuncParser.iniWrite(pathLauncherINI, "Game", "ZFighting", "false"); } int nearDistance = FuncParser.intRead(pathLauncherINI, "Game", "NearDistance"); if (nearDistance < 15 || nearDistance > 25) { FuncParser.iniWrite(pathLauncherINI, "Game", "NearDistance", "18"); } customFont = FuncParser.stringRead(pathLauncherINI, "Font", "CP_Font"); if (customFont != null) { var ifc = new InstalledFontCollection(); for (int i = ifc.Families.Length - 1; i >= 0; i--) { if (ifc.Families[i].Name == customFont) { FuncMisc.supportStrikeOut(customFont); FuncMisc.setFormFont(this); break; } else if (i == 0) { customFont = null; } } ifc = null; } } else { setLangTranslateRU(); StartPosition = FormStartPosition.CenterScreen; closeControlPanel(this, new EventArgs()); } if (!File.Exists(pathSkyrimPrefsINI) || !File.Exists(pathSkyrimINI)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(closeControlPanel); refreshStyle(); }