Exemplo n.º 1
0
    IEnumerator DoInstallDownloadedMod(string modname, string modpath)
    {
        Debug.Log("installing " + modname + "at " + modpath);
        status.text = "Installing " + modname;

        yield return(new WaitForSeconds(.1f));

        string defaultInstallPath = downloader.GetDefaultInstallPathByModByName(modname);

        //TODO: post a warning about the conflit and resolution/removal for users

        //remove mods that conflit with this mod
        CheckAndResolveConflicts(modname);

        //install this mod
        //TODO: correctly handle a failed install
        installer.InstallMod(modpath, modname, defaultInstallPath);

        UpdateModListState(modname, true);

        List <string> dependencies = downloader.GetModDependenciesByName(modname);

        modInstaller = null;

        //does it have dependencies?
        if (dependencies.Count > 0)
        {
            //see if we need to get them
            foreach (string s in dependencies)
            {
                Debug.Log("Queuing dependency for download: " + s);
                //is the mod already installed? if so skip queuing it
                if (settings.GetInstalledModByName(s) != null)
                {
                    continue;
                }

                //don't double download
                if (!queuedDepencencyDownloads.Contains(s))
                {
                    queuedDepencencyDownloads.Add(s);
                }
            }
        }

        yield break;
    }
Exemplo n.º 2
0
        /// <summary>
        /// Perform mod installation actions
        /// Will consume the contents of ModsToInstall
        /// </summary>
        public void InstallMods(string bsInstall)
        {
            // TODO: For now just fire off the work as async, let the user decide if they want to quit halfway through the process
            // TODO: This should have a progress bar, loading spinner, etc
            Task.Run(() =>
            {
                ModInstaller installer = new ModInstaller();
                foreach (var m in ModsToInstall)
                {
                    CurrentMod = $"Current Mod: {m.mod.name}";

                    if (m.selected)
                    {
                        CurrentStep = $"Current Step: Install";
                        if (!installer.InstallMod(m.mod, bsInstall, LogLine))
                        {
                            installLogText += $"{m.mod.name}: Install failed\n";
                            this.RaisePropertyChanged(nameof(InstallLogText));
                            continue;
                        }
                        else
                        {
                            installLogText += $"{m.mod.name}: Installed\n";
                            this.RaisePropertyChanged(nameof(InstallLogText));
                        }

                        CurrentStep = $"Current Step: Validate";
                        if (!installer.ValidateMod(m.mod, bsInstall, LogLine))
                        {
                            installLogText += $"{m.mod.name}: Validate failed (todo)\n";
                            this.RaisePropertyChanged(nameof(InstallLogText));
                            continue;
                        }
                        else
                        {
                            installLogText += $"{m.mod.name}: Validated\n";
                            this.RaisePropertyChanged(nameof(InstallLogText));
                        }

                        if (m.mod.name.Equals("BSIPA"))
                        {
                            CurrentStep = $"Current Step: Patch Beat Saber";
                            if (!installer.PatchBeatSaber(bsInstall, LogLine))
                            {
                                // If this setup step has failed then no mods will work in the game
                                // The most likely reason is the proton prefix is missing
                                // Which will happen if the game hasn't been run first
                                // before the mods were installed
                                installLogText += $"{m.mod.name}: Patching failed\n";

                                installLogText += $"\n\nSorry, looks like patching failed\n";
                                installLogText += $"Your installed mods will not work\n";
                                installLogText += $"First try a fresh install (Run the game once before Beataroni)\n";
                                installLogText += $"Then if it still fails please raise a bug at:\n";
                                installLogText += $"https://github.com/geefr/beatsaber-linux-goodies\n\n";

                                CurrentMod  = "ERROR: Setup Failed";
                                CurrentStep = "";

                                this.RaisePropertyChanged(nameof(InstallLogText));
                                return;
                            }
                            else
                            {
                                installLogText += $"{m.mod.name}: Patching succeeded\n";
                                this.RaisePropertyChanged(nameof(InstallLogText));
                            }
                        }
                    }
                    else
                    {
                        // TODO: At the moment we don't log anything here to avoid user-spam
                        // Do they really care if a mod was uninstalled? Really it's just a pass
                        // over the list to ensure what's installed matches the user's selection
                        installer.UninstallMod(m.mod, bsInstall, LogLine);
                    }
                }

                CurrentMod  = "SUCCESS: Setup Completed";
                CurrentStep = "Please Check the log below, if all is good go and enjoy your mods :)";
            });
        }