public static bool refreshButton(Button button, string file, string section, string parameter, string value, bool invert) { if (FuncParser.keyExists(file, section, parameter)) { button.Enabled = true; string readString = FuncParser.stringRead(file, section, parameter); bool toggle = false; toggle = readString != null && (readString == value || readString == "1" || string.Equals(readString, "true", StringComparison.OrdinalIgnoreCase)); toggle = invert ? !toggle : toggle; if (toggle) { button.BackgroundImage = Properties.Resources.buttonToggleOn; } else { button.BackgroundImage = Properties.Resources.buttonToggleOff; } return(toggle); } else { button.BackgroundImage = Properties.Resources.buttonToggleDisable; button.Enabled = false; return(false); } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // public static void refreshTrackBar(TrackBar trackbar, string file, string section, string parameter, int division, Label label) { if (FuncParser.keyExists(file, section, parameter)) { trackbar.Enabled = true; int readINT = FuncParser.intRead(file, section, parameter); if (division != -1) { readINT = readINT / division; } if (readINT >= trackbar.Minimum && readINT <= trackbar.Maximum) { if (division != -1) { label.Text = (readINT * division).ToString(); } else { label.Text = readINT.ToString(); } trackbar.Value = readINT; } else { label.Text = "N/A"; } } else { label.Text = "N/A"; trackbar.Enabled = false; } }
private void unpackUpdates(bool readyDL) { for (int i = 1; i <= 200; i++) { if (FuncParser.keyExists(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_delete_file_" + i.ToString())) { FuncFiles.deleteAny(FormMain.pathGameFolder + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_delete_file_" + i.ToString())); } else { break; } } FuncMisc.unpackRAR(pathUpdateFolder + "file" + numberSelectFile + ".rar"); FuncParser.iniWrite(FormMain.pathLauncherINI, "Updates", "Update_" + numberSelectFile + "_Version", FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_version")); comboBox_Updates_SelectedIndexChanged(this, new EventArgs()); if (readyDL) { stopDownload = false; enableDisableButtons(); } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void button_Uninstall_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { if (FuncMisc.dialogResult(textDeleteMod)) { string file = FormMain.pathModsFolder + listBox1.SelectedItem.ToString().Replace(".rar", ".txt"); if (File.Exists(file)) { foreach (string line in File.ReadLines(file)) { if (line.StartsWith("[")) { break; } else if (line.Length > 0) { FuncFiles.deleteAny(FormMain.pathGameFolder + line); } } if (FuncParser.keyExists(file, "UNINSTALL", "UNPACK")) { FuncMisc.unpackRAR(FormMain.pathGameFolder + FuncParser.stringRead(file, "UNINSTALL", "UNPACK")); } } else { MessageBox.Show(textNoUninstalFile); } } } else { MessageBox.Show(textNoFileSelect); } }
public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(FormMain.launcherFolder); if (File.Exists(iniLauncher)) { if (FuncParser.keyExists(iniLauncher, "Position", "POS_WindowTop") && FuncParser.keyExists(iniLauncher, "Position", "POS_WindowLeft")) { int Wleft = -1; int Wtop = -1; Wleft = FuncParser.intRead(iniLauncher, "Position", "POS_WindowLeft"); Wtop = FuncParser.intRead(iniLauncher, "Position", "POS_WindowTop"); if (Wleft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { Wleft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } else if (Wleft < 0) { Wleft = 0; } if (Wtop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { Wtop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } else if (Wtop < 0) { Wtop = 0; } StartPosition = FormStartPosition.Manual; Location = new Point(Wleft, Wtop); } else { StartPosition = FormStartPosition.CenterScreen; } if (FuncParser.keyExists(iniLauncher, "General", "Language")) { if (FuncParser.stringRead(iniLauncher, "General", "Language") == "RU") { SetLangTranslateRU(true); } else { langTranslate = "EN"; SetLangTranslateEN(); } } string version = FuncParser.stringRead(iniLauncher, "General", "Version_CP"); if (FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion != version) { FuncParser.iniWrite(iniLauncher, "General", "Version_CP", FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion); } numberStyle = FuncParser.intRead(iniLauncher, "General", "NumberStyle"); if (numberStyle < 1 && numberStyle > 2) { numberStyle = 1; } } else { SetLangTranslateRU(true); StartPosition = FormStartPosition.CenterScreen; OnProcessExit(this, new EventArgs()); } if (!File.Exists(iniSkyrimPrefs) || !File.Exists(iniSkyrim)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); RefreshStyle(); }
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(); }