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();
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        public void DeterminePaths()
        {
            string normalSteamBasePath          = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Astro");
            string normalMicrosoftStoreBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Packages", "SystemEraSoftworks.29415440E1269_ftk5pbg2rayv2", "LocalState", "Astro");

            BasePath = null;
            if (!string.IsNullOrEmpty(Program.CommandLineOptions.LocalDataPath))
            {
                BasePath = AMLUtils.FixBasePath(Path.GetFullPath(Path.Combine(Program.CommandLineOptions.LocalDataPath, "Astro")));
            }
            else
            {
                if (Program.CommandLineOptions.ServerMode)
                {
                    BasePath = Path.Combine(GamePath != null ? GamePath : Directory.GetCurrentDirectory(), "Astro");
                }
                else if (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) != null)
                {
                    switch (Platform)
                    {
                    case PlatformType.Steam:
                        BasePath = normalSteamBasePath;
                        break;

                    case PlatformType.Win10:
                        BasePath = normalMicrosoftStoreBasePath;
                        break;
                    }
                }
            }

            if (BasePath == null || !Directory.Exists(BasePath))
            {
                if (Platform == PlatformType.Custom || Platform == PlatformType.Unknown)
                {
                    if (!string.IsNullOrEmpty(CustomBasePath))
                    {
                        BasePath = CustomBasePath;
                    }
                    else
                    {
                        // If the regular Steam or Microsoft Store base paths do exist, they're probably what the user actually wants, but we still want to give them the option to change it here so we just put it in as prefilled text

                        TextPrompt initialPathPrompt = new TextPrompt
                        {
                            StartPosition = FormStartPosition.CenterScreen,
                            DisplayText   = "Select your local application data directory",
                            PrefilledText = Directory.Exists(normalSteamBasePath) ? normalSteamBasePath : (Directory.Exists(normalMicrosoftStoreBasePath) ? normalMicrosoftStoreBasePath : null),
                            VerifyMode    = VerifyPathMode.Base
                        };

                        if (initialPathPrompt.ShowDialog(BaseForm) == DialogResult.OK)
                        {
                            CustomBasePath = initialPathPrompt.OutputText;
                            BasePath       = CustomBasePath;
                        }
                        else
                        {
                            Environment.Exit(0);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Unable to find the local application data directory. If you have never created an Astroneer save file within the game on this computer before, please do so and then re-open AstroModLoader. Otherwise, please specify a local application data directory with the --data parameter.", "Uh oh!");
                    Environment.Exit(0);
                }
            }

            DetermineBasePathDerivatives();
        }