public static string GetCarName(string id) { /* Let's load the "Cached From Server" version first */ if (remoteCarsList != String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(Strings.Encode(remoteCarsList)); foreach (var item in dynJson) { if (item.carid == id) { return(item.carname); } } } /* If we don't have a Server version, load "default" version */ if (remoteCarsList == String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(Strings.Encode(ExtractResource.AsString("GameLauncher.App.Classes.LauncherCore.RPC.JSON.cars.json"))); foreach (var item in dynJson) { if (item.carid == id) { return(item.carname); } } } /* And if it's not found, do this instead */ return("Traffic Car (" + id + ")"); }
public static string GetEventType(int id) { /* Let's load the "From Server" version first */ if (remoteEventsList != String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(Strings.Encode(remoteEventsList)); foreach (var item in dynJson) { if (item.id == id) { return(item.type); } } } /* If we don't have a Server version, load "default" version */ if (remoteEventsList != String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(Strings.Encode( ExtractResource.AsString("GameLauncher.App.Classes.RPC.JSON.events.json"))); foreach (var item in dynJson) { if (item.id == id) { return(item.type); } } } /* And if it's not found, do this instead */ return("gamemode_freeroam"); }
public static string GetEventName(int id) { // Let's load the "From Server" version first if (remoteEventsList != String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(remoteEventsList); foreach (var item in dynJson) { if (item.id == id) { return(item.trackname); } } } // If we don't have a Server version, load "default" version if (remoteEventsList == String.Empty) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("GameLauncher.App.Classes.LauncherCore.RPC.JSON.events.json")); foreach (var item in dynJson) { if (item.id == id) { return(item.trackname); } } } // And if it's not found, do this instead return("EVENT:" + id); }
public static string getZoneName(string color) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("GameLauncher.App.Classes.RPC.JSON.zones.json")); foreach (var item in dynJson) { if (item.color == color) { return(item.name); } } return(null); }
public static string getEventType(int id) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("GameLauncher.App.Classes.RPC.JSON.events.json")); foreach (var item in dynJson) { if (item.id == id) { return(item.type); } } return("gamemode_freeroam"); }
public static string getCarName(string id) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("GameLauncher.App.Classes.RPC.JSON.cars.json")); foreach (var item in dynJson) { if (item.carid == id) { return(item.carname); } } return("CARID:" + id); }
public static string getCarName(string id) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("NFS.Class.Diss.cars.json")); foreach (var item in dynJson) { if (item.carid == id) { return(item.carname); } } return("Traffic Car (" + id + ")"); }
public static string getEventType(int id) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("NFS.Class.Diss.cars.json")); foreach (var item in dynJson) { if (item.id == id) { return(item.type); } } return("gamemode_freeroam"); }
public static string getEventName(int id) { dynamic dynJson = JsonConvert.DeserializeObject(ExtractResource.AsString("NFS.Class.Diss.events.json")); foreach (var item in dynJson) { if (item.id == id) { return(item.trackname); } } return("EVENT:" + id); }
static void Main() { bool mono = DetectLinux.MonoDetected(); bool wine = DetectLinux.WineDetected(); bool linux = DetectLinux.NativeLinuxDetected(); Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); if (Self.isTempFolder(Directory.GetCurrentDirectory())) { MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); } if (!Directory.Exists("Languages")) { Directory.CreateDirectory("Languages"); } try { File.Delete("Languages/Default.lng"); File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng")); } catch { } try { File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip"); } catch { } if (!File.Exists("LZMA.dll")) { File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll")); } if (!linux && !File.Exists("discord-rpc.dll")) { File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll")); } if (linux && !File.Exists("libdiscord-rpc.so")) { File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so")); } if (File.Exists("GameLauncherUpdater.exe")) { File.Delete("GameLauncherUpdater.exe"); } try { File.Delete("GL_Update.exe"); File.WriteAllBytes("GL_Update.exe", ExtractResource.AsByte("GameLauncher.Updater.GL_Update.exe")); } catch { } if (!File.Exists("servers.txt")) { try { File.Create("servers.txt"); } catch { } } if (Debugger.IsAttached) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); } 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(); } Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR"); try { if (mutex.WaitOne(0, false)) { String[] files = { "Newtonsoft.Json.dll", "INIFileParser.dll", "Microsoft.WindowsAPICodePack.dll", "Microsoft.WindowsAPICodePack.Shell.dll" }; List <string> missingfiles = new List <string>(); foreach (string file in files) { if (!File.Exists(file)) { missingfiles.Add(file); } } if (missingfiles.Count != 0) { string message = "Cannot launch GameLauncher. The following files are missing:\n\n"; foreach (string file in missingfiles) { message += "• " + file + "\n"; } message += "\nCurrent directory: " + Directory.GetCurrentDirectory(); MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); } else { MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { if (mutex != null) { mutex.Close(); mutex = null; } } } }
private static void Start() { DiscordLauncherPresence.Start("Start Up", null); if (!UnixOS.Detected()) { DiscordLauncherPresence.Status("Start Up", "Checking .NET Framework"); try { /* Check if User has a compatible .NET Framework Installed */ if (int.TryParse(RegistryCore.Read("Release", @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"), out int NetFrame_Version)) { /* For now, allow edge case of Windows 8.0 to run .NET 4.6.1 where upgrading to 8.1 is not possible */ if (WindowsProductVersion.GetWindowsNumber() == 6.2 && NetFrame_Version <= 394254) { if (MessageBox.Show(null, Translations.Database("Program_TextBox_NetFrame_P1") + " .NETFramework, Version=v4.6.1 \n\n" + Translations.Database("Program_TextBox_NetFrame_P2"), "GameLauncher.exe - " + Translations.Database("Program_TextBox_NetFrame_P3"), MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Process.Start("https://dotnet.microsoft.com/download/dotnet-framework/net461"); } FunctionStatus.LauncherForceClose = true; } /* Otherwise, all other OS Versions should have 4.6.2 as a Minimum Version */ else if (NetFrame_Version <= 394802) { if (MessageBox.Show(null, Translations.Database("Program_TextBox_NetFrame_P1") + " .NETFramework, Version=v4.6.2 \n\n" + Translations.Database("Program_TextBox_NetFrame_P2"), "GameLauncher.exe - " + Translations.Database("Program_TextBox_NetFrame_P3"), MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Process.Start("https://dotnet.microsoft.com/download/dotnet-framework"); } FunctionStatus.LauncherForceClose = true; } else { Log.System("NET-FRAMEWORK: Supported Installed Version"); } } else { Log.Warning("NET-FRAMEWORK: Failed to Parse Version"); } } catch { FunctionStatus.LauncherForceClose = true; } } if (FunctionStatus.LauncherForceClose) { FunctionStatus.ErrorCloseLauncher("Closing From .NET Framework Check", false); } else { /* Splash Screen */ if (!Debugger.IsAttached) { /* Starts Splash Screen */ SplashScreen.ThreadStatus("Start"); } LogToFileAddons.RemoveLogs(); Log.StartLogging(); Log.Info("CURRENT DATE: " + Time.GetTime("Date")); Log.Checking("LAUNCHER MIGRATION: Appdata and/or Roaming Folders"); /* Deletes Folders that will Crash the Launcher (Cleanup Migration) */ try { if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "Soapbox_Race_World")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "Soapbox_Race_World")), true); } if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "Soapbox_Race_World")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "Soapbox_Race_World")), true); } if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "SoapBoxRaceWorld")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "SoapBoxRaceWorld")), true); } if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "SoapBoxRaceWorld")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "SoapBoxRaceWorld")), true); } if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "WorldUnited.gg")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "WorldUnited.gg")), true); } if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "WorldUnited.gg")))) { Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "WorldUnited.gg")), true); } } catch (Exception Error) { LogToFileAddons.OpenLog("LAUNCHER MIGRATION", null, Error, null, true); } Log.Completed("LAUNCHER MIGRATION"); Log.Checking("LAUNCHER XML: If File Exists or Not"); DiscordLauncherPresence.Status("Start Up", "Checking if UserSettings XML Exists"); /* Create Default Configuration Files (if they don't already exist) */ if (!File.Exists(Locations.UserSettingsXML)) { try { if (!Directory.Exists(Locations.UserSettingsFolder)) { Directory.CreateDirectory(Locations.UserSettingsFolder); } File.WriteAllBytes(Locations.UserSettingsXML, ExtractResource.AsByte("GameLauncher.Resources.UserSettings.UserSettings.xml")); } catch (Exception Error) { LogToFileAddons.OpenLog("LAUNCHER XML", null, Error, null, true); } } Log.Completed("LAUNCHER XML"); string Insider = string.Empty; if (EnableInsiderDeveloper.Allowed()) { Insider = "DEV TEST "; } else if (EnableInsiderBetaTester.Allowed()) { Insider = "BETA TEST "; } Log.Build(Insider + "BUILD: GameLauncher " + Application.ProductVersion + "_" + InsiderInfo.BuildNumberOnly()); Log.Checking("OS: Detecting"); DiscordLauncherPresence.Status("Start Up", "Checking Operating System"); try { if (UnixOS.Detected()) { InformationCache.OSName = UnixOS.FullName(); Log.System("SYSTEM: Detected OS: " + InformationCache.OSName); } else { InformationCache.OSName = WindowsProductVersion.ConvertWindowsNumberToName(); Log.System("SYSTEM: Detected OS: " + InformationCache.OSName); Log.System("SYSTEM: Windows Build: " + WindowsProductVersion.GetWindowsBuildNumber()); Log.System("SYSTEM: NT Version: " + Environment.OSVersion.VersionString); Log.System("SYSTEM: Video Card: " + HardwareInfo.GPU.CardName()); Log.System("SYSTEM: Driver Version: " + HardwareInfo.GPU.DriverVersion()); } Log.Completed("OS: Detected"); } catch (Exception Error) { LogToFileAddons.OpenLog("SYSTEM", null, Error, null, true); FunctionStatus.LauncherForceCloseReason = "Code: 0\n" + Translations.Database("Program_TextBox_System_Detection") + "\n" + Error.Message; FunctionStatus.LauncherForceClose = true; } if (FunctionStatus.LauncherForceClose) { FunctionStatus.ErrorCloseLauncher("Closing From Operating System Check", false); } else { /* Set Launcher Directory */ Log.Checking("SETUP: Setting Launcher Folder Directory"); Directory.SetCurrentDirectory(Locations.LauncherFolder); Log.Completed("SETUP: Current Directory now Set at -> " + Locations.LauncherFolder); if (!UnixOS.Detected()) { Log.Checking("FOLDER LOCATION: Checking Launcher Folder Directory"); DiscordLauncherPresence.Status("Start Up", "Checking Launcher Folder Locations"); switch (FunctionStatus.CheckFolder(Locations.LauncherFolder)) { case FolderType.IsTempFolder: case FolderType.IsUsersFolders: case FolderType.IsProgramFilesFolder: case FolderType.IsWindowsFolder: case FolderType.IsRootFolder: String Constructed_Msg = String.Empty; Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher") + "\n\n"; Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P2") + "\n"; Constructed_Msg += "• X:\\GameLauncher.exe " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P3") + "\n"; Constructed_Msg += "• C:\\Program Files\n"; Constructed_Msg += "• C:\\Program Files (x86)\n"; Constructed_Msg += "• C:\\Users " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P4") + "\n"; Constructed_Msg += "• C:\\Windows\n\n"; Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P5") + "\n"; Constructed_Msg += "• 'C:\\Soapbox Race World' " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P6") + " 'C:\\SBRW'\n"; Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P7") + "\n\n"; MessageBox.Show(null, Constructed_Msg, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); FunctionStatus.LauncherForceClose = true; break; } Log.Completed("FOLDER LOCATION: Done"); } if (FunctionStatus.LauncherForceClose) { FunctionStatus.ErrorCloseLauncher("Closing From Invalid Launcher Location", false); } else { Log.Checking("WRITE TEST: Launcher Folder Test"); if (!FunctionStatus.HasWriteAccessToFolder(Locations.LauncherFolder)) { MessageBox.Show(Translations.Database("Program_TextBox_Folder_Write_Test")); } Log.Completed("WRITE TEST: Passed"); Log.Checking("INI FILES: Doing Nullsafe"); DiscordLauncherPresence.Status("Start Up", "Doing NullSafe ini Files"); FileSettingsSave.NullSafeSettings(); FileAccountSave.NullSafeAccount(); Log.Completed("INI FILES: Done"); /* Sets up Theming */ Theming.CheckIfThemeExists(); Log.Function("APPLICATION: Setting Language"); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(Translations.UI(Translations.Application_Language = FileSettingsSave.Lang.ToLower(), true)); Log.Completed("APPLICATION: Done Setting Language '" + Translations.UI(Translations.Application_Language) + "'"); /* Windows 7 TLS Check */ if (WindowsProductVersion.GetWindowsNumber() == 6.1) { Log.Checking("SSL/TLS: Windows 7 Detected"); DiscordLauncherPresence.Status("Start Up", "Checking Windows 7 SSL/TLS"); try { String MessageBoxPopupTLS = String.Empty; string keyName = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client"; string subKey = "DisabledByDefault"; if (Registry.GetValue(keyName, subKey, null) == null) { MessageBoxPopupTLS = Translations.Database("Program_TextBox_W7_TLS_P1") + "\n\n"; MessageBoxPopupTLS += "- HKLM/SYSTEM/CurrentControlSet/Control/SecurityProviders\n /SCHANNEL/Protocols/TLS 1.2/Client\n"; MessageBoxPopupTLS += "- Value: DisabledByDefault -> 0\n\n"; MessageBoxPopupTLS += Translations.Database("Program_TextBox_W7_TLS_P2") + "\n\n"; MessageBoxPopupTLS += Translations.Database("Program_TextBox_W7_TLS_P3"); /* There is only 'OK' Available because this IS Required */ if (MessageBox.Show(null, MessageBoxPopupTLS, "SBRW Launcher", MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK) { RegistryCore.Write("DisabledByDefault", 0x0, @"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client"); MessageBox.Show(null, Translations.Database("Program_TextBox_W7_TLS_P4"), "SBRW Launcher", MessageBoxButtons.OK, MessageBoxIcon.Information); } Log.Completed("SSL/TLS: Added Registry Key"); } else { Log.Completed("SSL/TLS: Done"); } } catch (Exception Error) { LogToFileAddons.OpenLog("SSL/TLS", null, Error, null, true); } } /* Windows 7 HotFix Check */ if (WindowsProductVersion.GetWindowsNumber() == 6.1 && string.IsNullOrWhiteSpace(FileSettingsSave.Win7UpdatePatches)) { Log.Checking("HotFixes: Windows 7 Detected"); DiscordLauncherPresence.Status("Start Up", "Checking Windows 7 HotFixes"); try { if (!ManagementSearcher.GetInstalledHotFix("KB3020369") || !ManagementSearcher.GetInstalledHotFix("KB3125574")) { String MessageBoxPopupKB = String.Empty; MessageBoxPopupKB = Translations.Database("Program_TextBox_W7_KB_P1") + "\n"; MessageBoxPopupKB += Translations.Database("Program_TextBox_W7_KB_P2") + "\n\n"; if (!ManagementSearcher.GetInstalledHotFix("KB3020369")) { MessageBoxPopupKB += "- " + Translations.Database("Program_TextBox_W7_KB_P3") + " KB3020369\n"; } if (!ManagementSearcher.GetInstalledHotFix("KB3125574")) { MessageBoxPopupKB += "- " + Translations.Database("Program_TextBox_W7_KB_P3") + " KB3125574\n"; } MessageBoxPopupKB += "\n" + Translations.Database("Program_TextBox_W7_KB_P4") + "\n"; if (MessageBox.Show(null, MessageBoxPopupKB, "SBRW Launcher", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { /* Since it's Informational we just need to know if they clicked 'OK' */ FileSettingsSave.Win7UpdatePatches = "1"; } else { /* or if they clicked 'Cancel' */ FileSettingsSave.Win7UpdatePatches = "0"; } FileSettingsSave.SaveSettings(); } Log.Completed("HotFixes: Done"); } catch (Exception Error) { LogToFileAddons.OpenLog("HotFixes", null, Error, null, true); } } } Log.Checking("JSON: Servers File"); try { if (File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON)))) { if (File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)))) { File.Delete(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON))); } File.Move( Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON)), Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON))); Log.Completed("JSON: Renaming Servers File"); } else if (!File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)))) { try { File.WriteAllText( Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)), "[]"); Log.Completed("JSON: Created Servers File"); } catch (Exception Error) { LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true); } } } catch (Exception Error) { LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true); } Log.Checking("JSON: Done"); 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"); } } Log.Checking("PROXY: Checking if Proxy Is Disabled from User Settings! It's value is " + FileSettingsSave.Proxy); if (FileSettingsSave.Proxy == "0") { Log.Core("PROXY: Starting Proxy (From Startup)"); ServerProxy.Instance.Start("Splash Screen [Program.cs]"); Log.Completed("PROXY: Started"); } else { Log.Completed("PROXY: Disabled"); } Log.Info("REDISTRIBUTABLE: Moved to Function"); /* (Starts Function Chain) Check if Redistributable Packages are Installed */ Redistributable.Check(); } } }
static void Main() { int SysVersion = (int)Environment.OSVersion.Platform; bool mono = DetectLinux.MonoDetected(); bool wine = DetectLinux.WineDetected(); bool linux = DetectLinux.NativeLinuxDetected(); try { } catch { MessageBox.Show("This should fake antivirus :v"); } /*if(Environment.OSVersion.Version.Major <= 5 && !linux) { * MessageBox.Show(null, "Windows XP Support has been terminated. Please upgrade your Operating System to 'Vista' or newer.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning); * Environment.Exit(Environment.ExitCode); * }*/ Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); if (!Directory.Exists("Languages")) { Directory.CreateDirectory("Languages"); } try { File.Delete("Languages/Default.lng"); File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng")); } catch { } try { File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip"); } catch { } if (linux) { MessageBox.Show(null, "Native Linux support is still under alpha stage. Therefore, launcher or game could crash.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (mono == true) { MessageBox.Show(null, "Mono support is still under alpha stage. Therefore, launcher could not launch.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!File.Exists("LZMA.dll")) { File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll")); } if (!linux && !File.Exists("discord-rpc.dll")) { File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll")); } if (linux && !File.Exists("libdiscord-rpc.so")) { File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so")); } if (File.Exists("GameLauncherUpdater.exe")) { File.Delete("GameLauncherUpdater.exe"); } try { File.Delete("GL_Update.exe"); File.WriteAllBytes("GL_Update.exe", ExtractResource.AsByte("GameLauncher.Updater.GL_Update.exe")); } catch { } if (!File.Exists("servers.txt")) { try { File.Create("servers.txt"); } catch { } } if (Debugger.IsAttached) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); } 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(); } Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR"); try { if (mutex.WaitOne(0, false)) { String[] files = { "Newtonsoft.Json.dll", "LZMA.dll" }; List <string> missingfiles = new List <string>(); foreach (string file in files) { if (!File.Exists(file)) { missingfiles.Add(file); } } if (missingfiles.Count != 0) { string message = "Cannot launch GameLauncher. The following files are missing:\n\n"; foreach (string file in missingfiles) { message += "• " + file + "\n"; } message += "\nCurrent directory: " + Directory.GetCurrentDirectory(); message += "\nYou will be moved to the project page for re-download."; MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases"); Environment.Exit(1); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); } else { MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { if (mutex != null) { mutex.Close(); mutex = null; } } } }
internal static void Main() { var linux = DetectLinux.NativeLinuxDetected(); Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException()); if (Self.isTempFolder(Directory.GetCurrentDirectory())) { MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(0); } if (!Directory.Exists("Languages")) { Directory.CreateDirectory("Languages"); } try { File.Delete("Languages/Default.lng"); File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng")); } catch { // ignored } try { File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip"); } catch { // ignored } if (!File.Exists("LZMA.dll")) { File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll")); } if (!linux && !File.Exists("discord-rpc.dll")) { File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll")); } if (linux && !File.Exists("libdiscord-rpc.so")) { File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so")); } if (File.Exists("GL_Update.exe")) { File.Delete("GL_Update.exe"); } if (!File.Exists("GameLauncherUpdater.exe")) { try { File.WriteAllBytes("GameLauncherUpdater.exe", new WebClientWithTimeout().DownloadData("http://launcher.soapboxrace.world/GameLauncherUpdater.exe")); } catch { // ignored } } if (!File.Exists("servers.json")) { try { File.WriteAllText("servers.json", "[]"); } catch { // ignored } } if (Debugger.IsAttached) { ServerProxy.Instance.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainScreen()); } 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 = { "Newtonsoft.Json.dll", "INIFileParser.dll", "Microsoft.WindowsAPICodePack.dll", "Microsoft.WindowsAPICodePack.Shell.dll", "Flurl.dll", "Flurl.Http.dll", "BlackListedServers.dat" }; var missingfiles = new List <string>(); foreach (var file in files) { if (!File.Exists(file)) { missingfiles.Add(file); } } if (missingfiles.Count != 0) { var message = "Cannot launch GameLauncher. The following files are missing:\n\n"; foreach (var file in missingfiles) { message += "• " + file + "\n"; } message += "\nCurrent directory: " + Directory.GetCurrentDirectory(); MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } ServerProxy.Instance.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainScreen()); } else { MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { mutex.Close(); mutex = null; } } }
static void Main() { int SysVersion = (int)Environment.OSVersion.Platform; bool mono = DetectLinux.MonoDetected(); bool wine = DetectLinux.WineDetected(); bool linux = DetectLinux.LinuxDetected(); //Discord fix Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); //Languages if (!File.Exists("Languages")) { Directory.CreateDirectory("Languages"); File.WriteAllText("Languages/Dutch.lng", ExtractResource.AsString("GameLauncher.Languages.Dutch.lng")); File.WriteAllText("Languages/English.lng", ExtractResource.AsString("GameLauncher.Languages.English.lng")); File.WriteAllText("Languages/French.lng", ExtractResource.AsString("GameLauncher.Languages.French.lng")); File.WriteAllText("Languages/German_Formal.lng", ExtractResource.AsString("GameLauncher.Languages.German_Formal.lng")); File.WriteAllText("Languages/German_Informal.lng", ExtractResource.AsString("GameLauncher.Languages.German_Informal.lng")); File.WriteAllText("Languages/Polish.lng", ExtractResource.AsString("GameLauncher.Languages.Polish.lng")); File.WriteAllText("Languages/Portuguese.lng", ExtractResource.AsString("GameLauncher.Languages.Portuguese.lng")); File.WriteAllText("Languages/Spanish.lng", ExtractResource.AsString("GameLauncher.Languages.Spanish.lng")); File.WriteAllText("Languages/Swedish.lng", ExtractResource.AsString("GameLauncher.Languages.Swedish.lng")); } //Remove zip file try { File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip"); } catch { } //Console log with warning if (mono == true) { MessageBox.Show(null, "Mono support is still under alpha stage. Therefore, launcher could not launch.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Add LZMA.dll on the fly (used for decompression of section{int}.dll files) if (!File.Exists("LZMA.dll")) { File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll")); } //Add GameLauncherUpdater.exe on the fly if (!File.Exists("GameLauncherUpdater.exe")) { File.WriteAllBytes("GameLauncherUpdater.exe", ExtractResource.AsByte("GameLauncher.Updater.GameLauncherUpdater.exe")); } //Detect if NFSW is launched 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(); } Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR"); //Forgot about other launchers... try { if (mutex.WaitOne(0, false)) { //First of all, we need to check if files exists String[] files = { "Newtonsoft.Json.dll", "LZMA.dll", "ICSharpCode.SharpZipLib.dll" }; List <string> missingfiles = new List <string>(); foreach (string file in files) { if (!File.Exists(file)) { missingfiles.Add(file); } } if (missingfiles.Count != 0) { string message = "Cannot launch GameLauncher. The following files are missing:\n\n"; foreach (string file in missingfiles) { message += "• " + file + "\n"; } message += "\nCurrent directory: " + Directory.GetCurrentDirectory(); message += "\nYou will be moved to the project page for re-download."; MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases"); Environment.Exit(1); } if (Environment.OSVersion.Version.Major >= 6) { User32.SetProcessDPIAware(); } //try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); //} catch(Exception) { //Temporarely we gonna kill it. // Process.GetProcessById(Process.GetCurrentProcess().Id).Kill(); //} } else { MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { if (mutex != null) { mutex.Close(); mutex = null; } } }
static void Main() { int SysVersion = (int)Environment.OSVersion.Platform; bool mono = DetectLinux.MonoDetected(); bool wine = DetectLinux.WineDetected(); bool linux = DetectLinux.LinuxDetected(); //Remove zip file File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip"); //Console log with warning if (mono == true) { //It will never work under pure mono... so... Application.Exit(); } else if (wine == true) { MessageBox.Show(null, "Wine support is still under alpha stage. Therefore, launcher could not launch.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Add LZMA.dll on the fly (used for decompression of section{int}.dll files) if (!File.Exists("LZMA.dll")) { File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll")); } //Add GameLauncherUpdater.exe on the fly if (!File.Exists("GameLauncherUpdater.exe")) { File.WriteAllBytes("GameLauncherUpdater.exe", ExtractResource.AsByte("GameLauncher.Updater.GameLauncherUpdater.exe")); } //Detect if NFSW is launched Mutex detectRunningNFSW = new Mutex(false, "Global\\{3E34CEFB-7B34-4e62-8034-33256B8BC2F7}"); try { if (!detectRunningNFSW.WaitOne(0, false)) { MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } } finally { if (detectRunningNFSW != null) { detectRunningNFSW.Close(); detectRunningNFSW = null; } } Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR"); //Forgot about other launchers... try { if (mutex.WaitOne(0, false)) { //First of all, we need to check if files exists String[] files = { "Microsoft.WindowsAPICodePack.dll", "Microsoft.WindowsAPICodePack.Shell.dll", "Newtonsoft.Json.dll", "LZMA.dll", "ICSharpCode.SharpZipLib.dll" }; List <string> missingfiles = new List <string>(); foreach (string file in files) { if (!File.Exists(file)) { missingfiles.Add(file); } } if (missingfiles.Count != 0) { string message = "Cannot launch GameLauncher. The following files are missing:\n\n"; foreach (string file in missingfiles) { message += "• " + file + "\n"; } message += "\nCurrent directory: " + Directory.GetCurrentDirectory(); message += "\nYou will be moved to the project page for re-download."; MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start(@"https://github.com/metonator/GameLauncher_NFSW/releases"); Environment.Exit(1); } if (Environment.OSVersion.Version.Major >= 6) { User32.SetProcessDPIAware(); } //try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainScreen()); //} catch(Exception ex) { // if(linux == true) { // extraLinuxInfo = "\n\nAditionally, please report that you're using Wine/Mono Runtime and your Linux Distro"; // } // MessageBox.Show(null, "Failed to launch GameLauncher. " + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace + extraLinuxInfo, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); // Environment.Exit(1); //} } else { MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { if (mutex != null) { mutex.Close(); mutex = null; } } }