Ejemplo n.º 1
0
        private void syncButton_Click(object sender, EventArgs e)
        {
            if (ModManager.IsReadOnly)
            {
                this.ShowBasicButton("You cannot sync mods while the game is open!", "OK", null, null);
                return;
            }

            if (CurrentlySyncing)
            {
                this.ShowBasicButton("Please wait, the mod loader is currently busy syncing.", "OK", null, null);
                return;
            }

            TextPrompt getIPPrompt = new TextPrompt();

            getIPPrompt.DisplayText   = "Enter a server address to sync with:";
            getIPPrompt.Width        -= 100;
            getIPPrompt.AllowBrowse   = false;
            getIPPrompt.StartPosition = FormStartPosition.Manual;
            getIPPrompt.Location      = new Point((this.Location.X + this.Width / 2) - (getIPPrompt.Width / 2), (this.Location.Y + this.Height / 2) - (getIPPrompt.Height / 2));

            if (getIPPrompt.ShowDialog(this) == DialogResult.OK)
            {
                ServerSyncPopup waiting = new ServerSyncPopup();
                waiting.StartPosition = FormStartPosition.Manual;
                waiting.Location      = new Point((this.Location.X + this.Width / 2) - (waiting.Width / 2), (this.Location.Y + this.Height / 2) - (waiting.Height / 2));
                waiting.OurIP         = getIPPrompt.OutputText.Trim();

                syncErrored            = true;
                syncErrorMessage       = "The syncing process halted prematurely!";
                syncFailedDownloadMods = null;
                syncKosherProfileName  = "";

                waiting.ShowDialog(this);

                CurrentlySyncing = false;
                ModManager.SyncConfigToDisk();
                TableManager.Refresh();

                if (syncErrored)
                {
                    this.ShowBasicButton(syncErrorMessage, "OK", null, null);
                }
                else
                {
                    int syncFailedDownloadCount = syncFailedDownloadMods.Length;
                    if (syncFailedDownloadCount == 0)
                    {
                        this.ShowBasicButton("Added a new profile named \"" + syncKosherProfileName + "\".\nNo mods failed to sync.", "OK", null, null);
                    }
                    else
                    {
                        this.ShowBasicButton("Added a new profile named \"" + syncKosherProfileName + "\".\n\n" + syncFailedDownloadCount.ToString() + " mod" + (syncFailedDownloadCount == 1 ? "" : "s") + " failed to sync:\n" + string.Join("\n", syncFailedDownloadMods).Trim(), "OK", null, null);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void newProfileButton_Click(object sender, EventArgs e)
        {
            if (OurParentForm == null)
            {
                return;
            }

            TextPrompt profileNamePrompt = new TextPrompt();

            profileNamePrompt.StartPosition = FormStartPosition.Manual;
            profileNamePrompt.Location      = new Point((this.Location.X + this.Width / 2) - (profileNamePrompt.Width / 2), (this.Location.Y + this.Height / 2) - (profileNamePrompt.Height / 2));
            profileNamePrompt.Text          = OurParentForm.Text;
            profileNamePrompt.AllowBrowse   = false;
            profileNamePrompt.Width        -= 100;
            profileNamePrompt.DisplayText   = "Name this profile:";
            if (profileNamePrompt.ShowDialog(this) == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(profileNamePrompt.OutputText))
                {
                    return;
                }
                if (OurParentForm.ModManager.ProfileList.ContainsKey(profileNamePrompt.OutputText))
                {
                    int dialogResult = this.ShowBasicButton("Do you want to overwrite this profile?", "Yes", "No", null);
                    if (dialogResult == 0)
                    {
                        OurParentForm.ModManager.ProfileList[profileNamePrompt.OutputText] = OurParentForm.ModManager.GenerateProfile();
                        OurParentForm.ModManager.SyncConfigToDisk();
                        RefreshBox();
                        statusLabel.Text = "Successfully overwrote profile.";
                    }
                    else
                    {
                        statusLabel.Text = "";
                    }
                    return;
                }
                OurParentForm.ModManager.ProfileList.Add(profileNamePrompt.OutputText, OurParentForm.ModManager.GenerateProfile());
                OurParentForm.ModManager.SyncConfigToDisk();
                RefreshBox();
                statusLabel.Text = "Successfully created profile.";
            }
        }
Ejemplo 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();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        private async void playButton_Click(object sender, EventArgs e)
        {
            ModManager.IsUpdatingAvailableVersionsFromIndexFilesWaitHandler.WaitOne(3000);

            await ModManager.FullUpdate();

            if (!Program.CommandLineOptions.ServerMode)
            {
                if (ModManager.Platform == PlatformType.Steam)
                {
                    Process.Start(@"steam://run/361420");
                    return;
                }
                else if (ModManager.Platform == PlatformType.Win10)
                {
                    if (!string.IsNullOrEmpty(ModManager.MicrosoftRuntimeID))
                    {
                        Process.Start(@"shell:appsFolder\" + ModManager.MicrosoftRuntimeID + "!ASTRONEER");
                    }
                    return;
                }
            }

            if ((Program.CommandLineOptions.ServerMode || AMLUtils.IsLinux || string.IsNullOrEmpty(ModManager.BinaryFilePath)) && string.IsNullOrEmpty(ModManager.LaunchCommand))
            {
                TextPrompt initialPathPrompt = new TextPrompt
                {
                    StartPosition = FormStartPosition.CenterScreen,
                    DisplayText   = "Select a file to run:",
                    AllowBrowse   = true,
                    BrowseMode    = BrowseMode.File
                };

                if (initialPathPrompt.ShowDialog(this) == DialogResult.OK)
                {
                    ModManager.LaunchCommand = initialPathPrompt.OutputText;
                    ModManager.SyncConfigToDisk();
                }
            }

            if (string.IsNullOrEmpty(ModManager.LaunchCommand) && !string.IsNullOrEmpty(ModManager.BinaryFilePath))
            {
                Process.Start(ModManager.BinaryFilePath, Program.CommandLineOptions.ServerMode ? "-log" : "");
            }
            else
            {
                if (string.IsNullOrEmpty(ModManager.LaunchCommand))
                {
                    return;
                }
                try
                {
                    Process.Start(new ProcessStartInfo()
                    {
                        WorkingDirectory = Path.GetDirectoryName(ModManager.LaunchCommand),
                        FileName         = ModManager.LaunchCommand
                    });
                }
                catch
                {
                    this.ShowBasicButton("Invalid path to file: \"" + ModManager.LaunchCommand + "\"", "OK", null, null);
                    ModManager.LaunchCommand = null;
                    ModManager.SyncConfigToDisk();
                }
            }
        }