コード例 #1
0
ファイル: LauncherLogic.cs プロジェクト: SeanLatimer/Nitrox
        internal void StartMultiplayer()
        {
            gameStarting = true;
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            if (PirateDetection.IsPirate(subnauticaPath))
            {
                if (PirateDetectedEvent != null)
                {
                    PirateDetectedEvent(this, new EventArgs());
                }
                return;
            }

            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove(); // Remove any previous instances first.
            nitroxEntryPatch.Apply();

            StartSubnautica(subnauticaPath);
            Thread thread = new Thread(new ThreadStart(AsyncGetProcess));

            thread.Start();
        }
コード例 #2
0
        public static ActionResult InstallPatch(Session session)
        {
            session.Log("Begin install");

            try
            {
                string managedDirectory = session.CustomActionData["MANAGEDDIR"];

                if (!RequiredAssembliesExist(managedDirectory))
                {
                    MessageBox.Show("Error installing Nitrox to the specified directory. Please ensure the installer is pointing to your subnautica directory and try again.  Attempting to locate managed at: " + managedDirectory);
                    return(ActionResult.Failure);
                }

                NitroxEntryPatch nitroxPatch = new NitroxEntryPatch(managedDirectory);

                NitroxServerSetup.Init(managedDirectory);

                if (!nitroxPatch.IsApplied)
                {
                    nitroxPatch.Apply();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                session.Log(ex.Message);
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: yawaraka/Nitrox
        private void MultiplayerButton_Click(object sender, EventArgs e)
        {
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            if (PirateDetection.IsPirate(subnauticaPath))
            {
                PirateDetected();
                return;
            }

            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove(); // Remove any previous instances first.
            nitroxEntryPatch.Apply();

            StartSubnautica(subnauticaPath);

            //TODO: maybe an async callback to remove when the app closes.
        }
コード例 #4
0
        private void SinglePlayerButton_Click(object sender, EventArgs e)
        {
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            if (PirateDetection.IsPirate(subnauticaPath))
            {
                PirateDetected();
                return;
            }

            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove();

            string subnauticaExe = Path.Combine(subnauticaPath, "Subnautica.exe");

            Process.Start(subnauticaExe);
        }
コード例 #5
0
ファイル: LauncherLogic.cs プロジェクト: SeanLatimer/Nitrox
        internal void StartSingleplayer()
        {
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            if (PirateDetection.IsPirate(subnauticaPath))
            {
                if (PirateDetectedEvent != null)
                {
                    PirateDetectedEvent(this, new EventArgs());
                }
                return;
            }
            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove();

            StartSubnautica(subnauticaPath);
        }
コード例 #6
0
ファイル: LauncherLogic.cs プロジェクト: iF1re12/Nitrox
        internal void StartMultiplayer()
        {
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            if (PirateDetection.IsPirate(subnauticaPath))
            {
                if (PirateDetectedEvent != null)
                {
                    PirateDetectedEvent(this, new EventArgs());
                }
                return;
            }

            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove(); // Remove any previous instances first.
            nitroxEntryPatch.Apply();

            StartSubnautica(subnauticaPath);

            //TODO: maybe an async callback to remove when the app closes.
        }
コード例 #7
0
        public void InstallPatches()
        {
            NitroxEntryPatch nitroxPatch = new NitroxEntryPatch(SubnauticaAssembliesPath);

            if (!nitroxPatch.IsApplied)
            {
                nitroxPatch.Apply();
            }
        }
コード例 #8
0
        public void RemovePatches()
        {
            NitroxEntryPatch nitroxPatch = new NitroxEntryPatch(SubnauticaAssembliesPath);

            if (nitroxPatch.IsApplied)
            {
                nitroxPatch.Remove();
            }
        }
コード例 #9
0
        public async Task <string> SetTargetedSubnauticaPath(string path)
        {
            if (Config.SubnauticaPath == path || !Directory.Exists(path))
            {
                return(null);
            }

            Config.SubnauticaPath = path;

            if (lastFindSubnauticaTask != null)
            {
                await lastFindSubnauticaTask;
            }

            lastFindSubnauticaTask = Task.Factory.StartNew(() =>
            {
                PirateDetection.TriggerOnDirectory(path);

                if (!FileSystem.Instance.IsWritable(Directory.GetCurrentDirectory()) || !FileSystem.Instance.IsWritable(path))
                {
                    // TODO: Move this check to another place where Nitrox installation can be verified. (i.e: another page on the launcher in order to check permissions, network setup, ...)
                    if (!FileSystem.Instance.SetFullAccessToCurrentUser(Directory.GetCurrentDirectory()) || !FileSystem.Instance.SetFullAccessToCurrentUser(path))
                    {
                        Dispatcher.CurrentDispatcher.BeginInvoke(() =>
                        {
                            MessageBox.Show(Application.Current.MainWindow !, "Restart Nitrox Launcher as admin to allow Nitrox to change permissions as needed. This is only needed once. Nitrox will close after this message.", "Required file permission error", MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            Environment.Exit(1);
                        }, DispatcherPriority.ApplicationIdle);
                    }
                }

                // Save game path as preferred for future sessions.
                NitroxUser.PreferredGamePath = path;

                if (nitroxEntryPatch?.IsApplied == true)
                {
                    nitroxEntryPatch.Remove();
                }
                nitroxEntryPatch = new NitroxEntryPatch(() => Config.SubnauticaPath);

                if (Path.GetFullPath(path).StartsWith(WindowsHelper.ProgramFileDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    WindowsHelper.RestartAsAdmin();
                }

                return(path);
            }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());

            return(await lastFindSubnauticaTask);
        }
コード例 #10
0
ファイル: LauncherLogic.cs プロジェクト: SeanLatimer/Nitrox
        private void OnSubnauticaExited(object sender, EventArgs e)
        {
            gameStarting = false;
            string subnauticaPath = "";

            Optional <string> installation = GameInstallationFinder.Instance.FindGame(new List <string>());

            if (!installation.IsPresent())
            {
                MessageBox.Show("Please configure your Subnautica location in settings.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            subnauticaPath = installation.Get();

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Remove();
            Log.Info("Finished removing patches!");
        }
コード例 #11
0
        private void MultiplayerButton_Click(object sender, EventArgs e)
        {
            string subnauticaPath = "";

            if (ErrorConfiguringLaunch(ref subnauticaPath))
            {
                return;
            }

            SyncAssembliesBetweenSubnauticaManagedAndLib(subnauticaPath);

            NitroxEntryPatch nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);

            nitroxEntryPatch.Apply();

            string subnauticaExe = Path.Combine(subnauticaPath, "Subnautica.exe");

            Process.Start(subnauticaExe, "-EpicPortal");

            //TODO: maybe an async callback to remove when the app closes.
        }
コード例 #12
0
        public static ActionResult UninstallPatch(Session session)
        {
            session.Log("Begin uninstall");

            try
            {
                string           managedDirectory = session.CustomActionData["MANAGEDDIR"];
                NitroxEntryPatch nitroxPatch      = new NitroxEntryPatch(managedDirectory);

                if (nitroxPatch.IsApplied)
                {
                    nitroxPatch.Remove();
                }
            }
            catch (Exception ex)
            {
                session.Log(ex.Message);
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
コード例 #13
0
ファイル: LauncherLogic.cs プロジェクト: keik00/Nitrox
 private LauncherLogic(string subnauticaPath)
 {
     this.subnauticaPath = subnauticaPath;
     PirateDetection.TriggerOnDirectory(subnauticaPath);
     nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);
 }