private void CheckListStatus() { ListStatusText.Text = "United List - Online"; if (!VisualsAPIChecker.UnitedAPI()) { ListStatusText.Text = "Carbon List - Online"; if (!VisualsAPIChecker.CarbonAPI()) { ListStatusText.Text = "Carbon 2nd List - Online"; if (!VisualsAPIChecker.CarbonAPITwo()) { ListStatusText.Text = "API Lists Connection - Error"; StatusCheck = true; } } } if (StatusCheck) { WelcomeText.Text = "Looks like the Game Launcher failed to Reach our APIs.\n" + "Clicking 'Manual Bypass' will allow you to continue with the Error"; APIErrorFormElements(); } else { APIErrorFormElements(false); SettingsFormElements(true); WelcomeText.Text = "Howdy!\n" + "Looks like this is the first time this launcher has been started.\n" + "Please select from the options below in order to continue this setup."; } }
public static void GetList() { Log.Checking("LIST CORE: Creating Language List"); DiscordLauncherPresence.Status("Start Up", "Creating Language List"); List <LangObject> langInfos = new List <LangObject>(); String json_language = String.Empty; try { json_language += "["; json_language += " { \"category\": \"Official\", \"name\": \"English\", \"xml_value\": \"EN\", \"ini_value\": \"EN\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Deutsch\", \"xml_value\": \"DE\", \"ini_value\": \"DE\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Español\", \"xml_value\": \"ES\", \"ini_value\": \"ES\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Français\", \"xml_value\": \"FR\", \"ini_value\": \"FR\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Polski\", \"xml_value\": \"PL\", \"ini_value\": \"PL\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Русский\", \"xml_value\": \"RU\", \"ini_value\": \"RU\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Português (Brasil)\", \"xml_value\": \"PT\", \"ini_value\": \"PT\"},"; json_language += " { \"category\": \"Official\", \"name\": \"繁體中文\", \"xml_value\": \"TC\", \"ini_value\": \"TC\"},"; json_language += " { \"category\": \"Official\", \"name\": \"简体中文\", \"xml_value\": \"SC\", \"ini_value\": \"SC\"},"; json_language += " { \"category\": \"Official\", \"name\": \"ภาษาไทย\", \"xml_value\": \"TH\", \"ini_value\": \"TH\"},"; json_language += " { \"category\": \"Official\", \"name\": \"Türkçe\", \"xml_value\": \"TR\", \"ini_value\": \"TR\"},"; json_language += " { \"category\": \"Custom\", \"name\": \"Italiano\", \"xml_value\": \"EN\", \"ini_value\": \"IT\"}"; json_language += "]"; } catch (Exception Error) { LogToFileAddons.OpenLog("LIST CORE", null, Error, null, true); } try { langInfos.AddRange(JsonConvert.DeserializeObject <List <LangObject> >(json_language)); } catch (Exception Error) { LogToFileAddons.OpenLog("LIST CORE", null, Error, null, true); } try { foreach (LangObject NoCatList in langInfos) { if (NoCategoryList.FindIndex(i => string.Equals(i.Name, NoCatList.Name)) == -1) { NoCategoryList.Add(NoCatList); } } List <LangObject> RawList = new List <LangObject>(); foreach (var langItemGroup in langInfos.GroupBy(s => s.Category)) { if (RawList.FindIndex(i => string.Equals(i.Name, $"<GROUP>{langItemGroup.Key} Mirrors")) == -1) { RawList.Add(new LangObject { Name = $"<GROUP>{langItemGroup.Key} Languages", IsSpecial = true }); } RawList.AddRange(langItemGroup.ToList()); } foreach (LangObject CList in RawList) { if (CleanList.FindIndex(i => string.Equals(i.Name, CList.Name)) == -1) { CleanList.Add(CList); } } } catch (Exception Error) { LogToFileAddons.OpenLog("LIST CORE", null, Error, null, true); } Log.Checking("LIST CORE: Done"); Log.Info("API: Moved to Function"); /* Run the API Checks to Make Sure it Visually Displayed Correctly */ VisualsAPIChecker.PingAPIStatus(); }
public static void FirstTimeRun() { if (!LauncherUpdateCheck.UpdatePopupStoppedSplashScreen) { LoadingComplete = true; SplashScreen.ThreadStatus("Stop"); } if (!string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { Log.Core("LAUNCHER: Checking InstallationDirectory: " + FileSettingsSave.GameInstallation); } Log.Checking("LAUNCHER: Checking Game Installation"); if (string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { DiscordLauncherPresence.Status("Start Up", "Doing First Time Run"); Log.Core("LAUNCHER: First run!"); try { Form welcome = new WelcomeScreen(); DialogResult welcomereply = welcome.ShowDialog(); if (welcomereply != DialogResult.OK) { LauncherForceClose = true; } else { FileSettingsSave.CDN = SelectedCDN.CDNUrl; FileSettingsSave.SaveSettings(); } } catch { Log.Warning("LAUNCHER: CDN Source URL was Empty! Setting a Null Safe URL 'http://localhost'"); FileSettingsSave.CDN = "http://localhost"; Log.Core("LAUNCHER: Installation Directory was Empty! Creating and Setting Directory at " + Locations.GameFilesFailSafePath); FileSettingsSave.GameInstallation = Locations.GameFilesFailSafePath; FileSettingsSave.SaveSettings(); } if (LauncherForceClose) { ErrorCloseLauncher("Closing From Welcome Dialog", false); } else { if (string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { DiscordLauncherPresence.Status("Start Up", "User Selecting/Inputting Game Files Folder"); try { if (!UnixOS.Detected()) { string GameFolderPath = string.Empty; CommonOpenFileDialog FolderDialog = new CommonOpenFileDialog { EnsurePathExists = true, EnsureFileExists = false, AllowNonFileSystemItems = false, Title = "Select the location to Find or Download NFS:W", IsFolderPicker = true }; if (FolderDialog.ShowDialog() == CommonFileDialogResult.Ok) { if (!string.IsNullOrWhiteSpace(Strings.Encode(FolderDialog.FileName))) { GameFolderPath = Strings.Encode(FolderDialog.FileName); } } FolderDialog.Dispose(); if (!string.IsNullOrWhiteSpace(GameFolderPath)) { DiscordLauncherPresence.Status("Start Up", "Verifying Game Files Folder Location"); if (!HasWriteAccessToFolder(GameFolderPath)) { Log.Error("FOLDER SELECT DIALOG: Not enough permissions. Exiting."); string ErrorMessage = "You don't have enough permission to select this path as the Installation folder. " + "Please select another directory."; MessageBox.Show(null, ErrorMessage, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information); LauncherForceClose = true; LauncherForceCloseReason = ErrorMessage; } else { if (GameFolderPath.Length == 3) { Directory.CreateDirectory("Game Files"); Log.Warning("FOLDER SELECT DIALOG: Installing NFSW in root of the harddisk is not allowed."); MessageBox.Show(null, string.Format("Installing NFSW in root of the harddisk is not allowed. " + "Instead, we will install it on {0}.", Locations.GameFilesFailSafePath), "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information); FileSettingsSave.GameInstallation = Locations.GameFilesFailSafePath; FileSettingsSave.SaveSettings(); FileGameSettings.Save("Suppress", "Language Only"); } else if (GameFolderPath == Locations.LauncherFolder) { Directory.CreateDirectory("Game Files"); Log.Warning("FOLDER SELECT DIALOG: Installing NFSW in same location where the GameLauncher resides is NOT allowed."); MessageBox.Show(null, string.Format("Installing NFSW in same location where the GameLauncher resides is NOT allowed.\n " + "Instead, we will install it on {0}.", Locations.GameFilesFailSafePath), "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information); FileSettingsSave.GameInstallation = Locations.GameFilesFailSafePath; FileSettingsSave.SaveSettings(); FileGameSettings.Save("Suppress", "Language Only"); } else { Log.Core("FOLDER SELECT DIALOG: Directory Set: " + GameFolderPath); FileSettingsSave.GameInstallation = GameFolderPath; FileSettingsSave.SaveSettings(); FileGameSettings.Save("Suppress", "Language Only"); } } } else { LauncherForceClose = true; } } else { if (string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { try { FileSettingsSave.GameInstallation = Strings.Encode(Path.GetFullPath("GameFiles")); } catch { FileSettingsSave.GameInstallation = "GameFiles"; } } } if (!string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { if (!Directory.Exists(FileSettingsSave.GameInstallation)) { Log.Core("FOLDER SELECT DIALOG: Created Game Files Directory: " + FileSettingsSave.GameInstallation); Directory.CreateDirectory(FileSettingsSave.GameInstallation); } } if (!string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation)) { Log.Checking("CLEANLINKS: Game Path"); if (File.Exists(Locations.GameLinksFile)) { ModNetHandler.CleanLinks(Locations.GameLinksFile, FileSettingsSave.GameInstallation); Log.Completed("CLEANLINKS: Done"); } else { Log.Completed("CLEANLINKS: Not Present"); } } } catch (Exception Error) { LauncherForceClose = true; LauncherForceCloseReason = Error.Message; LogToFileAddons.OpenLog("FOLDER SELECT DIALOG", null, Error, null, true); } } } } Log.Completed("LAUNCHER: Game Installation Path Done"); if (LauncherForceClose) { ErrorCloseLauncher("Closing From Folder Dialog", false); } else { if (!UnixOS.Detected()) { Log.Checking("LAUNCHER: Checking Game Path Location"); DiscordLauncherPresence.Status("Start Up", "Checking Game Files Folder Location"); switch (CheckFolder(FileSettingsSave.GameInstallation)) { case FolderType.IsSameAsLauncherFolder: Directory.CreateDirectory("Game Files"); Log.Error("LAUNCHER: Installing NFSW in same location where the GameLauncher resides is NOT allowed."); MessageBox.Show(null, string.Format("Installing NFSW in same location where the GameLauncher resides is NOT allowed.\n" + "Instead, we will install it at {0}.", Locations.GameFilesFailSafePath), "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information); FileSettingsSave.GameInstallation = Locations.GameFilesFailSafePath; break; case FolderType.IsTempFolder: case FolderType.IsUsersFolders: case FolderType.IsProgramFilesFolder: case FolderType.IsWindowsFolder: case FolderType.IsRootFolder: String constructMsg = String.Empty; constructMsg += "Using this location for Game Files is not allowed.\n\n"; constructMsg += "The following locations are also NOT allowed:\n"; constructMsg += "• X:\\nfsw.exe (Root of Drive, such as C:\\ or D:\\, must be in a folder)\n"; constructMsg += "• C:\\Program Files\n"; constructMsg += "• C:\\Program Files (x86)\n"; constructMsg += "• C:\\Users (Includes 'Desktop', 'Documents', 'Downloads')\n"; constructMsg += "• C:\\Windows\n\n"; constructMsg += "Instead, we will install the NFSW Game at " + Locations.GameFilesFailSafePath; try { if (!Directory.Exists(Locations.GameFilesFailSafePath)) { Log.Core("FOLDER SELECT DIALOG: Created Game Files Directory: " + Locations.GameFilesFailSafePath); Directory.CreateDirectory(Locations.GameFilesFailSafePath); } } catch { } MessageBox.Show(null, constructMsg, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information); Log.Error("LAUNCHER: Installing NFSW in a Restricted Location is not allowed."); FileSettingsSave.GameInstallation = Locations.GameFilesFailSafePath; break; } FileSettingsSave.SaveSettings(); Log.Completed("LAUNCHER: Done Checking Game Path Location"); } /* Check If Launcher Failed to Connect to any APIs */ if (!VisualsAPIChecker.CarbonAPITwo()) { DiscordLauncherPresence.Status("Start Up", "Launcher Encountered API Errors"); DialogResult restartAppNoApis = MessageBox.Show(null, "There is no internet connection, Launcher might crash." + "\n\nClick Yes to Close GameLauncher" + "\nor" + "\nClick No Continue", "GameLauncher has Stopped, Failed To Connect To API", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (restartAppNoApis == DialogResult.Yes) { LauncherForceClose = true; } } if (LauncherForceClose) { ErrorCloseLauncher("Closing From API Error", false); } else { try { Log.Info("MAINSCREEN: Program Started"); Application.Run(new MainScreen()); } catch (COMException Error) { LogToFileAddons.OpenLog("Main Screen [Application Run]", "Launcher Encounterd an Error.", Error, "Error", false); ErrorCloseLauncher("Main Screen [Application Run]", false); } catch (Exception Error) { LogToFileAddons.OpenLog("Main Screen [Application Run]", "Launcher Encounterd an Error.", Error, "Error", false); ErrorCloseLauncher("Main Screen [Application Run]", false); } } } }
private static void Main2(Arguments args) { if (!DetectLinux.LinuxDetected()) { //Check if User has .NETFramework 4.6.2 or later Installed const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) { if (ndpKey != null && ndpKey.GetValue("Release") != null && (int)ndpKey.GetValue("Release") >= 394802) { /* Check Up to Date Certificate Status */ try { WebClient update_data = new WebClient(); update_data.CancelAsync(); update_data.Headers.Add("user-agent", "GameLauncher " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)"); update_data.DownloadStringAsync(new Uri("http://crl.carboncrew.org/RCA-Info.json")); update_data.DownloadStringCompleted += (sender, e) => { JSONRootCA API = JsonConvert.DeserializeObject <JSONRootCA>(e.Result); if (API.CN != null) { Log.Info("CERTIFICATE STORE: Setting Common Name -> " + API.CN); CertificateStore.RootCACommonName = API.CN; } if (API.Subject != null) { Log.Info("CERTIFICATE STORE: Setting Subject Name -> " + API.Subject); CertificateStore.RootCASubjectName = API.Subject; } if (API.Ids != null) { foreach (IdsModel entries in API.Ids) { if (entries.Serial != null) { Log.Info("CERTIFICATE STORE: Setting Serial Number -> " + entries.Serial); CertificateStore.RootCASerial = entries.Serial; } } } if (API.File != null) { foreach (FileModel entries in API.File) { if (entries.Name != null) { Log.Info("CERTIFICATE STORE: Setting Root CA File Name -> " + entries.Name); CertificateStore.RootCAFileName = entries.Name; } if (entries.Cer != null) { Log.Info("CERTIFICATE STORE: Setting Root CA File URL -> " + entries.Cer); CertificateStore.RootCAFileURL = entries.Cer; } } } }; } catch { Log.Error("CERTIFICATE STORE: Unable to Retrive Latest Certificate Information"); } } else { DialogResult frameworkError = MessageBox.Show(null, "This application requires one of the following versions of the .NET Framework:\n" + " .NETFramework, Version=v4.6.2 \n\nDo you want to install this .NET Framework version now?", "GameLauncher.exe - This application could not be started.", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (frameworkError == DialogResult.Yes) { Process.Start("https://dotnet.microsoft.com/download/dotnet-framework"); } Process.GetProcessById(Process.GetCurrentProcess().Id).Kill(); } } } File.Delete("communication.log"); File.Delete("launcher.log"); Log.StartLogging(); FileSettingsSave.NullSafeSettings(); FileAccountSave.NullSafeAccount(); Self.currentLanguage = CultureInfo.CurrentCulture.Name.Split('-')[0].ToUpper(); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US"); if (UriScheme.IsCommandLineArgumentsInstalled()) { UriScheme.InstallCommandLineArguments(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), AppDomain.CurrentDomain.FriendlyName)); if (args.Parse != null) { new UriScheme(args.Parse); } } if (EnableInsider.ShouldIBeAnInsider() == true) { Log.Build("INSIDER: GameLauncher " + Application.ProductVersion + "_" + EnableInsider.BuildNumber()); } else { Log.Build("BUILD: GameLauncher " + Application.ProductVersion); } if (Properties.Settings.Default.IsRestarting) { Properties.Settings.Default.IsRestarting = false; Properties.Settings.Default.Save(); Thread.Sleep(3000); } if (!DetectLinux.LinuxDetected()) { //Windows Firewall Runner if (!string.IsNullOrEmpty(FileSettingsSave.FirewallStatus)) { string nameOfLauncher = "SBRW - Game Launcher"; string localOfLauncher = Assembly.GetEntryAssembly().Location; string nameOfUpdater = "SBRW - Game Launcher Updater"; string localOfUpdater = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "GameLauncherUpdater.exe"); string groupKeyLauncher = "Game Launcher for Windows"; string descriptionLauncher = "Soapbox Race World"; bool removeFirewallRule = false; bool firstTimeRun = false; if (FileSettingsSave.FirewallStatus == "Not Excluded") { firstTimeRun = true; FileSettingsSave.FirewallStatus = "Excluded"; } else if (FileSettingsSave.FirewallStatus == "Reset") { removeFirewallRule = true; FileSettingsSave.FirewallStatus = "Not Excluded"; } FileSettingsSave.SaveSettings(); //Inbound & Outbound FirewallHelper.DoesRulesExist(removeFirewallRule, firstTimeRun, nameOfLauncher, localOfLauncher, groupKeyLauncher, descriptionLauncher, FirewallProtocol.Any); FirewallHelper.DoesRulesExist(removeFirewallRule, firstTimeRun, nameOfUpdater, localOfUpdater, groupKeyLauncher, descriptionLauncher, FirewallProtocol.Any); //This Removes the Game File Exe From Firewall //To Find the one that Adds the Exe To Firewall -> Search for `OnDownloadFinished()` string CurrentGameFilesExePath = Path.Combine(FileSettingsSave.GameInstallation + "\\nfsw.exe"); if (File.Exists(CurrentGameFilesExePath) && removeFirewallRule == true) { string nameOfGame = "SBRW - Game"; string localOfGame = CurrentGameFilesExePath; string groupKeyGame = "Need for Speed: World"; string descriptionGame = groupKeyGame; //Inbound & Outbound FirewallHelper.DoesRulesExist(removeFirewallRule, firstTimeRun, nameOfGame, localOfGame, groupKeyGame, descriptionGame, FirewallProtocol.Any); } } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); VisualsAPIChecker.PingAPIStatus(); /* Set Launcher Directory */ Log.Info("CORE: Setting up current directory: " + Path.GetDirectoryName(Application.ExecutablePath)); Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); if (!DetectLinux.LinuxDetected()) { Log.Info("CORE: Checking current directory"); switch (Self.CheckFolder(Directory.GetCurrentDirectory())) { case FolderType.IsTempFolder: MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); break; case FolderType.IsUsersFolders: MessageBox.Show(null, "Please, choose a different directory for the game launcher.\n\nSpecial Folders such as:" + "\n\nDownloads, Documents, Desktop, Videos, Music, OneDrive, or Any Type of User Folders" + "\n\nAre Disadvised", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); break; case FolderType.IsProgramFilesFolder: MessageBox.Show(null, "Please, choose a different directory for the game launcher." + "\n\nSpecial Folders such as:\n\nProgram Files or Program Files (x86)\n\nAre Disadvised", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); break; case FolderType.IsWindowsFolder: MessageBox.Show(null, "Please, choose a different directory for the game launcher." + "\n\nSpecial Folder such as:\n\nWindows\n\nAre Disadvised", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); break; } if (!Self.HasWriteAccessToFolder(Path.GetDirectoryName(Application.ExecutablePath))) { MessageBox.Show("This application requires admin priviledge"); } //Update this text file if a new GameLauncherUpdater.exe has been delployed - DavidCarbon try { try { switch (APIStatusChecker.CheckStatus("http://api.github.com/repos/SoapboxRaceWorld/GameLauncherUpdater/releases/latest")) { case API.Online: WebClient update_data = new WebClient(); update_data.CancelAsync(); update_data.Headers.Add("user-agent", "GameLauncher " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)"); update_data.DownloadStringAsync(new Uri("http://api.github.com/repos/SoapboxRaceWorld/GameLauncherUpdater/releases/latest")); update_data.DownloadStringCompleted += (sender, e) => { GitHubRelease GHAPI = JsonConvert.DeserializeObject <GitHubRelease>(e.Result); if (GHAPI.TagName != null) { Log.Info("LAUNCHER UPDATER: Setting Latest Version -> " + GHAPI.TagName); LatestUpdaterBuildVersion = GHAPI.TagName; } Log.Info("LAUNCHER UPDATER: Latest Version -> " + LatestUpdaterBuildVersion); }; break; default: Log.Error("LAUNCHER UPDATER: Failed to Retrive Latest Updater Information from GitHub"); break; } } catch { var GetLatestUpdaterBuildVersion = new WebClient().DownloadString(Self.secondstaticapiserver + "/Version.txt"); if (!string.IsNullOrEmpty(GetLatestUpdaterBuildVersion)) { Log.Info("LAUNCHER UPDATER: Setting Latest Version -> " + GetLatestUpdaterBuildVersion); LatestUpdaterBuildVersion = GetLatestUpdaterBuildVersion; } } Log.Info("LAUNCHER UPDATER: Fail Safe Latest Version -> " + LatestUpdaterBuildVersion); } catch (Exception ex) { Log.Error("LAUNCHER UPDATER: Failed to get new version file: " + ex.Message); } } if (!DetectLinux.LinuxDetected()) { //Windows 7 Fix if ((string.IsNullOrEmpty(FileSettingsSave.Win7UpdatePatches) && WindowsProductVersion.GetWindowsNumber() == 6.1) || FileSettingsSave.Win7UpdatePatches == "0") { if (Self.GetInstalledHotFix("KB3020369") == false || Self.GetInstalledHotFix("KB3125574") == false) { String messageBoxPopupKB = String.Empty; messageBoxPopupKB = "Hey Windows 7 User, we've detected a potential issue of some missing Updates that are required.\n"; messageBoxPopupKB += "We found that these Windows Update packages are showing as not installed:\n\n"; if (Self.GetInstalledHotFix("KB3020369") == false) { messageBoxPopupKB += "- Update KB3020369\n"; } if (Self.GetInstalledHotFix("KB3125574") == false) { messageBoxPopupKB += "- Update KB3125574\n"; } messageBoxPopupKB += "\nAditionally, we must add a value to the registry:\n"; messageBoxPopupKB += "- HKLM/SYSTEM/CurrentControlSet/Control/SecurityProviders\n/SCHANNEL/Protocols/TLS 1.2/Client\n"; messageBoxPopupKB += "- Value: DisabledByDefault -> 0\n\n"; messageBoxPopupKB += "Would you like to add those values?"; DialogResult replyPatchWin7 = MessageBox.Show(null, messageBoxPopupKB, "SBRW Launcher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (replyPatchWin7 == DialogResult.Yes) { RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client"); key.SetValue("DisabledByDefault", 0x0); MessageBox.Show(null, "Registry option set, Remember that the changes may require a system reboot to take effect", "SBRW Launcher", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show(null, "Roger that, There may be some issues connecting to the servers.", "SBRW Launcher", MessageBoxButtons.OK, MessageBoxIcon.Warning); } FileSettingsSave.Win7UpdatePatches = "1"; FileSettingsSave.SaveSettings(); } } if (!RedistributablePackage.IsInstalled(RedistributablePackageVersion.VC2015to2019x86)) { var result = MessageBox.Show( "You do not have the 32-bit 2015-2019 VC++ Redistributable Package installed.\n \nThis will install in the Background\n \nThis may restart your computer. \n \nClick OK to install it.", "Compatibility", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result != DialogResult.OK) { MessageBox.Show("The game will not be started.", "Compatibility", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var wc = new WebClient(); wc.DownloadFile("https://aka.ms/vs/16/release/VC_redist.x86.exe", "VC_redist.x86.exe"); var proc = Process.Start(new ProcessStartInfo { Verb = "runas", Arguments = "/quiet", FileName = "VC_redist.x86.exe" }); if (proc == null) { MessageBox.Show("Failed to run package installer. The game will not be started.", "Compatibility", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (Environment.Is64BitOperatingSystem == true) { if (!RedistributablePackage.IsInstalled(RedistributablePackageVersion.VC2015to2019x64)) { var result = MessageBox.Show( "You do not have the 64-bit 2015-2019 VC++ Redistributable Package installed.\n \nThis will install in the Background\n \nThis may restart your computer. \n \nClick OK to install it.", "Compatibility", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result != DialogResult.OK) { MessageBox.Show("The game will not be started.", "Compatibility", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var wc = new WebClient(); wc.DownloadFile("https://aka.ms/vs/16/release/VC_redist.x64.exe", "VC_redist.x64.exe"); var proc = Process.Start(new ProcessStartInfo { Verb = "runas", Arguments = "/quiet", FileName = "VC_redist.x64.exe" }); if (proc == null) { MessageBox.Show("Failed to run package installer. The game will not be started.", "Compatibility", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } } Console.WriteLine("Application path: " + Path.GetDirectoryName(Application.ExecutablePath)); if (!string.IsNullOrEmpty(FileSettingsSave.GameInstallation)) { if (!Self.HasWriteAccessToFolder(FileSettingsSave.GameInstallation)) { MessageBox.Show("This application requires admin priviledge. Restarting..."); } } //INFO: this is here because this dll is necessary for downloading game files and I want to make it async. //Updated RedTheKitsune Code so it downloads the file if its missing. It also restarts the launcher if the user click on yes on Prompt. - DavidCarbon if (!File.Exists("LZMA.dll")) { try { Log.Warning("CORE: Starting LZMA downloader"); using (WebClient wc = new WebClient()) { wc.DownloadFileAsync(new Uri(Self.fileserver + "/LZMA.dll"), "LZMA.dll"); } DialogResult restartApp = MessageBox.Show(null, "Downloaded Missing LZMA.dll File. \nPlease Restart Launcher, Thanks!", "GameLauncher Restart Required", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (restartApp == DialogResult.Yes) { Properties.Settings.Default.IsRestarting = true; Properties.Settings.Default.Save(); Application.Restart(); } Process.GetProcessById(Process.GetCurrentProcess().Id).Kill(); } catch (Exception ex) { Log.Error("CORE: Failed to download LZMA. " + ex.Message); } } //StaticConfiguration.DisableErrorTraces = false; if (!File.Exists("servers.json")) { try { File.WriteAllText("servers.json", "[]"); } catch { /* ignored */ } } if (Properties.Settings.Default.IsRestarting) { Properties.Settings.Default.IsRestarting = false; Properties.Settings.Default.Save(); Thread.Sleep(3000); } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (Debugger.IsAttached) { ShowMainScreen(); } else { if (NFSW.IsNFSWRunning()) { MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Process.GetProcessById(Process.GetCurrentProcess().Id).Kill(); } var mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR"); try { if (mutex.WaitOne(0, false)) { string[] files = { "CommandLine.dll - 2.8.0", "DiscordRPC.dll - 1.0.169.0", "Flurl.dll - 3.0.1", "Flurl.Http.dll - 3.0.1", "INIFileParser.dll - 2.5.2", "LZMA.dll - 9.10 beta", "Microsoft.WindowsAPICodePack.dll - 1.1.0.0", "Microsoft.WindowsAPICodePack.Shell.dll - 1.1.0.0", "Microsoft.WindowsAPICodePack.ShellExtensions.dll - 1.1.0.0", "Nancy.dll - 2.0.0", "Nancy.Hosting.Self.dll - 2.0.0", "Newtonsoft.Json.dll - 12.0.3", "System.Runtime.InteropServices.RuntimeInformation.dll - 4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97", "System.ValueTuple.dll - 4.6.26515.06 @BuiltBy: dlab-DDVSOWINAGE059 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/30ab651fcb4354552bd4891619a0bdd81e0ebdbf", "WindowsFirewallHelper.dll - 1.6.3.40" }; var missingfiles = new List <string>(); if (!DetectLinux.LinuxDetected()) { //MONO Hates that... foreach (var file in files) { var splitFileVersion = file.Split(new string[] { " - " }, StringSplitOptions.None); if (!File.Exists(Directory.GetCurrentDirectory() + "\\" + splitFileVersion[0])) { missingfiles.Add(splitFileVersion[0] + " - Not Found"); } else { try { var versionInfo = FileVersionInfo.GetVersionInfo(splitFileVersion[0]); string[] versionsplit = versionInfo.ProductVersion.Split('+'); string version = versionsplit[0]; if (version == "") { missingfiles.Add(splitFileVersion[0] + " - Invalid File"); } else { if (Self.CheckArchitectureFile(splitFileVersion[0]) == false) { missingfiles.Add(splitFileVersion[0] + " - Wrong Architecture"); } else { if (version != splitFileVersion[1]) { missingfiles.Add(splitFileVersion[0] + " - Invalid Version (" + splitFileVersion[1] + " != " + version + ")"); } } } } catch { missingfiles.Add(splitFileVersion[0] + " - Invalid File"); } } } } if (missingfiles.Count != 0) { ShowSplashScreen(false); var message = "Cannot launch GameLauncher. The following files are invalid:\n\n"; foreach (var file in missingfiles) { message += "• " + file + "\n"; } MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Theming.CheckIfThemeExists(); ShowSplashScreen(true); } } else { ShowSplashScreen(false); MessageBox.Show(null, "An instance of Launcher is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { mutex.Close(); mutex = null; } } }
private void SetVisuals() { /*******************************/ /* Load CDN List / * /*******************************/ Log.Checking("API: Test #3"); /* Check If Launcher Failed to Connect to any APIs */ if (!VisualsAPIChecker.CarbonAPITwo()) { MessageBox.Show(null, "Unable to Connect to any CDN List API. Please check your connection." + "\n\nCDN Dropdown List will not be available on Welcome Screen", "GameLauncher has Paused, Failed To Connect to any CDN List API", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Log.Checking("API: Test #3 Done"); /*******************************/ /* Load CDN List / * /*******************************/ if (!CDNListUpdater.LoadedList) { CDNListUpdater.GetList(); } /*******************************/ /* Set Hardcoded Text / * /*******************************/ VersionLabel.Text = "Version: v" + Application.ProductVersion; if (UnixOS.Detected()) { ButtonSave.Text = "Save Settings and Game Language"; } /*******************************/ /* Set Font / * /*******************************/ FontFamily DejaVuSans = FontWrapper.Instance.GetFontFamily("DejaVuSans.ttf"); FontFamily DejaVuSansBold = FontWrapper.Instance.GetFontFamily("DejaVuSans-Bold.ttf"); var MainFontSize = 9f * 100f / CreateGraphics().DpiY; var SecondaryFontSize = 8f * 100f / CreateGraphics().DpiY; var ThirdFontSize = 10f * 100f / CreateGraphics().DpiY; var FourthFontSize = 14f * 100f / CreateGraphics().DpiY; if (UnixOS.Detected()) { MainFontSize = 9f; SecondaryFontSize = 8f; ThirdFontSize = 10f; FourthFontSize = 14f; } Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); WelcomeText.Font = new Font(DejaVuSansBold, ThirdFontSize, FontStyle.Bold); DownloadSourceText.Font = new Font(DejaVuSansBold, MainFontSize, FontStyle.Bold); GameLangText.Font = new Font(DejaVuSansBold, MainFontSize, FontStyle.Bold); GameLangSource.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); CDNSource.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); ButtonSave.Font = new Font(DejaVuSansBold, MainFontSize, FontStyle.Bold); ListStatusText.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); ButtonAPIError.Font = new Font(DejaVuSansBold, MainFontSize, FontStyle.Bold); VersionLabel.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); /********************************/ /* Set Theme Colors & Images / * /********************************/ BackColor = Theming.WinFormTBGForeColor; ForeColor = Theming.WinFormTextForeColor; ListStatusText.ForeColor = Theming.WinFormTextForeColor; WelcomeText.ForeColor = Theming.WinFormSecondaryTextForeColor; DownloadSourceText.ForeColor = Theming.WinFormTextForeColor; GameLangSource.ForeColor = Theming.WinFormTextForeColor; ButtonAPIError.ForeColor = Theming.BlueForeColorButton; ButtonAPIError.BackColor = Theming.BlueBackColorButton; ButtonAPIError.FlatAppearance.BorderColor = Theming.BlueBorderColorButton; ButtonAPIError.FlatAppearance.MouseOverBackColor = Theming.BlueMouseOverBackColorButton; ButtonSave.ForeColor = Theming.BlueForeColorButton; ButtonSave.BackColor = Theming.BlueBackColorButton; ButtonSave.FlatAppearance.BorderColor = Theming.BlueBorderColorButton; ButtonSave.FlatAppearance.MouseOverBackColor = Theming.BlueMouseOverBackColorButton; VersionLabel.ForeColor = Theming.WinFormTextForeColor; /********************************/ /* Events / * /********************************/ CDNSource.DrawItem += new DrawItemEventHandler(CDNSource_DrawItem); CDNSource.SelectedIndexChanged += new EventHandler(CDNSource_SelectedIndexChanged); GameLangSource.DrawItem += new DrawItemEventHandler(GameLangSource_DrawItem); GameLangSource.SelectedIndexChanged += new EventHandler(GameLangSource_SelectedIndexChanged); Shown += (x, y) => { Application.OpenForms["WelcomeScreen"].Activate(); this.BringToFront(); }; }