/// <summary> /// Attempts to install the actual update and returns true if no exceptions occured. /// </summary> /// <returns>bool</returns> public static bool InstallUpdate() { if (Directory.Exists("update")) { Directory.Delete("update", true); } try { var extractionPath = VRegistry.GetSubKeyValue("Path").ToString().Replace("/", "\\"); var archive = ZipFile.OpenRead("data_" + UpdateData.Version + ".rar"); ExtractToDirectory(archive, extractionPath, true); } catch (Exception e) { MessageBox.Show("Update has failed to install.\n\nError code: " + e.Message, "An error occured"); return(false); } Analytics.TrackEvent("Update has been installed!", new Dictionary <string, string> { { "Version", UpdateData.Version } }); VRegistry.CreateSubKey("Version", UpdateData.Version); return(true); }
/// <summary> /// removes the older version. /// </summary> /// <param name="codeName"></param> public static void RemoveOlderUpdate(string codeName) { string file_120 = Properties.Resources.VR12Files; string file_130 = Properties.Resources.VR13Files; string path = VRegistry.GetSubKeyValue("Path").ToString(); if (codeName == "1.2.0") { var lines = file_120.Split(new[] { Environment.NewLine }, StringSplitOptions.None); foreach (var line in lines) { string pathDel = path + "\\" + line; if (File.Exists(pathDel)) { File.SetAttributes(pathDel, FileAttributes.Normal); File.Delete(pathDel); ConsoleWrapper.PrintMessage("Deleting previous data chunk (" + pathDel + ")", ConsoleWrapper.PrintStatus.Warning); } else { ConsoleWrapper.PrintMessage("Skipping file " + pathDel, ConsoleWrapper.PrintStatus.Normal); } } } if (codeName == "1.3.0") { var lines = file_130.Split(new[] { Environment.NewLine }, StringSplitOptions.None); foreach (var line in lines) { string pathDel = path + "\\" + line; if (File.Exists(pathDel)) { File.SetAttributes(pathDel, FileAttributes.Normal); File.Delete(pathDel); ConsoleWrapper.PrintMessage("Deleting previous 1.3.0 data chunk (" + pathDel + ")", ConsoleWrapper.PrintStatus.Warning); } else { ConsoleWrapper.PrintMessage("Skipping file " + pathDel, ConsoleWrapper.PrintStatus.Normal); } } } }
/// <summary> /// Checks if a new version is available by first fetching the new version number from the /// website and then comparing local version number with fetched one. /// </summary> /// <returns></returns> public static bool IsNewVersionAvailable() { FetchVersion(); if (VRegistry.GetSubKeyValue("Version").Equals(null)) { VRegistry.CreateSubKey("Version", "0.0.0"); } if (!VRegistry.GetSubKeyValue("Version").ToString().Equals(UpdateData.Version)) { return(true); } return(false); }
public static void Run() { if (VRegistry.IsFirstRun()) { var folderBrowser = new OpenFileDialog { ValidateNames = false, CheckFileExists = false, CheckPathExists = true, FileName = "Select game root path" }; if (folderBrowser.ShowDialog() == DialogResult.OK) { var folderPath = Path.GetDirectoryName(folderBrowser.FileName); if (GameCheck.IsWorkspaceValid(folderPath)) { VRegistry.CreateSubKey("Path", folderPath); SelectVRVersionForm selectVRVersionForm = new SelectVRVersionForm(); selectVRVersionForm.Show(); // TEMP FIX. } else { //Notifications.PlayErrorSound(); MaterialMessageBox.Show(null, "The selected folder does not look valid. This might happen if you've selected wrong folder.\n\n" + "Start the app once again and select proper folder. If this error still presists, contact developers.", "Important message!", MessageBoxButtons.OK); Application.Restart(); } } else { Application.Exit(); } } }
private void Form1_Load(object sender, EventArgs e) { VRegistry.CreateSubKey("Launch", ""); // create a key in case it doesn't exist. Hide(); if (VRegistry.IsFirstRun()) { SetupLogic.Run(); } BringToTop(); Focus(); MaterialSkinManager = MaterialSkinManager.Instance; MaterialSkinManager.AddFormToManage(this); SetUiTheme(MaterialSkinManager.Themes.LIGHT); if (_userSettings.Theme == "Dark") { SetUiTheme(MaterialSkinManager.Themes.DARK); themeSwitch.Checked = false; } MaterialSkinManager.ColorScheme = new ColorScheme(Primary.Green800, Primary.Grey900, Primary.Green700, Accent.Green700, TextShade.WHITE); updaterVerLbl.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (VRegistry.GetSubKeyValue("Version") != null) { versionLabel.Text += VRegistry.GetSubKeyValue("Version").ToString(); } if (_userSettings.AutoUpdate) { updateSwitch.Checked = true; } backgroundChecker.RunWorkerAsync(); }
private void ver140Btn_Click(object sender, EventArgs e) { VRegistry.CreateSubKey("Version", "1.4.0"); }
private void idkBtn_Click(object sender, EventArgs e) { VRegistry.CreateSubKey("Version", "Unknown"); Application.Restart(); }
private void optionnoEnb_Click(object sender, EventArgs e) { VRegistry.CreateSubKey("Version", "1.3.0"); Application.Restart(); }
private void changePathBtn_Click(object sender, EventArgs e) { VRegistry.CreateSubKey("Path", ""); Application.Restart(); }
private async void updateBtn_Click(object sender, EventArgs e) { if (ProcessWatcher.IsGameRunning()) { Notifications.PlayErrorSound(); MaterialMessageBox.Show(null, "The game is active and running! Please close it if you wish to begin updating.", "CLOSE THE GAME", MessageBoxButtons.OK); return; } if (UpdateData.Version.Equals("1.3.0") && VRegistry.GetSubKeyValue("Version").Equals("1.2.0")) { Notifications.PlayNotificationSound2(); var dialogResult = MaterialMessageBox.Show(null, "Update 1.3.0 has a different file system organization and therefore previous update files must be removed.\n" + "Would you like the client to delete a list of 1.2.0 files and begin installing 1.3.0?", "Important notice!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Updater.RemoveOlderUpdate("1.2.0"); } else { CleanUpdateUi(); return; } } if (UpdateData.Version.Equals("1.4.0") && VRegistry.GetSubKeyValue("Version").Equals("1.3.0")) { Updater.RemoveOlderUpdate("1.3.0"); } checkUpdatesBtn.Enabled = false; updateBtn.Enabled = false; changePathBtn.Enabled = false; if (File.Exists("data_" + UpdateData.Version + ".rar")) { Notifications.PlayNotificationSound2(); var dialogResult = MaterialMessageBox.Show(null, "We've found already downloaded update package.\n\n" + "The package might be corrupted / invalid." + "Do you wish to install this package?", "Package found", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); if (dialogResult == DialogResult.Yes) { versionAvailableLbl.Text = "installing the cached update ..."; var installCached = Task.Run(() => Updater.InstallUpdate()); await Task.WhenAll(installCached); if (installCached.Result) { DisplayFinishedInstallUi(); } else { CleanUpdateUi(); Notifications.PlayErrorSound(); FlashWindow(this.Handle, true); return; } CleanupUpdate(); Analytics.TrackEvent("Cached update has been installed", new Dictionary <string, string> { { "Version", UpdateData.Version } }); } else { DownloadUpdate(); } } else { DownloadUpdate(); } }