예제 #1
0
        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
        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
        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
        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
 private LauncherLogic(string subnauticaPath)
 {
     this.subnauticaPath = subnauticaPath;
     PirateDetection.TriggerOnDirectory(subnauticaPath);
     nitroxEntryPatch = new NitroxEntryPatch(subnauticaPath);
 }