/// <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();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
        private void DebugScreen_Load(object sender, EventArgs e)
        {
            data.AutoGenerateColumns = true;

            string Antivirus   = String.Empty;
            string Firewall    = String.Empty;
            string AntiSpyware = String.Empty;

            if (!UnixOS.Detected())
            {
                try
                {
                    Antivirus   = (String.IsNullOrWhiteSpace(SecurityCenter("AntiVirusProduct"))) ? "---" : SecurityCenter("AntiVirusProduct");
                    Firewall    = (String.IsNullOrWhiteSpace(SecurityCenter("FirewallProduct"))) ? "Built-In" : SecurityCenter("FirewallProduct");
                    AntiSpyware = (String.IsNullOrWhiteSpace(SecurityCenter("AntiSpywareProduct"))) ? "---" : SecurityCenter("AntiSpywareProduct");
                }
                catch
                {
                    Antivirus   = "Unknown";
                    Firewall    = "Unknown";
                    AntiSpyware = "Unknown";
                }
            }

            string UpdateSkip;

            if (FileSettingsSave.IgnoreVersion == Application.ProductVersion || FileSettingsSave.IgnoreVersion == String.Empty)
            {
                UpdateSkip = "False";
            }
            else
            {
                UpdateSkip = FileSettingsSave.IgnoreVersion;
            }

            string StreamOpt;

            if (FileSettingsSave.StreamingSupport == "0")
            {
                StreamOpt = "Displaying Timer";
            }
            else
            {
                StreamOpt = "Native (Timer Removed)";
            }
            string ThemeOpt;

            if (FileSettingsSave.ThemeSupport == "0")
            {
                ThemeOpt = "Disabled";
            }
            else
            {
                ThemeOpt = "Enabled";
            }

            string InsiderOpt;

            if (FileSettingsSave.Insider == "0")
            {
                InsiderOpt = "Release Only";
            }
            else
            {
                InsiderOpt = "Insider Opt-In";
            }

            /* Used to calculate remaining Free Space on the Game Installed Drive */
            ulong lpFreeBytesAvailable = 0;

            if (!UnixOS.Detected())
            {
                try
                {
                    Kernel32.GetDiskFreeSpaceEx(FileSettingsSave.GameInstallation,
                                                out lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("Debug", null, Error, null, true);
                }
            }

            var settings = new List <ListType>
            {
                new ListType {
                    Name = "Operating System", Value = (UnixOS.Detected())? UnixOS.FullName() : Environment.OSVersion.VersionString
                },
                new ListType {
                    Name = "Environment Version", Value = Environment.OSVersion.Version.ToString()
                },
                new ListType {
                    Name = "Screen Resolution", Value = Screen.PrimaryScreen.Bounds.Width + "x" + Screen.PrimaryScreen.Bounds.Height + " (Primary Display)"
                },
                new ListType {
                    Name = "", Value = ""
                },
                new ListType {
                    Name = "InstallationDirectory", Value = FileSettingsSave.GameInstallation
                },
                new ListType {
                    Name = "Launcher Version", Value = Application.ProductVersion
                },
                new ListType {
                    Name = "Credentials Saved", Value = (!String.IsNullOrWhiteSpace(FileAccountSave.UserHashedPassword)) ? "True" : "False"
                },
                new ListType {
                    Name = "Language", Value = FileSettingsSave.Lang
                },
                new ListType {
                    Name = "Skipping Update", Value = UpdateSkip
                },
                new ListType {
                    Name = "Proxy Enabled", Value = ServerProxy.Running().ToString()
                },
                new ListType {
                    Name = "RPC Enabled", Value = DiscordLauncherPresence.Running().ToString()
                },
                new ListType {
                    Name = "Catpure Support", Value = StreamOpt
                },
                new ListType {
                    Name = "Theme Support", Value = ThemeOpt
                },
                new ListType {
                    Name = "Insider State", Value = InsiderOpt
                },
                new ListType {
                    Name = "", Value = ""
                },
                new ListType {
                    Name = "Server Name", Value = ServerListUpdater.ServerName("Debug")
                },
                new ListType {
                    Name = "Server Address", Value = InformationCache.SelectedServerData.IPAddress
                },
                new ListType {
                    Name = "CDN Address", Value = FileSettingsSave.CDN
                },
                new ListType {
                    Name = "ProxyPort", Value = ServerProxy.ProxyPort.ToString()
                },
                new ListType {
                    Name = "Client Method", Value = FileSettingsSave.WebCallMethod
                },
                new ListType {
                    Name = "", Value = ""
                },
            };

            if (!UnixOS.Detected())
            {
                DriveInfo driveInfo = new DriveInfo(FileSettingsSave.GameInstallation);
                settings.AddRange(new[]
                {
                    new ListType {
                        Name = "Antivirus", Value = Antivirus
                    },
                    new ListType {
                        Name = "Firewall Application", Value = Firewall
                    },
                    new ListType {
                        Name = "Firewall Rule - Launcher", Value = FileSettingsSave.FirewallLauncherStatus
                    },
                    new ListType {
                        Name = "Firewall Rule - Game", Value = FileSettingsSave.FirewallGameStatus
                    },
                    new ListType {
                        Name = "AntiSpyware", Value = AntiSpyware
                    },
                    new ListType {
                        Name = "", Value = ""
                    },
                    new ListType {
                        Name = "CPU", Value = HardwareInfo.CPU.CPUName()
                    },
                    new ListType {
                        Name = "RAM", Value = HardwareInfo.RAM.SysMem() + " MB"
                    },
                    new ListType {
                        Name = "GPU", Value = HardwareInfo.GPU.CardName()
                    },
                    new ListType {
                        Name = "GPU Driver", Value = HardwareInfo.GPU.DriverVersion()
                    },
                    new ListType {
                        Name = "Disk Space Left", Value = FormatFileSize(lpFreeBytesAvailable)
                    },
                    new ListType {
                        Name = "Disk Type", Value = driveInfo.DriveFormat
                    },
                    new ListType {
                        Name = "", Value = ""
                    }
                });
            }
            settings.AddRange(new[]
            {
                new ListType {
                    Name = "HWID", Value = HardwareID.FingerPrint.Level_One_Value()
                },
            });

            data.DataSource = settings;

            DataGridViewCellStyle style = new DataGridViewCellStyle
            {
                Font = new Font(data.Font, FontStyle.Regular)
            };

            data.Columns[0].DefaultCellStyle = style;

            data.Columns[0].Width += 50;

            int size_x = 512;
            int size_y = 640;

            data.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.Size = new Size(size_x, size_y);
        }