/// <summary> /// Used to Force Close Launcher when Launcher encounters an error during Startup /// </summary> /// <param name="Notes">Required: Where the Launcher is Closing From</param> /// <param name="Boolen">True: Restarts Launcher | False: Closes Launcher</param> public static void ErrorCloseLauncher(string Notes, bool Boolen) { SplashScreen.ThreadStatus("Stop"); if (DiscordLauncherPresence.Running()) { DiscordLauncherPresence.Stop("Close"); } if (ServerProxy.Running()) { ServerProxy.Instance.Stop("Force Close"); } Log.Warning("LAUNCHER: Exiting (" + Notes + ")"); if (!string.IsNullOrWhiteSpace(LauncherForceCloseReason)) { DialogResult OpenLogFile = MessageBox.Show(null, "The GameLauncher has ecountered an Error and it must Close. " + "Below is a Summary of the Error:" + "\n" + LauncherForceCloseReason + "\n\n" + LogToFileAddons.OpenLogMessage, "GameLauncher", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (OpenLogFile == DialogResult.Yes) { Process.Start(Locations.LogLauncher); } } if (Boolen) { Application.Restart(); } else { Application.Exit(); } }
public static void Latest() { Log.Checking("LAUNCHER UPDATE: Is Version Up to Date or not"); DiscordLauncherPresence.Status("Start Up", "Checking Latest Launcher Release Information"); try { Uri URLCall = new Uri((EnableInsiderBetaTester.Allowed() || EnableInsiderDeveloper.Allowed()) ? URLs.GitHub_Launcher_Beta : URLs.GitHub_Launcher_Stable); ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds; var Client = new WebClient { Encoding = Encoding.UTF8 }; if (!WebCalls.Alternative()) { Client = new WebClientWithTimeout { Encoding = Encoding.UTF8 }; } else { Client.Headers.Add("user-agent", "SBRW Launcher " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)"); } try { VersionJSON = Client.DownloadString(URLCall); VisualsAPIChecker.GitHubAPI = true; } catch (WebException Error) { APIChecker.StatusCodes(URLCall.GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped), Error, (HttpWebResponse)Error.Response); } catch (Exception Error) { LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true); } finally { if (Client != null) { Client.Dispose(); } } if (IsJSONValid.ValidJson(VersionJSON) && VisualsAPIChecker.GitHubAPI) { LatestLauncherBuild = (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed()) ? JsonConvert.DeserializeObject <List <GitHubRelease> >(VersionJSON)[0].TagName : JsonConvert.DeserializeObject <GitHubRelease>(VersionJSON).TagName; Log.Info("LAUNCHER UPDATE: GitHub Latest Version -> " + LatestLauncherBuild); ValidJSONDownload = true; } else { Log.Error("LAUNCHER UPDATE: Failed to retrieve Latest Build information from GitHub"); ValidJSONDownload = false; } } catch (Exception Error) { LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true); } Log.Completed("LAUNCHER UPDATE: Done"); if (!UpdateStatusResult()) { Log.Info("FIRST TIME RUN: Moved to Function"); /* Do First Time Run Checks */ FunctionStatus.FirstTimeRun(); } else { if (DiscordLauncherPresence.Running()) { DiscordLauncherPresence.Stop("Close"); } if (ServerProxy.Running()) { ServerProxy.Instance.Stop("Force Close"); } Application.Exit(); } }