static void Main() { WelcomeScreen wS = new WelcomeScreen(); WelcomeScreenController wSC = new WelcomeScreenController(wS); wS.ShowDialog(); }
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); } } } }