internal async Task StartMultiplayerAsync() { if (string.IsNullOrWhiteSpace(Config.SubnauticaPath) || !Directory.Exists(Config.SubnauticaPath)) { NavigateTo <OptionPage>(); throw new Exception("Location of Subnautica is unknown. Set the path to it in settings."); } if (Config.IsPirated) { throw new Exception("Aarrr ! Nitrox walked the plank :("); } #if RELEASE if (Process.GetProcessesByName("Subnautica").Length > 0) { throw new Exception("An instance of Subnautica is already running"); } #endif // TODO: The launcher should override FileRead win32 API for the Subnautica process to give it the modified Assembly-CSharp from memory string initDllName = "NitroxPatcher.dll"; try { File.Copy( Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "lib", initDllName), Path.Combine(Config.SubnauticaPath, "Subnautica_Data", "Managed", initDllName), true ); } catch (IOException ex) { Log.Error(ex, "Unable to move initialization dll to Managed folder. Still attempting to launch because it might exist from previous runs."); } // Try inject Nitrox into Subnautica code. if (lastFindSubnauticaTask != null) { await lastFindSubnauticaTask; } if (nitroxEntryPatch == null) { throw new Exception("Nitrox was blocked by another program"); } nitroxEntryPatch.Remove(); nitroxEntryPatch.Apply(); if (QModHelper.IsQModInstalled(Config.SubnauticaPath)) { Log.Warn("Seems like QModManager is Installed"); LauncherNotifier.Info("Detected QModManager in the game folder"); } gameProcess = await StartSubnauticaAsync(); }
public void Dispose() { Application.Current.MainWindow?.Hide(); try { nitroxEntryPatch.Remove(); } catch (Exception ex) { Log.Error(ex, "Error while disposing the launcher"); } gameProcess?.Dispose(); Server?.Dispose(); LauncherNotifier.Shutdown(); }
public async void CheckNitroxVersion() { await Task.Factory.StartNew(async() => { Version latestVersion = await Downloader.GetNitroxLatestVersion(); Version currentVersion = new(Version); if (latestVersion > currentVersion) { Config.IsUpToDate = false; Log.Info($"A new version of the mod ({latestVersion}) is available"); LauncherNotifier.Warning($"A new version of the mod ({latestVersion}) is available", new ToastNotifications.Core.MessageOptions() { NotificationClickAction = (n) => { NavigateTo <UpdatePage>(); }, }); } }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }