public static void DownloadLatest(string url) { ui.writeLine("New Update!\r\n\r\nDownloading: " + url); Uri uri; Uri.TryCreate(url, UriKind.Absolute, out uri); using (var client = new TimedWebClient()) { client.Proxy = null; client.DownloadFileAsync(uri, Path.GetTempPath() + "\\PrimeHackRelease.zip"); client.DownloadProgressChanged += ui.UpdateProgress; client.DownloadFileCompleted += InstallPrimeHack; } }
public static void migrate(UpdateUI ui) { string primesettings = ""; bool beam = false; if (File.Exists("hack_config.ini")) { ui.writeLine("Importing PrimeHack settings"); foreach (string line in File.ReadLines("hack_config.ini")) { if (line.StartsWith("[beam]")) { beam = true; continue; } if (line.StartsWith("[visor]")) { beam = false; continue; } if (line.StartsWith("sensitivity")) { primesettings += "PrimeHack/Camera Sensitivity = " + line.Replace("sensitivity = ", "") + "\n"; continue; } if (line.StartsWith("cursor_sensitivity")) { primesettings += "PrimeHack/Cursor Sensitivity = " + line.Replace("cursor_sensitivity = ", "") + "\n"; continue; } if (line.StartsWith("fov")) { primesettings += "PrimeHack/Field of View = " + line.Replace("fov = ", "") + "\n"; continue; } if (line.StartsWith("inverted_y")) { primesettings += "PrimeHack/Invert Y axis = " + line.Replace("inverted_y = ", "") + "\n"; continue; } string nline; if (line.StartsWith("index_0")) { if (beam) { nline = "PrimeHack/Beam 1 = " + line.Replace("index_0 = ", ""); } else { nline = "PrimeHack/Visor 1 = " + line.Replace("index_0 = ", ""); } primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n"; continue; } if (line.StartsWith("index_1")) { if (beam) { nline = "PrimeHack/Beam 2 = " + line.Replace("index_1 = ", ""); } else { nline = "PrimeHack/Visor 2 = " + line.Replace("index_1 = ", ""); } primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n"; continue; } if (line.StartsWith("index_2")) { if (beam) { nline = "PrimeHack/Beam 3 = " + line.Replace("index_2 = ", ""); } else { nline = "PrimeHack/Visor 3 = " + line.Replace("index_2 = ", ""); } primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n"; continue; } if (line.StartsWith("index_3")) { if (beam) { nline = "PrimeHack/Beam 4 = " + line.Replace("index_3 = ", ""); } else { nline = "PrimeHack/Visor 4 = " + line.Replace("index_3 = ", ""); } primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n"; continue; } } string config = DE + "\\Config\\WiimoteNew.ini"; if (!File.Exists(config)) { FileStream f = File.Create(config); f.Close(); primesettings = "[Wiimote1]\n" + primesettings; File.WriteAllLines(config, primesettings.Split('\n')); } else { string[] oldwiimotenew = File.ReadAllLines(config); List <string> newwiimote = new List <string>(); newwiimote.AddRange(oldwiimotenew); newwiimote.Insert(2, primesettings.Substring(0, primesettings.Length - 1)); File.WriteAllLines(config, newwiimote.ToArray()); } File.Delete(".\\hack_config.ini"); } }