public static async Task BringUpToDate(string branch, string expectedVersion, string updateReason) { string currentVersion = Program.VersionRegistry.GetString("VersionGuid"); if (currentVersion != expectedVersion) { DialogResult check = MessageBox.Show ( "Roblox Studio is out of date!\n" + updateReason + "\nWould you like to update now?", "Out of date!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ); if (check == DialogResult.Yes) { var bootstrapper = new StudioBootstrapper() { Branch = branch }; using (var installer = new BootstrapperForm(bootstrapper)) { var bootstrap = installer.Bootstrap(); await bootstrap.ConfigureAwait(true); } } } }
private async void launchStudio_Click(object sender = null, EventArgs e = null) { string branch = getSelectedBranch(); var bootstrapper = new StudioBootstrapper { ForceInstall = forceRebuild.Checked, ApplyModManagerPatches = true, SetStartEvent = true, Branch = branch }; Hide(); using (var installer = new BootstrapperForm(bootstrapper)) { var install = installer.Bootstrap(); await install.ConfigureAwait(true); } string studioRoot = StudioBootstrapper.GetStudioDirectory(); string modPath = getModPath(); string[] modFiles = Directory.GetFiles(modPath, "*.*", SearchOption.AllDirectories); foreach (string modFile in modFiles) { try { byte[] fileContents = File.ReadAllBytes(modFile); FileInfo modFileControl = new FileInfo(modFile); string relativeFile = modFile.Replace(modPath, studioRoot); string relativeDir = Directory .GetParent(relativeFile) .ToString(); if (!Directory.Exists(relativeDir)) { Directory.CreateDirectory(relativeDir); } if (File.Exists(relativeFile)) { byte[] relativeContents = File.ReadAllBytes(relativeFile); if (fileContents.SequenceEqual(relativeContents)) { continue; } modFileControl.CopyTo(relativeFile, true); continue; } File.WriteAllBytes(relativeFile, fileContents); } catch { Console.WriteLine("Failed to overwrite {0}!", modFile); } } var robloxStudioInfo = new ProcessStartInfo() { FileName = StudioBootstrapper.GetStudioPath(), Arguments = $"-startEvent {StudioBootstrapper.StartEvent}" }; if (args != null) { string firstArg = args[0]; if (firstArg != null && firstArg.StartsWith("roblox-studio", Program.StringFormat)) { // Arguments were passed by URI. var argMap = new Dictionary <string, string>(); foreach (string commandPair in firstArg.Split('+')) { if (commandPair.Contains(':')) { string[] kvPair = commandPair.Split(':'); string key = kvPair[0]; string val = kvPair[1]; if (key == "gameinfo") { // The user is authenticating. This argument is a special case. robloxStudioInfo.Arguments += " -url https://www.roblox.com/Login/Negotiate.ashx -ticket " + val; } else { argMap.Add(key, val); robloxStudioInfo.Arguments += " -" + key + ' ' + val; } } } if (argMap.ContainsKey("launchmode") && !argMap.ContainsKey("task")) { string launchMode = argMap["launchmode"]; if (launchMode == "plugin") { string pluginId = argMap["pluginid"]; robloxStudioInfo.Arguments += "-task InstallPlugin -pluginId " + pluginId; } else if (launchMode == "edit") { robloxStudioInfo.Arguments += "-task EditPlace"; } } } else { // Arguments were passed directly. for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (arg.Contains(' ')) { arg = $"\"{arg}\""; } robloxStudioInfo.Arguments += ' ' + arg; } } } if (openStudioDirectory.Checked) { Process.Start(studioRoot); Environment.Exit(0); } else { string currentVersion = versionRegistry.GetString("VersionGuid"); versionRegistry.SetValue("LastExecutedVersion", currentVersion); Process.Start(robloxStudioInfo); } }