private void UpdatePathing(object sender, EventArgs e)
        {
            string correctedGamePath  = AMLUtils.FixGamePath(gamePathBox.Text);
            string correctedLocalPath = AMLUtils.FixBasePath(localPathBox.Text);

            if (string.IsNullOrEmpty(correctedGamePath) || !AMLUtils.IsValidPath(correctedGamePath))
            {
                gamePathBox.Text = BaseForm.ModManager.GamePath;
                this.ShowBasicButton("The specified game path is invalid!", "OK", null, null);
                return;
            }

            if (string.IsNullOrEmpty(correctedLocalPath) || !AMLUtils.IsValidPath(correctedLocalPath))
            {
                localPathBox.Text = BaseForm.ModManager.BasePath;
                this.ShowBasicButton("The specified local path is invalid!", "OK", null, null);
                return;
            }

            BaseForm.ModManager.ValidPlatformTypesToPaths[PlatformType.Custom] = correctedGamePath;
            BaseForm.ModManager.CustomBasePath = correctedLocalPath;
            BaseForm.ModManager.RefreshAllPlatformsList();
            BaseForm.SwitchPlatform(PlatformType.Custom);

            this.UpdateLabels();
        }
        private void RunOKButton()
        {
            PerformPathSubstitutions();

            if (AllowBrowse && !AMLUtils.IsValidPath(gamePathBox.Text))
            {
                ShowWarning("This is not a valid path!");
                return;
            }

            if (gamePathBox.Text != null && gamePathBox.Text.Length > 0)
            {
                var doneText = gamePathBox.Text;
                if (AllowBrowse && doneText[doneText.Length - 1] == Path.DirectorySeparatorChar)
                {
                    doneText = doneText.Substring(0, doneText.Length - 1);
                }
                switch (VerifyMode)
                {
                case VerifyPathMode.Base:
                    doneText = AMLUtils.FixBasePath(doneText);
                    if (string.IsNullOrEmpty(doneText))
                    {
                        ShowWarning("This is not the correct path!");
                        OutputText = null;
                        return;
                    }
                    break;

                case VerifyPathMode.Game:
                    doneText = AMLUtils.FixGamePath(doneText);
                    if (doneText == null)
                    {
                        ShowWarning("This is not the correct path!");
                        OutputText = null;
                        return;
                    }
                    break;
                }

                OutputText        = doneText;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
        public ModHandler(Form1 baseForm)
        {
            BaseForm      = baseForm;
            OurIntegrator = new ModIntegrator();
            OurIntegrator.RefuseMismatchedConnections = true;

            string automaticSteamPath = null;
            string automaticWin10Path = null;

            if (!Program.CommandLineOptions.ServerMode)
            {
                try
                {
                    automaticSteamPath = AMLUtils.FixGamePath(CheckRegistryForSteamPath(361420)); // Astroneer: 361420
                }
                catch { }

                try
                {
                    automaticWin10Path = AMLUtils.FixGamePath(CheckRegistryForMicrosoftStorePath());
                }
                catch { }
            }

            //automaticSteamPath = null;
            //automaticWin10Path = null;

            ValidPlatformTypesToPaths = new Dictionary <PlatformType, string>();
            if (automaticSteamPath != null)
            {
                ValidPlatformTypesToPaths[PlatformType.Steam] = automaticSteamPath;
            }
            if (automaticWin10Path != null)
            {
                ValidPlatformTypesToPaths[PlatformType.Win10] = automaticWin10Path;
            }

            SyncIndependentConfigFromDisk();
            if (!string.IsNullOrEmpty(CustomBasePath))
            {
                string customGamePath = GetGamePathFromBasePath(CustomBasePath);
                if (!string.IsNullOrEmpty(customGamePath))
                {
                    ValidPlatformTypesToPaths[PlatformType.Custom] = customGamePath;
                }
            }

            RefreshAllPlatformsList();
            if (!ValidPlatformTypesToPaths.ContainsKey(Platform) && AllPlatforms.Count > 0)
            {
                Platform = AllPlatforms[0];
            }
            if (Program.CommandLineOptions.ServerMode)
            {
                Platform = PlatformType.Server;
            }

            DeterminePaths();
            SyncModsFromDisk();
            SyncDependentConfigFromDisk();
            VerifyGamePath();

            if (Program.CommandLineOptions.ServerMode && Directory.Exists(Path.Combine(BasePath, "Saved")))
            {
                GamePath = Path.GetFullPath(Path.Combine(BasePath, ".."));
            }

            if (GamePath == null || !Directory.Exists(GamePath))
            {
                GamePath = null;
                if (ValidPlatformTypesToPaths.ContainsKey(Platform))
                {
                    GamePath = ValidPlatformTypesToPaths[Platform];
                }
                else
                {
                    TextPrompt initialPathPrompt = new TextPrompt
                    {
                        StartPosition = FormStartPosition.CenterScreen,
                        DisplayText   = "Select your game installation directory",
                        VerifyMode    = VerifyPathMode.Game
                    };

                    if (initialPathPrompt.ShowDialog(BaseForm) == DialogResult.OK)
                    {
                        GamePath = initialPathPrompt.OutputText;
                        Platform = PlatformType.Custom;
                        ValidPlatformTypesToPaths[PlatformType.Custom] = GamePath;
                        RefreshAllPlatformsList();
                    }
                    else
                    {
                        Environment.Exit(0);
                    }
                }
            }

            ApplyGamePathDerivatives();
            VerifyIntegrity();

            foreach (Mod mod in Mods)
            {
                mod.Dirty = true;
            }
            FullUpdateSynchronous();
            SortMods();
            RefreshAllPriorites();
            SyncConfigToDisk();
        }