//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// public static void iniWrite(string path, string section, string key, string value) { bool readyToWrite = false; blockClearSR = true; string line = stringRead(path, section, key); blockClearSR = false; if (lineIndex != -1) { if (line == null || value == null || line.ToLower() != value.ToLower()) { cacheFile[lineIndex] = key + "=" + value; readyToWrite = true; } } else { if (startIndex != -1 && enbIndex != -1) { cacheFile[enbIndex] += Environment.NewLine + key + "=" + value; readyToWrite = true; } else { File.AppendAllText(path, Environment.NewLine + "[" + section + "]" + Environment.NewLine + key + "=" + value + Environment.NewLine); } } if (readyToWrite) { FuncMisc.writeToFile(path, cacheFile); } cacheFile = null; }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void OnProcessExit(object sender, EventArgs e) { if (!File.Exists(pathLauncherINI)) { FuncMisc.writeToFile(pathLauncherINI, new List <string>() { "[General]", "Version_CP=" + panelFileVersion, "HideWebButtons=false", "POS_WindowTop=100", "POS_WindowLeft=100", "SettingsPreset=2", "NumberStyle=1", "AspectRatio=-1", "Language=RU", "", "[Game]", "PredictFPS=60", "ZFighting=0", "NearDistance=18", "", "[ENB]", "MemorySizeMb=0", "LastPreset=", "", "[Font]", "CP_Font=", "", "Exaples:", " Comic Sans MS", " Courier New", " Franklin Gothic Medium", " Georgia", " Impact", " Lucida Sans Unicode", " Microsoft Sans Serif", " Palatino Linotype", " Tahoma", " Times New Roman", " Trebuchet MS", "", "[Updates]", "UpdateHost=http://www.slmp.ru/_SLMP-GR/2.6/" }); } else { FuncParser.iniWrite(pathLauncherINI, "General", "SettingsPreset", settingsPreset.ToString()); FuncParser.iniWrite(pathLauncherINI, "General", "NumberStyle", numberStyle.ToString()); FuncParser.iniWrite(pathLauncherINI, "General", "Language", langTranslate); FuncParser.iniWrite(pathLauncherINI, "Game", "PredictFPS", predictFPS.ToString()); if (Top >= 0 && Left >= 0) { FuncParser.iniWrite(pathLauncherINI, "General", "POS_WindowTop", Top.ToString()); FuncParser.iniWrite(pathLauncherINI, "General", "POS_WindowLeft", Left.ToString()); } } AppDomain.CurrentDomain.ProcessExit -= new EventHandler(OnProcessExit); }
private void writeMasterFile() { List <string> writeList = new List <string>(); foreach (ListViewItem item in listView1.CheckedItems) { if (item.Text.ToLower() != "skyrim.esm") { writeList.Add(item.Text); } } FuncMisc.writeToFile(pathToPlugins, writeList); writeList.Clear(); foreach (ListViewItem item in listView1.Items) { writeList.Add(item.Text); } FuncMisc.writeToFile(pathToLoader, writeList); writeList = null; label4.Text = listView1.CheckedItems.Count.ToString() + " / " + listView1.Items.Count.ToString(); }
private void button_AddIgnoreFiles_Click(object sender, EventArgs e) { label1.Focus(); openFileDialog1.InitialDirectory = pathGameFolder; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { if (openFileDialog1.FileName.IndexOf(pathGameFolder, StringComparison.OrdinalIgnoreCase) >= 0) { List <string> ignoreList = new List <string>(); ignoreList.AddRange(File.ReadAllLines(pathIgnoreINI)); foreach (string line in openFileDialog1.FileNames) { string file = line.Remove(0, gameDirLength); if (!ignoreList.Exists(s => s.Equals(file, StringComparison.OrdinalIgnoreCase))) { ignoreList.Add(file); } } string path = Path.GetDirectoryName(openFileDialog1.FileName); while (path.Length > gameDirLength) { string folder = path.Remove(0, gameDirLength); if (!ignoreList.Exists(s => s.Equals(folder, StringComparison.OrdinalIgnoreCase))) { ignoreList.Add(folder); } path = Path.GetDirectoryName(path); } FuncMisc.writeToFile(pathIgnoreINI, ignoreList); ignoreList.Clear(); } else { MessageBox.Show(textNotInDirectory); } } }
private void button_AddIgnoreFolder_Click(object sender, EventArgs e) { label1.Focus(); folderBrowserDialog1.SelectedPath = pathGameFolder; DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { if (folderBrowserDialog1.SelectedPath.IndexOf(pathGameFolder, StringComparison.OrdinalIgnoreCase) >= 0) { List <string> ignoreList = new List <string>(); ignoreList.AddRange(File.ReadAllLines(pathIgnoreINI)); ignoreList.Add(folderBrowserDialog1.SelectedPath.Remove(0, gameDirLength)); foreach (string line1 in Directory.EnumerateDirectories(folderBrowserDialog1.SelectedPath, "*", SearchOption.AllDirectories)) { string folder = line1.Remove(0, gameDirLength); if (!ignoreList.Exists(s => s.Equals(folder, StringComparison.OrdinalIgnoreCase))) { ignoreList.Add(folder); } } foreach (string line2 in Directory.EnumerateFiles(folderBrowserDialog1.SelectedPath, "*", SearchOption.AllDirectories)) { string file = line2.Remove(0, gameDirLength); if (!ignoreList.Exists(s => s.Equals(file, StringComparison.OrdinalIgnoreCase))) { ignoreList.Add(file); } } FuncMisc.writeToFile(pathIgnoreINI, ignoreList); ignoreList.Clear(); } else { MessageBox.Show(textNotInDirectory); } } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // public static void iniWrite(string path, string section, string key, string value) { bool readyToWrite = false; blockClearSR = true; string line = stringRead(path, section, key); if (lineIndex != -1) { if (value != null && value.Length == 0) { value = null; } if (!string.Equals(line, value, StringComparison.OrdinalIgnoreCase)) { cacheFile[lineIndex] = key + "=" + value; readyToWrite = true; } } else { if (startIndex != -1 && enbIndex != -1) { cacheFile[enbIndex] += Environment.NewLine + key + "=" + value; readyToWrite = true; } else if (File.Exists(path)) { FuncMisc.appendToFile(path, Environment.NewLine + "[" + section + "]" + Environment.NewLine + key + "=" + value); } } if (readyToWrite) { FuncMisc.writeToFile(path, cacheFile); } cacheFile.Clear(); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (stopDownload) { if (File.Exists(pathUpdateFolder + nameUpdateInfo)) { if (downloadFileType == "CheckU") { int CountComboBox = FuncParser.intRead(pathUpdateFolder + nameUpdateInfo, "General", "numbers_files_update"); if (CountComboBox > 0) { for (int i = 1; i <= CountComboBox; i++) { comboBox_Updates.SelectedIndexChanged -= comboBox_Updates_SelectedIndexChanged; if (checkUpdateVersion(i)) { realIndexI.Add(i); installPreLoad.Add(textInstalled + " / " + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } else { realIndex.Add(i); comboBox_Updates.Items.Add(textAvailable + " / " + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } comboBox_Updates.SelectedIndexChanged += comboBox_Updates_SelectedIndexChanged; } for (int i = 0; i < realIndexI.Count; i++) { realIndex.Add(realIndexI[i]); comboBox_Updates.Items.Add(installPreLoad[i]); } if (comboBox_Updates.Items.Count > 0) { comboBox_Updates.SelectedIndex = 0; } updatesFound = true; label4.Text = CountComboBox.ToString(); } else { updatesFound = false; label4.Text = textNoUpdate; } string line = FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "General", "version_control_panel"); if (line != null) { var result = new Version(FormMain.panelFileVersion).CompareTo(new Version(line)); updatesCPFound = result < 0; } } if (downloadFileType == "UpdateG") { if (checkUpdateFile(true)) { unpackUpdates(false); } } if (downloadFileType == "UpdateCP") { string version1 = FileVersionInfo.GetVersionInfo(pathUpdateFolder + nameControlPanel).ProductVersion; if (version1 == FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "General", "version_control_panel")) { FuncMisc.writeToFile(FormMain.pathLauncherFolder + "Update.bat", new List <string>() { "@Echo off", "mode con:cols=50 lines=10", "color 0E", "cd %~dp0", "SET CP_S=" + FormMain.pathLauncherExecuting, "SET CP_U=" + pathUpdateFolder + nameControlPanel, "Echo Please Wait 5 second before start update.", "TIMEOUT /T 2 /NOBREAK >nul 2>nul", "IF EXIST \"%CP_U%\" (", "Echo -Update file found.", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Delete old file control panel.", "del \"%CP_S%\" /Q >nul 2>nul", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Move new file control panel.", "move /Y \"%CP_U%\" \"%CP_S%\" >nul 2>nul", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Expectation launching new control panel.", "start \"Run new file\" \"%CP_S%\" >nul 2>nul", ") else (", "Echo -Update file not found...", "TIMEOUT /T 5 /NOBREAK >nul 2>nul", ")", "Echo -Closing.", "TIMEOUT /T 2 /NOBREAK >nul 2>nul", "del \"" + FormMain.pathLauncherFolder + "Update.bat\" /Q >nul 2>nul" }); FuncMisc.runProcess(FormMain.pathLauncherFolder + "Update.bat", null, null, this, true, false); Application.Exit(); } else { MessageBox.Show(textNoSyncWithUI); FuncFiles.deleteAny(pathUpdateFolder + nameControlPanel); } } } else { updatesFound = false; updatesCPFound = false; } } stopDownload = false; progressBar1.Value = 0; enableDisableButtons(); }
public void resetSettings() { try { RegistryKey key; key = Registry.LocalMachine.CreateSubKey(registryPath); key.SetValue(registryKey, pathGameFolder); key.Close(); } catch { MessageBox.Show(failWriteToRegistry + registryPath + " " + registryKey + "=" + pathGameFolder); } FuncFiles.deleteAny(pathMyDoc + "Logs"); FuncFiles.deleteAny(pathMyDoc + "SKSE"); FuncFiles.deleteAny(pathMyDoc + "SkyProc"); FuncFiles.deleteAny(pathMyDoc + "BethINI Cache"); FuncFiles.deleteAny(pathMyDoc + "BashSettings.dat"); FuncFiles.deleteAny(pathMyDoc + "BashSettings.dat.bak"); FuncFiles.deleteAny(pathMyDoc + "RendererInfo.txt"); FuncFiles.deleteAny(pathMyDoc + @"Saves\Bash"); FuncFiles.deleteAny(pathSkyrimINI); FuncFiles.deleteAny(pathSkyrimPrefsINI); FuncFiles.creatDirectory(pathMyDoc); if (File.Exists(pathLauncherFolder + "Skyrim.ini")) { FuncFiles.copyAny(pathLauncherFolder + "Skyrim.ini", pathSkyrimINI); } else { FuncMisc.writeToFile(pathSkyrimINI, FuncSettings.skyrimINI()); } if (File.Exists(pathLauncherFolder + "SkyrimPrefs.ini")) { FuncFiles.copyAny(pathLauncherFolder + "SkyrimPrefs.ini", pathSkyrimPrefsINI); } else { FuncMisc.writeToFile(pathSkyrimPrefsINI, FuncSettings.skyrimPrefsINI()); } if (File.Exists(pathLauncherFolder + @"MasterList\BashSettings.dat")) { FuncFiles.copyAny(pathLauncherFolder + @"MasterList\BashSettings.dat", pathMyDoc + "BashSettings.dat"); } FuncFiles.deleteAny(pathAppData + @"Plugins.txt"); FuncFiles.deleteAny(pathAppData + @"LoadOrder.txt"); FuncFiles.deleteAny(pathAppData + @"Plugins.tes5viewsettings"); FuncFiles.creatDirectory(pathAppData); if (File.Exists(pathLauncherFolder + @"MasterList\Plugins.txt")) { FuncFiles.copyAny(pathLauncherFolder + @"MasterList\Plugins.txt", pathAppData + @"Plugins.txt"); FuncFiles.copyAny(pathLauncherFolder + @"MasterList\Plugins.txt", pathAppData + @"LoadOrder.txt"); } else { FuncMisc.writeToFile(pathAppData + @"Plugins.txt", FuncSettings.pluginsTXT()); FuncMisc.writeToFile(pathAppData + @"LoadOrder.txt", FuncSettings.pluginsTXT()); } if (File.Exists(pathLauncherFolder + @"MasterList\Plugins.tes5viewsettings")) { FuncFiles.copyAny(pathLauncherFolder + @"MasterList\Plugins.tes5viewsettings", pathAppData + @"Plugins.tes5viewsettings"); } FuncSettings.setSettingsPreset(settingsPreset); FuncParser.iniWrite(pathSkyrimPrefsINI, "Display", "iSize W", Screen.PrimaryScreen.Bounds.Width.ToString()); FuncParser.iniWrite(pathSkyrimPrefsINI, "Display", "iSize H", Screen.PrimaryScreen.Bounds.Height.ToString()); FuncSettings.physicsFPS(); FuncSettings.restoreENBAdapter(); FuncSettings.restoreENBBorderless(); FuncSettings.restoreENBVSync(); MessageBox.Show(typeSettings[settingsPreset] + setSettings); }