Пример #1
0
 private void installANewModToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new OpenFileDialog
     {
         Multiselect = false,
         CheckFileExists = true,
         DereferenceLinks = true,
         ValidateNames = true,
         AutoUpgradeEnabled = true,
         Title = "Choose a .dll file or an archive with the mod to install",
         Filter = "Supported mod files(*.dll;*.zipmod;*.zip)|*.dll;*.zipmod;*.zip"
     })
     {
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             try
             {
                 ModInstaller.InstallFromUnknownFile(dialog.FileName);
                 RefreshContents(true, true);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex);
                 MessageBox.Show("Failed to install the selected mod.\n\n" + ex.Message, "Failed to install mod", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 /// <summary>
 /// Removes the given task.
 /// </summary>
 /// <param name="p_tskTask">BasicInstallTask task to remove.</param>
 public void RemoveQueuedTask(ModInstaller p_tskTask)
 {
     if (ModActivationMonitor.CanRemoveQueued(p_tskTask))
     {
         ModActivationMonitor.RemoveQueuedTask(p_tskTask);
     }
 }
Пример #3
0
 /// <summary>
 /// Removes the given task.
 /// </summary>
 /// <param name="p_tskTask">BasicInstallTask task to remove.</param>
 public void RemoveQueuedTask(ModInstaller p_tskTask)
 {
     if (ActivateModsMonitor.CanRemoveQueued(p_tskTask))
     {
         ActivateModsMonitor.RemoveQueuedTask(p_tskTask);
     }
 }
Пример #4
0
        private void Initialize()
        {
            modInstaller = new ModInstaller();

            game = new Game(this);

            fileObserver = new FileObserver(game);

            BuildLabel.Text = GameClient.Build;
        }
Пример #5
0
 /// <summary>
 /// Determines if the given <see cref="BasicInstallTask"/> selected can be removed from
 /// the monitor.
 /// </summary>
 /// <param name="p_tskTask">The task for which it is to be determined
 /// if it can be removed from the monitor.</param>
 /// <returns><c>true</c> if the p_tskTask can be removed;
 /// <c>false</c> otherwise.</returns>
 public bool CanRemoveSelected(ModInstaller p_tskTask)
 {
     if (p_tskTask.IsQueued || p_tskTask.IsCompleted)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #6
0
 /// <summary>
 /// Removes the given task.
 /// </summary>
 /// <param name="p_tskTask">BasicInstallTask task to remove.</param>
 public void RemoveSelectedTask(ModInstaller p_tskTask)
 {
     if (ActivateModsMonitor.CanRemoveSelected(p_tskTask))
     {
         if (p_tskTask.IsCompleted)
         {
             ActivateModsMonitor.RemoveTask(p_tskTask);
         }
         else if (p_tskTask.IsQueued)
         {
             ActivateModsMonitor.RemoveQueuedTask(p_tskTask);
         }
     }
 }
Пример #7
0
        public void FetchMods(string gameVersion, string bsInstall)
        {
            // List all mods for the specified game version
            var filters = BeatModsV1.DefaultFilters;

            filters.Add("gameVersion", gameVersion);

            var m         = BeatModsV1.FetchMods(BeatModsV1.DefaultFilters).OrderBy(mod => mod.name, new Helpers.StringInvariantSortComparerUS()).ToList();
            var installer = new ModInstaller();
            var entries   = new List <ModEntry>();

            foreach (var mm in m)
            {
                var mod = new ModEntry()
                {
                    mod = mm, selected = installer.IsModInstalled(mm, bsInstall)
                };
                entries.Add(mod);
            }

            mods = new ObservableCollection <ModEntry>(entries);
        }
Пример #8
0
 /// <summary>
 /// Sets up the script.
 /// </summary>
 /// <remarks>
 /// This method sets the <see cref="ModInstaller"/> this script will use
 /// to perform its work.
 /// </remarks>
 /// <param name="p_mdiScript">The <see cref="ModInstaller"/> this script will use
 /// to perform its work.</param>
 public static void Setup(ModInstaller p_mdiScript)
 {
     Installer = p_mdiScript;
 }
Пример #9
0
 /// <summary>
 /// Removes the given task (the task is already in queue or running).
 /// </summary>
 /// <param name="p_tskTask">BasicInstallTask task to remove.</param>
 public void RemoveUselessTask(ModInstaller p_tskTask)
 {
     ActivateModsMonitor.RemoveUselessTask(p_tskTask);
 }
Пример #10
0
 /// <summary>
 /// Determines if the given <see cref="BasicInstallTask"/> queued can be removed from
 /// the monitor.
 /// </summary>
 /// <param name="p_tskTask">The task for which it is to be determined
 /// if it can be removed from the monitor.</param>
 /// <returns><c>true</c> if the p_tskTask can be removed;
 /// <c>false</c> otherwise.</returns>
 public bool CanRemoveQueued(ModInstaller p_tskTask)
 {
     return(p_tskTask.IsQueued);
 }
Пример #11
0
 /// <summary>
 /// Determines if the given <see cref="BasicInstallTask"/> can be removed from
 /// the monitor.
 /// </summary>
 /// <param name="p_tskTask">The task for which it is to be determined
 /// if it can be removed from the monitor.</param>
 /// <returns><c>true</c> if the p_tskTask can be removed;
 /// <c>false</c> otherwise.</returns>
 public bool CanRemove(ModInstaller p_tskTask)
 {
     return(p_tskTask.IsCompleted);
 }
Пример #12
0
 /// <summary>
 /// Removes a useless task (the task is already in queue or running).
 /// </summary>
 public void RemoveUselessTask(ModInstaller p_tskTask)
 {
     m_oclTasks.Remove(p_tskTask);
 }
Пример #13
0
 /// <summary>
 /// Removes a task from the monitor.
 /// </summary>
 /// <remarks>
 /// Tasks can only be removed if they are not running.
 /// </remarks>
 /// <param name="p_tskTask">The task to remove.</param>
 public void RemoveQueuedTask(ModInstaller p_tskTask)
 {
     m_oclTasks.Remove(p_tskTask);
 }
Пример #14
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 :)";
            });
        }
 /// <summary>
 /// Removes the given task (the task is already in queue or running).
 /// </summary>
 /// <param name="p_tskTask">BasicInstallTask task to remove.</param>
 public void RemoveUselessTask(ModInstaller p_tskTask)
 {
     ModActivationMonitor.RemoveUselessTask(p_tskTask);
 }