private static void ShowMainScreen() { if (VisualsAPIChecker.WOPLAPI == false) { DialogResult restartAppNoApis = MessageBox.Show(null, "There's no internet connection, Launcher might crash \n \nClick Yes to Close Launcher \nor \nClick No Continue", "GameLauncher has Stopped, Failed To Connect To API", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (restartAppNoApis == DialogResult.No) { MessageBox.Show("Good Luck... \n No Really \n ...Good Luck", "GameLauncher Will Continue, When It Failed To Connect To API"); Log.Warning("PRE-CHECK: User has Bypassed 'No Internet Connection' Check and Will Continue"); } if (restartAppNoApis == DialogResult.Yes) { Process.GetProcessById(Process.GetCurrentProcess().Id).Kill(); } } ServerListUpdater.GetList(); CDNListUpdater.GetList(); LauncherUpdateCheck.CheckAvailability(); if (!DetectLinux.LinuxDetected()) { //Install Custom Root Certificate CertificateStore.Check(); if (!File.Exists("GameLauncherUpdater.exe")) { Log.Info("LAUNCHER UPDATER: Starting GameLauncherUpdater downloader"); try { using (WebClient wc = new WebClient()) { wc.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => { if (new FileInfo("GameLauncherUpdater.exe").Length == 0) { File.Delete("GameLauncherUpdater.exe"); } }; wc.DownloadFile(new Uri("https://github.com/SoapboxRaceWorld/GameLauncherUpdater/releases/latest/download/GameLauncherUpdater.exe"), "GameLauncherUpdater.exe"); } } catch (Exception ex) { Log.Error("LAUCHER UPDATER: Failed to download updater. " + ex.Message); } } else if (File.Exists("GameLauncherUpdater.exe")) { String GameLauncherUpdaterLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GameLauncherUpdater.exe"); var LauncherUpdaterBuild = FileVersionInfo.GetVersionInfo(GameLauncherUpdaterLocation); var LauncherUpdaterBuildNumber = LauncherUpdaterBuild.FileVersion; var UpdaterBuildNumberResult = LauncherUpdaterBuildNumber.CompareTo(LatestUpdaterBuildVersion); Log.Build("LAUNCHER UPDATER BUILD: GameLauncherUpdater " + LauncherUpdaterBuildNumber); if (UpdaterBuildNumberResult < 0) { Log.Info("LAUNCHER UPDATER: " + UpdaterBuildNumberResult + " Builds behind latest Updater!"); } else { Log.Info("LAUNCHER UPDATER: Latest GameLauncherUpdater!"); } if (UpdaterBuildNumberResult < 0) { Log.Info("LAUNCHER UPDATER: Downloading New GameLauncherUpdater.exe"); File.Delete("GameLauncherUpdater.exe"); try { using (WebClient wc = new WebClient()) { wc.DownloadFile(new Uri("https://github.com/SoapboxRaceWorld/GameLauncherUpdater/releases/latest/download/GameLauncherUpdater.exe"), "GameLauncherUpdater.exe"); } } catch (Exception ex) { Log.Error("LAUNCHER UPDATER: Failed to download new updater. " + ex.Message); } } } } if (!string.IsNullOrEmpty(FileSettingsSave.GameInstallation)) { var linksPath = Path.Combine(FileSettingsSave.GameInstallation + "\\.links"); ModNetLinksCleanup.CleanLinks(linksPath); } Log.Info("PROXY: Starting Proxy"); ServerProxy.Instance.Start(); Log.Visuals("CORE: Starting MainScreen"); Application.Run(new MainScreen()); }
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(); }; }
private void SettingsScreen_Load(object sender, EventArgs e) { /*******************************/ /* Read Settings.ini / * /*******************************/ _disableProxy = (FileSettingsSave.Proxy == "1"); _disableDiscordRPC = (FileSettingsSave.RPC == "1"); if (File.Exists(FileSettingsSave.GameInstallation + "/profwords") || File.Exists(FileSettingsSave.GameInstallation + "/profwords_dis")) { try { SettingsWordFilterCheck.Checked = !File.Exists(FileSettingsSave.GameInstallation + "/profwords"); } catch { SettingsWordFilterCheck.Checked = false; } } else { SettingsWordFilterCheck.Enabled = false; } if (File.Exists("Theme.ini")) { ThemeName.Text = "Theme Name: " + Theming.ThemeName; ThemeAuthor.Text = "Theme Author: " + Theming.ThemeAuthor; } else { ThemeName.Text = "Theme Name: Default"; ThemeAuthor.Text = "Theme Author: Launcher - Division"; } /*******************************/ /* Folder Locations / * /*******************************/ _newGameFilesPath = Path.GetFullPath(FileSettingsSave.GameInstallation); _newLauncherPath = AppDomain.CurrentDomain.BaseDirectory; SettingsProxyCheckbox.Checked = _disableProxy; SettingsDiscordRPCCheckbox.Checked = _disableDiscordRPC; /*******************************/ /* Enable/Disable Visuals / * /*******************************/ if (File.Exists(FileSettingsSave.GameInstallation + "/NFSWO_COMMUNICATION_LOG.txt")) { SettingsClearCommunicationLogButton.Enabled = true; } if (Directory.Exists(FileSettingsSave.GameInstallation + "/.data")) { SettingsClearServerModCacheButton.Enabled = true; } var crashLogFilesDirectory = new DirectoryInfo(FileSettingsSave.GameInstallation); if (crashLogFilesDirectory.EnumerateFiles("SBRCrashDump_CL0*.dmp").Count() != 0) { SettingsClearCrashLogsButton.Enabled = true; } try { string SavedCDN = FileSettingsSave.CDN; char[] charsToTrim = { '/' }; string FinalCDNURL = SavedCDN.TrimEnd(charsToTrim); if (EnableInsider.ShouldIBeAnInsider() == true) { Log.Info("SETTINGS VERIFYHASH: Checking Characters in URL"); Log.Info("SETTINGS VERIFYHASH: Trimed end of URL -> " + FinalCDNURL); Theming.ButtonVerifyHash = true; } else { if (FunctionStatus.IsVerifyHashDisabled == true) { Theming.ButtonVerifyHash = false; } else { switch (APIStatusChecker.CheckStatus(FinalCDNURL + "/unpacked/checksums.dat")) { case APIStatus.Online: Theming.ButtonVerifyHash = true; break; default: Theming.ButtonVerifyHash = false; break; } } } SettingsVFilesButton.Enabled = Theming.ButtonVerifyHash; } catch { } /********************************/ /* CDN, APIs, & Restore Last CDN / * /********************************/ if (FunctionStatus.CDNListStatus != "Loaded") { CDNListUpdater.GetList(); } SettingsCDNPick.DisplayMember = "Name"; SettingsCDNPick.DataSource = CDNListUpdater.CleanList; SettingsLanguage.DisplayMember = "Name"; SettingsLanguage.DataSource = LanguageListUpdater.CleanList; RememberLastCDN(); RememberLastLanguage(); IsCDNDownGame(); PingAPIStatus(); }
private void SetVisuals() { /*******************************/ /* Load CDN List / * /*******************************/ if (FileSettingsSave.CDN != "Loaded") { CDNListUpdater.GetList(); } /*******************************/ /* Set Hardcoded Text / * /*******************************/ VersionLabel.Text = "Version: v" + Application.ProductVersion; /*******************************/ /* 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 (DetectLinux.LinuxDetected()) { 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); CDNSource.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); Save.Font = new Font(DejaVuSansBold, MainFontSize, FontStyle.Bold); ListStatusText.Font = new Font(DejaVuSans, MainFontSize, FontStyle.Regular); APIErrorButton.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; APIErrorButton.ForeColor = Theming.BlueForeColorButton; APIErrorButton.BackColor = Theming.BlueBackColorButton; APIErrorButton.FlatAppearance.BorderColor = Theming.BlueBorderColorButton; APIErrorButton.FlatAppearance.MouseOverBackColor = Theming.BlueMouseOverBackColorButton; Save.ForeColor = Theming.BlueForeColorButton; Save.BackColor = Theming.BlueBackColorButton; Save.FlatAppearance.BorderColor = Theming.BlueBorderColorButton; Save.FlatAppearance.MouseOverBackColor = Theming.BlueMouseOverBackColorButton; VersionLabel.ForeColor = Theming.WinFormTextForeColor; /********************************/ /* Events / * /********************************/ CDNSource.DrawItem += new DrawItemEventHandler(CDNSource_DrawItem); CDNSource.SelectedIndexChanged += new EventHandler(CDNSource_SelectedIndexChanged); }